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.
49 lines
1.9 KiB
TypeScript
49 lines
1.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { filterBridgeToolCallMarkupDelta, flushPendingToolCallMarkup } from '../../packages/server/src/services/hermes/run-chat/bridge-delta'
|
|
|
|
describe('run-chat bridge delta filtering', () => {
|
|
it('keeps ordinary assistant text', () => {
|
|
const state = {}
|
|
|
|
expect(filterBridgeToolCallMarkupDelta(state, 'hello')).toBe('hello')
|
|
expect(filterBridgeToolCallMarkupDelta(state, ' world')).toBe(' world')
|
|
})
|
|
|
|
it('removes complete textual tool-call markup from bridge deltas', () => {
|
|
const state = {}
|
|
const delta = 'Before\n[Calling tool: terminal with arguments: {"cmd":"pwd"}]\nAfter'
|
|
|
|
expect(filterBridgeToolCallMarkupDelta(state, delta)).toBe('Before\nAfter')
|
|
})
|
|
|
|
it('removes tool-call markup split across multiple chunks', () => {
|
|
const state = {}
|
|
|
|
expect(filterBridgeToolCallMarkupDelta(state, '[Calling tool: terminal with arguments: {"cmd"')).toBe('')
|
|
expect(filterBridgeToolCallMarkupDelta(state, ':"pwd"}]\nDone')).toBe('Done')
|
|
})
|
|
|
|
it('keeps json arrays and brackets inside tool arguments from leaking', () => {
|
|
const state = {}
|
|
const delta = '[Calling tool: terminal with arguments: {"cmd":"printf \\"[x]\\"","items":["a","b"]}]\nDone'
|
|
|
|
expect(filterBridgeToolCallMarkupDelta(state, delta)).toBe('Done')
|
|
})
|
|
|
|
it('holds a partial marker suffix until the next chunk', () => {
|
|
const state = {}
|
|
|
|
expect(filterBridgeToolCallMarkupDelta(state, 'Text [Call')).toBe('Text ')
|
|
expect(filterBridgeToolCallMarkupDelta(state, 'ing tool: terminal with arguments: {}]\nDone')).toBe('Done')
|
|
})
|
|
|
|
it('flushes an orphan partial marker suffix when no text chunk follows', () => {
|
|
const state = {}
|
|
|
|
expect(filterBridgeToolCallMarkupDelta(state, 'Text [Call')).toBe('Text ')
|
|
expect(flushPendingToolCallMarkup(state)).toBe('[Call')
|
|
expect(flushPendingToolCallMarkup(state)).toBe('')
|
|
})
|
|
})
|