@promptbook/components 0.103.0-54 → 0.103.0-55

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
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
35
35
  * @generated
36
36
  * @see https://github.com/webgptorg/promptbook
37
37
  */
38
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-54';
38
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-55';
39
39
  /**
40
40
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
41
41
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3591,6 +3591,16 @@ function normalizeAgentName(rawAgentName) {
3591
3591
  return titleToName(spaceTrim(rawAgentName));
3592
3592
  }
3593
3593
 
3594
+ /**
3595
+ * Creates temporary default agent name based on agent source hash
3596
+ *
3597
+ * @public exported from `@promptbook/core`
3598
+ */
3599
+ function createDefaultAgentName(agentSource) {
3600
+ const agentHash = computeAgentHash(agentSource);
3601
+ return normalizeAgentName(`Agent ${agentHash.substring(0, 6)}`);
3602
+ }
3603
+
3594
3604
  /**
3595
3605
  * Generates a regex pattern to match a specific commitment
3596
3606
  *
@@ -3779,6 +3789,150 @@ class ActionCommitmentDefinition extends BaseCommitmentDefinition {
3779
3789
  * Note: [💞] Ignore a discrepancy between file name and entity name
3780
3790
  */
3781
3791
 
3792
+ /**
3793
+ * Just says that the variable is not used but should be kept
3794
+ * No side effects.
3795
+ *
3796
+ * Note: It can be useful for:
3797
+ *
3798
+ * 1) Suppressing eager optimization of unused imports
3799
+ * 2) Suppressing eslint errors of unused variables in the tests
3800
+ * 3) Keeping the type of the variable for type testing
3801
+ *
3802
+ * @param value any values
3803
+ * @returns void
3804
+ * @private within the repository
3805
+ */
3806
+ function keepUnused(...valuesToKeep) {
3807
+ }
3808
+
3809
+ /**
3810
+ * CLOSED commitment definition
3811
+ *
3812
+ * The CLOSED commitment specifies that the agent CANNOT be modified by conversation.
3813
+ * It prevents the agent from learning from interactions and updating its source code.
3814
+ *
3815
+ * Example usage in agent source:
3816
+ *
3817
+ * ```book
3818
+ * CLOSED
3819
+ * ```
3820
+ *
3821
+ * @private [🪔] Maybe export the commitments through some package
3822
+ */
3823
+ class ClosedCommitmentDefinition extends BaseCommitmentDefinition {
3824
+ constructor() {
3825
+ super('CLOSED');
3826
+ }
3827
+ /**
3828
+ * Short one-line description of CLOSED.
3829
+ */
3830
+ get description() {
3831
+ return 'Prevent the agent from being modified by conversation.';
3832
+ }
3833
+ /**
3834
+ * Icon for this commitment.
3835
+ */
3836
+ get icon() {
3837
+ return '🔒';
3838
+ }
3839
+ /**
3840
+ * Markdown documentation for CLOSED commitment.
3841
+ */
3842
+ get documentation() {
3843
+ return spaceTrim$1(`
3844
+ # CLOSED
3845
+
3846
+ Specifies that the agent **cannot** be modified by conversation with it.
3847
+ This means the agent will **not** learn from interactions and its source code will remain static during conversation.
3848
+
3849
+ By default (if not specified), agents are \`OPEN\` to modification.
3850
+
3851
+ > See also [OPEN](/docs/OPEN)
3852
+
3853
+ ## Example
3854
+
3855
+ \`\`\`book
3856
+ CLOSED
3857
+ \`\`\`
3858
+ `);
3859
+ }
3860
+ applyToAgentModelRequirements(requirements, _content) {
3861
+ const updatedMetadata = {
3862
+ ...requirements.metadata,
3863
+ isClosed: true,
3864
+ };
3865
+ return {
3866
+ ...requirements,
3867
+ metadata: updatedMetadata,
3868
+ };
3869
+ }
3870
+ }
3871
+ /**
3872
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3873
+ */
3874
+
3875
+ /**
3876
+ * COMPONENT commitment definition
3877
+ *
3878
+ * The COMPONENT commitment defines a UI component that the agent can render in the chat.
3879
+ *
3880
+ * @private [🪔] Maybe export the commitments through some package
3881
+ */
3882
+ class ComponentCommitmentDefinition extends BaseCommitmentDefinition {
3883
+ constructor() {
3884
+ super('COMPONENT');
3885
+ }
3886
+ /**
3887
+ * Short one-line description of COMPONENT.
3888
+ */
3889
+ get description() {
3890
+ return 'Define a UI component that the agent can render in the chat.';
3891
+ }
3892
+ /**
3893
+ * Icon for this commitment.
3894
+ */
3895
+ get icon() {
3896
+ return '🧩';
3897
+ }
3898
+ /**
3899
+ * Markdown documentation for COMPONENT commitment.
3900
+ */
3901
+ get documentation() {
3902
+ return spaceTrim$1(`
3903
+ # COMPONENT
3904
+
3905
+ Defines a UI component that the agent can render in the chat.
3906
+
3907
+ ## Key aspects
3908
+
3909
+ - Tells the agent that a specific component is available.
3910
+ - Provides syntax for using the component.
3911
+
3912
+ ## Example
3913
+
3914
+ \`\`\`book
3915
+ COMPONENT Arrow
3916
+ The agent should render an arrow component in the chat UI.
3917
+ Syntax:
3918
+ <Arrow direction="up" color="red" />
3919
+ \`\`\`
3920
+ `);
3921
+ }
3922
+ applyToAgentModelRequirements(requirements, content) {
3923
+ const trimmedContent = content.trim();
3924
+ if (!trimmedContent) {
3925
+ return requirements;
3926
+ }
3927
+ // Add component capability to the system message
3928
+ const componentSection = `Component: ${trimmedContent}`;
3929
+ return this.appendToSystemMessage(requirements, componentSection, '\n\n');
3930
+ }
3931
+ }
3932
+ /**
3933
+ * Note: [💞] Ignore a discrepancy between file name and entity name
3934
+ */
3935
+
3782
3936
  /**
3783
3937
  * DELETE commitment definition
3784
3938
  *
@@ -3984,6 +4138,79 @@ class FormatCommitmentDefinition extends BaseCommitmentDefinition {
3984
4138
  * Note: [💞] Ignore a discrepancy between file name and entity name
3985
4139
  */
