a81a450e7e
Merged into tinqs/studio: - cmd/tinqs-cli/ — tinqs-cli (Go binary, from bot/cli) - cmd/tea/ — Gitea CLI tool (from tinqs/cli-tea) - services/bot/ — Bot service (from tinqs-ltd/bot on git.arikigame.com) - services/admin/ — Admin panel (from tinqs/admin) - services/team-tool/ — Team Tool (from tinqs/team-tool) - services/proxy/ — tinqs-proxy (from bot/proxy) - web/landing/ — tinqs.com website (from tinqs/website) - web/docs/ — Platform docs (from tinqs/docs) - web/blog/ — Blog (placeholder) - runner/ — Ephemeral CI runner (from tinqs/runner) All source repos will be deleted after verification.
30 lines
739 B
TypeScript
30 lines
739 B
TypeScript
export type CaptionChunk = {
|
|
text: string;
|
|
timestamp: string;
|
|
speaker?: string;
|
|
};
|
|
|
|
const MS_PER_MINUTE = 60_000;
|
|
|
|
export function getLastNMinutes(
|
|
transcript: CaptionChunk[],
|
|
minutes: number
|
|
): CaptionChunk[] {
|
|
if (transcript.length === 0) return [];
|
|
const cutoff = Date.now() - minutes * MS_PER_MINUTE;
|
|
return transcript.filter((c) => {
|
|
const t = Date.parse(c.timestamp);
|
|
return !Number.isNaN(t) && t >= cutoff;
|
|
});
|
|
}
|
|
|
|
export function formatTranscript(chunks: CaptionChunk[]): string {
|
|
if (chunks.length === 0) return '(no transcript in window)';
|
|
return chunks
|
|
.map((c) => {
|
|
const who = c.speaker ? `${c.speaker}: ` : '';
|
|
return `[${c.timestamp}] ${who}${c.text}`;
|
|
})
|
|
.join('\n');
|
|
}
|