@promptbook/cli 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.
- package/apps/agents-server/src/app/agents/[agentName]/AgentQrCode.tsx +3 -3
- package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +1 -1
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +5 -2
- package/esm/index.es.js +192 -10
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +2 -2
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +6 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +6 -0
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +38 -0
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +2 -1
- package/esm/typings/src/commitments/index.d.ts +3 -1
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +192 -10
- package/umd/index.umd.js.map +1 -1
|
@@ -5,19 +5,19 @@ import { AgentBasicInformation } from '@promptbook-local/types';
|
|
|
5
5
|
import { useState } from 'react';
|
|
6
6
|
import spaceTrim from 'spacetrim';
|
|
7
7
|
|
|
8
|
-
type AgentQrCodeProps = Pick<AgentBasicInformation, 'agentName' | 'personaDescription'> & {
|
|
8
|
+
type AgentQrCodeProps = Pick<AgentBasicInformation, 'agentName' | 'personaDescription' | 'meta'> & {
|
|
9
9
|
agentUrl: string;
|
|
10
10
|
agentEmail: string;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export function AgentQrCode({ agentName, agentUrl, agentEmail, personaDescription }: AgentQrCodeProps) {
|
|
13
|
+
export function AgentQrCode({ agentName, agentUrl, agentEmail, personaDescription, meta }: AgentQrCodeProps) {
|
|
14
14
|
const [mode, setMode] = useState<'contact' | 'link'>('contact');
|
|
15
15
|
|
|
16
16
|
// TODO: [🧠] Should we include more info in VCARD?
|
|
17
17
|
const vcard = spaceTrim(`
|
|
18
18
|
BEGIN:VCARD
|
|
19
19
|
VERSION:3.0
|
|
20
|
-
FN:${agentName}
|
|
20
|
+
FN:${meta.fullname || agentName}
|
|
21
21
|
URL:${agentUrl}
|
|
22
22
|
EMAIL:${agentEmail}
|
|
23
23
|
NOTE:${personaDescription}
|
|
@@ -11,7 +11,7 @@ export async function generateAgentMetadata({ params }: { params: Promise<{ agen
|
|
|
11
11
|
const agentSource = await collection.getAgentSource(agentName);
|
|
12
12
|
const agentProfile = parseAgentSource(agentSource);
|
|
13
13
|
|
|
14
|
-
const title = agentProfile.meta.
|
|
14
|
+
const title = agentProfile.meta.fullname || agentProfile.agentName;
|
|
15
15
|
const description = agentProfile.meta.description || agentProfile.personaDescription || undefined;
|
|
16
16
|
|
|
17
17
|
// Extract image from meta
|
|
@@ -78,7 +78,7 @@ export default async function AgentPage({ params }: { params: Promise<{ agentNam
|
|
|
78
78
|
// eslint-disable-next-line @next/next/no-img-element
|
|
79
79
|
<img
|
|
80
80
|
src={agentProfile.meta.image as string}
|
|
81
|
-
alt={agentProfile.agentName || 'Agent'}
|
|
81
|
+
alt={agentProfile.meta.fullname || agentProfile.agentName || 'Agent'}
|
|
82
82
|
width={64}
|
|
83
83
|
height={64}
|
|
84
84
|
className="rounded-full object-cover border-2 aspect-square w-16 h-16"
|
|
@@ -86,7 +86,9 @@ export default async function AgentPage({ params }: { params: Promise<{ agentNam
|
|
|
86
86
|
/>
|
|
87
87
|
)}
|
|
88
88
|
<div className="flex-1">
|
|
89
|
-
<h1 className="text-3xl font-bold text-gray-900 break-words">
|
|
89
|
+
<h1 className="text-3xl font-bold text-gray-900 break-words">
|
|
90
|
+
{agentProfile.meta.fullname || agentProfile.agentName}
|
|
91
|
+
</h1>
|
|
90
92
|
<span
|
|
91
93
|
className="inline-block mt-1 px-2 py-1 rounded text-xs font-semibold text-white"
|
|
92
94
|
style={{ backgroundColor: brandColor.toHex() }}
|
|
@@ -145,6 +147,7 @@ export default async function AgentPage({ params }: { params: Promise<{ agentNam
|
|
|
145
147
|
<div className="bg-white rounded-lg p-4 flex flex-col items-center shadow-sm border border-gray-100">
|
|
146
148
|
<AgentQrCode
|
|
147
149
|
agentName={agentProfile.agentName || 'Agent'}
|
|
150
|
+
meta={agentProfile.meta}
|
|
148
151
|
personaDescription={agentProfile.personaDescription}
|
|
149
152
|
agentUrl={agentUrl}
|
|
150
153
|
agentEmail={agentEmail}
|
package/esm/index.es.js
CHANGED
|
@@ -47,7 +47,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
47
47
|
* @generated
|
|
48
48
|
* @see https://github.com/webgptorg/promptbook
|
|
49
49
|
*/
|
|
50
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
50
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-52';
|
|
51
51
|
/**
|
|
52
52
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
53
53
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -22395,9 +22395,13 @@ const _FormattedBookInMarkdownTranspilerRegistration = $bookTranspilersRegister.
|
|
|
22395
22395
|
*
|
|
22396
22396
|
* @private - TODO: [🧠] Maybe should be public?
|
|
22397
22397
|
*/
|
|
22398
|
-
function createCommitmentRegex(commitment) {
|
|
22399
|
-
const
|
|
22400
|
-
const
|
|
22398
|
+
function createCommitmentRegex(commitment, aliases = []) {
|
|
22399
|
+
const allCommitments = [commitment, ...aliases];
|
|
22400
|
+
const patterns = allCommitments.map((c) => {
|
|
22401
|
+
const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
22402
|
+
return escapedCommitment.split(/\s+/).join('\\s+');
|
|
22403
|
+
});
|
|
22404
|
+
const keywordPattern = patterns.join('|');
|
|
22401
22405
|
const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
|
|
22402
22406
|
return regex;
|
|
22403
22407
|
}
|
|
@@ -22410,9 +22414,13 @@ function createCommitmentRegex(commitment) {
|
|
|
22410
22414
|
*
|
|
22411
22415
|
* @private
|
|
22412
22416
|
*/
|
|
22413
|
-
function createCommitmentTypeRegex(commitment) {
|
|
22414
|
-
const
|
|
22415
|
-
const
|
|
22417
|
+
function createCommitmentTypeRegex(commitment, aliases = []) {
|
|
22418
|
+
const allCommitments = [commitment, ...aliases];
|
|
22419
|
+
const patterns = allCommitments.map((c) => {
|
|
22420
|
+
const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
22421
|
+
return escapedCommitment.split(/\s+/).join('\\s+');
|
|
22422
|
+
});
|
|
22423
|
+
const keywordPattern = patterns.join('|');
|
|
22416
22424
|
const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
|
|
22417
22425
|
return regex;
|
|
22418
22426
|
}
|
|
@@ -22424,22 +22432,23 @@ function createCommitmentTypeRegex(commitment) {
|
|
|
22424
22432
|
* @private
|
|
22425
22433
|
*/
|
|
22426
22434
|
class BaseCommitmentDefinition {
|
|
22427
|
-
constructor(type) {
|
|
22435
|
+
constructor(type, aliases = []) {
|
|
22428
22436
|
this.type = type;
|
|
22437
|
+
this.aliases = aliases;
|
|
22429
22438
|
}
|
|
22430
22439
|
/**
|
|
22431
22440
|
* Creates a regex pattern to match this commitment in agent source
|
|
22432
22441
|
* Uses the existing createCommitmentRegex function as internal helper
|
|
22433
22442
|
*/
|
|
22434
22443
|
createRegex() {
|
|
22435
|
-
return createCommitmentRegex(this.type);
|
|
22444
|
+
return createCommitmentRegex(this.type, this.aliases);
|
|
22436
22445
|
}
|
|
22437
22446
|
/**
|
|
22438
22447
|
* Creates a regex pattern to match just the commitment type
|
|
22439
22448
|
* Uses the existing createCommitmentTypeRegex function as internal helper
|
|
22440
22449
|
*/
|
|
22441
22450
|
createTypeRegex() {
|
|
22442
|
-
return createCommitmentTypeRegex(this.type);
|
|
22451
|
+
return createCommitmentTypeRegex(this.type, this.aliases);
|
|
22443
22452
|
}
|
|
22444
22453
|
/**
|
|
22445
22454
|
* Helper method to create a new requirements object with updated system message
|
|
@@ -23351,6 +23360,165 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
23351
23360
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23352
23361
|
*/
|
|
23353
23362
|
|
|
23363
|
+
/**
|
|
23364
|
+
* META COLOR commitment definition
|
|
23365
|
+
*
|
|
23366
|
+
* The META COLOR commitment sets the agent's accent color.
|
|
23367
|
+
* This commitment is special because it doesn't affect the system message,
|
|
23368
|
+
* but is handled separately in the parsing logic.
|
|
23369
|
+
*
|
|
23370
|
+
* Example usage in agent source:
|
|
23371
|
+
*
|
|
23372
|
+
* ```book
|
|
23373
|
+
* META COLOR #ff0000
|
|
23374
|
+
* META COLOR #00ff00
|
|
23375
|
+
* ```
|
|
23376
|
+
*
|
|
23377
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
23378
|
+
*/
|
|
23379
|
+
class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
23380
|
+
constructor() {
|
|
23381
|
+
super('META COLOR', ['COLOR']);
|
|
23382
|
+
}
|
|
23383
|
+
/**
|
|
23384
|
+
* Short one-line description of META COLOR.
|
|
23385
|
+
*/
|
|
23386
|
+
get description() {
|
|
23387
|
+
return "Set the agent's accent color.";
|
|
23388
|
+
}
|
|
23389
|
+
/**
|
|
23390
|
+
* Markdown documentation for META COLOR commitment.
|
|
23391
|
+
*/
|
|
23392
|
+
get documentation() {
|
|
23393
|
+
return spaceTrim$1(`
|
|
23394
|
+
# META COLOR
|
|
23395
|
+
|
|
23396
|
+
Sets the agent's accent color.
|
|
23397
|
+
|
|
23398
|
+
## Key aspects
|
|
23399
|
+
|
|
23400
|
+
- Does not modify the agent's behavior or responses.
|
|
23401
|
+
- Only one \`META COLOR\` should be used per agent.
|
|
23402
|
+
- If multiple are specified, the last one takes precedence.
|
|
23403
|
+
- Used for visual representation in user interfaces.
|
|
23404
|
+
|
|
23405
|
+
## Examples
|
|
23406
|
+
|
|
23407
|
+
\`\`\`book
|
|
23408
|
+
Professional Assistant
|
|
23409
|
+
|
|
23410
|
+
META COLOR #3498db
|
|
23411
|
+
PERSONA You are a professional business assistant
|
|
23412
|
+
\`\`\`
|
|
23413
|
+
|
|
23414
|
+
\`\`\`book
|
|
23415
|
+
Creative Helper
|
|
23416
|
+
|
|
23417
|
+
META COLOR #e74c3c
|
|
23418
|
+
PERSONA You are a creative and inspiring assistant
|
|
23419
|
+
\`\`\`
|
|
23420
|
+
`);
|
|
23421
|
+
}
|
|
23422
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
23423
|
+
// META COLOR doesn't modify the system message or model requirements
|
|
23424
|
+
// It's handled separately in the parsing logic for profile color extraction
|
|
23425
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
23426
|
+
return requirements;
|
|
23427
|
+
}
|
|
23428
|
+
/**
|
|
23429
|
+
* Extracts the profile color from the content
|
|
23430
|
+
* This is used by the parsing logic
|
|
23431
|
+
*/
|
|
23432
|
+
extractProfileColor(content) {
|
|
23433
|
+
const trimmedContent = content.trim();
|
|
23434
|
+
return trimmedContent || null;
|
|
23435
|
+
}
|
|
23436
|
+
}
|
|
23437
|
+
/**
|
|
23438
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23439
|
+
*/
|
|
23440
|
+
|
|
23441
|
+
/**
|
|
23442
|
+
* META IMAGE commitment definition
|
|
23443
|
+
*
|
|
23444
|
+
* The META IMAGE commitment sets the agent's avatar/profile image URL.
|
|
23445
|
+
* This commitment is special because it doesn't affect the system message,
|
|
23446
|
+
* but is handled separately in the parsing logic.
|
|
23447
|
+
*
|
|
23448
|
+
* Example usage in agent source:
|
|
23449
|
+
*
|
|
23450
|
+
* ```book
|
|
23451
|
+
* META IMAGE https://example.com/avatar.jpg
|
|
23452
|
+
* META IMAGE /assets/agent-avatar.png
|
|
23453
|
+
* ```
|
|
23454
|
+
*
|
|
23455
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
23456
|
+
*/
|
|
23457
|
+
class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
23458
|
+
constructor() {
|
|
23459
|
+
super('META IMAGE', ['IMAGE']);
|
|
23460
|
+
}
|
|
23461
|
+
/**
|
|
23462
|
+
* Short one-line description of META IMAGE.
|
|
23463
|
+
*/
|
|
23464
|
+
get description() {
|
|
23465
|
+
return "Set the agent's profile image URL.";
|
|
23466
|
+
}
|
|
23467
|
+
/**
|
|
23468
|
+
* Markdown documentation for META IMAGE commitment.
|
|
23469
|
+
*/
|
|
23470
|
+
get documentation() {
|
|
23471
|
+
return spaceTrim$1(`
|
|
23472
|
+
# META IMAGE
|
|
23473
|
+
|
|
23474
|
+
Sets the agent's avatar/profile image URL.
|
|
23475
|
+
|
|
23476
|
+
## Key aspects
|
|
23477
|
+
|
|
23478
|
+
- Does not modify the agent's behavior or responses.
|
|
23479
|
+
- Only one \`META IMAGE\` should be used per agent.
|
|
23480
|
+
- If multiple are specified, the last one takes precedence.
|
|
23481
|
+
- Used for visual representation in user interfaces.
|
|
23482
|
+
|
|
23483
|
+
## Examples
|
|
23484
|
+
|
|
23485
|
+
\`\`\`book
|
|
23486
|
+
Professional Assistant
|
|
23487
|
+
|
|
23488
|
+
META IMAGE https://example.com/professional-avatar.jpg
|
|
23489
|
+
PERSONA You are a professional business assistant
|
|
23490
|
+
STYLE Maintain a formal and courteous tone
|
|
23491
|
+
\`\`\`
|
|
23492
|
+
|
|
23493
|
+
\`\`\`book
|
|
23494
|
+
Creative Helper
|
|
23495
|
+
|
|
23496
|
+
META IMAGE /assets/creative-bot-avatar.png
|
|
23497
|
+
PERSONA You are a creative and inspiring assistant
|
|
23498
|
+
STYLE Be enthusiastic and encouraging
|
|
23499
|
+
ACTION Can help with brainstorming and ideation
|
|
23500
|
+
\`\`\`
|
|
23501
|
+
`);
|
|
23502
|
+
}
|
|
23503
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
23504
|
+
// META IMAGE doesn't modify the system message or model requirements
|
|
23505
|
+
// It's handled separately in the parsing logic for profile image extraction
|
|
23506
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
23507
|
+
return requirements;
|
|
23508
|
+
}
|
|
23509
|
+
/**
|
|
23510
|
+
* Extracts the profile image URL from the content
|
|
23511
|
+
* This is used by the parsing logic
|
|
23512
|
+
*/
|
|
23513
|
+
extractProfileImageUrl(content) {
|
|
23514
|
+
const trimmedContent = content.trim();
|
|
23515
|
+
return trimmedContent || null;
|
|
23516
|
+
}
|
|
23517
|
+
}
|
|
23518
|
+
/**
|
|
23519
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23520
|
+
*/
|
|
23521
|
+
|
|
23354
23522
|
/**
|
|
23355
23523
|
* MODEL commitment definition
|
|
23356
23524
|
*
|
|
@@ -24258,6 +24426,8 @@ const COMMITMENT_REGISTRY = [
|
|
|
24258
24426
|
new ModelCommitmentDefinition('MODELS'),
|
|
24259
24427
|
new ActionCommitmentDefinition('ACTION'),
|
|
24260
24428
|
new ActionCommitmentDefinition('ACTIONS'),
|
|
24429
|
+
new MetaImageCommitmentDefinition(),
|
|
24430
|
+
new MetaColorCommitmentDefinition(),
|
|
24261
24431
|
new MetaCommitmentDefinition(),
|
|
24262
24432
|
new NoteCommitmentDefinition('NOTE'),
|
|
24263
24433
|
new NoteCommitmentDefinition('NOTES'),
|
|
@@ -24710,6 +24880,14 @@ function parseAgentSource(agentSource) {
|
|
|
24710
24880
|
links.push(spaceTrim(commitment.content));
|
|
24711
24881
|
continue;
|
|
24712
24882
|
}
|
|
24883
|
+
if (commitment.type === 'META IMAGE') {
|
|
24884
|
+
meta.image = spaceTrim(commitment.content);
|
|
24885
|
+
continue;
|
|
24886
|
+
}
|
|
24887
|
+
if (commitment.type === 'META COLOR') {
|
|
24888
|
+
meta.color = spaceTrim(commitment.content);
|
|
24889
|
+
continue;
|
|
24890
|
+
}
|
|
24713
24891
|
if (commitment.type !== 'META') {
|
|
24714
24892
|
continue;
|
|
24715
24893
|
}
|
|
@@ -24725,6 +24903,10 @@ function parseAgentSource(agentSource) {
|
|
|
24725
24903
|
if (!meta.image) {
|
|
24726
24904
|
meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
|
|
24727
24905
|
}
|
|
24906
|
+
// Generate fullname fallback if no meta fullname specified
|
|
24907
|
+
if (!meta.fullname) {
|
|
24908
|
+
meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
24909
|
+
}
|
|
24728
24910
|
// Parse parameters using unified approach - both @Parameter and {parameter} notations
|
|
24729
24911
|
// are treated as the same syntax feature with unified representation
|
|
24730
24912
|
const parameters = parseParameters(agentSource);
|