@paperclipai/hermes-paperclip-adapter 0.3.0
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 +228 -0
- package/dist/cli/format-event.d.ts +14 -0
- package/dist/cli/format-event.d.ts.map +1 -0
- package/dist/cli/format-event.js +52 -0
- package/dist/cli/format-event.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +5 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +14 -0
- package/dist/index.test.js.map +1 -0
- package/dist/server/command-resolution.test.d.ts +2 -0
- package/dist/server/command-resolution.test.d.ts.map +1 -0
- package/dist/server/command-resolution.test.js +37 -0
- package/dist/server/command-resolution.test.js.map +1 -0
- package/dist/server/detect-model.d.ts +77 -0
- package/dist/server/detect-model.d.ts.map +1 -0
- package/dist/server/detect-model.js +158 -0
- package/dist/server/detect-model.js.map +1 -0
- package/dist/server/detect-model.test.d.ts +2 -0
- package/dist/server/detect-model.test.d.ts.map +1 -0
- package/dist/server/detect-model.test.js +166 -0
- package/dist/server/detect-model.test.js.map +1 -0
- package/dist/server/execute.d.ts +23 -0
- package/dist/server/execute.d.ts.map +1 -0
- package/dist/server/execute.js +482 -0
- package/dist/server/execute.js.map +1 -0
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +43 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/skills.d.ts +8 -0
- package/dist/server/skills.d.ts.map +1 -0
- package/dist/server/skills.js +177 -0
- package/dist/server/skills.js.map +1 -0
- package/dist/server/test.d.ts +9 -0
- package/dist/server/test.d.ts.map +1 -0
- package/dist/server/test.js +341 -0
- package/dist/server/test.js.map +1 -0
- package/dist/shared/constants.d.ts +47 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +91 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/ui/build-config.d.ts +17 -0
- package/dist/ui/build-config.d.ts.map +1 -0
- package/dist/ui/build-config.js +69 -0
- package/dist/ui/build-config.js.map +1 -0
- package/dist/ui/index.d.ts +7 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +7 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/parse-stdout.d.ts +25 -0
- package/dist/ui/parse-stdout.d.ts.map +1 -0
- package/dist/ui/parse-stdout.js +237 -0
- package/dist/ui/parse-stdout.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side execution logic for the Hermes Agent adapter.
|
|
3
|
+
*
|
|
4
|
+
* Spawns `hermes chat -q "..." -Q` as a child process, streams output,
|
|
5
|
+
* and returns structured results to Paperclip.
|
|
6
|
+
*
|
|
7
|
+
* Verified CLI flags (hermes chat):
|
|
8
|
+
* -q/--query single query (non-interactive)
|
|
9
|
+
* -Q/--quiet quiet mode (no banner/spinner, only response + session_id)
|
|
10
|
+
* -m/--model model name (e.g. anthropic/claude-sonnet-4)
|
|
11
|
+
* -t/--toolsets comma-separated toolsets to enable
|
|
12
|
+
* --provider inference provider (auto, openrouter, nous, etc.)
|
|
13
|
+
* -r/--resume resume session by ID
|
|
14
|
+
* -w/--worktree isolated git worktree
|
|
15
|
+
* -v/--verbose verbose output
|
|
16
|
+
* --checkpoints filesystem checkpoints
|
|
17
|
+
* --yolo bypass dangerous-command approval prompts (agents have no TTY)
|
|
18
|
+
* --source session source tag for filtering
|
|
19
|
+
*/
|
|
20
|
+
import fs from "node:fs/promises";
|
|
21
|
+
import path from "node:path";
|
|
22
|
+
import { runChildProcess, buildPaperclipEnv, renderTemplate, ensureAbsoluteDirectory, } from "@paperclipai/adapter-utils/server-utils";
|
|
23
|
+
import { HERMES_CLI, DEFAULT_TIMEOUT_SEC, DEFAULT_GRACE_SEC, DEFAULT_MODEL, } from "../shared/constants.js";
|
|
24
|
+
import { detectModel, resolveProvider, } from "./detect-model.js";
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Config helpers
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
function cfgString(v) {
|
|
29
|
+
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
30
|
+
}
|
|
31
|
+
function cfgNumber(v) {
|
|
32
|
+
return typeof v === "number" ? v : undefined;
|
|
33
|
+
}
|
|
34
|
+
function cfgBoolean(v) {
|
|
35
|
+
return typeof v === "boolean" ? v : undefined;
|
|
36
|
+
}
|
|
37
|
+
function cfgStringArray(v) {
|
|
38
|
+
return Array.isArray(v) && v.every((i) => typeof i === "string")
|
|
39
|
+
? v
|
|
40
|
+
: undefined;
|
|
41
|
+
}
|
|
42
|
+
export function resolveHermesCommand(config) {
|
|
43
|
+
return cfgString(config.hermesCommand) || cfgString(config.command) || HERMES_CLI;
|
|
44
|
+
}
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Wake-up prompt builder
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
const DEFAULT_PROMPT_TEMPLATE = `You are "{{agentName}}", an AI agent employee in a Paperclip-managed company.
|
|
49
|
+
|
|
50
|
+
IMPORTANT: Use \`terminal\` tool with \`curl\` for ALL Paperclip API calls (web_extract and browser cannot access localhost).
|
|
51
|
+
|
|
52
|
+
Your Paperclip identity:
|
|
53
|
+
Agent ID: {{agentId}}
|
|
54
|
+
Company ID: {{companyId}}
|
|
55
|
+
API Base: {{paperclipApiUrl}}
|
|
56
|
+
|
|
57
|
+
{{#taskId}}
|
|
58
|
+
## Assigned Task
|
|
59
|
+
|
|
60
|
+
Issue ID: {{taskId}}
|
|
61
|
+
Title: {{taskTitle}}
|
|
62
|
+
|
|
63
|
+
{{taskBody}}
|
|
64
|
+
|
|
65
|
+
## Workflow
|
|
66
|
+
|
|
67
|
+
0. First, check out the issue so others know you are working on it:
|
|
68
|
+
\`curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" -H "X-Paperclip-Run-Id: $PAPERCLIP_RUN_ID" "{{paperclipApiUrl}}/issues/{{taskId}}/checkout"\`
|
|
69
|
+
1. Work on the task using your tools
|
|
70
|
+
2. When done, mark the issue as completed:
|
|
71
|
+
\`curl -s -X PATCH -H "Authorization: Bearer $PAPERCLIP_API_KEY" -H "X-Paperclip-Run-Id: $PAPERCLIP_RUN_ID" "{{paperclipApiUrl}}/issues/{{taskId}}" -H "Content-Type: application/json" -d '{"status":"done"}'\`
|
|
72
|
+
3. Post a completion comment on the issue summarizing what you did:
|
|
73
|
+
\`curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" -H "X-Paperclip-Run-Id: $PAPERCLIP_RUN_ID" "{{paperclipApiUrl}}/issues/{{taskId}}/comments" -H "Content-Type: application/json" -d '{"body":"DONE: <your summary here>"}'\`
|
|
74
|
+
4. If this issue has a parent (check the issue body or comments for references like TRA-XX), post a brief notification on the parent issue so the parent owner knows:
|
|
75
|
+
\`curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" -H "X-Paperclip-Run-Id: $PAPERCLIP_RUN_ID" "{{paperclipApiUrl}}/issues/PARENT_ISSUE_ID/comments" -H "Content-Type: application/json" -d '{"body":"{{agentName}} completed {{taskId}}. Summary: <brief>"}'\`
|
|
76
|
+
{{/taskId}}
|
|
77
|
+
|
|
78
|
+
{{#commentId}}
|
|
79
|
+
## Comment on This Issue
|
|
80
|
+
|
|
81
|
+
Someone commented. Read it:
|
|
82
|
+
\`curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" "{{paperclipApiUrl}}/issues/{{taskId}}/comments/{{commentId}}"\`
|
|
83
|
+
|
|
84
|
+
You do NOT need to be assigned to this issue to comment on it.
|
|
85
|
+
Address the comment, POST a reply if needed, then continue working.
|
|
86
|
+
{{/commentId}}
|
|
87
|
+
|
|
88
|
+
{{#noTask}}
|
|
89
|
+
## Heartbeat Wake — Check for Work
|
|
90
|
+
|
|
91
|
+
First, check your environment for context:
|
|
92
|
+
\`echo "TASK_ID=$PAPERCLIP_TASK_ID WAKE_REASON=$PAPERCLIP_WAKE_REASON WAKE_COMMENT_ID=$PAPERCLIP_WAKE_COMMENT_ID"\`
|
|
93
|
+
|
|
94
|
+
1. List ALL open issues assigned to you (todo, backlog, in_progress):
|
|
95
|
+
\`curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" "{{paperclipApiUrl}}/companies/{{companyId}}/issues?assigneeAgentId={{agentId}}" | python3 -c "import sys,json;issues=json.loads(sys.stdin.read());[print(f\\"{i['identifier']} {i['status']:>12} {i['priority']:>6} {i['title']}\\") for i in issues if i['status'] not in ('done','cancelled')]" \`
|
|
96
|
+
|
|
97
|
+
2. If issues found, pick the highest priority one that is not done/cancelled and work on it:
|
|
98
|
+
- Read the issue details: \`curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" "{{paperclipApiUrl}}/issues/ISSUE_ID"\`
|
|
99
|
+
- Do the work in the project directory: {{projectName}}
|
|
100
|
+
- When done, mark complete and post a comment (see Workflow steps 2-4 above)
|
|
101
|
+
|
|
102
|
+
3. If no issues assigned to you, check for unassigned issues:
|
|
103
|
+
\`curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" "{{paperclipApiUrl}}/companies/{{companyId}}/issues?status=backlog" | python3 -c "import sys,json;issues=json.loads(sys.stdin.read());[print(f\\"{i['identifier']} {i['title']}\\") for i in issues if not i.get('assigneeAgentId')]" \`
|
|
104
|
+
If you find a relevant issue, assign it to yourself:
|
|
105
|
+
\`curl -s -X PATCH -H "Authorization: Bearer $PAPERCLIP_API_KEY" -H "X-Paperclip-Run-Id: $PAPERCLIP_RUN_ID" "{{paperclipApiUrl}}/issues/ISSUE_ID" -H "Content-Type: application/json" -d '{"assigneeAgentId":"{{agentId}}","status":"todo"}'\`
|
|
106
|
+
|
|
107
|
+
4. If truly nothing to do, report briefly what you checked.
|
|
108
|
+
{{/noTask}}`;
|
|
109
|
+
function buildPrompt(ctx, config) {
|
|
110
|
+
const template = cfgString(config.promptTemplate) || DEFAULT_PROMPT_TEMPLATE;
|
|
111
|
+
// BUG FIX: Read task/comment data from ctx.context (wake context), not ctx.config (adapter config).
|
|
112
|
+
// ctx.config only contains adapterConfig (model, provider, timeout); ctx.context has the wake payload.
|
|
113
|
+
const context = ctx.context || {};
|
|
114
|
+
const taskId = cfgString(context.taskId) || cfgString(context.issueId) || cfgString(ctx.config?.taskId);
|
|
115
|
+
const taskTitle = cfgString(context.taskTitle) || cfgString(ctx.config?.taskTitle) || "";
|
|
116
|
+
const taskBody = cfgString(context.taskBody) || cfgString(ctx.config?.taskBody) || "";
|
|
117
|
+
const commentId = cfgString(context.commentId) || cfgString(context.wakeCommentId) || cfgString(ctx.config?.commentId) || "";
|
|
118
|
+
const wakeReason = cfgString(context.wakeReason) || cfgString(ctx.config?.wakeReason) || "";
|
|
119
|
+
const agentName = ctx.agent?.name || "Hermes Agent";
|
|
120
|
+
const companyName = cfgString(context.companyName) || cfgString(ctx.config?.companyName) || "";
|
|
121
|
+
const projectName = cfgString(context.projectName) || cfgString(ctx.config?.projectName) || "";
|
|
122
|
+
// Build API URL — ensure it has the /api path
|
|
123
|
+
let paperclipApiUrl = cfgString(config.paperclipApiUrl) ||
|
|
124
|
+
process.env.PAPERCLIP_API_URL ||
|
|
125
|
+
"http://127.0.0.1:3100/api";
|
|
126
|
+
// Ensure /api suffix
|
|
127
|
+
if (!paperclipApiUrl.endsWith("/api")) {
|
|
128
|
+
paperclipApiUrl = paperclipApiUrl.replace(/\/+$/, "") + "/api";
|
|
129
|
+
}
|
|
130
|
+
const vars = {
|
|
131
|
+
agentId: ctx.agent?.id || "",
|
|
132
|
+
agentName,
|
|
133
|
+
companyId: ctx.agent?.companyId || "",
|
|
134
|
+
companyName,
|
|
135
|
+
runId: ctx.runId || "",
|
|
136
|
+
taskId: taskId || "",
|
|
137
|
+
taskTitle,
|
|
138
|
+
taskBody,
|
|
139
|
+
commentId,
|
|
140
|
+
wakeReason,
|
|
141
|
+
projectName,
|
|
142
|
+
paperclipApiUrl,
|
|
143
|
+
};
|
|
144
|
+
// Handle conditional sections: {{#key}}...{{/key}}
|
|
145
|
+
let rendered = template;
|
|
146
|
+
// {{#taskId}}...{{/taskId}} — include if task is assigned
|
|
147
|
+
rendered = rendered.replace(/\{\{#taskId\}\}([\s\S]*?)\{\{\/taskId\}\}/g, taskId ? "$1" : "");
|
|
148
|
+
// {{#noTask}}...{{/noTask}} — include if no task
|
|
149
|
+
rendered = rendered.replace(/\{\{#noTask\}\}([\s\S]*?)\{\{\/noTask\}\}/g, taskId ? "" : "$1");
|
|
150
|
+
// {{#commentId}}...{{/commentId}} — include if comment exists
|
|
151
|
+
rendered = rendered.replace(/\{\{#commentId\}\}([\s\S]*?)\{\{\/commentId\}\}/g, commentId ? "$1" : "");
|
|
152
|
+
// Replace remaining {{variable}} placeholders
|
|
153
|
+
return renderTemplate(rendered, vars);
|
|
154
|
+
}
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
// Output parsing
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
/** Regex to extract session ID from Hermes quiet-mode output: "session_id: <id>" */
|
|
159
|
+
const SESSION_ID_REGEX = /^session_id:\s*(\S+)/m;
|
|
160
|
+
/** Regex for legacy session output format */
|
|
161
|
+
const SESSION_ID_REGEX_LEGACY = /session[_ ](?:id|saved)[:\s]+([a-zA-Z0-9_-]+)/i;
|
|
162
|
+
/** Regex to extract token usage from Hermes output. */
|
|
163
|
+
const TOKEN_USAGE_REGEX = /tokens?[:\s]+(\d+)\s*(?:input|in)\b.*?(\d+)\s*(?:output|out)\b/i;
|
|
164
|
+
/** Regex to extract cost from Hermes output. */
|
|
165
|
+
const COST_REGEX = /(?:cost|spent)[:\s]*\$?([\d.]+)/i;
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
// Response cleaning
|
|
168
|
+
// ---------------------------------------------------------------------------
|
|
169
|
+
/** Strip noise lines from a Hermes response (tool output, system messages, etc.) */
|
|
170
|
+
function cleanResponse(raw) {
|
|
171
|
+
return raw
|
|
172
|
+
.split("\n")
|
|
173
|
+
.filter((line) => {
|
|
174
|
+
const t = line.trim();
|
|
175
|
+
if (!t)
|
|
176
|
+
return true; // keep blank lines for paragraph separation
|
|
177
|
+
if (t.startsWith("[tool]") || t.startsWith("[hermes]") || t.startsWith("[paperclip]"))
|
|
178
|
+
return false;
|
|
179
|
+
if (t.startsWith("session_id:"))
|
|
180
|
+
return false;
|
|
181
|
+
if (/^\[\d{4}-\d{2}-\d{2}T/.test(t))
|
|
182
|
+
return false;
|
|
183
|
+
if (/^\[done\]\s*┊/.test(t))
|
|
184
|
+
return false;
|
|
185
|
+
if (/^┊\s*[\p{Emoji_Presentation}]/u.test(t) && !/^┊\s*💬/.test(t))
|
|
186
|
+
return false;
|
|
187
|
+
if (/^\p{Emoji_Presentation}\s*(Completed|Running|Error)?\s*$/u.test(t))
|
|
188
|
+
return false;
|
|
189
|
+
return true;
|
|
190
|
+
})
|
|
191
|
+
.map((line) => {
|
|
192
|
+
let t = line.replace(/^[\s]*┊\s*💬\s*/, "").trim();
|
|
193
|
+
t = t.replace(/^\[done\]\s*/, "").trim();
|
|
194
|
+
return t;
|
|
195
|
+
})
|
|
196
|
+
.join("\n")
|
|
197
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
198
|
+
.trim();
|
|
199
|
+
}
|
|
200
|
+
// ---------------------------------------------------------------------------
|
|
201
|
+
// Output parsing
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
function parseHermesOutput(stdout, stderr) {
|
|
204
|
+
const combined = stdout + "\n" + stderr;
|
|
205
|
+
const result = {};
|
|
206
|
+
// In quiet mode, Hermes outputs:
|
|
207
|
+
// <response text>
|
|
208
|
+
//
|
|
209
|
+
// session_id: <id>
|
|
210
|
+
const sessionMatch = stdout.match(SESSION_ID_REGEX);
|
|
211
|
+
if (sessionMatch?.[1]) {
|
|
212
|
+
result.sessionId = sessionMatch?.[1] ?? null;
|
|
213
|
+
// The response is everything before the session_id line
|
|
214
|
+
const sessionLineIdx = stdout.lastIndexOf("\nsession_id:");
|
|
215
|
+
if (sessionLineIdx > 0) {
|
|
216
|
+
result.response = cleanResponse(stdout.slice(0, sessionLineIdx));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
// Legacy format (non-quiet mode)
|
|
221
|
+
const legacyMatch = combined.match(SESSION_ID_REGEX_LEGACY);
|
|
222
|
+
if (legacyMatch?.[1]) {
|
|
223
|
+
result.sessionId = legacyMatch?.[1] ?? null;
|
|
224
|
+
}
|
|
225
|
+
// In non-quiet mode, extract clean response from stdout by
|
|
226
|
+
// filtering out tool lines, system messages, and noise
|
|
227
|
+
const cleaned = cleanResponse(stdout);
|
|
228
|
+
if (cleaned.length > 0) {
|
|
229
|
+
result.response = cleaned;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// Extract token usage
|
|
233
|
+
const usageMatch = combined.match(TOKEN_USAGE_REGEX);
|
|
234
|
+
if (usageMatch) {
|
|
235
|
+
result.usage = {
|
|
236
|
+
inputTokens: parseInt(usageMatch[1], 10) || 0,
|
|
237
|
+
outputTokens: parseInt(usageMatch[2], 10) || 0,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
// Extract cost
|
|
241
|
+
const costMatch = combined.match(COST_REGEX);
|
|
242
|
+
if (costMatch?.[1]) {
|
|
243
|
+
result.costUsd = parseFloat(costMatch[1]);
|
|
244
|
+
}
|
|
245
|
+
// Check for error patterns in stderr
|
|
246
|
+
if (stderr.trim()) {
|
|
247
|
+
const errorLines = stderr
|
|
248
|
+
.split("\n")
|
|
249
|
+
.filter((line) => /error|exception|traceback|failed/i.test(line))
|
|
250
|
+
.filter((line) => !/INFO|DEBUG|warn/i.test(line)); // skip log-level noise
|
|
251
|
+
if (errorLines.length > 0) {
|
|
252
|
+
result.errorMessage = errorLines.slice(0, 5).join("\n");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
// ---------------------------------------------------------------------------
|
|
258
|
+
// Main execute
|
|
259
|
+
// ---------------------------------------------------------------------------
|
|
260
|
+
export async function execute(ctx) {
|
|
261
|
+
const config = (ctx.config ?? ctx.agent?.adapterConfig ?? {});
|
|
262
|
+
// ── Resolve configuration ──────────────────────────────────────────────
|
|
263
|
+
const hermesCmd = resolveHermesCommand(config);
|
|
264
|
+
const model = cfgString(config.model) || DEFAULT_MODEL;
|
|
265
|
+
const timeoutSec = cfgNumber(config.timeoutSec) || DEFAULT_TIMEOUT_SEC;
|
|
266
|
+
const graceSec = cfgNumber(config.graceSec) || DEFAULT_GRACE_SEC;
|
|
267
|
+
const maxTurns = cfgNumber(config.maxTurnsPerRun);
|
|
268
|
+
const toolsets = cfgString(config.toolsets) || cfgStringArray(config.enabledToolsets)?.join(",");
|
|
269
|
+
const extraArgs = cfgStringArray(config.extraArgs);
|
|
270
|
+
const persistSession = cfgBoolean(config.persistSession) !== false;
|
|
271
|
+
const worktreeMode = cfgBoolean(config.worktreeMode) === true;
|
|
272
|
+
const checkpoints = cfgBoolean(config.checkpoints) === true;
|
|
273
|
+
// ── Resolve provider (defense in depth) ────────────────────────────────
|
|
274
|
+
// Priority chain:
|
|
275
|
+
// 1. Explicit provider in adapterConfig (user override)
|
|
276
|
+
// 2. Provider from ~/.hermes/config.yaml (detected at runtime)
|
|
277
|
+
// 3. Provider inferred from model name prefix
|
|
278
|
+
// 4. "auto" (let Hermes decide)
|
|
279
|
+
//
|
|
280
|
+
// This ensures that even if the agent was created before provider tracking
|
|
281
|
+
// was added, or if the model was changed without updating provider, the
|
|
282
|
+
// correct provider is still used.
|
|
283
|
+
let detectedConfig = null;
|
|
284
|
+
const explicitProvider = cfgString(config.provider);
|
|
285
|
+
if (!explicitProvider) {
|
|
286
|
+
try {
|
|
287
|
+
detectedConfig = await detectModel();
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
// Non-fatal — detection failure shouldn't block execution
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const { provider: resolvedProvider, resolvedFrom } = resolveProvider({
|
|
294
|
+
explicitProvider,
|
|
295
|
+
detectedProvider: detectedConfig?.provider,
|
|
296
|
+
detectedModel: detectedConfig?.model,
|
|
297
|
+
detectedBaseUrl: detectedConfig?.baseUrl,
|
|
298
|
+
detectedHasApiKey: detectedConfig?.hasApiKey,
|
|
299
|
+
detectedApiMode: detectedConfig?.apiMode,
|
|
300
|
+
model,
|
|
301
|
+
});
|
|
302
|
+
// ── Load agent instructions file (Paperclip instruction bundles) ──────
|
|
303
|
+
// Built-in adapters (claude_local, codex_local, gemini_local) read the
|
|
304
|
+
// instructionsFilePath from adapterConfig and inject it into the agent
|
|
305
|
+
// prompt. The hermes adapter was missing this — so curated instruction
|
|
306
|
+
// files (AGENTS.md, SOUL.md, HEARTBEAT.md, TOOLS.md) were never read.
|
|
307
|
+
const instructionsFilePath = cfgString(config.instructionsFilePath);
|
|
308
|
+
let agentInstructions = "";
|
|
309
|
+
if (instructionsFilePath) {
|
|
310
|
+
try {
|
|
311
|
+
agentInstructions = await fs.readFile(instructionsFilePath, "utf-8");
|
|
312
|
+
const loadedInstructionsLength = agentInstructions.length;
|
|
313
|
+
const instructionsFileDir = path.dirname(instructionsFilePath);
|
|
314
|
+
agentInstructions += `\nThe above agent instructions were loaded from ${instructionsFilePath}. Resolve any relative file references from ${instructionsFileDir}/.`;
|
|
315
|
+
await ctx.onLog("stdout", `[hermes] Loaded agent instructions from ${instructionsFilePath} (${loadedInstructionsLength} chars)\n`);
|
|
316
|
+
}
|
|
317
|
+
catch (err) {
|
|
318
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
319
|
+
// Non-fatal: log to stdout with an explicit "Warning:" prefix so the
|
|
320
|
+
// Paperclip UI doesn't render this as a red error (stderr output is
|
|
321
|
+
// surfaced as an error signal even when execution continues).
|
|
322
|
+
await ctx.onLog("stdout", `[hermes] Warning: could not read agent instructions file "${instructionsFilePath}": ${reason}\n`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
// ── Build prompt ───────────────────────────────────────────────────────
|
|
326
|
+
let prompt = buildPrompt(ctx, config);
|
|
327
|
+
if (agentInstructions) {
|
|
328
|
+
prompt = agentInstructions + "\n\n---\n\n" + prompt;
|
|
329
|
+
}
|
|
330
|
+
// ── Build command args ─────────────────────────────────────────────────
|
|
331
|
+
// Use -Q (quiet) to get clean output: just response + session_id line
|
|
332
|
+
const useQuiet = cfgBoolean(config.quiet) === true; // default false
|
|
333
|
+
const args = ["chat", "-q", prompt];
|
|
334
|
+
if (useQuiet)
|
|
335
|
+
args.push("-Q");
|
|
336
|
+
if (model) {
|
|
337
|
+
args.push("-m", model);
|
|
338
|
+
}
|
|
339
|
+
// Always pass --provider when we have a resolved one (not "auto").
|
|
340
|
+
// "auto" means Hermes will decide on its own — no need to pass it.
|
|
341
|
+
if (resolvedProvider !== "auto") {
|
|
342
|
+
args.push("--provider", resolvedProvider);
|
|
343
|
+
}
|
|
344
|
+
if (toolsets) {
|
|
345
|
+
args.push("-t", toolsets);
|
|
346
|
+
}
|
|
347
|
+
if (maxTurns && maxTurns > 0) {
|
|
348
|
+
args.push("--max-turns", String(maxTurns));
|
|
349
|
+
}
|
|
350
|
+
if (worktreeMode)
|
|
351
|
+
args.push("-w");
|
|
352
|
+
if (checkpoints)
|
|
353
|
+
args.push("--checkpoints");
|
|
354
|
+
if (cfgBoolean(config.verbose) === true)
|
|
355
|
+
args.push("-v");
|
|
356
|
+
// Tag sessions as "tool" source so they don't clutter the user's session history.
|
|
357
|
+
// Requires hermes-agent >= PR #3255 (feat/session-source-tag).
|
|
358
|
+
args.push("--source", "tool");
|
|
359
|
+
// Bypass Hermes dangerous-command approval prompts.
|
|
360
|
+
// Paperclip agents run as non-interactive subprocesses with no TTY,
|
|
361
|
+
// so approval prompts would always timeout and deny legitimate commands
|
|
362
|
+
// (curl, python3 -c, etc.). Agents operate in a sandbox — the approval
|
|
363
|
+
// system is designed for human-attended interactive sessions.
|
|
364
|
+
args.push("--yolo");
|
|
365
|
+
// Session resume
|
|
366
|
+
const prevSessionId = cfgString(ctx.runtime?.sessionParams?.sessionId);
|
|
367
|
+
if (persistSession && prevSessionId) {
|
|
368
|
+
args.push("--resume", prevSessionId);
|
|
369
|
+
}
|
|
370
|
+
if (extraArgs?.length) {
|
|
371
|
+
args.push(...extraArgs);
|
|
372
|
+
}
|
|
373
|
+
// ── Build environment ──────────────────────────────────────────────────
|
|
374
|
+
const env = {
|
|
375
|
+
...process.env,
|
|
376
|
+
...buildPaperclipEnv(ctx.agent),
|
|
377
|
+
};
|
|
378
|
+
if (ctx.runId)
|
|
379
|
+
env.PAPERCLIP_RUN_ID = ctx.runId;
|
|
380
|
+
// BUG FIX: Inject authToken as PAPERCLIP_API_KEY (matches adapter-claude-local behavior)
|
|
381
|
+
if (ctx.authToken)
|
|
382
|
+
env.PAPERCLIP_API_KEY = ctx.authToken;
|
|
383
|
+
// BUG FIX: Read task context from ctx.context (wake context), not ctx.config (adapter config)
|
|
384
|
+
const ctxContext = ctx.context || {};
|
|
385
|
+
const envTaskId = cfgString(ctxContext.taskId) || cfgString(ctxContext.issueId) || cfgString(ctx.config?.taskId);
|
|
386
|
+
if (envTaskId)
|
|
387
|
+
env.PAPERCLIP_TASK_ID = envTaskId;
|
|
388
|
+
const envWakeReason = cfgString(ctxContext.wakeReason) || cfgString(ctx.config?.wakeReason);
|
|
389
|
+
if (envWakeReason)
|
|
390
|
+
env.PAPERCLIP_WAKE_REASON = envWakeReason;
|
|
391
|
+
const envCommentId = cfgString(ctxContext.commentId) || cfgString(ctxContext.wakeCommentId) || cfgString(ctx.config?.commentId);
|
|
392
|
+
if (envCommentId)
|
|
393
|
+
env.PAPERCLIP_WAKE_COMMENT_ID = envCommentId;
|
|
394
|
+
const userEnv = config.env;
|
|
395
|
+
if (userEnv && typeof userEnv === "object") {
|
|
396
|
+
Object.assign(env, userEnv);
|
|
397
|
+
}
|
|
398
|
+
// ── Resolve working directory ──────────────────────────────────────────
|
|
399
|
+
const cwd = cfgString(config.cwd) || cfgString(ctx.config?.workspaceDir) || ".";
|
|
400
|
+
try {
|
|
401
|
+
await ensureAbsoluteDirectory(cwd);
|
|
402
|
+
}
|
|
403
|
+
catch {
|
|
404
|
+
// Non-fatal
|
|
405
|
+
}
|
|
406
|
+
// ── Log start ──────────────────────────────────────────────────────────
|
|
407
|
+
await ctx.onLog("stdout", `[hermes] Starting Hermes Agent (model=${model}, provider=${resolvedProvider} [${resolvedFrom}], timeout=${timeoutSec}s${maxTurns ? `, max_turns=${maxTurns}` : ""})\n`);
|
|
408
|
+
if (prevSessionId) {
|
|
409
|
+
await ctx.onLog("stdout", `[hermes] Resuming session: ${prevSessionId}\n`);
|
|
410
|
+
}
|
|
411
|
+
// ── Execute ────────────────────────────────────────────────────────────
|
|
412
|
+
// Hermes writes non-error noise to stderr (MCP init, INFO logs, etc).
|
|
413
|
+
// Paperclip renders all stderr as red/error in the UI.
|
|
414
|
+
// Wrap onLog to reclassify benign stderr lines as stdout.
|
|
415
|
+
const wrappedOnLog = async (stream, chunk) => {
|
|
416
|
+
if (stream === "stderr") {
|
|
417
|
+
const trimmed = chunk.trimEnd();
|
|
418
|
+
// Benign patterns that should NOT appear as errors:
|
|
419
|
+
// - Structured log lines: [timestamp] INFO/DEBUG/WARN: ...
|
|
420
|
+
// - MCP server registration messages
|
|
421
|
+
// - Python import/site noise
|
|
422
|
+
const isBenign = /^\[?\d{4}[-/]\d{2}[-/]\d{2}T/.test(trimmed) || // structured timestamps
|
|
423
|
+
/^[A-Z]+:\s+(INFO|DEBUG|WARN|WARNING)\b/.test(trimmed) || // log levels
|
|
424
|
+
/Successfully registered all tools/.test(trimmed) ||
|
|
425
|
+
/MCP [Ss]erver/.test(trimmed) ||
|
|
426
|
+
/tool registered successfully/.test(trimmed) ||
|
|
427
|
+
/Application initialized/.test(trimmed);
|
|
428
|
+
if (isBenign) {
|
|
429
|
+
return ctx.onLog("stdout", chunk);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return ctx.onLog(stream, chunk);
|
|
433
|
+
};
|
|
434
|
+
const result = await runChildProcess(ctx.runId, hermesCmd, args, {
|
|
435
|
+
cwd,
|
|
436
|
+
env,
|
|
437
|
+
timeoutSec,
|
|
438
|
+
graceSec,
|
|
439
|
+
onLog: wrappedOnLog,
|
|
440
|
+
});
|
|
441
|
+
// ── Parse output ───────────────────────────────────────────────────────
|
|
442
|
+
const parsed = parseHermesOutput(result.stdout || "", result.stderr || "");
|
|
443
|
+
await ctx.onLog("stdout", `[hermes] Exit code: ${result.exitCode ?? "null"}, timed out: ${result.timedOut}\n`);
|
|
444
|
+
if (parsed.sessionId) {
|
|
445
|
+
await ctx.onLog("stdout", `[hermes] Session: ${parsed.sessionId}\n`);
|
|
446
|
+
}
|
|
447
|
+
// ── Build result ───────────────────────────────────────────────────────
|
|
448
|
+
const executionResult = {
|
|
449
|
+
exitCode: result.exitCode,
|
|
450
|
+
signal: result.signal,
|
|
451
|
+
timedOut: result.timedOut,
|
|
452
|
+
provider: resolvedProvider,
|
|
453
|
+
model,
|
|
454
|
+
};
|
|
455
|
+
if (parsed.errorMessage) {
|
|
456
|
+
executionResult.errorMessage = parsed.errorMessage;
|
|
457
|
+
}
|
|
458
|
+
if (parsed.usage) {
|
|
459
|
+
executionResult.usage = parsed.usage;
|
|
460
|
+
}
|
|
461
|
+
if (parsed.costUsd !== undefined) {
|
|
462
|
+
executionResult.costUsd = parsed.costUsd;
|
|
463
|
+
}
|
|
464
|
+
// Summary from agent response
|
|
465
|
+
if (parsed.response) {
|
|
466
|
+
executionResult.summary = parsed.response.slice(0, 2000);
|
|
467
|
+
}
|
|
468
|
+
// Set resultJson so Paperclip can persist run metadata (used for UI display + auto-comments)
|
|
469
|
+
executionResult.resultJson = {
|
|
470
|
+
result: parsed.response || "",
|
|
471
|
+
session_id: parsed.sessionId || null,
|
|
472
|
+
usage: parsed.usage || null,
|
|
473
|
+
cost_usd: parsed.costUsd ?? null,
|
|
474
|
+
};
|
|
475
|
+
// Store session ID for next run
|
|
476
|
+
if (persistSession && parsed.sessionId) {
|
|
477
|
+
executionResult.sessionParams = { sessionId: parsed.sessionId };
|
|
478
|
+
executionResult.sessionDisplayId = parsed.sessionId.slice(0, 16);
|
|
479
|
+
}
|
|
480
|
+
return executionResult;
|
|
481
|
+
}
|
|
482
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/server/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAQ7B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,uBAAuB,GACxB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GAEd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,WAAW,EACX,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E,SAAS,SAAS,CAAC,CAAU;IAC3B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC;AACD,SAAS,SAAS,CAAC,CAAU;IAC3B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,C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|
4
|
+
export { execute } from "./execute.js";
|
|
5
|
+
export { testEnvironment } from "./test.js";
|
|
6
|
+
export { detectModel, parseModelFromConfig, resolveProvider, inferProviderFromModel } from "./detect-model.js";
|
|
7
|
+
export { listHermesSkills as listSkills, syncHermesSkills as syncSkills, resolveHermesDesiredSkillNames as resolveDesiredSkillNames, } from "./skills.js";
|
|
8
|
+
import type { AdapterSessionCodec } from "@paperclipai/adapter-utils";
|
|
9
|
+
/**
|
|
10
|
+
* Session codec for structured validation and migration of session parameters.
|
|
11
|
+
*
|
|
12
|
+
* Hermes Agent uses a single `sessionId` for cross-heartbeat session continuity
|
|
13
|
+
* via the `--resume` CLI flag. The codec validates and normalizes this field.
|
|
14
|
+
*/
|
|
15
|
+
export declare const sessionCodec: AdapterSessionCodec;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EACL,gBAAgB,IAAI,UAAU,EAC9B,gBAAgB,IAAI,UAAU,EAC9B,8BAA8B,IAAI,wBAAwB,GAC3D,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMtE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,mBAsB1B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side adapter module exports.
|
|
3
|
+
*/
|
|
4
|
+
export { execute } from "./execute.js";
|
|
5
|
+
export { testEnvironment } from "./test.js";
|
|
6
|
+
export { detectModel, parseModelFromConfig, resolveProvider, inferProviderFromModel } from "./detect-model.js";
|
|
7
|
+
export { listHermesSkills as listSkills, syncHermesSkills as syncSkills, resolveHermesDesiredSkillNames as resolveDesiredSkillNames, } from "./skills.js";
|
|
8
|
+
function readNonEmptyString(value) {
|
|
9
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Session codec for structured validation and migration of session parameters.
|
|
13
|
+
*
|
|
14
|
+
* Hermes Agent uses a single `sessionId` for cross-heartbeat session continuity
|
|
15
|
+
* via the `--resume` CLI flag. The codec validates and normalizes this field.
|
|
16
|
+
*/
|
|
17
|
+
export const sessionCodec = {
|
|
18
|
+
deserialize(raw) {
|
|
19
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
20
|
+
return null;
|
|
21
|
+
const record = raw;
|
|
22
|
+
const sessionId = readNonEmptyString(record.sessionId) ??
|
|
23
|
+
readNonEmptyString(record.session_id);
|
|
24
|
+
if (!sessionId)
|
|
25
|
+
return null;
|
|
26
|
+
return { sessionId };
|
|
27
|
+
},
|
|
28
|
+
serialize(params) {
|
|
29
|
+
if (!params)
|
|
30
|
+
return null;
|
|
31
|
+
const sessionId = readNonEmptyString(params.sessionId) ??
|
|
32
|
+
readNonEmptyString(params.session_id);
|
|
33
|
+
if (!sessionId)
|
|
34
|
+
return null;
|
|
35
|
+
return { sessionId };
|
|
36
|
+
},
|
|
37
|
+
getDisplayId(params) {
|
|
38
|
+
if (!params)
|
|
39
|
+
return null;
|
|
40
|
+
return readNonEmptyString(params.sessionId) ?? readNonEmptyString(params.session_id);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,c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AC,MAAsC;QACjD,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,OAAO,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACvF,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AdapterSkillContext, AdapterSkillSnapshot } from "@paperclipai/adapter-utils";
|
|
2
|
+
export declare function listHermesSkills(ctx: AdapterSkillContext): Promise<AdapterSkillSnapshot>;
|
|
3
|
+
export declare function syncHermesSkills(ctx: AdapterSkillContext, _desiredSkills: string[]): Promise<AdapterSkillSnapshot>;
|
|
4
|
+
export declare function resolveHermesDesiredSkillNames(config: Record<string, unknown>, availableEntries: Array<{
|
|
5
|
+
key: string;
|
|
6
|
+
runtimeName?: string | null;
|
|
7
|
+
}>): string[];
|
|
8
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/server/skills.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EAEnB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAsMpC,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,mBAAmB,EACxB,cAAc,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAI/B;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,gBAAgB,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,GACpE,MAAM,EAAE,CAEV"}
|