@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
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Secret/credential scanner for prompt templates.
|
|
4
|
+
*
|
|
5
|
+
* This is intentionally conservative: it only fails on patterns that strongly
|
|
6
|
+
* resemble real credentials (or private key material) to avoid false positives.
|
|
7
|
+
*
|
|
8
|
+
* Scans:
|
|
9
|
+
* - all .txt files under packages/prompts/prompts/
|
|
10
|
+
* - all .txt files under plugin prompt folders (if plugins/ exists)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import fs from "node:fs/promises";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = path.dirname(__filename);
|
|
19
|
+
|
|
20
|
+
const PROMPTS_PKG_DIR = path.resolve(__dirname, "..");
|
|
21
|
+
const REPO_ROOT = path.resolve(PROMPTS_PKG_DIR, "..", "..");
|
|
22
|
+
|
|
23
|
+
const PROMPTS_DIR = path.join(PROMPTS_PKG_DIR, "prompts");
|
|
24
|
+
const PLUGINS_DIR = path.join(REPO_ROOT, "plugins");
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} dir
|
|
28
|
+
* @returns {Promise<string[]>}
|
|
29
|
+
*/
|
|
30
|
+
async function listPromptTxtFiles(dir) {
|
|
31
|
+
/** @type {string[]} */
|
|
32
|
+
const out = [];
|
|
33
|
+
|
|
34
|
+
/** @param {string} current */
|
|
35
|
+
async function walk(current) {
|
|
36
|
+
const entries = await fs.readdir(current, { withFileTypes: true });
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const full = path.join(current, entry.name);
|
|
39
|
+
if (entry.isDirectory()) {
|
|
40
|
+
await walk(full);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (entry.isFile() && entry.name.endsWith(".txt")) {
|
|
44
|
+
out.push(full);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await walk(dir);
|
|
51
|
+
} catch (_e) {
|
|
52
|
+
// Directory might not exist (e.g., plugins/ in minimal checkouts).
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {string} filePath
|
|
60
|
+
* @param {string} content
|
|
61
|
+
* @returns {{errors: string[], warnings: string[]}}
|
|
62
|
+
*/
|
|
63
|
+
function scanContent(filePath, content) {
|
|
64
|
+
/** @type {string[]} */
|
|
65
|
+
const errors = [];
|
|
66
|
+
/** @type {string[]} */
|
|
67
|
+
const warnings = [];
|
|
68
|
+
|
|
69
|
+
const lines = content.split(/\r?\n/);
|
|
70
|
+
|
|
71
|
+
/** @type {Array<{name: string, re: RegExp, severity: "error" | "warning"}>} */
|
|
72
|
+
const rules = [
|
|
73
|
+
{
|
|
74
|
+
name: "Private key material",
|
|
75
|
+
re: /-----BEGIN (?:RSA |EC |OPENSSH |)PRIVATE KEY-----/,
|
|
76
|
+
severity: "error",
|
|
77
|
+
},
|
|
78
|
+
{ name: "GitHub token", re: /\bghp_[A-Za-z0-9]{20,}\b/, severity: "error" },
|
|
79
|
+
{
|
|
80
|
+
name: "GitHub fine-grained token",
|
|
81
|
+
re: /\bgithub_pat_[A-Za-z0-9_]{20,}\b/,
|
|
82
|
+
severity: "error",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "Slack token",
|
|
86
|
+
re: /\bxox[baprs]-[A-Za-z0-9-]{10,}\b/,
|
|
87
|
+
severity: "error",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "AWS access key id",
|
|
91
|
+
re: /\bAKIA[0-9A-Z]{16}\b/,
|
|
92
|
+
severity: "error",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "Google API key",
|
|
96
|
+
re: /\bAIza[0-9A-Za-z\-_]{30,}\b/,
|
|
97
|
+
severity: "error",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "OpenAI-style key",
|
|
101
|
+
re: /\bsk-[A-Za-z0-9]{20,}\b/,
|
|
102
|
+
severity: "error",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "Anthropic-style key",
|
|
106
|
+
re: /\bsk-ant-[A-Za-z0-9\-_]{20,}\b/,
|
|
107
|
+
severity: "error",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "Generic credential assignment (review)",
|
|
111
|
+
re: /\b[A-Z0-9_]*(?:API_KEY|APIKEY|TOKEN|SECRET|PASSWORD|PASSWD|PRIVATE_KEY)[A-Z0-9_]*\s*=\s*["']?[^"'\s]{8,}/,
|
|
112
|
+
severity: "warning",
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
for (let i = 0; i < lines.length; i++) {
|
|
117
|
+
const line = lines[i];
|
|
118
|
+
for (const rule of rules) {
|
|
119
|
+
if (rule.re.test(line)) {
|
|
120
|
+
const msg = `${filePath}:${i + 1} ${rule.name}: ${line.trim()}`;
|
|
121
|
+
if (rule.severity === "error") errors.push(msg);
|
|
122
|
+
else warnings.push(msg);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return { errors, warnings };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function main() {
|
|
131
|
+
const promptFiles = await listPromptTxtFiles(PROMPTS_DIR);
|
|
132
|
+
|
|
133
|
+
/** @type {string[]} */
|
|
134
|
+
let pluginPromptFiles = [];
|
|
135
|
+
try {
|
|
136
|
+
const pluginEntries = await fs.readdir(PLUGINS_DIR, {
|
|
137
|
+
withFileTypes: true,
|
|
138
|
+
});
|
|
139
|
+
for (const entry of pluginEntries) {
|
|
140
|
+
if (!entry.isDirectory()) continue;
|
|
141
|
+
const candidate = path.join(PLUGINS_DIR, entry.name, "prompts");
|
|
142
|
+
const files = await listPromptTxtFiles(candidate);
|
|
143
|
+
pluginPromptFiles = pluginPromptFiles.concat(files);
|
|
144
|
+
}
|
|
145
|
+
} catch {
|
|
146
|
+
// plugins directory missing; ok.
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const allFiles = [...promptFiles, ...pluginPromptFiles].sort();
|
|
150
|
+
|
|
151
|
+
/** @type {string[]} */
|
|
152
|
+
const errors = [];
|
|
153
|
+
/** @type {string[]} */
|
|
154
|
+
const warnings = [];
|
|
155
|
+
|
|
156
|
+
for (const file of allFiles) {
|
|
157
|
+
const content = await fs.readFile(file, "utf-8");
|
|
158
|
+
const result = scanContent(file, content);
|
|
159
|
+
errors.push(...result.errors);
|
|
160
|
+
warnings.push(...result.warnings);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (warnings.length > 0) {
|
|
164
|
+
// eslint-disable-next-line no-console
|
|
165
|
+
console.warn("\nPrompt secret scan warnings (review recommended):\n");
|
|
166
|
+
for (const w of warnings) {
|
|
167
|
+
// eslint-disable-next-line no-console
|
|
168
|
+
console.warn(`- ${w}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (errors.length > 0) {
|
|
173
|
+
// eslint-disable-next-line no-console
|
|
174
|
+
console.error("\nPrompt secret scan errors (must fix):\n");
|
|
175
|
+
for (const e of errors) {
|
|
176
|
+
// eslint-disable-next-line no-console
|
|
177
|
+
console.error(`- ${e}`);
|
|
178
|
+
}
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
main().catch((err) => {
|
|
184
|
+
// eslint-disable-next-line no-console
|
|
185
|
+
console.error(err);
|
|
186
|
+
process.exit(2);
|
|
187
|
+
});
|