@promptbook/browser 0.103.0-54 → 0.103.0-56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import spaceTrim$1, { spaceTrim } from 'spacetrim';
1
+ import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
2
2
  import { randomBytes } from 'crypto';
3
3
  import { SHA256 } from 'crypto-js';
4
4
  import hexEncoder from 'crypto-js/enc-hex';
@@ -19,7 +19,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
19
19
  * @generated
20
20
  * @see https://github.com/webgptorg/promptbook
21
21
  */
22
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-54';
22
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
23
23
  /**
24
24
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
25
25
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -77,13 +77,13 @@ class SimplePromptInterfaceTools {
77
77
  * Trigger window.prompt dialog
78
78
  */
79
79
  async promptDialog(options) {
80
- const answer = window.prompt(spaceTrim((block) => `
80
+ const answer = window.prompt(spaceTrim$1((block) => `
81
81
  ${block(options.promptTitle)}
82
82
 
83
83
  ${block(options.promptMessage)}
84
84
  `));
85
85
  if (this.options.isVerbose) {
86
- console.info(spaceTrim((block) => `
86
+ console.info(spaceTrim$1((block) => `
87
87
  📖 ${block(options.promptTitle)}
88
88
  👤 ${block(answer || '🚫 User cancelled prompt')}
89
89
  `));
@@ -151,6 +151,17 @@ const $isRunningInWebWorker = new Function(`
151
151
  * TODO: [🎺]
152
152
  */
153
153
 
154
+ /**
155
+ * Trims string from all 4 sides
156
+ *
157
+ * Note: This is a re-exported function from the `spacetrim` package which is
158
+ * Developed by same author @hejny as this package
159
+ *
160
+ * @public exported from `@promptbook/utils`
161
+ * @see https://github.com/hejny/spacetrim#usage
162
+ */
163
+ const spaceTrim = spaceTrim$1;
164
+
154
165
  /**
155
166
  * @private util of `@promptbook/color`
156
167
  * @de
@@ -199,6 +210,7 @@ function take(initialValue) {
199
210
  * @public exported from `@promptbook/color`
200
211
  */
201
212
  const CSS_COLORS = {
213
+ promptbook: '#79EAFD',
202
214
  transparent: 'rgba(0,0,0,0)',
203
215
  aliceblue: '#f0f8ff',
204
216
  antiquewhite: '#faebd7',
@@ -414,6 +426,28 @@ class Color {
414
426
  throw new Error(`Can not create color from given object`);
415
427
  }
416
428
  }
429
+ /**
430
+ * Creates a new Color instance from miscellaneous formats
431
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
432
+ *
433
+ * @param color
434
+ * @returns Color object
435
+ */
436
+ static fromSafe(color) {
437
+ try {
438
+ return Color.from(color);
439
+ }
440
+ catch (error) {
441
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
442
+ console.warn(spaceTrim((block) => `
443
+ Color.fromSafe error:
444
+ ${block(error.message)}
445
+
446
+ Returning default PROMPTBOOK_COLOR.
447
+ `));
448
+ return Color.fromString('promptbook');
449
+ }
450
+ }
417
451
  /**
418
452
  * Creates a new Color instance from miscellaneous string formats
419
453
  *
@@ -1003,7 +1037,7 @@ const ADMIN_GITHUB_NAME = 'hejny';
1003
1037
  *
1004
1038
  * @public exported from `@promptbook/core`
1005
1039
  */
1006
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1040
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
1007
1041
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1008
1042
  /**
1009
1043
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1096,7 +1130,7 @@ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
1096
1130
  */
1097
1131
  class NotYetImplementedError extends Error {
1098
1132
  constructor(message) {
1099
- super(spaceTrim((block) => `
1133
+ super(spaceTrim$1((block) => `
1100
1134
  ${block(message)}
1101
1135
 
1102
1136
  Note: This feature is not implemented yet but it will be soon.
@@ -1120,7 +1154,7 @@ class NotYetImplementedError extends Error {
1120
1154
  function getErrorReportUrl(error) {
1121
1155
  const report = {
1122
1156
  title: `🐜 Error report from ${NAME}`,
1123
- body: spaceTrim$1((block) => `
1157
+ body: spaceTrim$2((block) => `
1124
1158
 
1125
1159
 
1126
1160
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1163,7 +1197,7 @@ function getErrorReportUrl(error) {
1163
1197
  */
1164
1198
  class UnexpectedError extends Error {
1165
1199
  constructor(message) {
1166
- super(spaceTrim((block) => `
1200
+ super(spaceTrim$1((block) => `
1167
1201
  ${block(message)}
1168
1202
 
1169
1203
  Note: This error should not happen.
@@ -1444,7 +1478,7 @@ function jsonParse(value) {
1444
1478
  }
1445
1479
  else if (typeof value !== 'string') {
1446
1480
  console.error('Can not parse JSON from non-string value.', { text: value });
1447
- throw new Error(spaceTrim$1(`
1481
+ throw new Error(spaceTrim$2(`
1448
1482
  Can not parse JSON from non-string value.
1449
1483
 
1450
1484
  The value type: ${typeof value}
@@ -1458,7 +1492,7 @@ function jsonParse(value) {
1458
1492
  if (!(error instanceof Error)) {
1459
1493
  throw error;
1460
1494
  }
1461
- throw new Error(spaceTrim$1((block) => `
1495
+ throw new Error(spaceTrim$2((block) => `
1462
1496
  ${block(error.message)}
1463
1497
 
1464
1498
  The expected JSON text:
@@ -1518,7 +1552,7 @@ class WrappedError extends Error {
1518
1552
  constructor(whatWasThrown) {
1519
1553
  const tag = `[🤮]`;
1520
1554
  console.error(tag, whatWasThrown);
1521
- super(spaceTrim(`
1555
+ super(spaceTrim$1(`
1522
1556
  Non-Error object was thrown
1523
1557
 
1524
1558
  Note: Look for ${tag} in the console for more details
@@ -1607,7 +1641,7 @@ function checkSerializableAsJson(options) {
1607
1641
  }
1608
1642
  else if (typeof value === 'object') {
1609
1643
  if (value instanceof Date) {
1610
- throw new UnexpectedError(spaceTrim$1((block) => `
1644
+ throw new UnexpectedError(spaceTrim$2((block) => `
1611
1645
  \`${name}\` is Date
1612
1646
 
1613
1647
  Use \`string_date_iso8601\` instead
@@ -1626,7 +1660,7 @@ function checkSerializableAsJson(options) {
1626
1660
  throw new UnexpectedError(`${name} is RegExp`);
1627
1661
  }
1628
1662
  else if (value instanceof Error) {
1629
- throw new UnexpectedError(spaceTrim$1((block) => `
1663
+ throw new UnexpectedError(spaceTrim$2((block) => `
1630
1664
  \`${name}\` is unserialized Error
1631
1665
 
1632
1666
  Use function \`serializeError\`
@@ -1649,7 +1683,7 @@ function checkSerializableAsJson(options) {
1649
1683
  }
1650
1684
  catch (error) {
1651
1685
  assertsError(error);
1652
- throw new UnexpectedError(spaceTrim$1((block) => `
1686
+ throw new UnexpectedError(spaceTrim$2((block) => `
1653
1687
  \`${name}\` is not serializable
1654
1688
 
1655
1689
  ${block(error.stack || error.message)}
@@ -1681,7 +1715,7 @@ function checkSerializableAsJson(options) {
1681
1715
  }
1682
1716
  }
1683
1717
  else {
1684
- throw new UnexpectedError(spaceTrim$1((block) => `
1718
+ throw new UnexpectedError(spaceTrim$2((block) => `
1685
1719
  \`${name}\` is unknown type
1686
1720
 
1687
1721
  Additional message for \`${name}\`:
@@ -1831,7 +1865,7 @@ function isSerializableAsJson(value) {
1831
1865
  */
1832
1866
  function stringifyPipelineJson(pipeline) {
1833
1867
  if (!isSerializableAsJson(pipeline)) {
1834
- throw new UnexpectedError(spaceTrim$1(`
1868
+ throw new UnexpectedError(spaceTrim$2(`
1835
1869
  Cannot stringify the pipeline, because it is not serializable as JSON
1836
1870
 
1837
1871
  There can be multiple reasons:
@@ -2117,7 +2151,7 @@ function valueToString(value) {
2117
2151
  * @public exported from `@promptbook/utils`
2118
2152
  */
2119
2153
  function computeHash(value) {
2120
- return SHA256(hexEncoder.parse(spaceTrim$1(valueToString(value)))).toString( /* hex */);
2154
+ return SHA256(hexEncoder.parse(spaceTrim$2(valueToString(value)))).toString( /* hex */);
2121
2155
  }
2122
2156
  /**
2123
2157
  * TODO: [🥬][🥬] Use this ACRY
@@ -2649,7 +2683,17 @@ new Function(`
2649
2683
  * @public exported from `@promptbook/core`
2650
2684
  */
2651
2685
  function normalizeAgentName(rawAgentName) {
2652
- return titleToName(spaceTrim$1(rawAgentName));
2686
+ return titleToName(spaceTrim$2(rawAgentName));
2687
+ }
2688
+
2689
+ /**
2690
+ * Creates temporary default agent name based on agent source hash
2691
+ *
2692
+ * @public exported from `@promptbook/core`
2693
+ */
2694
+ function createDefaultAgentName(agentSource) {
2695
+ const agentHash = computeAgentHash(agentSource);
2696
+ return normalizeAgentName(`Agent ${agentHash.substring(0, 6)}`);
2653
2697
  }
2654
2698
 
2655
2699
  /**
@@ -2793,7 +2837,7 @@ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
2793
2837
  * Markdown documentation for ACTION commitment.
2794
2838
  */
2795
2839
  get documentation() {
2796
- return spaceTrim(`
2840
+ return spaceTrim$1(`
2797
2841
  # ${this.type}
2798
2842
 
2799
2843
  Defines specific actions or capabilities that the agent can perform.
@@ -2840,6 +2884,133 @@ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
2840
2884
  * Note: [💞] Ignore a discrepancy between file name and entity name
2841
2885
  */
2842
2886
 
2887
+ /**
2888
+ * CLOSED commitment definition
2889
+ *
2890
+ * The CLOSED commitment specifies that the agent CANNOT be modified by conversation.
2891
+ * It prevents the agent from learning from interactions and updating its source code.
2892
+ *
2893
+ * Example usage in agent source:
2894
+ *
2895
+ * ```book
2896
+ * CLOSED
2897
+ * ```
2898
+ *
2899
+ * @private [🪔] Maybe export the commitments through some package
2900
+ */
2901
+ class ClosedCommitmentDefinition extends BaseCommitmentDefinition {
2902
+ constructor() {
2903
+ super('CLOSED');
2904
+ }
2905
+ /**
2906
+ * Short one-line description of CLOSED.
2907
+ */
2908
+ get description() {
2909
+ return 'Prevent the agent from being modified by conversation.';
2910
+ }
2911
+ /**
2912
+ * Icon for this commitment.
2913
+ */
2914
+ get icon() {
2915
+ return '🔒';
2916
+ }
2917
+ /**
2918
+ * Markdown documentation for CLOSED commitment.
2919
+ */
2920
+ get documentation() {
2921
+ return spaceTrim$1(`
2922
+ # CLOSED
2923
+
2924
+ Specifies that the agent **cannot** be modified by conversation with it.
2925
+ This means the agent will **not** learn from interactions and its source code will remain static during conversation.
2926
+
2927
+ By default (if not specified), agents are \`OPEN\` to modification.
2928
+
2929
+ > See also [OPEN](/docs/OPEN)
2930
+
2931
+ ## Example
2932
+
2933
+ \`\`\`book
2934
+ CLOSED
2935
+ \`\`\`
2936
+ `);
2937
+ }
2938
+ applyToAgentModelRequirements(requirements, _content) {
2939
+ const updatedMetadata = {
2940
+ ...requirements.metadata,
2941
+ isClosed: true,
2942
+ };
2943
+ return {
2944
+ ...requirements,
2945
+ metadata: updatedMetadata,
2946
+ };
2947
+ }
2948
+ }
2949
+ /**
2950
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2951
+ */
2952
+
2953
+ /**
2954
+ * COMPONENT commitment definition
2955
+ *
2956
+ * The COMPONENT commitment defines a UI component that the agent can render in the chat.
2957
+ *
2958
+ * @private [🪔] Maybe export the commitments through some package
2959
+ */
2960
+ class ComponentCommitmentDefinition extends BaseCommitmentDefinition {
2961
+ constructor() {
2962
+ super('COMPONENT');
2963
+ }
2964
+ /**
2965
+ * Short one-line description of COMPONENT.
2966
+ */
2967
+ get description() {
2968
+ return 'Define a UI component that the agent can render in the chat.';
2969
+ }
2970
+ /**
2971
+ * Icon for this commitment.
2972
+ */
2973
+ get icon() {
2974
+ return '🧩';
2975
+ }
2976
+ /**
2977
+ * Markdown documentation for COMPONENT commitment.
2978
+ */
2979
+ get documentation() {
2980
+ return spaceTrim$1(`
2981
+ # COMPONENT
2982
+
2983
+ Defines a UI component that the agent can render in the chat.
2984
+
2985
+ ## Key aspects
2986
+
2987
+ - Tells the agent that a specific component is available.
2988
+ - Provides syntax for using the component.
2989
+
2990
+ ## Example
2991
+
2992
+ \`\`\`book
2993
+ COMPONENT Arrow
2994
+ The agent should render an arrow component in the chat UI.
2995
+ Syntax:
2996
+ <Arrow direction="up" color="red" />
2997
+ \`\`\`
2998
+ `);
2999
+ }
3000
+ applyToAgentModelRequirements(requirements, content) {
3001
+ const trimmedContent = content.trim();
3002
+ if (!trimmedContent) {
3003
+ return requirements;
3004
+ }
3005
+ // Add component capability to the system message
3006
+ const componentSection = `Component: ${trimmedContent}`;
3007
+ return this.appendToSystemMessage(requirements, componentSection, '\n\n');
3008
+ }
3009
+ }
3010
+ /**
3011
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3012
+ */
3013
+
2843
3014
  /**
2844
3015
  * DELETE commitment definition
2845
3016
  *
@@ -2878,7 +3049,7 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
2878
3049
  * Markdown documentation for DELETE commitment.
2879
3050
  */
2880
3051
  get documentation() {
2881
- return spaceTrim(`
3052
+ return spaceTrim$1(`
2882
3053
  # DELETE (CANCEL, DISCARD, REMOVE)
2883
3054
 
2884
3055
  A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
@@ -3000,7 +3171,7 @@ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
3000
3171
  * Markdown documentation for FORMAT commitment.
3001
3172
  */
3002
3173
  get documentation() {
3003
- return spaceTrim(`
3174
+ return spaceTrim$1(`
3004
3175
  # ${this.type}
3005
3176
 
3006
3177
  Defines the specific output structure and formatting for responses (data formats, templates, structure).
@@ -3045,6 +3216,79 @@ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
3045
3216
  * Note: [💞] Ignore a discrepancy between file name and entity name
3046
3217
  */
3047
3218
 
3219
+ /**
3220
+ * FROM commitment definition
3221
+ *
3222
+ * The FROM commitment tells the agent that its `agentSource` is inherited from another agent.
3223
+ *
3224
+ * Example usage in agent source:
3225
+ *
3226
+ * ```book
3227
+ * FROM https://s6.ptbk.io/benjamin-white
3228
+ * ```
3229
+ *
3230
+ * @private [🪔] Maybe export the commitments through some package
3231
+ */
3232
+ class FromCommitmentDefinition extends BaseCommitmentDefinition {
3233
+ constructor(type = 'FROM') {
3234
+ super(type);
3235
+ }
3236
+ /**
3237
+ * Short one-line description of FROM.
3238
+ */
3239
+ get description() {
3240
+ return 'Inherit agent source from another agent.';
3241
+ }
3242
+ /**
3243
+ * Icon for this commitment.
3244
+ */
3245
+ get icon() {
3246
+ return '🧬';
3247
+ }
3248
+ /**
3249
+ * Markdown documentation for FROM commitment.
3250
+ */
3251
+ get documentation() {
3252
+ return spaceTrim$1(`
3253
+ # ${this.type}
3254
+
3255
+ Inherits agent source from another agent.
3256
+
3257
+ ## Examples
3258
+
3259
+ \`\`\`book
3260
+ My AI Agent
3261
+
3262
+ FROM https://s6.ptbk.io/benjamin-white
3263
+ RULE Speak only in English.
3264
+ \`\`\`
3265
+ `);
3266
+ }
3267
+ applyToAgentModelRequirements(requirements, content) {
3268
+ const trimmedContent = content.trim();
3269
+ if (!trimmedContent) {
3270
+ return requirements;
3271
+ }
3272
+ // Validate URL
3273
+ try {
3274
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3275
+ const url = new URL(trimmedContent);
3276
+ // TODO: Add more validation if needed (e.g. check for valid protocol)
3277
+ }
3278
+ catch (error) {
3279
+ console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
3280
+ return requirements;
3281
+ }
3282
+ return {
3283
+ ...requirements,
3284
+ parentAgentUrl: trimmedContent,
3285
+ };
3286
+ }
3287
+ }
3288
+ /**
3289
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3290
+ */
3291
+
3048
3292
  /**
3049
3293
  * GOAL commitment definition
3050
3294
  *
@@ -3081,7 +3325,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
3081
3325
  * Markdown documentation for GOAL commitment.
3082
3326
  */
3083
3327
  get documentation() {
3084
- return spaceTrim(`
3328
+ return spaceTrim$1(`
3085
3329
  # ${this.type}
3086
3330
 
3087
3331
  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.
@@ -3183,7 +3427,7 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
3183
3427
  * Markdown documentation for KNOWLEDGE commitment.
3184
3428
  */
3185
3429
  get documentation() {
3186
- return spaceTrim(`
3430
+ return spaceTrim$1(`
3187
3431
  # ${this.type}
3188
3432
 
3189
3433
  Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
@@ -3253,6 +3497,77 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
3253
3497
  * Note: [💞] Ignore a discrepancy between file name and entity name
3254
3498
  */
3255
3499
 
3500
+ /**
3501
+ * LANGUAGE commitment definition
3502
+ *
3503
+ * The LANGUAGE/LANGUAGES commitment specifies the language(s) the agent should use in its responses.
3504
+ *
3505
+ * Example usage in agent source:
3506
+ *
3507
+ * ```book
3508
+ * LANGUAGE English
3509
+ * LANGUAGE French, English and Czech
3510
+ * ```
3511
+ *
3512
+ * @private [🪔] Maybe export the commitments through some package
3513
+ */
3514
+ class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
3515
+ constructor(type = 'LANGUAGE') {
3516
+ super(type);
3517
+ }
3518
+ /**
3519
+ * Short one-line description of LANGUAGE/LANGUAGES.
3520
+ */
3521
+ get description() {
3522
+ return 'Specifies the language(s) the agent should use.';
3523
+ }
3524
+ /**
3525
+ * Icon for this commitment.
3526
+ */
3527
+ get icon() {
3528
+ return '🌐';
3529
+ }
3530
+ /**
3531
+ * Markdown documentation for LANGUAGE/LANGUAGES commitment.
3532
+ */
3533
+ get documentation() {
3534
+ return spaceTrim$1(`
3535
+ # ${this.type}
3536
+
3537
+ Specifies the language(s) the agent should use in its responses.
3538
+ This is a specialized variation of the RULE commitment focused on language constraints.
3539
+
3540
+ ## Examples
3541
+
3542
+ \`\`\`book
3543
+ Paul Smith & Associés
3544
+
3545
+ PERSONA You are a company lawyer.
3546
+ LANGUAGE French, English and Czech
3547
+ \`\`\`
3548
+
3549
+ \`\`\`book
3550
+ Customer Support
3551
+
3552
+ PERSONA You are a customer support agent.
3553
+ LANGUAGE English
3554
+ \`\`\`
3555
+ `);
3556
+ }
3557
+ applyToAgentModelRequirements(requirements, content) {
3558
+ const trimmedContent = content.trim();
3559
+ if (!trimmedContent) {
3560
+ return requirements;
3561
+ }
3562
+ // Add language rule to the system message
3563
+ const languageSection = `Language: ${trimmedContent}`;
3564
+ return this.appendToSystemMessage(requirements, languageSection, '\n\n');
3565
+ }
3566
+ }
3567
+ /**
3568
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3569
+ */
3570
+
3256
3571
  /**
3257
3572
  * MEMORY commitment definition
3258
3573
  *
@@ -3290,7 +3605,7 @@ class MemoryCommitmentDefinition extends BaseCommitmentDefinition {
3290
3605
  * Markdown documentation for MEMORY commitment.
3291
3606
  */
3292
3607
  get documentation() {
3293
- return spaceTrim(`
3608
+ return spaceTrim$1(`
3294
3609
  # ${this.type}
3295
3610
 
3296
3611
  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.
@@ -3394,7 +3709,7 @@ class AgentMessageCommitmentDefinition extends BaseCommitmentDefinition {
3394
3709
  * Markdown documentation for AGENT MESSAGE commitment.
3395
3710
  */
3396
3711
  get documentation() {
3397
- return spaceTrim(`
3712
+ return spaceTrim$1(`
3398
3713
  # ${this.type}
3399
3714
 
3400
3715
  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.
@@ -3471,7 +3786,7 @@ class InitialMessageCommitmentDefinition extends BaseCommitmentDefinition {
3471
3786
  * Markdown documentation for INITIAL MESSAGE commitment.
3472
3787
  */
3473
3788
  get documentation() {
3474
- return spaceTrim(`
3789
+ return spaceTrim$1(`
3475
3790
  # ${this.type}
3476
3791
 
3477
3792
  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).
@@ -3535,7 +3850,7 @@ class MessageCommitmentDefinition extends BaseCommitmentDefinition {
3535
3850
  * Markdown documentation for MESSAGE commitment.
3536
3851
  */
3537
3852
  get documentation() {
3538
- return spaceTrim(`
3853
+ return spaceTrim$1(`
3539
3854
  # ${this.type}
3540
3855
 
3541
3856
  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.
@@ -3647,7 +3962,7 @@ class UserMessageCommitmentDefinition extends BaseCommitmentDefinition {
3647
3962
  * Markdown documentation for USER MESSAGE commitment.
3648
3963
  */
3649
3964
  get documentation() {
3650
- return spaceTrim(`
3965
+ return spaceTrim$1(`
3651
3966
  # ${this.type}
3652
3967
 
3653
3968
  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.
@@ -3726,7 +4041,7 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
3726
4041
  * Markdown documentation for META commitment.
3727
4042
  */
3728
4043
  get documentation() {
3729
- return spaceTrim(`
4044
+ return spaceTrim$1(`
3730
4045
  # META
3731
4046
 
3732
4047
  Sets meta-information about the agent that is used for display and attribution purposes.
@@ -3837,6 +4152,12 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
3837
4152
  * META COLOR #00ff00
3838
4153
  * ```
3839
4154
  *
4155
+ * You can also specify multiple colors separated by comma:
4156
+ *
4157
+ * ```book
4158
+ * META COLOR #ff0000, #00ff00, #0000ff
4159
+ * ```
4160
+ *
3840
4161
  * @private [🪔] Maybe export the commitments through some package
3841
4162
  */
3842
4163
  class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
@@ -3847,7 +4168,7 @@ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
3847
4168
  * Short one-line description of META COLOR.
3848
4169
  */
3849
4170
  get description() {
3850
- return "Set the agent's accent color.";
4171
+ return "Set the agent's accent color or gradient.";
3851
4172
  }
3852
4173
  /**
3853
4174
  * Icon for this commitment.
@@ -3859,10 +4180,10 @@ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
3859
4180
  * Markdown documentation for META COLOR commitment.
3860
4181
  */
3861
4182
  get documentation() {
3862
- return spaceTrim(`
4183
+ return spaceTrim$1(`
3863
4184
  # META COLOR
3864
4185
 
3865
- Sets the agent's accent color.
4186
+ Sets the agent's accent color or gradient.
3866
4187
 
3867
4188
  ## Key aspects
3868
4189
 
@@ -3870,6 +4191,7 @@ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
3870
4191
  - Only one \`META COLOR\` should be used per agent.
3871
4192
  - If multiple are specified, the last one takes precedence.
3872
4193
  - Used for visual representation in user interfaces.
4194
+ - Can specify multiple colors separated by comma to create a gradient.
3873
4195
 
3874
4196
  ## Examples
3875
4197
 
@@ -3886,6 +4208,13 @@ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
3886
4208
  META COLOR #e74c3c
3887
4209
  PERSONA You are a creative and inspiring assistant
3888
4210
  \`\`\`
4211
+
4212
+ \`\`\`book
4213
+ Gradient Agent
4214
+
4215
+ META COLOR #ff0000, #00ff00, #0000ff
4216
+ PERSONA You are a colorful agent
4217
+ \`\`\`
3889
4218
  `);
3890
4219
  }
3891
4220
  applyToAgentModelRequirements(requirements, content) {
@@ -3908,84 +4237,82 @@ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
3908
4237
  */
3909
4238
 
3910
4239
  /**
3911
- * META IMAGE commitment definition
4240
+ * META FONT commitment definition
3912
4241
  *
3913
- * The META IMAGE commitment sets the agent's avatar/profile image URL.
4242
+ * The META FONT commitment sets the agent's font.
3914
4243
  * This commitment is special because it doesn't affect the system message,
3915
4244
  * but is handled separately in the parsing logic.
3916
4245
  *
3917
4246
  * Example usage in agent source:
3918
4247
  *
3919
4248
  * ```book
3920
- * META IMAGE https://example.com/avatar.jpg
3921
- * META IMAGE /assets/agent-avatar.png
4249
+ * META FONT Poppins, Arial, sans-serif
4250
+ * META FONT Roboto
3922
4251
  * ```
3923
4252
  *
3924
4253
  * @private [🪔] Maybe export the commitments through some package
3925
4254
  */
3926
- class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
4255
+ class MetaFontCommitmentDefinition extends BaseCommitmentDefinition {
3927
4256
  constructor() {
3928
- super('META IMAGE', ['IMAGE']);
4257
+ super('META FONT', ['FONT']);
3929
4258
  }
3930
4259
  /**
3931
- * Short one-line description of META IMAGE.
4260
+ * Short one-line description of META FONT.
3932
4261
  */
3933
4262
  get description() {
3934
- return "Set the agent's profile image URL.";
4263
+ return "Set the agent's font.";
3935
4264
  }
3936
4265
  /**
3937
4266
  * Icon for this commitment.
3938
4267
  */
3939
4268
  get icon() {
3940
- return '🖼️';
4269
+ return '🔤';
3941
4270
  }
3942
4271
  /**
3943
- * Markdown documentation for META IMAGE commitment.
4272
+ * Markdown documentation for META FONT commitment.
3944
4273
  */
3945
4274
  get documentation() {
3946
- return spaceTrim(`
3947
- # META IMAGE
4275
+ return spaceTrim$1(`
4276
+ # META FONT
3948
4277
 
3949
- Sets the agent's avatar/profile image URL.
4278
+ Sets the agent's font.
3950
4279
 
3951
4280
  ## Key aspects
3952
4281
 
3953
4282
  - Does not modify the agent's behavior or responses.
3954
- - Only one \`META IMAGE\` should be used per agent.
4283
+ - Only one \`META FONT\` should be used per agent.
3955
4284
  - If multiple are specified, the last one takes precedence.
3956
4285
  - Used for visual representation in user interfaces.
4286
+ - Supports Google Fonts.
3957
4287
 
3958
4288
  ## Examples
3959
4289
 
3960
4290
  \`\`\`book
3961
- Professional Assistant
4291
+ Modern Assistant
3962
4292
 
3963
- META IMAGE https://example.com/professional-avatar.jpg
3964
- PERSONA You are a professional business assistant
3965
- STYLE Maintain a formal and courteous tone
4293
+ META FONT Poppins, Arial, sans-serif
4294
+ PERSONA You are a modern assistant
3966
4295
  \`\`\`
3967
4296
 
3968
4297
  \`\`\`book
3969
- Creative Helper
4298
+ Classic Helper
3970
4299
 
3971
- META IMAGE /assets/creative-bot-avatar.png
3972
- PERSONA You are a creative and inspiring assistant
3973
- STYLE Be enthusiastic and encouraging
3974
- ACTION Can help with brainstorming and ideation
4300
+ META FONT Times New Roman
4301
+ PERSONA You are a classic helper
3975
4302
  \`\`\`
3976
4303
  `);
3977
4304
  }
3978
4305
  applyToAgentModelRequirements(requirements, content) {
3979
- // META IMAGE doesn't modify the system message or model requirements
3980
- // It's handled separately in the parsing logic for profile image extraction
4306
+ // META FONT doesn't modify the system message or model requirements
4307
+ // It's handled separately in the parsing logic
3981
4308
  // This method exists for consistency with the CommitmentDefinition interface
3982
4309
  return requirements;
3983
4310
  }
3984
4311
  /**
3985
- * Extracts the profile image URL from the content
4312
+ * Extracts the font from the content
3986
4313
  * This is used by the parsing logic
3987
4314
  */
3988
- extractProfileImageUrl(content) {
4315
+ extractProfileFont(content) {
3989
4316
  const trimmedContent = content.trim();
3990
4317
  return trimmedContent || null;
3991
4318
  }
@@ -3995,10 +4322,206 @@ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
3995
4322
  */
3996
4323
 
3997
4324
  /**
3998
- * MODEL commitment definition
4325
+ * META IMAGE commitment definition
3999
4326
  *
4000
- * The MODEL commitment specifies which AI model to use and can also set
4001
- * model-specific parameters like temperature, topP, topK, and maxTokens.
4327
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
4328
+ * This commitment is special because it doesn't affect the system message,
4329
+ * but is handled separately in the parsing logic.
4330
+ *
4331
+ * Example usage in agent source:
4332
+ *
4333
+ * ```book
4334
+ * META IMAGE https://example.com/avatar.jpg
4335
+ * META IMAGE /assets/agent-avatar.png
4336
+ * ```
4337
+ *
4338
+ * @private [🪔] Maybe export the commitments through some package
4339
+ */
4340
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
4341
+ constructor() {
4342
+ super('META IMAGE', ['IMAGE']);
4343
+ }
4344
+ /**
4345
+ * Short one-line description of META IMAGE.
4346
+ */
4347
+ get description() {
4348
+ return "Set the agent's profile image URL.";
4349
+ }
4350
+ /**
4351
+ * Icon for this commitment.
4352
+ */
4353
+ get icon() {
4354
+ return '🖼️';
4355
+ }
4356
+ /**
4357
+ * Markdown documentation for META IMAGE commitment.
4358
+ */
4359
+ get documentation() {
4360
+ return spaceTrim$1(`
4361
+ # META IMAGE
4362
+
4363
+ Sets the agent's avatar/profile image URL.
4364
+
4365
+ ## Key aspects
4366
+
4367
+ - Does not modify the agent's behavior or responses.
4368
+ - Only one \`META IMAGE\` should be used per agent.
4369
+ - If multiple are specified, the last one takes precedence.
4370
+ - Used for visual representation in user interfaces.
4371
+
4372
+ ## Examples
4373
+
4374
+ \`\`\`book
4375
+ Professional Assistant
4376
+
4377
+ META IMAGE https://example.com/professional-avatar.jpg
4378
+ PERSONA You are a professional business assistant
4379
+ STYLE Maintain a formal and courteous tone
4380
+ \`\`\`
4381
+
4382
+ \`\`\`book
4383
+ Creative Helper
4384
+
4385
+ META IMAGE /assets/creative-bot-avatar.png
4386
+ PERSONA You are a creative and inspiring assistant
4387
+ STYLE Be enthusiastic and encouraging
4388
+ ACTION Can help with brainstorming and ideation
4389
+ \`\`\`
4390
+ `);
4391
+ }
4392
+ applyToAgentModelRequirements(requirements, content) {
4393
+ // META IMAGE doesn't modify the system message or model requirements
4394
+ // It's handled separately in the parsing logic for profile image extraction
4395
+ // This method exists for consistency with the CommitmentDefinition interface
4396
+ return requirements;
4397
+ }
4398
+ /**
4399
+ * Extracts the profile image URL from the content
4400
+ * This is used by the parsing logic
4401
+ */
4402
+ extractProfileImageUrl(content) {
4403
+ const trimmedContent = content.trim();
4404
+ return trimmedContent || null;
4405
+ }
4406
+ }
4407
+ /**
4408
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4409
+ */
4410
+
4411
+ /**
4412
+ * META LINK commitment definition
4413
+ *
4414
+ * The `META LINK` commitment represents the link to the person from whom the agent is created.
4415
+ * This commitment is special because it doesn't affect the system message,
4416
+ * but is handled separately in the parsing logic for profile display.
4417
+ *
4418
+ * Example usage in agent source:
4419
+ *
4420
+ * ```
4421
+ * META LINK https://twitter.com/username
4422
+ * META LINK https://linkedin.com/in/profile
4423
+ * META LINK https://github.com/username
4424
+ * ```
4425
+ *
4426
+ * Multiple `META LINK` commitments can be used when there are multiple sources:
4427
+ *
4428
+ * ```book
4429
+ * META LINK https://twitter.com/username
4430
+ * META LINK https://linkedin.com/in/profile
4431
+ * ```
4432
+ *
4433
+ * @private [🪔] Maybe export the commitments through some package
4434
+ */
4435
+ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
4436
+ constructor() {
4437
+ super('META LINK');
4438
+ }
4439
+ /**
4440
+ * Short one-line description of META LINK.
4441
+ */
4442
+ get description() {
4443
+ return 'Provide profile/source links for the person the agent models.';
4444
+ }
4445
+ /**
4446
+ * Icon for this commitment.
4447
+ */
4448
+ get icon() {
4449
+ return '🔗';
4450
+ }
4451
+ /**
4452
+ * Markdown documentation for META LINK commitment.
4453
+ */
4454
+ get documentation() {
4455
+ return spaceTrim$1(`
4456
+ # META LINK
4457
+
4458
+ Represents a profile or source link for the person the agent is modeled after.
4459
+
4460
+ ## Key aspects
4461
+
4462
+ - Does not modify the agent's behavior or responses.
4463
+ - Multiple \`META LINK\` commitments can be used for different social profiles.
4464
+ - Used for attribution and crediting the original person.
4465
+ - Displayed in user interfaces for transparency.
4466
+
4467
+ ## Examples
4468
+
4469
+ \`\`\`book
4470
+ Expert Consultant
4471
+
4472
+ META LINK https://twitter.com/expertname
4473
+ META LINK https://linkedin.com/in/expertprofile
4474
+ PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
4475
+ KNOWLEDGE Extensive background in machine learning and neural networks
4476
+ \`\`\`
4477
+
4478
+ \`\`\`book
4479
+ Open Source Developer
4480
+
4481
+ META LINK https://github.com/developer
4482
+ META LINK https://twitter.com/devhandle
4483
+ PERSONA You are an experienced open source developer
4484
+ ACTION Can help with code reviews and architecture decisions
4485
+ STYLE Be direct and technical in explanations
4486
+ \`\`\`
4487
+ `);
4488
+ }
4489
+ applyToAgentModelRequirements(requirements, content) {
4490
+ // META LINK doesn't modify the system message or model requirements
4491
+ // It's handled separately in the parsing logic for profile link extraction
4492
+ // This method exists for consistency with the CommitmentDefinition interface
4493
+ return requirements;
4494
+ }
4495
+ /**
4496
+ * Extracts the profile link URL from the content
4497
+ * This is used by the parsing logic
4498
+ */
4499
+ extractProfileLinkUrl(content) {
4500
+ const trimmedContent = content.trim();
4501
+ return trimmedContent || null;
4502
+ }
4503
+ /**
4504
+ * Validates if the provided content is a valid URL
4505
+ */
4506
+ isValidUrl(content) {
4507
+ try {
4508
+ new URL(content.trim());
4509
+ return true;
4510
+ }
4511
+ catch (_a) {
4512
+ return false;
4513
+ }
4514
+ }
4515
+ }
4516
+ /**
4517
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4518
+ */
4519
+
4520
+ /**
4521
+ * MODEL commitment definition
4522
+ *
4523
+ * The MODEL commitment specifies which AI model to use and can also set
4524
+ * model-specific parameters like temperature, topP, topK, and maxTokens.
4002
4525
  *
4003
4526
  * Supports multiple syntax variations:
4004
4527
  *
@@ -4039,7 +4562,7 @@ class ModelCommitmentDefinition extends BaseCommitmentDefinition {
4039
4562
  * Markdown documentation for MODEL commitment.
4040
4563
  */
4041
4564
  get documentation() {
4042
- return spaceTrim(`
4565
+ return spaceTrim$1(`
4043
4566
  # ${this.type}
4044
4567
 
4045
4568
  Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
@@ -4280,7 +4803,7 @@ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
4280
4803
  * Markdown documentation for NOTE commitment.
4281
4804
  */
4282
4805
  get documentation() {
4283
- return spaceTrim(`
4806
+ return spaceTrim$1(`
4284
4807
  # ${this.type}
4285
4808
 
4286
4809
  Adds comments for documentation without changing agent behavior.
@@ -4345,6 +4868,74 @@ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
4345
4868
  * [💞] Ignore a discrepancy between file name and entity name
4346
4869
  */
4347
4870
 
4871
+ /**
4872
+ * OPEN commitment definition
4873
+ *
4874
+ * The OPEN commitment specifies that the agent can be modified by conversation.
4875
+ * This is the default behavior.
4876
+ *
4877
+ * Example usage in agent source:
4878
+ *
4879
+ * ```book
4880
+ * OPEN
4881
+ * ```
4882
+ *
4883
+ * @private [🪔] Maybe export the commitments through some package
4884
+ */
4885
+ class OpenCommitmentDefinition extends BaseCommitmentDefinition {
4886
+ constructor() {
4887
+ super('OPEN');
4888
+ }
4889
+ /**
4890
+ * Short one-line description of OPEN.
4891
+ */
4892
+ get description() {
4893
+ return 'Allow the agent to be modified by conversation (default).';
4894
+ }
4895
+ /**
4896
+ * Icon for this commitment.
4897
+ */
4898
+ get icon() {
4899
+ return '🔓';
4900
+ }
4901
+ /**
4902
+ * Markdown documentation for OPEN commitment.
4903
+ */
4904
+ get documentation() {
4905
+ return spaceTrim$1(`
4906
+ # OPEN
4907
+
4908
+ Specifies that the agent can be modified by conversation with it.
4909
+ This means the agent will learn from interactions and update its source code.
4910
+
4911
+ This is the default behavior if neither \`OPEN\` nor \`CLOSED\` is specified.
4912
+
4913
+ > See also [CLOSED](/docs/CLOSED)
4914
+
4915
+ ## Example
4916
+
4917
+ \`\`\`book
4918
+ OPEN
4919
+ \`\`\`
4920
+ `);
4921
+ }
4922
+ applyToAgentModelRequirements(requirements, _content) {
4923
+ // Since OPEN is default, we can just ensure isClosed is false
4924
+ // But to be explicit we can set it
4925
+ const updatedMetadata = {
4926
+ ...requirements.metadata,
4927
+ isClosed: false,
4928
+ };
4929
+ return {
4930
+ ...requirements,
4931
+ metadata: updatedMetadata,
4932
+ };
4933
+ }
4934
+ }
4935
+ /**
4936
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4937
+ */
4938
+
4348
4939
  /**
4349
4940
  * PERSONA commitment definition
4350
4941
  *
@@ -4388,7 +4979,7 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
4388
4979
  * Markdown documentation for PERSONA commitment.
4389
4980
  */
4390
4981
  get documentation() {
4391
- return spaceTrim(`
4982
+ return spaceTrim$1(`
4392
4983
  # ${this.type}
4393
4984
 
4394
4985
  Defines who the agent is, their background, expertise, and personality traits.
@@ -4521,7 +5112,7 @@ class RuleCommitmentDefinition extends BaseCommitmentDefinition {
4521
5112
  * Markdown documentation for RULE/RULES commitment.
4522
5113
  */
4523
5114
  get documentation() {
4524
- return spaceTrim(`
5115
+ return spaceTrim$1(`
4525
5116
  # ${this.type}
4526
5117
 
4527
5118
  Adds behavioral constraints and guidelines that the agent must follow.
@@ -4603,7 +5194,7 @@ class SampleCommitmentDefinition extends BaseCommitmentDefinition {
4603
5194
  * Markdown documentation for SAMPLE/EXAMPLE commitment.
4604
5195
  */
4605
5196
  get documentation() {
4606
- return spaceTrim(`
5197
+ return spaceTrim$1(`
4607
5198
  # ${this.type}
4608
5199
 
4609
5200
  Provides examples of how the agent should respond or behave in certain situations.
@@ -4686,7 +5277,7 @@ class ScenarioCommitmentDefinition extends BaseCommitmentDefinition {
4686
5277
  * Markdown documentation for SCENARIO commitment.
4687
5278
  */
4688
5279
  get documentation() {
4689
- return spaceTrim(`
5280
+ return spaceTrim$1(`
4690
5281
  # ${this.type}
4691
5282
 
4692
5283
  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.
@@ -4808,7 +5399,7 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
4808
5399
  * Markdown documentation for STYLE commitment.
4809
5400
  */
4810
5401
  get documentation() {
4811
- return spaceTrim(`
5402
+ return spaceTrim$1(`
4812
5403
  # ${this.type}
4813
5404
 
4814
5405
  Defines how the agent should format and present its responses (tone, writing style, formatting).
@@ -4855,6 +5446,389 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
4855
5446
  * [💞] Ignore a discrepancy between file name and entity name
4856
5447
  */
4857
5448
 
5449
+ /**
5450
+ * USE commitment definition
5451
+ *
5452
+ * The USE commitment indicates that the agent should utilize specific tools or capabilities
5453
+ * to access and interact with external systems when necessary.
5454
+ *
5455
+ * Supported USE types:
5456
+ * - USE BROWSER: Enables the agent to use a web browser tool
5457
+ * - USE SEARCH ENGINE (future): Enables search engine access
5458
+ * - USE FILE SYSTEM (future): Enables file system operations
5459
+ * - USE MCP (future): Enables MCP server connections
5460
+ *
5461
+ * The content following the USE commitment is ignored (similar to NOTE).
5462
+ *
5463
+ * Example usage in agent source:
5464
+ *
5465
+ * ```book
5466
+ * USE BROWSER
5467
+ * USE SEARCH ENGINE
5468
+ * ```
5469
+ *
5470
+ * @private [🪔] Maybe export the commitments through some package
5471
+ */
5472
+ class UseCommitmentDefinition extends BaseCommitmentDefinition {
5473
+ constructor() {
5474
+ super('USE');
5475
+ }
5476
+ /**
5477
+ * Short one-line description of USE commitments.
5478
+ */
5479
+ get description() {
5480
+ return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
5481
+ }
5482
+ /**
5483
+ * Icon for this commitment.
5484
+ */
5485
+ get icon() {
5486
+ return '🔧';
5487
+ }
5488
+ /**
5489
+ * Markdown documentation for USE commitment.
5490
+ */
5491
+ get documentation() {
5492
+ return spaceTrim$1(`
5493
+ # USE
5494
+
5495
+ Enables the agent to use specific tools or capabilities for interacting with external systems.
5496
+
5497
+ ## Supported USE types
5498
+
5499
+ - **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
5500
+ - **USE SEARCH ENGINE** (future) - Enables search engine access
5501
+ - **USE FILE SYSTEM** (future) - Enables file system operations
5502
+ - **USE MCP** (future) - Enables MCP server connections
5503
+
5504
+ ## Key aspects
5505
+
5506
+ - The content following the USE commitment is ignored (similar to NOTE)
5507
+ - Multiple USE commitments can be specified to enable multiple capabilities
5508
+ - The actual tool usage is handled by the agent runtime
5509
+
5510
+ ## Examples
5511
+
5512
+ ### Basic browser usage
5513
+
5514
+ \`\`\`book
5515
+ Research Assistant
5516
+
5517
+ PERSONA You are a helpful research assistant
5518
+ USE BROWSER
5519
+ KNOWLEDGE Can search the web for up-to-date information
5520
+ \`\`\`
5521
+
5522
+ ### Multiple tools
5523
+
5524
+ \`\`\`book
5525
+ Data Analyst
5526
+
5527
+ PERSONA You are a data analyst assistant
5528
+ USE BROWSER
5529
+ USE FILE SYSTEM
5530
+ ACTION Can analyze data from various sources
5531
+ \`\`\`
5532
+ `);
5533
+ }
5534
+ applyToAgentModelRequirements(requirements, content) {
5535
+ // USE commitments don't modify the system message or model requirements directly
5536
+ // They are handled separately in the parsing logic for capability extraction
5537
+ // This method exists for consistency with the CommitmentDefinition interface
5538
+ return requirements;
5539
+ }
5540
+ /**
5541
+ * Extracts the tool type from the USE commitment
5542
+ * This is used by the parsing logic
5543
+ */
5544
+ extractToolType(content) {
5545
+ var _a, _b;
5546
+ const trimmedContent = content.trim();
5547
+ // The tool type is the first word after USE (already stripped)
5548
+ const match = trimmedContent.match(/^(\w+)/);
5549
+ 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;
5550
+ }
5551
+ /**
5552
+ * Checks if this is a known USE type
5553
+ */
5554
+ isKnownUseType(useType) {
5555
+ const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
5556
+ return knownTypes.includes(useType.toUpperCase());
5557
+ }
5558
+ }
5559
+ /**
5560
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5561
+ */
5562
+
5563
+ /**
5564
+ * USE BROWSER commitment definition
5565
+ *
5566
+ * The `USE BROWSER` commitment indicates that the agent should utilize a web browser tool
5567
+ * to access and retrieve up-to-date information from the internet when necessary.
5568
+ *
5569
+ * The content following `USE BROWSER` is ignored (similar to NOTE).
5570
+ *
5571
+ * Example usage in agent source:
5572
+ *
5573
+ * ```book
5574
+ * USE BROWSER
5575
+ * USE BROWSER This will be ignored
5576
+ * ```
5577
+ *
5578
+ * @private [🪔] Maybe export the commitments through some package
5579
+ */
5580
+ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
5581
+ constructor() {
5582
+ super('USE BROWSER', ['BROWSER']);
5583
+ }
5584
+ /**
5585
+ * Short one-line description of USE BROWSER.
5586
+ */
5587
+ get description() {
5588
+ return 'Enable the agent to use a web browser tool for accessing internet information.';
5589
+ }
5590
+ /**
5591
+ * Icon for this commitment.
5592
+ */
5593
+ get icon() {
5594
+ return '🌐';
5595
+ }
5596
+ /**
5597
+ * Markdown documentation for USE BROWSER commitment.
5598
+ */
5599
+ get documentation() {
5600
+ return spaceTrim$1(`
5601
+ # USE BROWSER
5602
+
5603
+ Enables the agent to use a web browser tool to access and retrieve up-to-date information from the internet.
5604
+
5605
+ ## Key aspects
5606
+
5607
+ - The content following \`USE BROWSER\` is ignored (similar to NOTE)
5608
+ - The actual browser tool usage is handled by the agent runtime
5609
+ - Allows the agent to fetch current information from websites
5610
+ - Useful for research tasks, fact-checking, and accessing dynamic content
5611
+
5612
+ ## Examples
5613
+
5614
+ \`\`\`book
5615
+ Research Assistant
5616
+
5617
+ PERSONA You are a helpful research assistant specialized in finding current information
5618
+ USE BROWSER
5619
+ RULE Always cite your sources when providing information from the web
5620
+ \`\`\`
5621
+
5622
+ \`\`\`book
5623
+ News Analyst
5624
+
5625
+ PERSONA You are a news analyst who stays up-to-date with current events
5626
+ USE BROWSER
5627
+ STYLE Present news in a balanced and objective manner
5628
+ ACTION Can search for and summarize news articles
5629
+ \`\`\`
5630
+
5631
+ \`\`\`book
5632
+ Company Lawyer
5633
+
5634
+ PERSONA You are a company lawyer providing legal advice
5635
+ USE BROWSER
5636
+ KNOWLEDGE Corporate law and legal procedures
5637
+ RULE Always recommend consulting with a licensed attorney for specific legal matters
5638
+ \`\`\`
5639
+ `);
5640
+ }
5641
+ applyToAgentModelRequirements(requirements, content) {
5642
+ // We simply mark that browser capability is enabled in metadata
5643
+ // Get existing metadata
5644
+ const existingMetadata = requirements.metadata || {};
5645
+ // Get existing tools array or create new one
5646
+ const existingTools = existingMetadata.tools || [];
5647
+ // Add 'browser' to tools if not already present
5648
+ const updatedTools = existingTools.includes('browser') ? existingTools : [...existingTools, 'browser'];
5649
+ // Return requirements with updated metadata
5650
+ return {
5651
+ ...requirements,
5652
+ metadata: {
5653
+ ...existingMetadata,
5654
+ tools: updatedTools,
5655
+ useBrowser: true,
5656
+ },
5657
+ };
5658
+ }
5659
+ }
5660
+ /**
5661
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5662
+ */
5663
+
5664
+ /**
5665
+ * USE MCP commitment definition
5666
+ *
5667
+ * The `USE MCP` commitment allows to specify an MCP server URL which the agent will connect to
5668
+ * for retrieving additional instructions and actions.
5669
+ *
5670
+ * The content following `USE MCP` is the URL of the MCP server.
5671
+ *
5672
+ * Example usage in agent source:
5673
+ *
5674
+ * ```book
5675
+ * USE MCP http://mcp-server-url.com
5676
+ * ```
5677
+ *
5678
+ * @private [🪔] Maybe export the commitments through some package
5679
+ */
5680
+ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
5681
+ constructor() {
5682
+ super('USE MCP', ['MCP']);
5683
+ }
5684
+ /**
5685
+ * Short one-line description of USE MCP.
5686
+ */
5687
+ get description() {
5688
+ return 'Connects the agent to an external MCP server for additional capabilities.';
5689
+ }
5690
+ /**
5691
+ * Icon for this commitment.
5692
+ */
5693
+ get icon() {
5694
+ return '🔌';
5695
+ }
5696
+ /**
5697
+ * Markdown documentation for USE MCP commitment.
5698
+ */
5699
+ get documentation() {
5700
+ return spaceTrim$1(`
5701
+ # USE MCP
5702
+
5703
+ Connects the agent to an external Model Context Protocol (MCP) server.
5704
+
5705
+ ## Key aspects
5706
+
5707
+ - The content following \`USE MCP\` must be a valid URL
5708
+ - Multiple MCP servers can be connected by using multiple \`USE MCP\` commitments
5709
+ - The agent will have access to tools and resources provided by the MCP server
5710
+
5711
+ ## Example
5712
+
5713
+ \`\`\`book
5714
+ Company Lawyer
5715
+
5716
+ PERSONA You are a company lawyer.
5717
+ USE MCP http://legal-db.example.com
5718
+ \`\`\`
5719
+ `);
5720
+ }
5721
+ applyToAgentModelRequirements(requirements, content) {
5722
+ const mcpServerUrl = content.trim();
5723
+ if (!mcpServerUrl) {
5724
+ return requirements;
5725
+ }
5726
+ const existingMcpServers = requirements.mcpServers || [];
5727
+ // Avoid duplicates
5728
+ if (existingMcpServers.includes(mcpServerUrl)) {
5729
+ return requirements;
5730
+ }
5731
+ return {
5732
+ ...requirements,
5733
+ mcpServers: [...existingMcpServers, mcpServerUrl],
5734
+ };
5735
+ }
5736
+ }
5737
+ /**
5738
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5739
+ */
5740
+
5741
+ /**
5742
+ * USE SEARCH ENGINE commitment definition
5743
+ *
5744
+ * The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
5745
+ * to access and retrieve up-to-date information from the internet when necessary.
5746
+ *
5747
+ * The content following `USE SEARCH ENGINE` is ignored (similar to NOTE).
5748
+ *
5749
+ * Example usage in agent source:
5750
+ *
5751
+ * ```book
5752
+ * USE SEARCH ENGINE
5753
+ * USE SEARCH ENGINE This will be ignored
5754
+ * ```
5755
+ *
5756
+ * @private [🪔] Maybe export the commitments through some package
5757
+ */
5758
+ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
5759
+ constructor() {
5760
+ super('USE SEARCH ENGINE', ['SEARCH ENGINE', 'SEARCH']);
5761
+ }
5762
+ /**
5763
+ * Short one-line description of USE SEARCH ENGINE.
5764
+ */
5765
+ get description() {
5766
+ return 'Enable the agent to use a search engine tool for accessing internet information.';
5767
+ }
5768
+ /**
5769
+ * Icon for this commitment.
5770
+ */
5771
+ get icon() {
5772
+ return '🔍';
5773
+ }
5774
+ /**
5775
+ * Markdown documentation for USE SEARCH ENGINE commitment.
5776
+ */
5777
+ get documentation() {
5778
+ return spaceTrim$1(`
5779
+ # USE SEARCH ENGINE
5780
+
5781
+ Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
5782
+
5783
+ ## Key aspects
5784
+
5785
+ - The content following \`USE SEARCH ENGINE\` is ignored (similar to NOTE)
5786
+ - The actual search engine tool usage is handled by the agent runtime
5787
+ - Allows the agent to search for current information from the web
5788
+ - Useful for research tasks, finding facts, and accessing dynamic content
5789
+
5790
+ ## Examples
5791
+
5792
+ \`\`\`book
5793
+ Research Assistant
5794
+
5795
+ PERSONA You are a helpful research assistant specialized in finding current information
5796
+ USE SEARCH ENGINE
5797
+ RULE Always cite your sources when providing information from the web
5798
+ \`\`\`
5799
+
5800
+ \`\`\`book
5801
+ Fact Checker
5802
+
5803
+ PERSONA You are a fact checker
5804
+ USE SEARCH ENGINE
5805
+ ACTION Search for claims and verify them against reliable sources
5806
+ \`\`\`
5807
+ `);
5808
+ }
5809
+ applyToAgentModelRequirements(requirements, content) {
5810
+ // We simply mark that search engine capability is enabled in metadata
5811
+ // Get existing metadata
5812
+ const existingMetadata = requirements.metadata || {};
5813
+ // Get existing tools array or create new one
5814
+ const existingTools = existingMetadata.tools || [];
5815
+ // Add 'search-engine' to tools if not already present
5816
+ const updatedTools = existingTools.includes('search-engine') ? existingTools : [...existingTools, 'search-engine'];
5817
+ // Return requirements with updated metadata
5818
+ return {
5819
+ ...requirements,
5820
+ metadata: {
5821
+ ...existingMetadata,
5822
+ tools: updatedTools,
5823
+ useSearchEngine: true,
5824
+ },
5825
+ };
5826
+ }
5827
+ }
5828
+ /**
5829
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5830
+ */
5831
+
4858
5832
  /**
4859
5833
  * Placeholder commitment definition for commitments that are not yet implemented
4860
5834
  *
@@ -4883,7 +5857,7 @@ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
4883
5857
  * Markdown documentation available at runtime.
4884
5858
  */
4885
5859
  get documentation() {
4886
- return spaceTrim(`
5860
+ return spaceTrim$1(`
4887
5861
  # ${this.type}
4888
5862
 
4889
5863
  This commitment is not yet fully implemented.
@@ -4941,16 +5915,22 @@ const COMMITMENT_REGISTRY = [
4941
5915
  new StyleCommitmentDefinition('STYLES'),
4942
5916
  new RuleCommitmentDefinition('RULE'),
4943
5917
  new RuleCommitmentDefinition('RULES'),
5918
+ new LanguageCommitmentDefinition('LANGUAGE'),
5919
+ new LanguageCommitmentDefinition('LANGUAGES'),
4944
5920
  new SampleCommitmentDefinition('SAMPLE'),
4945
5921
  new SampleCommitmentDefinition('EXAMPLE'),
4946
5922
  new FormatCommitmentDefinition('FORMAT'),
4947
5923
  new FormatCommitmentDefinition('FORMATS'),
5924
+ new FromCommitmentDefinition('FROM'),
4948
5925
  new ModelCommitmentDefinition('MODEL'),
4949
5926
  new ModelCommitmentDefinition('MODELS'),
4950
5927
  new ActionCommitmentDefinition('ACTION'),
4951
5928
  new ActionCommitmentDefinition('ACTIONS'),
5929
+ new ComponentCommitmentDefinition(),
4952
5930
  new MetaImageCommitmentDefinition(),
4953
5931
  new MetaColorCommitmentDefinition(),
5932
+ new MetaFontCommitmentDefinition(),
5933
+ new MetaLinkCommitmentDefinition(),
4954
5934
  new MetaCommitmentDefinition(),
4955
5935
  new NoteCommitmentDefinition('NOTE'),
4956
5936
  new NoteCommitmentDefinition('NOTES'),
@@ -4969,6 +5949,12 @@ const COMMITMENT_REGISTRY = [
4969
5949
  new DeleteCommitmentDefinition('CANCEL'),
4970
5950
  new DeleteCommitmentDefinition('DISCARD'),
4971
5951
  new DeleteCommitmentDefinition('REMOVE'),
5952
+ new OpenCommitmentDefinition(),
5953
+ new ClosedCommitmentDefinition(),
5954
+ new UseBrowserCommitmentDefinition(),
5955
+ new UseSearchEngineCommitmentDefinition(),
5956
+ new UseMcpCommitmentDefinition(),
5957
+ new UseCommitmentDefinition(),
4972
5958
  // Not yet implemented commitments (using placeholder)
4973
5959
  new NotYetImplementedCommitmentDefinition('EXPECT'),
4974
5960
  new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
@@ -4982,6 +5968,11 @@ const COMMITMENT_REGISTRY = [
4982
5968
  * Note: [💞] Ignore a discrepancy between file name and entity name
4983
5969
  */
4984
5970
 
5971
+ /**
5972
+ * Regex pattern to match horizontal lines (markdown thematic breaks)
5973
+ * Matches 3 or more hyphens, underscores, or asterisks (with optional spaces between)
5974
+ */
5975
+ const HORIZONTAL_LINE_PATTERN = /^[\s]*[-_*][\s]*[-_*][\s]*[-_*][\s]*[-_*]*[\s]*$/;
4985
5976
  /**
4986
5977
  * Parses agent source using the new commitment system with multiline support
4987
5978
  * This function replaces the hardcoded commitment parsing in the original parseAgentSource
@@ -5024,7 +6015,7 @@ function parseAgentSourceWithCommitments(agentSource) {
5024
6015
  const fullContent = currentCommitment.contentLines.join('\n');
5025
6016
  commitments.push({
5026
6017
  type: currentCommitment.type,
5027
- content: spaceTrim(fullContent),
6018
+ content: spaceTrim$1(fullContent),
5028
6019
  originalLine: currentCommitment.originalStartLine,
5029
6020
  lineNumber: currentCommitment.startLineNumber,
5030
6021
  });
@@ -5044,6 +6035,24 @@ function parseAgentSourceWithCommitments(agentSource) {
5044
6035
  break;
5045
6036
  }
5046
6037
  }
6038
+ // Check if this is a horizontal line (ends any current commitment)
6039
+ const isHorizontalLine = HORIZONTAL_LINE_PATTERN.test(line);
6040
+ if (isHorizontalLine) {
6041
+ // Save the current commitment if it exists
6042
+ if (currentCommitment) {
6043
+ const fullContent = currentCommitment.contentLines.join('\n');
6044
+ commitments.push({
6045
+ type: currentCommitment.type,
6046
+ content: spaceTrim$1(fullContent),
6047
+ originalLine: currentCommitment.originalStartLine,
6048
+ lineNumber: currentCommitment.startLineNumber,
6049
+ });
6050
+ currentCommitment = null;
6051
+ }
6052
+ // Add horizontal line to non-commitment lines
6053
+ nonCommitmentLines.push(line);
6054
+ continue;
6055
+ }
5047
6056
  if (!foundNewCommitment) {
5048
6057
  if (currentCommitment) {
5049
6058
  // This line belongs to the current commitment
@@ -5060,7 +6069,7 @@ function parseAgentSourceWithCommitments(agentSource) {
5060
6069
  const fullContent = currentCommitment.contentLines.join('\n');
5061
6070
  commitments.push({
5062
6071
  type: currentCommitment.type,
5063
- content: spaceTrim(fullContent),
6072
+ content: spaceTrim$1(fullContent),
5064
6073
  originalLine: currentCommitment.originalStartLine,
5065
6074
  lineNumber: currentCommitment.startLineNumber,
5066
6075
  });
@@ -5130,16 +6139,6 @@ function parseParameters(text) {
5130
6139
  return uniqueParameters;
5131
6140
  }
5132
6141
 
5133
- /**
5134
- * Creates temporary default agent name based on agent source hash
5135
- *
5136
- * @public exported from `@promptbook/core`
5137
- */
5138
- function createDefaultAgentName(agentSource) {
5139
- const agentHash = computeAgentHash(agentSource);
5140
- return normalizeAgentName(`Agent ${agentHash.substring(0, 6)}`);
5141
- }
5142
-
5143
6142
  /**
5144
6143
  * Parses basic information from agent source
5145
6144
  *
@@ -5179,15 +6178,21 @@ function parseAgentSource(agentSource) {
5179
6178
  const links = [];
5180
6179
  for (const commitment of parseResult.commitments) {
5181
6180
  if (commitment.type === 'META LINK') {
5182
- links.push(spaceTrim$1(commitment.content));
6181
+ const linkValue = spaceTrim$2(commitment.content);
6182
+ links.push(linkValue);
6183
+ meta.link = linkValue;
5183
6184
  continue;
5184
6185
  }
5185
6186
  if (commitment.type === 'META IMAGE') {
5186
- meta.image = spaceTrim$1(commitment.content);
6187
+ meta.image = spaceTrim$2(commitment.content);
5187
6188
  continue;
5188
6189
  }
5189
6190
  if (commitment.type === 'META COLOR') {
5190
- meta.color = spaceTrim$1(commitment.content);
6191
+ meta.color = spaceTrim$2(commitment.content);
6192
+ continue;
6193
+ }
6194
+ if (commitment.type === 'META FONT') {
6195
+ meta.font = spaceTrim$2(commitment.content);
5191
6196
  continue;
5192
6197
  }
5193
6198
  if (commitment.type !== 'META') {
@@ -5196,10 +6201,10 @@ function parseAgentSource(agentSource) {
5196
6201
  // Parse META commitments - format is "META TYPE content"
5197
6202
  const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
5198
6203
  if (metaTypeRaw === 'LINK') {
5199
- links.push(spaceTrim$1(commitment.content.substring(metaTypeRaw.length)));
6204
+ links.push(spaceTrim$2(commitment.content.substring(metaTypeRaw.length)));
5200
6205
  }
5201
6206
  const metaType = normalizeTo_camelCase(metaTypeRaw);
5202
- meta[metaType] = spaceTrim$1(commitment.content.substring(metaTypeRaw.length));
6207
+ meta[metaType] = spaceTrim$2(commitment.content.substring(metaTypeRaw.length));
5203
6208
  }
5204
6209
  // Generate gravatar fallback if no meta image specified
5205
6210
  if (!meta.image) {