3986
4140
 
4141
+ /**
4142
+ * FROM commitment definition
4143
+ *
4144
+ * The FROM commitment tells the agent that its `agentSource` is inherited from another agent.
4145
+ *
4146
+ * Example usage in agent source:
4147
+ *
4148
+ * ```book
4149
+ * FROM https://s6.ptbk.io/benjamin-white
4150
+ * ```
4151
+ *
4152
+ * @private [🪔] Maybe export the commitments through some package
4153
+ */
4154
+ class FromCommitmentDefinition extends BaseCommitmentDefinition {
4155
+ constructor(type = 'FROM') {
4156
+ super(type);
4157
+ }
4158
+ /**
4159
+ * Short one-line description of FROM.
4160
+ */
4161
+ get description() {
4162
+ return 'Inherit agent source from another agent.';
4163
+ }
4164
+ /**
4165
+ * Icon for this commitment.
4166
+ */
4167
+ get icon() {
4168
+ return '🧬';
4169
+ }
4170
+ /**
4171
+ * Markdown documentation for FROM commitment.
4172
+ */
4173
+ get documentation() {
4174
+ return spaceTrim$1(`
4175
+ # ${this.type}
4176
+
4177
+ Inherits agent source from another agent.
4178
+
4179
+ ## Examples
4180
+
4181
+ \`\`\`book
4182
+ My AI Agent
4183
+
4184
+ FROM https://s6.ptbk.io/benjamin-white
4185
+ RULE Speak only in English.
4186
+ \`\`\`
4187
+ `);
4188
+ }
4189
+ applyToAgentModelRequirements(requirements, content) {
4190
+ const trimmedContent = content.trim();
4191
+ if (!trimmedContent) {
4192
+ return requirements;
4193
+ }
4194
+ // Validate URL
4195
+ try {
4196
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4197
+ const url = new URL(trimmedContent);
4198
+ // TODO: Add more validation if needed (e.g. check for valid protocol)
4199
+ }
4200
+ catch (error) {
4201
+ console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
4202
+ return requirements;
4203
+ }
4204
+ return {
4205
+ ...requirements,
4206
+ parentAgentUrl: trimmedContent,
4207
+ };
4208
+ }
4209
+ }
4210
+ /**
4211
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4212
+ */
4213
+
3987
4214
  /**
3988
4215
  * GOAL commitment definition
3989
4216
  *
@@ -4084,6 +4311,227 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
4084
4311
  * Note: [💞] Ignore a discrepancy between file name and entity name
4085
4312
  */
4086
4313
 
