@hasna/prompts 0.3.3 → 0.3.4
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/dist/mcp/index.js +25 -1
- package/package.json +1 -1
package/dist/mcp/index.js
CHANGED
|
@@ -5413,7 +5413,31 @@ server.registerTool("prompts_render", {
|
|
|
5413
5413
|
}, async ({ id, vars, agent }) => {
|
|
5414
5414
|
try {
|
|
5415
5415
|
const prompt = usePrompt(id);
|
|
5416
|
-
const
|
|
5416
|
+
const autoFilled = {};
|
|
5417
|
+
if (agent) {
|
|
5418
|
+
const CONTEXT_VARS = {
|
|
5419
|
+
agent_name: () => agent,
|
|
5420
|
+
agent_id: () => agent,
|
|
5421
|
+
project_id: () => process.env.TODOS_PROJECT_ID || process.env.PROJECT_ID,
|
|
5422
|
+
org_id: () => process.env.ORG_ID,
|
|
5423
|
+
session_id: () => process.env.SESSION_ID,
|
|
5424
|
+
cwd: () => process.cwd(),
|
|
5425
|
+
date: () => new Date().toISOString().split("T")[0],
|
|
5426
|
+
datetime: () => new Date().toISOString()
|
|
5427
|
+
};
|
|
5428
|
+
for (const [key, getter] of Object.entries(CONTEXT_VARS)) {
|
|
5429
|
+
if (!(key in vars)) {
|
|
5430
|
+
const val = getter();
|
|
5431
|
+
if (val)
|
|
5432
|
+
autoFilled[key] = val;
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
5436
|
+
const mergedVars = { ...autoFilled, ...vars };
|
|
5437
|
+
const result = renderTemplate(prompt.body, mergedVars);
|
|
5438
|
+
if (Object.keys(autoFilled).length > 0) {
|
|
5439
|
+
result.auto_filled = autoFilled;
|
|
5440
|
+
}
|
|
5417
5441
|
await maybeSaveMemento({ slug: prompt.slug, body: prompt.body, rendered: result.rendered, agentId: agent });
|
|
5418
5442
|
return ok(result);
|
|
5419
5443
|
} catch (e) {
|