@agentproto/adapter-hermes 0.3.4 → 0.4.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/dist/index.d.ts +13 -1
- package/dist/index.mjs +99 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AgentCliHandle, AgentCliRuntime } from '@agentproto/driver-agent-cli';
|
|
2
2
|
export { AgentCliHandle, AgentCliRuntime } from '@agentproto/driver-agent-cli';
|
|
3
|
+
import { CapabilityStrategy } from '@agentproto/provider-kit';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @agentproto/adapter-hermes — AIP-45 adapter for Nous Research's Hermes Agent.
|
|
@@ -21,6 +22,17 @@ export { AgentCliHandle, AgentCliRuntime } from '@agentproto/driver-agent-cli';
|
|
|
21
22
|
|
|
22
23
|
declare const hermes: AgentCliHandle;
|
|
23
24
|
declare function hermesRuntime(): AgentCliRuntime;
|
|
25
|
+
/**
|
|
26
|
+
* Best-effort capability discovery for hermes: parses hermes' OWN native
|
|
27
|
+
* stores (`~/.hermes/auth.json`, `~/.hermes/provider_models_cache.json`)
|
|
28
|
+
* rather than the manifest's generic `models.env` slots, so it reflects
|
|
29
|
+
* what's ACTUALLY configured on this host, not just what the adapter
|
|
30
|
+
* declares it's capable of. Never throws — `discoverCapabilities` also
|
|
31
|
+
* catches, but every read here is independently defensive so a single
|
|
32
|
+
* malformed file doesn't blank out the providers a good file already
|
|
33
|
+
* yielded.
|
|
34
|
+
*/
|
|
35
|
+
declare const hermesCapabilities: CapabilityStrategy;
|
|
24
36
|
/** Best-effort read of a hermes session's cost/token usage from its state.db.
|
|
25
37
|
*
|
|
26
38
|
* hermes writes the per-turn cost to state.db slightly AFTER the ACP turn
|
|
@@ -34,4 +46,4 @@ declare function readHermesUsage(sessionId: string): Promise<{
|
|
|
34
46
|
tokensOut?: number;
|
|
35
47
|
} | null>;
|
|
36
48
|
|
|
37
|
-
export { hermes, hermesRuntime, readHermesUsage };
|
|
49
|
+
export { hermes, hermesCapabilities, hermesRuntime, readHermesUsage };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
1
2
|
import { defineAgentCli, createAgentCliRuntime } from '@agentproto/driver-agent-cli';
|
|
2
3
|
import { homedir } from 'os';
|
|
3
|
-
import { join } from 'path';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @agentproto/adapter-hermes v0.1.0-alpha
|
|
@@ -38,6 +38,11 @@ var hermes = defineAgentCli({
|
|
|
38
38
|
// ("openrouter") = OPENROUTER_API_KEY, derived from the catalog. No
|
|
39
39
|
// authSubscription ⇒ `subscription` fails loud with `unsupported_auth_mode`.
|
|
40
40
|
provider: "openrouter",
|
|
41
|
+
// The endpoint falls out of the model id's vendor prefix — `openai/*` is
|
|
42
|
+
// routed through OpenAI, everything else through OpenRouter (see the
|
|
43
|
+
// `model` option) — so there is nothing independent to choose: picking the
|
|
44
|
+
// model already fixes the route → derived-from-model.
|
|
45
|
+
routeSelection: "derived-from-model",
|
|
41
46
|
sandbox: "./SANDBOX.md",
|
|
42
47
|
protocol: "acp",
|
|
43
48
|
acp: "./hermes-acp.ACP.md",
|
|
@@ -60,12 +65,20 @@ var hermes = defineAgentCli({
|
|
|
60
65
|
// are the go-to cheap coders. `allowed` is only the curated menu: the
|
|
61
66
|
// `model` option is free-form, so any OpenRouter id (kimi, qwen, …) can
|
|
62
67
|
// still be passed even when it isn't listed here.
|
|
63
|
-
default: "z-ai/glm-5.2",
|
|
68
|
+
default: "z-ai/glm-5.2@openrouter",
|
|
64
69
|
allowed: [
|
|
65
|
-
"z-ai/glm-5.2",
|
|
66
|
-
"deepseek/deepseek-v4-pro",
|
|
67
|
-
"meta-llama/llama-3.3-70b",
|
|
68
|
-
"openai/gpt-4"
|
|
70
|
+
"z-ai/glm-5.2@openrouter",
|
|
71
|
+
"deepseek/deepseek-v4-pro@openrouter",
|
|
72
|
+
"meta-llama/llama-3.3-70b-instruct@openrouter",
|
|
73
|
+
"openai/gpt-4",
|
|
74
|
+
"x-ai/grok-4.5@openrouter",
|
|
75
|
+
"x-ai/grok-4.20@openrouter",
|
|
76
|
+
"x-ai/grok-4.3@openrouter",
|
|
77
|
+
"google/gemini-3.1-pro-preview@openrouter",
|
|
78
|
+
"google/gemini-3.5-flash@openrouter",
|
|
79
|
+
"google/gemini-2.5-flash@openrouter",
|
|
80
|
+
"google/gemini-2.5-pro@openrouter",
|
|
81
|
+
"moonshotai/kimi-k2.7-code@openrouter"
|
|
69
82
|
],
|
|
70
83
|
// Anthropic models are reserved for the dedicated claude-code adapter —
|
|
71
84
|
// hermes must NEVER route to them, even if a caller passes the id
|
|
@@ -88,7 +101,12 @@ var hermes = defineAgentCli({
|
|
|
88
101
|
file_io: true,
|
|
89
102
|
multimodal: true,
|
|
90
103
|
resumable: false,
|
|
91
|
-
bidirectional: true
|
|
104
|
+
bidirectional: true,
|
|
105
|
+
// Hermes has a verified native TUI resume path:
|
|
106
|
+
// `hermes --resume <SESSION> --tui`. This lets the daemon offer
|
|
107
|
+
// provider-native terminal restart for Hermes sessions, distinct from
|
|
108
|
+
// its ACP-level `resumable: false` honesty.
|
|
109
|
+
nativeTerminalResume: true
|
|
92
110
|
},
|
|
93
111
|
modes: [
|
|
94
112
|
{
|
|
@@ -118,7 +136,7 @@ var hermes = defineAgentCli({
|
|
|
118
136
|
// config, not from its own CLI args. Anthropic ids are denied
|
|
119
137
|
// (models.deny) — those are reserved for the claude-code adapter.
|
|
120
138
|
type: "string",
|
|
121
|
-
description: "Model ID routed through OpenRouter/OpenAI (e.g. 'deepseek/deepseek-v4-pro', 'z-ai/glm-5.2', 'moonshotai/kimi-k2'). Anthropic models are not permitted on hermes \u2014 use the claude-code adapter for those. Applied via a `/model <id>` control turn after the session is created (hermes ignores the ACP session model config). Omit to use the hermes default."
|
|
139
|
+
description: "Model ID routed through OpenRouter/OpenAI (e.g. 'deepseek/deepseek-v4-pro', 'z-ai/glm-5.2@openrouter', 'moonshotai/kimi-k2@openrouter'). Anthropic models are not permitted on hermes \u2014 use the claude-code adapter for those. Applied via a `/model <id>` control turn after the session is created (hermes ignores the ACP session model config). Omit to use the hermes default."
|
|
122
140
|
},
|
|
123
141
|
{
|
|
124
142
|
id: "effort",
|
|
@@ -140,6 +158,78 @@ var hermes = defineAgentCli({
|
|
|
140
158
|
function hermesRuntime() {
|
|
141
159
|
return createAgentCliRuntime(hermes);
|
|
142
160
|
}
|
|
161
|
+
var hermesCapabilities = async (def, ctx) => {
|
|
162
|
+
const authPath = join(ctx.homeDir, ".hermes", "auth.json");
|
|
163
|
+
const modelsCachePath = join(ctx.homeDir, ".hermes", "provider_models_cache.json");
|
|
164
|
+
const authStores = [
|
|
165
|
+
{ kind: "file", path: "~/.hermes/auth.json", format: "json", providerKeyed: true }
|
|
166
|
+
];
|
|
167
|
+
const providers = [];
|
|
168
|
+
const authRaw = await ctx.readFile(authPath);
|
|
169
|
+
if (authRaw !== null) {
|
|
170
|
+
try {
|
|
171
|
+
const parsed = JSON.parse(authRaw);
|
|
172
|
+
const pool = Array.isArray(parsed.credential_pool) ? parsed.credential_pool : [];
|
|
173
|
+
for (const entry of pool) {
|
|
174
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
175
|
+
const id = typeof entry.provider === "string" ? entry.provider : void 0;
|
|
176
|
+
if (!id) continue;
|
|
177
|
+
const keyEnv = typeof entry.key_env === "string" ? entry.key_env : void 0;
|
|
178
|
+
const fingerprint = typeof entry.fingerprint === "string" ? entry.fingerprint : void 0;
|
|
179
|
+
const baseUrl = typeof entry.base_url === "string" ? entry.base_url : typeof entry.baseUrl === "string" ? entry.baseUrl : void 0;
|
|
180
|
+
const source = keyEnv ? { kind: "env", var: keyEnv } : { kind: "file", path: "~/.hermes/auth.json", pointer: `credential_pool[provider=${id}]` };
|
|
181
|
+
providers.push({
|
|
182
|
+
id,
|
|
183
|
+
billingEndpoint: id,
|
|
184
|
+
cred: {
|
|
185
|
+
present: true,
|
|
186
|
+
source,
|
|
187
|
+
...fingerprint ? { fingerprint } : {}
|
|
188
|
+
},
|
|
189
|
+
...baseUrl ? { baseUrl } : {}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
} catch (err) {
|
|
193
|
+
ctx.warn(
|
|
194
|
+
`hermes capability discovery: could not parse ~/.hermes/auth.json: ${err instanceof Error ? err.message : String(err)}`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
let ids;
|
|
199
|
+
let stale = true;
|
|
200
|
+
const cacheRaw = await ctx.readFile(modelsCachePath);
|
|
201
|
+
if (cacheRaw !== null) {
|
|
202
|
+
try {
|
|
203
|
+
const parsedCache = JSON.parse(cacheRaw);
|
|
204
|
+
ids = Array.isArray(parsedCache.models) ? parsedCache.models.filter((m) => typeof m === "string") : void 0;
|
|
205
|
+
stale = false;
|
|
206
|
+
} catch (err) {
|
|
207
|
+
ctx.warn(
|
|
208
|
+
`hermes capability discovery: could not parse ~/.hermes/provider_models_cache.json: ${err instanceof Error ? err.message : String(err)}`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const modelApply = def.models?.apply;
|
|
213
|
+
return {
|
|
214
|
+
adapter: def.id,
|
|
215
|
+
source: "discovered",
|
|
216
|
+
discoverable: "live",
|
|
217
|
+
authStores,
|
|
218
|
+
providers,
|
|
219
|
+
models: {
|
|
220
|
+
mechanism: "file-cache",
|
|
221
|
+
ref: "hermes model --refresh",
|
|
222
|
+
...ids ? { ids } : {},
|
|
223
|
+
stale
|
|
224
|
+
},
|
|
225
|
+
endpointCompat: {},
|
|
226
|
+
application: {
|
|
227
|
+
modelApply: modelApply === "command" || modelApply === "arg" ? modelApply : "config",
|
|
228
|
+
postureApply: "none",
|
|
229
|
+
coupled: false
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
};
|
|
143
233
|
async function readHermesUsage(sessionId) {
|
|
144
234
|
try {
|
|
145
235
|
const sqliteSpecifier = ["node", "sqlite"].join(":");
|
|
@@ -166,6 +256,6 @@ async function readHermesUsage(sessionId) {
|
|
|
166
256
|
}
|
|
167
257
|
}
|
|
168
258
|
|
|
169
|
-
export { hermes, hermesRuntime, readHermesUsage };
|
|
259
|
+
export { hermes, hermesCapabilities, hermesRuntime, readHermesUsage };
|
|
170
260
|
//# sourceMappingURL=index.mjs.map
|
|
171
261
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAyBO,IAAM,SAAyB,cAAA,CAAe;AAAA,EACnD,IAAA,EAAM,QAAA;AAAA,EACN,EAAA,EAAI,QAAA;AAAA,EACJ,WAAA,EACE,qLAAA;AAAA,EACF,OAAA,EAAS,OAAA;AAAA,EACT,GAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAU,CAAC,KAAK,CAAA;AAAA,EAChB,OAAA,EAAS;AAAA,IACP;AAAA,MACE,MAAA,EAAQ,MAAA;AAAA,MACR,GAAA,EAAK;AAAA;AACP,GACF;AAAA,EACA,aAAA,EAAe;AAAA,IACb,GAAA,EAAK,kBAAA;AAAA,IACL,KAAA,EAAO,sBAAA;AAAA,IACP,KAAA,EAAO,iBAAA;AAAA,IACP,UAAA,EAAY;AAAA,GACd;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,GAAA,EAAK,cAAA;AAAA;AAAA;AAAA;AAAA,IAIL,OAAO,EAAE,GAAA,EAAK,CAAC,oBAAA,EAAsB,gBAAgB,CAAA;AAAE,GACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,QAAA,EAAU,YAAA;AAAA,EACV,OAAA,EAAS,cAAA;AAAA,EACT,QAAA,EAAU,KAAA;AAAA,EACV,GAAA,EAAK,qBAAA;AAAA,EACL,OAAA,E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A;AACtD,MAAA,MAAM,MAAM,EAAA,CAAG,OAAA;AAAA,QACb;AAAA,OACF,CAAE,IAAI,SAAS,CAAA;AACf,MAAA,EAAA,CAAG,KAAA,EAAM;AACT,MAAA,IAAI,GAAA,EAAK;AACP,QAAA,IAAA,GAAO,EAAE,SAAS,GAAA,CAAI,IAAA,EAAM,UAAU,GAAA,CAAI,EAAA,EAAI,SAAA,EAAW,GAAA,CAAI,GAAA,EAAI;AAGjE,QAAA,IAAI,IAAI,IAAA,KAAS,IAAA,IAAQ,GAAA,CAAI,IAAA,KAAS,QAAW,OAAO,IAAA;AAAA,MAC1D;AACA,MAAA,IAAI,CAAA,GAAI,QAAA,GAAW,CAAA,EAAG,MAAM,IAAI,QAAQ,CAAA,CAAA,KAAK,UAAA,CAAW,CAAA,EAAG,QAAQ,CAAC,CAAA;AAAA,IACtE;AACA,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"index.mjs","sourcesContent":["/**\n * @agentproto/adapter-hermes — AIP-45 adapter for Nous Research's Hermes Agent.\n *\n * Re-exports a `defineAgentCli` instance plus the runtime factory so\n * a host can boot Hermes with one import:\n *\n * import { hermes, hermesRuntime } from \"@agentproto/adapter-hermes\"\n * const session = await hermesRuntime().start({ env: { OPENROUTER_API_KEY } })\n * for await (const evt of session.send({ role: \"user\", content: \"...\" })) {\n * console.log(evt)\n * }\n * await session.close()\n *\n * The companion HERMES.md / SECRETS.md / hermes-acp.ACP.md files in\n * this package describe the manifest, secret slots, and ACP wire\n * profile.\n */\n\nimport {\n createAgentCliRuntime,\n defineAgentCli,\n type AgentCliHandle,\n type AgentCliRuntime,\n} from \"@agentproto/driver-agent-cli\"\n\nexport const hermes: AgentCliHandle = defineAgentCli({\n name: \"hermes\",\n id: \"hermes\",\n description:\n \"Nous Research's Hermes Agent — autonomous CLI agent with skills, sandboxes, memory plugins, and a built-in ACP server. Spawned as `hermes acp` and driven over stdio JSON-RPC.\",\n version: \"0.1.0\",\n bin: \"hermes\",\n bin_args: [\"acp\"],\n install: [\n {\n method: \"curl\",\n url: \"https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh\",\n },\n ],\n version_check: {\n cmd: \"hermes --version\",\n parse: \"(\\\\d+\\\\.\\\\d+\\\\.\\\\d+)\",\n range: \">=0.13.0 <1.0.0\",\n timeout_ms: 5000,\n },\n auth: {\n ref: \"./SECRETS.md\",\n // No ANTHROPIC_API_KEY — hermes is the budget arm and deliberately does\n // not route to Anthropic (see models.deny). Anthropic stays exclusive to\n // the claude-code adapter.\n state: { env: [\"OPENROUTER_API_KEY\", \"OPENAI_API_KEY\"] },\n },\n // Billing-auth (opt-in — no authEnforce, so unconfigured spawns stay\n // ambient). Single-provider adapter: api-key mode SETS providerEnvVar\n // (\"openrouter\") = OPENROUTER_API_KEY, derived from the catalog. No\n // authSubscription ⇒ `subscription` fails loud with `unsupported_auth_mode`.\n provider: \"openrouter\",\n sandbox: \"./SANDBOX.md\",\n protocol: \"acp\",\n acp: \"./hermes-acp.ACP.md\",\n session: {\n mode: \"persistent\",\n idle_timeout_ms: 1_800_000,\n context_carryover: true,\n // hermes's own ACP server has been observed to hit its internal\n // max-tool-iterations cap, produce a final answer, and then never\n // send the `prompt` JSON-RPC response — hanging the daemon's turn\n // drain loop forever with no other adapter-side signal available.\n // 5 minutes of true silence (reset on any ACP traffic, so a long\n // legitimate tool-call chain doesn't false-positive) is generous\n // enough to not trip during normal use.\n turn_idle_timeout_ms: 300_000,\n },\n models: {\n // Cheap OpenRouter models by default — hermes is the budget delegation\n // arm (a Sonnet default would defeat the purpose). glm-5.2 + deepseek\n // are the go-to cheap coders. `allowed` is only the curated menu: the\n // `model` option is free-form, so any OpenRouter id (kimi, qwen, …) can\n // still be passed even when it isn't listed here.\n default: \"z-ai/glm-5.2\",\n allowed: [\n \"z-ai/glm-5.2\",\n \"deepseek/deepseek-v4-pro\",\n \"meta-llama/llama-3.3-70b\",\n \"openai/gpt-4\",\n ],\n // Anthropic models are reserved for the dedicated claude-code adapter —\n // hermes must NEVER route to them, even if a caller passes the id\n // explicitly. Enforced at compose time (RuntimeConfigError), so the\n // budget arm can't silently burn premium Anthropic spend.\n deny: [\"anthropic/*\", \"claude-*\"],\n env: {\n openrouter: \"OPENROUTER_API_KEY\",\n openai: \"OPENAI_API_KEY\",\n },\n // hermes keeps its own configured default when given a model via the\n // ACP session config — selection must go through a `/model <id>`\n // control turn instead. See AgentCliModels.apply.\n apply: \"command\",\n },\n capabilities: {\n streaming: true,\n tool_calls: true,\n sub_agents: true,\n file_io: true,\n multimodal: true,\n resumable: false,\n bidirectional: true,\n },\n modes: [\n {\n id: \"default\",\n description:\n \"Standard interactive mode — loads ~/.hermes/config.yaml and auto-injects \" +\n \"rules/memory/preloaded skills as usual.\",\n },\n {\n id: \"lean\",\n description:\n \"Skip ~/.hermes/config.yaml, cutting the skills/rules/memory scaffolding hermes \" +\n \"would otherwise preload into context. Composed as `hermes --ignore-user-config \" +\n \"acp` — the global flag MUST precede the `acp` subcommand baked into `bin_args`, \" +\n \"which is why this needs bin_args_prepend rather than bin_args_append.\",\n bin_args_prepend: [\"--ignore-user-config\"],\n status: \"noop\",\n status_note:\n \"Measured no-op: --ignore-user-config skips ~/.hermes/config.yaml, but hermes \" +\n \"skills live in a separate skills dir (not config), so prompt-size is \" +\n \"byte-identical. The real lean lever is narrowing the mounted toolset, not \" +\n \"this flag.\",\n },\n ],\n options: [\n {\n id: \"skills\",\n type: \"string\" as const,\n description:\n \"Preload one or more agentskills.io-compatible skills for the session \" +\n \"(comma-separate for multiple), via hermes' `--skills` global flag. Same \" +\n \"prepend-before-`acp` constraint as the `lean` mode.\",\n bin_args_prepend: [\"--skills\", \"{value}\"],\n },\n {\n id: \"model\",\n // string (not enum) so any valid OpenRouter/OpenAI model ID is accepted\n // without a code change to expand the list. Applied via ACP\n // newSession(model:...) — hermes reads the model from the ACP session\n // config, not from its own CLI args. Anthropic ids are denied\n // (models.deny) — those are reserved for the claude-code adapter.\n type: \"string\" as const,\n description:\n \"Model ID routed through OpenRouter/OpenAI \" +\n \"(e.g. 'deepseek/deepseek-v4-pro', 'z-ai/glm-5.2', 'moonshotai/kimi-k2'). \" +\n \"Anthropic models are not permitted on hermes — use the claude-code \" +\n \"adapter for those. \" +\n \"Applied via a `/model <id>` control turn after the session is created \" +\n \"(hermes ignores the ACP session model config). \" +\n \"Omit to use the hermes default.\",\n },\n {\n id: \"effort\",\n type: \"enum\" as const,\n enum: [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"],\n description:\n \"Reasoning effort level passed to hermes via ACP newSession. \" +\n \"Omit to use the hermes default.\",\n },\n ],\n tags: [\"hermes\", \"nous\", \"acp\", \"agent-runtime\"],\n metadata: {\n // Opts hermes into `agentproto install skill/<slug>` fan-out (no\n // --target given): skills get copied one subdir per skill into\n // hermes's own skills directory, alongside whatever it ships\n // natively. See packages/cli/src/commands/skill-install/types.ts\n // `AdapterSkillsTarget` for the shape + guard.\n skills: { format: \"flat-dir\", dir: \"~/.hermes/skills\" },\n },\n})\n\nexport function hermesRuntime(): AgentCliRuntime {\n return createAgentCliRuntime(hermes)\n}\n\nimport { homedir } from \"node:os\"\nimport { join } from \"node:path\"\n\n/** Best-effort read of a hermes session's cost/token usage from its state.db.\n *\n * hermes writes the per-turn cost to state.db slightly AFTER the ACP turn\n * ends, so a single read right at turn-end usually finds the cost column\n * still null. We poll a few times with a short backoff until the cost lands\n * (or give up — best-effort, never throws). Bounded so a missing write can't\n * hang the caller (the turn-end path awaits this). */\nexport async function readHermesUsage(\n sessionId: string,\n): Promise<{ costUsd?: number; tokensIn?: number; tokensOut?: number } | null> {\n try {\n // node:sqlite is a Node 22+ builtin. Build the specifier at runtime so the\n // bundler (esbuild/tsup) can't statically rewrite it — it strips the\n // `node:` prefix off this not-yet-recognised builtin, turning the import\n // into a missing `sqlite` package that throws and silently yields null.\n const sqliteSpecifier = [\"node\", \"sqlite\"].join(\":\")\n const { DatabaseSync } = (await import(sqliteSpecifier)) as unknown as {\n DatabaseSync: new (p: string, o?: { readOnly?: boolean }) => {\n prepare(sql: string): { get(...a: unknown[]): unknown }\n close(): void\n }\n }\n const dbPath = join(homedir(), \".hermes\", \"state.db\")\n const ATTEMPTS = 6\n const DELAY_MS = 130\n let last: { costUsd?: number; tokensIn?: number; tokensOut?: number } | null = null\n for (let i = 0; i < ATTEMPTS; i++) {\n const db = new DatabaseSync(dbPath, { readOnly: true })\n const row = db.prepare(\n \"select estimated_cost_usd as cost, input_tokens as ti, output_tokens as to_ from sessions where id = ?\",\n ).get(sessionId) as { cost?: number; ti?: number; to_?: number } | undefined\n db.close()\n if (row) {\n last = { costUsd: row.cost, tokensIn: row.ti, tokensOut: row.to_ }\n // Cost has landed (non-null) → done. Otherwise keep polling: the row\n // exists but hermes hasn't written the cost for this turn yet.\n if (row.cost !== null && row.cost !== undefined) return last\n }\n if (i < ATTEMPTS - 1) await new Promise(r => setTimeout(r, DELAY_MS))\n }\n return last\n } catch {\n return null\n }\n}\n\nexport type { AgentCliHandle, AgentCliRuntime }\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAgCO,IAAM,SAAyB,cAAA,CAAe;AAAA,EACnD,IAAA,EAAM,QAAA;AAAA,EACN,EAAA,EAAI,QAAA;AAAA,EACJ,WAAA,EACE,qLAAA;AAAA,EACF,OAAA,EAAS,OAAA;AAAA,EACT,GAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAU,CAAC,KAAK,CAAA;AAAA,EAChB,OAAA,EAAS;AAAA,IACP;AAAA,MACE,MAAA,EAAQ,MAAA;AAAA,MACR,GAAA,EAAK;AAAA;AACP,GACF;AAAA,EACA,aAAA,EAAe;AAAA,IACb,GAAA,EAAK,kBAAA;AAAA,IACL,KAAA,EAAO,sBAAA;AAAA,IACP,KAAA,EAAO,iBAAA;AAAA,IACP,UAAA,EAAY;AAAA,GACd;AAAA,EACA,I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A,EAAA,EAAK;AACjC,MAAA,MAAM,KAAK,IAAI,YAAA,CAAa,QAAQ,EAAE,QAAA,EAAU,MAAM,CAAA;AACtD,MAAA,MAAM,MAAM,EAAA,CAAG,OAAA;AAAA,QACb;AAAA,OACF,CAAE,IAAI,SAAS,CAAA;AACf,MAAA,EAAA,CAAG,KAAA,EAAM;AACT,MAAA,IAAI,GAAA,EAAK;AACP,QAAA,IAAA,GAAO,EAAE,SAAS,GAAA,CAAI,IAAA,EAAM,UAAU,GAAA,CAAI,EAAA,EAAI,SAAA,EAAW,GAAA,CAAI,GAAA,EAAI;AAGjE,QAAA,IAAI,IAAI,IAAA,KAAS,IAAA,IAAQ,GAAA,CAAI,IAAA,KAAS,QAAW,OAAO,IAAA;AAAA,MAC1D;AACA,MAAA,IAAI,CAAA,GAAI,QAAA,GAAW,CAAA,EAAG,MAAM,IAAI,QAAQ,CAAA,CAAA,KAAK,UAAA,CAAW,CAAA,EAAG,QAAQ,CAAC,CAAA;AAAA,IACtE;AACA,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF","file":"index.mjs","sourcesContent":["/**\n * @agentproto/adapter-hermes — AIP-45 adapter for Nous Research's Hermes Agent.\n *\n * Re-exports a `defineAgentCli` instance plus the runtime factory so\n * a host can boot Hermes with one import:\n *\n * import { hermes, hermesRuntime } from \"@agentproto/adapter-hermes\"\n * const session = await hermesRuntime().start({ env: { OPENROUTER_API_KEY } })\n * for await (const evt of session.send({ role: \"user\", content: \"...\" })) {\n * console.log(evt)\n * }\n * await session.close()\n *\n * The companion HERMES.md / SECRETS.md / hermes-acp.ACP.md files in\n * this package describe the manifest, secret slots, and ACP wire\n * profile.\n */\n\nimport { join } from \"node:path\"\nimport {\n createAgentCliRuntime,\n defineAgentCli,\n type AgentCliHandle,\n type AgentCliRuntime,\n} from \"@agentproto/driver-agent-cli\"\nimport type {\n AuthStore,\n CapabilityStrategy,\n CredSource,\n ProviderCapability,\n} from \"@agentproto/provider-kit\"\n\nexport const hermes: AgentCliHandle = defineAgentCli({\n name: \"hermes\",\n id: \"hermes\",\n description:\n \"Nous Research's Hermes Agent — autonomous CLI agent with skills, sandboxes, memory plugins, and a built-in ACP server. Spawned as `hermes acp` and driven over stdio JSON-RPC.\",\n version: \"0.1.0\",\n bin: \"hermes\",\n bin_args: [\"acp\"],\n install: [\n {\n method: \"curl\",\n url: \"https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh\",\n },\n ],\n version_check: {\n cmd: \"hermes --version\",\n parse: \"(\\\\d+\\\\.\\\\d+\\\\.\\\\d+)\",\n range: \">=0.13.0 <1.0.0\",\n timeout_ms: 5000,\n },\n auth: {\n ref: \"./SECRETS.md\",\n // No ANTHROPIC_API_KEY — hermes is the budget arm and deliberately does\n // not route to Anthropic (see models.deny). Anthropic stays exclusive to\n // the claude-code adapter.\n state: { env: [\"OPENROUTER_API_KEY\", \"OPENAI_API_KEY\"] },\n },\n // Billing-auth (opt-in — no authEnforce, so unconfigured spawns stay\n // ambient). Single-provider adapter: api-key mode SETS providerEnvVar\n // (\"openrouter\") = OPENROUTER_API_KEY, derived from the catalog. No\n // authSubscription ⇒ `subscription` fails loud with `unsupported_auth_mode`.\n provider: \"openrouter\",\n // The endpoint falls out of the model id's vendor prefix — `openai/*` is\n // routed through OpenAI, everything else through OpenRouter (see the\n // `model` option) — so there is nothing independent to choose: picking the\n // model already fixes the route → derived-from-model.\n routeSelection: \"derived-from-model\",\n sandbox: \"./SANDBOX.md\",\n protocol: \"acp\",\n acp: \"./hermes-acp.ACP.md\",\n session: {\n mode: \"persistent\",\n idle_timeout_ms: 1_800_000,\n context_carryover: true,\n // hermes's own ACP server has been observed to hit its internal\n // max-tool-iterations cap, produce a final answer, and then never\n // send the `prompt` JSON-RPC response — hanging the daemon's turn\n // drain loop forever with no other adapter-side signal available.\n // 5 minutes of true silence (reset on any ACP traffic, so a long\n // legitimate tool-call chain doesn't false-positive) is generous\n // enough to not trip during normal use.\n turn_idle_timeout_ms: 300_000,\n },\n models: {\n // Cheap OpenRouter models by default — hermes is the budget delegation\n // arm (a Sonnet default would defeat the purpose). glm-5.2 + deepseek\n // are the go-to cheap coders. `allowed` is only the curated menu: the\n // `model` option is free-form, so any OpenRouter id (kimi, qwen, …) can\n // still be passed even when it isn't listed here.\n default: \"z-ai/glm-5.2@openrouter\",\n allowed: [\n \"z-ai/glm-5.2@openrouter\",\n \"deepseek/deepseek-v4-pro@openrouter\",\n \"meta-llama/llama-3.3-70b-instruct@openrouter\",\n \"openai/gpt-4\",\n \"x-ai/grok-4.5@openrouter\",\n \"x-ai/grok-4.20@openrouter\",\n \"x-ai/grok-4.3@openrouter\",\n \"google/gemini-3.1-pro-preview@openrouter\",\n \"google/gemini-3.5-flash@openrouter\",\n \"google/gemini-2.5-flash@openrouter\",\n \"google/gemini-2.5-pro@openrouter\",\n \"moonshotai/kimi-k2.7-code@openrouter\",\n ],\n // Anthropic models are reserved for the dedicated claude-code adapter —\n // hermes must NEVER route to them, even if a caller passes the id\n // explicitly. Enforced at compose time (RuntimeConfigError), so the\n // budget arm can't silently burn premium Anthropic spend.\n deny: [\"anthropic/*\", \"claude-*\"],\n env: {\n openrouter: \"OPENROUTER_API_KEY\",\n openai: \"OPENAI_API_KEY\",\n },\n // hermes keeps its own configured default when given a model via the\n // ACP session config — selection must go through a `/model <id>`\n // control turn instead. See AgentCliModels.apply.\n apply: \"command\",\n },\n capabilities: {\n streaming: true,\n tool_calls: true,\n sub_agents: true,\n file_io: true,\n multimodal: true,\n resumable: false,\n bidirectional: true,\n // Hermes has a verified native TUI resume path:\n // `hermes --resume <SESSION> --tui`. This lets the daemon offer\n // provider-native terminal restart for Hermes sessions, distinct from\n // its ACP-level `resumable: false` honesty.\n nativeTerminalResume: true,\n },\n modes: [\n {\n id: \"default\",\n description:\n \"Standard interactive mode — loads ~/.hermes/config.yaml and auto-injects \" +\n \"rules/memory/preloaded skills as usual.\",\n },\n {\n id: \"lean\",\n description:\n \"Skip ~/.hermes/config.yaml, cutting the skills/rules/memory scaffolding hermes \" +\n \"would otherwise preload into context. Composed as `hermes --ignore-user-config \" +\n \"acp` — the global flag MUST precede the `acp` subcommand baked into `bin_args`, \" +\n \"which is why this needs bin_args_prepend rather than bin_args_append.\",\n bin_args_prepend: [\"--ignore-user-config\"],\n status: \"noop\",\n status_note:\n \"Measured no-op: --ignore-user-config skips ~/.hermes/config.yaml, but hermes \" +\n \"skills live in a separate skills dir (not config), so prompt-size is \" +\n \"byte-identical. The real lean lever is narrowing the mounted toolset, not \" +\n \"this flag.\",\n },\n ],\n options: [\n {\n id: \"skills\",\n type: \"string\" as const,\n description:\n \"Preload one or more agentskills.io-compatible skills for the session \" +\n \"(comma-separate for multiple), via hermes' `--skills` global flag. Same \" +\n \"prepend-before-`acp` constraint as the `lean` mode.\",\n bin_args_prepend: [\"--skills\", \"{value}\"],\n },\n {\n id: \"model\",\n // string (not enum) so any valid OpenRouter/OpenAI model ID is accepted\n // without a code change to expand the list. Applied via ACP\n // newSession(model:...) — hermes reads the model from the ACP session\n // config, not from its own CLI args. Anthropic ids are denied\n // (models.deny) — those are reserved for the claude-code adapter.\n type: \"string\" as const,\n description:\n \"Model ID routed through OpenRouter/OpenAI \" +\n \"(e.g. 'deepseek/deepseek-v4-pro', 'z-ai/glm-5.2@openrouter', 'moonshotai/kimi-k2@openrouter'). \" +\n \"Anthropic models are not permitted on hermes — use the claude-code \" +\n \"adapter for those. \" +\n \"Applied via a `/model <id>` control turn after the session is created \" +\n \"(hermes ignores the ACP session model config). \" +\n \"Omit to use the hermes default.\",\n },\n {\n id: \"effort\",\n type: \"enum\" as const,\n enum: [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"],\n description:\n \"Reasoning effort level passed to hermes via ACP newSession. \" +\n \"Omit to use the hermes default.\",\n },\n ],\n tags: [\"hermes\", \"nous\", \"acp\", \"agent-runtime\"],\n metadata: {\n // Opts hermes into `agentproto install skill/<slug>` fan-out (no\n // --target given): skills get copied one subdir per skill into\n // hermes's own skills directory, alongside whatever it ships\n // natively. See packages/cli/src/commands/skill-install/types.ts\n // `AdapterSkillsTarget` for the shape + guard.\n skills: { format: \"flat-dir\", dir: \"~/.hermes/skills\" },\n },\n})\n\nexport function hermesRuntime(): AgentCliRuntime {\n return createAgentCliRuntime(hermes)\n}\n\n/** Shape of one `~/.hermes/auth.json` `credential_pool` entry this strategy\n * reads. Only non-secret fields — never the credential value itself. The\n * pool's own `key_env` (when present) is preserved verbatim: hermes' native\n * kimi/moonshot slot is `KIMI_API_KEY`, NOT `MOONSHOT_API_KEY`, so this must\n * never derive/normalize an env var name from the provider id. */\ninterface HermesCredentialPoolEntry {\n provider?: unknown\n key_env?: unknown\n fingerprint?: unknown\n base_url?: unknown\n baseUrl?: unknown\n}\n\ninterface HermesAuthFile {\n credential_pool?: unknown\n}\n\ninterface HermesModelsCacheFile {\n models?: unknown\n}\n\n/**\n * Best-effort capability discovery for hermes: parses hermes' OWN native\n * stores (`~/.hermes/auth.json`, `~/.hermes/provider_models_cache.json`)\n * rather than the manifest's generic `models.env` slots, so it reflects\n * what's ACTUALLY configured on this host, not just what the adapter\n * declares it's capable of. Never throws — `discoverCapabilities` also\n * catches, but every read here is independently defensive so a single\n * malformed file doesn't blank out the providers a good file already\n * yielded.\n */\nexport const hermesCapabilities: CapabilityStrategy = async (def, ctx) => {\n const authPath = join(ctx.homeDir, \".hermes\", \"auth.json\")\n const modelsCachePath = join(ctx.homeDir, \".hermes\", \"provider_models_cache.json\")\n\n const authStores: AuthStore[] = [\n { kind: \"file\", path: \"~/.hermes/auth.json\", format: \"json\", providerKeyed: true },\n ]\n\n const providers: ProviderCapability[] = []\n const authRaw = await ctx.readFile(authPath)\n if (authRaw !== null) {\n try {\n const parsed = JSON.parse(authRaw) as HermesAuthFile\n const pool = Array.isArray(parsed.credential_pool) ? parsed.credential_pool : []\n for (const entry of pool as HermesCredentialPoolEntry[]) {\n if (typeof entry !== \"object\" || entry === null) continue\n const id = typeof entry.provider === \"string\" ? entry.provider : undefined\n if (!id) continue\n const keyEnv = typeof entry.key_env === \"string\" ? entry.key_env : undefined\n const fingerprint = typeof entry.fingerprint === \"string\" ? entry.fingerprint : undefined\n const baseUrl =\n typeof entry.base_url === \"string\"\n ? entry.base_url\n : typeof entry.baseUrl === \"string\"\n ? entry.baseUrl\n : undefined\n // Never guess an env var from the provider id (that's exactly the\n // KIMI_API_KEY vs MOONSHOT_API_KEY trap) — only trust an explicit\n // key_env; otherwise the credential's origin is the pool file itself.\n const source: CredSource = keyEnv\n ? { kind: \"env\", var: keyEnv }\n : { kind: \"file\", path: \"~/.hermes/auth.json\", pointer: `credential_pool[provider=${id}]` }\n providers.push({\n id,\n billingEndpoint: id,\n cred: {\n present: true,\n source,\n ...(fingerprint ? { fingerprint } : {}),\n },\n ...(baseUrl ? { baseUrl } : {}),\n })\n }\n } catch (err) {\n ctx.warn(\n `hermes capability discovery: could not parse ~/.hermes/auth.json: ` +\n `${err instanceof Error ? err.message : String(err)}`,\n )\n }\n }\n\n let ids: string[] | undefined\n let stale = true\n const cacheRaw = await ctx.readFile(modelsCachePath)\n if (cacheRaw !== null) {\n try {\n const parsedCache = JSON.parse(cacheRaw) as HermesModelsCacheFile\n ids = Array.isArray(parsedCache.models)\n ? parsedCache.models.filter((m): m is string => typeof m === \"string\")\n : undefined\n stale = false\n } catch (err) {\n ctx.warn(\n `hermes capability discovery: could not parse ` +\n `~/.hermes/provider_models_cache.json: ${err instanceof Error ? err.message : String(err)}`,\n )\n }\n }\n\n const modelApply = def.models?.apply\n return {\n adapter: def.id,\n source: \"discovered\",\n discoverable: \"live\",\n authStores,\n providers,\n models: {\n mechanism: \"file-cache\",\n ref: \"hermes model --refresh\",\n ...(ids ? { ids } : {}),\n stale,\n },\n endpointCompat: {},\n application: {\n modelApply: modelApply === \"command\" || modelApply === \"arg\" ? modelApply : \"config\",\n postureApply: \"none\",\n coupled: false,\n },\n }\n}\n\nimport { homedir } from \"node:os\"\n\n/** Best-effort read of a hermes session's cost/token usage from its state.db.\n *\n * hermes writes the per-turn cost to state.db slightly AFTER the ACP turn\n * ends, so a single read right at turn-end usually finds the cost column\n * still null. We poll a few times with a short backoff until the cost lands\n * (or give up — best-effort, never throws). Bounded so a missing write can't\n * hang the caller (the turn-end path awaits this). */\nexport async function readHermesUsage(\n sessionId: string,\n): Promise<{ costUsd?: number; tokensIn?: number; tokensOut?: number } | null> {\n try {\n // node:sqlite is a Node 22+ builtin. Build the specifier at runtime so the\n // bundler (esbuild/tsup) can't statically rewrite it — it strips the\n // `node:` prefix off this not-yet-recognised builtin, turning the import\n // into a missing `sqlite` package that throws and silently yields null.\n const sqliteSpecifier = [\"node\", \"sqlite\"].join(\":\")\n const { DatabaseSync } = (await import(sqliteSpecifier)) as unknown as {\n DatabaseSync: new (p: string, o?: { readOnly?: boolean }) => {\n prepare(sql: string): { get(...a: unknown[]): unknown }\n close(): void\n }\n }\n const dbPath = join(homedir(), \".hermes\", \"state.db\")\n const ATTEMPTS = 6\n const DELAY_MS = 130\n let last: { costUsd?: number; tokensIn?: number; tokensOut?: number } | null = null\n for (let i = 0; i < ATTEMPTS; i++) {\n const db = new DatabaseSync(dbPath, { readOnly: true })\n const row = db.prepare(\n \"select estimated_cost_usd as cost, input_tokens as ti, output_tokens as to_ from sessions where id = ?\",\n ).get(sessionId) as { cost?: number; ti?: number; to_?: number } | undefined\n db.close()\n if (row) {\n last = { costUsd: row.cost, tokensIn: row.ti, tokensOut: row.to_ }\n // Cost has landed (non-null) → done. Otherwise keep polling: the row\n // exists but hermes hasn't written the cost for this turn yet.\n if (row.cost !== null && row.cost !== undefined) return last\n }\n if (i < ATTEMPTS - 1) await new Promise(r => setTimeout(r, DELAY_MS))\n }\n return last\n } catch {\n return null\n }\n}\n\nexport type { AgentCliHandle, AgentCliRuntime }\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentproto/adapter-hermes",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "@agentproto/adapter-hermes — AIP-45 AGENT-CLI adapter for Nous Research's Hermes Agent. Spawns `hermes acp` and drives it as an agentproto agent CLI via the ACP protocol arm of @agentproto/driver-agent-cli.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentproto",
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@agentproto/driver-agent-cli": "2.0
|
|
46
|
+
"@agentproto/driver-agent-cli": "2.1.0",
|
|
47
|
+
"@agentproto/provider-kit": "0.4.0"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@types/node": "^25.6.2",
|