Files
fusion/plugins/fusion-plugin-hermes-runtime/dist/runtime-adapter.js
Fusion 6e65786bc5 fix(plugins): re-export probe symbols + declare plugin deps in dashboard
- Hermes / OpenClaw plugin index.ts now re-export `probeHermesBinary` /
  `probeOpenClawBinary` and their status types so the dashboard's
  `runtime-provider-probes.ts` façade can import them via the public
  package entry instead of deep paths.
- Dashboard `package.json` adds `@fusion-plugin-examples/hermes-runtime`,
  `…/openclaw-runtime`, `…/paperclip-runtime` as workspace deps so
  pnpm symlinks them into `packages/dashboard/node_modules/`. Without
  these, the new probe imports failed with "Cannot find module" during
  `pnpm typecheck`.

This clears 6 of the 9 outstanding typecheck errors. The remaining 3 are
in the in-flight Hermes plugin rewrite (runtime-adapter still imports
from a deleted `./pi-module.js`; the new `index.ts` calls a factory
with the wrong arg type) and should be resolved by the same change set
that landed the rewrite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 22:17:54 -07:00

62 lines
2.2 KiB
JavaScript

/**
* Hermes Runtime Adapter — drives the local `hermes` CLI as a subprocess.
*
* Each call to `promptWithFallback` invokes `hermes chat -q ... -Q --source tool`
* and captures the resulting `session_id:` line. Subsequent calls on the same
* session pass `--resume <id>` to continue the conversation.
*/
import { invokeHermesCli, resolveCliSettings } from "./cli-spawn.js";
export class HermesRuntimeAdapter {
id = "hermes";
name = "Hermes Runtime";
settings;
constructor(settings) {
this.settings = resolveCliSettings(settings);
}
async createSession(options) {
const session = {
model: undefined,
systemPrompt: options.systemPrompt,
messages: [],
apiKey: undefined,
thinkingLevel: undefined,
sessionId: "",
lastModelDescription: this.describeFromSettings(),
callbacks: {
onText: options.onText,
onThinking: options.onThinking,
onToolStart: options.onToolStart,
onToolEnd: options.onToolEnd,
},
dispose: () => undefined,
};
return { session, sessionFile: undefined };
}
async promptWithFallback(session, prompt, _options) {
const resumeId = session.sessionId || undefined;
const result = await invokeHermesCli(prompt, this.settings, resumeId);
session.sessionId = result.sessionId;
session.lastModelDescription = this.describeFromSettings();
if (result.body) {
session.callbacks.onText?.(result.body);
}
}
describeModel(session) {
return session.lastModelDescription || this.describeFromSettings();
}
async dispose(_session) {
// No persistent resources to release — the hermes CLI process exits per turn.
}
describeFromSettings() {
const provider = this.settings.provider;
const model = this.settings.model;
if (provider && model)
return `hermes/${provider}/${model}`;
if (model)
return `hermes/${model}`;
if (provider)
return `hermes/${provider}`;
return "hermes";
}
}
//# sourceMappingURL=runtime-adapter.js.map