@elizaos/prompts 2.0.0-alpha
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/LICENSE +21 -0
- package/README.md +142 -0
- package/dist/python/__init__.py +2 -0
- package/dist/python/prompts.py +601 -0
- package/dist/rust/mod.rs +3 -0
- package/dist/rust/prompts.rs +575 -0
- package/dist/typescript/index.d.ts +42 -0
- package/dist/typescript/index.ts +615 -0
- package/package.json +47 -0
- package/prompts/autonomy_continuous_continue.txt +15 -0
- package/prompts/autonomy_continuous_first.txt +13 -0
- package/prompts/autonomy_task_continue.txt +17 -0
- package/prompts/autonomy_task_first.txt +14 -0
- package/prompts/choose_option.txt +25 -0
- package/prompts/image_description.txt +31 -0
- package/prompts/image_generation.txt +25 -0
- package/prompts/message_handler.txt +100 -0
- package/prompts/multi_step_decision.txt +52 -0
- package/prompts/multi_step_summary.txt +44 -0
- package/prompts/option_extraction.txt +31 -0
- package/prompts/post_creation.txt +52 -0
- package/prompts/reflection.txt +31 -0
- package/prompts/reflection_evaluator.txt +64 -0
- package/prompts/reply.txt +31 -0
- package/prompts/should_respond.txt +40 -0
- package/prompts/update_entity.txt +31 -0
- package/prompts/update_settings.txt +30 -0
- package/scripts/check-secrets.js +187 -0
- package/scripts/generate-action-docs.js +912 -0
- package/scripts/generate-plugin-action-spec.js +647 -0
- package/scripts/generate-plugin-prompts.js +306 -0
- package/scripts/generate.js +279 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shaw Walters and elizaOS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# @elizaos/prompts
|
|
2
|
+
|
|
3
|
+
Shared prompt templates for elizaOS across TypeScript, Python, and Rust runtimes.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides a single source of truth for all prompt templates used by elizaOS agents. Prompts are stored as `.txt` files and generated into native formats for each language.
|
|
8
|
+
|
|
9
|
+
## Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
packages/prompts/
|
|
13
|
+
├── prompts/ # Source prompt templates (.txt files)
|
|
14
|
+
│ ├── reply.txt
|
|
15
|
+
│ ├── choose_option.txt
|
|
16
|
+
│ ├── image_generation.txt
|
|
17
|
+
│ └── ...
|
|
18
|
+
├── scripts/ # Build scripts
|
|
19
|
+
│ └── generate.js # Generates native code from prompts
|
|
20
|
+
├── dist/ # Generated output
|
|
21
|
+
│ ├── typescript/ # TypeScript exports
|
|
22
|
+
│ ├── python/ # Python module
|
|
23
|
+
│ └── rust/ # Rust source
|
|
24
|
+
└── package.json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Template Syntax
|
|
28
|
+
|
|
29
|
+
All prompts use **Handlebars-style** template variables:
|
|
30
|
+
|
|
31
|
+
- `{{variableName}}` - Simple variable substitution
|
|
32
|
+
- `{{#each items}}...{{/each}}` - Iteration over arrays
|
|
33
|
+
- `{{#if condition}}...{{/if}}` - Conditional blocks
|
|
34
|
+
|
|
35
|
+
### Variable Naming Convention
|
|
36
|
+
|
|
37
|
+
Use camelCase for all template variables to ensure consistency across languages:
|
|
38
|
+
|
|
39
|
+
- `{{agentName}}` - The agent's name
|
|
40
|
+
- `{{providers}}` - Provider context
|
|
41
|
+
- `{{recentMessages}}` - Recent conversation messages
|
|
42
|
+
|
|
43
|
+
## Building
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Build all targets
|
|
47
|
+
npm run build
|
|
48
|
+
|
|
49
|
+
# Build specific target
|
|
50
|
+
npm run build:typescript
|
|
51
|
+
npm run build:python
|
|
52
|
+
npm run build:rust
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
### TypeScript
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { REPLY_TEMPLATE, CHOOSE_OPTION_TEMPLATE } from "@elizaos/prompts";
|
|
61
|
+
|
|
62
|
+
const prompt = composePrompt({
|
|
63
|
+
state: { agentName: "Alice" },
|
|
64
|
+
template: REPLY_TEMPLATE,
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Python
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from elizaos.prompts import REPLY_TEMPLATE, CHOOSE_OPTION_TEMPLATE
|
|
72
|
+
|
|
73
|
+
prompt = compose_prompt(state={'agentName': 'Alice'}, template=REPLY_TEMPLATE)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Rust
|
|
77
|
+
|
|
78
|
+
```rust
|
|
79
|
+
use elizaos_prompts::{REPLY_TEMPLATE, CHOOSE_OPTION_TEMPLATE};
|
|
80
|
+
|
|
81
|
+
let prompt = compose_prompt(&state, REPLY_TEMPLATE);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Adding New Prompts
|
|
85
|
+
|
|
86
|
+
1. Create a new `.txt` file in `prompts/` directory
|
|
87
|
+
2. Name the file using snake_case (e.g., `my_new_action.txt`)
|
|
88
|
+
3. Run `npm run build` to generate native code
|
|
89
|
+
4. The prompt will be exported as `MY_NEW_ACTION_TEMPLATE` in all languages
|
|
90
|
+
|
|
91
|
+
## Plugin Prompts
|
|
92
|
+
|
|
93
|
+
Plugins can use the same prompt system! See [README-PLUGIN-PROMPTS.md](./README-PLUGIN-PROMPTS.md) for details on how to set up prompts in your plugin.
|
|
94
|
+
|
|
95
|
+
The `scripts/generate-plugin-prompts.js` utility can be used by any plugin to generate TypeScript, Python, and Rust exports from `.txt` prompt templates.
|
|
96
|
+
|
|
97
|
+
## Template Guidelines
|
|
98
|
+
|
|
99
|
+
1. **Start with a task description** - Begin prompts with `# Task:` to clearly state the objective
|
|
100
|
+
2. **Include providers placeholder** - Use `{{providers}}` where provider context should be injected
|
|
101
|
+
3. **Use XML output format** - Standardize on XML response format for consistent parsing
|
|
102
|
+
4. **Add clear instructions** - Include explicit instructions for the LLM
|
|
103
|
+
5. **End with output format** - Always specify the expected output format
|
|
104
|
+
|
|
105
|
+
Example:
|
|
106
|
+
|
|
107
|
+
```txt
|
|
108
|
+
# Task: Generate dialog for the character {{agentName}}.
|
|
109
|
+
|
|
110
|
+
{{providers}}
|
|
111
|
+
|
|
112
|
+
# Instructions: Write the next message for {{agentName}}.
|
|
113
|
+
|
|
114
|
+
Respond using XML format like this:
|
|
115
|
+
<response>
|
|
116
|
+
<thought>Your thought here</thought>
|
|
117
|
+
<text>Your message here</text>
|
|
118
|
+
</response>
|
|
119
|
+
|
|
120
|
+
IMPORTANT: Your response must ONLY contain the <response></response> XML block above.
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Security & Privacy Guidance (SOC2-aligned)
|
|
124
|
+
|
|
125
|
+
- **Do not embed real secrets** in prompt templates. Prompts are source-controlled and often distributed.
|
|
126
|
+
- **Avoid including PII** (emails, phone numbers, addresses, IDs) in templates or examples.
|
|
127
|
+
- Prefer placeholders (e.g., `{{apiKey}}`, `{{userEmail}}`) and ensure the runtime injects only the minimum needed.
|
|
128
|
+
|
|
129
|
+
### Secret scan
|
|
130
|
+
|
|
131
|
+
This package includes a conservative scanner that flags prompt templates containing strings that strongly resemble real credentials (or private key material).
|
|
132
|
+
|
|
133
|
+
Run:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npm run check:secrets
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
It scans:
|
|
140
|
+
|
|
141
|
+
- `packages/prompts/prompts/**/*.txt`
|
|
142
|
+
- `plugins/**/prompts/**/*.txt`
|