hermes-agent/apps/desktop/e2e/new-bot-config-on-disk.spec.ts
teknium1 b5a9efea06 fix(cli): inherit the launch profile's custom provider gateway with its model
A profile created without a clone source copies the launch profile's
`model` block so it can run. When that block points at a custom
`providers:` gateway (self-hosted / local endpoint), `model.provider:
my-gateway` alone is "Unknown provider 'my-gateway'" on the new bot's very
first turn — created, but unable to run, the same on-arrival failure
#101885 / #94071 describe for the built-in case (fixed in 01a3e9a44c).

launch_model_seed() returns the model block plus exactly that provider's
definition; both the CLI seed (_seed_model_config, also behind the
Desktop's profiles.create) and the gateway inheritance path
(_inherit_launch_model) write the same shape.

Live repro: e2e/new-bot-config-on-disk.spec.ts (New Bot → Fresh profile →
Create; asserts the created profile's config.yaml on disk and that the
intro turn completes) — red on origin/main with the banner "Unknown
provider 'mock'", green here.
2026-09-16 17:02:38 -07:00

81 lines
3.2 KiB
TypeScript

import { existsSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
import { type MockBackendFixture, setupMockBackend, waitForAppReady } from './fixtures'
import { expect, test } from './test'
// A bot created from the New Bot dialog WITHOUT a clone source (the "inherited
// from launch profile" path) must land on disk with a usable `model:` block in
// its own config.yaml and its introduction turn must actually run — a profile
// whose config.yaml lacks the block is dead on arrival ("No LLM provider
// configured" on the first message). Verified against storage truth (the
// created profile's config.yaml under HERMES_HOME), not the toast.
let fixture: MockBackendFixture | null = null
type Page = MockBackendFixture['page']
async function openBots(page: Page): Promise<void> {
const tab = page
.getByRole('button', { name: 'Bots', exact: true })
.or(page.getByRole('tab', { name: 'Bots', exact: true }))
.first()
await tab.click()
await expect(page.getByRole('button', { name: 'New bot or group chat' })).toBeVisible()
}
test.beforeAll(async () => {
fixture = await setupMockBackend()
await waitForAppReady(fixture, 120_000)
})
// eslint-disable-next-line no-empty-pattern
test.afterEach(async ({}, info) => {
if (!fixture) {
return
}
await info.attach('native-window', { body: await fixture.page.screenshot(), contentType: 'image/png' })
const cfg = join(fixture.sandbox.hermesHome, 'profiles', 'fresh-scout', 'config.yaml')
await info.attach('created-config', {
body: existsSync(cfg) ? readFileSync(cfg) : Buffer.from('<missing>'),
contentType: 'text/plain'
})
})
test.afterAll(async () => {
await fixture?.cleanup()
fixture = null
})
test('a fresh (non-clone) bot gets a runnable model block on disk', async () => {
test.setTimeout(300_000)
const page = fixture!.page
await openBots(page)
await page.getByRole('button', { name: 'New bot or group chat' }).click()
await page.getByRole('menuitem', { name: 'New Bot' }).click()
const dialog = page.getByRole('dialog', { name: 'New Bot' })
await dialog.getByPlaceholder('inbox-triage').fill('fresh-scout')
await dialog.getByPlaceholder('Inbox Triage').fill('Fresh Scout')
await dialog.getByRole('button', { name: 'Advanced' }).click()
// "Fresh profile" = no clone source; the model must be inherited, not cloned.
await dialog.getByRole('combobox').filter({ hasText: /default|Fresh profile/ }).first().click()
await page.getByRole('option', { name: 'Fresh profile (bundled skills)' }).click()
await dialog.getByRole('button', { name: 'Create Bot' }).click()
await expect(dialog).toBeHidden({ timeout: 60_000 })
// Storage truth: the created profile's own config.yaml carries the model block.
const cfgPath = join(fixture!.sandbox.hermesHome, 'profiles', 'fresh-scout', 'config.yaml')
await expect.poll(() => existsSync(cfgPath), { timeout: 30_000 }).toBe(true)
const cfg = readFileSync(cfgPath, 'utf8')
expect(cfg).toMatch(/^model:/m)
expect(cfg).toMatch(/provider:\s*mock/)
expect(cfg).toMatch(/default:\s*mock-model/)
// The inherited model rides a custom `providers:` gateway; its definition must travel with it
// or the first turn dies with "Unknown provider 'mock'".
expect(cfg).toMatch(/^providers:\n\s+mock:/m)
})