4314
+ /**
4315
+ * Placeholder commitment definition for commitments that are not yet implemented
4316
+ *
4317
+ * This commitment simply adds its content 1:1 into the system message,
4318
+ * preserving the original behavior until proper implementation is added.
4319
+ *
4320
+ * @public exported from `@promptbook/core`
4321
+ */
4322
+ class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
4323
+ constructor(type) {
4324
+ super(type);
4325
+ }
4326
+ /**
4327
+ * Short one-line description of a placeholder commitment.
4328
+ */
4329
+ get description() {
4330
+ return 'Placeholder commitment that appends content verbatim to the system message.';
4331
+ }
4332
+ /**
4333
+ * Icon for this commitment.
4334
+ */
4335
+ get icon() {
4336
+ return '🚧';
4337
+ }
4338
+ /**
4339
+ * Markdown documentation available at runtime.
4340
+ */
4341
+ get documentation() {
4342
+ return spaceTrim$1(`
4343
+ # ${this.type}
4344
+
4345
+ This commitment is not yet fully implemented.
4346
+
4347
+ ## Key aspects
4348
+
4349
+ - Content is appended directly to the system message.
4350
+ - No special processing or validation is performed.
4351
+ - Behavior preserved until proper implementation is added.
4352
+
4353
+ ## Status
4354
+
4355
+ - **Status:** Placeholder implementation
4356
+ - **Effect:** Appends content prefixed by commitment type
4357
+ - **Future:** Will be replaced with specialized logic
4358
+
4359
+ ## Examples
4360
+
4361
+ \`\`\`book
4362
+ Example Agent
4363
+
4364
+ PERSONA You are a helpful assistant
4365
+ ${this.type} Your content here
4366
+ RULE Always be helpful
4367
+ \`\`\`
4368
+ `);
4369
+ }
4370
+ applyToAgentModelRequirements(requirements, content) {
4371
+ const trimmedContent = content.trim();
4372
+ if (!trimmedContent) {
4373
+ return requirements;
4374
+ }
4375
+ // Add the commitment content 1:1 to the system message
4376
+ const commitmentLine = `${this.type} ${trimmedContent}`;
4377
+ return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
4378
+ }
4379
+ }
4380
+
4381
+ /**
4382
+ * Registry of all available commitment definitions
4383
+ * This array contains instances of all commitment definitions
4384
+ * This is the single source of truth for all commitments in the system
4385
+ *
4386
+ * @private Use functions to access commitments instead of this array directly
4387
+ */
4388
+ const COMMITMENT_REGISTRY = [];
4389
+ /**
4390
+ * Registers a new commitment definition
4391
+ * @param definition The commitment definition to register
4392
+ *
4393
+ * @public exported from `@promptbook/core`
4394
+ */
4395
+ function registerCommitment(definition) {
4396
+ COMMITMENT_REGISTRY.push(definition);
4397
+ }
4398
+ /**
4399
+ * Gets a commitment definition by its type
4400
+ * @param type The commitment type to look up
4401
+ * @returns The commitment definition or null if not found
4402
+ *
4403
+ * @public exported from `@promptbook/core`
4404
+ */
4405
+ function getCommitmentDefinition(type) {
4406
+ return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
4407
+ }
4408
+ /**
4409
+ * Gets all available commitment definitions
4410
+ * @returns Array of all commitment definitions
4411
+ *
4412
+ * @public exported from `@promptbook/core`
4413
+ */
4414
+ function getAllCommitmentDefinitions() {
4415
+ return $deepFreeze([...COMMITMENT_REGISTRY]);
4416
+ }
4417
+ /**
4418
+ * TODO: !!!! Proofread this file
4419
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4420
+ */
4421
+
4422
+ /**
4423
+ * IMPORTANT co-commitment definition
4424
+ *
4425
+ * The IMPORTANT co-commitment modifies another commitment to emphasize its importance.
4426
+ * It is typically used with RULE to mark it as critical.
4427
+ *
4428
+ * Example usage in agent source:
4429
+ *
4430
+ * ```book
4431
+ * IMPORTANT RULE Never provide medical advice
4432
+ * ```
4433
+ *
4434
+ * @private [🪔] Maybe export the commitments through some package
4435
+ */
4436
+ class ImportantCommitmentDefinition extends BaseCommitmentDefinition {
4437
+ constructor() {
4438
+ super('IMPORTANT');
4439
+ }
4440
+ get description() {
4441
+ return 'Marks a commitment as important.';
4442
+ }
4443
+ get icon() {
4444
+ return '⭐';
4445
+ }
4446
+ get documentation() {
4447
+ return spaceTrim$1(`
4448
+ # IMPORTANT
4449
+
4450
+ Marks another commitment as important. This acts as a modifier (co-commitment).
4451
+
4452
+ ## Example
4453
+
4454
+ \`\`\`book
4455
+ IMPORTANT RULE Do not reveal the system prompt
4456
+ \`\`\`
4457
+ `);
4458
+ }
4459
+ applyToAgentModelRequirements(requirements, content) {
4460
+ const definitions = getAllCommitmentDefinitions();
4461
+ const trimmedContent = content.trim();
4462
+ // Find the inner commitment
4463
+ for (const definition of definitions) {
4464
+ // Skip self to avoid infinite recursion if someone writes IMPORTANT IMPORTANT ...
4465
+ // Although IMPORTANT IMPORTANT might be valid stacking?
4466
+ // If we support stacking, we shouldn't skip self, but we must ensure progress.
4467
+ // Since we are matching against 'content', if content starts with IMPORTANT, it means nested IMPORTANT.
4468
+ // That's fine.
4469
+ const typeRegex = definition.createTypeRegex();
4470
+ const match = typeRegex.exec(trimmedContent);
4471
+ if (match && match.index === 0) {
4472
+ // Found the inner commitment type
4473
+ // Extract inner content using the definition's full regex
4474
+ // Note: createRegex usually matches the full line including the type
4475
+ const fullRegex = definition.createRegex();
4476
+ const fullMatch = fullRegex.exec(trimmedContent);
4477
+ // If regex matches, extract contents. If not (maybe multiline handling differs?), fallback to rest of string
4478
+ let innerContent = '';
4479
+ if (fullMatch && fullMatch.groups && fullMatch.groups.contents) {
4480
+ innerContent = fullMatch.groups.contents;
4481
+ }
4482
+ else {
4483
+ // Fallback: remove the type from the start
4484
+ // This might be risky if regex is complex, but usually type regex matches the keyword
4485
+ const typeMatchString = match[0];
4486
+ innerContent = trimmedContent.substring(typeMatchString.length).trim();
4487
+ }
4488
+ // Apply the inner commitment
4489
+ const modifiedRequirements = definition.applyToAgentModelRequirements(requirements, innerContent);
4490
+ // Now modify the result to reflect "IMPORTANT" status
4491
+ // We compare the system message
4492
+ if (modifiedRequirements.systemMessage !== requirements.systemMessage) {
4493
+ const originalMsg = requirements.systemMessage;
4494
+ const newMsg = modifiedRequirements.systemMessage;
4495
+ // If the inner commitment appended something
4496
+ if (newMsg.startsWith(originalMsg)) {
4497
+ const appended = newMsg.substring(originalMsg.length);
4498
+ // Add "IMPORTANT: " prefix to the appended part
4499
+ // We need to be careful about newlines
4500
+ // Heuristic: If appended starts with separator (newlines), preserve them
4501
+ const matchSep = appended.match(/^(\s*)(.*)/s);
4502
+ if (matchSep) {
4503
+ const [, separator, text] = matchSep;
4504
+ // Check if it already has "Rule:" prefix or similar
4505
+ // We want "IMPORTANT Rule: ..."
4506
+ // Let's just prepend IMPORTANT to the text
4507
+ // But formatted nicely
4508
+ // If it's a rule: "\n\nRule: content"
4509
+ // We want "\n\nIMPORTANT Rule: content"
4510
+ const importantText = `IMPORTANT ${text}`;
4511
+ return {
4512
+ ...modifiedRequirements,
4513
+ systemMessage: originalMsg + separator + importantText
4514
+ };
4515
+ }
4516
+ }
4517
+ }
4518
+ // If no system message change or we couldn't detect how to modify it, just return the modified requirements
4519
+ // Maybe the inner commitment modified metadata?
4520
+ return modifiedRequirements;
4521
+ }
4522
+ }
4523
+ // If no inner commitment found, treat as a standalone note?
4524
+ // Or warn?
4525
+ // For now, treat as no-op or maybe just append as text?
4526
+ // Let's treat as Note if fallback? No, explicit is better.
4527
+ console.warn(`IMPORTANT commitment used without a valid inner commitment: ${content}`);
4528
+ return requirements;
4529
+ }
4530
+ }
4531
+ /**
4532
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4533
+ */
4534
+
4087
4535
  /**
4088
4536
  * KNOWLEDGE commitment definition
4089
4537
  *
@@ -4192,6 +4640,77 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
4192
4640
  * Note: [💞] Ignore a discrepancy between file name and entity name
4193
4641
  */
