Fix bridge history, profile models, and Windows gateway handling (#845)

* feat: support profile-aware group chat bridge flows

* feat: route cron jobs through hermes cli

* Fix group chat routing and isolate bridge tests

* Add Grok image-to-video media skill

* Default Grok videos to media directory

* Fix bridge profile fallback and cron repeat clearing

* Refine bridge chat and gateway platform handling

* Filter bridge tool-call text deltas

* Preserve structured bridge chat history

* Prepare beta release build artifacts

* Fix Windows run profile resolution

* Fix Windows path compatibility checks

* Fix profile-scoped model page display

* Hide Windows subprocess windows for jobs and updates

* Hide Windows file backend subprocess windows

* Avoid Windows gateway restart lock conflicts

* Treat Windows gateway lock as running on startup

* Force release Windows gateway lock on restart

* Tighten Windows gateway lock cleanup

* Update chat e2e source expectation

* Bump package version to 0.5.30

---------

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
ekko
2026-05-19 16:09:59 +08:00
committed by GitHub
parent 3d74d78698
commit 9a9416c99c
129 changed files with 7017 additions and 1838 deletions
+74 -14
View File
@@ -1,10 +1,24 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'fs'
import { tmpdir } from 'os'
import { join } from 'path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
vi.mock('../../packages/server/src/services/gateway-bootstrap', () => ({
getGatewayManagerInstance: () => ({
getUpstream: () => 'http://127.0.0.1:8642',
getApiKey: () => null,
}),
const testState = vi.hoisted(() => ({
profileDir: '',
execFile: vi.fn(),
}))
vi.mock('../../packages/server/src/services/hermes/hermes-profile', () => ({
getActiveProfileName: () => 'default',
getProfileDir: () => testState.profileDir || '/fake/home/.hermes',
}))
vi.mock('../../packages/server/src/services/hermes/hermes-path', () => ({
getHermesBin: () => '/fake/bin/hermes',
}))
vi.mock('child_process', () => ({
execFile: testState.execFile,
}))
const mockFetch = vi.fn()
@@ -33,12 +47,25 @@ function createMockCtx(overrides: Record<string, any> = {}) {
return ctx
}
describe('Hermes jobs controller proxy', () => {
describe('Hermes jobs controller', () => {
let tempDir = ''
beforeEach(() => {
vi.clearAllMocks()
tempDir = mkdtempSync(join(tmpdir(), 'hermes-web-ui-jobs-test-'))
testState.profileDir = tempDir
testState.execFile.mockImplementation((_bin, _args, _opts, cb) => {
cb(null, { stdout: '', stderr: '' })
})
})
it('passes through upstream validation status and body instead of masking it as 502', async () => {
afterEach(() => {
if (tempDir) rmSync(tempDir, { recursive: true, force: true })
tempDir = ''
testState.profileDir = ''
})
it('returns 404 before editing when the local cron job does not exist', async () => {
mockFetch.mockResolvedValue({
ok: false,
status: 400,
@@ -50,18 +77,51 @@ describe('Hermes jobs controller proxy', () => {
const ctx = createMockCtx()
await update(ctx)
expect(ctx.status).toBe(400)
expect(ctx.body).toEqual({ error: 'Prompt must be ≤ 5000 characters' })
expect(ctx.set).toHaveBeenCalledWith('Content-Type', 'application/json')
expect(ctx.status).toBe(404)
expect(ctx.body).toEqual({ error: { message: 'Job not found' } })
expect(mockFetch).not.toHaveBeenCalled()
})
it('keeps real proxy connection failures as 502', async () => {
it('does not call the removed gateway proxy path for missing jobs', async () => {
mockFetch.mockRejectedValue(new Error('ECONNREFUSED'))
const ctx = createMockCtx()
await update(ctx)
expect(ctx.status).toBe(502)
expect(ctx.body).toEqual({ error: { message: 'Proxy error: ECONNREFUSED' } })
expect(ctx.status).toBe(404)
expect(ctx.body).toEqual({ error: { message: 'Job not found' } })
expect(mockFetch).not.toHaveBeenCalled()
})
it('clears repeat by passing repeat 0 to Hermes CLI', async () => {
const cronDir = join(tempDir, 'cron')
mkdirSync(cronDir, { recursive: true })
writeFileSync(join(cronDir, 'jobs.json'), JSON.stringify({
jobs: [{
job_id: 'abc123abc123',
id: 'abc123abc123',
name: 'daily',
schedule: { kind: 'cron', expr: '0 9 * * *', display: '0 9 * * *' },
schedule_display: '0 9 * * *',
prompt: 'run daily',
repeat: { times: 3, completed: 1 },
}],
}))
const ctx = createMockCtx({
request: { body: { repeat: null } },
})
await update(ctx)
expect(ctx.status).toBe(200)
expect(testState.execFile).toHaveBeenCalledWith(
'/fake/bin/hermes',
['cron', 'edit', 'abc123abc123', '--repeat', '0'],
expect.objectContaining({
env: expect.objectContaining({ HERMES_HOME: tempDir }),
windowsHide: true,
}),
expect.any(Function),
)
})
})