open-design/e2e/tests/structured-streams.test.ts
PerishFire c6d11018a0
Refresh desktop integration control plane (#123)
* feat(dev): add desktop tools-dev control plane

* refactor(sidecar): split Open Design contracts

Move Open Design-specific sidecar protocol definitions into @open-design/contracts so sidecar and platform can remain descriptor-driven primitives.

* refactor(daemon): organize package sources

Keep daemon app code, tests, and sidecar entrypoints in separate package directories so each layer can be built and verified independently.

* chore(repo): streamline maintenance entrypoints

Centralize agent guidance by directory and reduce root command chains while preserving the existing build scope.

* docs: translate agent guidance to English

* fix(sidecar): tolerate stale IPC sockets

Remove stale Unix socket files only after confirming no listener is active, so tools-dev can restart after unclean shutdowns.
2026-04-30 14:23:53 +08:00

61 lines
1.7 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { createClaudeStreamHandler } from '../../apps/daemon/src/claude-stream.js';
import { createCopilotStreamHandler } from '../../apps/daemon/src/copilot-stream.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 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' }],
},
});
});
});