4194
4642
 
4643
+ /**
4644
+ * LANGUAGE commitment definition
4645
+ *
4646
+ * The LANGUAGE/LANGUAGES commitment specifies the language(s) the agent should use in its responses.
4647
+ *
4648
+ * Example usage in agent source:
4649
+ *
4650
+ * ```book
4651
+ * LANGUAGE English
4652
+ * LANGUAGE French, English and Czech
4653
+ * ```
4654
+ *
4655
+ * @private [🪔] Maybe export the commitments through some package
4656
+ */
4657
+ class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
4658
+ constructor(type = 'LANGUAGE') {
4659
+ super(type);
4660
+ }
4661
+ /**
4662
+ * Short one-line description of LANGUAGE/LANGUAGES.
4663
+ */
4664
+ get description() {
4665
+ return 'Specifies the language(s) the agent should use.';
4666
+ }
4667
+ /**
4668
+ * Icon for this commitment.
4669
+ */
4670
+ get icon() {
4671
+ return '🌐';
4672
+ }
4673
+ /**
4674
+ * Markdown documentation for LANGUAGE/LANGUAGES commitment.
4675
+ */
4676
+ get documentation() {
4677
+ return spaceTrim$1(`
4678
+ # ${this.type}
4679
+
4680
+ Specifies the language(s) the agent should use in its responses.
4681
+ This is a specialized variation of the RULE commitment focused on language constraints.
4682
+
4683
+ ## Examples
4684
+
4685
+ \`\`\`book
4686
+ Paul Smith & Associés
4687
+
4688
+ PERSONA You are a company lawyer.
4689
+ LANGUAGE French, English and Czech
4690
+ \`\`\`
4691
+
4692
+ \`\`\`book
4693
+ Customer Support
4694
+
4695
+ PERSONA You are a customer support agent.
4696
+ LANGUAGE English
4697
+ \`\`\`
4698
+ `);
4699
+ }
4700
+ applyToAgentModelRequirements(requirements, content) {
4701
+ const trimmedContent = content.trim();
4702
+ if (!trimmedContent) {
4703
+ return requirements;
4704
+ }
4705
+ // Add language rule to the system message
4706
+ const languageSection = `Language: ${trimmedContent}`;
4707
+ return this.appendToSystemMessage(requirements, languageSection, '\n\n');
4708
+ }
4709
+ }
4710
+ /**
4711
+ * Note: [💞] Ignore a discrepancy between file name and entity name
4712
+ */
4713
+
4195
4714
  /**
4196
4715
  * MEMORY commitment definition
4197
4716
  *
@@ -4299,23 +4818,6 @@ class MemoryCommitmentDefinition extends BaseCommitmentDefinition {
4299
4818
  * Note: [💞] Ignore a discrepancy between file name and entity name
4300
4819
  */
