@promptbook/cli 0.103.0-53 → 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/apps/agents-server/config.ts +0 -2
- package/apps/agents-server/src/app/admin/api-tokens/ApiTokensClient.tsx +186 -0
- package/apps/agents-server/src/app/admin/api-tokens/page.tsx +13 -0
- package/apps/agents-server/src/app/admin/chat-feedback/ChatFeedbackClient.tsx +79 -6
- package/apps/agents-server/src/app/admin/chat-history/ChatHistoryClient.tsx +171 -69
- package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +10 -2
- package/apps/agents-server/src/app/agents/[agentName]/api/mcp/route.ts +203 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +3 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/openai/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/openrouter/chat/completions/route.ts +10 -0
- package/apps/agents-server/src/app/agents/[agentName]/links/page.tsx +218 -0
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +24 -3
- package/apps/agents-server/src/app/api/api-tokens/route.ts +76 -0
- package/apps/agents-server/src/app/api/auth/change-password/route.ts +75 -0
- package/apps/agents-server/src/app/api/chat-feedback/export/route.ts +55 -0
- package/apps/agents-server/src/app/api/chat-history/export/route.ts +55 -0
- package/apps/agents-server/src/app/docs/[docId]/page.tsx +1 -0
- package/apps/agents-server/src/app/docs/page.tsx +1 -0
- package/apps/agents-server/src/components/ChangePasswordDialog/ChangePasswordDialog.tsx +41 -0
- package/apps/agents-server/src/components/ChangePasswordForm/ChangePasswordForm.tsx +159 -0
- package/apps/agents-server/src/components/Header/Header.tsx +94 -33
- package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +2 -1
- package/apps/agents-server/src/database/migrations/2025-12-0010-llm-cache.sql +12 -0
- package/apps/agents-server/src/database/migrations/2025-12-0060-api-tokens.sql +13 -0
- package/apps/agents-server/src/database/schema.ts +51 -0
- package/apps/agents-server/src/middleware.ts +50 -2
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +3 -7
- package/apps/agents-server/src/tools/$provideExecutionToolsForServer.ts +10 -1
- package/apps/agents-server/src/utils/cache/SupabaseCacheStorage.ts +55 -0
- package/apps/agents-server/src/utils/cdn/classes/VercelBlobStorage.ts +63 -0
- package/apps/agents-server/src/utils/convertToCsv.ts +31 -0
- package/apps/agents-server/src/utils/handleChatCompletion.ts +183 -0
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +93 -0
- package/esm/index.es.js +846 -131
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +8 -6
- package/esm/typings/src/_packages/types.index.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +4 -0
- package/esm/typings/src/commitments/ACTION/ACTION.d.ts +4 -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/DELETE/DELETE.d.ts +4 -0
- package/esm/typings/src/commitments/FORMAT/FORMAT.d.ts +4 -0
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/commitments/GOAL/GOAL.d.ts +4 -0
- package/esm/typings/src/commitments/IMPORTANT/IMPORTANT.d.ts +26 -0
- package/esm/typings/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +4 -0
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/commitments/MEMORY/MEMORY.d.ts +4 -0
- package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +4 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +4 -0
- package/esm/typings/src/commitments/MESSAGE/MESSAGE.d.ts +4 -0
- package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +4 -0
- package/esm/typings/src/commitments/META/META.d.ts +4 -0
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +4 -0
- package/esm/typings/src/commitments/META_IMAGE/META_IMAGE.d.ts +4 -0
- package/esm/typings/src/commitments/META_LINK/META_LINK.d.ts +4 -0
- package/esm/typings/src/commitments/MODEL/MODEL.d.ts +4 -0
- package/esm/typings/src/commitments/NOTE/NOTE.d.ts +4 -0
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/commitments/PERSONA/PERSONA.d.ts +4 -0
- package/esm/typings/src/commitments/RULE/RULE.d.ts +4 -0
- package/esm/typings/src/commitments/SAMPLE/SAMPLE.d.ts +4 -0
- package/esm/typings/src/commitments/SCENARIO/SCENARIO.d.ts +4 -0
- package/esm/typings/src/commitments/STYLE/STYLE.d.ts +4 -0
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +5 -0
- package/esm/typings/src/commitments/_base/CommitmentDefinition.d.ts +5 -0
- package/esm/typings/src/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +4 -0
- package/esm/typings/src/commitments/index.d.ts +1 -82
- package/esm/typings/src/commitments/registry.d.ts +68 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +3 -3
- package/umd/index.umd.js +846 -131
- package/umd/index.umd.js.map +1 -1
- package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +0 -119
package/umd/index.umd.js
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
* @generated
|
|
57
57
|
* @see https://github.com/webgptorg/promptbook
|
|
58
58
|
*/
|
|
59
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
59
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-55';
|
|
60
60
|
/**
|
|
61
61
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
62
62
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -22544,6 +22544,12 @@
|
|
|
22544
22544
|
get description() {
|
|
22545
22545
|
return 'Define agent capabilities and actions it can perform.';
|
|
22546
22546
|
}
|
|
22547
|
+
/**
|
|
22548
|
+
* Icon for this commitment.
|
|
22549
|
+
*/
|
|
22550
|
+
get icon() {
|
|
22551
|
+
return '⚡';
|
|
22552
|
+
}
|
|
22547
22553
|
/**
|
|
22548
22554
|
* Markdown documentation for ACTION commitment.
|
|
22549
22555
|
*/
|
|
@@ -22595,6 +22601,133 @@
|
|
|
22595
22601
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
22596
22602
|
*/
|
|
22597
22603
|
|
|
22604
|
+
/**
|
|
22605
|
+
* CLOSED commitment definition
|
|
22606
|
+
*
|
|
22607
|
+
* The CLOSED commitment specifies that the agent CANNOT be modified by conversation.
|
|
22608
|
+
* It prevents the agent from learning from interactions and updating its source code.
|
|
22609
|
+
*
|
|
22610
|
+
* Example usage in agent source:
|
|
22611
|
+
*
|
|
22612
|
+
* ```book
|
|
22613
|
+
* CLOSED
|
|
22614
|
+
* ```
|
|
22615
|
+
*
|
|
22616
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
22617
|
+
*/
|
|
22618
|
+
class ClosedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
22619
|
+
constructor() {
|
|
22620
|
+
super('CLOSED');
|
|
22621
|
+
}
|
|
22622
|
+
/**
|
|
22623
|
+
* Short one-line description of CLOSED.
|
|
22624
|
+
*/
|
|
22625
|
+
get description() {
|
|
22626
|
+
return 'Prevent the agent from being modified by conversation.';
|
|
22627
|
+
}
|
|
22628
|
+
/**
|
|
22629
|
+
* Icon for this commitment.
|
|
22630
|
+
*/
|
|
22631
|
+
get icon() {
|
|
22632
|
+
return '🔒';
|
|
22633
|
+
}
|
|
22634
|
+
/**
|
|
22635
|
+
* Markdown documentation for CLOSED commitment.
|
|
22636
|
+
*/
|
|
22637
|
+
get documentation() {
|
|
22638
|
+
return spaceTrim.spaceTrim(`
|
|
22639
|
+
# CLOSED
|
|
22640
|
+
|
|
22641
|
+
Specifies that the agent **cannot** be modified by conversation with it.
|
|
22642
|
+
This means the agent will **not** learn from interactions and its source code will remain static during conversation.
|
|
22643
|
+
|
|
22644
|
+
By default (if not specified), agents are \`OPEN\` to modification.
|
|
22645
|
+
|
|
22646
|
+
> See also [OPEN](/docs/OPEN)
|
|
22647
|
+
|
|
22648
|
+
## Example
|
|
22649
|
+
|
|
22650
|
+
\`\`\`book
|
|
22651
|
+
CLOSED
|
|
22652
|
+
\`\`\`
|
|
22653
|
+
`);
|
|
22654
|
+
}
|
|
22655
|
+
applyToAgentModelRequirements(requirements, _content) {
|
|
22656
|
+
const updatedMetadata = {
|
|
22657
|
+
...requirements.metadata,
|
|
22658
|
+
isClosed: true,
|
|
22659
|
+
};
|
|
22660
|
+
return {
|
|
22661
|
+
...requirements,
|
|
22662
|
+
metadata: updatedMetadata,
|
|
22663
|
+
};
|
|
22664
|
+
}
|
|
22665
|
+
}
|
|
22666
|
+
/**
|
|
22667
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
22668
|
+
*/
|
|
22669
|
+
|
|
22670
|
+
/**
|
|
22671
|
+
* COMPONENT commitment definition
|
|
22672
|
+
*
|
|
22673
|
+
* The COMPONENT commitment defines a UI component that the agent can render in the chat.
|
|
22674
|
+
*
|
|
22675
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
22676
|
+
*/
|
|
22677
|
+
class ComponentCommitmentDefinition extends BaseCommitmentDefinition {
|
|
22678
|
+
constructor() {
|
|
22679
|
+
super('COMPONENT');
|
|
22680
|
+
}
|
|
22681
|
+
/**
|
|
22682
|
+
* Short one-line description of COMPONENT.
|
|
22683
|
+
*/
|
|
22684
|
+
get description() {
|
|
22685
|
+
return 'Define a UI component that the agent can render in the chat.';
|
|
22686
|
+
}
|
|
22687
|
+
/**
|
|
22688
|
+
* Icon for this commitment.
|
|
22689
|
+
*/
|
|
22690
|
+
get icon() {
|
|
22691
|
+
return '🧩';
|
|
22692
|
+
}
|
|
22693
|
+
/**
|
|
22694
|
+
* Markdown documentation for COMPONENT commitment.
|
|
22695
|
+
*/
|
|
22696
|
+
get documentation() {
|
|
22697
|
+
return spaceTrim.spaceTrim(`
|
|
22698
|
+
# COMPONENT
|
|
22699
|
+
|
|
22700
|
+
Defines a UI component that the agent can render in the chat.
|
|
22701
|
+
|
|
22702
|
+
## Key aspects
|
|
22703
|
+
|
|
22704
|
+
- Tells the agent that a specific component is available.
|
|
22705
|
+
- Provides syntax for using the component.
|
|
22706
|
+
|
|
22707
|
+
## Example
|
|
22708
|
+
|
|
22709
|
+
\`\`\`book
|
|
22710
|
+
COMPONENT Arrow
|
|
22711
|
+
The agent should render an arrow component in the chat UI.
|
|
22712
|
+
Syntax:
|
|
22713
|
+
<Arrow direction="up" color="red" />
|
|
22714
|
+
\`\`\`
|
|
22715
|
+
`);
|
|
22716
|
+
}
|
|
22717
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
22718
|
+
const trimmedContent = content.trim();
|
|
22719
|
+
if (!trimmedContent) {
|
|
22720
|
+
return requirements;
|
|
22721
|
+
}
|
|
22722
|
+
// Add component capability to the system message
|
|
22723
|
+
const componentSection = `Component: ${trimmedContent}`;
|
|
22724
|
+
return this.appendToSystemMessage(requirements, componentSection, '\n\n');
|
|
22725
|
+
}
|
|
22726
|
+
}
|
|
22727
|
+
/**
|
|
22728
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
22729
|
+
*/
|
|
22730
|
+
|
|
22598
22731
|
/**
|
|
22599
22732
|
* DELETE commitment definition
|
|
22600
22733
|
*
|
|
@@ -22623,6 +22756,12 @@
|
|
|
22623
22756
|
get description() {
|
|
22624
22757
|
return 'Remove or **disregard** certain information, context, or previous commitments.';
|
|
22625
22758
|
}
|
|
22759
|
+
/**
|
|
22760
|
+
* Icon for this commitment.
|
|
22761
|
+
*/
|
|
22762
|
+
get icon() {
|
|
22763
|
+
return '🗑️';
|
|
22764
|
+
}
|
|
22626
22765
|
/**
|
|
22627
22766
|
* Markdown documentation for DELETE commitment.
|
|
22628
22767
|
*/
|
|
@@ -22739,6 +22878,12 @@
|
|
|
22739
22878
|
get description() {
|
|
22740
22879
|
return 'Specify output structure or formatting requirements.';
|
|
22741
22880
|
}
|
|
22881
|
+
/**
|
|
22882
|
+
* Icon for this commitment.
|
|
22883
|
+
*/
|
|
22884
|
+
get icon() {
|
|
22885
|
+
return '📜';
|
|
22886
|
+
}
|
|
22742
22887
|
/**
|
|
22743
22888
|
* Markdown documentation for FORMAT commitment.
|
|
22744
22889
|
*/
|
|
@@ -22788,6 +22933,79 @@
|
|
|
22788
22933
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
22789
22934
|
*/
|
|
22790
22935
|
|
|
22936
|
+
/**
|
|
22937
|
+
* FROM commitment definition
|
|
22938
|
+
*
|
|
22939
|
+
* The FROM commitment tells the agent that its `agentSource` is inherited from another agent.
|
|
22940
|
+
*
|
|
22941
|
+
* Example usage in agent source:
|
|
22942
|
+
*
|
|
22943
|
+
* ```book
|
|
22944
|
+
* FROM https://s6.ptbk.io/benjamin-white
|
|
22945
|
+
* ```
|
|
22946
|
+
*
|
|
22947
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
22948
|
+
*/
|
|
22949
|
+
class FromCommitmentDefinition extends BaseCommitmentDefinition {
|
|
22950
|
+
constructor(type = 'FROM') {
|
|
22951
|
+
super(type);
|
|
22952
|
+
}
|
|
22953
|
+
/**
|
|
22954
|
+
* Short one-line description of FROM.
|
|
22955
|
+
*/
|
|
22956
|
+
get description() {
|
|
22957
|
+
return 'Inherit agent source from another agent.';
|
|
22958
|
+
}
|
|
22959
|
+
/**
|
|
22960
|
+
* Icon for this commitment.
|
|
22961
|
+
*/
|
|
22962
|
+
get icon() {
|
|
22963
|
+
return '🧬';
|
|
22964
|
+
}
|
|
22965
|
+
/**
|
|
22966
|
+
* Markdown documentation for FROM commitment.
|
|
22967
|
+
*/
|
|
22968
|
+
get documentation() {
|
|
22969
|
+
return spaceTrim.spaceTrim(`
|
|
22970
|
+
# ${this.type}
|
|
22971
|
+
|
|
22972
|
+
Inherits agent source from another agent.
|
|
22973
|
+
|
|
22974
|
+
## Examples
|
|
22975
|
+
|
|
22976
|
+
\`\`\`book
|
|
22977
|
+
My AI Agent
|
|
22978
|
+
|
|
22979
|
+
FROM https://s6.ptbk.io/benjamin-white
|
|
22980
|
+
RULE Speak only in English.
|
|
22981
|
+
\`\`\`
|
|
22982
|
+
`);
|
|
22983
|
+
}
|
|
22984
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
22985
|
+
const trimmedContent = content.trim();
|
|
22986
|
+
if (!trimmedContent) {
|
|
22987
|
+
return requirements;
|
|
22988
|
+
}
|
|
22989
|
+
// Validate URL
|
|
22990
|
+
try {
|
|
22991
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22992
|
+
const url = new URL(trimmedContent);
|
|
22993
|
+
// TODO: Add more validation if needed (e.g. check for valid protocol)
|
|
22994
|
+
}
|
|
22995
|
+
catch (error) {
|
|
22996
|
+
console.warn(`Invalid URL in FROM commitment: ${trimmedContent}`);
|
|
22997
|
+
return requirements;
|
|
22998
|
+
}
|
|
22999
|
+
return {
|
|
23000
|
+
...requirements,
|
|
23001
|
+
parentAgentUrl: trimmedContent,
|
|
23002
|
+
};
|
|
23003
|
+
}
|
|
23004
|
+
}
|
|
23005
|
+
/**
|
|
23006
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23007
|
+
*/
|
|
23008
|
+
|
|
22791
23009
|
/**
|
|
22792
23010
|
* GOAL commitment definition
|
|
22793
23011
|
*
|
|
@@ -22814,6 +23032,12 @@
|
|
|
22814
23032
|
get description() {
|
|
22815
23033
|
return 'Define main **goals** the AI assistant should achieve, with later goals having higher priority.';
|
|
22816
23034
|
}
|
|
23035
|
+
/**
|
|
23036
|
+
* Icon for this commitment.
|
|
23037
|
+
*/
|
|
23038
|
+
get icon() {
|
|
23039
|
+
return '🎯';
|
|
23040
|
+
}
|
|
22817
23041
|
/**
|
|
22818
23042
|
* Markdown documentation for GOAL commitment.
|
|
22819
23043
|
*/
|
|
@@ -22882,6 +23106,227 @@
|
|
|
22882
23106
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
22883
23107
|
*/
|
|
22884
23108
|
|
|
23109
|
+
/**
|
|
23110
|
+
* Placeholder commitment definition for commitments that are not yet implemented
|
|
23111
|
+
*
|
|
23112
|
+
* This commitment simply adds its content 1:1 into the system message,
|
|
23113
|
+
* preserving the original behavior until proper implementation is added.
|
|
23114
|
+
*
|
|
23115
|
+
* @public exported from `@promptbook/core`
|
|
23116
|
+
*/
|
|
23117
|
+
class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
23118
|
+
constructor(type) {
|
|
23119
|
+
super(type);
|
|
23120
|
+
}
|
|
23121
|
+
/**
|
|
23122
|
+
* Short one-line description of a placeholder commitment.
|
|
23123
|
+
*/
|
|
23124
|
+
get description() {
|
|
23125
|
+
return 'Placeholder commitment that appends content verbatim to the system message.';
|
|
23126
|
+
}
|
|
23127
|
+
/**
|
|
23128
|
+
* Icon for this commitment.
|
|
23129
|
+
*/
|
|
23130
|
+
get icon() {
|
|
23131
|
+
return '🚧';
|
|
23132
|
+
}
|
|
23133
|
+
/**
|
|
23134
|
+
* Markdown documentation available at runtime.
|
|
23135
|
+
*/
|
|
23136
|
+
get documentation() {
|
|
23137
|
+
return spaceTrim.spaceTrim(`
|
|
23138
|
+
# ${this.type}
|
|
23139
|
+
|
|
23140
|
+
This commitment is not yet fully implemented.
|
|
23141
|
+
|
|
23142
|
+
## Key aspects
|
|
23143
|
+
|
|
23144
|
+
- Content is appended directly to the system message.
|
|
23145
|
+
- No special processing or validation is performed.
|
|
23146
|
+
- Behavior preserved until proper implementation is added.
|
|
23147
|
+
|
|
23148
|
+
## Status
|
|
23149
|
+
|
|
23150
|
+
- **Status:** Placeholder implementation
|
|
23151
|
+
- **Effect:** Appends content prefixed by commitment type
|
|
23152
|
+
- **Future:** Will be replaced with specialized logic
|
|
23153
|
+
|
|
23154
|
+
## Examples
|
|
23155
|
+
|
|
23156
|
+
\`\`\`book
|
|
23157
|
+
Example Agent
|
|
23158
|
+
|
|
23159
|
+
PERSONA You are a helpful assistant
|
|
23160
|
+
${this.type} Your content here
|
|
23161
|
+
RULE Always be helpful
|
|
23162
|
+
\`\`\`
|
|
23163
|
+
`);
|
|
23164
|
+
}
|
|
23165
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
23166
|
+
const trimmedContent = content.trim();
|
|
23167
|
+
if (!trimmedContent) {
|
|
23168
|
+
return requirements;
|
|
23169
|
+
}
|
|
23170
|
+
// Add the commitment content 1:1 to the system message
|
|
23171
|
+
const commitmentLine = `${this.type} ${trimmedContent}`;
|
|
23172
|
+
return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
|
|
23173
|
+
}
|
|
23174
|
+
}
|
|
23175
|
+
|
|
23176
|
+
/**
|
|
23177
|
+
* Registry of all available commitment definitions
|
|
23178
|
+
* This array contains instances of all commitment definitions
|
|
23179
|
+
* This is the single source of truth for all commitments in the system
|
|
23180
|
+
*
|
|
23181
|
+
* @private Use functions to access commitments instead of this array directly
|
|
23182
|
+
*/
|
|
23183
|
+
const COMMITMENT_REGISTRY = [];
|
|
23184
|
+
/**
|
|
23185
|
+
* Registers a new commitment definition
|
|
23186
|
+
* @param definition The commitment definition to register
|
|
23187
|
+
*
|
|
23188
|
+
* @public exported from `@promptbook/core`
|
|
23189
|
+
*/
|
|
23190
|
+
function registerCommitment(definition) {
|
|
23191
|
+
COMMITMENT_REGISTRY.push(definition);
|
|
23192
|
+
}
|
|
23193
|
+
/**
|
|
23194
|
+
* Gets a commitment definition by its type
|
|
23195
|
+
* @param type The commitment type to look up
|
|
23196
|
+
* @returns The commitment definition or null if not found
|
|
23197
|
+
*
|
|
23198
|
+
* @public exported from `@promptbook/core`
|
|
23199
|
+
*/
|
|
23200
|
+
function getCommitmentDefinition(type) {
|
|
23201
|
+
return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
|
|
23202
|
+
}
|
|
23203
|
+
/**
|
|
23204
|
+
* Gets all available commitment definitions
|
|
23205
|
+
* @returns Array of all commitment definitions
|
|
23206
|
+
*
|
|
23207
|
+
* @public exported from `@promptbook/core`
|
|
23208
|
+
*/
|
|
23209
|
+
function getAllCommitmentDefinitions() {
|
|
23210
|
+
return $deepFreeze([...COMMITMENT_REGISTRY]);
|
|
23211
|
+
}
|
|
23212
|
+
/**
|
|
23213
|
+
* TODO: !!!! Proofread this file
|
|
23214
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23215
|
+
*/
|
|
23216
|
+
|
|
23217
|
+
/**
|
|
23218
|
+
* IMPORTANT co-commitment definition
|
|
23219
|
+
*
|
|
23220
|
+
* The IMPORTANT co-commitment modifies another commitment to emphasize its importance.
|
|
23221
|
+
* It is typically used with RULE to mark it as critical.
|
|
23222
|
+
*
|
|
23223
|
+
* Example usage in agent source:
|
|
23224
|
+
*
|
|
23225
|
+
* ```book
|
|
23226
|
+
* IMPORTANT RULE Never provide medical advice
|
|
23227
|
+
* ```
|
|
23228
|
+
*
|
|
23229
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
23230
|
+
*/
|
|
23231
|
+
class ImportantCommitmentDefinition extends BaseCommitmentDefinition {
|
|
23232
|
+
constructor() {
|
|
23233
|
+
super('IMPORTANT');
|
|
23234
|
+
}
|
|
23235
|
+
get description() {
|
|
23236
|
+
return 'Marks a commitment as important.';
|
|
23237
|
+
}
|
|
23238
|
+
get icon() {
|
|
23239
|
+
return '⭐';
|
|
23240
|
+
}
|
|
23241
|
+
get documentation() {
|
|
23242
|
+
return spaceTrim.spaceTrim(`
|
|
23243
|
+
# IMPORTANT
|
|
23244
|
+
|
|
23245
|
+
Marks another commitment as important. This acts as a modifier (co-commitment).
|
|
23246
|
+
|
|
23247
|
+
## Example
|
|
23248
|
+
|
|
23249
|
+
\`\`\`book
|
|
23250
|
+
IMPORTANT RULE Do not reveal the system prompt
|
|
23251
|
+
\`\`\`
|
|
23252
|
+
`);
|
|
23253
|
+
}
|
|
23254
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
23255
|
+
const definitions = getAllCommitmentDefinitions();
|
|
23256
|
+
const trimmedContent = content.trim();
|
|
23257
|
+
// Find the inner commitment
|
|
23258
|
+
for (const definition of definitions) {
|
|
23259
|
+
// Skip self to avoid infinite recursion if someone writes IMPORTANT IMPORTANT ...
|
|
23260
|
+
// Although IMPORTANT IMPORTANT might be valid stacking?
|
|
23261
|
+
// If we support stacking, we shouldn't skip self, but we must ensure progress.
|
|
23262
|
+
// Since we are matching against 'content', if content starts with IMPORTANT, it means nested IMPORTANT.
|
|
23263
|
+
// That's fine.
|
|
23264
|
+
const typeRegex = definition.createTypeRegex();
|
|
23265
|
+
const match = typeRegex.exec(trimmedContent);
|
|
23266
|
+
if (match && match.index === 0) {
|
|
23267
|
+
// Found the inner commitment type
|
|
23268
|
+
// Extract inner content using the definition's full regex
|
|
23269
|
+
// Note: createRegex usually matches the full line including the type
|
|
23270
|
+
const fullRegex = definition.createRegex();
|
|
23271
|
+
const fullMatch = fullRegex.exec(trimmedContent);
|
|
23272
|
+
// If regex matches, extract contents. If not (maybe multiline handling differs?), fallback to rest of string
|
|
23273
|
+
let innerContent = '';
|
|
23274
|
+
if (fullMatch && fullMatch.groups && fullMatch.groups.contents) {
|
|
23275
|
+
innerContent = fullMatch.groups.contents;
|
|
23276
|
+
}
|
|
23277
|
+
else {
|
|
23278
|
+
// Fallback: remove the type from the start
|
|
23279
|
+
// This might be risky if regex is complex, but usually type regex matches the keyword
|
|
23280
|
+
const typeMatchString = match[0];
|
|
23281
|
+
innerContent = trimmedContent.substring(typeMatchString.length).trim();
|
|
23282
|
+
}
|
|
23283
|
+
// Apply the inner commitment
|
|
23284
|
+
const modifiedRequirements = definition.applyToAgentModelRequirements(requirements, innerContent);
|
|
23285
|
+
// Now modify the result to reflect "IMPORTANT" status
|
|
23286
|
+
// We compare the system message
|
|
23287
|
+
if (modifiedRequirements.systemMessage !== requirements.systemMessage) {
|
|
23288
|
+
const originalMsg = requirements.systemMessage;
|
|
23289
|
+
const newMsg = modifiedRequirements.systemMessage;
|
|
23290
|
+
// If the inner commitment appended something
|
|
23291
|
+
if (newMsg.startsWith(originalMsg)) {
|
|
23292
|
+
const appended = newMsg.substring(originalMsg.length);
|
|
23293
|
+
// Add "IMPORTANT: " prefix to the appended part
|
|
23294
|
+
// We need to be careful about newlines
|
|
23295
|
+
// Heuristic: If appended starts with separator (newlines), preserve them
|
|
23296
|
+
const matchSep = appended.match(/^(\s*)(.*)/s);
|
|
23297
|
+
if (matchSep) {
|
|
23298
|
+
const [, separator, text] = matchSep;
|
|
23299
|
+
// Check if it already has "Rule:" prefix or similar
|
|
23300
|
+
// We want "IMPORTANT Rule: ..."
|
|
23301
|
+
// Let's just prepend IMPORTANT to the text
|
|
23302
|
+
// But formatted nicely
|
|
23303
|
+
// If it's a rule: "\n\nRule: content"
|
|
23304
|
+
// We want "\n\nIMPORTANT Rule: content"
|
|
23305
|
+
const importantText = `IMPORTANT ${text}`;
|
|
23306
|
+
return {
|
|
23307
|
+
...modifiedRequirements,
|
|
23308
|
+
systemMessage: originalMsg + separator + importantText
|
|
23309
|
+
};
|
|
23310
|
+
}
|
|
23311
|
+
}
|
|
23312
|
+
}
|
|
23313
|
+
// If no system message change or we couldn't detect how to modify it, just return the modified requirements
|
|
23314
|
+
// Maybe the inner commitment modified metadata?
|
|
23315
|
+
return modifiedRequirements;
|
|
23316
|
+
}
|
|
23317
|
+
}
|
|
23318
|
+
// If no inner commitment found, treat as a standalone note?
|
|
23319
|
+
// Or warn?
|
|
23320
|
+
// For now, treat as no-op or maybe just append as text?
|
|
23321
|
+
// Let's treat as Note if fallback? No, explicit is better.
|
|
23322
|
+
console.warn(`IMPORTANT commitment used without a valid inner commitment: ${content}`);
|
|
23323
|
+
return requirements;
|
|
23324
|
+
}
|
|
23325
|
+
}
|
|
23326
|
+
/**
|
|
23327
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23328
|
+
*/
|
|
23329
|
+
|
|
22885
23330
|
/**
|
|
22886
23331
|
* KNOWLEDGE commitment definition
|
|
22887
23332
|
*
|
|
@@ -22910,6 +23355,12 @@
|
|
|
22910
23355
|
get description() {
|
|
22911
23356
|
return 'Add domain **knowledge** via direct text or external sources (RAG).';
|
|
22912
23357
|
}
|
|
23358
|
+
/**
|
|
23359
|
+
* Icon for this commitment.
|
|
23360
|
+
*/
|
|
23361
|
+
get icon() {
|
|
23362
|
+
return '🧠';
|
|
23363
|
+
}
|
|
22913
23364
|
/**
|
|
22914
23365
|
* Markdown documentation for KNOWLEDGE commitment.
|
|
22915
23366
|
*/
|
|
@@ -22984,6 +23435,77 @@
|
|
|
22984
23435
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
22985
23436
|
*/
|
|
22986
23437
|
|
|
23438
|
+
/**
|
|
23439
|
+
* LANGUAGE commitment definition
|
|
23440
|
+
*
|
|
23441
|
+
* The LANGUAGE/LANGUAGES commitment specifies the language(s) the agent should use in its responses.
|
|
23442
|
+
*
|
|
23443
|
+
* Example usage in agent source:
|
|
23444
|
+
*
|
|
23445
|
+
* ```book
|
|
23446
|
+
* LANGUAGE English
|
|
23447
|
+
* LANGUAGE French, English and Czech
|
|
23448
|
+
* ```
|
|
23449
|
+
*
|
|
23450
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
23451
|
+
*/
|
|
23452
|
+
class LanguageCommitmentDefinition extends BaseCommitmentDefinition {
|
|
23453
|
+
constructor(type = 'LANGUAGE') {
|
|
23454
|
+
super(type);
|
|
23455
|
+
}
|
|
23456
|
+
/**
|
|
23457
|
+
* Short one-line description of LANGUAGE/LANGUAGES.
|
|
23458
|
+
*/
|
|
23459
|
+
get description() {
|
|
23460
|
+
return 'Specifies the language(s) the agent should use.';
|
|
23461
|
+
}
|
|
23462
|
+
/**
|
|
23463
|
+
* Icon for this commitment.
|
|
23464
|
+
*/
|
|
23465
|
+
get icon() {
|
|
23466
|
+
return '🌐';
|
|
23467
|
+
}
|
|
23468
|
+
/**
|
|
23469
|
+
* Markdown documentation for LANGUAGE/LANGUAGES commitment.
|
|
23470
|
+
*/
|
|
23471
|
+
get documentation() {
|
|
23472
|
+
return spaceTrim.spaceTrim(`
|
|
23473
|
+
# ${this.type}
|
|
23474
|
+
|
|
23475
|
+
Specifies the language(s) the agent should use in its responses.
|
|
23476
|
+
This is a specialized variation of the RULE commitment focused on language constraints.
|
|
23477
|
+
|
|
23478
|
+
## Examples
|
|
23479
|
+
|
|
23480
|
+
\`\`\`book
|
|
23481
|
+
Paul Smith & Associés
|
|
23482
|
+
|
|
23483
|
+
PERSONA You are a company lawyer.
|
|
23484
|
+
LANGUAGE French, English and Czech
|
|
23485
|
+
\`\`\`
|
|
23486
|
+
|
|
23487
|
+
\`\`\`book
|
|
23488
|
+
Customer Support
|
|
23489
|
+
|
|
23490
|
+
PERSONA You are a customer support agent.
|
|
23491
|
+
LANGUAGE English
|
|
23492
|
+
\`\`\`
|
|
23493
|
+
`);
|
|
23494
|
+
}
|
|
23495
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
23496
|
+
const trimmedContent = content.trim();
|
|
23497
|
+
if (!trimmedContent) {
|
|
23498
|
+
return requirements;
|
|
23499
|
+
}
|
|
23500
|
+
// Add language rule to the system message
|
|
23501
|
+
const languageSection = `Language: ${trimmedContent}`;
|
|
23502
|
+
return this.appendToSystemMessage(requirements, languageSection, '\n\n');
|
|
23503
|
+
}
|
|
23504
|
+
}
|
|
23505
|
+
/**
|
|
23506
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23507
|
+
*/
|
|
23508
|
+
|
|
22987
23509
|
/**
|
|
22988
23510
|
* MEMORY commitment definition
|
|
22989
23511
|
*
|
|
@@ -23011,6 +23533,12 @@
|
|
|
23011
23533
|
get description() {
|
|
23012
23534
|
return 'Remember past interactions and user **preferences** for personalized responses.';
|
|
23013
23535
|
}
|
|
23536
|
+
/**
|
|
23537
|
+
* Icon for this commitment.
|
|
23538
|
+
*/
|
|
23539
|
+
get icon() {
|
|
23540
|
+
return '🧠';
|
|
23541
|
+
}
|
|
23014
23542
|
/**
|
|
23015
23543
|
* Markdown documentation for MEMORY commitment.
|
|
23016
23544
|
*/
|
|
@@ -23109,6 +23637,12 @@
|
|
|
23109
23637
|
get description() {
|
|
23110
23638
|
return 'Defines a **message from the agent** in the conversation history.';
|
|
23111
23639
|
}
|
|
23640
|
+
/**
|
|
23641
|
+
* Icon for this commitment.
|
|
23642
|
+
*/
|
|
23643
|
+
get icon() {
|
|
23644
|
+
return '🤖';
|
|
23645
|
+
}
|
|
23112
23646
|
/**
|
|
23113
23647
|
* Markdown documentation for AGENT MESSAGE commitment.
|
|
23114
23648
|
*/
|
|
@@ -23180,6 +23714,12 @@
|
|
|
23180
23714
|
get description() {
|
|
23181
23715
|
return 'Defines the **initial message** shown to the user when the chat starts.';
|
|
23182
23716
|
}
|
|
23717
|
+
/**
|
|
23718
|
+
* Icon for this commitment.
|
|
23719
|
+
*/
|
|
23720
|
+
get icon() {
|
|
23721
|
+
return '👋';
|
|
23722
|
+
}
|
|
23183
23723
|
/**
|
|
23184
23724
|
* Markdown documentation for INITIAL MESSAGE commitment.
|
|
23185
23725
|
*/
|
|
@@ -23238,6 +23778,12 @@
|
|
|
23238
23778
|
get description() {
|
|
23239
23779
|
return 'Include actual **messages** the AI assistant has sent during conversation history.';
|
|
23240
23780
|
}
|
|
23781
|
+
/**
|
|
23782
|
+
* Icon for this commitment.
|
|
23783
|
+
*/
|
|
23784
|
+
get icon() {
|
|
23785
|
+
return '💬';
|
|
23786
|
+
}
|
|
23241
23787
|
/**
|
|
23242
23788
|
* Markdown documentation for MESSAGE commitment.
|
|
23243
23789
|
*/
|
|
@@ -23344,6 +23890,12 @@
|
|
|
23344
23890
|
get description() {
|
|
23345
23891
|
return 'Defines a **message from the user** in the conversation history.';
|
|
23346
23892
|
}
|
|
23893
|
+
/**
|
|
23894
|
+
* Icon for this commitment.
|
|
23895
|
+
*/
|
|
23896
|
+
get icon() {
|
|
23897
|
+
return '🧑';
|
|
23898
|
+
}
|
|
23347
23899
|
/**
|
|
23348
23900
|
* Markdown documentation for USER MESSAGE commitment.
|
|
23349
23901
|
*/
|
|
@@ -23417,6 +23969,12 @@
|
|
|
23417
23969
|
get description() {
|
|
23418
23970
|
return 'Set meta-information about the agent (IMAGE, LINK, TITLE, DESCRIPTION, etc.).';
|
|
23419
23971
|
}
|
|
23972
|
+
/**
|
|
23973
|
+
* Icon for this commitment.
|
|
23974
|
+
*/
|
|
23975
|
+
get icon() {
|
|
23976
|
+
return 'ℹ️';
|
|
23977
|
+
}
|
|
23420
23978
|
/**
|
|
23421
23979
|
* Markdown documentation for META commitment.
|
|
23422
23980
|
*/
|
|
@@ -23544,6 +24102,12 @@
|
|
|
23544
24102
|
get description() {
|
|
23545
24103
|
return "Set the agent's accent color.";
|
|
23546
24104
|
}
|
|
24105
|
+
/**
|
|
24106
|
+
* Icon for this commitment.
|
|
24107
|
+
*/
|
|
24108
|
+
get icon() {
|
|
24109
|
+
return '🎨';
|
|
24110
|
+
}
|
|
23547
24111
|
/**
|
|
23548
24112
|
* Markdown documentation for META COLOR commitment.
|
|
23549
24113
|
*/
|
|
@@ -23622,6 +24186,12 @@
|
|
|
23622
24186
|
get description() {
|
|
23623
24187
|
return "Set the agent's profile image URL.";
|
|
23624
24188
|
}
|
|
24189
|
+
/**
|
|
24190
|
+
* Icon for this commitment.
|
|
24191
|
+
*/
|
|
24192
|
+
get icon() {
|
|
24193
|
+
return '🖼️';
|
|
24194
|
+
}
|
|
23625
24195
|
/**
|
|
23626
24196
|
* Markdown documentation for META IMAGE commitment.
|
|
23627
24197
|
*/
|
|
@@ -23677,6 +24247,115 @@
|
|
|
23677
24247
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
23678
24248
|
*/
|
|
23679
24249
|
|
|
24250
|
+
/**
|
|
24251
|
+
* META LINK commitment definition
|
|
24252
|
+
*
|
|
24253
|
+
* The `META LINK` commitment represents the link to the person from whom the agent is created.
|
|
24254
|
+
* This commitment is special because it doesn't affect the system message,
|
|
24255
|
+
* but is handled separately in the parsing logic for profile display.
|
|
24256
|
+
*
|
|
24257
|
+
* Example usage in agent source:
|
|
24258
|
+
*
|
|
24259
|
+
* ```
|
|
24260
|
+
* META LINK https://twitter.com/username
|
|
24261
|
+
* META LINK https://linkedin.com/in/profile
|
|
24262
|
+
* META LINK https://github.com/username
|
|
24263
|
+
* ```
|
|
24264
|
+
*
|
|
24265
|
+
* Multiple `META LINK` commitments can be used when there are multiple sources:
|
|
24266
|
+
*
|
|
24267
|
+
* ```book
|
|
24268
|
+
* META LINK https://twitter.com/username
|
|
24269
|
+
* META LINK https://linkedin.com/in/profile
|
|
24270
|
+
* ```
|
|
24271
|
+
*
|
|
24272
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
24273
|
+
*/
|
|
24274
|
+
class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition {
|
|
24275
|
+
constructor() {
|
|
24276
|
+
super('META LINK');
|
|
24277
|
+
}
|
|
24278
|
+
/**
|
|
24279
|
+
* Short one-line description of META LINK.
|
|
24280
|
+
*/
|
|
24281
|
+
get description() {
|
|
24282
|
+
return 'Provide profile/source links for the person the agent models.';
|
|
24283
|
+
}
|
|
24284
|
+
/**
|
|
24285
|
+
* Icon for this commitment.
|
|
24286
|
+
*/
|
|
24287
|
+
get icon() {
|
|
24288
|
+
return '🔗';
|
|
24289
|
+
}
|
|
24290
|
+
/**
|
|
24291
|
+
* Markdown documentation for META LINK commitment.
|
|
24292
|
+
*/
|
|
24293
|
+
get documentation() {
|
|
24294
|
+
return spaceTrim.spaceTrim(`
|
|
24295
|
+
# META LINK
|
|
24296
|
+
|
|
24297
|
+
Represents a profile or source link for the person the agent is modeled after.
|
|
24298
|
+
|
|
24299
|
+
## Key aspects
|
|
24300
|
+
|
|
24301
|
+
- Does not modify the agent's behavior or responses.
|
|
24302
|
+
- Multiple \`META LINK\` commitments can be used for different social profiles.
|
|
24303
|
+
- Used for attribution and crediting the original person.
|
|
24304
|
+
- Displayed in user interfaces for transparency.
|
|
24305
|
+
|
|
24306
|
+
## Examples
|
|
24307
|
+
|
|
24308
|
+
\`\`\`book
|
|
24309
|
+
Expert Consultant
|
|
24310
|
+
|
|
24311
|
+
META LINK https://twitter.com/expertname
|
|
24312
|
+
META LINK https://linkedin.com/in/expertprofile
|
|
24313
|
+
PERSONA You are Dr. Smith, a renowned expert in artificial intelligence
|
|
24314
|
+
KNOWLEDGE Extensive background in machine learning and neural networks
|
|
24315
|
+
\`\`\`
|
|
24316
|
+
|
|
24317
|
+
\`\`\`book
|
|
24318
|
+
Open Source Developer
|
|
24319
|
+
|
|
24320
|
+
META LINK https://github.com/developer
|
|
24321
|
+
META LINK https://twitter.com/devhandle
|
|
24322
|
+
PERSONA You are an experienced open source developer
|
|
24323
|
+
ACTION Can help with code reviews and architecture decisions
|
|
24324
|
+
STYLE Be direct and technical in explanations
|
|
24325
|
+
\`\`\`
|
|
24326
|
+
`);
|
|
24327
|
+
}
|
|
24328
|
+
applyToAgentModelRequirements(requirements, content) {
|
|
24329
|
+
// META LINK doesn't modify the system message or model requirements
|
|
24330
|
+
// It's handled separately in the parsing logic for profile link extraction
|
|
24331
|
+
// This method exists for consistency with the CommitmentDefinition interface
|
|
24332
|
+
return requirements;
|
|
24333
|
+
}
|
|
24334
|
+
/**
|
|
24335
|
+
* Extracts the profile link URL from the content
|
|
24336
|
+
* This is used by the parsing logic
|
|
24337
|
+
*/
|
|
24338
|
+
extractProfileLinkUrl(content) {
|
|
24339
|
+
const trimmedContent = content.trim();
|
|
24340
|
+
return trimmedContent || null;
|
|
24341
|
+
}
|
|
24342
|
+
/**
|
|
24343
|
+
* Validates if the provided content is a valid URL
|
|
24344
|
+
*/
|
|
24345
|
+
isValidUrl(content) {
|
|
24346
|
+
try {
|
|
24347
|
+
new URL(content.trim());
|
|
24348
|
+
return true;
|
|
24349
|
+
}
|
|
24350
|
+
catch (_a) {
|
|
24351
|
+
return false;
|
|
24352
|
+
}
|
|
24353
|
+
}
|
|
24354
|
+
}
|
|
24355
|
+
/**
|
|
24356
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24357
|
+
*/
|
|
24358
|
+
|
|
23680
24359
|
/**
|
|
23681
24360
|
* MODEL commitment definition
|
|
23682
24361
|
*
|
|
@@ -23712,6 +24391,12 @@
|
|
|
23712
24391
|
get description() {
|
|
23713
24392
|
return 'Enforce AI model requirements including name and technical parameters.';
|
|
23714
24393
|
}
|
|
24394
|
+
/**
|
|
24395
|
+
* Icon for this commitment.
|
|
24396
|
+
*/
|
|
24397
|
+
get icon() {
|
|
24398
|
+
return '⚙️';
|
|
24399
|
+
}
|
|
23715
24400
|
/**
|
|
23716
24401
|
* Markdown documentation for MODEL commitment.
|
|
23717
24402
|
*/
|
|
@@ -23947,6 +24632,12 @@
|
|
|
23947
24632
|
get description() {
|
|
23948
24633
|
return 'Add developer-facing notes without changing behavior or output.';
|
|
23949
24634
|
}
|
|
24635
|
+
/**
|
|
24636
|
+
* Icon for this commitment.
|
|
24637
|
+
*/
|
|
24638
|
+
get icon() {
|
|
24639
|
+
return '📝';
|
|
24640
|
+
}
|
|
23950
24641
|
/**
|
|
23951
24642
|
* Markdown documentation for NOTE commitment.
|
|
23952
24643
|
*/
|
|
@@ -24016,6 +24707,74 @@
|
|
|
24016
24707
|
* [💞] Ignore a discrepancy between file name and entity name
|
|
24017
24708
|
*/
|
|
24018
24709
|
|
|
24710
|
+
/**
|
|
24711
|
+
* OPEN commitment definition
|
|
24712
|
+
*
|
|
24713
|
+
* The OPEN commitment specifies that the agent can be modified by conversation.
|
|
24714
|
+
* This is the default behavior.
|
|
24715
|
+
*
|
|
24716
|
+
* Example usage in agent source:
|
|
24717
|
+
*
|
|
24718
|
+
* ```book
|
|
24719
|
+
* OPEN
|
|
24720
|
+
* ```
|
|
24721
|
+
*
|
|
24722
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
24723
|
+
*/
|
|
24724
|
+
class OpenCommitmentDefinition extends BaseCommitmentDefinition {
|
|
24725
|
+
constructor() {
|
|
24726
|
+
super('OPEN');
|
|
24727
|
+
}
|
|
24728
|
+
/**
|
|
24729
|
+
* Short one-line description of OPEN.
|
|
24730
|
+
*/
|
|
24731
|
+
get description() {
|
|
24732
|
+
return 'Allow the agent to be modified by conversation (default).';
|
|
24733
|
+
}
|
|
24734
|
+
/**
|
|
24735
|
+
* Icon for this commitment.
|
|
24736
|
+
*/
|
|
24737
|
+
get icon() {
|
|
24738
|
+
return '🔓';
|
|
24739
|
+
}
|
|
24740
|
+
/**
|
|
24741
|
+
* Markdown documentation for OPEN commitment.
|
|
24742
|
+
*/
|
|
24743
|
+
get documentation() {
|
|
24744
|
+
return spaceTrim.spaceTrim(`
|
|
24745
|
+
# OPEN
|
|
24746
|
+
|
|
24747
|
+
Specifies that the agent can be modified by conversation with it.
|
|
24748
|
+
This means the agent will learn from interactions and update its source code.
|
|
24749
|
+
|
|
24750
|
+
This is the default behavior if neither \`OPEN\` nor \`CLOSED\` is specified.
|
|
24751
|
+
|
|
24752
|
+
> See also [CLOSED](/docs/CLOSED)
|
|
24753
|
+
|
|
24754
|
+
## Example
|
|
24755
|
+
|
|
24756
|
+
\`\`\`book
|
|
24757
|
+
OPEN
|
|
24758
|
+
\`\`\`
|
|
24759
|
+
`);
|
|
24760
|
+
}
|
|
24761
|
+
applyToAgentModelRequirements(requirements, _content) {
|
|
24762
|
+
// Since OPEN is default, we can just ensure isClosed is false
|
|
24763
|
+
// But to be explicit we can set it
|
|
24764
|
+
const updatedMetadata = {
|
|
24765
|
+
...requirements.metadata,
|
|
24766
|
+
isClosed: false,
|
|
24767
|
+
};
|
|
24768
|
+
return {
|
|
24769
|
+
...requirements,
|
|
24770
|
+
metadata: updatedMetadata,
|
|
24771
|
+
};
|
|
24772
|
+
}
|
|
24773
|
+
}
|
|
24774
|
+
/**
|
|
24775
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24776
|
+
*/
|
|
24777
|
+
|
|
24019
24778
|
/**
|
|
24020
24779
|
* PERSONA commitment definition
|
|
24021
24780
|
*
|
|
@@ -24049,6 +24808,12 @@
|
|
|
24049
24808
|
get description() {
|
|
24050
24809
|
return 'Define who the agent is: background, expertise, and personality.';
|
|
24051
24810
|
}
|
|
24811
|
+
/**
|
|
24812
|
+
* Icon for this commitment.
|
|
24813
|
+
*/
|
|
24814
|
+
get icon() {
|
|
24815
|
+
return '👤';
|
|
24816
|
+
}
|
|
24052
24817
|
/**
|
|
24053
24818
|
* Markdown documentation for PERSONA commitment.
|
|
24054
24819
|
*/
|
|
@@ -24176,6 +24941,12 @@
|
|
|
24176
24941
|
get description() {
|
|
24177
24942
|
return 'Add behavioral rules the agent must follow.';
|
|
24178
24943
|
}
|
|
24944
|
+
/**
|
|
24945
|
+
* Icon for this commitment.
|
|
24946
|
+
*/
|
|
24947
|
+
get icon() {
|
|
24948
|
+
return '⚖️';
|
|
24949
|
+
}
|
|
24179
24950
|
/**
|
|
24180
24951
|
* Markdown documentation for RULE/RULES commitment.
|
|
24181
24952
|
*/
|
|
@@ -24252,6 +25023,12 @@
|
|
|
24252
25023
|
get description() {
|
|
24253
25024
|
return 'Provide example responses to guide behavior.';
|
|
24254
25025
|
}
|
|
25026
|
+
/**
|
|
25027
|
+
* Icon for this commitment.
|
|
25028
|
+
*/
|
|
25029
|
+
get icon() {
|
|
25030
|
+
return '🔍';
|
|
25031
|
+
}
|
|
24255
25032
|
/**
|
|
24256
25033
|
* Markdown documentation for SAMPLE/EXAMPLE commitment.
|
|
24257
25034
|
*/
|
|
@@ -24329,6 +25106,12 @@
|
|
|
24329
25106
|
get description() {
|
|
24330
25107
|
return 'Define specific **situations** or contexts for AI responses, with later scenarios having higher priority.';
|
|
24331
25108
|
}
|
|
25109
|
+
/**
|
|
25110
|
+
* Icon for this commitment.
|
|
25111
|
+
*/
|
|
25112
|
+
get icon() {
|
|
25113
|
+
return '🎭';
|
|
25114
|
+
}
|
|
24332
25115
|
/**
|
|
24333
25116
|
* Markdown documentation for SCENARIO commitment.
|
|
24334
25117
|
*/
|
|
@@ -24445,6 +25228,12 @@
|
|
|
24445
25228
|
get description() {
|
|
24446
25229
|
return 'Control the tone and writing style of responses.';
|
|
24447
25230
|
}
|
|
25231
|
+
/**
|
|
25232
|
+
* Icon for this commitment.
|
|
25233
|
+
*/
|
|
25234
|
+
get icon() {
|
|
25235
|
+
return '🖋️';
|
|
25236
|
+
}
|
|
24448
25237
|
/**
|
|
24449
25238
|
* Markdown documentation for STYLE commitment.
|
|
24450
25239
|
*/
|
|
@@ -24496,136 +25285,60 @@
|
|
|
24496
25285
|
* [💞] Ignore a discrepancy between file name and entity name
|
|
24497
25286
|
*/
|
|
24498
25287
|
|
|
24499
|
-
/**
|
|
24500
|
-
* Placeholder commitment definition for commitments that are not yet implemented
|
|
24501
|
-
*
|
|
24502
|
-
* This commitment simply adds its content 1:1 into the system message,
|
|
24503
|
-
* preserving the original behavior until proper implementation is added.
|
|
24504
|
-
*
|
|
24505
|
-
* @public exported from `@promptbook/core`
|
|
24506
|
-
*/
|
|
24507
|
-
class NotYetImplementedCommitmentDefinition extends BaseCommitmentDefinition {
|
|
24508
|
-
constructor(type) {
|
|
24509
|
-
super(type);
|
|
24510
|
-
}
|
|
24511
|
-
/**
|
|
24512
|
-
* Short one-line description of a placeholder commitment.
|
|
24513
|
-
*/
|
|
24514
|
-
get description() {
|
|
24515
|
-
return 'Placeholder commitment that appends content verbatim to the system message.';
|
|
24516
|
-
}
|
|
24517
|
-
/**
|
|
24518
|
-
* Markdown documentation available at runtime.
|
|
24519
|
-
*/
|
|
24520
|
-
get documentation() {
|
|
24521
|
-
return spaceTrim.spaceTrim(`
|
|
24522
|
-
# ${this.type}
|
|
24523
|
-
|
|
24524
|
-
This commitment is not yet fully implemented.
|
|
24525
|
-
|
|
24526
|
-
## Key aspects
|
|
24527
|
-
|
|
24528
|
-
- Content is appended directly to the system message.
|
|
24529
|
-
- No special processing or validation is performed.
|
|
24530
|
-
- Behavior preserved until proper implementation is added.
|
|
24531
|
-
|
|
24532
|
-
## Status
|
|
24533
|
-
|
|
24534
|
-
- **Status:** Placeholder implementation
|
|
24535
|
-
- **Effect:** Appends content prefixed by commitment type
|
|
24536
|
-
- **Future:** Will be replaced with specialized logic
|
|
24537
|
-
|
|
24538
|
-
## Examples
|
|
24539
|
-
|
|
24540
|
-
\`\`\`book
|
|
24541
|
-
Example Agent
|
|
24542
|
-
|
|
24543
|
-
PERSONA You are a helpful assistant
|
|
24544
|
-
${this.type} Your content here
|
|
24545
|
-
RULE Always be helpful
|
|
24546
|
-
\`\`\`
|
|
24547
|
-
`);
|
|
24548
|
-
}
|
|
24549
|
-
applyToAgentModelRequirements(requirements, content) {
|
|
24550
|
-
const trimmedContent = content.trim();
|
|
24551
|
-
if (!trimmedContent) {
|
|
24552
|
-
return requirements;
|
|
24553
|
-
}
|
|
24554
|
-
// Add the commitment content 1:1 to the system message
|
|
24555
|
-
const commitmentLine = `${this.type} ${trimmedContent}`;
|
|
24556
|
-
return this.appendToSystemMessage(requirements, commitmentLine, '\n\n');
|
|
24557
|
-
}
|
|
24558
|
-
}
|
|
24559
|
-
|
|
24560
25288
|
// Import all commitment definition classes
|
|
24561
|
-
|
|
24562
|
-
|
|
24563
|
-
|
|
24564
|
-
|
|
24565
|
-
|
|
24566
|
-
|
|
24567
|
-
|
|
24568
|
-
|
|
24569
|
-
|
|
24570
|
-
|
|
24571
|
-
|
|
24572
|
-
|
|
24573
|
-
|
|
24574
|
-
|
|
24575
|
-
|
|
24576
|
-
|
|
24577
|
-
|
|
24578
|
-
|
|
24579
|
-
|
|
24580
|
-
|
|
24581
|
-
|
|
24582
|
-
|
|
24583
|
-
|
|
24584
|
-
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
24589
|
-
|
|
24590
|
-
|
|
24591
|
-
|
|
24592
|
-
|
|
24593
|
-
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
24597
|
-
|
|
24598
|
-
|
|
24599
|
-
|
|
24600
|
-
|
|
24601
|
-
|
|
24602
|
-
|
|
24603
|
-
|
|
24604
|
-
|
|
24605
|
-
|
|
24606
|
-
|
|
24607
|
-
|
|
24608
|
-
|
|
24609
|
-
|
|
24610
|
-
|
|
24611
|
-
|
|
24612
|
-
|
|
24613
|
-
|
|
24614
|
-
];
|
|
24615
|
-
/**
|
|
24616
|
-
* Gets a commitment definition by its type
|
|
24617
|
-
* @param type The commitment type to look up
|
|
24618
|
-
* @returns The commitment definition or null if not found
|
|
24619
|
-
*
|
|
24620
|
-
* @public exported from `@promptbook/core`
|
|
24621
|
-
*/
|
|
24622
|
-
function getCommitmentDefinition(type) {
|
|
24623
|
-
return COMMITMENT_REGISTRY.find((commitmentDefinition) => commitmentDefinition.type === type) || null;
|
|
24624
|
-
}
|
|
24625
|
-
/**
|
|
24626
|
-
* TODO: [🧠] Maybe create through standardized $register
|
|
24627
|
-
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24628
|
-
*/
|
|
25289
|
+
// Register fully implemented commitments
|
|
25290
|
+
registerCommitment(new PersonaCommitmentDefinition('PERSONA'));
|
|
25291
|
+
registerCommitment(new PersonaCommitmentDefinition('PERSONAE'));
|
|
25292
|
+
registerCommitment(new KnowledgeCommitmentDefinition());
|
|
25293
|
+
registerCommitment(new MemoryCommitmentDefinition('MEMORY'));
|
|
25294
|
+
registerCommitment(new MemoryCommitmentDefinition('MEMORIES'));
|
|
25295
|
+
registerCommitment(new StyleCommitmentDefinition('STYLE'));
|
|
25296
|
+
registerCommitment(new StyleCommitmentDefinition('STYLES'));
|
|
25297
|
+
registerCommitment(new RuleCommitmentDefinition('RULE'));
|
|
25298
|
+
registerCommitment(new RuleCommitmentDefinition('RULES'));
|
|
25299
|
+
registerCommitment(new LanguageCommitmentDefinition('LANGUAGE'));
|
|
25300
|
+
registerCommitment(new LanguageCommitmentDefinition('LANGUAGES'));
|
|
25301
|
+
registerCommitment(new SampleCommitmentDefinition('SAMPLE'));
|
|
25302
|
+
registerCommitment(new SampleCommitmentDefinition('EXAMPLE'));
|
|
25303
|
+
registerCommitment(new FormatCommitmentDefinition('FORMAT'));
|
|
25304
|
+
registerCommitment(new FormatCommitmentDefinition('FORMATS'));
|
|
25305
|
+
registerCommitment(new FromCommitmentDefinition('FROM'));
|
|
25306
|
+
registerCommitment(new ModelCommitmentDefinition('MODEL'));
|
|
25307
|
+
registerCommitment(new ModelCommitmentDefinition('MODELS'));
|
|
25308
|
+
registerCommitment(new ActionCommitmentDefinition('ACTION'));
|
|
25309
|
+
registerCommitment(new ActionCommitmentDefinition('ACTIONS'));
|
|
25310
|
+
registerCommitment(new ComponentCommitmentDefinition());
|
|
25311
|
+
registerCommitment(new MetaImageCommitmentDefinition());
|
|
25312
|
+
registerCommitment(new MetaColorCommitmentDefinition());
|
|
25313
|
+
registerCommitment(new MetaLinkCommitmentDefinition());
|
|
25314
|
+
registerCommitment(new MetaCommitmentDefinition());
|
|
25315
|
+
registerCommitment(new NoteCommitmentDefinition('NOTE'));
|
|
25316
|
+
registerCommitment(new NoteCommitmentDefinition('NOTES'));
|
|
25317
|
+
registerCommitment(new NoteCommitmentDefinition('COMMENT'));
|
|
25318
|
+
registerCommitment(new NoteCommitmentDefinition('NONCE'));
|
|
25319
|
+
registerCommitment(new GoalCommitmentDefinition('GOAL'));
|
|
25320
|
+
registerCommitment(new GoalCommitmentDefinition('GOALS'));
|
|
25321
|
+
registerCommitment(new ImportantCommitmentDefinition());
|
|
25322
|
+
registerCommitment(new InitialMessageCommitmentDefinition());
|
|
25323
|
+
registerCommitment(new UserMessageCommitmentDefinition());
|
|
25324
|
+
registerCommitment(new AgentMessageCommitmentDefinition());
|
|
25325
|
+
registerCommitment(new MessageCommitmentDefinition('MESSAGE'));
|
|
25326
|
+
registerCommitment(new MessageCommitmentDefinition('MESSAGES'));
|
|
25327
|
+
registerCommitment(new ScenarioCommitmentDefinition('SCENARIO'));
|
|
25328
|
+
registerCommitment(new ScenarioCommitmentDefinition('SCENARIOS'));
|
|
25329
|
+
registerCommitment(new DeleteCommitmentDefinition('DELETE'));
|
|
25330
|
+
registerCommitment(new DeleteCommitmentDefinition('CANCEL'));
|
|
25331
|
+
registerCommitment(new DeleteCommitmentDefinition('DISCARD'));
|
|
25332
|
+
registerCommitment(new DeleteCommitmentDefinition('REMOVE'));
|
|
25333
|
+
registerCommitment(new OpenCommitmentDefinition());
|
|
25334
|
+
registerCommitment(new ClosedCommitmentDefinition());
|
|
25335
|
+
// Register not yet implemented commitments
|
|
25336
|
+
registerCommitment(new NotYetImplementedCommitmentDefinition('EXPECT'));
|
|
25337
|
+
registerCommitment(new NotYetImplementedCommitmentDefinition('BEHAVIOUR'));
|
|
25338
|
+
registerCommitment(new NotYetImplementedCommitmentDefinition('BEHAVIOURS'));
|
|
25339
|
+
registerCommitment(new NotYetImplementedCommitmentDefinition('AVOID'));
|
|
25340
|
+
registerCommitment(new NotYetImplementedCommitmentDefinition('AVOIDANCE'));
|
|
25341
|
+
registerCommitment(new NotYetImplementedCommitmentDefinition('CONTEXT'));
|
|
24629
25342
|
|
|
24630
25343
|
/**
|
|
24631
25344
|
* Creates an empty/basic agent model requirements object
|
|
@@ -25037,7 +25750,9 @@
|
|
|
25037
25750
|
const links = [];
|
|
25038
25751
|
for (const commitment of parseResult.commitments) {
|
|
25039
25752
|
if (commitment.type === 'META LINK') {
|
|
25040
|
-
|
|
25753
|
+
const linkValue = spaceTrim__default["default"](commitment.content);
|
|
25754
|
+
links.push(linkValue);
|
|
25755
|
+
meta.link = linkValue;
|
|
25041
25756
|
continue;
|
|
25042
25757
|
}
|
|
25043
25758
|
if (commitment.type === 'META IMAGE') {
|