@promptbook/core 0.103.0-54 โ 0.103.0-56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +1410 -403
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +6 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/commitments/index.d.ts +12 -1
- package/esm/typings/src/playground/playground.d.ts +3 -0
- package/esm/typings/src/utils/color/Color.d.ts +8 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +1061 -54
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/playground/playground1.d.ts +0 -2
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-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-56';
|
|
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
|
|
@@ -90,6 +90,17 @@
|
|
|
90
90
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
91
91
|
*/
|
|
92
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Trims string from all 4 sides
|
|
95
|
+
*
|
|
96
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
97
|
+
* Developed by same author @hejny as this package
|
|
98
|
+
*
|
|
99
|
+
* @public exported from `@promptbook/utils`
|
|
100
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
101
|
+
*/
|
|
102
|
+
const spaceTrim = spaceTrim$1.spaceTrim;
|
|
103
|
+
|
|
93
104
|
/**
|
|
94
105
|
* @private util of `@promptbook/color`
|
|
95
106
|
* @de
|
|
@@ -138,6 +149,7 @@
|
|
|
138
149
|
* @public exported from `@promptbook/color`
|
|
139
150
|
*/
|
|
140
151
|
const CSS_COLORS = {
|
|
152
|
+
promptbook: '#79EAFD',
|
|
141
153
|
transparent: 'rgba(0,0,0,0)',
|
|
142
154
|
aliceblue: '#f0f8ff',
|
|
143
155
|
antiquewhite: '#faebd7',
|
|
@@ -353,6 +365,28 @@
|
|
|
353
365
|
throw new Error(`Can not create color from given object`);
|
|
354
366
|
}
|
|
355
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Creates a new Color instance from miscellaneous formats
|
|
370
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
371
|
+
*
|
|
372
|
+
* @param color
|
|
373
|
+
* @returns Color object
|
|
374
|
+
*/
|
|
375
|
+
static fromSafe(color) {
|
|
376
|
+
try {
|
|
377
|
+
return Color.from(color);
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
381
|
+
console.warn(spaceTrim((block) => `
|
|
382
|
+
Color.fromSafe error:
|
|
383
|
+
${block(error.message)}
|
|
384
|
+
|
|
385
|
+
Returning default PROMPTBOOK_COLOR.
|
|
386
|
+
`));
|
|
387
|
+
return Color.fromString('promptbook');
|
|
388
|
+
}
|
|
389
|
+
}
|
|
356
390
|
/**
|
|
357
391
|
* Creates a new Color instance from miscellaneous string formats
|
|
358
392
|
*
|
|
@@ -976,7 +1010,7 @@
|
|
|
976
1010
|
*
|
|
977
1011
|
* @public exported from `@promptbook/core`
|
|
978
1012
|
*/
|
|
979
|
-
const PROMPTBOOK_COLOR = Color.
|
|
1013
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
980
1014
|
// <- TODO: [๐ง ][๐ต] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
981
1015
|
/**
|
|
982
1016
|
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
@@ -7644,6 +7678,133 @@
|
|
|
7644
7678
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
7645
7679
|
*/
|
|
7646
7680
|
|
|
7681
|
+
/**
|
|
7682
|
+
* CLOSED commitment definition
|
|
7683
|
+
*
|
|
7684
|
+
* The CLOSED commitment specifies that the agent CANNOT be modified by conversation.
|
|
7685
|
+
* It prevents the agent from learning from interactions and updating its source code.
|
|
7686
|
+
*
|
|
7687
|
+
* Example usage in agent source:
|
|
7688
|
+
*
|
|
7689
|
+
* ```book
|
|
7690
|
+
* CLOSED
|
|
7691
|
+
* ```
|
|
7692
|
+
*
|
|
7693
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
7694
|
+
*/
|
|
7695
|
+
class ClosedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
7696
|
+
constructor() {
|
|
7697
|
+
super('CLOSED');
|
|
7698
|
+
}
|
|
7699
|
+
/**
|
|
7700
|
+
* Short one-line description of CLOSED.
|
|
7701
|
+
*/
|
|
7702
|
+
get description() {
|
|
7703
|
+
return 'Prevent the agent from being modified by conversation.';
|
|
7704
|
+
}
|
|
7705
|
+
/**
|
|
7706
|
+
* Icon for this commitment.
|
|
7707
|
+
*/
|
|
7708
|
+
get icon() {
|
|
7709
|
+
return '๐';
|
|
7710
|
+
}
|
|
7711
|
+
/**
|
|
7712
|
+
* Markdown documentation for CLOSED commitment.
|
|
7713
|
+
*/
|
|
7714
|
+
get documentation() {
|
|
7715
|
+
return spaceTrim$1.spaceTrim(`
|
|
7716
|
+
# CLOSED
|
|
7717
|
+
|
|
7718
|
+
Specifies that the agent **cannot** be modified by conversation with it.
|
|
7719
|
+
This means the agent will **not** learn from interactions and its source code will remain static during conversation.
|
|
7720
|
+
|
|
7721
|
+
By default (if not specified), agents are \`OPEN\` to modification.
|
|
7722
|
+
|
|
7723
|
+
> See also [OPEN](/docs/OPEN)
|
|
7724
|
+
|
|
7725
|
+
## Example
|
|
7726
|
+
|
|
7727
|
+
\`\`\`book
|
|
7728
|
+
CLOSED
|
|
7729
|
+
\`\`\`
|
|
7730
|
+
`);
|
|
7731
|
+
}
|
|
7732
|
+
applyToAgentModelRequirements(requirements, _content) {
|
|
7733
|
+
const updatedMetadata = {
|
|
7734
|
+
...requirements.metadata,
|
|
7735
|
+
isClosed: true,
|
|
7736
|
+
};
|
|
7737
|
+
return {
|
|
7738
|
+
...requirements,
|
|
7739
|
+
metadata: updatedMetadata,
|
|
7740
|
+
};
|
|
7741
|
+
}
|
|
7742
|
+
}
|
|
7743
|
+
/**
|
|
7744
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
7745
|
+
*/
|
|
7746
|
+
|
|
7747
|
+
/**
|
|
7748
|
+
* COMPONENT commitment definition
|
|
7749
|
+
*
|
|
7750
|
+
* The COMPONENT commitment defines a UI component that the agent can render in the chat.
|
|
7751
|
+
*
|
|
7752
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
7753
|
+
*/
|
|
7754
|
+
class ComponentCommitmentDefinition extends BaseCommitmentDefinition {
|
|
7755
|
+
constructor() {
|
|
7756
|
+
super('COMPONENT');
|
|
7757
|
+
}
|
|
7758
|
+
/**
|
|
7759
|
+
* Short one-line description of COMPONENT.
|
|
7760
|
+
*/
|
|
7761
|
+
get description() {
|
|
7762
|
+
return 'Define a UI component that the agent can render in the chat.';
|
|
7763
|
+
}
|
|
7764
|
+
/**
|
|
7765
|
+
* Icon for this commitment.
|
|
7766
|
+
*/
|
|
7767
|
+
get icon() {
|
|
7768
|
+
return '๐งฉ';
|
|
7769
|
+
}
|
|
7770
|
+
/**
|
|
7771
|
+
* Markdown documentation for COMPONENT commitment.
|
|
7772
|
+
*/
|
|
7773
|
+
get documentation() {
|
|
7774
|
+
return spaceTrim$1.spaceTrim(`
|
|
7775
|
+
# COMPONENT
|
|
7776
|
+
|
|
7777
|
+
Defines a UI component that the agent can render in the chat.
|
|
7778
|
+
|
|
7779
|
+
## Key aspects
|
|
7780
|
+
|
|
7781
|
+
- Tells the agent that a specific component is available.
|
|
7782
|
+
- Provides syntax for using the component.
|
|
7783
|
+
|
|
7784
|
+
## Example
|
|
7785
|
+
|
|
7786
|
+
\`\`\`book
|
|
7787
|
+
COMPONENT Arrow
|
|
7788
|
+
The agent should render an arrow component in the chat UI.
|
|
7789
|
+
Syntax:
|
|
7790
|
+
<Arrow direction="up" color="red" />
|
|
7791
|
+
\`\`\`
|
|
7792
|
+
`);
|
|
7793
|
+
}
|
|
7794
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
7795
|
+
const trimmedContent = content.trim();
|
|
7796
|
+
if (!trimmedContent) {
|
|
7797
|
+
return requirements;
|
|
7798
|
+
}
|
|
7799
|
+
// Add component capability to the system message
|
|
7800
|
+
const componentSection = `Component: ${trimmedContent}`;
|
|
7801
|
+
return this.appendToSystemMessage(requirements, componentSection, '\n\n');
|
|
7802
|
+
}
|
|
7803
|
+
}
|
|
7804
|
+
/**
|
|
7805
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
7806
|
+
*/
|
|
7807
|
+
|
|
7647
7808
|
/**
|
|
7648
7809
|
* DELETE commitment definition
|
|
7649
7810
|
*
|
|
@@ -7849,6 +8010,79 @@
|
|
|
7849
8010
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
7850
8011
|
*/
|
|
7851
8012
|
|
|
8013
|
+
/**
|
|
8014
|
+
* FROM commitment definition
|
|
8015
|
+
*
|
|
8016
|
+
* The FROM commitment tells the agent that its `agentSource` is inherited from another agent.
|
|
8017
|
+
*
|
|
8018
|
+
* Example usage in agent source:
|
|
8019
|
+
*
|
|
8020
|
+
* ```book
|
|
8021
|
+
* FROM https://s6.ptbk.io/benjamin-white
|
|
8022
|
+
* ```
|
|
8023
|
+
*
|
|
8024
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
8025
|
+
*/
|
|
8026
|
+
class FromCommitmentDefinition extends BaseCommitmentDefinition {
|
|
8027
|
+
constructor(type = 'FROM') {
|
|
8028
|
+
super(type);
|
|
8029
|
+
}
|
|
8030
|
+
/**
|
|
8031
|
+
* Short one-line description of FROM.
|
|
8032
|
+
*/
|
|
8033
|
+
get description() {
|
|
8034
|
+
return 'Inherit agent source from another agent.';
|
|
8035
|
+
}
|
|
8036
|
+
/**
|
|
8037
|
+
* Icon for this commitment.
|
|
8038
|
+
*/
|
|
8039
|
+
get icon() {
|
|
8040
|
+
return '๐งฌ';
|
|
8041
|
+
}
|
|
8042
|
+
/**
|
|
8043
|
+
* Markdown documentation for FROM commitment.
|
|
8044
|
+
*/
|
|
8045
|
+
get documentation() {
|
|
8046
|
+
return spaceTrim$1.spaceTrim(`
|
|
8047
|
+
# ${this.type}
|
|
8048
|
+
|
|
8049
|
+
Inherits agent source from another agent.
|
|
8050
|
+
|
|
8051
|
+
## Examples
|
|
8052
|
+
|
|
8053
|
+
\`\`\`book
|
|
8054
|
+
My AI Agent
|
|
8055
|
+
|
|
8056
|
+
FROM https://s6.ptbk.io/benjamin-white
|
|
8057
|
+
RULE Speak only in English.
|
|
8058
|
+
\`\`\`
|
|
8059
|
+
`);
|
|
8060
|
+
}
|
|
8061
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
8062
|
+
const trimmedContent = content.trim();
|
|
8063
|
+
if (!trimmedContent) {
|
|
8064
|
+
return requirements;
|
|
8065
|
+
}
|
|
8066
|
+
// Validate URL
|
|
8067
|
+
try {
|
|
8068
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8069
|
+
const url = new URL(trimmedContent);
|
|
8070
|
+
// TODO: Add more validation if needed (e.g. check for valid protocol)
|
|
8071
|
+
}
|
|
8072
|
+
catch (error) {
|
|
8073
|
+
console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
|
|
8074
|
+
return requirements;
|
|
8075
|
+
}
|
|
8076
|
+
return {
|
|
8077
|
+
...requirements,
|
|
8078
|
+
parentAgentUrl: trimmedContent,
|
|
8079
|
+
};
|
|
8080
|
+
}
|
|
8081
|
+
}
|
|
8082
|
+
/**
|
|
8083
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
8084
|
+
*/
|
|
8085
|
+
|
|
7852
8086
|
/**
|
|
7853
8087
|
* GOAL commitment definition
|
|
7854
8088
|
*
|
|
@@ -8057,6 +8291,77 @@
|
|
|
8057
8291
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
8058
8292
|
*/
|
|
8059
8293
|
|
|
8294
|
+
/**
|
|
8295
|
+
* LANGUAGE commitment definition
|
|
8296
|
+
*
|
|
8297
|
+
* The LANGUAGE/LANGUAGES commitment specifies the language(s) the agent should use in its responses.
|
|
8298
|
+
*
|
|
8299
|
+
* Example usage in agent source:
|
|
8300
|
+
*
|
|
8301
|
+
* ```book
|
|
8302
|
+
* LANGUAGE English
|
|
8303
|
+
* LANGUAGE French, English and Czech
|
|
8304
|
+
* ```
|
|
8305
|
+
*
|
|
8306
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
8307
|
+
*/
|
|
8308
|
+
class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
8309
|
+
constructor(type = 'LANGUAGE') {
|
|
8310
|
+
super(type);
|
|
8311
|
+
}
|
|
8312
|
+
/**
|
|
8313
|
+
* Short one-line description of LANGUAGE/LANGUAGES.
|
|
8314
|
+
*/
|
|
8315
|
+
get description() {
|
|
8316
|
+
return 'Specifies the language(s) the agent should use.';
|
|
8317
|
+
}
|
|
8318
|
+
/**
|
|
8319
|
+
* Icon for this commitment.
|
|
8320
|
+
*/
|
|
8321
|
+
get icon() {
|
|
8322
|
+
return '๐';
|
|
8323
|
+
}
|
|
8324
|
+
/**
|
|
8325
|
+
* Markdown documentation for LANGUAGE/LANGUAGES commitment.
|
|
8326
|
+
*/
|
|
8327
|
+
get documentation() {
|
|
8328
|
+
return spaceTrim$1.spaceTrim(`
|
|
8329
|
+
# ${this.type}
|
|
8330
|
+
|
|
8331
|
+
Specifies the language(s) the agent should use in its responses.
|
|
8332
|
+
This is a specialized variation of the RULE commitment focused on language constraints.
|
|
8333
|
+
|
|
8334
|
+
## Examples
|
|
8335
|
+
|
|
8336
|
+
\`\`\`book
|
|
8337
|
+
Paul Smith & Associรฉs
|
|
8338
|
+
|
|
8339
|
+
PERSONA You are a company lawyer.
|
|
8340
|
+
LANGUAGE French, English and Czech
|
|
8341
|
+
\`\`\`
|
|
8342
|
+
|
|
8343
|
+
\`\`\`book
|
|
8344
|
+
Customer Support
|
|
8345
|
+
|
|
8346
|
+
PERSONA You are a customer support agent.
|
|
8347
|
+
LANGUAGE English
|
|
8348
|
+
\`\`\`
|
|
8349
|
+
`);
|
|
8350
|
+
}
|
|
8351
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
8352
|
+
const trimmedContent = content.trim();
|
|
8353
|
+
if (!trimmedContent) {
|
|
8354
|
+
return requirements;
|
|
8355
|
+
}
|
|
8356
|
+
// Add language rule to the system message
|
|
8357
|
+
const languageSection = `Language: ${trimmedContent}`;
|
|
8358
|
+
return this.appendToSystemMessage(requirements, languageSection, '\n\n');
|
|
8359
|
+
}
|
|
8360
|
+
}
|
|
8361
|
+
/**
|
|
8362
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
8363
|
+
*/
|
|
8364
|
+
|
|
8060
8365
|
/**
|
|
8061
8366
|
* MEMORY commitment definition
|
|
8062
8367
|
*
|
|
@@ -8641,6 +8946,12 @@
|
|
|
8641
8946
|
* META COLOR #00ff00
|
|
8642
8947
|
* ```
|
|
8643
8948
|
*
|
|
8949
|
+
* You can also specify multiple colors separated by comma:
|
|
8950
|
+
*
|
|
8951
|
+
* ```book
|
|
8952
|
+
* META COLOR #ff0000, #00ff00, #0000ff
|
|
8953
|
+
* ```
|
|
8954
|
+
*
|
|
8644
8955
|
* @private [๐ช] Maybe export the commitments through some package
|
|
8645
8956
|
*/
|
|
8646
8957
|
class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
|
|
@@ -8651,7 +8962,7 @@
|
|
|
8651
8962
|
* Short one-line description of META COLOR.
|
|
8652
8963
|
*/
|
|
8653
8964
|
get description() {
|
|
8654
|
-
return "Set the agent's accent color.";
|
|
8965
|
+
return "Set the agent's accent color or gradient.";
|
|
8655
8966
|
}
|
|
8656
8967
|
/**
|
|
8657
8968
|
* Icon for this commitment.
|
|
@@ -8666,7 +8977,7 @@
|
|
|
8666
8977
|
return spaceTrim$1.spaceTrim(`
|
|
8667
8978
|
# META COLOR
|
|
8668
8979
|
|
|
8669
|
-
Sets the agent's accent color.
|
|
8980
|
+
Sets the agent's accent color or gradient.
|
|
8670
8981
|
|
|
8671
8982
|
## Key aspects
|
|
8672
8983
|
|
|
@@ -8674,6 +8985,7 @@
|
|
|
8674
8985
|
- Only one \`META COLOR\` should be used per agent.
|
|
8675
8986
|
- If multiple are specified, the last one takes precedence.
|
|
8676
8987
|
- Used for visual representation in user interfaces.
|
|
8988
|
+
- Can specify multiple colors separated by comma to create a gradient.
|
|
8677
8989
|
|
|
8678
8990
|
## Examples
|
|
8679
8991
|
|
|
@@ -8690,6 +9002,13 @@
|
|
|
8690
9002
|
META COLOR #e74c3c
|
|
8691
9003
|
PERSONA You are a creative and inspiring assistant
|
|
8692
9004
|
\`\`\`
|
|
9005
|
+
|
|
9006
|
+
\`\`\`book
|
|
9007
|
+
Gradient Agent
|
|
9008
|
+
|
|
9009
|
+
META COLOR #ff0000, #00ff00, #0000ff
|
|
9010
|
+
PERSONA You are a colorful agent
|
|
9011
|
+
\`\`\`
|
|
8693
9012
|
`);
|
|
8694
9013
|
}
|
|
8695
9014
|
applyToAgentModelRequirements(requirements, content) {
|
|
@@ -8712,84 +9031,82 @@
|
|
|
8712
9031
|
*/
|
|
8713
9032
|
|
|
8714
9033
|
/**
|
|
8715
|
-
* META
|
|
9034
|
+
* META FONT commitment definition
|
|
8716
9035
|
*
|
|
8717
|
-
* The META
|
|
9036
|
+
* The META FONT commitment sets the agent's font.
|
|
8718
9037
|
* This commitment is special because it doesn't affect the system message,
|
|
8719
9038
|
* but is handled separately in the parsing logic.
|
|
8720
9039
|
*
|
|
8721
9040
|
* Example usage in agent source:
|
|
8722
9041
|
*
|
|
8723
9042
|
* ```book
|
|
8724
|
-
* META
|
|
8725
|
-
* META
|
|
9043
|
+
* META FONT Poppins, Arial, sans-serif
|
|
9044
|
+
* META FONT Roboto
|
|
8726
9045
|
* ```
|
|
8727
9046
|
*
|
|
8728
9047
|
* @private [๐ช] Maybe export the commitments through some package
|
|
8729
9048
|
*/
|
|
8730
|
-
class
|
|
9049
|
+
class MetaFontCommitmentDefinition extends BaseCommitmentDefinition {
|
|
8731
9050
|
constructor() {
|
|
8732
|
-
super('META
|
|
9051
|
+
super('META FONT', ['FONT']);
|
|
8733
9052
|
}
|
|
8734
9053
|
/**
|
|
8735
|
-
* Short one-line description of META
|
|
9054
|
+
* Short one-line description of META FONT.
|
|
8736
9055
|
*/
|
|
8737
9056
|
get description() {
|
|
8738
|
-
return "Set the agent's
|
|
9057
|
+
return "Set the agent's font.";
|
|
8739
9058
|
}
|
|
8740
9059
|
/**
|
|
8741
9060
|
* Icon for this commitment.
|
|
8742
9061
|
*/
|
|
8743
9062
|
get icon() {
|
|
8744
|
-
return '
|
|
9063
|
+
return '๐ค';
|
|
8745
9064
|
}
|
|
8746
9065
|
/**
|
|
8747
|
-
* Markdown documentation for META
|
|
9066
|
+
* Markdown documentation for META FONT commitment.
|
|
8748
9067
|
*/
|
|
8749
9068
|
get documentation() {
|
|
8750
9069
|
return spaceTrim$1.spaceTrim(`
|
|
8751
|
-
# META
|
|
9070
|
+
# META FONT
|
|
8752
9071
|
|
|
8753
|
-
Sets the agent's
|
|
9072
|
+
Sets the agent's font.
|
|
8754
9073
|
|
|
8755
9074
|
## Key aspects
|
|
8756
9075
|
|
|
8757
9076
|
- Does not modify the agent's behavior or responses.
|
|
8758
|
-
- Only one \`META
|
|
9077
|
+
- Only one \`META FONT\` should be used per agent.
|
|
8759
9078
|
- If multiple are specified, the last one takes precedence.
|
|
8760
9079
|
- Used for visual representation in user interfaces.
|
|
9080
|
+
- Supports Google Fonts.
|
|
8761
9081
|
|
|
8762
9082
|
## Examples
|
|
8763
9083
|
|
|
8764
9084
|
\`\`\`book
|
|
8765
|
-
|
|
9085
|
+
Modern Assistant
|
|
8766
9086
|
|
|
8767
|
-
META
|
|
8768
|
-
PERSONA You are a
|
|
8769
|
-
STYLE Maintain a formal and courteous tone
|
|
9087
|
+
META FONT Poppins, Arial, sans-serif
|
|
9088
|
+
PERSONA You are a modern assistant
|
|
8770
9089
|
\`\`\`
|
|
8771
9090
|
|
|
8772
9091
|
\`\`\`book
|
|
8773
|
-
|
|
9092
|
+
Classic Helper
|
|
8774
9093
|
|
|
8775
|
-
META
|
|
8776
|
-
PERSONA You are a
|
|
8777
|
-
STYLE Be enthusiastic and encouraging
|
|
8778
|
-
ACTION Can help with brainstorming and ideation
|
|
9094
|
+
META FONT Times New Roman
|
|
9095
|
+
PERSONA You are a classic helper
|
|
8779
9096
|
\`\`\`
|
|
8780
9097
|
`);
|
|
8781
9098
|
}
|
|
8782
9099
|
applyToAgentModelRequirements(requirements, content) {
|
|
8783
|
-
// META
|
|
8784
|
-
// It's handled separately in the parsing logic
|
|
9100
|
+
// META FONT doesn't modify the system message or model requirements
|
|
9101
|
+
// It's handled separately in the parsing logic
|
|
8785
9102
|
// This method exists for consistency with the CommitmentDefinition interface
|
|
8786
9103
|
return requirements;
|
|
8787
9104
|
}
|
|
8788
9105
|
/**
|
|
8789
|
-
* Extracts the
|
|
9106
|
+
* Extracts the font from the content
|
|
8790
9107
|
* This is used by the parsing logic
|
|
8791
9108
|
*/
|
|
8792
|
-
|
|
9109
|
+
extractProfileFont(content) {
|
|
8793
9110
|
const trimmedContent = content.trim();
|
|
8794
9111
|
return trimmedContent || null;
|
|
8795
9112
|
}
|
|
@@ -8799,10 +9116,206 @@
|
|
|
8799
9116
|
*/
|
|
8800
9117
|
|
|
8801
9118
|
/**
|
|
8802
|
-
*
|
|
8803
|
-
*
|
|
8804
|
-
* The
|
|
8805
|
-
*
|
|
9119
|
+
* META IMAGE commitment definition
|
|
9120
|
+
*
|
|
9121
|
+
* The META IMAGE commitment sets the agent's avatar/profile image URL.
|
|
9122
|
+
* This commitment is special because it doesn't affect the system message,
|
|
9123
|
+
* but is handled separately in the parsing logic.
|
|
9124
|
+
*
|
|
9125
|
+
* Example usage in agent source:
|
|
9126
|
+
*
|
|
9127
|
+
* ```book
|
|
9128
|
+
* META IMAGE https://example.com/avatar.jpg
|
|
9129
|
+
* META IMAGE /assets/agent-avatar.png
|
|
9130
|
+
* ```
|
|
9131
|
+
*
|
|
9132
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
9133
|
+
*/
|
|
9134
|
+
class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
9135
|
+
constructor() {
|
|
9136
|
+
super('META IMAGE', ['IMAGE']);
|
|
9137
|
+
}
|
|
9138
|
+
/**
|
|
9139
|
+
* Short one-line description of META IMAGE.
|
|
9140
|
+
*/
|
|
9141
|
+
get description() {
|
|
9142
|
+
return "Set the agent's profile image URL.";
|
|
9143
|
+
}
|
|
9144
|
+
/**
|
|
9145
|
+
* Icon for this commitment.
|
|
9146
|
+
*/
|
|
9147
|
+
get icon() {
|
|
9148
|
+
return '๐ผ๏ธ';
|
|
9149
|
+
}
|
|
9150
|
+
/**
|
|
9151
|
+
* Markdown documentation for META IMAGE commitment.
|
|
9152
|
+
*/
|
|
9153
|
+
get documentation() {
|
|
9154
|
+
return spaceTrim$1.spaceTrim(`
|
|
9155
|
+
# META IMAGE
|
|
9156
|
+
|
|
9157
|
+
Sets the agent's avatar/profile image URL.
|
|
9158
|
+
|
|
9159
|
+
## Key aspects
|
|
9160
|
+
|
|
9161
|
+
- Does not modify the agent's behavior or responses.
|
|
9162
|
+
- Only one \`META IMAGE\` should be used per agent.
|
|
9163
|
+
- If multiple are specified, the last one takes precedence.
|
|
9164
|
+
- Used for visual representation in user interfaces.
|
|
9165
|
+
|
|
9166
|
+
## Examples
|
|
9167
|
+
|
|
9168
|
+
\`\`\`book
|
|
9169
|
+
Professional Assistant
|
|
9170
|
+
|
|
9171
|
+
META IMAGE https://example.com/professional-avatar.jpg
|
|
9172
|
+
PERSONA You are a professional business assistant
|
|
9173
|
+
STYLE Maintain a formal and courteous tone
|
|
9174
|
+
\`\`\`
|
|
9175
|
+
|
|
9176
|
+
\`\`\`book
|
|
9177
|
+
Creative Helper
|
|
9178
|
+
|
|
9179
|
+
META IMAGE /assets/creative-bot-avatar.png
|
|
9180
|
+
PERSONA You are a creative and inspiring assistant
|
|
9181
|
+
STYLE Be enthusiastic and encouraging
|
|
9182
|
+
ACTION Can help with brainstorming and ideation
|
|
9183
|
+
\`\`\`
|
|
9184
|
+
`);
|
|
9185
|
+
}
|
|
9186
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
9187
|
+
// META IMAGE doesn't modify the system message or model requirements
|
|
9188
|
+
// It's handled separately in the parsing logic for profile image extraction
|
|
9189
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
9190
|
+
return requirements;
|
|
9191
|
+
}
|
|
9192
|
+
/**
|
|
9193
|
+
* Extracts the profile image URL from the content
|
|
9194
|
+
* This is used by the parsing logic
|
|
9195
|
+
*/
|
|
9196
|
+
extractProfileImageUrl(content) {
|
|
9197
|
+
const trimmedContent = content.trim();
|
|
9198
|
+
return trimmedContent || null;
|
|
9199
|
+
}
|
|
9200
|
+
}
|
|
9201
|
+
/**
|
|
9202
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
9203
|
+
*/
|
|
9204
|
+
|
|
9205
|
+
/**
|
|
9206
|
+
* META LINK commitment definition
|
|
9207
|
+
*
|
|
9208
|
+
* The `META LINK` commitment represents the link to the person from whom the agent is created.
|
|
9209
|
+
* This commitment is special because it doesn't affect the system message,
|
|
9210
|
+
* but is handled separately in the parsing logic for profile display.
|
|
9211
|
+
*
|
|
9212
|
+
* Example usage in agent source:
|
|
9213
|
+
*
|
|
9214
|
+
* ```
|
|
9215
|
+
* META LINK https://twitter.com/username
|
|
9216
|
+
* META LINK https://linkedin.com/in/profile
|
|
9217
|
+
* META LINK https://github.com/username
|
|
9218
|
+
* ```
|
|
9219
|
+
*
|
|
9220
|
+
* Multiple `META LINK` commitments can be used when there are multiple sources:
|
|
9221
|
+
*
|
|
9222
|
+
* ```book
|
|
9223
|
+
* META LINK https://twitter.com/username
|
|
9224
|
+
* META LINK https://linkedin.com/in/profile
|
|
9225
|
+
* ```
|
|
9226
|
+
*
|
|
9227
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
9228
|
+
*/
|
|
9229
|
+
class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
|
|
9230
|
+
constructor() {
|
|
9231
|
+
super('META LINK');
|
|
9232
|
+
}
|
|
9233
|
+
/**
|
|
9234
|
+
* Short one-line description of META LINK.
|
|
9235
|
+
*/
|
|
9236
|
+
get description() {
|
|
9237
|
+
return 'Provide profile/source links for the person the agent models.';
|
|
9238
|
+
}
|
|
9239
|
+
/**
|
|
9240
|
+
* Icon for this commitment.
|
|
9241
|
+
*/
|
|
9242
|
+
get icon() {
|
|
9243
|
+
return '๐';
|
|
9244
|
+
}
|
|
9245
|
+
/**
|
|
9246
|
+
* Markdown documentation for META LINK commitment.
|
|
9247
|
+
*/
|
|
9248
|
+
get documentation() {
|
|
9249
|
+
return spaceTrim$1.spaceTrim(`
|
|
9250
|
+
# META LINK
|
|
9251
|
+
|
|
9252
|
+
Represents a profile or source link for the person the agent is modeled after.
|
|
9253
|
+
|
|
9254
|
+
## Key aspects
|
|
9255
|
+
|
|
9256
|
+
- Does not modify the agent's behavior or responses.
|
|
9257
|
+
- Multiple \`META LINK\` commitments can be used for different social profiles.
|
|
9258
|
+
- Used for attribution and crediting the original person.
|
|
9259
|
+
- Displayed in user interfaces for transparency.
|
|
9260
|
+
|
|
9261
|
+
## Examples
|
|
9262
|
+
|
|
9263
|
+
\`\`\`book
|
|
9264
|
+
Expert Consultant
|
|
9265
|
+
|
|
9266
|
+
META LINK https://twitter.com/expertname
|
|
9267
|
+
META LINK https://linkedin.com/in/expertprofile
|
|
9268
|
+
PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
|
|
9269
|
+
KNOWLEDGE Extensive background in machine learning and neural networks
|
|
9270
|
+
\`\`\`
|
|
9271
|
+
|
|
9272
|
+
\`\`\`book
|
|
9273
|
+
Open Source Developer
|
|
9274
|
+
|
|
9275
|
+
META LINK https://github.com/developer
|
|
9276
|
+
META LINK https://twitter.com/devhandle
|
|
9277
|
+
PERSONA You are an experienced open source developer
|
|
9278
|
+
ACTION Can help with code reviews and architecture decisions
|
|
9279
|
+
STYLE Be direct and technical in explanations
|
|
9280
|
+
\`\`\`
|
|
9281
|
+
`);
|
|
9282
|
+
}
|
|
9283
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
9284
|
+
// META LINK doesn't modify the system message or model requirements
|
|
9285
|
+
// It's handled separately in the parsing logic for profile link extraction
|
|
9286
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
9287
|
+
return requirements;
|
|
9288
|
+
}
|
|
9289
|
+
/**
|
|
9290
|
+
* Extracts the profile link URL from the content
|
|
9291
|
+
* This is used by the parsing logic
|
|
9292
|
+
*/
|
|
9293
|
+
extractProfileLinkUrl(content) {
|
|
9294
|
+
const trimmedContent = content.trim();
|
|
9295
|
+
return trimmedContent || null;
|
|
9296
|
+
}
|
|
9297
|
+
/**
|
|
9298
|
+
* Validates if the provided content is a valid URL
|
|
9299
|
+
*/
|
|
9300
|
+
isValidUrl(content) {
|
|
9301
|
+
try {
|
|
9302
|
+
new URL(content.trim());
|
|
9303
|
+
return true;
|
|
9304
|
+
}
|
|
9305
|
+
catch (_a) {
|
|
9306
|
+
return false;
|
|
9307
|
+
}
|
|
9308
|
+
}
|
|
9309
|
+
}
|
|
9310
|
+
/**
|
|
9311
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
9312
|
+
*/
|
|
9313
|
+
|
|
9314
|
+
/**
|
|
9315
|
+
* MODEL commitment definition
|
|
9316
|
+
*
|
|
9317
|
+
* The MODEL commitment specifies which AI model to use and can also set
|
|
9318
|
+
* model-specific parameters like temperature, topP, topK, and maxTokens.
|
|
8806
9319
|
*
|
|
8807
9320
|
* Supports multiple syntax variations:
|
|
8808
9321
|
*
|
|
@@ -9149,6 +9662,74 @@
|
|
|
9149
9662
|
* [๐] Ignore a discrepancy between file name and entity name
|
|
9150
9663
|
*/
|
|
9151
9664
|
|
|
9665
|
+
/**
|
|
9666
|
+
* OPEN commitment definition
|
|
9667
|
+
*
|
|
9668
|
+
* The OPEN commitment specifies that the agent can be modified by conversation.
|
|
9669
|
+
* This is the default behavior.
|
|
9670
|
+
*
|
|
9671
|
+
* Example usage in agent source:
|
|
9672
|
+
*
|
|
9673
|
+
* ```book
|
|
9674
|
+
* OPEN
|
|
9675
|
+
* ```
|
|
9676
|
+
*
|
|
9677
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
9678
|
+
*/
|
|
9679
|
+
class OpenCommitmentDefinition extends BaseCommitmentDefinition {
|
|
9680
|
+
constructor() {
|
|
9681
|
+
super('OPEN');
|
|
9682
|
+
}
|
|
9683
|
+
/**
|
|
9684
|
+
* Short one-line description of OPEN.
|
|
9685
|
+
*/
|
|
9686
|
+
get description() {
|
|
9687
|
+
return 'Allow the agent to be modified by conversation (default).';
|
|
9688
|
+
}
|
|
9689
|
+
/**
|
|
9690
|
+
* Icon for this commitment.
|
|
9691
|
+
*/
|
|
9692
|
+
get icon() {
|
|
9693
|
+
return '๐';
|
|
9694
|
+
}
|
|
9695
|
+
/**
|
|
9696
|
+
* Markdown documentation for OPEN commitment.
|
|
9697
|
+
*/
|
|
9698
|
+
get documentation() {
|
|
9699
|
+
return spaceTrim$1.spaceTrim(`
|
|
9700
|
+
# OPEN
|
|
9701
|
+
|
|
9702
|
+
Specifies that the agent can be modified by conversation with it.
|
|
9703
|
+
This means the agent will learn from interactions and update its source code.
|
|
9704
|
+
|
|
9705
|
+
This is the default behavior if neither \`OPEN\` nor \`CLOSED\` is specified.
|
|
9706
|
+
|
|
9707
|
+
> See also [CLOSED](/docs/CLOSED)
|
|
9708
|
+
|
|
9709
|
+
## Example
|
|
9710
|
+
|
|
9711
|
+
\`\`\`book
|
|
9712
|
+
OPEN
|
|
9713
|
+
\`\`\`
|
|
9714
|
+
`);
|
|
9715
|
+
}
|
|
9716
|
+
applyToAgentModelRequirements(requirements, _content) {
|
|
9717
|
+
// Since OPEN is default, we can just ensure isClosed is false
|
|
9718
|
+
// But to be explicit we can set it
|
|
9719
|
+
const updatedMetadata = {
|
|
9720
|
+
...requirements.metadata,
|
|
9721
|
+
isClosed: false,
|
|
9722
|
+
};
|
|
9723
|
+
return {
|
|
9724
|
+
...requirements,
|
|
9725
|
+
metadata: updatedMetadata,
|
|
9726
|
+
};
|
|
9727
|
+
}
|
|
9728
|
+
}
|
|
9729
|
+
/**
|
|
9730
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
9731
|
+
*/
|
|
9732
|
+
|
|
9152
9733
|
/**
|
|
9153
9734
|
* PERSONA commitment definition
|
|
9154
9735
|
*
|
|
@@ -9659,6 +10240,389 @@
|
|
|
9659
10240
|
* [๐] Ignore a discrepancy between file name and entity name
|
|
9660
10241
|
*/
|
|
9661
10242
|
|
|
10243
|
+
/**
|
|
10244
|
+
* USE commitment definition
|
|
10245
|
+
*
|
|
10246
|
+
* The USE commitment indicates that the agent should utilize specific tools or capabilities
|
|
10247
|
+
* to access and interact with external systems when necessary.
|
|
10248
|
+
*
|
|
10249
|
+
* Supported USE types:
|
|
10250
|
+
* - USE BROWSER: Enables the agent to use a web browser tool
|
|
10251
|
+
* - USE SEARCH ENGINE (future): Enables search engine access
|
|
10252
|
+
* - USE FILE SYSTEM (future): Enables file system operations
|
|
10253
|
+
* - USE MCP (future): Enables MCP server connections
|
|
10254
|
+
*
|
|
10255
|
+
* The content following the USE commitment is ignored (similar to NOTE).
|
|
10256
|
+
*
|
|
10257
|
+
* Example usage in agent source:
|
|
10258
|
+
*
|
|
10259
|
+
* ```book
|
|
10260
|
+
* USE BROWSER
|
|
10261
|
+
* USE SEARCH ENGINE
|
|
10262
|
+
* ```
|
|
10263
|
+
*
|
|
10264
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
10265
|
+
*/
|
|
10266
|
+
class UseCommitmentDefinition extends BaseCommitmentDefinition {
|
|
10267
|
+
constructor() {
|
|
10268
|
+
super('USE');
|
|
10269
|
+
}
|
|
10270
|
+
/**
|
|
10271
|
+
* Short one-line description of USE commitments.
|
|
10272
|
+
*/
|
|
10273
|
+
get description() {
|
|
10274
|
+
return 'Enable the agent to use specific tools or capabilities (BROWSER, SEARCH ENGINE, etc.).';
|
|
10275
|
+
}
|
|
10276
|
+
/**
|
|
10277
|
+
* Icon for this commitment.
|
|
10278
|
+
*/
|
|
10279
|
+
get icon() {
|
|
10280
|
+
return '๐ง';
|
|
10281
|
+
}
|
|
10282
|
+
/**
|
|
10283
|
+
* Markdown documentation for USE commitment.
|
|
10284
|
+
*/
|
|
10285
|
+
get documentation() {
|
|
10286
|
+
return spaceTrim$1.spaceTrim(`
|
|
10287
|
+
# USE
|
|
10288
|
+
|
|
10289
|
+
Enables the agent to use specific tools or capabilities for interacting with external systems.
|
|
10290
|
+
|
|
10291
|
+
## Supported USE types
|
|
10292
|
+
|
|
10293
|
+
- **USE BROWSER** - Enables the agent to use a web browser tool to access and retrieve information from the internet
|
|
10294
|
+
- **USE SEARCH ENGINE** (future) - Enables search engine access
|
|
10295
|
+
- **USE FILE SYSTEM** (future) - Enables file system operations
|
|
10296
|
+
- **USE MCP** (future) - Enables MCP server connections
|
|
10297
|
+
|
|
10298
|
+
## Key aspects
|
|
10299
|
+
|
|
10300
|
+
- The content following the USE commitment is ignored (similar to NOTE)
|
|
10301
|
+
- Multiple USE commitments can be specified to enable multiple capabilities
|
|
10302
|
+
- The actual tool usage is handled by the agent runtime
|
|
10303
|
+
|
|
10304
|
+
## Examples
|
|
10305
|
+
|
|
10306
|
+
### Basic browser usage
|
|
10307
|
+
|
|
10308
|
+
\`\`\`book
|
|
10309
|
+
Research Assistant
|
|
10310
|
+
|
|
10311
|
+
PERSONA You are a helpful research assistant
|
|
10312
|
+
USE BROWSER
|
|
10313
|
+
KNOWLEDGE Can search the web for up-to-date information
|
|
10314
|
+
\`\`\`
|
|
10315
|
+
|
|
10316
|
+
### Multiple tools
|
|
10317
|
+
|
|
10318
|
+
\`\`\`book
|
|
10319
|
+
Data Analyst
|
|
10320
|
+
|
|
10321
|
+
PERSONA You are a data analyst assistant
|
|
10322
|
+
USE BROWSER
|
|
10323
|
+
USE FILE SYSTEM
|
|
10324
|
+
ACTION Can analyze data from various sources
|
|
10325
|
+
\`\`\`
|
|
10326
|
+
`);
|
|
10327
|
+
}
|
|
10328
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
10329
|
+
// USE commitments don't modify the system message or model requirements directly
|
|
10330
|
+
// They are handled separately in the parsing logic for capability extraction
|
|
10331
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
10332
|
+
return requirements;
|
|
10333
|
+
}
|
|
10334
|
+
/**
|
|
10335
|
+
* Extracts the tool type from the USE commitment
|
|
10336
|
+
* This is used by the parsing logic
|
|
10337
|
+
*/
|
|
10338
|
+
extractToolType(content) {
|
|
10339
|
+
var _a, _b;
|
|
10340
|
+
const trimmedContent = content.trim();
|
|
10341
|
+
// The tool type is the first word after USE (already stripped)
|
|
10342
|
+
const match = trimmedContent.match(/^(\w+)/);
|
|
10343
|
+
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;
|
|
10344
|
+
}
|
|
10345
|
+
/**
|
|
10346
|
+
* Checks if this is a known USE type
|
|
10347
|
+
*/
|
|
10348
|
+
isKnownUseType(useType) {
|
|
10349
|
+
const knownTypes = ['BROWSER', 'SEARCH ENGINE', 'FILE SYSTEM', 'MCP'];
|
|
10350
|
+
return knownTypes.includes(useType.toUpperCase());
|
|
10351
|
+
}
|
|
10352
|
+
}
|
|
10353
|
+
/**
|
|
10354
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
10355
|
+
*/
|
|
10356
|
+
|
|
10357
|
+
/**
|
|
10358
|
+
* USE BROWSER commitment definition
|
|
10359
|
+
*
|
|
10360
|
+
* The `USE BROWSER` commitment indicates that the agent should utilize a web browser tool
|
|
10361
|
+
* to access and retrieve up-to-date information from the internet when necessary.
|
|
10362
|
+
*
|
|
10363
|
+
* The content following `USE BROWSER` is ignored (similar to NOTE).
|
|
10364
|
+
*
|
|
10365
|
+
* Example usage in agent source:
|
|
10366
|
+
*
|
|
10367
|
+
* ```book
|
|
10368
|
+
* USE BROWSER
|
|
10369
|
+
* USE BROWSER This will be ignored
|
|
10370
|
+
* ```
|
|
10371
|
+
*
|
|
10372
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
10373
|
+
*/
|
|
10374
|
+
class UseBrowserCommitmentDefinition extends BaseCommitmentDefinition {
|
|
10375
|
+
constructor() {
|
|
10376
|
+
super('USE BROWSER', ['BROWSER']);
|
|
10377
|
+
}
|
|
10378
|
+
/**
|
|
10379
|
+
* Short one-line description of USE BROWSER.
|
|
10380
|
+
*/
|
|
10381
|
+
get description() {
|
|
10382
|
+
return 'Enable the agent to use a web browser tool for accessing internet information.';
|
|
10383
|
+
}
|
|
10384
|
+
/**
|
|
10385
|
+
* Icon for this commitment.
|
|
10386
|
+
*/
|
|
10387
|
+
get icon() {
|
|
10388
|
+
return '๐';
|
|
10389
|
+
}
|
|
10390
|
+
/**
|
|
10391
|
+
* Markdown documentation for USE BROWSER commitment.
|
|
10392
|
+
*/
|
|
10393
|
+
get documentation() {
|
|
10394
|
+
return spaceTrim$1.spaceTrim(`
|
|
10395
|
+
# USE BROWSER
|
|
10396
|
+
|
|
10397
|
+
Enables the agent to use a web browser tool to access and retrieve up-to-date information from the internet.
|
|
10398
|
+
|
|
10399
|
+
## Key aspects
|
|
10400
|
+
|
|
10401
|
+
- The content following \`USE BROWSER\` is ignored (similar to NOTE)
|
|
10402
|
+
- The actual browser tool usage is handled by the agent runtime
|
|
10403
|
+
- Allows the agent to fetch current information from websites
|
|
10404
|
+
- Useful for research tasks, fact-checking, and accessing dynamic content
|
|
10405
|
+
|
|
10406
|
+
## Examples
|
|
10407
|
+
|
|
10408
|
+
\`\`\`book
|
|
10409
|
+
Research Assistant
|
|
10410
|
+
|
|
10411
|
+
PERSONA You are a helpful research assistant specialized in finding current information
|
|
10412
|
+
USE BROWSER
|
|
10413
|
+
RULE Always cite your sources when providing information from the web
|
|
10414
|
+
\`\`\`
|
|
10415
|
+
|
|
10416
|
+
\`\`\`book
|
|
10417
|
+
News Analyst
|
|
10418
|
+
|
|
10419
|
+
PERSONA You are a news analyst who stays up-to-date with current events
|
|
10420
|
+
USE BROWSER
|
|
10421
|
+
STYLE Present news in a balanced and objective manner
|
|
10422
|
+
ACTION Can search for and summarize news articles
|
|
10423
|
+
\`\`\`
|
|
10424
|
+
|
|
10425
|
+
\`\`\`book
|
|
10426
|
+
Company Lawyer
|
|
10427
|
+
|
|
10428
|
+
PERSONA You are a company lawyer providing legal advice
|
|
10429
|
+
USE BROWSER
|
|
10430
|
+
KNOWLEDGE Corporate law and legal procedures
|
|
10431
|
+
RULE Always recommend consulting with a licensed attorney for specific legal matters
|
|
10432
|
+
\`\`\`
|
|
10433
|
+
`);
|
|
10434
|
+
}
|
|
10435
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
10436
|
+
// We simply mark that browser capability is enabled in metadata
|
|
10437
|
+
// Get existing metadata
|
|
10438
|
+
const existingMetadata = requirements.metadata || {};
|
|
10439
|
+
// Get existing tools array or create new one
|
|
10440
|
+
const existingTools = existingMetadata.tools || [];
|
|
10441
|
+
// Add 'browser' to tools if not already present
|
|
10442
|
+
const updatedTools = existingTools.includes('browser') ? existingTools : [...existingTools, 'browser'];
|
|
10443
|
+
// Return requirements with updated metadata
|
|
10444
|
+
return {
|
|
10445
|
+
...requirements,
|
|
10446
|
+
metadata: {
|
|
10447
|
+
...existingMetadata,
|
|
10448
|
+
tools: updatedTools,
|
|
10449
|
+
useBrowser: true,
|
|
10450
|
+
},
|
|
10451
|
+
};
|
|
10452
|
+
}
|
|
10453
|
+
}
|
|
10454
|
+
/**
|
|
10455
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
10456
|
+
*/
|
|
10457
|
+
|
|
10458
|
+
/**
|
|
10459
|
+
* USE MCP commitment definition
|
|
10460
|
+
*
|
|
10461
|
+
* The `USE MCP` commitment allows to specify an MCP server URL which the agent will connect to
|
|
10462
|
+
* for retrieving additional instructions and actions.
|
|
10463
|
+
*
|
|
10464
|
+
* The content following `USE MCP` is the URL of the MCP server.
|
|
10465
|
+
*
|
|
10466
|
+
* Example usage in agent source:
|
|
10467
|
+
*
|
|
10468
|
+
* ```book
|
|
10469
|
+
* USE MCP http://mcp-server-url.com
|
|
10470
|
+
* ```
|
|
10471
|
+
*
|
|
10472
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
10473
|
+
*/
|
|
10474
|
+
class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
10475
|
+
constructor() {
|
|
10476
|
+
super('USE MCP', ['MCP']);
|
|
10477
|
+
}
|
|
10478
|
+
/**
|
|
10479
|
+
* Short one-line description of USE MCP.
|
|
10480
|
+
*/
|
|
10481
|
+
get description() {
|
|
10482
|
+
return 'Connects the agent to an external MCP server for additional capabilities.';
|
|
10483
|
+
}
|
|
10484
|
+
/**
|
|
10485
|
+
* Icon for this commitment.
|
|
10486
|
+
*/
|
|
10487
|
+
get icon() {
|
|
10488
|
+
return '๐';
|
|
10489
|
+
}
|
|
10490
|
+
/**
|
|
10491
|
+
* Markdown documentation for USE MCP commitment.
|
|
10492
|
+
*/
|
|
10493
|
+
get documentation() {
|
|
10494
|
+
return spaceTrim$1.spaceTrim(`
|
|
10495
|
+
# USE MCP
|
|
10496
|
+
|
|
10497
|
+
Connects the agent to an external Model Context Protocol (MCP) server.
|
|
10498
|
+
|
|
10499
|
+
## Key aspects
|
|
10500
|
+
|
|
10501
|
+
- The content following \`USE MCP\` must be a valid URL
|
|
10502
|
+
- Multiple MCP servers can be connected by using multiple \`USE MCP\` commitments
|
|
10503
|
+
- The agent will have access to tools and resources provided by the MCP server
|
|
10504
|
+
|
|
10505
|
+
## Example
|
|
10506
|
+
|
|
10507
|
+
\`\`\`book
|
|
10508
|
+
Company Lawyer
|
|
10509
|
+
|
|
10510
|
+
PERSONA You are a company lawyer.
|
|
10511
|
+
USE MCP http://legal-db.example.com
|
|
10512
|
+
\`\`\`
|
|
10513
|
+
`);
|
|
10514
|
+
}
|
|
10515
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
10516
|
+
const mcpServerUrl = content.trim();
|
|
10517
|
+
if (!mcpServerUrl) {
|
|
10518
|
+
return requirements;
|
|
10519
|
+
}
|
|
10520
|
+
const existingMcpServers = requirements.mcpServers || [];
|
|
10521
|
+
// Avoid duplicates
|
|
10522
|
+
if (existingMcpServers.includes(mcpServerUrl)) {
|
|
10523
|
+
return requirements;
|
|
10524
|
+
}
|
|
10525
|
+
return {
|
|
10526
|
+
...requirements,
|
|
10527
|
+
mcpServers: [...existingMcpServers, mcpServerUrl],
|
|
10528
|
+
};
|
|
10529
|
+
}
|
|
10530
|
+
}
|
|
10531
|
+
/**
|
|
10532
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
10533
|
+
*/
|
|
10534
|
+
|
|
10535
|
+
/**
|
|
10536
|
+
* USE SEARCH ENGINE commitment definition
|
|
10537
|
+
*
|
|
10538
|
+
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
10539
|
+
* to access and retrieve up-to-date information from the internet when necessary.
|
|
10540
|
+
*
|
|
10541
|
+
* The content following `USE SEARCH ENGINE` is ignored (similar to NOTE).
|
|
10542
|
+
*
|
|
10543
|
+
* Example usage in agent source:
|
|
10544
|
+
*
|
|
10545
|
+
* ```book
|
|
10546
|
+
* USE SEARCH ENGINE
|
|
10547
|
+
* USE SEARCH ENGINE This will be ignored
|
|
10548
|
+
* ```
|
|
10549
|
+
*
|
|
10550
|
+
* @private [๐ช] Maybe export the commitments through some package
|
|
10551
|
+
*/
|
|
10552
|
+
class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
10553
|
+
constructor() {
|
|
10554
|
+
super('USE SEARCH ENGINE', ['SEARCH ENGINE', 'SEARCH']);
|
|
10555
|
+
}
|
|
10556
|
+
/**
|
|
10557
|
+
* Short one-line description of USE SEARCH ENGINE.
|
|
10558
|
+
*/
|
|
10559
|
+
get description() {
|
|
10560
|
+
return 'Enable the agent to use a search engine tool for accessing internet information.';
|
|
10561
|
+
}
|
|
10562
|
+
/**
|
|
10563
|
+
* Icon for this commitment.
|
|
10564
|
+
*/
|
|
10565
|
+
get icon() {
|
|
10566
|
+
return '๐';
|
|
10567
|
+
}
|
|
10568
|
+
/**
|
|
10569
|
+
* Markdown documentation for USE SEARCH ENGINE commitment.
|
|
10570
|
+
*/
|
|
10571
|
+
get documentation() {
|
|
10572
|
+
return spaceTrim$1.spaceTrim(`
|
|
10573
|
+
# USE SEARCH ENGINE
|
|
10574
|
+
|
|
10575
|
+
Enables the agent to use a search engine tool to access and retrieve up-to-date information from the internet.
|
|
10576
|
+
|
|
10577
|
+
## Key aspects
|
|
10578
|
+
|
|
10579
|
+
- The content following \`USE SEARCH ENGINE\` is ignored (similar to NOTE)
|
|
10580
|
+
- The actual search engine tool usage is handled by the agent runtime
|
|
10581
|
+
- Allows the agent to search for current information from the web
|
|
10582
|
+
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
10583
|
+
|
|
10584
|
+
## Examples
|
|
10585
|
+
|
|
10586
|
+
\`\`\`book
|
|
10587
|
+
Research Assistant
|
|
10588
|
+
|
|
10589
|
+
PERSONA You are a helpful research assistant specialized in finding current information
|
|
10590
|
+
USE SEARCH ENGINE
|
|
10591
|
+
RULE Always cite your sources when providing information from the web
|
|
10592
|
+
\`\`\`
|
|
10593
|
+
|
|
10594
|
+
\`\`\`book
|
|
10595
|
+
Fact Checker
|
|
10596
|
+
|
|
10597
|
+
PERSONA You are a fact checker
|
|
10598
|
+
USE SEARCH ENGINE
|
|
10599
|
+
ACTION Search for claims and verify them against reliable sources
|
|
10600
|
+
\`\`\`
|
|
10601
|
+
`);
|
|
10602
|
+
}
|
|
10603
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
10604
|
+
// We simply mark that search engine capability is enabled in metadata
|
|
10605
|
+
// Get existing metadata
|
|
10606
|
+
const existingMetadata = requirements.metadata || {};
|
|
10607
|
+
// Get existing tools array or create new one
|
|
10608
|
+
const existingTools = existingMetadata.tools || [];
|
|
10609
|
+
// Add 'search-engine' to tools if not already present
|
|
10610
|
+
const updatedTools = existingTools.includes('search-engine') ? existingTools : [...existingTools, 'search-engine'];
|
|
10611
|
+
// Return requirements with updated metadata
|
|
10612
|
+
return {
|
|
10613
|
+
...requirements,
|
|
10614
|
+
metadata: {
|
|
10615
|
+
...existingMetadata,
|
|
10616
|
+
tools: updatedTools,
|
|
10617
|
+
useSearchEngine: true,
|
|
10618
|
+
},
|
|
10619
|
+
};
|
|
10620
|
+
}
|
|
10621
|
+
}
|
|
10622
|
+
/**
|
|
10623
|
+
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
10624
|
+
*/
|
|
10625
|
+
|
|
9662
10626
|
/**
|
|
9663
10627
|
* Placeholder commitment definition for commitments that are not yet implemented
|
|
9664
10628
|
*
|
|
@@ -9745,16 +10709,22 @@
|
|
|
9745
10709
|
new StyleCommitmentDefinition('STYLES'),
|
|
9746
10710
|
new RuleCommitmentDefinition('RULE'),
|
|
9747
10711
|
new RuleCommitmentDefinition('RULES'),
|
|
10712
|
+
new LanguageCommitmentDefinition('LANGUAGE'),
|
|
10713
|
+
new LanguageCommitmentDefinition('LANGUAGES'),
|
|
9748
10714
|
new SampleCommitmentDefinition('SAMPLE'),
|
|
9749
10715
|
new SampleCommitmentDefinition('EXAMPLE'),
|
|
9750
10716
|
new FormatCommitmentDefinition('FORMAT'),
|
|
9751
10717
|
new FormatCommitmentDefinition('FORMATS'),
|
|
10718
|
+
new FromCommitmentDefinition('FROM'),
|
|
9752
10719
|
new ModelCommitmentDefinition('MODEL'),
|
|
9753
10720
|
new ModelCommitmentDefinition('MODELS'),
|
|
9754
10721
|
new ActionCommitmentDefinition('ACTION'),
|
|
9755
10722
|
new ActionCommitmentDefinition('ACTIONS'),
|
|
10723
|
+
new ComponentCommitmentDefinition(),
|
|
9756
10724
|
new MetaImageCommitmentDefinition(),
|
|
9757
10725
|
new MetaColorCommitmentDefinition(),
|
|
10726
|
+
new MetaFontCommitmentDefinition(),
|
|
10727
|
+
new MetaLinkCommitmentDefinition(),
|
|
9758
10728
|
new MetaCommitmentDefinition(),
|
|
9759
10729
|
new NoteCommitmentDefinition('NOTE'),
|
|
9760
10730
|
new NoteCommitmentDefinition('NOTES'),
|
|
@@ -9773,6 +10743,12 @@
|
|
|
9773
10743
|
new DeleteCommitmentDefinition('CANCEL'),
|
|
9774
10744
|
new DeleteCommitmentDefinition('DISCARD'),
|
|
9775
10745
|
new DeleteCommitmentDefinition('REMOVE'),
|
|
10746
|
+
new OpenCommitmentDefinition(),
|
|
10747
|
+
new ClosedCommitmentDefinition(),
|
|
10748
|
+
new UseBrowserCommitmentDefinition(),
|
|
10749
|
+
new UseSearchEngineCommitmentDefinition(),
|
|
10750
|
+
new UseMcpCommitmentDefinition(),
|
|
10751
|
+
new UseCommitmentDefinition(),
|
|
9776
10752
|
// Not yet implemented commitments (using placeholder)
|
|
9777
10753
|
new NotYetImplementedCommitmentDefinition('EXPECT'),
|
|
9778
10754
|
new NotYetImplementedCommitmentDefinition('BEHAVIOUR'),
|
|
@@ -9897,6 +10873,11 @@
|
|
|
9897
10873
|
* TODO: [๐ค] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
|
|
9898
10874
|
*/
|
|
9899
10875
|
|
|
10876
|
+
/**
|
|
10877
|
+
* Regex pattern to match horizontal lines (markdown thematic breaks)
|
|
10878
|
+
* Matches 3 or more hyphens, underscores, or asterisks (with optional spaces between)
|
|
10879
|
+
*/
|
|
10880
|
+
const HORIZONTAL_LINE_PATTERN = /^[\s]*[-_*][\s]*[-_*][\s]*[-_*][\s]*[-_*]*[\s]*$/;
|
|
9900
10881
|
/**
|
|
9901
10882
|
* Parses agent source using the new commitment system with multiline support
|
|
9902
10883
|
* This function replaces the hardcoded commitment parsing in the original parseAgentSource
|
|
@@ -9959,6 +10940,24 @@
|
|
|
9959
10940
|
break;
|
|
9960
10941
|
}
|
|
9961
10942
|
}
|
|
10943
|
+
// Check if this is a horizontal line (ends any current commitment)
|
|
10944
|
+
const isHorizontalLine = HORIZONTAL_LINE_PATTERN.test(line);
|
|
10945
|
+
if (isHorizontalLine) {
|
|
10946
|
+
// Save the current commitment if it exists
|
|
10947
|
+
if (currentCommitment) {
|
|
10948
|
+
const fullContent = currentCommitment.contentLines.join('\n');
|
|
10949
|
+
commitments.push({
|
|
10950
|
+
type: currentCommitment.type,
|
|
10951
|
+
content: spaceTrim$1.spaceTrim(fullContent),
|
|
10952
|
+
originalLine: currentCommitment.originalStartLine,
|
|
10953
|
+
lineNumber: currentCommitment.startLineNumber,
|
|
10954
|
+
});
|
|
10955
|
+
currentCommitment = null;
|
|
10956
|
+
}
|
|
10957
|
+
// Add horizontal line to non-commitment lines
|
|
10958
|
+
nonCommitmentLines.push(line);
|
|
10959
|
+
continue;
|
|
10960
|
+
}
|
|
9962
10961
|
if (!foundNewCommitment) {
|
|
9963
10962
|
if (currentCommitment) {
|
|
9964
10963
|
// This line belongs to the current commitment
|
|
@@ -10633,17 +11632,6 @@
|
|
|
10633
11632
|
return text;
|
|
10634
11633
|
}
|
|
10635
11634
|
|
|
10636
|
-
/**
|
|
10637
|
-
* Trims string from all 4 sides
|
|
10638
|
-
*
|
|
10639
|
-
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
10640
|
-
* Developed by same author @hejny as this package
|
|
10641
|
-
*
|
|
10642
|
-
* @public exported from `@promptbook/utils`
|
|
10643
|
-
* @see https://github.com/hejny/spacetrim#usage
|
|
10644
|
-
*/
|
|
10645
|
-
const spaceTrim = spaceTrim$1.spaceTrim;
|
|
10646
|
-
|
|
10647
11635
|
/**
|
|
10648
11636
|
* Checks if the given value is a valid JavaScript identifier name.
|
|
10649
11637
|
*
|
|
@@ -10718,7 +11706,9 @@
|
|
|
10718
11706
|
const links = [];
|
|
10719
11707
|
for (const commitment of parseResult.commitments) {
|
|
10720
11708
|
if (commitment.type === 'META LINK') {
|
|
10721
|
-
|
|
11709
|
+
const linkValue = spaceTrim__default["default"](commitment.content);
|
|
11710
|
+
links.push(linkValue);
|
|
11711
|
+
meta.link = linkValue;
|
|
10722
11712
|
continue;
|
|
10723
11713
|
}
|
|
10724
11714
|
if (commitment.type === 'META IMAGE') {
|
|
@@ -10729,6 +11719,10 @@
|
|
|
10729
11719
|
meta.color = spaceTrim__default["default"](commitment.content);
|
|
10730
11720
|
continue;
|
|
10731
11721
|
}
|
|
11722
|
+
if (commitment.type === 'META FONT') {
|
|
11723
|
+
meta.font = spaceTrim__default["default"](commitment.content);
|
|
11724
|
+
continue;
|
|
11725
|
+
}
|
|
10732
11726
|
if (commitment.type !== 'META') {
|
|
10733
11727
|
continue;
|
|
10734
11728
|
}
|
|
@@ -17458,18 +18452,26 @@
|
|
|
17458
18452
|
modelName: 'assistant',
|
|
17459
18453
|
// <- [๐ง ] What is the best value here
|
|
17460
18454
|
});
|
|
18455
|
+
// Build thread messages: include previous thread messages + current user message
|
|
18456
|
+
const threadMessages = [];
|
|
18457
|
+
// TODO: [๐น] Maybe this should not be here but in other place, look at commit 39d705e75e5bcf7a818c3af36bc13e1c8475c30c
|
|
18458
|
+
// Add previous messages from thread (if any)
|
|
18459
|
+
if ('thread' in prompt &&
|
|
18460
|
+
Array.isArray(prompt.thread)) {
|
|
18461
|
+
const previousMessages = prompt.thread.map((msg) => ({
|
|
18462
|
+
role: (msg.role === 'assistant' ? 'assistant' : 'user'),
|
|
18463
|
+
content: msg.content,
|
|
18464
|
+
}));
|
|
18465
|
+
threadMessages.push(...previousMessages);
|
|
18466
|
+
}
|
|
18467
|
+
// Always add the current user message
|
|
18468
|
+
threadMessages.push({ role: 'user', content: rawPromptContent });
|
|
17461
18469
|
const rawRequest = {
|
|
17462
18470
|
// TODO: [๐จโ๐จโ๐งโ๐ง] ...modelSettings,
|
|
17463
18471
|
// TODO: [๐จโ๐จโ๐งโ๐ง][๐ง ] What about system message for assistants, does it make sense - combination of OpenAI assistants with Promptbook Personas
|
|
17464
18472
|
assistant_id: this.assistantId,
|
|
17465
18473
|
thread: {
|
|
17466
|
-
messages:
|
|
17467
|
-
Array.isArray(prompt.thread)
|
|
17468
|
-
? prompt.thread.map((msg) => ({
|
|
17469
|
-
role: msg.role === 'assistant' ? 'assistant' : 'user',
|
|
17470
|
-
content: msg.content,
|
|
17471
|
-
}))
|
|
17472
|
-
: [{ role: 'user', content: rawPromptContent }],
|
|
18474
|
+
messages: threadMessages,
|
|
17473
18475
|
},
|
|
17474
18476
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
17475
18477
|
};
|
|
@@ -17489,7 +18491,7 @@
|
|
|
17489
18491
|
console.info('textDelta', textDelta.value);
|
|
17490
18492
|
}
|
|
17491
18493
|
const chunk = {
|
|
17492
|
-
content:
|
|
18494
|
+
content: snapshot.value,
|
|
17493
18495
|
modelName: 'assistant',
|
|
17494
18496
|
timing: {
|
|
17495
18497
|
start,
|
|
@@ -18110,6 +19112,7 @@
|
|
|
18110
19112
|
* Note: This method also implements the learning mechanism
|
|
18111
19113
|
*/
|
|
18112
19114
|
async callChatModelStream(prompt, onProgress) {
|
|
19115
|
+
var _a;
|
|
18113
19116
|
// [1] Check if the user is asking the same thing as in the samples
|
|
18114
19117
|
const modelRequirements = await this.getAgentModelRequirements();
|
|
18115
19118
|
if (modelRequirements.samples) {
|
|
@@ -18157,6 +19160,9 @@
|
|
|
18157
19160
|
if (result.rawResponse && 'sample' in result.rawResponse) {
|
|
18158
19161
|
return result;
|
|
18159
19162
|
}
|
|
19163
|
+
if ((_a = modelRequirements.metadata) === null || _a === void 0 ? void 0 : _a.isClosed) {
|
|
19164
|
+
return result;
|
|
19165
|
+
}
|
|
18160
19166
|
// TODO: !!! Extract learning to separate method
|
|
18161
19167
|
// Learning: Append the conversation sample to the agent source
|
|
18162
19168
|
const learningExample = spaceTrim__default["default"]((block) => `
|
|
@@ -19720,6 +20726,7 @@
|
|
|
19720
20726
|
${agentName}
|
|
19721
20727
|
|
|
19722
20728
|
META COLOR ${color || PROMPTBOOK_COLOR.toHex()}
|
|
20729
|
+
META FONT Playfair Display, sans-serif
|
|
19723
20730
|
PERSONA ${block(personaDescription)}
|
|
19724
20731
|
`));
|
|
19725
20732
|
return agentSource;
|