π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
β¨ feat(cli): add lh meeting list and view (#22593)
Arvin Xu8221df2c53eb
diff --git a/apps/cli/src/commands/meeting.test.ts b/apps/cli/src/commands/meeting.test.tsnew file mode 100644index 00000000000..ee83d7e4e13--- /dev/null+++ b/apps/cli/src/commands/meeting.test.ts@@ -0,0 +1,195 @@+import { Command } from 'commander';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { log } from '../utils/logger';+import { registerMeetingCommand } from './meeting';++const { mockTrpcClient } = vi.hoisted(() => ({+ mockTrpcClient: {+ meeting: {+ detail: { query: vi.fn() },+ list: { query: vi.fn() },+ },+ },+}));++vi.mock('../api/client', () => ({ getTrpcClient: vi.fn(async () => mockTrpcClient) }));++const meetingRow = {+ durationMs: 65_000,+ id: 'meeting-1',+ language: 'zh',+ startedAt: new Date('2026-11-08T10:00:00Z').toISOString(),+ status: 'ready',+ title: 'Weekly sync',+};++const output = (spy: ReturnType<typeof vi.spyOn>) =>+ spy.mock.calls.map((call: unknown[]) => call.join(' ')).join('\n');++describe('meeting command', () => {+ let exitSpy: ReturnType<typeof vi.spyOn>;+ let consoleSpy: ReturnType<typeof vi.spyOn>;++ beforeEach(() => {+ exitSpy = vi.spyOn(process, 'exit').mockImplementation((() => {}) as any);+ consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});+ vi.spyOn(log, 'error').mockImplementation(() => {});+ mockTrpcClient.meeting.list.query.mockReset();+ mockTrpcClient.meeting.detail.query.mockReset();+ });++ afterEach(() => {+ vi.restoreAllMocks();+ });++ const run = (...args: string[]) => {+ const program = new Command();+ program.exitOverride();+ registerMeetingCommand(program);+ return program.parseAsync(['node', 'test', 'meeting', ...args]);+ };++ describe('list', () => {+ it('passes paging and status to the API and prints a table', async () => {+ mockTrpcClient.meeting.list.query.mockResolvedValue({ data: [meetingRow], success: true });++ await run('list', '-L', '5', '--offset', '10', '--status', 'ready');++ expect(mockTrpcClient.meeting.list.query).toHaveBeenCalledWith({+ limit: 5,+ offset: 10,+ status: 'ready',+ });+ expect(output(consoleSpy)).toContain('Weekly sync');+ expect(output(consoleSpy)).toContain('1:05');+ });++ it('leaves the duration blank while a meeting has none', async () => {+ mockTrpcClient.meeting.list.query.mockResolvedValue({+ data: [{ ...meetingRow, durationMs: null }],+ success: true,+ });++ await run('list');++ expect(output(consoleSpy)).not.toContain('0:00');+ });++ it('outputs the selected JSON fields', async () => {+ mockTrpcClient.meeting.list.query.mockResolvedValue({ data: [meetingRow], success: true });++ await run('list', '--json', 'id,status');++ expect(JSON.parse(output(consoleSpy))).toEqual([{ id: 'meeting-1', status: 'ready' }]);+ });++ it('reports an empty list', async () => {+ mockTrpcClient.meeting.list.query.mockResolvedValue({ data: [], success: true });++ await run('list');++ expect(output(consoleSpy)).toContain('No meetings found.');+ });++ it.each([+ ['--limit', '101'],+ ['--limit', '1.5'],+ ['--offset', '-1'],+ ])('rejects %s %s before calling the API', async (flag, value) => {+ await run('list', `${flag}=${value}`);++ expect(exitSpy).toHaveBeenCalledWith(1);+ expect(mockTrpcClient.meeting.list.query).not.toHaveBeenCalled();+ });++ it('rejects an unknown status', async () => {+ await expect(run('list', '--status', 'nope')).rejects.toThrow();+ expect(mockTrpcClient.meeting.list.query).not.toHaveBeenCalled();+ });+ });++ describe('view', () => {+ const detail = {+ ...meetingRow,+ audio: { url: 'https://cdn/a.webm' },+ localAudioPath: null,+ minutes: {+ actionItems: [+ { assigneeHint: 'Alice', id: 'a1', segmentIds: [], status: 'suggested', text: 'Ship it' },+ ],+ chapters: [{ endMs: 60_000, segmentIds: [], startMs: 0, title: 'Kickoff' }],+ decisions: [{ segmentIds: [], text: 'Use uuid' }],+ keywords: ['api'],+ summary: 'All good',+ },+ segmentSource: 'refine',+ segments: [+ { id: 's1', speakerId: 'sp1', startMs: 3_661_000, text: 'Hello' },+ { id: 's2', speakerId: null, startMs: 5_000, text: 'Unattributed' },+ ],+ speakers: [{ displayName: 'Alice', id: 'sp1', label: 'S1' }],+ };++ it('prints minutes and a transcript with speaker names', async () => {+ mockTrpcClient.meeting.detail.query.mockResolvedValue({ data: detail, success: true });++ await run('view', 'meeting-1', '--source', 'refine');++ expect(mockTrpcClient.meeting.detail.query).toHaveBeenCalledWith({+ id: 'meeting-1',+ source: 'refine',+ });+ const text = output(consoleSpy);+ for (const expected of [+ 'Weekly sync',+ 'https://cdn/a.webm',+ 'All good',+ 'Kickoff',+ 'Use uuid',+ 'Ship it',+ 'Transcript (refine)',+ '1:01:01',+ 'Alice',+ 'Hello',+ 'Unattributed',+ ]) {+ expect(text).toContain(expected);+ }+ });++ it('falls back to the diarization label and skips absent minutes', async () => {+ mockTrpcClient.meeting.detail.query.mockResolvedValue({+ data: {+ ...detail,+ audio: null,+ localAudioPath: '/tmp/a.wav',+ minutes: null,+ speakers: [{ displayName: null, id: 'sp1', label: 'S1' }],+ },+ success: true,+ });++ await run('view', 'meeting-1');++ const text = output(consoleSpy);+ expect(text).toContain('S1');+ expect(text).toContain('/tmp/a.wav');+ expect(text).not.toContain('Summary');+ });++ it('outputs JSON', async () => {+ mockTrpcClient.meeting.detail.query.mockResolvedValue({ data: detail, success: true });++ await run('view', 'meeting-1', '--json', 'id,segmentSource');++ expect(JSON.parse(output(consoleSpy))).toEqual({ id: 'meeting-1', segmentSource: 'refine' });+ });++ it('lets a server error reach the top-level handler', async () => {+ mockTrpcClient.meeting.detail.query.mockRejectedValue(new Error('Meeting not found'));++ await expect(run('view', 'missing')).rejects.toThrow('Meeting not found');+ });+ });+});diff --git a/apps/cli/src/commands/meeting.ts b/apps/cli/src/commands/meeting.tsnew file mode 100644index 00000000000..754ac9732a8--- /dev/null+++ b/apps/cli/src/commands/meeting.ts@@ -0,0 +1,177 @@+import { MEETING_SEGMENT_SOURCES, MEETING_STATUSES } from '@lobechat/types';+import { type Command, Option } from 'commander';+import pc from 'picocolors';++import { getTrpcClient } from '../api/client';+import { formatTimestamp, outputJson, printTable, timeAgo, truncate } from '../utils/format';+import { log } from '../utils/logger';++/** Offset within the recording as `m:ss`, or `h:mm:ss` from the first hour on. */+function formatOffset(ms: number): string {+ const totalSeconds = Math.floor(ms / 1000);+ const hours = Math.floor(totalSeconds / 3600);+ const minutes = Math.floor((totalSeconds % 3600) / 60);+ const seconds = String(totalSeconds % 60).padStart(2, '0');++ return hours > 0+ ? `${hours}:${String(minutes).padStart(2, '0')}:${seconds}`+ : `${minutes}:${seconds}`;+}++function printSection(title: string, lines: string[]) {+ if (lines.length === 0) return;++ console.log();+ console.log(pc.bold(title));+ for (const line of lines) console.log(line);+}++function printMinutes(minutes: any) {+ printSection('Summary', minutes.summary ? [minutes.summary] : []);+ printSection(+ 'Chapters',+ minutes.chapters.map(+ (chapter: any) => ` ${pc.dim(formatOffset(chapter.startMs))} ${chapter.title}`,+ ),+ );+ printSection(+ 'Decisions',+ minutes.decisions.map((decision: any) => ` - ${decision.text}`),+ );+ printSection(+ 'Action items',+ minutes.actionItems.map((item: any) => {+ const owner = item.assigneeHint ? ` ${pc.dim(`@${item.assigneeHint}`)}` : '';+ const due = item.dueDate ? ` ${pc.dim(`due ${item.dueDate}`)}` : '';+ return ` - [${item.status}] ${item.text}${owner}${due}`;+ }),+ );+ printSection('Keywords', minutes.keywords.length > 0 ? [` ${minutes.keywords.join(', ')}`] : []);+}++export function registerMeetingCommand(program: Command) {+ const meeting = program.command('meeting').description('Read recorded meetings');++ // ββ list ββββββββββββββββββββββββββββββββββββββββββββββ++ meeting+ .command('list')+ .description('List meetings, newest first')+ .option('-L, --limit <n>', 'Page size (1-100)', '20')+ .option('--offset <n>', 'Number of meetings to skip', '0')+ .addOption(new Option('--status <status>', 'Filter by status').choices(MEETING_STATUSES))+ .option('--json [fields]', 'Output JSON, optionally specify fields (comma-separated)')+ .action(+ async (options: {+ json?: string | boolean;+ limit: string;+ offset: string;+ status?: (typeof MEETING_STATUSES)[number];+ }) => {+ const limit = Number(options.limit);+ if (!Number.isInteger(limit) || limit < 1 || limit > 100) {+ log.error('--limit must be an integer between 1 and 100');+ process.exit(1);+ return;+ }++ const offset = Number(options.offset);+ if (!Number.isInteger(offset) || offset < 0) {+ log.error('--offset must be a non-negative integer');+ process.exit(1);+ return;+ }++ const client = await getTrpcClient();+ const { data: items } = (await client.meeting.list.query({+ limit,+ offset,+ status: options.status,+ })) as { data: any[] };++ if (options.json !== undefined) {+ outputJson(items, typeof options.json === 'string' ? options.json : undefined);+ return;+ }++ if (items.length === 0) {+ console.log('No meetings found.');+ return;+ }++ printTable(+ items.map((item) => [+ item.id,+ truncate(item.title, 40),+ item.status,+ item.durationMs === null ? '' : formatOffset(item.durationMs),+ timeAgo(item.startedAt),+ ]),+ ['ID', 'TITLE', 'STATUS', 'DURATION', 'STARTED'],+ );+ },+ );++ // ββ view ββββββββββββββββββββββββββββββββββββββββββββββ++ meeting+ .command('view <id>')+ .description('View a meeting with its speakers, transcript and minutes')+ .addOption(+ new Option(+ '--source <source>',+ 'Transcript to read (default: refined once available, else realtime)',+ ).choices(MEETING_SEGMENT_SOURCES),+ )+ .option('--json [fields]', 'Output JSON, optionally specify fields (comma-separated)')+ .action(+ async (+ id: string,+ options: {+ json?: string | boolean;+ source?: (typeof MEETING_SEGMENT_SOURCES)[number];+ },+ ) => {+ const client = await getTrpcClient();+ const { data } = (await client.meeting.detail.query({+ id,+ source: options.source,+ })) as { data: any };++ if (options.json !== undefined) {+ outputJson(data, typeof options.json === 'string' ? options.json : undefined);+ return;+ }++ console.log(pc.bold(data.title));+ console.log(+ pc.dim(+ [+ data.id,+ data.status,+ formatTimestamp(data.startedAt),+ data.durationMs === null ? undefined : formatOffset(data.durationMs),+ data.language,+ ]+ .filter(Boolean)+ .join(' Β· '),+ ),+ );+ if (data.audio) console.log(pc.dim(`Audio: ${data.audio.url}`));+ else if (data.localAudioPath) console.log(pc.dim(`Audio: ${data.localAudioPath}`));++ if (data.minutes) printMinutes(data.minutes);++ const speakers = new Map<string, string>(+ data.speakers.map((speaker: any) => [speaker.id, speaker.displayName || speaker.label]),+ );+ printSection(+ `Transcript (${data.segmentSource})`,+ data.segments.map((segment: any) => {+ const speaker = speakers.get(segment.speakerId);+ return `${pc.dim(formatOffset(segment.startMs))} ${speaker ? `${pc.cyan(speaker)}: ` : ''}${segment.text}`;+ }),+ );+ },+ );+}diff --git a/apps/cli/src/program.ts b/apps/cli/src/program.tsindex a2d9544c8e6..51131e81013 100644--- a/apps/cli/src/program.ts+++ b/apps/cli/src/program.ts@@ -25,6 +25,7 @@ import { registerKbCommand } from './commands/kb';import { registerLoginCommand } from './commands/login';import { registerLogoutCommand } from './commands/logout';import { registerManCommand } from './commands/man';+import { registerMeetingCommand } from './commands/meeting';import { registerMemoryCommand } from './commands/memory';import { registerMessageCommand } from './commands/message';import { registerMigrateCommand } from './commands/migrate';@@ -94,6 +95,7 @@ export function createProgram() {registerReadCommand(program);registerRecallCommand(program);registerKbCommand(program);+ registerMeetingCommand(program);registerMemoryCommand(program);registerAgentCommand(program);registerAgentGroupCommand(program);