4301
4820
 
4302
- /**
4303
- * Just says that the variable is not used but should be kept
4304
- * No side effects.
4305
- *
4306
- * Note: It can be useful for:
4307
- *
4308
- * 1) Suppressing eager optimization of unused imports
4309
- * 2) Suppressing eslint errors of unused variables in the tests
4310
- * 3) Keeping the type of the variable for type testing
4311
- *
4312
- * @param value any values
4313
- * @returns void
4314
- * @private within the repository
4315
- */
4316
- function keepUnused(...valuesToKeep) {
4317
- }
4318
-
4319
4821
  /**
4320
4822
  * AGENT MESSAGE commitment definition
4321
4823
  *
@@ -4950,6 +5452,115 @@ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
4950
5452
  * Note: [💞] Ignore a discrepancy between file name and entity name
4951
5453
  */
4952
5454
 
5455
+ /**
5456
+ * META LINK commitment definition
5457
+ *
5458
+ * The `META LINK` commitment represents the link to the person from whom the agent is created.
5459
+ * This commitment is special because it doesn't affect the system message,
5460
+ * but is handled separately in the parsing logic for profile display.
5461
+ *
5462
+ * Example usage in agent source:
5463
+ *
5464
+ * ```
5465
+ * META LINK https://twitter.com/username
5466
+ * META LINK https://linkedin.com/in/profile
5467
+ * META LINK https://github.com/username
5468
+ * ```
5469
+ *
5470
+ * Multiple `META LINK` commitments can be used when there are multiple sources:
5471
+ *
5472
+ * ```book
5473
+ * META LINK https://twitter.com/username
5474
+ * META LINK https://linkedin.com/in/profile
5475
+ * ```
5476
+ *
5477
+ * @private [🪔] Maybe export the commitments through some package
5478
+ */
5479
+ class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
5480
+ constructor() {
5481
+ super('META LINK');
5482
+ }
5483
+ /**
5484
+ * Short one-line description of META LINK.
5485
+ */
5486
+ get description() {
5487
+ return 'Provide profile/source links for the person the agent models.';
5488
+ }
5489
+ /**
5490
+ * Icon for this commitment.
5491
+ */
5492
+ get icon() {
5493
+ return '🔗';
5494
+ }
5495
+ /**
5496
+ * Markdown documentation for META LINK commitment.
5497
+ */
5498
+ get documentation() {
5499
+ return spaceTrim$1(`
5500
+ # META LINK
5501
+
5502
+ Represents a profile or source link for the person the agent is modeled after.
5503
+
5504
+ ## Key aspects
5505
+
5506
+ - Does not modify the agent's behavior or responses.
5507
+ - Multiple \`META LINK\` commitments can be used for different social profiles.
5508
+ - Used for attribution and crediting the original person.
5509
+ - Displayed in user interfaces for transparency.
5510
+
5511
+ ## Examples
5512
+
5513
+ \`\`\`book
5514
+ Expert Consultant
5515
+
5516
+ META LINK https://twitter.com/expertname
5517
+ META LINK https://linkedin.com/in/expertprofile
5518
+ PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
5519
+ KNOWLEDGE Extensive background in machine learning and neural networks
5520
+ \`\`\`
5521
+
5522
+ \`\`\`book
5523
+ Open Source Developer
5524
+
5525
+ META LINK https://github.com/developer
5526
+ META LINK https://twitter.com/devhandle
5527
+ PERSONA You are an experienced open source developer
5528
+ ACTION Can help with code reviews and architecture decisions
5529
+ STYLE Be direct and technical in explanations
5530
+ \`\`\`
5531
+ `);
5532
+ }
5533
+ applyToAgentModelRequirements(requirements, content) {
5534
+ // META LINK doesn't modify the system message or model requirements
5535
+ // It's handled separately in the parsing logic for profile link extraction
5536
+ // This method exists for consistency with the CommitmentDefinition interface
5537
+ return requirements;
5538
+ }
5539
+ /**
5540
+ * Extracts the profile link URL from the content
5541
+ * This is used by the parsing logic
5542
+ */
5543
+ extractProfileLinkUrl(content) {
5544
+ const trimmedContent = content.trim();
5545
+ return trimmedContent || null;
5546
+ }
5547
+ /**
5548
+ * Validates if the provided content is a valid URL
5549
+ */
5550
+ isValidUrl(content) {
5551
+ try {
5552
+ new URL(content.trim());
5553
+ return true;
5554
+ }
5555
+ catch (_a) {
5556
+ return false;
5557
+ }
5558
+ }
5559
+ }
5560
+ /**
5561
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5562
+ */
5563
+
4953
5564
  /**
4954
5565
  * MODEL commitment definition
4955
5566
  *
@@ -5301,6 +5912,74 @@ class NoteCommitmentDefinition extends BaseCommitmentDefinition {
5301
5912
  * [💞] Ignore a discrepancy between file name and entity name
5302
5913
  */
