Some checks failed
ci / Validate workspace (push) Successful in 12m32s
landing-page-ci / Validate landing page (push) Successful in 9m41s
landing-page-deploy / Deploy landing page (push) Failing after 5m23s
github-metrics / Generate repository metrics SVG (push) Failing after 2m3s
refresh-contributors-wall / Refresh contributors wall cache bust (push) Failing after 11s
This repository contains the open-design daemon CLI source code, built and packaged at https://helix-mind.ai/cli/open-design/latest.tgz for use by the HelixMind /design slash command. Licenses: Apache-2.0 (root) + MIT (skills/*)
93 lines
2.8 KiB
TypeScript
93 lines
2.8 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { createClaudeStreamHandler } from '../src/claude-stream.js';
|
|
import { createCopilotStreamHandler } from '../src/copilot-stream.js';
|
|
import { mapPiRpcEvent } from '../src/pi-rpc.js';
|
|
|
|
describe('structured agent stream fixtures', () => {
|
|
it('emits TodoWrite tool_use from Claude Code stream JSON', () => {
|
|
const events: unknown[] = [];
|
|
const handler = createClaudeStreamHandler((event: unknown) => events.push(event));
|
|
handler.feed(`${JSON.stringify({
|
|
type: 'assistant',
|
|
message: {
|
|
id: 'msg-1',
|
|
content: [
|
|
{
|
|
type: 'tool_use',
|
|
id: 'toolu-1',
|
|
name: 'TodoWrite',
|
|
input: {
|
|
todos: [{ content: 'Run QA', status: 'pending' }],
|
|
},
|
|
},
|
|
],
|
|
},
|
|
})}\n`);
|
|
handler.flush();
|
|
|
|
expect(events).toContainEqual({
|
|
type: 'tool_use',
|
|
id: 'toolu-1',
|
|
name: 'TodoWrite',
|
|
input: {
|
|
todos: [{ content: 'Run QA', status: 'pending' }],
|
|
},
|
|
});
|
|
});
|
|
|
|
it('emits TodoWrite tool_use from Pi RPC tool_execution events', () => {
|
|
const events: unknown[] = [];
|
|
const send = (_channel: string, payload: unknown) => { events.push(payload); };
|
|
const ctx = { runStartedAt: Date.now(), sentFirstToken: { value: false } };
|
|
|
|
mapPiRpcEvent(
|
|
{ type: 'tool_execution_start', toolCallId: 'pi-call-1', toolName: 'TodoWrite', args: { todos: [{ content: 'Run QA', status: 'pending' }] } },
|
|
send,
|
|
ctx,
|
|
);
|
|
mapPiRpcEvent(
|
|
{ type: 'tool_execution_end', toolCallId: 'pi-call-1', toolName: 'TodoWrite', result: { content: [{ type: 'text', text: 'written' }] }, isError: false },
|
|
send,
|
|
ctx,
|
|
);
|
|
|
|
expect(events).toContainEqual({
|
|
type: 'tool_use',
|
|
id: 'pi-call-1',
|
|
name: 'TodoWrite',
|
|
input: { todos: [{ content: 'Run QA', status: 'pending' }] },
|
|
});
|
|
expect(events).toContainEqual({
|
|
type: 'tool_result',
|
|
toolUseId: 'pi-call-1',
|
|
content: 'written',
|
|
isError: false,
|
|
});
|
|
});
|
|
|
|
it('emits TodoWrite tool_use from GitHub Copilot CLI JSON stream', () => {
|
|
const events: unknown[] = [];
|
|
const handler = createCopilotStreamHandler((event: unknown) => events.push(event));
|
|
handler.feed(`${JSON.stringify({
|
|
type: 'tool.execution_start',
|
|
data: {
|
|
toolCallId: 'call-1',
|
|
toolName: 'TodoWrite',
|
|
arguments: {
|
|
todos: [{ content: 'Run QA', status: 'pending' }],
|
|
},
|
|
},
|
|
})}\n`);
|
|
handler.flush();
|
|
|
|
expect(events).toContainEqual({
|
|
type: 'tool_use',
|
|
id: 'call-1',
|
|
name: 'TodoWrite',
|
|
input: {
|
|
todos: [{ content: 'Run QA', status: 'pending' }],
|
|
},
|
|
});
|
|
});
|
|
});
|