@elizaos/prompts 2.0.0-alpha.97 → 2.0.0-beta.1
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/README.md +32 -91
- package/dist/python/prompts.py +830 -258
- package/dist/rust/prompts.rs +811 -259
- package/package.json +10 -15
- package/scripts/check-secrets.js +89 -41
- package/scripts/generate-action-docs.js +156 -450
- package/scripts/generate-plugin-action-spec.js +719 -14
- package/scripts/prompt-compression.js +171 -0
- package/src/index.ts +1301 -0
- package/LICENSE +0 -21
- package/dist/typescript/index.d.ts +0 -42
- package/dist/typescript/index.ts +0 -612
- package/prompts/autonomy_continuous_continue.txt +0 -15
- package/prompts/autonomy_continuous_first.txt +0 -13
- package/prompts/autonomy_task_continue.txt +0 -17
- package/prompts/autonomy_task_first.txt +0 -14
- package/prompts/choose_option.txt +0 -25
- package/prompts/image_description.txt +0 -29
- package/prompts/image_generation.txt +0 -25
- package/prompts/message_handler.txt +0 -105
- package/prompts/multi_step_decision.txt +0 -52
- package/prompts/multi_step_summary.txt +0 -44
- package/prompts/option_extraction.txt +0 -29
- package/prompts/post_creation.txt +0 -50
- package/prompts/reflection.txt +0 -31
- package/prompts/reflection_evaluator.txt +0 -62
- package/prompts/reply.txt +0 -31
- package/prompts/should_respond.txt +0 -40
- package/prompts/update_entity.txt +0 -31
- package/prompts/update_settings.txt +0 -30
- package/scripts/generate-plugin-prompts.js +0 -306
- package/scripts/generate.js +0 -279
package/README.md
CHANGED
|
@@ -1,61 +1,51 @@
|
|
|
1
1
|
# @elizaos/prompts
|
|
2
2
|
|
|
3
|
-
Shared prompt templates
|
|
3
|
+
Shared prompt templates and action specs for elizaOS.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
This package
|
|
7
|
+
This package is the single source of truth for prompt templates used by the runtime. Prompts are authored directly as TypeScript modules under `src/` and re-exported from `src/index.ts`.
|
|
8
8
|
|
|
9
9
|
## Structure
|
|
10
10
|
|
|
11
11
|
```
|
|
12
12
|
packages/prompts/
|
|
13
|
-
├──
|
|
14
|
-
│ ├── reply.
|
|
15
|
-
│ ├── choose_option.
|
|
16
|
-
│ ├── image_generation.
|
|
13
|
+
├── src/ # TypeScript prompt template modules (source of truth)
|
|
14
|
+
│ ├── reply.ts
|
|
15
|
+
│ ├── choose_option.ts
|
|
16
|
+
│ ├── image_generation.ts
|
|
17
17
|
│ └── ...
|
|
18
|
-
├──
|
|
19
|
-
|
|
20
|
-
├──
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
└── package.json
|
|
18
|
+
├── specs/ # Canonical merged action/provider specs (JSON) + generated plugins.generated.json
|
|
19
|
+
└── scripts/ # Spec + docs generators
|
|
20
|
+
├── generate-action-docs.js
|
|
21
|
+
├── generate-plugin-action-spec.js
|
|
22
|
+
├── prompt-compression.js
|
|
23
|
+
└── check-secrets.js
|
|
25
24
|
```
|
|
26
25
|
|
|
27
26
|
## Template Syntax
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
Prompts use Handlebars-style variables:
|
|
30
29
|
|
|
31
|
-
- `{{variableName}}` -
|
|
32
|
-
- `{{#each items}}...{{/each}}` -
|
|
33
|
-
- `{{#if condition}}...{{/if}}` -
|
|
30
|
+
- `{{variableName}}` - simple variable substitution
|
|
31
|
+
- `{{#each items}}...{{/each}}` - iteration
|
|
32
|
+
- `{{#if condition}}...{{/if}}` - conditional
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
Use camelCase for variables (`{{agentName}}`, `{{providers}}`, `{{recentMessages}}`).
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
## Plugin-local `prompts/*.json` (under `plugins/**`)
|
|
38
37
|
|
|
39
|
-
- `
|
|
40
|
-
- `{{providers}}` - Provider context
|
|
41
|
-
- `{{recentMessages}}` - Recent conversation messages
|
|
38
|
+
Some plugins keep **hand-edited** `actions.json` / `evaluators.json` / `providers.json` next to their source. Those files feed **per-plugin codegen** (for example `generated/specs/spec-helpers.ts` via each plugin’s own workflow). They are **not** inputs to `scripts/generate-plugin-action-spec.js`, which instead scans `plugins/**/*.ts` for `export const …: Action` blocks and writes `specs/actions/plugins.generated.json`.
|
|
42
39
|
|
|
43
40
|
## Building
|
|
44
41
|
|
|
45
42
|
```bash
|
|
46
|
-
#
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# Build specific target
|
|
50
|
-
npm run build:typescript
|
|
51
|
-
npm run build:python
|
|
52
|
-
npm run build:rust
|
|
43
|
+
# Generate plugin action spec + action docs
|
|
44
|
+
bun run build
|
|
53
45
|
```
|
|
54
46
|
|
|
55
47
|
## Usage
|
|
56
48
|
|
|
57
|
-
### TypeScript
|
|
58
|
-
|
|
59
49
|
```typescript
|
|
60
50
|
import { REPLY_TEMPLATE, CHOOSE_OPTION_TEMPLATE } from "@elizaos/prompts";
|
|
61
51
|
|
|
@@ -65,78 +55,29 @@ const prompt = composePrompt({
|
|
|
65
55
|
});
|
|
66
56
|
```
|
|
67
57
|
|
|
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
58
|
## Adding New Prompts
|
|
85
59
|
|
|
86
|
-
1. Create a new `.
|
|
87
|
-
2.
|
|
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.
|
|
60
|
+
1. Create a new `.ts` file in `src/` exporting a `*_TEMPLATE` constant.
|
|
61
|
+
2. Re-export it from `src/index.ts`.
|
|
96
62
|
|
|
97
63
|
## Template Guidelines
|
|
98
64
|
|
|
99
|
-
1. **Start with a task description**
|
|
100
|
-
2. **Include providers placeholder**
|
|
101
|
-
3. **Use
|
|
102
|
-
4. **Add clear instructions**
|
|
103
|
-
5. **End with output format**
|
|
104
|
-
|
|
105
|
-
Example:
|
|
106
|
-
|
|
107
|
-
```txt
|
|
108
|
-
# Task: Generate dialog for the character {{agentName}}.
|
|
65
|
+
1. **Start with a task description** — begin prompts with `# Task:` to state the objective.
|
|
66
|
+
2. **Include providers placeholder** — use `{{providers}}` where provider context should be injected.
|
|
67
|
+
3. **Use JSON output format** — standardize on JSON response format for consistent parsing.
|
|
68
|
+
4. **Add clear instructions** — explicit instructions for the LLM.
|
|
69
|
+
5. **End with output format** — always specify the expected output format.
|
|
109
70
|
|
|
110
|
-
|
|
71
|
+
## Security & Privacy
|
|
111
72
|
|
|
112
|
-
|
|
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.
|
|
73
|
+
- **Do not embed real secrets** in prompt templates. Prompts are source-controlled.
|
|
126
74
|
- **Avoid including PII** (emails, phone numbers, addresses, IDs) in templates or examples.
|
|
127
|
-
- Prefer placeholders (e.g., `{{apiKey}}`, `{{userEmail}}`) and
|
|
75
|
+
- Prefer placeholders (e.g., `{{apiKey}}`, `{{userEmail}}`) and inject only the minimum needed at runtime.
|
|
128
76
|
|
|
129
77
|
### Secret scan
|
|
130
78
|
|
|
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
79
|
```bash
|
|
136
80
|
npm run check:secrets
|
|
137
81
|
```
|
|
138
82
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
- `packages/prompts/prompts/**/*.txt`
|
|
142
|
-
- `plugins/**/prompts/**/*.txt`
|
|
83
|
+
Scans `packages/prompts/src/**/*.ts`, plugin prompt TS modules (paths matching `prompts/**/*.ts`, `workflow-prompts/**/*.ts`, etc.), and a few explicit files — see `scripts/check-secrets.js`.
|