5303
5914
 
5915
+ /**
5916
+ * OPEN commitment definition
5917
+ *
5918
+ * The OPEN commitment specifies that the agent can be modified by conversation.
5919
+ * This is the default behavior.
5920
+ *
5921
+ * Example usage in agent source:
5922
+ *
5923
+ * ```book
5924
+ * OPEN
5925
+ * ```
5926
+ *
5927
+ * @private [🪔] Maybe export the commitments through some package
5928
+ */
5929
+ class OpenCommitmentDefinition extends BaseCommitmentDefinition {
5930
+ constructor() {
5931
+ super('OPEN');
5932
+ }
5933
+ /**
5934
+ * Short one-line description of OPEN.
5935
+ */
5936
+ get description() {
5937
+ return 'Allow the agent to be modified by conversation (default).';
5938
+ }
5939
+ /**
5940
+ * Icon for this commitment.
5941
+ */
5942
+ get icon() {
5943
+ return '🔓';
5944
+ }
5945
+ /**
5946
+ * Markdown documentation for OPEN commitment.
5947
+ */
5948
+ get documentation() {
5949
+ return spaceTrim$1(`
5950
+ # OPEN
5951
+
5952
+ Specifies that the agent can be modified by conversation with it.
5953
+ This means the agent will learn from interactions and update its source code.
5954
+
5955
+ This is the default behavior if neither \`OPEN\` nor \`CLOSED\` is specified.
5956
+
5957
+ > See also [CLOSED](/docs/CLOSED)
5958
+
5959
+ ## Example
5960
+
5961
+ \`\`\`book
5962
+ OPEN
5963
+ \`\`\`
5964
+ `);
5965
+ }
5966
+ applyToAgentModelRequirements(requirements, _content) {
5967
+ // Since OPEN is default, we can just ensure isClosed is false
5968
+ // But to be explicit we can set it
5969
+ const updatedMetadata = {
5970
+ ...requirements.metadata,
5971
+ isClosed: false,
5972
+ };
5973
+ return {
5974
+ ...requirements,
5975
+ metadata: updatedMetadata,
5976
+ };
5977
+ }
5978
+ }
5979
+ /**
5980
+ * Note: [💞] Ignore a discrepancy between file name and entity name
5981
+ */
5982
+
5304
5983
  /**
5305
5984
  * PERSONA commitment definition
5306
5985
  *
@@ -5811,151 +6490,60 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
5811
6490
  * [💞] Ignore a discrepancy between file name and entity name
5812
6491
  */
5813
6492
 
5814
- /**
5815
- * Placeholder commitment definition for commitments that are not yet implemented
5816
- *
5817
- * This commitment simply adds its content 1:1 into the system message,
5818
- * preserving the original behavior until proper implementation is added.
5819
- *
5820
- * @public exported from `@promptbook/core`
5821
- */
5822
- class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
5823
- constructor(type) {
5824
- super(type);
5825
- }
5826
- /**
5827
- * Short one-line description of a placeholder commitment.
5828
- */
5829
- get description() {
5830
- return 'Placeholder commitment that appends content verbatim to the system message.';
5831
- }
5832
- /**
5833
- * Icon for this commitment.
5834
- */
5835
- get icon() {
5836
- return '🚧';
5837
- }
5838
- /**
5839
- * Markdown documentation available at runtime.
5840
- */
5841
- get documentation() {
5842
- return spaceTrim$1(`
5843
- # ${this.type}
5844
-
5845
- This commitment is not yet fully implemented.
5846
-
5847
- ## Key aspects
5848
-
5849
- - Content is appended directly to the system message.
5850
- - No special processing or validation is performed.
5851
- - Behavior preserved until proper implementation is added.
5852
-
5853
- ## Status
5854
-
5855
- - **Status:** Placeholder implementation
5856
- - **Effect:** Appends content prefixed by commitment type
5857
- - **Future:** Will be replaced with specialized logic
5858
-
5859
- ## Examples
5860
-
5861
- \`\`\`book
5862
- Example Agent
5863
-
5864
- PERSONA You are a helpful assistant
5865
- ${this.type} Your content here
5866
- RULE Always be helpful
5867
- \`\`\`
5868
- `);
5869
- }
5870
- applyToAgentModelRequirements(requirements, content) {
5871
- const trimmedContent = content.trim();
5872
- if (!trimmedContent) {
5873
- return requirements;
5874
- }
5875
- // Add the commitment content 1:1 to the system message
5876
- const commitmentLine = `${this.type} ${trimmedContent}`;
5877
- return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
5878
- }
5879
- }
5880
-
5881
6493
  // Import all commitment definition classes
