@agentproto/adapter-hermes 0.1.1 → 0.2.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/HERMES.md CHANGED
@@ -28,16 +28,25 @@ session:
28
28
  idle_timeout_ms: 1800000
29
29
  context_carryover: true
30
30
  models:
31
- default: anthropic/claude-sonnet-4-6
31
+ default: z-ai/glm-5.2
32
32
  allowed:
33
- - anthropic/claude-sonnet-4-6
34
- - anthropic/claude-opus-4-7
35
- - openai/gpt-4
33
+ - z-ai/glm-5.2
34
+ - deepseek/deepseek-v4-pro
36
35
  - meta-llama/llama-3.3-70b
36
+ - openai/gpt-4
37
+ # Anthropic models are reserved for the dedicated claude-code adapter —
38
+ # hermes must NEVER route to them, even if a caller passes the id
39
+ # explicitly. Enforced at compose time (RuntimeConfigError).
40
+ deny:
41
+ - anthropic/*
42
+ - claude-*
37
43
  env:
38
- anthropic: ANTHROPIC_API_KEY
39
44
  openrouter: OPENROUTER_API_KEY
40
45
  openai: OPENAI_API_KEY
46
+ # hermes keeps its own configured default when given a model via the ACP
47
+ # session config — selection must go through a `/model <id>` control turn
48
+ # instead. See the "Model selection" section below.
49
+ apply: command
41
50
  capabilities:
42
51
  streaming: true
43
52
  tool_calls: true
@@ -46,6 +55,41 @@ capabilities:
46
55
  multimodal: true
47
56
  resumable: false
48
57
  bidirectional: true
58
+ modes:
59
+ - id: default
60
+ description: Standard interactive mode — loads ~/.hermes/config.yaml and auto-injects rules/memory/preloaded skills as usual.
61
+ - id: lean
62
+ description: >-
63
+ Skip ~/.hermes/config.yaml, cutting the skills/rules/memory scaffolding
64
+ hermes would otherwise preload into context. Composed as
65
+ `hermes --ignore-user-config acp` — the global flag MUST precede the
66
+ `acp` subcommand baked into `bin_args`, which is why this needs
67
+ `bin_args_prepend` rather than `bin_args_append`.
68
+ bin_args_prepend: ["--ignore-user-config"]
69
+ options:
70
+ - id: skills
71
+ type: string
72
+ description: >-
73
+ Preload one or more agentskills.io-compatible skills for the session
74
+ (comma-separate for multiple), via hermes' `--skills` global flag.
75
+ Same prepend-before-`acp` constraint as the `lean` mode.
76
+ bin_args_prepend: ["--skills", "{value}"]
77
+ - id: model
78
+ type: string
79
+ description: >-
80
+ Model ID routed through OpenRouter/OpenAI (e.g.
81
+ 'deepseek/deepseek-v4-pro', 'z-ai/glm-5.2', 'moonshotai/kimi-k2').
82
+ Free-form: any valid OpenRouter/OpenAI id is accepted even when not
83
+ in `allowed`. Anthropic models are denied (see `models.deny`) — use
84
+ the claude-code adapter for those. Applied via a `/model <id>`
85
+ control turn after the session is created (hermes ignores the ACP
86
+ session model config). Omit to use the hermes default.
87
+ - id: effort
88
+ type: enum
89
+ enum: [low, medium, high, xhigh, max]
90
+ description: >-
91
+ Reasoning effort level passed to hermes via ACP newSession. Omit to
92
+ use the hermes default.
49
93
  tags: [hermes, nous, acp, agent-runtime]
50
94
  ---
51
95
 
@@ -74,6 +118,34 @@ resolved from the operator's secret store and passed via
74
118
  `OPENROUTER_API_KEY`, `ANTHROPIC_API_KEY`, or `OPENAI_API_KEY` MUST
75
119
  be present at boot.
76
120
 
121
+ ## Model selection
122
+
123
+ Hermes does **not** read the model from its ACP session config — it keeps
124
+ whatever its own `~/.hermes/config.yaml` resolves as default. So unlike the
125
+ claude-code / claude-sdk adapters (which pin the model at spawn via a CLI
126
+ flag), the `model` option here is applied as a **`/model <id>` control turn
127
+ sent after the session is created** (`models.apply: command`).
128
+
129
+ Two consequences an operator should know:
130
+
131
+ - **Provider is whatever hermes resolves at session start.** The `/model`
132
+ turn only switches the model id; it does not re-resolve the provider. If
133
+ `~/.hermes/config.yaml`'s default provider is `moa` (Mixture of Agents),
134
+ a `/model moonshotai/kimi-k2` turn targets a model moa can't serve and
135
+ fails. Point hermes at the right provider (e.g. set
136
+ `model.default.provider: openrouter`, or a direct `moonshot` provider
137
+ block) before relying on the `model` option. The interactive CLI
138
+ `hermes --model <id>` resolves the provider at launch and does not have
139
+ this constraint.
140
+ - **No `provider` option is exposed.** Agentproto can only set the model
141
+ id, not force OpenRouter/Moonshot routing. To run Kimi through a
142
+ provider-pinned path, prefer the `claude-sdk` adapter with
143
+ `mode: moonshot` (or `mode: openrouter` + a model slug).
144
+
145
+ `models.deny` (`anthropic/*`, `claude-*`) is enforced at compose time — a
146
+ RuntimeConfigError — so the budget arm can never silently burn premium
147
+ Anthropic spend.
148
+
77
149
  ## Protocol
78
150
 
79
151
  `protocol: acp` — Hermes ships an ACP server in
package/dist/index.mjs CHANGED
@@ -28,7 +28,10 @@ var hermes = defineAgentCli({
28
28
  },
29
29
  auth: {
30
30
  ref: "./SECRETS.md",
31
- state: { env: ["OPENROUTER_API_KEY", "ANTHROPIC_API_KEY", "OPENAI_API_KEY"] }
31
+ // No ANTHROPIC_API_KEY hermes is the budget arm and deliberately does
32
+ // not route to Anthropic (see models.deny). Anthropic stays exclusive to
33
+ // the claude-code adapter.
34
+ state: { env: ["OPENROUTER_API_KEY", "OPENAI_API_KEY"] }
32
35
  },
33
36
  sandbox: "./SANDBOX.md",
34
37
  protocol: "acp",
@@ -49,18 +52,22 @@ var hermes = defineAgentCli({
49
52
  models: {
50
53
  // Cheap OpenRouter models by default — hermes is the budget delegation
51
54
  // arm (a Sonnet default would defeat the purpose). glm-5.2 + deepseek
52
- // are the go-to cheap coders; the bigger models stay available.
55
+ // are the go-to cheap coders. `allowed` is only the curated menu: the
56
+ // `model` option is free-form, so any OpenRouter id (kimi, qwen, …) can
57
+ // still be passed even when it isn't listed here.
53
58
  default: "z-ai/glm-5.2",
54
59
  allowed: [
55
60
  "z-ai/glm-5.2",
56
61
  "deepseek/deepseek-v4-pro",
57
62
  "meta-llama/llama-3.3-70b",
58
- "anthropic/claude-sonnet-4-6",
59
- "anthropic/claude-opus-4-7",
60
63
  "openai/gpt-4"
61
64
  ],
65
+ // Anthropic models are reserved for the dedicated claude-code adapter —
66
+ // hermes must NEVER route to them, even if a caller passes the id
67
+ // explicitly. Enforced at compose time (RuntimeConfigError), so the
68
+ // budget arm can't silently burn premium Anthropic spend.
69
+ deny: ["anthropic/*", "claude-*"],
62
70
  env: {
63
- anthropic: "ANTHROPIC_API_KEY",
64
71
  openrouter: "OPENROUTER_API_KEY",
65
72
  openai: "OPENAI_API_KEY"
66
73
  },
@@ -78,15 +85,35 @@ var hermes = defineAgentCli({
78
85
  resumable: false,
79
86
  bidirectional: true
80
87
  },
88
+ modes: [
89
+ {
90
+ id: "default",
91
+ description: "Standard interactive mode \u2014 loads ~/.hermes/config.yaml and auto-injects rules/memory/preloaded skills as usual."
92
+ },
93
+ {
94
+ id: "lean",
95
+ description: "Skip ~/.hermes/config.yaml, cutting the skills/rules/memory scaffolding hermes would otherwise preload into context. Composed as `hermes --ignore-user-config acp` \u2014 the global flag MUST precede the `acp` subcommand baked into `bin_args`, which is why this needs bin_args_prepend rather than bin_args_append.",
96
+ bin_args_prepend: ["--ignore-user-config"],
97
+ status: "noop",
98
+ status_note: "Measured no-op: --ignore-user-config skips ~/.hermes/config.yaml, but hermes skills live in a separate skills dir (not config), so prompt-size is byte-identical. The real lean lever is narrowing the mounted toolset, not this flag."
99
+ }
100
+ ],
81
101
  options: [
102
+ {
103
+ id: "skills",
104
+ type: "string",
105
+ description: "Preload one or more agentskills.io-compatible skills for the session (comma-separate for multiple), via hermes' `--skills` global flag. Same prepend-before-`acp` constraint as the `lean` mode.",
106
+ bin_args_prepend: ["--skills", "{value}"]
107
+ },
82
108
  {
83
109
  id: "model",
84
- // string (not enum) so any valid OpenRouter/Anthropic/OpenAI model ID is
85
- // accepted without requiring a code change to expand the list. Applied via
86
- // ACP newSession(model:...) — hermes reads the model from the ACP session
87
- // config, not from its own CLI args.
110
+ // string (not enum) so any valid OpenRouter/OpenAI model ID is accepted
111
+ // without a code change to expand the list. Applied via ACP
112
+ // newSession(model:...) — hermes reads the model from the ACP session
113
+ // config, not from its own CLI args. Anthropic ids are denied
114
+ // (models.deny) — those are reserved for the claude-code adapter.
88
115
  type: "string",
89
- description: "Model ID routed through OpenRouter/Anthropic/OpenAI (e.g. 'anthropic/claude-sonnet-4-6', 'deepseek/deepseek-v4-pro', 'z-ai/glm-5.2'). 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."
116
+ 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."
90
117
  },
91
118
  {
92
119
  id: "effort",
@@ -95,7 +122,15 @@ var hermes = defineAgentCli({
95
122
  description: "Reasoning effort level passed to hermes via ACP newSession. Omit to use the hermes default."
96
123
  }
97
124
  ],
98
- tags: ["hermes", "nous", "acp", "agent-runtime"]
125
+ tags: ["hermes", "nous", "acp", "agent-runtime"],
126
+ metadata: {
127
+ // Opts hermes into `agentproto install skill/<slug>` fan-out (no
128
+ // --target given): skills get copied one subdir per skill into
129
+ // hermes's own skills directory, alongside whatever it ships
130
+ // natively. See packages/cli/src/commands/skill-install/types.ts
131
+ // `AdapterSkillsTarget` for the shape + guard.
132
+ skills: { format: "flat-dir", dir: "~/.hermes/skills" }
133
+ }
99
134
  });
100
135
  function hermesRuntime() {
101
136
  return createAgentCliRuntime(hermes);
@@ -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,aAA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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 state: { env: [\"OPENROUTER_API_KEY\", \"ANTHROPIC_API_KEY\", \"OPENAI_API_KEY\"] },\n },\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; the bigger models stay available.\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 \"anthropic/claude-sonnet-4-6\",\n \"anthropic/claude-opus-4-7\",\n \"openai/gpt-4\",\n ],\n env: {\n anthropic: \"ANTHROPIC_API_KEY\",\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 options: [\n {\n id: \"model\",\n // string (not enum) so any valid OpenRouter/Anthropic/OpenAI model ID is\n // accepted without requiring a code change to expand the list. Applied via\n // ACP newSession(model:...) — hermes reads the model from the ACP session\n // config, not from its own CLI args.\n type: \"string\" as const,\n description:\n \"Model ID routed through OpenRouter/Anthropic/OpenAI \" +\n \"(e.g. 'anthropic/claude-sonnet-4-6', 'deepseek/deepseek-v4-pro', 'z-ai/glm-5.2'). \" +\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})\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":";;;;;;;;;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,EACA,OAAA,EAAS,cAAA;AAAA,EACT,QAAA,EAAU,KAAA;AAAA,EACV,GAAA,EAAK,qBAAA;AAAA,EACL,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,YAAA;AAAA,IACN,eAAA,EAAiB,IAAA;AAAA,IACjB,iBAAA,EAAmB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;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 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentproto/adapter-hermes",
3
- "version": "0.1.1",
3
+ "version": "0.2.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,7 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@agentproto/driver-agent-cli": "0.3.0"
46
+ "@agentproto/driver-agent-cli": "0.4.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/node": "^25.6.2",