2026-06-19 12:42:28 +08:00
|
|
|
import { fileURLToPath } from 'node:url'
|
2026-07-14 05:00:54 +08:00
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
|
2026-06-19 12:42:28 +08:00
|
|
|
|
|
|
|
|
/**
|
2026-07-14 05:00:54 +08:00
|
|
|
* Keyless-by-nature Loader-path coverage for examples/echo-agent. The real
|
|
|
|
|
* tree uses its deterministic mock model, so this suite is both the boot smoke
|
|
|
|
|
* and the complete behavior proof for the example.
|
2026-06-19 12:42:28 +08:00
|
|
|
*/
|
|
|
|
|
|
2026-07-15 15:57:57 +08:00
|
|
|
const binScript = fileURLToPath(new URL('../../../packages/examples/stdio-demo/src/bin.ts', import.meta.url))
|
2026-06-21 12:03:44 +08:00
|
|
|
const configPath = fileURLToPath(new URL('../cordis.yml', import.meta.url))
|
2026-07-14 05:00:54 +08:00
|
|
|
const tsconfigPath = fileURLToPath(new URL('../../../tsconfig.json', import.meta.url))
|
|
|
|
|
|
|
|
|
|
async function runEcho(stdinLines: readonly string[]): Promise<string> {
|
|
|
|
|
const { stdout } = await runLoaderSmoke({
|
|
|
|
|
label: 'echo-agent',
|
|
|
|
|
tempDirPrefix: 'echo-smoke-',
|
|
|
|
|
binScript,
|
|
|
|
|
configPath,
|
|
|
|
|
tsconfigPath,
|
|
|
|
|
stdinLines,
|
2026-06-19 12:42:28 +08:00
|
|
|
})
|
2026-07-14 05:00:54 +08:00
|
|
|
return stdout
|
2026-06-19 12:42:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('echo-agent keyless smoke (real cordis.yml via the Loader)', () => {
|
|
|
|
|
it('boots, prints its welcome banner, and exits cleanly on stdin EOF', async () => {
|
2026-07-14 05:00:54 +08:00
|
|
|
expect(await runEcho([])).toContain('echo-agent ready.')
|
|
|
|
|
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
|
2026-06-19 12:42:28 +08:00
|
|
|
|
|
|
|
|
it('runs the echo tool round-trip for an "echo …" line', async () => {
|
2026-07-14 05:00:54 +08:00
|
|
|
const stdout = await runEcho(['echo hello world'])
|
2026-06-19 12:42:28 +08:00
|
|
|
expect(stdout).toContain('[tool call] echo')
|
|
|
|
|
expect(stdout).toContain('[tool result] ECHO: HELLO WORLD')
|
2026-07-14 05:00:54 +08:00
|
|
|
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
|
2026-06-19 12:42:28 +08:00
|
|
|
|
|
|
|
|
it('streams a direct canned reply for a non-echo line', async () => {
|
2026-07-14 05:00:54 +08:00
|
|
|
const stdout = await runEcho(['just chatting'])
|
2026-06-19 12:42:28 +08:00
|
|
|
expect(stdout).toContain('just chatting')
|
|
|
|
|
expect(stdout).not.toContain('[tool call]')
|
2026-07-14 05:00:54 +08:00
|
|
|
}, LOADER_SMOKE_TEST_TIMEOUT_MS)
|
2026-06-19 12:42:28 +08:00
|
|
|
})
|