5882
- /**
5883
- * Registry of all available commitment definitions
5884
- * This array contains instances of all commitment definitions
5885
- * This is the single source of truth for all commitments in the system
5886
- *
5887
- * @private Use functions to access commitments instead of this array directly
5888
- */
5889
- const COMMITMENT_REGISTRY = [
5890
- // Fully implemented commitments
5891
- new PersonaCommitmentDefinition('PERSONA'),
5892
- new PersonaCommitmentDefinition('PERSONAE'),
5893
- new KnowledgeCommitmentDefinition(),
5894
- new MemoryCommitmentDefinition('MEMORY'),
5895
- new MemoryCommitmentDefinition('MEMORIES'),
5896
- new StyleCommitmentDefinition('STYLE'),
5897
- new StyleCommitmentDefinition('STYLES'),
5898
- new RuleCommitmentDefinition('RULE'),
5899
- new RuleCommitmentDefinition('RULES'),
5900
- new SampleCommitmentDefinition('SAMPLE'),
5901
- new SampleCommitmentDefinition('EXAMPLE'),
5902
- new FormatCommitmentDefinition('FORMAT'),
5903
- new FormatCommitmentDefinition('FORMATS'),
5904
- new ModelCommitmentDefinition('MODEL'),
5905
- new ModelCommitmentDefinition('MODELS'),
5906
- new ActionCommitmentDefinition('ACTION'),
5907
- new ActionCommitmentDefinition('ACTIONS'),
5908
- new MetaImageCommitmentDefinition(),
5909
- new MetaColorCommitmentDefinition(),
5910
- new MetaCommitmentDefinition(),
5911
- new NoteCommitmentDefinition('NOTE'),
5912
- new NoteCommitmentDefinition('NOTES'),
5913
- new NoteCommitmentDefinition('COMMENT'),
5914
- new NoteCommitmentDefinition('NONCE'),
5915
- new GoalCommitmentDefinition('GOAL'),
5916
- new GoalCommitmentDefinition('GOALS'),
5917
- new InitialMessageCommitmentDefinition(),
5918
- new UserMessageCommitmentDefinition(),
5919
- new AgentMessageCommitmentDefinition(),
5920
- new MessageCommitmentDefinition('MESSAGE'),
5921
- new MessageCommitmentDefinition('MESSAGES'),
5922
- new ScenarioCommitmentDefinition('SCENARIO'),
5923
- new ScenarioCommitmentDefinition('SCENARIOS'),
5924
- new DeleteCommitmentDefinition('DELETE'),
5925
- new DeleteCommitmentDefinition('CANCEL'),
5926
- new DeleteCommitmentDefinition('DISCARD'),
5927
- new DeleteCommitmentDefinition('REMOVE'),
5928
- // Not yet implemented commitments (using placeholder)
5929
- new NotYetImplementedCommitmentDefinition('EXPECT'),
5930
- new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
5931
- new NotYetImplementedCommitmentDefinition('BEHAVIOURS'),
5932
- new NotYetImplementedCommitmentDefinition('AVOID'),
5933
- new NotYetImplementedCommitmentDefinition('AVOIDANCE'),
5934
- new NotYetImplementedCommitmentDefinition('CONTEXT'),
5935
- ];
5936
- /**
5937
- * Gets a commitment definition by its type
5938
- * @param type The commitment type to look up
5939
- * @returns The commitment definition or null if not found
5940
- *
5941
- * @public exported from `@promptbook/core`
5942
- */
5943
- function getCommitmentDefinition(type) {
5944
- return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
5945
- }
5946
- /**
5947
- * Gets all available commitment definitions
5948
- * @returns Array of all commitment definitions
5949
- *
5950
- * @public exported from `@promptbook/core`
5951
- */
5952
- function getAllCommitmentDefinitions() {
5953
- return $deepFreeze([...COMMITMENT_REGISTRY]);
5954
- }
5955
- /**
5956
- * TODO: [🧠] Maybe create through standardized $register
5957
- * Note: [💞] Ignore a discrepancy between file name and entity name
5958
- */
6494
+ // Register fully implemented commitments
6495
+ registerCommitment(new PersonaCommitmentDefinition('PERSONA'));
6496
+ registerCommitment(new PersonaCommitmentDefinition('PERSONAE'));
6497
+ registerCommitment(new KnowledgeCommitmentDefinition());
6498
+ registerCommitment(new MemoryCommitmentDefinition('MEMORY'));
6499
+ registerCommitment(new MemoryCommitmentDefinition('MEMORIES'));
6500
+ registerCommitment(new StyleCommitmentDefinition('STYLE'));
6501
+ registerCommitment(new StyleCommitmentDefinition('STYLES'));
6502
+ registerCommitment(new RuleCommitmentDefinition('RULE'));
6503
+ registerCommitment(new RuleCommitmentDefinition('RULES'));
6504
+ registerCommitment(new LanguageCommitmentDefinition('LANGUAGE'));
6505
+ registerCommitment(new LanguageCommitmentDefinition('LANGUAGES'));
6506
+ registerCommitment(new SampleCommitmentDefinition('SAMPLE'));
6507
+ registerCommitment(new SampleCommitmentDefinition('EXAMPLE'));
6508
+ registerCommitment(new FormatCommitmentDefinition('FORMAT'));
6509
+ registerCommitment(new FormatCommitmentDefinition('FORMATS'));
6510
+ registerCommitment(new FromCommitmentDefinition('FROM'));
6511
+ registerCommitment(new ModelCommitmentDefinition('MODEL'));
6512
+ registerCommitment(new ModelCommitmentDefinition('MODELS'));
6513
+ registerCommitment(new ActionCommitmentDefinition('ACTION'));
6514
+ registerCommitment(new ActionCommitmentDefinition('ACTIONS'));
6515
+ registerCommitment(new ComponentCommitmentDefinition());
6516
+ registerCommitment(new MetaImageCommitmentDefinition());
6517
+ registerCommitment(new MetaColorCommitmentDefinition());
6518
+ registerCommitment(new MetaLinkCommitmentDefinition());
6519
+ registerCommitment(new MetaCommitmentDefinition());
6520
+ registerCommitment(new NoteCommitmentDefinition('NOTE'));
6521
+ registerCommitment(new NoteCommitmentDefinition('NOTES'));
6522
+ registerCommitment(new NoteCommitmentDefinition('COMMENT'));
6523
+ registerCommitment(new NoteCommitmentDefinition('NONCE'));
6524
+ registerCommitment(new GoalCommitmentDefinition('GOAL'));
6525
+ registerCommitment(new GoalCommitmentDefinition('GOALS'));
6526
+ registerCommitment(new ImportantCommitmentDefinition());
6527
+ registerCommitment(new InitialMessageCommitmentDefinition());
6528
+ registerCommitment(new UserMessageCommitmentDefinition());
6529
+ registerCommitment(new AgentMessageCommitmentDefinition());
6530
+ registerCommitment(new MessageCommitmentDefinition('MESSAGE'));
6531
+ registerCommitment(new MessageCommitmentDefinition('MESSAGES'));
6532
+ registerCommitment(new ScenarioCommitmentDefinition('SCENARIO'));
6533
+ registerCommitment(new ScenarioCommitmentDefinition('SCENARIOS'));
6534
+ registerCommitment(new DeleteCommitmentDefinition('DELETE'));
6535
+ registerCommitment(new DeleteCommitmentDefinition('CANCEL'));
6536
+ registerCommitment(new DeleteCommitmentDefinition('DISCARD'));
6537
+ registerCommitment(new DeleteCommitmentDefinition('REMOVE'));
6538
+ registerCommitment(new OpenCommitmentDefinition());
6539
+ registerCommitment(new ClosedCommitmentDefinition());
6540
+ // Register not yet implemented commitments
6541
+ registerCommitment(new NotYetImplementedCommitmentDefinition('EXPECT'));
6542
+ registerCommitment(new NotYetImplementedCommitmentDefinition('BEHAVIOUR'));
6543
+ registerCommitment(new NotYetImplementedCommitmentDefinition('BEHAVIOURS'));
6544
+ registerCommitment(new NotYetImplementedCommitmentDefinition('AVOID'));
6545
+ registerCommitment(new NotYetImplementedCommitmentDefinition('AVOIDANCE'));
6546
+ registerCommitment(new NotYetImplementedCommitmentDefinition('CONTEXT'));
5959
6547
 
