Files
hermes-web-ui/tests/server/model-run-prompt.test.ts
ekko 83e37bac02 feat: add outbound relay and MCU login flow (#1580)
* add global agent chat relay

* add model run MCP auth

* avoid codex prompt inflation

* guide codex to use hermes lan tools

* truncate long tool call previews

* write codex MCP env inline

* log codex developer prompt

* remove codex prompt debug logging

* fix codex chat tool history

* log codex chat proxy requests

* write codex proxy debug to server log

* log codex upstream tool requests

* expand codex mcp namespaces for custom providers

* remove codex proxy debug logging

* add hermes mcp openapi relay

* fix: improve mcp docs and chat run cleanup

* feat: add mcu relay login flow

* fix ci test expectations

* fix group chat deeplink e2e expectation

---------

Co-authored-by: Codex <codex@openai.com>
2026-06-16 09:16:26 +08:00

44 lines
1.9 KiB
TypeScript

import { existsSync, mkdtempSync, readFileSync, rmSync } from 'fs'
import { tmpdir } from 'os'
import { join } from 'path'
import { afterEach, describe, expect, it, vi } from 'vitest'
const issueModelRunJwtMock = vi.hoisted(() => vi.fn(async () => 'model-run-token'))
const homes: string[] = []
vi.mock('../../packages/server/src/middleware/user-auth', () => ({
issueModelRunJwt: issueModelRunJwtMock,
}))
describe('model run prompt', () => {
afterEach(() => {
delete process.env.HERMES_WEB_UI_HOME
for (const home of homes.splice(0)) rmSync(home, { recursive: true, force: true })
})
it('stores the model-run token under the profile and keeps the token out of the prompt', async () => {
const home = mkdtempSync(join(tmpdir(), 'hermes-model-run-prompt-'))
homes.push(home)
process.env.HERMES_WEB_UI_HOME = home
const { writeModelRunProfileToken, modelRunProfileTokenPath } = await import('../../packages/server/src/services/hermes/run-chat/model-run-prompt')
await writeModelRunProfileToken({ id: 1, username: 'admin', role: 'super_admin' }, 'default')
const tokenPath = modelRunProfileTokenPath('default')
expect(issueModelRunJwtMock).toHaveBeenCalledWith({ id: 1, username: 'admin', role: 'super_admin' })
expect(tokenPath).toBe(join(home, 'profiles', 'default', '.model-run-token'))
expect(readFileSync(tokenPath, 'utf-8').trim()).toBe('model-run-token')
})
it('returns profile instructions without writing a token for anonymous runs', async () => {
const home = mkdtempSync(join(tmpdir(), 'hermes-model-run-prompt-'))
homes.push(home)
process.env.HERMES_WEB_UI_HOME = home
const { writeModelRunProfileToken, modelRunProfileTokenPath } = await import('../../packages/server/src/services/hermes/run-chat/model-run-prompt')
await writeModelRunProfileToken(undefined, 'research')
expect(existsSync(modelRunProfileTokenPath('research'))).toBe(false)
})
})