Import the client, server, skills, tests, and build scripts as the starting point for the rebuild, then trim the surfaces this project does not ship: Electron desktop packaging, the marketing website, and the ESP32 firmware tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows. Rename the package and CLI entry points to hermes-ui, drop the prepare hook so npm ci no longer triggers a build, and drop the removed tsconfig and nodemon references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs so the documented package map and hard rules match this repository. reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
53 lines
2.0 KiB
TypeScript
53 lines
2.0 KiB
TypeScript
import { mkdtemp, rm, writeFile } from 'fs/promises'
|
|
import { join } from 'path'
|
|
import { tmpdir } from 'os'
|
|
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
import { convertContentBlocks, convertContentBlocksForAgent } from '../../packages/server/src/services/hermes/run-chat/content-blocks'
|
|
|
|
let tempDir = ''
|
|
|
|
describe('run chat content blocks', () => {
|
|
beforeEach(async () => {
|
|
tempDir = await mkdtemp(join(tmpdir(), 'hermes-content-blocks-'))
|
|
})
|
|
|
|
afterEach(async () => {
|
|
if (tempDir) await rm(tempDir, { recursive: true, force: true })
|
|
})
|
|
|
|
it('keeps API image conversion as base64 input_image only', async () => {
|
|
const imagePath = join(tempDir, 'image.png')
|
|
await writeFile(imagePath, Buffer.from([1, 2, 3]))
|
|
|
|
const parts = await convertContentBlocks([
|
|
{ type: 'text', text: 'animate this' },
|
|
{ type: 'image', name: 'image.png', path: imagePath, media_type: 'image/png' },
|
|
])
|
|
|
|
expect(parts).toHaveLength(2)
|
|
expect(parts[0]).toEqual({ type: 'input_text', text: 'animate this' })
|
|
expect(parts[1].type).toBe('input_image')
|
|
expect(parts[1].image_url).toMatch(/^data:image\/png;base64,/)
|
|
expect(JSON.stringify(parts)).not.toContain('Local image path for tools')
|
|
})
|
|
|
|
it('adds local file path text for bridge agents while preserving the image data', async () => {
|
|
const imagePath = join(tempDir, 'image.png')
|
|
await writeFile(imagePath, Buffer.from([1, 2, 3]))
|
|
|
|
const parts = await convertContentBlocksForAgent([
|
|
{ type: 'text', text: 'animate this' },
|
|
{ type: 'image', name: 'image.png', path: imagePath, media_type: 'image/png' },
|
|
])
|
|
|
|
expect(parts).toHaveLength(3)
|
|
expect(parts[0]).toEqual({ type: 'text', text: 'animate this' })
|
|
expect(parts[1]).toEqual({
|
|
type: 'text',
|
|
text: `[Attached image: image.png]\nLocal image path for tools: ${imagePath}`,
|
|
})
|
|
expect(parts[2].type).toBe('image_url')
|
|
expect(parts[2].image_url?.url).toMatch(/^data:image\/png;base64,/)
|
|
})
|
|
})
|