Initial import: open-design source for helix-mind.ai distribution
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 2m6s
refresh-contributors-wall / Refresh contributors wall cache bust (push) Failing after 12s

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/*)
This commit is contained in:
marco
2026-05-06 20:50:24 +02:00
commit 5dd70b5016
1336 changed files with 287186 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
export type ParsedSseFrame =
| { kind: 'event'; event: string; data: Record<string, unknown>; id?: string }
| { kind: 'comment'; comment: string }
| { kind: 'empty' };
export function parseSseFrame(frame: string): ParsedSseFrame | null {
const lines = frame.split('\n');
const comments: string[] = [];
let event = 'message';
let id: string | undefined;
const dataLines: string[] = [];
for (const rawLine of lines) {
const line = rawLine.endsWith('\r') ? rawLine.slice(0, -1) : rawLine;
if (line.startsWith(':')) {
comments.push(line.slice(1).trimStart());
} else if (line.startsWith('event: ')) {
event = line.slice(7).trim();
} else if (line.startsWith('id: ')) {
id = line.slice(4).trim();
} else if (line.startsWith('data: ')) {
dataLines.push(line.slice(6));
}
}
if (dataLines.length === 0) {
if (comments.length > 0) {
return { kind: 'comment', comment: comments.join('\n') };
}
return { kind: 'empty' };
}
try {
return { kind: 'event', event, data: JSON.parse(dataLines.join('\n')), ...(id ? { id } : {}) };
} catch {
return null;
}
}