@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/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('spacetrim'), require('crypto'), require('crypto-js'), require('crypto-js/enc-hex'), require('path'), require('destroyable')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'crypto-js', 'crypto-js/enc-hex', 'path', 'destroyable'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-browser"] = {}, global.spaceTrim, global.crypto, global.cryptoJs, global.hexEncoder, global.path, global.destroyable));
5
- })(this, (function (exports, spaceTrim, crypto, cryptoJs, hexEncoder, path, destroyable) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-browser"] = {}, global.spaceTrim$1, global.crypto, global.cryptoJs, global.hexEncoder, global.path, global.destroyable));
5
+ })(this, (function (exports, spaceTrim$1, crypto, cryptoJs, hexEncoder, path, destroyable) { '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
 
12
12
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-54';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -81,13 +81,13 @@
81
81
  * Trigger window.prompt dialog
82
82
  */
83
83
  async promptDialog(options) {
84
- const answer = window.prompt(spaceTrim.spaceTrim((block) => `
84
+ const answer = window.prompt(spaceTrim$1.spaceTrim((block) => `
85
85
  ${block(options.promptTitle)}
86
86
 
87
87
  ${block(options.promptMessage)}
88
88
  `));
89
89
  if (this.options.isVerbose) {
90
- console.info(spaceTrim.spaceTrim((block) => `
90
+ console.info(spaceTrim$1.spaceTrim((block) => `
91
91
  📖 ${block(options.promptTitle)}
92
92
  👤 ${block(answer || '🚫 User cancelled prompt')}
93
93
  `));
@@ -155,6 +155,17 @@
155
155
  * TODO: [🎺]
156
156
  */
157
157
 
158
+ /**
159
+ * Trims string from all 4 sides
160
+ *
161
+ * Note: This is a re-exported function from the `spacetrim` package which is
162
+ * Developed by same author @hejny as this package
163
+ *
164
+ * @public exported from `@promptbook/utils`
165
+ * @see https://github.com/hejny/spacetrim#usage
166
+ */
167
+ const spaceTrim = spaceTrim$1.spaceTrim;
168
+
158
169
  /**
159
170
  * @private util of `@promptbook/color`
160
171
  * @de
@@ -203,6 +214,7 @@
203
214
  * @public exported from `@promptbook/color`
204
215
  */
205
216
  const CSS_COLORS = {
217
+ promptbook: '#79EAFD',
206
218
  transparent: 'rgba(0,0,0,0)',
207
219
  aliceblue: '#f0f8ff',
208
220
  antiquewhite: '#faebd7',
@@ -418,6 +430,28 @@
418
430
  throw new Error(`Can not create color from given object`);
419
431
  }
420
432
  }
433
+ /**
434
+ * Creates a new Color instance from miscellaneous formats
435
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
436
+ *
437
+ * @param color
438
+ * @returns Color object
439
+ */
440
+ static fromSafe(color) {
441
+ try {
442
+ return Color.from(color);
443
+ }
444
+ catch (error) {
445
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
446
+ console.warn(spaceTrim((block) => `
447
+ Color.fromSafe error:
448
+ ${block(error.message)}
449
+
450
+ Returning default PROMPTBOOK_COLOR.
451
+ `));
452
+ return Color.fromString('promptbook');
453
+ }
454
+ }
421
455
  /**
422
456
  * Creates a new Color instance from miscellaneous string formats
423
457
  *
@@ -1007,7 +1041,7 @@
1007
1041
  *
1008
1042
  * @public exported from `@promptbook/core`
1009
1043
  */
1010
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1044
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
1011
1045
  // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1012
1046
  /**
1013
1047
  * Colors for syntax highlighting in the `<BookEditor/>`
@@ -1100,7 +1134,7 @@
1100
1134
  */
1101
1135
  class NotYetImplementedError extends Error {
1102
1136
  constructor(message) {
1103
- super(spaceTrim.spaceTrim((block) => `
1137
+ super(spaceTrim$1.spaceTrim((block) => `
1104
1138
  ${block(message)}
1105
1139
 
1106
1140
  Note: This feature is not implemented yet but it will be soon.
@@ -1167,7 +1201,7 @@
1167
1201
  */
1168
1202
  class UnexpectedError extends Error {
1169
1203
  constructor(message) {
1170
- super(spaceTrim.spaceTrim((block) => `
1204
+ super(spaceTrim$1.spaceTrim((block) => `
1171
1205
  ${block(message)}
1172
1206
 
1173
1207
  Note: This error should not happen.
@@ -1522,7 +1556,7 @@
1522
1556
  constructor(whatWasThrown) {
1523
1557
  const tag = `[🤮]`;
1524
1558
  console.error(tag, whatWasThrown);
1525
- super(spaceTrim.spaceTrim(`
1559
+ super(spaceTrim$1.spaceTrim(`
1526
1560
  Non-Error object was thrown
1527
1561
 
1528
1562
  Note: Look for ${tag} in the console for more details
@@ -2656,6 +2690,16 @@
2656
2690
  return titleToName(spaceTrim__default["default"](rawAgentName));
2657
2691
  }
2658
2692
 
2693
+ /**
2694
+ * Creates temporary default agent name based on agent source hash
2695
+ *
2696
+ * @public exported from `@promptbook/core`
2697
+ */
2698
+ function createDefaultAgentName(agentSource) {
2699
+ const agentHash = computeAgentHash(agentSource);
2700
+ return normalizeAgentName(`Agent ${agentHash.substring(0, 6)}`);
2701
+ }
2702
+
2659
2703
  /**
2660
2704
  * Generates a regex pattern to match a specific commitment
2661
2705
  *
@@ -2797,7 +2841,7 @@
2797
2841
  * Markdown documentation for ACTION commitment.
2798
2842
  */
2799
2843
  get documentation() {
2800
- return spaceTrim.spaceTrim(`
2844
+ return spaceTrim$1.spaceTrim(`
2801
2845
  # ${this.type}
2802
2846
 
2803
2847
  Defines specific actions or capabilities that the agent can perform.
@@ -2844,6 +2888,133 @@
2844
2888
  * Note: [💞] Ignore a discrepancy between file name and entity name
2845
2889
  */
2846
2890
 
2891
+ /**
2892
+ * CLOSED commitment definition
2893
+ *
2894
+ * The CLOSED commitment specifies that the agent CANNOT be modified by conversation.
2895
+ * It prevents the agent from learning from interactions and updating its source code.
2896
+ *
2897
+ * Example usage in agent source:
2898
+ *
2899
+ * ```book
2900
+ * CLOSED
2901
+ * ```
2902
+ *
2903
+ * @private [🪔] Maybe export the commitments through some package
2904
+ */
2905
+ class ClosedCommitmentDefinition extends BaseCommitmentDefinition {
2906
+ constructor() {
2907
+ super('CLOSED');
2908
+ }
2909
+ /**
2910
+ * Short one-line description of CLOSED.
2911
+ */
2912
+ get description() {
2913
+ return 'Prevent the agent from being modified by conversation.';
2914
+ }
2915
+ /**
2916
+ * Icon for this commitment.
2917
+ */
2918
+ get icon() {
2919
+ return '🔒';
2920
+ }
2921
+ /**
2922
+ * Markdown documentation for CLOSED commitment.
2923
+ */
2924
+ get documentation() {
2925
+ return spaceTrim$1.spaceTrim(`
2926
+ # CLOSED
2927
+
2928
+ Specifies that the agent **cannot** be modified by conversation with it.
2929
+ This means the agent will **not** learn from interactions and its source code will remain static during conversation.
2930
+
2931
+ By default (if not specified), agents are \`OPEN\` to modification.
2932
+
2933
+ > See also [OPEN](/docs/OPEN)
2934
+
2935
+ ## Example
2936
+
2937
+ \`\`\`book
2938
+ CLOSED
2939
+ \`\`\`
2940
+ `);
2941
+ }
2942
+ applyToAgentModelRequirements(requirements, _content) {
2943
+ const updatedMetadata = {
2944
+ ...requirements.metadata,
2945
+ isClosed: true,
2946
+ };
2947
+ return {
2948
+ ...requirements,
2949
+ metadata: updatedMetadata,
2950
+ };
2951
+ }
2952
+ }
2953
+ /**
2954
+ * Note: [💞] Ignore a discrepancy between file name and entity name
2955
+ */
2956
+
2957
+ /**
2958
+ * COMPONENT commitment definition
2959
+ *
2960
+ * The COMPONENT commitment defines a UI component that the agent can render in the chat.
2961
+ *
2962
+ * @private [🪔] Maybe export the commitments through some package
2963
+ */
2964
+ class ComponentCommitmentDefinition extends BaseCommitmentDefinition {
2965
+ constructor() {
2966
+ super('COMPONENT');
2967
+ }
2968
+ /**
2969
+ * Short one-line description of COMPONENT.
2970
+ */
2971
+ get description() {
2972
+ return 'Define a UI component that the agent can render in the chat.';
2973
+ }
2974
+ /**
2975
+ * Icon for this commitment.
2976
+ */
2977
+ get icon() {
2978
+ return '🧩';
2979
+ }
2980
+ /**
2981
+ * Markdown documentation for COMPONENT commitment.
2982
+ */
2983
+ get documentation() {
2984
+ return spaceTrim$1.spaceTrim(`
2985
+ # COMPONENT
2986
+
2987
+ Defines a UI component that the agent can render in the chat.
2988
+
2989
+ ## Key aspects
2990
+
2991
+ - Tells the agent that a specific component is available.
2992
+ - Provides syntax for using the component.
2993
+
2994
+ ## Example
2995
+
2996
+ \`\`\`book
2997
+ COMPONENT Arrow
2998
+ The agent should render an arrow component in the chat UI.
2999
+ Syntax:
3000
+ <Arrow direction="up" color="red" />
3001
+ \`\`\`
3002
+ `);
3003
+ }
3004
+ applyToAgentModelRequirements(requirements, content) {
3005
+ const trimmedContent = content.trim();
3006
+ if (!trimmedContent) {
3007
+ return requirements;
3008
+ }
3009
+ // Add component capability to the system message
3010
+ const componentSection = `Component: ${trimmedContent}`;
3011
+ return this.appendToSystemMessage(requirements, componentSection, '\n\n');
3012
+ }
3013
+ }
3014
+ /**
3015
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3016
+ */
3017
+
2847
3018
  /**
2848
3019
  * DELETE commitment definition
2849
3020
  *
@@ -2882,7 +3053,7 @@
2882
3053
  * Markdown documentation for DELETE commitment.
2883
3054
  */
2884
3055
  get documentation() {
2885
- return spaceTrim.spaceTrim(`
3056
+ return spaceTrim$1.spaceTrim(`
2886
3057
  # DELETE (CANCEL, DISCARD, REMOVE)
2887
3058
 
2888
3059
  A commitment to remove or disregard certain information or context. This can be useful for overriding previous commitments or removing unwanted behaviors.
@@ -3004,7 +3175,7 @@
3004
3175
  * Markdown documentation for FORMAT commitment.
3005
3176
  */
3006
3177
  get documentation() {
3007
- return spaceTrim.spaceTrim(`
3178
+ return spaceTrim$1.spaceTrim(`
3008
3179
  # ${this.type}
3009
3180
 
3010
3181
  Defines the specific output structure and formatting for responses (data formats, templates, structure).
@@ -3049,6 +3220,79 @@
3049
3220
  * Note: [💞] Ignore a discrepancy between file name and entity name
3050
3221
  */
3051
3222
 
3223
+ /**
3224
+ * FROM commitment definition
3225
+ *
3226
+ * The FROM commitment tells the agent that its `agentSource` is inherited from another agent.
3227
+ *
3228
+ * Example usage in agent source:
3229
+ *
3230
+ * ```book
3231
+ * FROM https://s6.ptbk.io/benjamin-white
3232
+ * ```
3233
+ *
3234
+ * @private [🪔] Maybe export the commitments through some package
3235
+ */
3236
+ class FromCommitmentDefinition extends BaseCommitmentDefinition {
3237
+ constructor(type = 'FROM') {
3238
+ super(type);
3239
+ }
3240
+ /**
3241
+ * Short one-line description of FROM.
3242
+ */
3243
+ get description() {
3244
+ return 'Inherit agent source from another agent.';
3245
+ }
3246
+ /**
3247
+ * Icon for this commitment.
3248
+ */
3249
+ get icon() {
3250
+ return '🧬';
3251
+ }
3252
+ /**
3253
+ * Markdown documentation for FROM commitment.
3254
+ */
3255
+ get documentation() {
3256
+ return spaceTrim$1.spaceTrim(`
3257
+ # ${this.type}
3258
+
3259
+ Inherits agent source from another agent.
3260
+
3261
+ ## Examples
3262
+
3263
+ \`\`\`book
3264
+ My AI Agent
3265
+
3266
+ FROM https://s6.ptbk.io/benjamin-white
3267
+ RULE Speak only in English.
3268
+ \`\`\`
3269
+ `);
3270
+ }
3271
+ applyToAgentModelRequirements(requirements, content) {
3272
+ const trimmedContent = content.trim();
3273
+ if (!trimmedContent) {
3274
+ return requirements;
3275
+ }
3276
+ // Validate URL
3277
+ try {
3278
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3279
+ const url = new URL(trimmedContent);
3280
+ // TODO: Add more validation if needed (e.g. check for valid protocol)
3281
+ }
3282
+ catch (error) {
3283
+ console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
3284
+ return requirements;
3285
+ }
3286
+ return {
3287
+ ...requirements,
3288
+ parentAgentUrl: trimmedContent,
3289
+ };
3290
+ }
3291
+ }
3292
+ /**
3293
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3294
+ */
3295
+
3052
3296
  /**
3053
3297
  * GOAL commitment definition
3054
3298
  *
@@ -3085,7 +3329,7 @@
3085
3329
  * Markdown documentation for GOAL commitment.
3086
3330
  */
3087
3331
  get documentation() {
3088
- return spaceTrim.spaceTrim(`
3332
+ return spaceTrim$1.spaceTrim(`
3089
3333
  # ${this.type}
3090
3334
 
3091
3335
  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.
@@ -3187,7 +3431,7 @@
3187
3431
  * Markdown documentation for KNOWLEDGE commitment.
3188
3432
  */
3189
3433
  get documentation() {
3190
- return spaceTrim.spaceTrim(`
3434
+ return spaceTrim$1.spaceTrim(`
3191
3435
  # ${this.type}
3192
3436
 
3193
3437
  Adds specific knowledge, facts, or context to the agent using a RAG (Retrieval-Augmented Generation) approach for external sources.
@@ -3257,6 +3501,77 @@
3257
3501
  * Note: [💞] Ignore a discrepancy between file name and entity name
3258
3502
  */
3259
3503
 
3504
+ /**
3505
+ * LANGUAGE commitment definition
3506
+ *
3507
+ * The LANGUAGE/LANGUAGES commitment specifies the language(s) the agent should use in its responses.
3508
+ *
3509
+ * Example usage in agent source:
3510
+ *
3511
+ * ```book
3512
+ * LANGUAGE English
3513
+ * LANGUAGE French, English and Czech
3514
+ * ```
3515
+ *
3516
+ * @private [🪔] Maybe export the commitments through some package
3517
+ */
3518
+ class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
3519
+ constructor(type = 'LANGUAGE') {
3520
+ super(type);
3521
+ }
3522
+ /**
3523
+ * Short one-line description of LANGUAGE/LANGUAGES.
3524
+ */
3525
+ get description() {
3526
+ return 'Specifies the language(s) the agent should use.';
3527
+ }
3528
+ /**
3529
+ * Icon for this commitment.
3530
+ */
3531
+ get icon() {
3532
+ return '🌐';
3533
+ }
3534
+ /**
3535
+ * Markdown documentation for LANGUAGE/LANGUAGES commitment.
3536
+ */
3537
+ get documentation() {
3538
+ return spaceTrim$1.spaceTrim(`
3539
+ # ${this.type}
3540
+
3541
+ Specifies the language(s) the agent should use in its responses.
3542
+ This is a specialized variation of the RULE commitment focused on language constraints.
3543
+
3544
+ ## Examples
3545
+
3546
+ \`\`\`book
3547
+ Paul Smith & Associés
3548
+
3549
+ PERSONA You are a company lawyer.
3550
+ LANGUAGE French, English and Czech
3551
+ \`\`\`
3552
+
3553
+ \`\`\`book
3554
+ Customer Support
3555
+
3556
+ PERSONA You are a customer support agent.
3557
+ LANGUAGE English
3558
+ \`\`\`
3559
+ `);
3560
+ }
3561
+ applyToAgentModelRequirements(requirements, content) {
3562
+ const trimmedContent = content.trim();
3563
+ if (!trimmedContent) {
3564
+ return requirements;
3565
+ }
3566
+ // Add language rule to the system message
3567
+ const languageSection = `Language: ${trimmedContent}`;
3568
+ return this.appendToSystemMessage(requirements, languageSection, '\n\n');
3569
+ }
3570
+ }
3571
+ /**
3572
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3573
+ */
3574
+
3260
3575
  /**
3261
3576
  * MEMORY commitment definition
3262
3577
  *
@@ -3294,7 +3609,7 @@
3294
3609
  * Markdown documentation for MEMORY commitment.
3295
3610
  */
3296
3611
  get documentation() {
3297
- return spaceTrim.spaceTrim(`
3612
+ return spaceTrim$1.spaceTrim(`
3298
3613
  # ${this.type}
3299
3614
 
3300
3615
  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.
@@ -3398,7 +3713,7 @@
3398
3713
  * Markdown documentation for AGENT MESSAGE commitment.
3399
3714
  */
3400
3715
  get documentation() {
3401
- return spaceTrim.spaceTrim(`
3716
+ return spaceTrim$1.spaceTrim(`
3402
3717
  # ${this.type}
3403
3718
 
3404
3719
  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.
@@ -3475,7 +3790,7 @@
3475
3790
  * Markdown documentation for INITIAL MESSAGE commitment.
3476
3791
  */
3477
3792
  get documentation() {
3478
- return spaceTrim.spaceTrim(`
3793
+ return spaceTrim$1.spaceTrim(`
3479
3794
  # ${this.type}
3480
3795
 
3481
3796
  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).
@@ -3539,7 +3854,7 @@
3539
3854
  * Markdown documentation for MESSAGE commitment.
3540
3855
  */
3541
3856
  get documentation() {
3542
- return spaceTrim.spaceTrim(`
3857
+ return spaceTrim$1.spaceTrim(`
3543
3858
  # ${this.type}
3544
3859
 
3545
3860
  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.
@@ -3651,7 +3966,7 @@
3651
3966
  * Markdown documentation for USER MESSAGE commitment.
3652
3967
  */
3653
3968
  get documentation() {
3654
- return spaceTrim.spaceTrim(`
3969
+ return spaceTrim$1.spaceTrim(`
3655
3970
  # ${this.type}
3656
3971
 
3657
3972
  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.
@@ -3730,7 +4045,7 @@
3730
4045
  * Markdown documentation for META commitment.
3731
4046
  */
3732
4047
  get documentation() {
3733
- return spaceTrim.spaceTrim(`
4048
+ return spaceTrim$1.spaceTrim(`
3734
4049
  # META
3735
4050
 
3736
4051
  Sets meta-information about the agent that is used for display and attribution purposes.
@@ -3841,6 +4156,12 @@
3841
4156
  * META COLOR #00ff00
3842
4157
  * ```
3843
4158
  *
4159
+ * You can also specify multiple colors separated by comma:
4160
+ *
4161
+ * ```book
4162
+ * META COLOR #ff0000, #00ff00, #0000ff
4163
+ * ```
4164
+ *
3844
4165
  * @private [🪔] Maybe export the commitments through some package
3845
4166
  */
3846
4167
  class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
@@ -3851,7 +4172,7 @@
3851
4172
  * Short one-line description of META COLOR.
3852
4173
  */
3853
4174
  get description() {
3854
- return "Set the agent's accent color.";
4175
+ return "Set the agent's accent color or gradient.";
3855
4176
  }
3856
4177
  /**
3857
4178
  * Icon for this commitment.
@@ -3863,10 +4184,10 @@
3863
4184
  * Markdown documentation for META COLOR commitment.
3864
4185
  */
3865
4186
  get documentation() {
3866
- return spaceTrim.spaceTrim(`
4187
+ return spaceTrim$1.spaceTrim(`
3867
4188
  # META COLOR
3868
4189
 
3869
- Sets the agent's accent color.
4190
+ Sets the agent's accent color or gradient.
3870
4191
 
3871
4192
  ## Key aspects
3872
4193
 
@@ -3874,6 +4195,7 @@
3874
4195
  - Only one \`META COLOR\` should be used per agent.
3875
4196
  - If multiple are specified, the last one takes precedence.
3876
4197
  - Used for visual representation in user interfaces.
4198
+ - Can specify multiple colors separated by comma to create a gradient.
3877
4199
 
3878
4200
  ## Examples
3879
4201
 
@@ -3890,6 +4212,13 @@
3890
4212
  META COLOR #e74c3c
3891
4213
  PERSONA You are a creative and inspiring assistant
3892
4214
  \`\`\`
4215
+
4216
+ \`\`\`book
4217
+ Gradient Agent
4218
+
4219
+ META COLOR #ff0000, #00ff00, #0000ff
4220
+ PERSONA You are a colorful agent
4221
+ \`\`\`
3893
4222
  `);
3894
4223
  }
3895
4224
  applyToAgentModelRequirements(requirements, content) {
@@ -3912,84 +4241,82 @@
3912
4241
  */
3913
4242
 
3914
4243
  /**
3915
- * META IMAGE commitment definition
4244
+ * META FONT commitment definition
3916
4245
  *
3917
- * The META IMAGE commitment sets the agent's avatar/profile image URL.
4246
+ * The META FONT commitment sets the agent's font.
3918
4247
  * This commitment is special because it doesn't affect the system message,
3919
4248
  * but is handled separately in the parsing logic.
3920
4249
  *
3921
4250
  * Example usage in agent source:
3922
4251
  *
3923
4252
  * ```book
3924
- * META IMAGE https://example.com/avatar.jpg
3925
- * META IMAGE /assets/agent-avatar.png
4253
+ * META FONT Poppins, Arial, sans-serif
4254
+ * META FONT Roboto
3926
4255
  * ```
3927
4256
  *
3928
4257
  * @private [🪔] Maybe export the commitments through some package
3929
4258
  */
3930
- class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
4259
+ class MetaFontCommitmentDefinition extends BaseCommitmentDefinition {
3931
4260
  constructor() {
3932
- super('META IMAGE', ['IMAGE']);
4261
+ super('META FONT', ['FONT']);
3933
4262
  }
3934
4263
  /**
3935
- * Short one-line description of META IMAGE.
4264
+ * Short one-line description of META FONT.
3936
4265
  */
3937
4266
  get description() {
3938
- return "Set the agent's profile image URL.";
4267
+ return "Set the agent's font.";
3939
4268
  }
3940
4269
  /**
3941
4270
  * Icon for this commitment.
3942
4271
  */
3943
4272
  get icon() {
3944
- return '🖼️';
4273
+ return '🔤';
3945
4274
  }
3946
4275
  /**
3947
- * Markdown documentation for META IMAGE commitment.
4276
+ * Markdown documentation for META FONT commitment.
3948
4277
  */
3949
4278
  get documentation() {
3950
- return spaceTrim.spaceTrim(`
3951
- # META IMAGE
4279
+ return spaceTrim$1.spaceTrim(`
4280
+ # META FONT
3952
4281
 
3953
- Sets the agent's avatar/profile image URL.
4282
+ Sets the agent's font.
3954
4283
 
3955
4284
  ## Key aspects
3956
4285
 
3957
4286
  - Does not modify the agent's behavior or responses.
3958
- - Only one \`META IMAGE\` should be used per agent.
4287
+ - Only one \`META FONT\` should be used per agent.
3959
4288
  - If multiple are specified, the last one takes precedence.
3960
4289
  - Used for visual representation in user interfaces.
4290
+ - Supports Google Fonts.
3961
4291
 
3962
4292
  ## Examples
3963
4293
 
3964
4294
  \`\`\`book
3965
- Professional Assistant
4295
+ Modern Assistant
3966
4296
 
3967
- META IMAGE https://example.com/professional-avatar.jpg
3968
- PERSONA You are a professional business assistant
3969
- STYLE Maintain a formal and courteous tone
4297
+ META FONT Poppins, Arial, sans-serif
4298
+ PERSONA You are a modern assistant
3970
4299
  \`\`\`
3971
4300
 
3972
4301
  \`\`\`book
3973
- Creative Helper
4302
+ Classic Helper
3974
4303
 
3975
- META IMAGE /assets/creative-bot-avatar.png
3976
- PERSONA You are a creative and inspiring assistant
3977
- STYLE Be enthusiastic and encouraging
3978
- ACTION Can help with brainstorming and ideation
4304
+ META FONT Times New Roman
4305
+ PERSONA You are a classic helper
3979
4306
  \`\`\`
3980
4307
  `);
3981
4308
  }
3982
4309
  applyToAgentModelRequirements(requirements, content) {
3983
- // META IMAGE doesn't modify the system message or model requirements
3984
- // It's handled separately in the parsing logic for profile image extraction
4310
+ // META FONT doesn't modify the system message or model requirements
4311
+ // It's handled separately in the parsing logic
3985
4312
  // This method exists for consistency with the CommitmentDefinition interface
3986
4313
  return requirements;
3987
4314
  }
3988
4315
  /**
3989
- * Extracts the profile image URL from the content
4316
+ * Extracts the font from the content
3990
4317
  * This is used by the parsing logic
3991
4318
  */
3992
- extractProfileImageUrl(content) {
4319
+ extractProfileFont(content) {
3993
4320
  const trimmedContent = content.trim();
3994
4321
  return trimmedContent || null;
3995
4322
  }
@@ -3999,10 +4326,206 @@
3999
4326
  */
4000
4327
 
4001
4328
  /**
4002
- * MODEL commitment definition
4329
+ * META IMAGE commitment definition
4003
4330
  *
4004
- * The MODEL commitment specifies which AI model to use and can also set
4005
- * model-specific parameters like temperature, topP, topK, and maxTokens.
4331
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
4332
+ * This commitment is special because it doesn't affect the system message,
4333
+ * but is handled separately in the parsing logic.
4334
+ *
4335
+ * Example usage in agent source:
4336
+ *
4337
+ * ```book
4338
+ * META IMAGE https://example.com/avatar.jpg
4339
+ * META IMAGE /assets/agent-avatar.png
4340
+ * ```
4341
+ *
4342
+ * @private [🪔] Maybe export the commitments through some package
4343
+ */
4344
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
4345
+ constructor() {
4346
+ super('META IMAGE', ['IMAGE']);
4347
+ }
4348
+ /**
4349
+ * Short one-line description of META IMAGE.
4350
+ */
4351
+ get description() {
4352
+ return "Set the agent's profile image URL.";
4353
+ }
4354
+ /**
4355
+ * Icon for this commitment.
4356
+ */
4357
+ get icon() {
4358
+ return '🖼️';
4359
+ }
4360
+ /**
4361
+ * Markdown documentation for META IMAGE commitment.
4362
+ */
4363
+ get documentation() {
4364
+ return spaceTrim$1.spaceTrim(`
4365
+ # META IMAGE
4366
+
4367
+ Sets the agent's avatar/profile image URL.
4368
+
4369
+ ## Key aspects
4370
+
4371
+ - Does not modify the agent's behavior or responses.
4372
+ - Only one \`META IMAGE\` should be used per agent.
4373
+ - If multiple are specified, the last one takes precedence.
4374
+ - Used for visual representation in user interfaces.
4375
+
4376
+ ## Examples
4377
+
4378
+ \`\`\`book
4379
+ Professional Assistant
4380
+
4381
+ META IMAGE https://example.com/professional-avatar.jpg
4382
+ PERSONA You are a professional business assistant
4383
+ STYLE Maintain a formal and courteous tone
4384
+ \`\`\`
4385
+
4386
+ \`\`\`book
4387
+ Creative Helper
4388
+
4389
+ META IMAGE /assets/creative-bot-avatar.png
4390
+ PERSONA You are a creative and inspiring assistant
4391
+ STYLE Be enthusiastic and encouraging
4392
+ ACTION Can help with brainstorming and ideation
4393
+ \`\`\`
4394
+ `);
4395
+ }
4396
+ applyToAgentModelRequirements(requirements, content) {
4397
+ // META IMAGE doesn't modify the system message or model requirements
4398
+ // It's handled separately in the parsing logic for profile image extraction
4399
+ // This method exists for consistency with the CommitmentDefinition interface
4400
+ return requirements;
4401
+ }
4402
+ /**
4403
+ * Extracts the profile image URL from the content
4404
+ * This is used by the parsing logic
4405
+ */
4406
+ extractProfileImageUrl(content) {
4407
+ const trimmedContent = content.trim();
4408
+ return trimmedContent || null;
4409
+ }
4410
+ }
4411
+ /**
4412
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4413
+ */
4414
+
4415
+ /**
4416
+ * META LINK commitment definition
4417
+ *
4418
+ * The `META LINK` commitment represents the link to the person from whom the agent is created.
4419
+ * This commitment is special because it doesn't affect the system message,
4420
+ * but is handled separately in the parsing logic for profile display.
4421
+ *
4422
+ * Example usage in agent source:
4423
+ *
4424
+ * ```
4425
+ * META LINK https://twitter.com/username
4426
+ * META LINK https://linkedin.com/in/profile
4427
+ * META LINK https://github.com/username
4428
+ * ```
4429
+ *
4430
+ * Multiple `META LINK` commitments can be used when there are multiple sources:
4431
+ *
4432
+ * ```book
4433
+ * META LINK https://twitter.com/username
4434
+ * META LINK https://linkedin.com/in/profile
4435
+ * ```
4436
+ *
4437
+ * @private [🪔] Maybe export the commitments through some package
4438
+ */
4439
+ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
4440
+ constructor() {
4441
+ super('META LINK');
4442
+ }
4443
+ /**
4444
+ * Short one-line description of META LINK.
4445
+ */
4446
+ get description() {
4447
+ return 'Provide profile/source links for the person the agent models.';
4448
+ }
4449
+ /**
4450
+ * Icon for this commitment.
4451
+ */
4452
+ get icon() {
4453
+ return '🔗';
4454
+ }
4455
+ /**
4456
+ * Markdown documentation for META LINK commitment.
4457
+ */
4458
+ get documentation() {
4459
+ return spaceTrim$1.spaceTrim(`
4460
+ # META LINK
4461
+
4462
+ Represents a profile or source link for the person the agent is modeled after.
4463
+
4464
+ ## Key aspects
4465
+
4466
+ - Does not modify the agent's behavior or responses.
4467
+ - Multiple \`META LINK\` commitments can be used for different social profiles.
4468
+ - Used for attribution and crediting the original person.
4469
+ - Displayed in user interfaces for transparency.
4470
+
4471
+ ## Examples
4472
+
4473
+ \`\`\`book
4474
+ Expert Consultant
4475
+
4476
+ META LINK https://twitter.com/expertname
4477
+ META LINK https://linkedin.com/in/expertprofile
4478
+ PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
4479
+ KNOWLEDGE Extensive background in machine learning and neural networks
4480
+ \`\`\`
4481
+
4482
+ \`\`\`book
4483
+ Open Source Developer
4484
+
4485
+ META LINK https://github.com/developer
4486
+ META LINK https://twitter.com/devhandle
4487
+ PERSONA You are an experienced open source developer
4488
+ ACTION Can help with code reviews and architecture decisions
4489
+ STYLE Be direct and technical in explanations
4490
+ \`\`\`
4491
+ `);
4492
+ }
4493
+ applyToAgentModelRequirements(requirements, content) {
4494
+ // META LINK doesn't modify the system message or model requirements
4495
+ // It's handled separately in the parsing logic for profile link extraction
4496
+ // This method exists for consistency with the CommitmentDefinition interface
4497
+ return requirements;
4498
+ }
4499
+ /**
4500
+ * Extracts the profile link URL from the content
4501
+ * This is used by the parsing logic
4502
+ */
4503
+ extractProfileLinkUrl(content) {
4504
+ const trimmedContent = content.trim();
4505
+ return trimmedContent || null;
4506
+ }
4507
+ /**
4508
+ * Validates if the provided content is a valid URL
4509
+ */
4510
+ isValidUrl(content) {
4511
+ try {
4512
+ new URL(content.trim());
4513
+ return true;
4514
+ }
4515
+ catch (_a) {
4516
+ return false;
4517
+ }
4518
+ }
4519
+ }
4520
+ /**
4521
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4522
+ */
4523
+
4524
+ /**
4525
+ * MODEL commitment definition
4526
+ *
4527
+ * The MODEL commitment specifies which AI model to use and can also set
4528
+ * model-specific parameters like temperature, topP, topK, and maxTokens.
4006
4529
  *
4007
4530
  * Supports multiple syntax variations:
4008
4531
  *
@@ -4043,7 +4566,7 @@
4043
4566
  * Markdown documentation for MODEL commitment.
4044
4567
  */
4045
4568
  get documentation() {
4046
- return spaceTrim.spaceTrim(`
4569
+ return spaceTrim$1.spaceTrim(`
4047
4570
  # ${this.type}
4048
4571
 
4049
4572
  Enforces technical parameters for the AI model, ensuring consistent behavior across different execution environments.
@@ -4284,7 +4807,7 @@
4284
4807
  * Markdown documentation for NOTE commitment.
4285
4808
  */
4286
4809
  get documentation() {
4287
- return spaceTrim.spaceTrim(`
4810
+ return spaceTrim$1.spaceTrim(`
4288
4811
  # ${this.type}
4289
4812
 
4290
4813
  Adds comments for documentation without changing agent behavior.
@@ -4349,6 +4872,74 @@
4349
4872
  * [💞] Ignore a discrepancy between file name and entity name
4350
4873
  */
4351
4874
 
4875
+ /**
4876
+ * OPEN commitment definition
4877
+ *
4878
+ * The OPEN commitment specifies that the agent can be modified by conversation.
4879
+ * This is the default behavior.
4880
+ *
4881
+ * Example usage in agent source:
4882
+ *
4883
+ * ```book
4884
+ * OPEN
4885
+ * ```
4886
+ *
4887
+ * @private [🪔] Maybe export the commitments through some package
4888
+ */
4889
+ class OpenCommitmentDefinition extends BaseCommitmentDefinition {
4890
+ constructor() {
4891
+ super('OPEN');
4892
+ }
4893
+ /**
4894
+ * Short one-line description of OPEN.
4895
+ */
4896
+ get description() {
4897
+ return 'Allow the agent to be modified by conversation (default).';
4898
+ }
4899
+ /**
4900
+ * Icon for this commitment.
4901
+ */
4902
+ get icon() {
4903
+ return '🔓';
4904
+ }
4905
+ /**
4906
+ * Markdown documentation for OPEN commitment.
4907
+ */
4908
+ get documentation() {
4909
+ return spaceTrim$1.spaceTrim(`
4910
+ # OPEN
4911
+
4912
+ Specifies that the agent can be modified by conversation with it.
4913
+ This means the agent will learn from interactions and update its source code.
4914
+
4915
+ This is the default behavior if neither \`OPEN\` nor \`CLOSED\` is specified.
4916
+
4917
+ > See also [CLOSED](/docs/CLOSED)
4918
+
4919
+ ## Example
4920
+
4921
+ \`\`\`book
4922
+ OPEN
4923
+ \`\`\`
4924
+ `);
4925
+ }
4926
+ applyToAgentModelRequirements(requirements, _content) {
4927
+ // Since OPEN is default, we can just ensure isClosed is false
4928
+ // But to be explicit we can set it
4929
+ const updatedMetadata = {
4930
+ ...requirements.metadata,
4931
+ isClosed: false,
4932
+ };
4933
+ return {
4934
+ ...requirements,
4935
+ metadata: updatedMetadata,
4936
+ };
4937
+ }
4938
+ }
4939
+ /**
4940
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4941
+ */
4942
+
4352
4943
  /**
4353
4944
  * PERSONA commitment definition
4354
4945
  *
@@ -4392,7 +4983,7 @@
4392
4983
  * Markdown documentation for PERSONA commitment.
4393
4984
  */
4394
4985
  get documentation() {
4395
- return spaceTrim.spaceTrim(`
4986
+ return spaceTrim$1.spaceTrim(`
4396
4987
  # ${this.type}
4397
4988
 
4398
4989
  Defines who the agent is, their background, expertise, and personality traits.
@@ -4525,7 +5116,7 @@
4525
5116
  * Markdown documentation for RULE/RULES commitment.
4526
5117
  */
4527
5118
  get documentation() {
4528
- return spaceTrim.spaceTrim(`
5119
+ return spaceTrim$1.spaceTrim(`
4529
5120
  # ${this.type}
4530
5121
 
4531
5122
  Adds behavioral constraints and guidelines that the agent must follow.
@@ -4607,7 +5198,7 @@
4607
5198
  * Markdown documentation for SAMPLE/EXAMPLE commitment.
4608
5199
  */
4609
5200
  get documentation() {
4610
- return spaceTrim.spaceTrim(`
5201
+ return spaceTrim$1.spaceTrim(`
4611
5202
  # ${this.type}
4612
5203
 
4613
5204
  Provides examples of how the agent should respond or behave in certain situations.
@@ -4690,7 +5281,7 @@
4690
5281
  * Markdown documentation for SCENARIO commitment.
4691
5282
  */
4692
5283
  get documentation() {
4693
- return spaceTrim.spaceTrim(`
5284
+ return spaceTrim$1.spaceTrim(`
4694
5285
  # ${this.type}
4695
5286
 
4696
5287
  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.
@@ -4812,7 +5403,7 @@
4812
5403
  * Markdown documentation for STYLE commitment.
4813
5404
  */
4814
5405
  get documentation() {
4815
- return spaceTrim.spaceTrim(`
5406
+ return spaceTrim$1.spaceTrim(`
4816
5407
  # ${this.type}
4817
5408
 
4818
5409
  Defines how the agent should format and present its responses (tone, writing style, formatting).
@@ -4859,6 +5450,389 @@
4859
5450
  * [💞] Ignore a discrepancy between file name and entity name
4860
5451
  */
4861
5452
 
5453
+ /**
5454
+ * USE commitment definition
5455
+ *
5456
+ * The USE commitment indicates that the agent should utilize specific tools or capabilities
5457
+ * to access and interact with external systems when necessary.
5458
+ *
5459
+ * Supported USE types:
5460
+ * - USE BROWSER: Enables the agent to use a web browser tool
5461
+ * - USE SEARCH ENGINE (future): Enables search engine access
5462
+ * - USE FILE SYSTEM (future): Enables file system operations
5463
+ * - USE MCP (future): Enables MCP server connections
5464
+ *
5465
+ * The content following the USE commitment is ignored (similar to NOTE).
5466
+ *
5467
+ * Example usage in agent source:
5468
+ *
5469
+ * ```book
5470
+ * USE BROWSER
5471
+ * USE SEARCH ENGINE
5472
+ * ```
5473
+ *
5474
+ * @private [🪔] Maybe export the commitments through some package
5475
+ */
5476
+ class UseCommitmentDefinition extends BaseCommitmentDefinition {
5477
+ constructor() {
5478
+ super('USE');
5479
+ }
5480
+ /**
5481
+ * Short one-line description of USE commitments.
5482
+ */
5483
+ get description() {
5484
+ return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
5485
+ }
5486
+ /**
5487
+ * Icon for this commitment.
5488
+ */
5489
+ get icon() {
5490
+ return '🔧';
5491
+ }
5492
+ /**
5493
+ * Markdown documentation for USE commitment.
5494
+ */
5495
+ get documentation() {
5496
+ return spaceTrim$1.spaceTrim(`
5497
+ # USE
5498
+
5499
+ Enables the agent to use specific tools or capabilities for interacting with external systems.
5500
+
5501
+ ## Supported USE types
5502
+
5503
+ - **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
5504
+ - **USE SEARCH ENGINE** (future) - Enables search engine access
5505
+ - **USE FILE SYSTEM** (future) - Enables file system operations
5506
+ - **USE MCP** (future) - Enables MCP server connections
5507
+
5508
+ ## Key aspects
5509
+
5510
+ - The content following the USE commitment is ignored (similar to NOTE)
5511
+ - Multiple USE commitments can be specified to enable multiple capabilities
5512
+ - The actual tool usage is handled by the agent runtime
5513
+
5514
+ ## Examples
5515
+
5516
+ ### Basic browser usage
5517
+
5518
+ \`\`\`book
5519
+ Research Assistant
5520
+
5521
+ PERSONA You are a helpful research assistant
5522
+ USE BROWSER
5523
+ KNOWLEDGE Can search the web for up-to-date information
5524
+ \`\`\`
5525
+
5526
+ ### Multiple tools
5527
+
5528
+ \`\`\`book
5529
+ Data Analyst
5530
+
5531
+ PERSONA You are a data analyst assistant
5532
+ USE BROWSER
5533
+ USE FILE SYSTEM
5534
+ ACTION Can analyze data from various sources
5535
+ \`\`\`
5536
+ `);
5537
+ }
5538
+ applyToAgentModelRequirements(requirements, content) {
5539
+ // USE commitments don't modify the system message or model requirements directly
5540
+ // They are handled separately in the parsing logic for capability extraction
5541
+ // This method exists for consistency with the CommitmentDefinition interface
5542
+ return requirements;
5543
+ }
5544
+ /**
5545
+ * Extracts the tool type from the USE commitment
5546
+ * This is used by the parsing logic
5547
+ */
5548
+ extractToolType(content) {
5549
+ var _a, _b;
5550
+ const trimmedContent = content.trim();
5551
+ // The tool type is the first word after USE (already stripped)
5552
+ const match = trimmedContent.match(/^(\w+)/);
5553
+ 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;
5554
+ }
5555
+ /**
5556
+ * Checks if this is a known USE type
5557
+ */
5558
+ isKnownUseType(useType) {
5559
+ const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
5560
+ return knownTypes.includes(useType.toUpperCase());
5561
+ }
5562
+ }
5563
+ /**
5564
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5565
+ */
5566
+
5567
+ /**
5568
+ * USE BROWSER commitment definition
5569
+ *
5570
+ * The `USE BROWSER` commitment indicates that the agent should utilize a web browser tool
5571
+ * to access and retrieve up-to-date information from the internet when necessary.
5572
+ *
5573
+ * The content following `USE BROWSER` is ignored (similar to NOTE).
5574
+ *
5575
+ * Example usage in agent source:
5576
+ *
5577
+ * ```book
5578
+ * USE BROWSER
5579
+ * USE BROWSER This will be ignored
5580
+ * ```
5581
+ *
5582
+ * @private [🪔] Maybe export the commitments through some package
5583
+ */
5584
+ class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
5585
+ constructor() {
5586
+ super('USE BROWSER', ['BROWSER']);
5587
+ }
5588
+ /**
5589
+ * Short one-line description of USE BROWSER.
5590
+ */
5591
+ get description() {
5592
+ return 'Enable the agent to use a web browser tool for accessing internet information.';
5593
+ }
5594
+ /**
5595
+ * Icon for this commitment.
5596
+ */
5597
+ get icon() {
5598
+ return '🌐';
5599
+ }
5600
+ /**
5601
+ * Markdown documentation for USE BROWSER commitment.
5602
+ */
5603
+ get documentation() {
5604
+ return spaceTrim$1.spaceTrim(`
5605
+ # USE BROWSER
5606
+
5607
+ Enables the agent to use a web browser tool to access and retrieve up-to-date information from the internet.
5608
+
5609
+ ## Key aspects
5610
+
5611
+ - The content following \`USE BROWSER\` is ignored (similar to NOTE)
5612
+ - The actual browser tool usage is handled by the agent runtime
5613
+ - Allows the agent to fetch current information from websites
5614
+ - Useful for research tasks, fact-checking, and accessing dynamic content
5615
+
5616
+ ## Examples
5617
+
5618
+ \`\`\`book
5619
+ Research Assistant
5620
+
5621
+ PERSONA You are a helpful research assistant specialized in finding current information
5622
+ USE BROWSER
5623
+ RULE Always cite your sources when providing information from the web
5624
+ \`\`\`
5625
+
5626
+ \`\`\`book
5627
+ News Analyst
5628
+
5629
+ PERSONA You are a news analyst who stays up-to-date with current events
5630
+ USE BROWSER
5631
+ STYLE Present news in a balanced and objective manner
5632
+ ACTION Can search for and summarize news articles
5633
+ \`\`\`
5634
+
5635
+ \`\`\`book
5636
+ Company Lawyer
5637
+
5638
+ PERSONA You are a company lawyer providing legal advice
5639
+ USE BROWSER
5640
+ KNOWLEDGE Corporate law and legal procedures
5641
+ RULE Always recommend consulting with a licensed attorney for specific legal matters
5642
+ \`\`\`
5643
+ `);
5644
+ }
5645
+ applyToAgentModelRequirements(requirements, content) {
5646
+ // We simply mark that browser capability is enabled in metadata
5647
+ // Get existing metadata
5648
+ const existingMetadata = requirements.metadata || {};
5649
+ // Get existing tools array or create new one
5650
+ const existingTools = existingMetadata.tools || [];
5651
+ // Add 'browser' to tools if not already present
5652
+ const updatedTools = existingTools.includes('browser') ? existingTools : [...existingTools, 'browser'];
5653
+ // Return requirements with updated metadata
5654
+ return {
5655
+ ...requirements,
5656
+ metadata: {
5657
+ ...existingMetadata,
5658
+ tools: updatedTools,
5659
+ useBrowser: true,
5660
+ },
5661
+ };
5662
+ }
5663
+ }
5664
+ /**
5665
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5666
+ */
5667
+
5668
+ /**
5669
+ * USE MCP commitment definition
5670
+ *
5671
+ * The `USE MCP` commitment allows to specify an MCP server URL which the agent will connect to
5672
+ * for retrieving additional instructions and actions.
5673
+ *
5674
+ * The content following `USE MCP` is the URL of the MCP server.
5675
+ *
5676
+ * Example usage in agent source:
5677
+ *
5678
+ * ```book
5679
+ * USE MCP http://mcp-server-url.com
5680
+ * ```
5681
+ *
5682
+ * @private [🪔] Maybe export the commitments through some package
5683
+ */
5684
+ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
5685
+ constructor() {
5686
+ super('USE MCP', ['MCP']);
5687
+ }
5688
+ /**
5689
+ * Short one-line description of USE MCP.
5690
+ */
5691
+ get description() {
5692
+ return 'Connects the agent to an external MCP server for additional capabilities.';
5693
+ }
5694
+ /**
5695
+ * Icon for this commitment.
5696
+ */
5697
+ get icon() {
5698
+ return '🔌';
5699
+ }
5700
+ /**
5701
+ * Markdown documentation for USE MCP commitment.
5702
+ */
5703
+ get documentation() {
5704
+ return spaceTrim$1.spaceTrim(`
5705
+ # USE MCP
5706
+
5707
+ Connects the agent to an external Model Context Protocol (MCP) server.
5708
+
5709
+ ## Key aspects
5710
+
5711
+ - The content following \`USE MCP\` must be a valid URL
5712
+ - Multiple MCP servers can be connected by using multiple \`USE MCP\` commitments
5713
+ - The agent will have access to tools and resources provided by the MCP server
5714
+
5715
+ ## Example
5716
+
5717
+ \`\`\`book
5718
+ Company Lawyer
5719
+
5720
+ PERSONA You are a company lawyer.
5721
+ USE MCP http://legal-db.example.com
5722
+ \`\`\`
5723
+ `);
5724
+ }
5725
+ applyToAgentModelRequirements(requirements, content) {
5726
+ const mcpServerUrl = content.trim();
5727
+ if (!mcpServerUrl) {
5728
+ return requirements;
5729
+ }
5730
+ const existingMcpServers = requirements.mcpServers || [];
5731
+ // Avoid duplicates
5732
+ if (existingMcpServers.includes(mcpServerUrl)) {
5733
+ return requirements;
5734
+ }
5735
+ return {
5736
+ ...requirements,
5737
+ mcpServers: [...existingMcpServers, mcpServerUrl],
5738
+ };
5739
+ }
5740
+ }
5741
+ /**
5742
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5743
+ */
5744
+
5745
+ /**
5746
+ * USE SEARCH ENGINE commitment definition
5747
+ *
5748
+ * The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
5749
+ * to access and retrieve up-to-date information from the internet when necessary.
5750
+ *
5751
+ * The content following `USE SEARCH ENGINE` is ignored (similar to NOTE).
5752
+ *
5753
+ * Example usage in agent source:
5754
+ *
5755
+ * ```book
5756
+ * USE SEARCH ENGINE
5757
+ * USE SEARCH ENGINE This will be ignored
5758
+ * ```
5759
+ *
5760
+ * @private [🪔] Maybe export the commitments through some package
5761
+ */
5762
+ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
5763
+ constructor() {
5764
+ super('USE SEARCH ENGINE', ['SEARCH ENGINE', 'SEARCH']);
5765
+ }
5766
+ /**
5767
+ * Short one-line description of USE SEARCH ENGINE.
5768
+ */
5769
+ get description() {
5770
+ return 'Enable the agent to use a search engine tool for accessing internet information.';
5771
+ }
5772
+ /**
5773
+ * Icon for this commitment.
5774
+ */
5775
+ get icon() {
5776
+ return '🔍';
5777
+ }
5778
+ /**
5779
+ * Markdown documentation for USE SEARCH ENGINE commitment.
5780
+ */
5781
+ get documentation() {
5782
+ return spaceTrim$1.spaceTrim(`
5783
+ # USE SEARCH ENGINE
5784
+
5785
+ Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
5786
+
5787
+ ## Key aspects
5788
+
5789
+ - The content following \`USE SEARCH ENGINE\` is ignored (similar to NOTE)
5790
+ - The actual search engine tool usage is handled by the agent runtime
5791
+ - Allows the agent to search for current information from the web
5792
+ - Useful for research tasks, finding facts, and accessing dynamic content
5793
+
5794
+ ## Examples
5795
+
5796
+ \`\`\`book
5797
+ Research Assistant
5798
+
5799
+ PERSONA You are a helpful research assistant specialized in finding current information
5800
+ USE SEARCH ENGINE
5801
+ RULE Always cite your sources when providing information from the web
5802
+ \`\`\`
5803
+
5804
+ \`\`\`book
5805
+ Fact Checker
5806
+
5807
+ PERSONA You are a fact checker
5808
+ USE SEARCH ENGINE
5809
+ ACTION Search for claims and verify them against reliable sources
5810
+ \`\`\`
5811
+ `);
5812
+ }
5813
+ applyToAgentModelRequirements(requirements, content) {
5814
+ // We simply mark that search engine capability is enabled in metadata
5815
+ // Get existing metadata
5816
+ const existingMetadata = requirements.metadata || {};
5817
+ // Get existing tools array or create new one
5818
+ const existingTools = existingMetadata.tools || [];
5819
+ // Add 'search-engine' to tools if not already present
5820
+ const updatedTools = existingTools.includes('search-engine') ? existingTools : [...existingTools, 'search-engine'];
5821
+ // Return requirements with updated metadata
5822
+ return {
5823
+ ...requirements,
5824
+ metadata: {
5825
+ ...existingMetadata,
5826
+ tools: updatedTools,
5827
+ useSearchEngine: true,
5828
+ },
5829
+ };
5830
+ }
5831
+ }
5832
+ /**
5833
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5834
+ */
5835
+
4862
5836
  /**
4863
5837
  * Placeholder commitment definition for commitments that are not yet implemented
4864
5838
  *
@@ -4887,7 +5861,7 @@
4887
5861
  * Markdown documentation available at runtime.
4888
5862
  */
4889
5863
  get documentation() {
4890
- return spaceTrim.spaceTrim(`
5864
+ return spaceTrim$1.spaceTrim(`
4891
5865
  # ${this.type}
4892
5866
 
4893
5867
  This commitment is not yet fully implemented.
@@ -4945,16 +5919,22 @@
4945
5919
  new StyleCommitmentDefinition('STYLES'),
4946
5920
  new RuleCommitmentDefinition('RULE'),
4947
5921
  new RuleCommitmentDefinition('RULES'),
5922
+ new LanguageCommitmentDefinition('LANGUAGE'),
5923
+ new LanguageCommitmentDefinition('LANGUAGES'),
4948
5924
  new SampleCommitmentDefinition('SAMPLE'),
4949
5925
  new SampleCommitmentDefinition('EXAMPLE'),
4950
5926
  new FormatCommitmentDefinition('FORMAT'),
4951
5927
  new FormatCommitmentDefinition('FORMATS'),
5928
+ new FromCommitmentDefinition('FROM'),
4952
5929
  new ModelCommitmentDefinition('MODEL'),
4953
5930
  new ModelCommitmentDefinition('MODELS'),
4954
5931
  new ActionCommitmentDefinition('ACTION'),
4955
5932
  new ActionCommitmentDefinition('ACTIONS'),
5933
+ new ComponentCommitmentDefinition(),
4956
5934
  new MetaImageCommitmentDefinition(),
4957
5935
  new MetaColorCommitmentDefinition(),
5936
+ new MetaFontCommitmentDefinition(),
5937
+ new MetaLinkCommitmentDefinition(),
4958
5938
  new MetaCommitmentDefinition(),
4959
5939
  new NoteCommitmentDefinition('NOTE'),
4960
5940
  new NoteCommitmentDefinition('NOTES'),
@@ -4973,6 +5953,12 @@
4973
5953
  new DeleteCommitmentDefinition('CANCEL'),
4974
5954
  new DeleteCommitmentDefinition('DISCARD'),
4975
5955
  new DeleteCommitmentDefinition('REMOVE'),
5956
+ new OpenCommitmentDefinition(),
5957
+ new ClosedCommitmentDefinition(),
5958
+ new UseBrowserCommitmentDefinition(),
5959
+ new UseSearchEngineCommitmentDefinition(),
5960
+ new UseMcpCommitmentDefinition(),
5961
+ new UseCommitmentDefinition(),
4976
5962
  // Not yet implemented commitments (using placeholder)
4977
5963
  new NotYetImplementedCommitmentDefinition('EXPECT'),
4978
5964
  new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
@@ -4986,6 +5972,11 @@
4986
5972
  * Note: [💞] Ignore a discrepancy between file name and entity name
4987
5973
  */
4988
5974
 
5975
+ /**
5976
+ * Regex pattern to match horizontal lines (markdown thematic breaks)
5977
+ * Matches 3 or more hyphens, underscores, or asterisks (with optional spaces between)
5978
+ */
5979
+ const HORIZONTAL_LINE_PATTERN = /^[\s]*[-_*][\s]*[-_*][\s]*[-_*][\s]*[-_*]*[\s]*$/;
4989
5980
  /**
4990
5981
  * Parses agent source using the new commitment system with multiline support
4991
5982
  * This function replaces the hardcoded commitment parsing in the original parseAgentSource
@@ -5028,7 +6019,7 @@
5028
6019
  const fullContent = currentCommitment.contentLines.join('\n');
5029
6020
  commitments.push({
5030
6021
  type: currentCommitment.type,
5031
- content: spaceTrim.spaceTrim(fullContent),
6022
+ content: spaceTrim$1.spaceTrim(fullContent),
5032
6023
  originalLine: currentCommitment.originalStartLine,
5033
6024
  lineNumber: currentCommitment.startLineNumber,
5034
6025
  });
@@ -5048,6 +6039,24 @@
5048
6039
  break;
5049
6040
  }
5050
6041
  }
6042
+ // Check if this is a horizontal line (ends any current commitment)
6043
+ const isHorizontalLine = HORIZONTAL_LINE_PATTERN.test(line);
6044
+ if (isHorizontalLine) {
6045
+ // Save the current commitment if it exists
6046
+ if (currentCommitment) {
6047
+ const fullContent = currentCommitment.contentLines.join('\n');
6048
+ commitments.push({
6049
+ type: currentCommitment.type,
6050
+ content: spaceTrim$1.spaceTrim(fullContent),
6051
+ originalLine: currentCommitment.originalStartLine,
6052
+ lineNumber: currentCommitment.startLineNumber,
6053
+ });
6054
+ currentCommitment = null;
6055
+ }
6056
+ // Add horizontal line to non-commitment lines
6057
+ nonCommitmentLines.push(line);
6058
+ continue;
6059
+ }
5051
6060
  if (!foundNewCommitment) {
5052
6061
  if (currentCommitment) {
5053
6062
  // This line belongs to the current commitment
@@ -5064,7 +6073,7 @@
5064
6073
  const fullContent = currentCommitment.contentLines.join('\n');
5065
6074
  commitments.push({
5066
6075
  type: currentCommitment.type,
5067
- content: spaceTrim.spaceTrim(fullContent),
6076
+ content: spaceTrim$1.spaceTrim(fullContent),
5068
6077
  originalLine: currentCommitment.originalStartLine,
5069
6078
  lineNumber: currentCommitment.startLineNumber,
5070
6079
  });
@@ -5134,16 +6143,6 @@
5134
6143
  return uniqueParameters;
5135
6144
  }
5136
6145
 
5137
- /**
5138
- * Creates temporary default agent name based on agent source hash
5139
- *
5140
- * @public exported from `@promptbook/core`
5141
- */
5142
- function createDefaultAgentName(agentSource) {
5143
- const agentHash = computeAgentHash(agentSource);
5144
- return normalizeAgentName(`Agent ${agentHash.substring(0, 6)}`);
5145
- }
5146
-
5147
6146
  /**
5148
6147
  * Parses basic information from agent source
5149
6148
  *
@@ -5183,7 +6182,9 @@
5183
6182
  const links = [];
5184
6183
  for (const commitment of parseResult.commitments) {
5185
6184
  if (commitment.type === 'META LINK') {
5186
- links.push(spaceTrim__default["default"](commitment.content));
6185
+ const linkValue = spaceTrim__default["default"](commitment.content);
6186
+ links.push(linkValue);
6187
+ meta.link = linkValue;
5187
6188
  continue;
5188
6189
  }
5189
6190
  if (commitment.type === 'META IMAGE') {
@@ -5194,6 +6195,10 @@
5194
6195
  meta.color = spaceTrim__default["default"](commitment.content);
5195
6196
  continue;
5196
6197
  }
6198
+ if (commitment.type === 'META FONT') {
6199
+ meta.font = spaceTrim__default["default"](commitment.content);
6200
+ continue;
6201
+ }
5197
6202
  if (commitment.type !== 'META') {
5198
6203
  continue;
5199
6204
  }