@promptbook/core 0.103.0-51 → 0.103.0-52

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.
@@ -49,6 +49,7 @@ export type AgentBasicInformation = {
49
49
  * When there are multiple meta commitments of the same type, later overrides earlier
50
50
  */
51
51
  meta: {
52
+ fullname?: string;
52
53
  image?: string_url_image;
53
54
  color?: string_color;
54
55
  [key: string]: string | undefined;
@@ -7,7 +7,7 @@ import type { BookCommitment } from '../../commitments/_base/BookCommitment';
7
7
  *
8
8
  * @private - TODO: [🧠] Maybe should be public?
9
9
  */
10
- export declare function createCommitmentRegex(commitment: BookCommitment): RegExp;
10
+ export declare function createCommitmentRegex(commitment: BookCommitment, aliases?: BookCommitment[]): RegExp;
11
11
  /**
12
12
  * Generates a regex pattern to match a specific commitment type
13
13
  *
@@ -17,4 +17,4 @@ export declare function createCommitmentRegex(commitment: BookCommitment): RegEx
17
17
  *
18
18
  * @private
19
19
  */
20
- export declare function createCommitmentTypeRegex(commitment: BookCommitment): RegExp;
20
+ export declare function createCommitmentTypeRegex(commitment: BookCommitment, aliases?: BookCommitment[]): RegExp;
@@ -77,6 +77,12 @@ export type ChatProps = {
77
77
  * adding feature–specific controls (e.g. Pause / Resume in MockedChat).
78
78
  */
79
79
  readonly extraActions?: ReactNode;
80
+ /**
81
+ * Optional container to render the actions into (using React Portal).
82
+ * If provided, the actions toolbar will be rendered inside this element
83
+ * instead of its default position within the chat.
84
+ */
85
+ readonly actionsContainer?: HTMLElement | null;
80
86
  /**
81
87
  * Optional CSS class name which will be added to root <div/> element
82
88
  */
@@ -1,3 +1,4 @@
1
+ import type { AgentBasicInformation } from '../../book-2.0/agent-source/AgentBasicInformation';
1
2
  type PromptbookAgentProps = {
2
3
  /**
3
4
  * URL of the agent to connect to
@@ -5,6 +6,11 @@ type PromptbookAgentProps = {
5
6
  * @example "http://s6.ptbk.io/benjamin-white"
6
7
  */
7
8
  agentUrl: string;
9
+ /**
10
+ * Optional metadata to show before the agent is connected
11
+ * Or to override the agent metadata if the agent does not provide it
12
+ */
13
+ meta?: Partial<AgentBasicInformation['meta']>;
8
14
  /**
9
15
  * Callback when the window is opened or closed
10
16
  */
@@ -0,0 +1,38 @@
1
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
3
+ /**
4
+ * META COLOR commitment definition
5
+ *
6
+ * The META COLOR commitment sets the agent's accent color.
7
+ * This commitment is special because it doesn't affect the system message,
8
+ * but is handled separately in the parsing logic.
9
+ *
10
+ * Example usage in agent source:
11
+ *
12
+ * ```book
13
+ * META COLOR #ff0000
14
+ * META COLOR #00ff00
15
+ * ```
16
+ *
17
+ * @private [🪔] Maybe export the commitments through some package
18
+ */
19
+ export declare class MetaColorCommitmentDefinition extends BaseCommitmentDefinition<'META COLOR'> {
20
+ constructor();
21
+ /**
22
+ * Short one-line description of META COLOR.
23
+ */
24
+ get description(): string;
25
+ /**
26
+ * Markdown documentation for META COLOR commitment.
27
+ */
28
+ get documentation(): string;
29
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
30
+ /**
31
+ * Extracts the profile color from the content
32
+ * This is used by the parsing logic
33
+ */
34
+ extractProfileColor(content: string): string | null;
35
+ }
36
+ /**
37
+ * Note: [💞] Ignore a discrepancy between file name and entity name
38
+ */
@@ -8,7 +8,8 @@ import type { CommitmentDefinition } from './CommitmentDefinition';
8
8
  */
9
9
  export declare abstract class BaseCommitmentDefinition<TBookCommitment extends string> implements CommitmentDefinition {
10
10
  readonly type: TBookCommitment;
11
- constructor(type: TBookCommitment);
11
+ readonly aliases: string[];
12
+ constructor(type: TBookCommitment, aliases?: string[]);
12
13
  /**
13
14
  * Short one-line markdown description; concise, may use inline **markdown**.
14
15
  * Must be implemented by each concrete commitment.
@@ -9,6 +9,8 @@ import { MemoryCommitmentDefinition } from './MEMORY/MEMORY';
9
9
  import { InitialMessageCommitmentDefinition } from './MESSAGE/InitialMessageCommitmentDefinition';
10
10
  import { MessageCommitmentDefinition } from './MESSAGE/MESSAGE';
11
11
  import { MetaCommitmentDefinition } from './META/META';
12
+ import { MetaColorCommitmentDefinition } from './META_COLOR/META_COLOR';
13
+ import { MetaImageCommitmentDefinition } from './META_IMAGE/META_IMAGE';
12
14
  import { ModelCommitmentDefinition } from './MODEL/MODEL';
13
15
  import { NoteCommitmentDefinition } from './NOTE/NOTE';
14
16
  import { PersonaCommitmentDefinition } from './PERSONA/PERSONA';
@@ -24,7 +26,7 @@ import { NotYetImplementedCommitmentDefinition } from './_base/NotYetImplemented
24
26
  *
25
27
  * @private Use functions to access commitments instead of this array directly
26
28
  */
27
- export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, ModelCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, ActionCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, GoalCommitmentDefinition, InitialMessageCommitmentDefinition, MessageCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
29
+ export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, ModelCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, ActionCommitmentDefinition, MetaImageCommitmentDefinition, MetaColorCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, GoalCommitmentDefinition, InitialMessageCommitmentDefinition, MessageCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
28
30
  /**
29
31
  * Gets a commitment definition by its type
30
32
  * @param type The commitment type to look up
@@ -45,6 +45,7 @@ export declare class Agent extends AgentLlmExecutionTools implements LlmExecutio
45
45
  * Metadata like image or color
46
46
  */
47
47
  meta: {
48
+ fullname?: string;
48
49
  image?: string_url_image;
49
50
  link?: string;
50
51
  title?: string;
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.103.0-50`).
18
+ * It follows semantic versioning (e.g., `0.103.0-51`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.103.0-51",
3
+ "version": "0.103.0-52",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -28,7 +28,7 @@
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-51';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-52';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -7445,9 +7445,13 @@
7445
7445
  *
7446
7446
  * @private - TODO: [🧠] Maybe should be public?
7447
7447
  */
7448
- function createCommitmentRegex(commitment) {
7449
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7450
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
7448
+ function createCommitmentRegex(commitment, aliases = []) {
7449
+ const allCommitments = [commitment, ...aliases];
7450
+ const patterns = allCommitments.map((c) => {
7451
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7452
+ return escapedCommitment.split(/\s+/).join('\\s+');
7453
+ });
7454
+ const keywordPattern = patterns.join('|');
7451
7455
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
7452
7456
  return regex;
7453
7457
  }
@@ -7460,9 +7464,13 @@
7460
7464
  *
7461
7465
  * @private
7462
7466
  */
7463
- function createCommitmentTypeRegex(commitment) {
7464
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7465
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
7467
+ function createCommitmentTypeRegex(commitment, aliases = []) {
7468
+ const allCommitments = [commitment, ...aliases];
7469
+ const patterns = allCommitments.map((c) => {
7470
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7471
+ return escapedCommitment.split(/\s+/).join('\\s+');
7472
+ });
7473
+ const keywordPattern = patterns.join('|');
7466
7474
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
7467
7475
  return regex;
7468
7476
  }
@@ -7474,22 +7482,23 @@
7474
7482
  * @private
7475
7483
  */
7476
7484
  class BaseCommitmentDefinition {
7477
- constructor(type) {
7485
+ constructor(type, aliases = []) {
7478
7486
  this.type = type;
7487
+ this.aliases = aliases;
7479
7488
  }
7480
7489
  /**
7481
7490
  * Creates a regex pattern to match this commitment in agent source
7482
7491
  * Uses the existing createCommitmentRegex function as internal helper
7483
7492
  */
7484
7493
  createRegex() {
7485
- return createCommitmentRegex(this.type);
7494
+ return createCommitmentRegex(this.type, this.aliases);
7486
7495
  }
7487
7496
  /**
7488
7497
  * Creates a regex pattern to match just the commitment type
7489
7498
  * Uses the existing createCommitmentTypeRegex function as internal helper
7490
7499
  */
7491
7500
  createTypeRegex() {
7492
- return createCommitmentTypeRegex(this.type);
7501
+ return createCommitmentTypeRegex(this.type, this.aliases);
7493
7502
  }
7494
7503
  /**
7495
7504
  * Helper method to create a new requirements object with updated system message
@@ -8401,6 +8410,165 @@
8401
8410
  * Note: [💞] Ignore a discrepancy between file name and entity name
8402
8411
  */
8403
8412
 
8413
+ /**
8414
+ * META COLOR commitment definition
8415
+ *
8416
+ * The META COLOR commitment sets the agent's accent color.
8417
+ * This commitment is special because it doesn't affect the system message,
8418
+ * but is handled separately in the parsing logic.
8419
+ *
8420
+ * Example usage in agent source:
8421
+ *
8422
+ * ```book
8423
+ * META COLOR #ff0000
8424
+ * META COLOR #00ff00
8425
+ * ```
8426
+ *
8427
+ * @private [🪔] Maybe export the commitments through some package
8428
+ */
8429
+ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
8430
+ constructor() {
8431
+ super('META COLOR', ['COLOR']);
8432
+ }
8433
+ /**
8434
+ * Short one-line description of META COLOR.
8435
+ */
8436
+ get description() {
8437
+ return "Set the agent's accent color.";
8438
+ }
8439
+ /**
8440
+ * Markdown documentation for META COLOR commitment.
8441
+ */
8442
+ get documentation() {
8443
+ return spaceTrim$1.spaceTrim(`
8444
+ # META COLOR
8445
+
8446
+ Sets the agent's accent color.
8447
+
8448
+ ## Key aspects
8449
+
8450
+ - Does not modify the agent's behavior or responses.
8451
+ - Only one \`META COLOR\` should be used per agent.
8452
+ - If multiple are specified, the last one takes precedence.
8453
+ - Used for visual representation in user interfaces.
8454
+
8455
+ ## Examples
8456
+
8457
+ \`\`\`book
8458
+ Professional Assistant
8459
+
8460
+ META COLOR #3498db
8461
+ PERSONA You are a professional business assistant
8462
+ \`\`\`
8463
+
8464
+ \`\`\`book
8465
+ Creative Helper
8466
+
8467
+ META COLOR #e74c3c
8468
+ PERSONA You are a creative and inspiring assistant
8469
+ \`\`\`
8470
+ `);
8471
+ }
8472
+ applyToAgentModelRequirements(requirements, content) {
8473
+ // META COLOR doesn't modify the system message or model requirements
8474
+ // It's handled separately in the parsing logic for profile color extraction
8475
+ // This method exists for consistency with the CommitmentDefinition interface
8476
+ return requirements;
8477
+ }
8478
+ /**
8479
+ * Extracts the profile color from the content
8480
+ * This is used by the parsing logic
8481
+ */
8482
+ extractProfileColor(content) {
8483
+ const trimmedContent = content.trim();
8484
+ return trimmedContent || null;
8485
+ }
8486
+ }
8487
+ /**
8488
+ * Note: [💞] Ignore a discrepancy between file name and entity name
8489
+ */
8490
+
8491
+ /**
8492
+ * META IMAGE commitment definition
8493
+ *
8494
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
8495
+ * This commitment is special because it doesn't affect the system message,
8496
+ * but is handled separately in the parsing logic.
8497
+ *
8498
+ * Example usage in agent source:
8499
+ *
8500
+ * ```book
8501
+ * META IMAGE https://example.com/avatar.jpg
8502
+ * META IMAGE /assets/agent-avatar.png
8503
+ * ```
8504
+ *
8505
+ * @private [🪔] Maybe export the commitments through some package
8506
+ */
8507
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
8508
+ constructor() {
8509
+ super('META IMAGE', ['IMAGE']);
8510
+ }
8511
+ /**
8512
+ * Short one-line description of META IMAGE.
8513
+ */
8514
+ get description() {
8515
+ return "Set the agent's profile image URL.";
8516
+ }
8517
+ /**
8518
+ * Markdown documentation for META IMAGE commitment.
8519
+ */
8520
+ get documentation() {
8521
+ return spaceTrim$1.spaceTrim(`
8522
+ # META IMAGE
8523
+
8524
+ Sets the agent's avatar/profile image URL.
8525
+
8526
+ ## Key aspects
8527
+
8528
+ - Does not modify the agent's behavior or responses.
8529
+ - Only one \`META IMAGE\` should be used per agent.
8530
+ - If multiple are specified, the last one takes precedence.
8531
+ - Used for visual representation in user interfaces.
8532
+
8533
+ ## Examples
8534
+
8535
+ \`\`\`book
8536
+ Professional Assistant
8537
+
8538
+ META IMAGE https://example.com/professional-avatar.jpg
8539
+ PERSONA You are a professional business assistant
8540
+ STYLE Maintain a formal and courteous tone
8541
+ \`\`\`
8542
+
8543
+ \`\`\`book
8544
+ Creative Helper
8545
+
8546
+ META IMAGE /assets/creative-bot-avatar.png
8547
+ PERSONA You are a creative and inspiring assistant
8548
+ STYLE Be enthusiastic and encouraging
8549
+ ACTION Can help with brainstorming and ideation
8550
+ \`\`\`
8551
+ `);
8552
+ }
8553
+ applyToAgentModelRequirements(requirements, content) {
8554
+ // META IMAGE doesn't modify the system message or model requirements
8555
+ // It's handled separately in the parsing logic for profile image extraction
8556
+ // This method exists for consistency with the CommitmentDefinition interface
8557
+ return requirements;
8558
+ }
8559
+ /**
8560
+ * Extracts the profile image URL from the content
8561
+ * This is used by the parsing logic
8562
+ */
8563
+ extractProfileImageUrl(content) {
8564
+ const trimmedContent = content.trim();
8565
+ return trimmedContent || null;
8566
+ }
8567
+ }
8568
+ /**
8569
+ * Note: [💞] Ignore a discrepancy between file name and entity name
8570
+ */
8571
+
8404
8572
  /**
8405
8573
  * MODEL commitment definition
8406
8574
  *
@@ -9308,6 +9476,8 @@
9308
9476
  new ModelCommitmentDefinition('MODELS'),
9309
9477
  new ActionCommitmentDefinition('ACTION'),
9310
9478
  new ActionCommitmentDefinition('ACTIONS'),
9479
+ new MetaImageCommitmentDefinition(),
9480
+ new MetaColorCommitmentDefinition(),
9311
9481
  new MetaCommitmentDefinition(),
9312
9482
  new NoteCommitmentDefinition('NOTE'),
9313
9483
  new NoteCommitmentDefinition('NOTES'),
@@ -10221,6 +10391,14 @@
10221
10391
  links.push(spaceTrim__default["default"](commitment.content));
10222
10392
  continue;
10223
10393
  }
10394
+ if (commitment.type === 'META IMAGE') {
10395
+ meta.image = spaceTrim__default["default"](commitment.content);
10396
+ continue;
10397
+ }
10398
+ if (commitment.type === 'META COLOR') {
10399
+ meta.color = spaceTrim__default["default"](commitment.content);
10400
+ continue;
10401
+ }
10224
10402
  if (commitment.type !== 'META') {
10225
10403
  continue;
10226
10404
  }
@@ -10236,6 +10414,10 @@
10236
10414
  if (!meta.image) {
10237
10415
  meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
10238
10416
  }
10417
+ // Generate fullname fallback if no meta fullname specified
10418
+ if (!meta.fullname) {
10419
+ meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
10420
+ }
10239
10421
  // Parse parameters using unified approach - both @Parameter and {parameter} notations
10240
10422
  // are treated as the same syntax feature with unified representation
10241
10423
  const parameters = parseParameters(agentSource);
@@ -17265,7 +17447,7 @@
17265
17447
  }
17266
17448
  get title() {
17267
17449
  const agentInfo = this.getAgentInfo();
17268
- return (agentInfo.agentName || 'Agent');
17450
+ return (agentInfo.meta.fullname || agentInfo.agentName || 'Agent');
17269
17451
  }
17270
17452
  get description() {
17271
17453
  const agentInfo = this.getAgentInfo();
@@ -17278,7 +17460,7 @@
17278
17460
  }
17279
17461
  return {
17280
17462
  name: agentInfo.agentName.toUpperCase().replace(/\s+/g, '_'),
17281
- fullname: agentInfo.agentName,
17463
+ fullname: agentInfo.meta.fullname || agentInfo.agentName,
17282
17464
  color: agentInfo.meta.color || '#6366f1',
17283
17465
  avatarSrc: agentInfo.meta.image,
17284
17466
  };
@@ -17510,12 +17692,10 @@
17510
17692
 
17511
17693
  ---
17512
17694
 
17513
- SAMPLE
17514
-
17515
- User:
17695
+ USER MESSAGE
17516
17696
  ${block(prompt.content)}
17517
17697
 
17518
- ${this.title} (Me, the Agent):
17698
+ AGENT MESSAGE
17519
17699
  ${block(result.content)}
17520
17700
 
17521
17701
  `);