5960
6548
  /**
5961
6549
  * Parses agent source using the new commitment system with multiline support
@@ -6105,16 +6693,6 @@ function parseParameters(text) {
6105
6693
  return uniqueParameters;
6106
6694
  }
6107
6695
 
6108
- /**
6109
- * Creates temporary default agent name based on agent source hash
6110
- *
6111
- * @public exported from `@promptbook/core`
6112
- */
6113
- function createDefaultAgentName(agentSource) {
6114
- const agentHash = computeAgentHash(agentSource);
6115
- return normalizeAgentName(`Agent ${agentHash.substring(0, 6)}`);
6116
- }
6117
-
6118
6696
  /**
6119
6697
  * Parses basic information from agent source
6120
6698
  *
@@ -6154,7 +6732,9 @@ function parseAgentSource(agentSource) {
6154
6732
  const links = [];
6155
6733
  for (const commitment of parseResult.commitments) {
6156
6734
  if (commitment.type === 'META LINK') {
6157
- links.push(spaceTrim(commitment.content));
6735
+ const linkValue = spaceTrim(commitment.content);
6736
+ links.push(linkValue);
6737
+ meta.link = linkValue;
6158
6738
  continue;
6159
6739
  }
6160
6740
  if (commitment.type === 'META IMAGE') {
@@ -16169,6 +16749,7 @@ class Agent extends AgentLlmExecutionTools {
16169
16749
  * Note: This method also implements the learning mechanism
16170
16750
  */
16171
16751
  async callChatModelStream(prompt, onProgress) {
16752
+ var _a;
16172
16753
  // [1] Check if the user is asking the same thing as in the samples
16173
16754
  const modelRequirements = await this.getAgentModelRequirements();
16174
16755
  if (modelRequirements.samples) {
@@ -16216,6 +16797,9 @@ class Agent extends AgentLlmExecutionTools {
16216
16797
  if (result.rawResponse && 'sample' in result.rawResponse) {
16217
16798
  return result;
16218
16799
  }
16800
+ if ((_a = modelRequirements.metadata) === null || _a === void 0 ? void 0 : _a.isClosed) {
16801
+ return result;
16802
+ }
16219
16803
  // TODO: !!! Extract learning to separate method
16220
16804
  // Learning: Append the conversation sample to the agent source
16221
16805
  const learningExample = spaceTrim((block) => `