mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
- hermes-ink: export `withInkSuspended()` + `useExternalProcess()` that pause/resume Ink around an arbitrary external process (built on the existing enterAlternateScreen/exitAlternateScreen plumbing) - tui: `launchHermesCommand(args)` spawns the `hermes` binary with inherited stdio, with `HERMES_BIN` override for non-standard launches - tui: `/model` and `/setup` slash commands invoke the CLI wizards in-place, then re-preflight `setup.status` and auto-start a session on success — no more exit-and-relaunch to finish first-run setup - setup panel now advertises those slashes instead of only pointing users back at the shell
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import type { RunExternalProcess } from '@hermes/ink'
|
|
|
|
import type { SetupStatusResponse } from '../gatewayTypes.js'
|
|
import type { LaunchResult } from '../lib/externalCli.js'
|
|
|
|
import type { SlashHandlerContext } from './interfaces.js'
|
|
import { patchUiState } from './uiStore.js'
|
|
|
|
export interface RunExternalSetupOptions {
|
|
args: string[]
|
|
ctx: Pick<SlashHandlerContext, 'gateway' | 'session' | 'transcript'>
|
|
done: string
|
|
launcher: (args: string[]) => Promise<LaunchResult>
|
|
suspend: (run: RunExternalProcess) => Promise<void>
|
|
}
|
|
|
|
export async function runExternalSetup({ args, ctx, done, launcher, suspend }: RunExternalSetupOptions) {
|
|
const { gateway, session, transcript } = ctx
|
|
|
|
transcript.sys(`launching \`hermes ${args.join(' ')}\`…`)
|
|
patchUiState({ status: 'setup running…' })
|
|
|
|
let result: LaunchResult = { code: null }
|
|
|
|
await suspend(async () => {
|
|
result = await launcher(args)
|
|
})
|
|
|
|
if (result.error) {
|
|
transcript.sys(`error launching hermes: ${result.error}`)
|
|
patchUiState({ status: 'setup required' })
|
|
|
|
return
|
|
}
|
|
|
|
if (result.code !== 0) {
|
|
transcript.sys(`hermes ${args[0]} exited with code ${result.code}`)
|
|
patchUiState({ status: 'setup required' })
|
|
|
|
return
|
|
}
|
|
|
|
const setup = await gateway.rpc<SetupStatusResponse>('setup.status', {})
|
|
|
|
if (setup?.provider_configured === false) {
|
|
transcript.sys('still no provider configured')
|
|
patchUiState({ status: 'setup required' })
|
|
|
|
return
|
|
}
|
|
|
|
transcript.sys(done)
|
|
session.newSession()
|
|
}
|