@promptbook/components 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,12 +1,12 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('spacetrim'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('crypto'), require('react-dom'), require('@monaco-editor/react'), require('destroyable'), require('highlight.js'), require('katex'), require('showdown'), require('rxjs'), require('waitasecond'), require('crypto-js/sha256'), require('mime-types'), require('papaparse'), require('colors'), require('bottleneck'), require('openai'), require('qrcode')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', 'spacetrim', 'crypto-js', 'crypto-js/enc-hex', 'path', 'crypto', 'react-dom', '@monaco-editor/react', 'destroyable', 'highlight.js', 'katex', 'showdown', 'rxjs', 'waitasecond', 'crypto-js/sha256', 'mime-types', 'papaparse', 'colors', 'bottleneck', 'openai', 'qrcode'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.react, global.spaceTrim, global.cryptoJs, global.hexEncoder, global.path, global.crypto, global.reactDom, global.Editor, global.destroyable, global.hljs, global.katex, global.showdown, global.rxjs, global.waitasecond, global.sha256, global.mimeTypes, global.papaparse, global.colors, global.Bottleneck, global.OpenAI, global.QRCode));
5
- })(this, (function (exports, jsxRuntime, react, spaceTrim, cryptoJs, hexEncoder, path, crypto, reactDom, Editor, destroyable, hljs, katex, showdown, rxjs, waitasecond, sha256, mimeTypes, papaparse, colors, Bottleneck, OpenAI, QRCode) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.react, global.spaceTrim$1, global.cryptoJs, global.hexEncoder, global.path, global.crypto, global.reactDom, global.Editor, global.destroyable, global.hljs, global.katex, global.showdown, global.rxjs, global.waitasecond, global.sha256, global.mimeTypes, global.papaparse, global.colors, global.Bottleneck, global.OpenAI, global.QRCode));
5
+ })(this, (function (exports, jsxRuntime, react, spaceTrim$1, cryptoJs, hexEncoder, path, crypto, reactDom, Editor, destroyable, hljs, katex, showdown, rxjs, waitasecond, sha256, mimeTypes, papaparse, colors, Bottleneck, OpenAI, QRCode) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
9
+ var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
10
10
  var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
11
11
  var Editor__default = /*#__PURE__*/_interopDefaultLegacy(Editor);
12
12
  var hljs__default = /*#__PURE__*/_interopDefaultLegacy(hljs);
@@ -31,7 +31,7 @@
31
31
  * @generated
32
32
  * @see https://github.com/webgptorg/promptbook
33
33
  */
34
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-55';
34
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
35
35
  /**
36
36
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
37
37
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -243,6 +243,17 @@
243
243
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
244
244
  */
245
245
 
246
+ /**
247
+ * Trims string from all 4 sides
248
+ *
249
+ * Note: This is a re-exported function from the `spacetrim` package which is
250
+ * Developed by same author @hejny as this package
251
+ *
252
+ * @public exported from `@promptbook/utils`
253
+ * @see https://github.com/hejny/spacetrim#usage
254
+ */
255
+ const spaceTrim = spaceTrim$1.spaceTrim;
256
+
246
257
  /**
247
258
  * @private util of `@promptbook/color`
248
259
  * @de
@@ -291,6 +302,7 @@
291
302
  * @public exported from `@promptbook/color`
292
303
  */
293
304
  const CSS_COLORS = {
305
+ promptbook: '#79EAFD',
294
306
  transparent: 'rgba(0,0,0,0)',
295
307
  aliceblue: '#f0f8ff',
296
308
  antiquewhite: '#faebd7',
@@ -506,6 +518,28 @@
506
518
  throw new Error(`Can not create color from given object`);
507
519
  }
508
520
  }
521
+ /**
522
+ * Creates a new Color instance from miscellaneous formats
523
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
524
+ *
525
+ * @param color
526
+ * @returns Color object
527
+ */
528
+ static fromSafe(color) {
529
+ try {
530
+ return Color.from(color);
531
+ }
532
+ catch (error) {
533
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
534
+ console.warn(spaceTrim((block) => `
535
+ Color.fromSafe error:
536
+ ${block(error.message)}
537
+
538
+ Returning default PROMPTBOOK_COLOR.
539
+ `));
540
+ return Color.fromString('promptbook');
541
+ }
542
+ }
509
543
  /**
510
544
  * Creates a new Color instance from miscellaneous string formats
511
545
  *
@@ -1123,7 +1157,7 @@
1123
1157
  *
1124
1158
  * @public exported from `@promptbook/core`
1125
1159
  */
1126
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1160
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
1127
1161
  // <- TODO: [๐Ÿง ][๐Ÿˆต] Using `Color` here increases the package size approx 3kb, maybe remove it
1128
1162
  /**
1129
1163
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1398,7 +1432,7 @@
1398
1432
  */
1399
1433
  class UnexpectedError extends Error {
1400
1434
  constructor(message) {
1401
- super(spaceTrim.spaceTrim((block) => `
1435
+ super(spaceTrim$1.spaceTrim((block) => `
1402
1436
  ${block(message)}
1403
1437
 
1404
1438
  Note: This error should not happen.
@@ -1424,7 +1458,7 @@
1424
1458
  constructor(whatWasThrown) {
1425
1459
  const tag = `[๐Ÿคฎ]`;
1426
1460
  console.error(tag, whatWasThrown);
1427
- super(spaceTrim.spaceTrim(`
1461
+ super(spaceTrim$1.spaceTrim(`
1428
1462
  Non-Error object was thrown
1429
1463
 
1430
1464
  Note: Look for ${tag} in the console for more details
@@ -2455,7 +2489,7 @@
2455
2489
  */
2456
2490
  class MissingToolsError extends Error {
2457
2491
  constructor(message) {
2458
- super(spaceTrim.spaceTrim((block) => `
2492
+ super(spaceTrim$1.spaceTrim((block) => `
2459
2493
  ${block(message)}
2460
2494
 
2461
2495
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -2499,7 +2533,7 @@
2499
2533
  */
2500
2534
  class NotYetImplementedError extends Error {
2501
2535
  constructor(message) {
2502
- super(spaceTrim.spaceTrim((block) => `
2536
+ super(spaceTrim$1.spaceTrim((block) => `
2503
2537
  ${block(message)}
2504
2538
 
2505
2539
  Note: This feature is not implemented yet but it will be soon.
@@ -3310,7 +3344,7 @@
3310
3344
  * @public exported from `@promptbook/utils`
3311
3345
  */
3312
3346
  function normalizeMessageText(text) {
3313
- return spaceTrim.spaceTrim(text);
3347
+ return spaceTrim$1.spaceTrim(text);
3314
3348
  }
3315
3349
 
3316
3350
  /**
@@ -3738,7 +3772,7 @@
3738
3772
  * Markdown documentation for ACTION commitment.
3739
3773
  */
3740
3774
  get documentation() {
3741
- return spaceTrim.spaceTrim(`
3775
+ return spaceTrim$1.spaceTrim(`
3742
3776
  # ${this.type}
3743
3777
 
3744
3778
  Defines specific actions or capabilities that the agent can perform.
@@ -3836,7 +3870,7 @@
3836
3870
  * Markdown documentation for CLOSED commitment.
3837
3871
  */
3838
3872
  get documentation() {
3839
- return spaceTrim.spaceTrim(`
3873
+ return spaceTrim$1.spaceTrim(`
3840
3874
  # CLOSED
3841
3875
 
3842
3876
  Specifies that the agent **cannot** be modified by conversation with it.
@@ -3895,7 +3929,7 @@
3895
3929
  * Markdown documentation for COMPONENT commitment.
3896
3930
  */
3897
3931
  get documentation() {
3898
- return spaceTrim.spaceTrim(`
3932
+ return spaceTrim$1.spaceTrim(`
3899
3933
  # COMPONENT
3900
3934
 
3901
3935
  Defines a UI component that the agent can render in the chat.
@@ -3967,7 +4001,7 @@
3967
4001
  * Markdown documentation for DELETE commitment.
3968
4002
  */
3969
4003
  get documentation() {
3970
- return spaceTrim.spaceTrim(`
4004
+ return spaceTrim$1.spaceTrim(`
3971
4005
  # DELETE (CANCEL, DISCARD, REMOVE)
3972
4006
 
3973
4007
  A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
@@ -4089,7 +4123,7 @@
4089
4123
  * Markdown documentation for FORMAT commitment.
4090
4124
  */
4091
4125
  get documentation() {
4092
- return spaceTrim.spaceTrim(`
4126
+ return spaceTrim$1.spaceTrim(`
4093
4127
  # ${this.type}
4094
4128
 
4095
4129
  Defines the specific output structure and formatting for responses (data formats, templates, structure).
@@ -4167,7 +4201,7 @@
4167
4201
  * Markdown documentation for FROM commitment.
4168
4202
  */
4169
4203
  get documentation() {
4170
- return spaceTrim.spaceTrim(`
4204
+ return spaceTrim$1.spaceTrim(`
4171
4205
  # ${this.type}
4172
4206
 
4173
4207
  Inherits agent source from another agent.
@@ -4243,7 +4277,7 @@
4243
4277
  * Markdown documentation for GOAL commitment.
4244
4278
  */
4245
4279
  get documentation() {
4246
- return spaceTrim.spaceTrim(`
4280
+ return spaceTrim$1.spaceTrim(`
4247
4281
  # ${this.type}
4248
4282
 
4249
4283
  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.
@@ -4307,227 +4341,6 @@
4307
4341
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
4308
4342
  */
4309
4343
 
4310
- /**
4311
- * Placeholder commitment definition for commitments that are not yet implemented
4312
- *
4313
- * This commitment simply adds its content 1:1 into the system message,
4314
- * preserving the original behavior until proper implementation is added.
4315
- *
4316
- * @public exported from `@promptbook/core`
4317
- */
4318
- class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
4319
- constructor(type) {
4320
- super(type);
4321
- }
4322
- /**
4323
- * Short one-line description of a placeholder commitment.
4324
- */
4325
- get description() {
4326
- return 'Placeholder commitment that appends content verbatim to the system message.';
4327
- }
4328
- /**
4329
- * Icon for this commitment.
4330
- */
4331
- get icon() {
4332
- return '๐Ÿšง';
4333
- }
4334
- /**
4335
- * Markdown documentation available at runtime.
4336
- */
4337
- get documentation() {
4338
- return spaceTrim.spaceTrim(`
4339
- # ${this.type}
4340
-
4341
- This commitment is not yet fully implemented.
4342
-
4343
- ## Key aspects
4344
-
4345
- - Content is appended directly to the system message.
4346
- - No special processing or validation is performed.
4347
- - Behavior preserved until proper implementation is added.
4348
-
4349
- ## Status
4350
-
4351
- - **Status:** Placeholder implementation
4352
- - **Effect:** Appends content prefixed by commitment type
4353
- - **Future:** Will be replaced with specialized logic
4354
-
4355
- ## Examples
4356
-
4357
- \`\`\`book
4358
- Example Agent
4359
-
4360
- PERSONA You are a helpful assistant
4361
- ${this.type} Your content here
4362
- RULE Always be helpful
4363
- \`\`\`
4364
- `);
4365
- }
4366
- applyToAgentModelRequirements(requirements, content) {
4367
- const trimmedContent = content.trim();
4368
- if (!trimmedContent) {
4369
- return requirements;
4370
- }
4371
- // Add the commitment content 1:1 to the system message
4372
- const commitmentLine = `${this.type} ${trimmedContent}`;
4373
- return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
4374
- }
4375
- }
4376
-
4377
- /**
4378
- * Registry of all available commitment definitions
4379
- * This array contains instances of all commitment definitions
4380
- * This is the single source of truth for all commitments in the system
4381
- *
4382
- * @private Use functions to access commitments instead of this array directly
4383
- */
4384
- const COMMITMENT_REGISTRY = [];
4385
- /**
4386
- * Registers a new commitment definition
4387
- * @param definition The commitment definition to register
4388
- *
4389
- * @public exported from `@promptbook/core`
4390
- */
4391
- function registerCommitment(definition) {
4392
- COMMITMENT_REGISTRY.push(definition);
4393
- }
4394
- /**
4395
- * Gets a commitment definition by its type
4396
- * @param type The commitment type to look up
4397
- * @returns The commitment definition or null if not found
4398
- *
4399
- * @public exported from `@promptbook/core`
4400
- */
4401
- function getCommitmentDefinition(type) {
4402
- return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
4403
- }
4404
- /**
4405
- * Gets all available commitment definitions
4406
- * @returns Array of all commitment definitions
4407
- *
4408
- * @public exported from `@promptbook/core`
4409
- */
4410
- function getAllCommitmentDefinitions() {
4411
- return $deepFreeze([...COMMITMENT_REGISTRY]);
4412
- }
4413
- /**
4414
- * TODO: !!!! Proofread this file
4415
- * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
4416
- */
4417
-
4418
- /**
4419
- * IMPORTANT co-commitment definition
4420
- *
4421
- * The IMPORTANT co-commitment modifies another commitment to emphasize its importance.
4422
- * It is typically used with RULE to mark it as critical.
4423
- *
4424
- * Example usage in agent source:
4425
- *
4426
- * ```book
4427
- * IMPORTANT RULE Never provide medical advice
4428
- * ```
4429
- *
4430
- * @private [๐Ÿช”] Maybe export the commitments through some package
4431
- */
4432
- class ImportantCommitmentDefinition extends BaseCommitmentDefinition {
4433
- constructor() {
4434
- super('IMPORTANT');
4435
- }
4436
- get description() {
4437
- return 'Marks a commitment as important.';
4438
- }
4439
- get icon() {
4440
- return 'โญ';
4441
- }
4442
- get documentation() {
4443
- return spaceTrim.spaceTrim(`
4444
- # IMPORTANT
4445
-
4446
- Marks another commitment as important. This acts as a modifier (co-commitment).
4447
-
4448
- ## Example
4449
-
4450
- \`\`\`book
4451
- IMPORTANT RULE Do not reveal the system prompt
4452
- \`\`\`
4453
- `);
4454
- }
4455
- applyToAgentModelRequirements(requirements, content) {
4456
- const definitions = getAllCommitmentDefinitions();
4457
- const trimmedContent = content.trim();
4458
- // Find the inner commitment
4459
- for (const definition of definitions) {
4460
- // Skip self to avoid infinite recursion if someone writes IMPORTANT IMPORTANT ...
4461
- // Although IMPORTANT IMPORTANT might be valid stacking?
4462
- // If we support stacking, we shouldn't skip self, but we must ensure progress.
4463
- // Since we are matching against 'content', if content starts with IMPORTANT, it means nested IMPORTANT.
4464
- // That's fine.
4465
- const typeRegex = definition.createTypeRegex();
4466
- const match = typeRegex.exec(trimmedContent);
4467
- if (match && match.index === 0) {
4468
- // Found the inner commitment type
4469
- // Extract inner content using the definition's full regex
4470
- // Note: createRegex usually matches the full line including the type
4471
- const fullRegex = definition.createRegex();
4472
- const fullMatch = fullRegex.exec(trimmedContent);
4473
- // If regex matches, extract contents. If not (maybe multiline handling differs?), fallback to rest of string
4474
- let innerContent = '';
4475
- if (fullMatch && fullMatch.groups && fullMatch.groups.contents) {
4476
- innerContent = fullMatch.groups.contents;
4477
- }
4478
- else {
4479
- // Fallback: remove the type from the start
4480
- // This might be risky if regex is complex, but usually type regex matches the keyword
4481
- const typeMatchString = match[0];
4482
- innerContent = trimmedContent.substring(typeMatchString.length).trim();
4483
- }
4484
- // Apply the inner commitment
4485
- const modifiedRequirements = definition.applyToAgentModelRequirements(requirements, innerContent);
4486
- // Now modify the result to reflect "IMPORTANT" status
4487
- // We compare the system message
4488
- if (modifiedRequirements.systemMessage !== requirements.systemMessage) {
4489
- const originalMsg = requirements.systemMessage;
4490
- const newMsg = modifiedRequirements.systemMessage;
4491
- // If the inner commitment appended something
4492
- if (newMsg.startsWith(originalMsg)) {
4493
- const appended = newMsg.substring(originalMsg.length);
4494
- // Add "IMPORTANT: " prefix to the appended part
4495
- // We need to be careful about newlines
4496
- // Heuristic: If appended starts with separator (newlines), preserve them
4497
- const matchSep = appended.match(/^(\s*)(.*)/s);
4498
- if (matchSep) {
4499
- const [, separator, text] = matchSep;
4500
- // Check if it already has "Rule:" prefix or similar
4501
- // We want "IMPORTANT Rule: ..."
4502
- // Let's just prepend IMPORTANT to the text
4503
- // But formatted nicely
4504
- // If it's a rule: "\n\nRule: content"
4505
- // We want "\n\nIMPORTANT Rule: content"
4506
- const importantText = `IMPORTANT ${text}`;
4507
- return {
4508
- ...modifiedRequirements,
4509
- systemMessage: originalMsg + separator + importantText
4510
- };
4511
- }
4512
- }
4513
- }
4514
- // If no system message change or we couldn't detect how to modify it, just return the modified requirements
4515
- // Maybe the inner commitment modified metadata?
4516
- return modifiedRequirements;
4517
- }
4518
- }
4519
- // If no inner commitment found, treat as a standalone note?
4520
- // Or warn?
4521
- // For now, treat as no-op or maybe just append as text?
4522
- // Let's treat as Note if fallback? No, explicit is better.
4523
- console.warn(`IMPORTANT commitment used without a valid inner commitment: ${content}`);
4524
- return requirements;
4525
- }
4526
- }
4527
- /**
4528
- * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
4529
- */
4530
-
4531
4344
  /**
4532
4345
  * KNOWLEDGE commitment definition
4533
4346
  *
@@ -4566,7 +4379,7 @@
4566
4379
  * Markdown documentation for KNOWLEDGE commitment.
4567
4380
  */
4568
4381
  get documentation() {
4569
- return spaceTrim.spaceTrim(`
4382
+ return spaceTrim$1.spaceTrim(`
4570
4383
  # ${this.type}
4571
4384
 
4572
4385
  Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
@@ -4670,7 +4483,7 @@
4670
4483
  * Markdown documentation for LANGUAGE/LANGUAGES commitment.
4671
4484
  */
4672
4485
  get documentation() {
4673
- return spaceTrim.spaceTrim(`
4486
+ return spaceTrim$1.spaceTrim(`
4674
4487
  # ${this.type}
4675
4488
 
4676
4489
  Specifies the language(s) the agent should use in its responses.
@@ -4744,7 +4557,7 @@
4744
4557
  * Markdown documentation for MEMORY commitment.
4745
4558
  */
4746
4559
  get documentation() {
4747
- return spaceTrim.spaceTrim(`
4560
+ return spaceTrim$1.spaceTrim(`
4748
4561
  # ${this.type}
4749
4562
 
4750
4563
  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.
@@ -4848,7 +4661,7 @@
4848
4661
  * Markdown documentation for AGENT MESSAGE commitment.
4849
4662
  */
4850
4663
  get documentation() {
4851
- return spaceTrim.spaceTrim(`
4664
+ return spaceTrim$1.spaceTrim(`
4852
4665
  # ${this.type}
4853
4666
 
4854
4667
  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.
@@ -4925,7 +4738,7 @@
4925
4738
  * Markdown documentation for INITIAL MESSAGE commitment.
4926
4739
  */
4927
4740
  get documentation() {
4928
- return spaceTrim.spaceTrim(`
4741
+ return spaceTrim$1.spaceTrim(`
4929
4742
  # ${this.type}
4930
4743
 
4931
4744
  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).
@@ -4989,7 +4802,7 @@
4989
4802
  * Markdown documentation for MESSAGE commitment.
4990
4803
  */
4991
4804
  get documentation() {
4992
- return spaceTrim.spaceTrim(`
4805
+ return spaceTrim$1.spaceTrim(`
4993
4806
  # ${this.type}
4994
4807
 
4995
4808
  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.
@@ -5101,7 +4914,7 @@
5101
4914
  * Markdown documentation for USER MESSAGE commitment.
5102
4915
  */
5103
4916
  get documentation() {
5104
- return spaceTrim.spaceTrim(`
4917
+ return spaceTrim$1.spaceTrim(`
5105
4918
  # ${this.type}
5106
4919
 
5107
4920
  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.
@@ -5180,7 +4993,7 @@
5180
4993
  * Markdown documentation for META commitment.
5181
4994
  */
5182
4995
  get documentation() {
5183
- return spaceTrim.spaceTrim(`
4996
+ return spaceTrim$1.spaceTrim(`
5184
4997
  # META
5185
4998
 
5186
4999
  Sets meta-information about the agent that is used for display and attribution purposes.
@@ -5291,6 +5104,12 @@
5291
5104
  * META COLOR #00ff00
5292
5105
  * ```
5293
5106
  *
5107
+ * You can also specify multiple colors separated by comma:
5108
+ *
5109
+ * ```book
5110
+ * META COLOR #ff0000, #00ff00, #0000ff
5111
+ * ```
5112
+ *
5294
5113
  * @private [๐Ÿช”] Maybe export the commitments through some package
5295
5114
  */
5296
5115
  class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
@@ -5301,7 +5120,7 @@
5301
5120
  * Short one-line description of META COLOR.
5302
5121
  */
5303
5122
  get description() {
5304
- return "Set the agent's accent color.";
5123
+ return "Set the agent's accent color or gradient.";
5305
5124
  }
5306
5125
  /**
5307
5126
  * Icon for this commitment.
@@ -5313,10 +5132,10 @@
5313
5132
  * Markdown documentation for META COLOR commitment.
5314
5133
  */
5315
5134
  get documentation() {
5316
- return spaceTrim.spaceTrim(`
5135
+ return spaceTrim$1.spaceTrim(`
5317
5136
  # META COLOR
5318
5137
 
5319
- Sets the agent's accent color.
5138
+ Sets the agent's accent color or gradient.
5320
5139
 
5321
5140
  ## Key aspects
5322
5141
 
@@ -5324,6 +5143,7 @@
5324
5143
  - Only one \`META COLOR\` should be used per agent.
5325
5144
  - If multiple are specified, the last one takes precedence.
5326
5145
  - Used for visual representation in user interfaces.
5146
+ - Can specify multiple colors separated by comma to create a gradient.
5327
5147
 
5328
5148
  ## Examples
5329
5149
 
@@ -5340,6 +5160,13 @@
5340
5160
  META COLOR #e74c3c
5341
5161
  PERSONA You are a creative and inspiring assistant
5342
5162
  \`\`\`
5163
+
5164
+ \`\`\`book
5165
+ Gradient Agent
5166
+
5167
+ META COLOR #ff0000, #00ff00, #0000ff
5168
+ PERSONA You are a colorful agent
5169
+ \`\`\`
5343
5170
  `);
5344
5171
  }
5345
5172
  applyToAgentModelRequirements(requirements, content) {
@@ -5361,6 +5188,91 @@
5361
5188
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
5362
5189
  */
5363
5190
 
5191
+ /**
5192
+ * META FONT commitment definition
5193
+ *
5194
+ * The META FONT commitment sets the agent's font.
5195
+ * This commitment is special because it doesn't affect the system message,
5196
+ * but is handled separately in the parsing logic.
5197
+ *
5198
+ * Example usage in agent source:
5199
+ *
5200
+ * ```book
5201
+ * META FONT Poppins, Arial, sans-serif
5202
+ * META FONT Roboto
5203
+ * ```
5204
+ *
5205
+ * @private [๐Ÿช”] Maybe export the commitments through some package
5206
+ */
5207
+ class MetaFontCommitmentDefinition extends BaseCommitmentDefinition {
5208
+ constructor() {
5209
+ super('META FONT', ['FONT']);
5210
+ }
5211
+ /**
5212
+ * Short one-line description of META FONT.
5213
+ */
5214
+ get description() {
5215
+ return "Set the agent's font.";
5216
+ }
5217
+ /**
5218
+ * Icon for this commitment.
5219
+ */
5220
+ get icon() {
5221
+ return '๐Ÿ”ค';
5222
+ }
5223
+ /**
5224
+ * Markdown documentation for META FONT commitment.
5225
+ */
5226
+ get documentation() {
5227
+ return spaceTrim$1.spaceTrim(`
5228
+ # META FONT
5229
+
5230
+ Sets the agent's font.
5231
+
5232
+ ## Key aspects
5233
+
5234
+ - Does not modify the agent's behavior or responses.
5235
+ - Only one \`META FONT\` should be used per agent.
5236
+ - If multiple are specified, the last one takes precedence.
5237
+ - Used for visual representation in user interfaces.
5238
+ - Supports Google Fonts.
5239
+
5240
+ ## Examples
5241
+
5242
+ \`\`\`book
5243
+ Modern Assistant
5244
+
5245
+ META FONT Poppins, Arial, sans-serif
5246
+ PERSONA You are a modern assistant
5247
+ \`\`\`
5248
+
5249
+ \`\`\`book
5250
+ Classic Helper
5251
+
5252
+ META FONT Times New Roman
5253
+ PERSONA You are a classic helper
5254
+ \`\`\`
5255
+ `);
5256
+ }
5257
+ applyToAgentModelRequirements(requirements, content) {
5258
+ // META FONT doesn't modify the system message or model requirements
5259
+ // It's handled separately in the parsing logic
5260
+ // This method exists for consistency with the CommitmentDefinition interface
5261
+ return requirements;
5262
+ }
5263
+ /**
5264
+ * Extracts the font from the content
5265
+ * This is used by the parsing logic
5266
+ */
5267
+ extractProfileFont(content) {
5268
+ const trimmedContent = content.trim();
5269
+ return trimmedContent || null;
5270
+ }
5271
+ }
5272
+ /**
5273
+ * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
5274
+ */
5275
+
5364
5276
  /**
5365
5277
  * META IMAGE commitment definition
5366
5278
  *
@@ -5397,7 +5309,7 @@
5397
5309
  * Markdown documentation for META IMAGE commitment.
5398
5310
  */
5399
5311
  get documentation() {
5400
- return spaceTrim.spaceTrim(`
5312
+ return spaceTrim$1.spaceTrim(`
5401
5313
  # META IMAGE
5402
5314
 
5403
5315
  Sets the agent's avatar/profile image URL.
@@ -5492,7 +5404,7 @@
5492
5404
  * Markdown documentation for META LINK commitment.
5493
5405
  */
5494
5406
  get documentation() {
5495
- return spaceTrim.spaceTrim(`
5407
+ return spaceTrim$1.spaceTrim(`
5496
5408
  # META LINK
5497
5409
 
5498
5410
  Represents a profile or source link for the person the agent is modeled after.
@@ -5602,7 +5514,7 @@
5602
5514
  * Markdown documentation for MODEL commitment.
5603
5515
  */
5604
5516
  get documentation() {
5605
- return spaceTrim.spaceTrim(`
5517
+ return spaceTrim$1.spaceTrim(`
5606
5518
  # ${this.type}
5607
5519
 
5608
5520
  Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
@@ -5843,7 +5755,7 @@
5843
5755
  * Markdown documentation for NOTE commitment.
5844
5756
  */
5845
5757
  get documentation() {
5846
- return spaceTrim.spaceTrim(`
5758
+ return spaceTrim$1.spaceTrim(`
5847
5759
  # ${this.type}
5848
5760
 
5849
5761
  Adds comments for documentation without changing agent behavior.
@@ -5942,7 +5854,7 @@
5942
5854
  * Markdown documentation for OPEN commitment.
5943
5855
  */
5944
5856
  get documentation() {
5945
- return spaceTrim.spaceTrim(`
5857
+ return spaceTrim$1.spaceTrim(`
5946
5858
  # OPEN
5947
5859
 
5948
5860
  Specifies that the agent can be modified by conversation with it.
@@ -6019,7 +5931,7 @@
6019
5931
  * Markdown documentation for PERSONA commitment.
6020
5932
  */
6021
5933
  get documentation() {
6022
- return spaceTrim.spaceTrim(`
5934
+ return spaceTrim$1.spaceTrim(`
6023
5935
  # ${this.type}
6024
5936
 
6025
5937
  Defines who the agent is, their background, expertise, and personality traits.
@@ -6152,7 +6064,7 @@
6152
6064
  * Markdown documentation for RULE/RULES commitment.
6153
6065
  */
6154
6066
  get documentation() {
6155
- return spaceTrim.spaceTrim(`
6067
+ return spaceTrim$1.spaceTrim(`
6156
6068
  # ${this.type}
6157
6069
 
6158
6070
  Adds behavioral constraints and guidelines that the agent must follow.
@@ -6186,13 +6098,515 @@
6186
6098
  `);
6187
6099
  }
6188
6100
  applyToAgentModelRequirements(requirements, content) {
6189
- const trimmedContent = content.trim();
6190
- if (!trimmedContent) {
6191
- return requirements;
6192
- }
6193
- // Add rule to the system message
6194
- const ruleSection = `Rule: ${trimmedContent}`;
6195
- return this.appendToSystemMessage(requirements, ruleSection, '\n\n');
6101
+ const trimmedContent = content.trim();
6102
+ if (!trimmedContent) {
6103
+ return requirements;
6104
+ }
6105
+ // Add rule to the system message
6106
+ const ruleSection = `Rule: ${trimmedContent}`;
6107
+ return this.appendToSystemMessage(requirements, ruleSection, '\n\n');
6108
+ }
6109
+ }
6110
+ /**
6111
+ * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
6112
+ */
6113
+
6114
+ /**
6115
+ * SAMPLE commitment definition
6116
+ *
6117
+ * The SAMPLE/EXAMPLE commitment provides examples of how the agent should respond
6118
+ * or behave in certain situations. These examples help guide the agent's responses.
6119
+ *
6120
+ * Example usage in agent source:
6121
+ *
6122
+ * ```book
6123
+ * SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
6124
+ * EXAMPLE For code questions, always include working code snippets
6125
+ * ```
6126
+ *
6127
+ * @private [๐Ÿช”] Maybe export the commitments through some package
6128
+ */
6129
+ class SampleCommitmentDefinition extends BaseCommitmentDefinition {
6130
+ constructor(type = 'SAMPLE') {
6131
+ super(type);
6132
+ }
6133
+ /**
6134
+ * Short one-line description of SAMPLE/EXAMPLE.
6135
+ */
6136
+ get description() {
6137
+ return 'Provide example responses to guide behavior.';
6138
+ }
6139
+ /**
6140
+ * Icon for this commitment.
6141
+ */
6142
+ get icon() {
6143
+ return '๐Ÿ”';
6144
+ }
6145
+ /**
6146
+ * Markdown documentation for SAMPLE/EXAMPLE commitment.
6147
+ */
6148
+ get documentation() {
6149
+ return spaceTrim$1.spaceTrim(`
6150
+ # ${this.type}
6151
+
6152
+ Provides examples of how the agent should respond or behave in certain situations.
6153
+
6154
+ ## Key aspects
6155
+
6156
+ - Both terms work identically and can be used interchangeably.
6157
+ - Examples help guide the agent's response patterns and style.
6158
+
6159
+ ## Examples
6160
+
6161
+ \`\`\`book
6162
+ Sales Assistant
6163
+
6164
+ PERSONA You are a knowledgeable sales representative
6165
+ SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
6166
+ SAMPLE For feature comparisons, create a clear comparison table
6167
+ RULE Always be honest about limitations
6168
+ \`\`\`
6169
+
6170
+ \`\`\`book
6171
+ Code Reviewer
6172
+
6173
+ PERSONA You are an experienced software engineer
6174
+ EXAMPLE For code questions, always include working code snippets
6175
+ EXAMPLE When suggesting improvements: "Here's a more efficient approach..."
6176
+ RULE Explain the reasoning behind your suggestions
6177
+ STYLE Be constructive and encouraging in feedback
6178
+ \`\`\`
6179
+ `);
6180
+ }
6181
+ applyToAgentModelRequirements(requirements, content) {
6182
+ const trimmedContent = content.trim();
6183
+ if (!trimmedContent) {
6184
+ return requirements;
6185
+ }
6186
+ // Add example to the system message
6187
+ const exampleSection = `Example: ${trimmedContent}`;
6188
+ return this.appendToSystemMessage(requirements, exampleSection, '\n\n');
6189
+ }
6190
+ }
6191
+ /**
6192
+ * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
6193
+ */
6194
+
6195
+ /**
6196
+ * SCENARIO commitment definition
6197
+ *
6198
+ * The SCENARIO commitment defines a specific situation or context in which the AI
6199
+ * assistant should operate. It helps to set the scene for the AI's responses.
6200
+ * Later scenarios are more important than earlier scenarios.
6201
+ *
6202
+ * Example usage in agent source:
6203
+ *
6204
+ * ```book
6205
+ * SCENARIO You are in a customer service call center during peak hours
6206
+ * SCENARIO The customer is frustrated and has been on hold for 20 minutes
6207
+ * SCENARIO This is the customer's third call about the same issue
6208
+ * ```
6209
+ *
6210
+ * @private [๐Ÿช”] Maybe export the commitments through some package
6211
+ */
6212
+ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
6213
+ constructor(type = 'SCENARIO') {
6214
+ super(type);
6215
+ }
6216
+ /**
6217
+ * Short one-line description of SCENARIO.
6218
+ */
6219
+ get description() {
6220
+ return 'Define specific **situations** or contexts for AI responses, with later scenarios having higher priority.';
6221
+ }
6222
+ /**
6223
+ * Icon for this commitment.
6224
+ */
6225
+ get icon() {
6226
+ return '๐ŸŽญ';
6227
+ }
6228
+ /**
6229
+ * Markdown documentation for SCENARIO commitment.
6230
+ */
6231
+ get documentation() {
6232
+ return spaceTrim$1.spaceTrim(`
6233
+ # ${this.type}
6234
+
6235
+ 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.
6236
+
6237
+ ## Key aspects
6238
+
6239
+ - Multiple \`SCENARIO\` and \`SCENARIOS\` commitments build upon each other.
6240
+ - Both terms work identically and can be used interchangeably.
6241
+ - Later scenarios have higher priority and can override earlier scenarios.
6242
+ - Provides situational context that influences response tone and content.
6243
+ - Helps establish the environment and circumstances for interactions.
6244
+
6245
+ ## Priority system
6246
+
6247
+ When multiple scenarios are defined, they are processed in order, with later scenarios taking precedence over earlier ones when there are conflicts.
6248
+
6249
+ ## Use cases
6250
+
6251
+ - Setting the physical or virtual environment
6252
+ - Establishing time constraints or urgency
6253
+ - Defining relationship dynamics or power structures
6254
+ - Creating emotional or situational context
6255
+
6256
+ ## Examples
6257
+
6258
+ \`\`\`book
6259
+ Emergency Response Operator
6260
+
6261
+ PERSONA You are an emergency response operator
6262
+ SCENARIO You are handling a 911 emergency call
6263
+ SCENARIO The caller is panicked and speaking rapidly
6264
+ SCENARIO Time is critical - every second counts
6265
+ GOAL Gather essential information quickly and dispatch appropriate help
6266
+ RULE Stay calm and speak clearly
6267
+ \`\`\`
6268
+
6269
+ \`\`\`book
6270
+ Sales Representative
6271
+
6272
+ PERSONA You are a software sales representative
6273
+ SCENARIO You are in the final meeting of a 6-month sales cycle
6274
+ SCENARIO The client has budget approval and decision-making authority
6275
+ SCENARIO Two competitors have also submitted proposals
6276
+ SCENARIO The client values long-term partnership over lowest price
6277
+ GOAL Close the deal while building trust for future business
6278
+ \`\`\`
6279
+
6280
+ \`\`\`book
6281
+ Medical Assistant
6282
+
6283
+ PERSONA You are a medical assistant in a busy clinic
6284
+ SCENARIO The waiting room is full and the doctor is running behind schedule
6285
+ SCENARIO Patients are becoming impatient and anxious
6286
+ SCENARIO You need to manage expectations while maintaining professionalism
6287
+ SCENARIO Some patients have been waiting over an hour
6288
+ GOAL Keep patients informed and calm while supporting efficient clinic flow
6289
+ RULE Never provide medical advice or diagnosis
6290
+ \`\`\`
6291
+
6292
+ \`\`\`book
6293
+ Technical Support Agent
6294
+
6295
+ PERSONA You are a technical support agent
6296
+ SCENARIO The customer is a small business owner during their busy season
6297
+ SCENARIO Their main business system has been down for 2 hours
6298
+ SCENARIO They are losing money every minute the system is offline
6299
+ SCENARIO This is their first experience with your company
6300
+ GOAL Resolve the issue quickly while creating a positive first impression
6301
+ \`\`\`
6302
+ `);
6303
+ }
6304
+ applyToAgentModelRequirements(requirements, content) {
6305
+ const trimmedContent = content.trim();
6306
+ if (!trimmedContent) {
6307
+ return requirements;
6308
+ }
6309
+ // Create scenario section for system message
6310
+ const scenarioSection = `Scenario: ${trimmedContent}`;
6311
+ // Scenarios provide important contextual information that affects behavior
6312
+ return this.appendToSystemMessage(requirements, scenarioSection, '\n\n');
6313
+ }
6314
+ }
6315
+ /**
6316
+ * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
6317
+ */
6318
+
6319
+ /**
6320
+ * STYLE commitment definition
6321
+ *
6322
+ * The STYLE commitment defines how the agent should format and present its responses.
6323
+ * This includes tone, writing style, formatting preferences, and communication patterns.
6324
+ *
6325
+ * Example usage in agent source:
6326
+ *
6327
+ * ```book
6328
+ * STYLE Write in a professional but friendly tone, use bullet points for lists
6329
+ * STYLE Always provide code examples when explaining programming concepts
6330
+ * ```
6331
+ *
6332
+ * @private [๐Ÿช”] Maybe export the commitments through some package
6333
+ */
6334
+ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
6335
+ constructor(type = 'STYLE') {
6336
+ super(type);
6337
+ }
6338
+ /**
6339
+ * Short one-line description of STYLE.
6340
+ */
6341
+ get description() {
6342
+ return 'Control the tone and writing style of responses.';
6343
+ }
6344
+ /**
6345
+ * Icon for this commitment.
6346
+ */
6347
+ get icon() {
6348
+ return '๐Ÿ–‹๏ธ';
6349
+ }
6350
+ /**
6351
+ * Markdown documentation for STYLE commitment.
6352
+ */
6353
+ get documentation() {
6354
+ return spaceTrim$1.spaceTrim(`
6355
+ # ${this.type}
6356
+
6357
+ Defines how the agent should format and present its responses (tone, writing style, formatting).
6358
+
6359
+ ## Key aspects
6360
+
6361
+ - Both terms work identically and can be used interchangeably.
6362
+ - Later style instructions can override earlier ones.
6363
+ - Style affects both tone and presentation format.
6364
+
6365
+ ## Examples
6366
+
6367
+ \`\`\`book
6368
+ Technical Writer
6369
+
6370
+ PERSONA You are a technical documentation expert
6371
+ STYLE Write in a professional but friendly tone, use bullet points for lists
6372
+ STYLE Always provide code examples when explaining programming concepts
6373
+ FORMAT Use markdown formatting with clear headings
6374
+ \`\`\`
6375
+
6376
+ \`\`\`book
6377
+ Creative Assistant
6378
+
6379
+ PERSONA You are a creative writing helper
6380
+ STYLE Be enthusiastic and encouraging in your responses
6381
+ STYLE Use vivid metaphors and analogies to explain concepts
6382
+ STYLE Keep responses conversational and engaging
6383
+ RULE Always maintain a positive and supportive tone
6384
+ \`\`\`
6385
+ `);
6386
+ }
6387
+ applyToAgentModelRequirements(requirements, content) {
6388
+ const trimmedContent = content.trim();
6389
+ if (!trimmedContent) {
6390
+ return requirements;
6391
+ }
6392
+ // Add style instructions to the system message
6393
+ const styleSection = `Style: ${trimmedContent}`;
6394
+ return this.appendToSystemMessage(requirements, styleSection, '\n\n');
6395
+ }
6396
+ }
6397
+ /**
6398
+ * [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
6399
+ */
6400
+
6401
+ /**
6402
+ * USE commitment definition
6403
+ *
6404
+ * The USE commitment indicates that the agent should utilize specific tools or capabilities
6405
+ * to access and interact with external systems when necessary.
6406
+ *
6407
+ * Supported USE types:
6408
+ * - USE BROWSER: Enables the agent to use a web browser tool
6409
+ * - USE SEARCH ENGINE (future): Enables search engine access
6410
+ * - USE FILE SYSTEM (future): Enables file system operations
6411
+ * - USE MCP (future): Enables MCP server connections
6412
+ *
6413
+ * The content following the USE commitment is ignored (similar to NOTE).
6414
+ *
6415
+ * Example usage in agent source:
6416
+ *
6417
+ * ```book
6418
+ * USE BROWSER
6419
+ * USE SEARCH ENGINE
6420
+ * ```
6421
+ *
6422
+ * @private [๐Ÿช”] Maybe export the commitments through some package
6423
+ */
6424
+ class UseCommitmentDefinition extends BaseCommitmentDefinition {
6425
+ constructor() {
6426
+ super('USE');
6427
+ }
6428
+ /**
6429
+ * Short one-line description of USE commitments.
6430
+ */
6431
+ get description() {
6432
+ return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
6433
+ }
6434
+ /**
6435
+ * Icon for this commitment.
6436
+ */
6437
+ get icon() {
6438
+ return '๐Ÿ”ง';
6439
+ }
6440
+ /**
6441
+ * Markdown documentation for USE commitment.
6442
+ */
6443
+ get documentation() {
6444
+ return spaceTrim$1.spaceTrim(`
6445
+ # USE
6446
+
6447
+ Enables the agent to use specific tools or capabilities for interacting with external systems.
6448
+
6449
+ ## Supported USE types
6450
+
6451
+ - **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
6452
+ - **USE SEARCH ENGINE** (future) - Enables search engine access
6453
+ - **USE FILE SYSTEM** (future) - Enables file system operations
6454
+ - **USE MCP** (future) - Enables MCP server connections
6455
+
6456
+ ## Key aspects
6457
+
6458
+ - The content following the USE commitment is ignored (similar to NOTE)
6459
+ - Multiple USE commitments can be specified to enable multiple capabilities
6460
+ - The actual tool usage is handled by the agent runtime
6461
+
6462
+ ## Examples
6463
+
6464
+ ### Basic browser usage
6465
+
6466
+ \`\`\`book
6467
+ Research Assistant
6468
+
6469
+ PERSONA You are a helpful research assistant
6470
+ USE BROWSER
6471
+ KNOWLEDGE Can search the web for up-to-date information
6472
+ \`\`\`
6473
+
6474
+ ### Multiple tools
6475
+
6476
+ \`\`\`book
6477
+ Data Analyst
6478
+
6479
+ PERSONA You are a data analyst assistant
6480
+ USE BROWSER
6481
+ USE FILE SYSTEM
6482
+ ACTION Can analyze data from various sources
6483
+ \`\`\`
6484
+ `);
6485
+ }
6486
+ applyToAgentModelRequirements(requirements, content) {
6487
+ // USE commitments don't modify the system message or model requirements directly
6488
+ // They are handled separately in the parsing logic for capability extraction
6489
+ // This method exists for consistency with the CommitmentDefinition interface
6490
+ return requirements;
6491
+ }
6492
+ /**
6493
+ * Extracts the tool type from the USE commitment
6494
+ * This is used by the parsing logic
6495
+ */
6496
+ extractToolType(content) {
6497
+ var _a, _b;
6498
+ const trimmedContent = content.trim();
6499
+ // The tool type is the first word after USE (already stripped)
6500
+ const match = trimmedContent.match(/^(\w+)/);
6501
+ 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;
6502
+ }
6503
+ /**
6504
+ * Checks if this is a known USE type
6505
+ */
6506
+ isKnownUseType(useType) {
6507
+ const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
6508
+ return knownTypes.includes(useType.toUpperCase());
6509
+ }
6510
+ }
6511
+ /**
6512
+ * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
6513
+ */
6514
+
6515
+ /**
6516
+ * USE BROWSER commitment definition
6517
+ *
6518
+ * The `USE BROWSER` commitment indicates that the agent should utilize a web browser tool
6519
+ * to access and retrieve up-to-date information from the internet when necessary.
6520
+ *
6521
+ * The content following `USE BROWSER` is ignored (similar to NOTE).
6522
+ *
6523
+ * Example usage in agent source:
6524
+ *
6525
+ * ```book
6526
+ * USE BROWSER
6527
+ * USE BROWSER This will be ignored
6528
+ * ```
6529
+ *
6530
+ * @private [๐Ÿช”] Maybe export the commitments through some package
6531
+ */
6532
+ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
6533
+ constructor() {
6534
+ super('USE BROWSER', ['BROWSER']);
6535
+ }
6536
+ /**
6537
+ * Short one-line description of USE BROWSER.
6538
+ */
6539
+ get description() {
6540
+ return 'Enable the agent to use a web browser tool for accessing internet information.';
6541
+ }
6542
+ /**
6543
+ * Icon for this commitment.
6544
+ */
6545
+ get icon() {
6546
+ return '๐ŸŒ';
6547
+ }
6548
+ /**
6549
+ * Markdown documentation for USE BROWSER commitment.
6550
+ */
6551
+ get documentation() {
6552
+ return spaceTrim$1.spaceTrim(`
6553
+ # USE BROWSER
6554
+
6555
+ Enables the agent to use a web browser tool to access and retrieve up-to-date information from the internet.
6556
+
6557
+ ## Key aspects
6558
+
6559
+ - The content following \`USE BROWSER\` is ignored (similar to NOTE)
6560
+ - The actual browser tool usage is handled by the agent runtime
6561
+ - Allows the agent to fetch current information from websites
6562
+ - Useful for research tasks, fact-checking, and accessing dynamic content
6563
+
6564
+ ## Examples
6565
+
6566
+ \`\`\`book
6567
+ Research Assistant
6568
+
6569
+ PERSONA You are a helpful research assistant specialized in finding current information
6570
+ USE BROWSER
6571
+ RULE Always cite your sources when providing information from the web
6572
+ \`\`\`
6573
+
6574
+ \`\`\`book
6575
+ News Analyst
6576
+
6577
+ PERSONA You are a news analyst who stays up-to-date with current events
6578
+ USE BROWSER
6579
+ STYLE Present news in a balanced and objective manner
6580
+ ACTION Can search for and summarize news articles
6581
+ \`\`\`
6582
+
6583
+ \`\`\`book
6584
+ Company Lawyer
6585
+
6586
+ PERSONA You are a company lawyer providing legal advice
6587
+ USE BROWSER
6588
+ KNOWLEDGE Corporate law and legal procedures
6589
+ RULE Always recommend consulting with a licensed attorney for specific legal matters
6590
+ \`\`\`
6591
+ `);
6592
+ }
6593
+ applyToAgentModelRequirements(requirements, content) {
6594
+ // We simply mark that browser capability is enabled in metadata
6595
+ // Get existing metadata
6596
+ const existingMetadata = requirements.metadata || {};
6597
+ // Get existing tools array or create new one
6598
+ const existingTools = existingMetadata.tools || [];
6599
+ // Add 'browser' to tools if not already present
6600
+ const updatedTools = existingTools.includes('browser') ? existingTools : [...existingTools, 'browser'];
6601
+ // Return requirements with updated metadata
6602
+ return {
6603
+ ...requirements,
6604
+ metadata: {
6605
+ ...existingMetadata,
6606
+ tools: updatedTools,
6607
+ useBrowser: true,
6608
+ },
6609
+ };
6196
6610
  }
6197
6611
  }
6198
6612
  /**
@@ -6200,80 +6614,76 @@
6200
6614
  */
6201
6615
 
6202
6616
  /**
6203
- * SAMPLE commitment definition
6617
+ * USE MCP commitment definition
6204
6618
  *
6205
- * The SAMPLE/EXAMPLE commitment provides examples of how the agent should respond
6206
- * or behave in certain situations. These examples help guide the agent's responses.
6619
+ * The `USE MCP` commitment allows to specify an MCP server URL which the agent will connect to
6620
+ * for retrieving additional instructions and actions.
6621
+ *
6622
+ * The content following `USE MCP` is the URL of the MCP server.
6207
6623
  *
6208
6624
  * Example usage in agent source:
6209
6625
  *
6210
6626
  * ```book
6211
- * SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
6212
- * EXAMPLE For code questions, always include working code snippets
6627
+ * USE MCP http://mcp-server-url.com
6213
6628
  * ```
6214
6629
  *
6215
6630
  * @private [๐Ÿช”] Maybe export the commitments through some package
6216
6631
  */
6217
- class SampleCommitmentDefinition extends BaseCommitmentDefinition {
6218
- constructor(type = 'SAMPLE') {
6219
- super(type);
6632
+ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
6633
+ constructor() {
6634
+ super('USE MCP', ['MCP']);
6220
6635
  }
6221
6636
  /**
6222
- * Short one-line description of SAMPLE/EXAMPLE.
6637
+ * Short one-line description of USE MCP.
6223
6638
  */
6224
6639
  get description() {
6225
- return 'Provide example responses to guide behavior.';
6640
+ return 'Connects the agent to an external MCP server for additional capabilities.';
6226
6641
  }
6227
6642
  /**
6228
6643
  * Icon for this commitment.
6229
6644
  */
6230
6645
  get icon() {
6231
- return '๐Ÿ”';
6646
+ return '๐Ÿ”Œ';
6232
6647
  }
6233
6648
  /**
6234
- * Markdown documentation for SAMPLE/EXAMPLE commitment.
6649
+ * Markdown documentation for USE MCP commitment.
6235
6650
  */
6236
6651
  get documentation() {
6237
- return spaceTrim.spaceTrim(`
6238
- # ${this.type}
6652
+ return spaceTrim$1.spaceTrim(`
6653
+ # USE MCP
6239
6654
 
6240
- Provides examples of how the agent should respond or behave in certain situations.
6655
+ Connects the agent to an external Model Context Protocol (MCP) server.
6241
6656
 
6242
6657
  ## Key aspects
6243
6658
 
6244
- - Both terms work identically and can be used interchangeably.
6245
- - Examples help guide the agent's response patterns and style.
6246
-
6247
- ## Examples
6248
-
6249
- \`\`\`book
6250
- Sales Assistant
6659
+ - The content following \`USE MCP\` must be a valid URL
6660
+ - Multiple MCP servers can be connected by using multiple \`USE MCP\` commitments
6661
+ - The agent will have access to tools and resources provided by the MCP server
6251
6662
 
6252
- PERSONA You are a knowledgeable sales representative
6253
- SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
6254
- SAMPLE For feature comparisons, create a clear comparison table
6255
- RULE Always be honest about limitations
6256
- \`\`\`
6663
+ ## Example
6257
6664
 
6258
6665
  \`\`\`book
6259
- Code Reviewer
6666
+ Company Lawyer
6260
6667
 
6261
- PERSONA You are an experienced software engineer
6262
- EXAMPLE For code questions, always include working code snippets
6263
- EXAMPLE When suggesting improvements: "Here's a more efficient approach..."
6264
- RULE Explain the reasoning behind your suggestions
6265
- STYLE Be constructive and encouraging in feedback
6668
+ PERSONA You are a company lawyer.
6669
+ USE MCP http://legal-db.example.com
6266
6670
  \`\`\`
6267
6671
  `);
6268
6672
  }
6269
6673
  applyToAgentModelRequirements(requirements, content) {
6270
- const trimmedContent = content.trim();
6271
- if (!trimmedContent) {
6674
+ const mcpServerUrl = content.trim();
6675
+ if (!mcpServerUrl) {
6272
6676
  return requirements;
6273
6677
  }
6274
- // Add example to the system message
6275
- const exampleSection = `Example: ${trimmedContent}`;
6276
- return this.appendToSystemMessage(requirements, exampleSection, '\n\n');
6678
+ const existingMcpServers = requirements.mcpServers || [];
6679
+ // Avoid duplicates
6680
+ if (existingMcpServers.includes(mcpServerUrl)) {
6681
+ return requirements;
6682
+ }
6683
+ return {
6684
+ ...requirements,
6685
+ mcpServers: [...existingMcpServers, mcpServerUrl],
6686
+ };
6277
6687
  }
6278
6688
  }
6279
6689
  /**
@@ -6281,123 +6691,90 @@
6281
6691
  */
6282
6692
 
6283
6693
  /**
6284
- * SCENARIO commitment definition
6694
+ * USE SEARCH ENGINE commitment definition
6285
6695
  *
6286
- * The SCENARIO commitment defines a specific situation or context in which the AI
6287
- * assistant should operate. It helps to set the scene for the AI's responses.
6288
- * Later scenarios are more important than earlier scenarios.
6696
+ * The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
6697
+ * to access and retrieve up-to-date information from the internet when necessary.
6698
+ *
6699
+ * The content following `USE SEARCH ENGINE` is ignored (similar to NOTE).
6289
6700
  *
6290
6701
  * Example usage in agent source:
6291
6702
  *
6292
6703
  * ```book
6293
- * SCENARIO You are in a customer service call center during peak hours
6294
- * SCENARIO The customer is frustrated and has been on hold for 20 minutes
6295
- * SCENARIO This is the customer's third call about the same issue
6704
+ * USE SEARCH ENGINE
6705
+ * USE SEARCH ENGINE This will be ignored
6296
6706
  * ```
6297
6707
  *
6298
6708
  * @private [๐Ÿช”] Maybe export the commitments through some package
6299
6709
  */
6300
- class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
6301
- constructor(type = 'SCENARIO') {
6302
- super(type);
6710
+ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
6711
+ constructor() {
6712
+ super('USE SEARCH ENGINE', ['SEARCH ENGINE', 'SEARCH']);
6303
6713
  }
6304
6714
  /**
6305
- * Short one-line description of SCENARIO.
6715
+ * Short one-line description of USE SEARCH ENGINE.
6306
6716
  */
6307
6717
  get description() {
6308
- return 'Define specific **situations** or contexts for AI responses, with later scenarios having higher priority.';
6718
+ return 'Enable the agent to use a search engine tool for accessing internet information.';
6309
6719
  }
6310
6720
  /**
6311
6721
  * Icon for this commitment.
6312
6722
  */
6313
6723
  get icon() {
6314
- return '๐ŸŽญ';
6724
+ return '๐Ÿ”';
6315
6725
  }
6316
6726
  /**
6317
- * Markdown documentation for SCENARIO commitment.
6727
+ * Markdown documentation for USE SEARCH ENGINE commitment.
6318
6728
  */
6319
6729
  get documentation() {
6320
- return spaceTrim.spaceTrim(`
6321
- # ${this.type}
6730
+ return spaceTrim$1.spaceTrim(`
6731
+ # USE SEARCH ENGINE
6322
6732
 
6323
- 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.
6733
+ Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
6324
6734
 
6325
6735
  ## Key aspects
6326
6736
 
6327
- - Multiple \`SCENARIO\` and \`SCENARIOS\` commitments build upon each other.
6328
- - Both terms work identically and can be used interchangeably.
6329
- - Later scenarios have higher priority and can override earlier scenarios.
6330
- - Provides situational context that influences response tone and content.
6331
- - Helps establish the environment and circumstances for interactions.
6332
-
6333
- ## Priority system
6334
-
6335
- When multiple scenarios are defined, they are processed in order, with later scenarios taking precedence over earlier ones when there are conflicts.
6336
-
6337
- ## Use cases
6338
-
6339
- - Setting the physical or virtual environment
6340
- - Establishing time constraints or urgency
6341
- - Defining relationship dynamics or power structures
6342
- - Creating emotional or situational context
6737
+ - The content following \`USE SEARCH ENGINE\` is ignored (similar to NOTE)
6738
+ - The actual search engine tool usage is handled by the agent runtime
6739
+ - Allows the agent to search for current information from the web
6740
+ - Useful for research tasks, finding facts, and accessing dynamic content
6343
6741
 
6344
6742
  ## Examples
6345
6743
 
6346
6744
  \`\`\`book
6347
- Emergency Response Operator
6348
-
6349
- PERSONA You are an emergency response operator
6350
- SCENARIO You are handling a 911 emergency call
6351
- SCENARIO The caller is panicked and speaking rapidly
6352
- SCENARIO Time is critical - every second counts
6353
- GOAL Gather essential information quickly and dispatch appropriate help
6354
- RULE Stay calm and speak clearly
6355
- \`\`\`
6356
-
6357
- \`\`\`book
6358
- Sales Representative
6359
-
6360
- PERSONA You are a software sales representative
6361
- SCENARIO You are in the final meeting of a 6-month sales cycle
6362
- SCENARIO The client has budget approval and decision-making authority
6363
- SCENARIO Two competitors have also submitted proposals
6364
- SCENARIO The client values long-term partnership over lowest price
6365
- GOAL Close the deal while building trust for future business
6366
- \`\`\`
6367
-
6368
- \`\`\`book
6369
- Medical Assistant
6745
+ Research Assistant
6370
6746
 
6371
- PERSONA You are a medical assistant in a busy clinic
6372
- SCENARIO The waiting room is full and the doctor is running behind schedule
6373
- SCENARIO Patients are becoming impatient and anxious
6374
- SCENARIO You need to manage expectations while maintaining professionalism
6375
- SCENARIO Some patients have been waiting over an hour
6376
- GOAL Keep patients informed and calm while supporting efficient clinic flow
6377
- RULE Never provide medical advice or diagnosis
6747
+ PERSONA You are a helpful research assistant specialized in finding current information
6748
+ USE SEARCH ENGINE
6749
+ RULE Always cite your sources when providing information from the web
6378
6750
  \`\`\`
6379
6751
 
6380
6752
  \`\`\`book
6381
- Technical Support Agent
6753
+ Fact Checker
6382
6754
 
6383
- PERSONA You are a technical support agent
6384
- SCENARIO The customer is a small business owner during their busy season
6385
- SCENARIO Their main business system has been down for 2 hours
6386
- SCENARIO They are losing money every minute the system is offline
6387
- SCENARIO This is their first experience with your company
6388
- GOAL Resolve the issue quickly while creating a positive first impression
6755
+ PERSONA You are a fact checker
6756
+ USE SEARCH ENGINE
6757
+ ACTION Search for claims and verify them against reliable sources
6389
6758
  \`\`\`
6390
6759
  `);
6391
6760
  }
6392
6761
  applyToAgentModelRequirements(requirements, content) {
6393
- const trimmedContent = content.trim();
6394
- if (!trimmedContent) {
6395
- return requirements;
6396
- }
6397
- // Create scenario section for system message
6398
- const scenarioSection = `Scenario: ${trimmedContent}`;
6399
- // Scenarios provide important contextual information that affects behavior
6400
- return this.appendToSystemMessage(requirements, scenarioSection, '\n\n');
6762
+ // We simply mark that search engine capability is enabled in metadata
6763
+ // Get existing metadata
6764
+ const existingMetadata = requirements.metadata || {};
6765
+ // Get existing tools array or create new one
6766
+ const existingTools = existingMetadata.tools || [];
6767
+ // Add 'search-engine' to tools if not already present
6768
+ const updatedTools = existingTools.includes('search-engine') ? existingTools : [...existingTools, 'search-engine'];
6769
+ // Return requirements with updated metadata
6770
+ return {
6771
+ ...requirements,
6772
+ metadata: {
6773
+ ...existingMetadata,
6774
+ tools: updatedTools,
6775
+ useSearchEngine: true,
6776
+ },
6777
+ };
6401
6778
  }
6402
6779
  }
6403
6780
  /**
@@ -6405,70 +6782,58 @@
6405
6782
  */
6406
6783
 
6407
6784
  /**
6408
- * STYLE commitment definition
6409
- *
6410
- * The STYLE commitment defines how the agent should format and present its responses.
6411
- * This includes tone, writing style, formatting preferences, and communication patterns.
6412
- *
6413
- * Example usage in agent source:
6785
+ * Placeholder commitment definition for commitments that are not yet implemented
6414
6786
  *
6415
- * ```book
6416
- * STYLE Write in a professional but friendly tone, use bullet points for lists
6417
- * STYLE Always provide code examples when explaining programming concepts
6418
- * ```
6787
+ * This commitment simply adds its content 1:1 into the system message,
6788
+ * preserving the original behavior until proper implementation is added.
6419
6789
  *
6420
- * @private [๐Ÿช”] Maybe export the commitments through some package
6790
+ * @public exported from `@promptbook/core`
6421
6791
  */
6422
- class StyleCommitmentDefinition extends BaseCommitmentDefinition {
6423
- constructor(type = 'STYLE') {
6792
+ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
6793
+ constructor(type) {
6424
6794
  super(type);
6425
6795
  }
6426
6796
  /**
6427
- * Short one-line description of STYLE.
6797
+ * Short one-line description of a placeholder commitment.
6428
6798
  */
6429
6799
  get description() {
6430
- return 'Control the tone and writing style of responses.';
6800
+ return 'Placeholder commitment that appends content verbatim to the system message.';
6431
6801
  }
6432
6802
  /**
6433
6803
  * Icon for this commitment.
6434
6804
  */
6435
6805
  get icon() {
6436
- return '๐Ÿ–‹๏ธ';
6806
+ return '๐Ÿšง';
6437
6807
  }
6438
6808
  /**
6439
- * Markdown documentation for STYLE commitment.
6809
+ * Markdown documentation available at runtime.
6440
6810
  */
6441
6811
  get documentation() {
6442
- return spaceTrim.spaceTrim(`
6812
+ return spaceTrim$1.spaceTrim(`
6443
6813
  # ${this.type}
6444
6814
 
6445
- Defines how the agent should format and present its responses (tone, writing style, formatting).
6815
+ This commitment is not yet fully implemented.
6446
6816
 
6447
6817
  ## Key aspects
6448
6818
 
6449
- - Both terms work identically and can be used interchangeably.
6450
- - Later style instructions can override earlier ones.
6451
- - Style affects both tone and presentation format.
6819
+ - Content is appended directly to the system message.
6820
+ - No special processing or validation is performed.
6821
+ - Behavior preserved until proper implementation is added.
6452
6822
 
6453
- ## Examples
6823
+ ## Status
6454
6824
 
6455
- \`\`\`book
6456
- Technical Writer
6825
+ - **Status:** Placeholder implementation
6826
+ - **Effect:** Appends content prefixed by commitment type
6827
+ - **Future:** Will be replaced with specialized logic
6457
6828
 
6458
- PERSONA You are a technical documentation expert
6459
- STYLE Write in a professional but friendly tone, use bullet points for lists
6460
- STYLE Always provide code examples when explaining programming concepts
6461
- FORMAT Use markdown formatting with clear headings
6462
- \`\`\`
6829
+ ## Examples
6463
6830
 
6464
6831
  \`\`\`book
6465
- Creative Assistant
6832
+ Example Agent
6466
6833
 
6467
- PERSONA You are a creative writing helper
6468
- STYLE Be enthusiastic and encouraging in your responses
6469
- STYLE Use vivid metaphors and analogies to explain concepts
6470
- STYLE Keep responses conversational and engaging
6471
- RULE Always maintain a positive and supportive tone
6834
+ PERSONA You are a helpful assistant
6835
+ ${this.type} Your content here
6836
+ RULE Always be helpful
6472
6837
  \`\`\`
6473
6838
  `);
6474
6839
  }
@@ -6477,70 +6842,108 @@
6477
6842
  if (!trimmedContent) {
6478
6843
  return requirements;
6479
6844
  }
6480
- // Add style instructions to the system message
6481
- const styleSection = `Style: ${trimmedContent}`;
6482
- return this.appendToSystemMessage(requirements, styleSection, '\n\n');
6845
+ // Add the commitment content 1:1 to the system message
6846
+ const commitmentLine = `${this.type} ${trimmedContent}`;
6847
+ return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
6483
6848
  }
6484
6849
  }
6485
- /**
6486
- * [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
6487
- */
6488
6850
 
6489
6851
  // Import all commitment definition classes
6490
- // Register fully implemented commitments
6491
- registerCommitment(new PersonaCommitmentDefinition('PERSONA'));
6492
- registerCommitment(new PersonaCommitmentDefinition('PERSONAE'));
6493
- registerCommitment(new KnowledgeCommitmentDefinition());
6494
- registerCommitment(new MemoryCommitmentDefinition('MEMORY'));
6495
- registerCommitment(new MemoryCommitmentDefinition('MEMORIES'));
6496
- registerCommitment(new StyleCommitmentDefinition('STYLE'));
6497
- registerCommitment(new StyleCommitmentDefinition('STYLES'));
6498
- registerCommitment(new RuleCommitmentDefinition('RULE'));
6499
- registerCommitment(new RuleCommitmentDefinition('RULES'));
6500
- registerCommitment(new LanguageCommitmentDefinition('LANGUAGE'));
6501
- registerCommitment(new LanguageCommitmentDefinition('LANGUAGES'));
6502
- registerCommitment(new SampleCommitmentDefinition('SAMPLE'));
6503
- registerCommitment(new SampleCommitmentDefinition('EXAMPLE'));
6504
- registerCommitment(new FormatCommitmentDefinition('FORMAT'));
6505
- registerCommitment(new FormatCommitmentDefinition('FORMATS'));
6506
- registerCommitment(new FromCommitmentDefinition('FROM'));
6507
- registerCommitment(new ModelCommitmentDefinition('MODEL'));
6508
- registerCommitment(new ModelCommitmentDefinition('MODELS'));
6509
- registerCommitment(new ActionCommitmentDefinition('ACTION'));
6510
- registerCommitment(new ActionCommitmentDefinition('ACTIONS'));
6511
- registerCommitment(new ComponentCommitmentDefinition());
6512
- registerCommitment(new MetaImageCommitmentDefinition());
6513
- registerCommitment(new MetaColorCommitmentDefinition());
6514
- registerCommitment(new MetaLinkCommitmentDefinition());
6515
- registerCommitment(new MetaCommitmentDefinition());
6516
- registerCommitment(new NoteCommitmentDefinition('NOTE'));
6517
- registerCommitment(new NoteCommitmentDefinition('NOTES'));
6518
- registerCommitment(new NoteCommitmentDefinition('COMMENT'));
6519
- registerCommitment(new NoteCommitmentDefinition('NONCE'));
6520
- registerCommitment(new GoalCommitmentDefinition('GOAL'));
6521
- registerCommitment(new GoalCommitmentDefinition('GOALS'));
6522
- registerCommitment(new ImportantCommitmentDefinition());
6523
- registerCommitment(new InitialMessageCommitmentDefinition());
6524
- registerCommitment(new UserMessageCommitmentDefinition());
6525
- registerCommitment(new AgentMessageCommitmentDefinition());
6526
- registerCommitment(new MessageCommitmentDefinition('MESSAGE'));
6527
- registerCommitment(new MessageCommitmentDefinition('MESSAGES'));
6528
- registerCommitment(new ScenarioCommitmentDefinition('SCENARIO'));
6529
- registerCommitment(new ScenarioCommitmentDefinition('SCENARIOS'));
6530
- registerCommitment(new DeleteCommitmentDefinition('DELETE'));
6531
- registerCommitment(new DeleteCommitmentDefinition('CANCEL'));
6532
- registerCommitment(new DeleteCommitmentDefinition('DISCARD'));
6533
- registerCommitment(new DeleteCommitmentDefinition('REMOVE'));
6534
- registerCommitment(new OpenCommitmentDefinition());
6535
- registerCommitment(new ClosedCommitmentDefinition());
6536
- // Register not yet implemented commitments
6537
- registerCommitment(new NotYetImplementedCommitmentDefinition('EXPECT'));
6538
- registerCommitment(new NotYetImplementedCommitmentDefinition('BEHAVIOUR'));
6539
- registerCommitment(new NotYetImplementedCommitmentDefinition('BEHAVIOURS'));
6540
- registerCommitment(new NotYetImplementedCommitmentDefinition('AVOID'));
6541
- registerCommitment(new NotYetImplementedCommitmentDefinition('AVOIDANCE'));
6542
- registerCommitment(new NotYetImplementedCommitmentDefinition('CONTEXT'));
6852
+ /**
6853
+ * Registry of all available commitment definitions
6854
+ * This array contains instances of all commitment definitions
6855
+ * This is the single source of truth for all commitments in the system
6856
+ *
6857
+ * @private Use functions to access commitments instead of this array directly
6858
+ */
6859
+ const COMMITMENT_REGISTRY = [
6860
+ // Fully implemented commitments
6861
+ new PersonaCommitmentDefinition('PERSONA'),
6862
+ new PersonaCommitmentDefinition('PERSONAE'),
6863
+ new KnowledgeCommitmentDefinition(),
6864
+ new MemoryCommitmentDefinition('MEMORY'),
6865
+ new MemoryCommitmentDefinition('MEMORIES'),
6866
+ new StyleCommitmentDefinition('STYLE'),
6867
+ new StyleCommitmentDefinition('STYLES'),
6868
+ new RuleCommitmentDefinition('RULE'),
6869
+ new RuleCommitmentDefinition('RULES'),
6870
+ new LanguageCommitmentDefinition('LANGUAGE'),
6871
+ new LanguageCommitmentDefinition('LANGUAGES'),
6872
+ new SampleCommitmentDefinition('SAMPLE'),
6873
+ new SampleCommitmentDefinition('EXAMPLE'),
6874
+ new FormatCommitmentDefinition('FORMAT'),
6875
+ new FormatCommitmentDefinition('FORMATS'),
6876
+ new FromCommitmentDefinition('FROM'),
6877
+ new ModelCommitmentDefinition('MODEL'),
6878
+ new ModelCommitmentDefinition('MODELS'),
6879
+ new ActionCommitmentDefinition('ACTION'),
6880
+ new ActionCommitmentDefinition('ACTIONS'),
6881
+ new ComponentCommitmentDefinition(),
6882
+ new MetaImageCommitmentDefinition(),
6883
+ new MetaColorCommitmentDefinition(),
6884
+ new MetaFontCommitmentDefinition(),
6885
+ new MetaLinkCommitmentDefinition(),
6886
+ new MetaCommitmentDefinition(),
6887
+ new NoteCommitmentDefinition('NOTE'),
6888
+ new NoteCommitmentDefinition('NOTES'),
6889
+ new NoteCommitmentDefinition('COMMENT'),
6890
+ new NoteCommitmentDefinition('NONCE'),
6891
+ new GoalCommitmentDefinition('GOAL'),
6892
+ new GoalCommitmentDefinition('GOALS'),
6893
+ new InitialMessageCommitmentDefinition(),
6894
+ new UserMessageCommitmentDefinition(),
6895
+ new AgentMessageCommitmentDefinition(),
6896
+ new MessageCommitmentDefinition('MESSAGE'),
6897
+ new MessageCommitmentDefinition('MESSAGES'),
6898
+ new ScenarioCommitmentDefinition('SCENARIO'),
6899
+ new ScenarioCommitmentDefinition('SCENARIOS'),
6900
+ new DeleteCommitmentDefinition('DELETE'),
6901
+ new DeleteCommitmentDefinition('CANCEL'),
6902
+ new DeleteCommitmentDefinition('DISCARD'),
6903
+ new DeleteCommitmentDefinition('REMOVE'),
6904
+ new OpenCommitmentDefinition(),
6905
+ new ClosedCommitmentDefinition(),
6906
+ new UseBrowserCommitmentDefinition(),
6907
+ new UseSearchEngineCommitmentDefinition(),
6908
+ new UseMcpCommitmentDefinition(),
6909
+ new UseCommitmentDefinition(),
6910
+ // Not yet implemented commitments (using placeholder)
6911
+ new NotYetImplementedCommitmentDefinition('EXPECT'),
6912
+ new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
6913
+ new NotYetImplementedCommitmentDefinition('BEHAVIOURS'),
6914
+ new NotYetImplementedCommitmentDefinition('AVOID'),
6915
+ new NotYetImplementedCommitmentDefinition('AVOIDANCE'),
6916
+ new NotYetImplementedCommitmentDefinition('CONTEXT'),
6917
+ ];
6918
+ /**
6919
+ * Gets a commitment definition by its type
6920
+ * @param type The commitment type to look up
6921
+ * @returns The commitment definition or null if not found
6922
+ *
6923
+ * @public exported from `@promptbook/core`
6924
+ */
6925
+ function getCommitmentDefinition(type) {
6926
+ return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
6927
+ }
6928
+ /**
6929
+ * Gets all available commitment definitions
6930
+ * @returns Array of all commitment definitions
6931
+ *
6932
+ * @public exported from `@promptbook/core`
6933
+ */
6934
+ function getAllCommitmentDefinitions() {
6935
+ return $deepFreeze([...COMMITMENT_REGISTRY]);
6936
+ }
6937
+ /**
6938
+ * TODO: [๐Ÿง ] Maybe create through standardized $register
6939
+ * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
6940
+ */
6543
6941
 
6942
+ /**
6943
+ * Regex pattern to match horizontal lines (markdown thematic breaks)
6944
+ * Matches 3 or more hyphens, underscores, or asterisks (with optional spaces between)
6945
+ */
6946
+ const HORIZONTAL_LINE_PATTERN = /^[\s]*[-_*][\s]*[-_*][\s]*[-_*][\s]*[-_*]*[\s]*$/;
6544
6947
  /**
6545
6948
  * Parses agent source using the new commitment system with multiline support
6546
6949
  * This function replaces the hardcoded commitment parsing in the original parseAgentSource
@@ -6583,7 +6986,7 @@
6583
6986
  const fullContent = currentCommitment.contentLines.join('\n');
6584
6987
  commitments.push({
6585
6988
  type: currentCommitment.type,
6586
- content: spaceTrim.spaceTrim(fullContent),
6989
+ content: spaceTrim$1.spaceTrim(fullContent),
6587
6990
  originalLine: currentCommitment.originalStartLine,
6588
6991
  lineNumber: currentCommitment.startLineNumber,
6589
6992
  });
@@ -6603,6 +7006,24 @@
6603
7006
  break;
6604
7007
  }
6605
7008
  }
7009
+ // Check if this is a horizontal line (ends any current commitment)
7010
+ const isHorizontalLine = HORIZONTAL_LINE_PATTERN.test(line);
7011
+ if (isHorizontalLine) {
7012
+ // Save the current commitment if it exists
7013
+ if (currentCommitment) {
7014
+ const fullContent = currentCommitment.contentLines.join('\n');
7015
+ commitments.push({
7016
+ type: currentCommitment.type,
7017
+ content: spaceTrim$1.spaceTrim(fullContent),
7018
+ originalLine: currentCommitment.originalStartLine,
7019
+ lineNumber: currentCommitment.startLineNumber,
7020
+ });
7021
+ currentCommitment = null;
7022
+ }
7023
+ // Add horizontal line to non-commitment lines
7024
+ nonCommitmentLines.push(line);
7025
+ continue;
7026
+ }
6606
7027
  if (!foundNewCommitment) {
6607
7028
  if (currentCommitment) {
6608
7029
  // This line belongs to the current commitment
@@ -6619,7 +7040,7 @@
6619
7040
  const fullContent = currentCommitment.contentLines.join('\n');
6620
7041
  commitments.push({
6621
7042
  type: currentCommitment.type,
6622
- content: spaceTrim.spaceTrim(fullContent),
7043
+ content: spaceTrim$1.spaceTrim(fullContent),
6623
7044
  originalLine: currentCommitment.originalStartLine,
6624
7045
  lineNumber: currentCommitment.startLineNumber,
6625
7046
  });
@@ -6741,6 +7162,10 @@
6741
7162
  meta.color = spaceTrim__default["default"](commitment.content);
6742
7163
  continue;
6743
7164
  }
7165
+ if (commitment.type === 'META FONT') {
7166
+ meta.font = spaceTrim__default["default"](commitment.content);
7167
+ continue;
7168
+ }
6744
7169
  if (commitment.type !== 'META') {
6745
7170
  continue;
6746
7171
  }
@@ -8533,9 +8958,9 @@
8533
8958
  const mdSaveFormatDefinition = {
8534
8959
  formatName: 'md',
8535
8960
  label: 'Markdown',
8536
- getContent: ({ messages }) => spaceTrim.spaceTrim(`
8961
+ getContent: ({ messages }) => spaceTrim$1.spaceTrim(`
8537
8962
  ${messages
8538
- .map((message) => spaceTrim.spaceTrim(`
8963
+ .map((message) => spaceTrim$1.spaceTrim(`
8539
8964
  **${message.from}:**
8540
8965
 
8541
8966
  > ${message.content.replace(/\n/g, '\n> ')}
@@ -8796,7 +9221,7 @@
8796
9221
  // Note: Do not hide tooltip on mouse leave, it will be hidden by clicking outside
8797
9222
  };
8798
9223
  const isMe = participant === null || participant === void 0 ? void 0 : participant.isMe;
8799
- const color = Color.from((participant && participant.color) || (isMe ? USER_CHAT_COLOR : PROMPTBOOK_CHAT_COLOR));
9224
+ const color = Color.fromSafe((participant && participant.color) || (isMe ? USER_CHAT_COLOR : PROMPTBOOK_CHAT_COLOR));
8800
9225
  const colorOfText = color.then(textColor);
8801
9226
  const { contentWithoutButtons, buttons } = parseMessageButtons(message.content);
8802
9227
  const shouldShowButtons = isLastMessage && buttons.length > 0 && onMessage;
@@ -9433,7 +9858,7 @@
9433
9858
  * @public exported from `@promptbook/components`
9434
9859
  */
9435
9860
  function LlmChat(props) {
9436
- const { llmTools, persistenceKey, onChange, onReset, initialMessages, sendMessage, userParticipantName = 'USER', llmParticipantName = 'ASSISTANT', ...restProps } = props;
9861
+ const { llmTools, persistenceKey, onChange, onReset, initialMessages, sendMessage, userParticipantName = 'USER', llmParticipantName = 'ASSISTANT', autoExecuteMessage, ...restProps } = props;
9437
9862
  // Internal state management
9438
9863
  // DRY: Single factory for seeding initial messages (used on mount and after reset)
9439
9864
  const buildInitialMessages = react.useCallback(() => (initialMessages ? [...initialMessages] : []), [initialMessages]);
@@ -9767,6 +10192,14 @@
9767
10192
  sendMessage._attach(handleMessage);
9768
10193
  }
9769
10194
  }, [sendMessage, handleMessage]);
10195
+ // Handle autoExecuteMessage
10196
+ const hasAutoExecutedRef = react.useRef(false);
10197
+ react.useEffect(() => {
10198
+ if (autoExecuteMessage && !hasAutoExecutedRef.current) {
10199
+ hasAutoExecutedRef.current = true;
10200
+ handleMessage(autoExecuteMessage);
10201
+ }
10202
+ }, [autoExecuteMessage, handleMessage]);
9770
10203
  return (jsxRuntime.jsx(Chat, { ...restProps, messages, onReset, tasksProgress, participants, onMessage: handleMessage, onReset: handleReset, onVoiceInput: llmTools.callVoiceChatModel ? handleVoiceInput : undefined, isVoiceCalling: isVoiceCalling }));
9771
10204
  }
9772
10205
 
@@ -10711,7 +11144,7 @@
10711
11144
  if (!(error instanceof PipelineLogicError)) {
10712
11145
  throw error;
10713
11146
  }
10714
- console.error(spaceTrim.spaceTrim((block) => `
11147
+ console.error(spaceTrim$1.spaceTrim((block) => `
10715
11148
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
10716
11149
 
10717
11150
  ${block(error.message)}
@@ -10738,7 +11171,7 @@
10738
11171
  })();
10739
11172
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
10740
11173
  // <- Note: [๐Ÿšฒ]
10741
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11174
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10742
11175
  Invalid promptbook URL "${pipeline.pipelineUrl}"
10743
11176
 
10744
11177
  ${block(pipelineIdentification)}
@@ -10746,7 +11179,7 @@
10746
11179
  }
10747
11180
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
10748
11181
  // <- Note: [๐Ÿšฒ]
10749
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11182
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10750
11183
  Invalid Promptbook Version "${pipeline.bookVersion}"
10751
11184
 
10752
11185
  ${block(pipelineIdentification)}
@@ -10755,7 +11188,7 @@
10755
11188
  // TODO: [๐Ÿง ] Maybe do here some proper JSON-schema / ZOD checking
10756
11189
  if (!Array.isArray(pipeline.parameters)) {
10757
11190
  // TODO: [๐Ÿง ] what is the correct error tp throw - maybe PromptbookSchemaError
10758
- throw new ParseError(spaceTrim.spaceTrim((block) => `
11191
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
10759
11192
  Pipeline is valid JSON but with wrong structure
10760
11193
 
10761
11194
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -10766,7 +11199,7 @@
10766
11199
  // TODO: [๐Ÿง ] Maybe do here some proper JSON-schema / ZOD checking
10767
11200
  if (!Array.isArray(pipeline.tasks)) {
10768
11201
  // TODO: [๐Ÿง ] what is the correct error tp throw - maybe PromptbookSchemaError
10769
- throw new ParseError(spaceTrim.spaceTrim((block) => `
11202
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
10770
11203
  Pipeline is valid JSON but with wrong structure
10771
11204
 
10772
11205
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -10792,7 +11225,7 @@
10792
11225
  // Note: Check each parameter individually
10793
11226
  for (const parameter of pipeline.parameters) {
10794
11227
  if (parameter.isInput && parameter.isOutput) {
10795
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11228
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10796
11229
 
10797
11230
  Parameter \`{${parameter.name}}\` can not be both input and output
10798
11231
 
@@ -10803,7 +11236,7 @@
10803
11236
  if (!parameter.isInput &&
10804
11237
  !parameter.isOutput &&
10805
11238
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
10806
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11239
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10807
11240
  Parameter \`{${parameter.name}}\` is created but not used
10808
11241
 
10809
11242
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -10815,7 +11248,7 @@
10815
11248
  }
10816
11249
  // Note: Testing that parameter is either input or result of some task
10817
11250
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
10818
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11251
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10819
11252
  Parameter \`{${parameter.name}}\` is declared but not defined
10820
11253
 
10821
11254
  You can do one of these:
@@ -10831,14 +11264,14 @@
10831
11264
  // Note: Checking each task individually
10832
11265
  for (const task of pipeline.tasks) {
10833
11266
  if (definedParameters.has(task.resultingParameterName)) {
10834
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11267
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10835
11268
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
10836
11269
 
10837
11270
  ${block(pipelineIdentification)}
10838
11271
  `));
10839
11272
  }
10840
11273
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
10841
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11274
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10842
11275
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
10843
11276
 
10844
11277
  ${block(pipelineIdentification)}
@@ -10848,7 +11281,7 @@
10848
11281
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
10849
11282
  if (!task.format &&
10850
11283
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
10851
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11284
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10852
11285
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
10853
11286
 
10854
11287
  ${block(pipelineIdentification)}
@@ -10856,7 +11289,7 @@
10856
11289
  }
10857
11290
  for (const joker of task.jokerParameterNames) {
10858
11291
  if (!task.dependentParameterNames.includes(joker)) {
10859
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11292
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10860
11293
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
10861
11294
 
10862
11295
  ${block(pipelineIdentification)}
@@ -10867,21 +11300,21 @@
10867
11300
  if (task.expectations) {
10868
11301
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
10869
11302
  if (min !== undefined && max !== undefined && min > max) {
10870
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11303
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10871
11304
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
10872
11305
 
10873
11306
  ${block(pipelineIdentification)}
10874
11307
  `));
10875
11308
  }
10876
11309
  if (min !== undefined && min < 0) {
10877
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11310
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10878
11311
  Min expectation of ${unit} must be zero or positive
10879
11312
 
10880
11313
  ${block(pipelineIdentification)}
10881
11314
  `));
10882
11315
  }
10883
11316
  if (max !== undefined && max <= 0) {
10884
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
11317
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
10885
11318
  Max expectation of ${unit} must be positive
10886
11319
 
10887
11320
  ${block(pipelineIdentification)}
@@ -10903,7 +11336,7 @@
10903
11336
  while (unresovedTasks.length > 0) {
10904
11337
  if (loopLimit-- < 0) {
10905
11338
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
10906
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
11339
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
10907
11340
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
10908
11341
 
10909
11342
  ${block(pipelineIdentification)}
@@ -10913,7 +11346,7 @@
10913
11346
  if (currentlyResovedTasks.length === 0) {
10914
11347
  throw new PipelineLogicError(
10915
11348
  // TODO: [๐ŸŽ] DRY
10916
- spaceTrim.spaceTrim((block) => `
11349
+ spaceTrim$1.spaceTrim((block) => `
10917
11350
 
10918
11351
  Can not resolve some parameters:
10919
11352
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -11034,7 +11467,7 @@
11034
11467
  for (const pipeline of pipelines) {
11035
11468
  // TODO: [๐Ÿ‘ ] DRY
11036
11469
  if (pipeline.pipelineUrl === undefined) {
11037
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
11470
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
11038
11471
  Pipeline with name "${pipeline.title}" does not have defined URL
11039
11472
 
11040
11473
  File:
@@ -11056,7 +11489,7 @@
11056
11489
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
11057
11490
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
11058
11491
  const existing = this.collection.get(pipeline.pipelineUrl);
11059
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
11492
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
11060
11493
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection ๐ŸŽ
11061
11494
 
11062
11495
  Conflicting files:
@@ -11088,13 +11521,13 @@
11088
11521
  const pipeline = this.collection.get(url);
11089
11522
  if (!pipeline) {
11090
11523
  if (this.listPipelines().length === 0) {
11091
- throw new NotFoundError(spaceTrim.spaceTrim(`
11524
+ throw new NotFoundError(spaceTrim$1.spaceTrim(`
11092
11525
  Pipeline with url "${url}" not found
11093
11526
 
11094
11527
  No pipelines available
11095
11528
  `));
11096
11529
  }
11097
- throw new NotFoundError(spaceTrim.spaceTrim((block) => `
11530
+ throw new NotFoundError(spaceTrim$1.spaceTrim((block) => `
11098
11531
  Pipeline with url "${url}" not found
11099
11532
 
11100
11533
  Available pipelines:
@@ -11193,11 +11626,11 @@
11193
11626
  throw deserializeError(errors[0]);
11194
11627
  }
11195
11628
  else {
11196
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
11629
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11197
11630
  Multiple errors occurred during Promptbook execution
11198
11631
 
11199
11632
  ${block(errors
11200
- .map(({ name, stack, message }, index) => spaceTrim.spaceTrim((block) => `
11633
+ .map(({ name, stack, message }, index) => spaceTrim$1.spaceTrim((block) => `
11201
11634
  ${name} ${index + 1}:
11202
11635
  ${block(stack || message)}
11203
11636
  `))
@@ -12216,7 +12649,7 @@
12216
12649
  if (task.taskType === 'PROMPT_TASK' &&
12217
12650
  knowledgePiecesCount > 0 &&
12218
12651
  !dependentParameterNames.includes('knowledge')) {
12219
- preparedContent = spaceTrim.spaceTrim(`
12652
+ preparedContent = spaceTrim$1.spaceTrim(`
12220
12653
  {content}
12221
12654
 
12222
12655
  ## Knowledge
@@ -12448,7 +12881,7 @@
12448
12881
  }
12449
12882
  catch (error) {
12450
12883
  assertsError(error);
12451
- throw new ParseError(spaceTrim.spaceTrim((block) => `
12884
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
12452
12885
  Can not extract variables from the script
12453
12886
  ${block(error.stack || error.message)}
12454
12887
 
@@ -12991,7 +13424,7 @@
12991
13424
  }
12992
13425
  catch (error) {
12993
13426
  keepUnused(error);
12994
- throw new ExpectError(spaceTrim.spaceTrim((block) => `
13427
+ throw new ExpectError(spaceTrim$1.spaceTrim((block) => `
12995
13428
  Expected valid JSON string
12996
13429
 
12997
13430
  The expected JSON text:
@@ -13054,7 +13487,7 @@
13054
13487
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
13055
13488
  // TODO: [๐Ÿง ][๐Ÿญ] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
13056
13489
  if (isJokerAttempt && !jokerParameterName) {
13057
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
13490
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
13058
13491
  Joker not found in attempt ${attemptIndex}
13059
13492
 
13060
13493
  ${block(pipelineIdentification)}
@@ -13065,7 +13498,7 @@
13065
13498
  $ongoingTaskResult.$expectError = null;
13066
13499
  if (isJokerAttempt) {
13067
13500
  if (parameters[jokerParameterName] === undefined) {
13068
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
13501
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13069
13502
  Joker parameter {${jokerParameterName}} not defined
13070
13503
 
13071
13504
  ${block(pipelineIdentification)}
@@ -13123,7 +13556,7 @@
13123
13556
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
13124
13557
  break variant;
13125
13558
  case 'EMBEDDING':
13126
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
13559
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13127
13560
  Embedding model can not be used in pipeline
13128
13561
 
13129
13562
  This should be catched during parsing
@@ -13134,7 +13567,7 @@
13134
13567
  break variant;
13135
13568
  // <- case [๐Ÿค–]:
13136
13569
  default:
13137
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
13570
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13138
13571
  Unknown model variant "${task.modelRequirements.modelVariant}"
13139
13572
 
13140
13573
  ${block(pipelineIdentification)}
@@ -13145,14 +13578,14 @@
13145
13578
  break;
13146
13579
  case 'SCRIPT_TASK':
13147
13580
  if (arrayableToArray(tools.script).length === 0) {
13148
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
13581
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13149
13582
  No script execution tools are available
13150
13583
 
13151
13584
  ${block(pipelineIdentification)}
13152
13585
  `));
13153
13586
  }
13154
13587
  if (!task.contentLanguage) {
13155
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
13588
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13156
13589
  Script language is not defined for SCRIPT TASK "${task.name}"
13157
13590
 
13158
13591
  ${block(pipelineIdentification)}
@@ -13183,7 +13616,7 @@
13183
13616
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
13184
13617
  }
13185
13618
  else {
13186
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
13619
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13187
13620
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
13188
13621
 
13189
13622
  ${block(pipelineIdentification)}
@@ -13197,7 +13630,7 @@
13197
13630
  break taskType;
13198
13631
  case 'DIALOG_TASK':
13199
13632
  if (tools.userInterface === undefined) {
13200
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
13633
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13201
13634
  User interface tools are not available
13202
13635
 
13203
13636
  ${block(pipelineIdentification)}
@@ -13215,7 +13648,7 @@
13215
13648
  break taskType;
13216
13649
  // <- case: [๐Ÿ…ฑ]
13217
13650
  default:
13218
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
13651
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13219
13652
  Unknown execution type "${task.taskType}"
13220
13653
 
13221
13654
  ${block(pipelineIdentification)}
@@ -13313,7 +13746,7 @@
13313
13746
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
13314
13747
  // Note: Create a summary of all failures
13315
13748
  const failuresSummary = $ongoingTaskResult.$failedResults
13316
- .map((failure) => spaceTrim.spaceTrim((block) => {
13749
+ .map((failure) => spaceTrim$1.spaceTrim((block) => {
13317
13750
  var _a, _b;
13318
13751
  return `
13319
13752
  Attempt ${failure.attemptIndex + 1}:
@@ -13323,14 +13756,14 @@
13323
13756
  Result:
13324
13757
  ${block(failure.result === null
13325
13758
  ? 'null'
13326
- : spaceTrim.spaceTrim(failure.result)
13759
+ : spaceTrim$1.spaceTrim(failure.result)
13327
13760
  .split('\n')
13328
13761
  .map((line) => `> ${line}`)
13329
13762
  .join('\n'))}
13330
13763
  `;
13331
13764
  }))
13332
13765
  .join('\n\n---\n\n');
13333
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
13766
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => {
13334
13767
  var _a;
13335
13768
  return `
13336
13769
  LLM execution failed ${maxExecutionAttempts}x
@@ -13350,7 +13783,7 @@
13350
13783
  }
13351
13784
  }
13352
13785
  if ($ongoingTaskResult.$resultString === null) {
13353
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
13786
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
13354
13787
  Something went wrong and prompt result is null
13355
13788
 
13356
13789
  ${block(pipelineIdentification)}
@@ -13656,7 +14089,7 @@
13656
14089
  // Note: Doublecheck that ALL reserved parameters are defined:
13657
14090
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
13658
14091
  if (reservedParameters[parameterName] === undefined) {
13659
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
14092
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
13660
14093
  Reserved parameter {${parameterName}} is not defined
13661
14094
 
13662
14095
  ${block(pipelineIdentification)}
@@ -13682,7 +14115,7 @@
13682
14115
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
13683
14116
  // TODO: [๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘ฉ๐Ÿป] Use here `mapAvailableToExpectedParameters`
13684
14117
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
13685
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
14118
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
13686
14119
  Dependent parameters are not consistent with used parameters:
13687
14120
 
13688
14121
  Dependent parameters:
@@ -13726,7 +14159,7 @@
13726
14159
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
13727
14160
  // Houston, we have a problem
13728
14161
  // Note: Checking part is also done in `validatePipeline`, but itโ€™s good to doublecheck
13729
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
14162
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
13730
14163
  Parameter \`{${parameterName}}\` is NOT defined
13731
14164
  BUT used in task "${currentTask.title || currentTask.name}"
13732
14165
 
@@ -13795,7 +14228,7 @@
13795
14228
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
13796
14229
  if (parametersToPass[parameter.name] === undefined) {
13797
14230
  // [4]
13798
- $warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
14231
+ $warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13799
14232
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
13800
14233
 
13801
14234
  Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
@@ -13903,7 +14336,7 @@
13903
14336
  for (const parameterName of Object.keys(inputParameters)) {
13904
14337
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
13905
14338
  if (parameter === undefined) {
13906
- warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
14339
+ warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13907
14340
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
13908
14341
 
13909
14342
  ${block(pipelineIdentification)}
@@ -13918,7 +14351,7 @@
13918
14351
  // TODO: [๐Ÿง ] This should be also non-critical error
13919
14352
  return exportJson({
13920
14353
  name: 'pipelineExecutorResult',
13921
- message: spaceTrim.spaceTrim((block) => `
14354
+ message: spaceTrim$1.spaceTrim((block) => `
13922
14355
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
13923
14356
 
13924
14357
  ${block(pipelineIdentification)}
@@ -13927,7 +14360,7 @@
13927
14360
  value: {
13928
14361
  isSuccessful: false,
13929
14362
  errors: [
13930
- new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
14363
+ new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
13931
14364
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
13932
14365
 
13933
14366
  ${block(pipelineIdentification)}
@@ -13954,7 +14387,7 @@
13954
14387
  while (unresovedTasks.length > 0) {
13955
14388
  if (loopLimit-- < 0) {
13956
14389
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
13957
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
14390
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
13958
14391
  Loop limit reached during resolving parameters pipeline execution
13959
14392
 
13960
14393
  ${block(pipelineIdentification)}
@@ -13964,7 +14397,7 @@
13964
14397
  if (!currentTask && resolving.length === 0) {
13965
14398
  throw new UnexpectedError(
13966
14399
  // TODO: [๐ŸŽ] DRY
13967
- spaceTrim.spaceTrim((block) => `
14400
+ spaceTrim$1.spaceTrim((block) => `
13968
14401
  Can not resolve some parameters:
13969
14402
 
13970
14403
  ${block(pipelineIdentification)}
@@ -14004,7 +14437,7 @@
14004
14437
  tools,
14005
14438
  onProgress(newOngoingResult) {
14006
14439
  if (isReturned) {
14007
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
14440
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
14008
14441
  Can not call \`onProgress\` after pipeline execution is finished
14009
14442
 
14010
14443
  ${block(pipelineIdentification)}
@@ -14021,7 +14454,7 @@
14021
14454
  },
14022
14455
  logLlmCall,
14023
14456
  $executionReport: executionReport,
14024
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
14457
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
14025
14458
  ${block(pipelineIdentification)}
14026
14459
  Task name: ${currentTask.name}
14027
14460
  Task title: ${currentTask.title}
@@ -14130,7 +14563,7 @@
14130
14563
  preparedPipeline = pipeline;
14131
14564
  }
14132
14565
  else if (isNotPreparedWarningSuppressed !== true) {
14133
- console.warn(spaceTrim.spaceTrim((block) => `
14566
+ console.warn(spaceTrim$1.spaceTrim((block) => `
14134
14567
  Pipeline is not prepared
14135
14568
 
14136
14569
  ${block(pipelineIdentification)}
@@ -14155,7 +14588,7 @@
14155
14588
  tools,
14156
14589
  onProgress,
14157
14590
  logLlmCall,
14158
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
14591
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
14159
14592
  ${block(pipelineIdentification)}
14160
14593
  ${runCount === 1 ? '' : `Run #${runCount}`}
14161
14594
  `),
@@ -16093,18 +16526,26 @@
16093
16526
  modelName: 'assistant',
16094
16527
  // <- [๐Ÿง ] What is the best value here
16095
16528
  });
16529
+ // Build thread messages: include previous thread messages + current user message
16530
+ const threadMessages = [];
16531
+ // TODO: [๐Ÿˆน] Maybe this should not be here but in other place, look at commit 39d705e75e5bcf7a818c3af36bc13e1c8475c30c
16532
+ // Add previous messages from thread (if any)
16533
+ if ('thread' in prompt &&
16534
+ Array.isArray(prompt.thread)) {
16535
+ const previousMessages = prompt.thread.map((msg) => ({
16536
+ role: (msg.role === 'assistant' ? 'assistant' : 'user'),
16537
+ content: msg.content,
16538
+ }));
16539
+ threadMessages.push(...previousMessages);
16540
+ }
16541
+ // Always add the current user message
16542
+ threadMessages.push({ role: 'user', content: rawPromptContent });
16096
16543
  const rawRequest = {
16097
16544
  // TODO: [๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ง] ...modelSettings,
16098
16545
  // TODO: [๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ง][๐Ÿง ] What about system message for assistants, does it make sense - combination of OpenAI assistants with Promptbook Personas
16099
16546
  assistant_id: this.assistantId,
16100
16547
  thread: {
16101
- messages: 'thread' in prompt &&
16102
- Array.isArray(prompt.thread)
16103
- ? prompt.thread.map((msg) => ({
16104
- role: msg.role === 'assistant' ? 'assistant' : 'user',
16105
- content: msg.content,
16106
- }))
16107
- : [{ role: 'user', content: rawPromptContent }],
16548
+ messages: threadMessages,
16108
16549
  },
16109
16550
  // <- TODO: Add user identification here> user: this.options.user,
16110
16551
  };
@@ -16124,7 +16565,7 @@
16124
16565
  console.info('textDelta', textDelta.value);
16125
16566
  }
16126
16567
  const chunk = {
16127
- content: textDelta.value || '',
16568
+ content: snapshot.value,
16128
16569
  modelName: 'assistant',
16129
16570
  timing: {
16130
16571
  start,