@startsimpli/integrations 0.2.197 → 0.2.201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/src/__tests__/briefing-actions.test.ts +11 -0
- package/src/__tests__/briefing-edits.test.ts +98 -0
- package/src/__tests__/converse-brain.test.ts +64 -1
- package/src/__tests__/converse-handoff.test.ts +8 -0
- package/src/__tests__/converse-meeting-brief.test.ts +72 -8
- package/src/__tests__/converse-meeting-duplex.test.ts +132 -0
- package/src/__tests__/converse-meeting-keep-speech.test.ts +87 -0
- package/src/__tests__/converse-meeting-vad.test.ts +1 -1
- package/src/__tests__/converse-spoken-form.test.ts +10 -0
- package/src/__tests__/converse-spoken-summary.test.ts +27 -6
- package/src/__tests__/converse.test.ts +29 -2
- package/src/__tests__/corpus-ask-items.test.ts +14 -0
- package/src/__tests__/corpus-ask.test.ts +22 -0
- package/src/__tests__/corpus-tracker.test.tsx +12 -0
- package/src/__tests__/extract-classify.test.ts +17 -0
- package/src/__tests__/fleet-page.test.tsx +57 -0
- package/src/__tests__/fleet-view.test.ts +149 -0
- package/src/__tests__/project-basis-entity.test.ts +19 -0
- package/src/__tests__/project-basis.test.ts +21 -0
- package/src/__tests__/relay-cli.test.ts +10 -1
- package/src/__tests__/spoken-time.test.ts +4 -0
- package/src/__tests__/task-detail-project-guess.test.tsx +46 -0
- package/src/__tests__/voice-due-later-sentence.test.ts +26 -0
- package/src/components/index.ts +2 -0
- package/src/components/pages/FleetPage.tsx +115 -0
- package/src/components/pages/TaskDetailPage.tsx +27 -1
- package/src/components/pages/TrackerPage.tsx +1 -1
- package/src/components/pages/task-tracker/ProjectGuess.tsx +42 -0
- package/src/corpus/ask-items-intent.ts +24 -0
- package/src/corpus/ask-items.ts +7 -4
- package/src/corpus/ask.ts +1 -1
- package/src/corpus/briefing/actions/confirm.ts +9 -1
- package/src/corpus/briefing/actions/execute.ts +71 -11
- package/src/corpus/briefing/actions/log.ts +1 -1
- package/src/corpus/briefing/actions/seam.ts +18 -2
- package/src/corpus/briefing/actions/types.ts +14 -0
- package/src/corpus/briefing/intent/describe.ts +5 -1
- package/src/corpus/briefing/intent/edits.ts +92 -0
- package/src/corpus/briefing/intent/grammar.ts +3 -0
- package/src/corpus/briefing/intent/ground.ts +5 -1
- package/src/corpus/briefing/intent/match.ts +3 -1
- package/src/corpus/briefing/intent/model.ts +36 -3
- package/src/corpus/briefing/intent/resolve.ts +12 -1
- package/src/corpus/briefing/intent/types.ts +8 -0
- package/src/corpus/briefing/speak.ts +13 -0
- package/src/corpus/client.ts +2 -0
- package/src/corpus/converse/brain.ts +41 -13
- package/src/corpus/converse/briefing-queue.ts +105 -27
- package/src/corpus/converse/client.ts +6 -0
- package/src/corpus/converse/fleet-view.ts +126 -0
- package/src/corpus/converse/fleet.ts +18 -5
- package/src/corpus/converse/followups.ts +12 -2
- package/src/corpus/converse/handle.ts +21 -12
- package/src/corpus/converse/handoff.ts +7 -2
- package/src/corpus/converse/index.ts +5 -3
- package/src/corpus/converse/meeting-config.ts +8 -4
- package/src/corpus/converse/meeting.ts +66 -11
- package/src/corpus/converse/respond.ts +14 -2
- package/src/corpus/converse/spoken-form.ts +9 -2
- package/src/corpus/converse/spoken-summary.ts +30 -8
- package/src/corpus/converse/store.ts +2 -0
- package/src/corpus/converse/types.ts +14 -1
- package/src/corpus/entities.ts +2 -0
- package/src/corpus/extract.ts +9 -4
- package/src/corpus/project-basis.ts +23 -0
- package/src/corpus/spoken-time.ts +18 -2
- package/src/corpus/types.ts +6 -0
- package/src/corpus/voice-due.ts +24 -0
- package/src/native/app/converseServices.ts +5 -3
- package/src/native/app/device.ts +2 -0
- package/src/native/converse/ConverseScreen.tsx +28 -0
- package/src/native/converse/__tests__/liveScreen.test.tsx +35 -2
- package/src/native/converse/__tests__/meetingIO.test.ts +55 -1
- package/src/native/converse/format.ts +2 -2
- package/src/native/converse/io.ts +15 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/integrations",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.201",
|
|
4
4
|
"description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://startsimpli.com",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"react-native": ">=0.74.0",
|
|
51
51
|
"@startsimpli/ui-native": ">=0.1.12",
|
|
52
52
|
"react-native-safe-area-context": ">=4.0.0",
|
|
53
|
-
"@startsimpli/utils": "^0.4.
|
|
54
|
-
"@startsimpli/ui": "^0.4.
|
|
55
|
-
"@startsimpli/auth": "^0.4.
|
|
53
|
+
"@startsimpli/utils": "^0.4.21",
|
|
54
|
+
"@startsimpli/ui": "^0.4.192",
|
|
55
|
+
"@startsimpli/auth": "^0.4.54"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"react": {
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
"react-native": "0.85.3",
|
|
100
100
|
"react-native-safe-area-context": "~5.7.0",
|
|
101
101
|
"@startsimpli/llm": "0.4.31",
|
|
102
|
-
"@startsimpli/ui": "0.4.
|
|
102
|
+
"@startsimpli/ui": "0.4.192",
|
|
103
103
|
"@startsimpli/ui-native": "0.1.15",
|
|
104
|
-
"@startsimpli/auth": "0.4.
|
|
105
|
-
"@startsimpli/utils": "0.4.
|
|
104
|
+
"@startsimpli/auth": "0.4.54",
|
|
105
|
+
"@startsimpli/utils": "0.4.21"
|
|
106
106
|
},
|
|
107
107
|
"scripts": {
|
|
108
108
|
"type-check": "tsc --noEmit && tsc --noEmit -p tsconfig.native.json",
|
|
@@ -154,6 +154,17 @@ describe('idempotency', () => {
|
|
|
154
154
|
expect(again.replayed).toBe(true);
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
+
it('skips survive a save and load through the tenant row', async () => {
|
|
158
|
+
const rows = new Map<string, any>();
|
|
159
|
+
const http = {
|
|
160
|
+
get: async (_p: string, o?: { params?: Record<string, unknown> }) => ({ results: [...rows.values()].filter((r) => r.external_id === o?.params?.external_id__in) }),
|
|
161
|
+
post: async (_p: string, body: any) => { const row = { id: '1', owner_sub: ME, ...body }; rows.set(body.external_id, row); return row; },
|
|
162
|
+
};
|
|
163
|
+
const log = createEntityActionLog(http as never, ME);
|
|
164
|
+
await log.save({ applied: {}, order: [], stack: [], skips: { date: '2026-11-16', keys: ['bench'] } });
|
|
165
|
+
expect((await createEntityActionLog(http as never, ME).load()).skips).toEqual({ date: '2026-11-16', keys: ['bench'] });
|
|
166
|
+
});
|
|
167
|
+
|
|
157
168
|
it('the action log is a source_document with no body, so the extractor ignores it, and another owner\'s row is not read', async () => {
|
|
158
169
|
const rows = new Map<string, any>();
|
|
159
170
|
const http = {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
/** More voice edits through the item seam: rename, add a note, estimate, project; one undo reverts a whole reply. */
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { createMemoryActionLog, executeVoiceActions, type EditableItem, type ItemEditSeam, type ItemPatch, type VoiceAction } from '../corpus/briefing';
|
|
5
|
+
|
|
6
|
+
const NOW = Date.parse('2026-11-16T17:00:00Z');
|
|
7
|
+
const TZ = 'America/Denver';
|
|
8
|
+
const FOCUSES = [{ id: 'f-croc', title: 'Crochets' }, { id: 'f-tandem', title: 'Tandem' }];
|
|
9
|
+
|
|
10
|
+
function memory(rows: EditableItem[], opts: { focuses?: boolean } = { focuses: true }) {
|
|
11
|
+
const items = new Map(rows.map((r) => [r.id, { ...r }]));
|
|
12
|
+
const seam: ItemEditSeam = {
|
|
13
|
+
async load(id) { return items.get(id) ? { ...items.get(id)! } : null; },
|
|
14
|
+
async update(item, patch: ItemPatch) {
|
|
15
|
+
const next = { ...items.get(item.id)!, ...patch } as EditableItem;
|
|
16
|
+
if (patch.estimateMinutes === null) delete next.estimateMinutes;
|
|
17
|
+
items.set(item.id, next);
|
|
18
|
+
return { ...next };
|
|
19
|
+
},
|
|
20
|
+
async create() { throw new Error('no'); },
|
|
21
|
+
...(opts.focuses ? { listFocuses: async () => FOCUSES } : {}),
|
|
22
|
+
};
|
|
23
|
+
return { items, seam };
|
|
24
|
+
}
|
|
25
|
+
const run = (seam: ItemEditSeam, actions: VoiceAction[], log = createMemoryActionLog(), id = 'k1') =>
|
|
26
|
+
executeVoiceActions({ actions, clientActionId: id, seam, log, ownerSub: 'me', now: () => NOW, timeZone: TZ }).then((out) => ({ out, log }));
|
|
27
|
+
const BENCH: EditableItem = { id: 'bench', title: "Order dad's bench", status: 'open', detail: 'Walnut if possible.' };
|
|
28
|
+
|
|
29
|
+
describe('rename, note, estimate, project', () => {
|
|
30
|
+
it('renames, says so, and undo puts the old title back', async () => {
|
|
31
|
+
const m = memory([BENCH]);
|
|
32
|
+
const { out, log } = await run(m.seam, [{ type: 'rename', itemId: 'bench', title: 'Order the walnut bench' }]);
|
|
33
|
+
expect(m.items.get('bench')!.title).toBe('Order the walnut bench');
|
|
34
|
+
expect(out.text).toBe('Renamed it to Order the walnut bench.');
|
|
35
|
+
const undone = await run(m.seam, [{ type: 'undo' }], log, 'k2');
|
|
36
|
+
expect(m.items.get('bench')!.title).toBe("Order dad's bench");
|
|
37
|
+
expect(undone.out.results[0].status).toBe('applied');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('adds a note after what is there; undo restores the old detail', async () => {
|
|
41
|
+
const m = memory([BENCH]);
|
|
42
|
+
const { out, log } = await run(m.seam, [{ type: 'add_detail', itemId: 'bench', detail: 'Call Pete first.' }]);
|
|
43
|
+
expect(m.items.get('bench')!.detail).toBe('Walnut if possible.\n\nCall Pete first.');
|
|
44
|
+
expect(out.text).toBe("Added a note to Order dad's bench.");
|
|
45
|
+
await run(m.seam, [{ type: 'undo' }], log, 'k2');
|
|
46
|
+
expect(m.items.get('bench')!.detail).toBe('Walnut if possible.');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('sets an estimate in words a person says, and undo clears it', async () => {
|
|
50
|
+
const m = memory([BENCH]);
|
|
51
|
+
const { out, log } = await run(m.seam, [{ type: 'set_estimate', itemId: 'bench', minutes: 90 }]);
|
|
52
|
+
expect(m.items.get('bench')!.estimateMinutes).toBe(90);
|
|
53
|
+
expect(out.text).toBe("Set Order dad's bench to an hour and a half.");
|
|
54
|
+
await run(m.seam, [{ type: 'undo' }], log, 'k2');
|
|
55
|
+
expect(m.items.get('bench')!.estimateMinutes).toBeUndefined();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('files under a project found by name (case and "project" ignored); undo files it back', async () => {
|
|
59
|
+
const m = memory([{ ...BENCH, focusId: 'f-tandem' }]);
|
|
60
|
+
const { out, log } = await run(m.seam, [{ type: 'set_project', itemId: 'bench', project: 'the crochets project' }]);
|
|
61
|
+
expect(m.items.get('bench')!.focusId).toBe('f-croc');
|
|
62
|
+
expect(out.text).toBe("Moved Order dad's bench to Crochets.");
|
|
63
|
+
await run(m.seam, [{ type: 'undo' }], log, 'k2');
|
|
64
|
+
expect(m.items.get('bench')!.focusId).toBe('f-tandem');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('a project that does not exist, or a seam that cannot file, says so and changes nothing', async () => {
|
|
68
|
+
const m = memory([BENCH]);
|
|
69
|
+
const none = await run(m.seam, [{ type: 'set_project', itemId: 'bench', project: 'Gardening' }]);
|
|
70
|
+
expect(none.out.results[0]).toMatchObject({ status: 'asked' });
|
|
71
|
+
expect(none.out.text).toMatch(/Gardening/);
|
|
72
|
+
expect(m.items.get('bench')!.focusId).toBeUndefined();
|
|
73
|
+
const blind = memory([BENCH], { focuses: false });
|
|
74
|
+
const cannot = await run(blind.seam, [{ type: 'set_project', itemId: 'bench', project: 'Crochets' }]);
|
|
75
|
+
expect(cannot.out.results[0].status).toBe('failed');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('one undo reverts a whole reply', () => {
|
|
80
|
+
it('"mark all of those done" is undone in one go', async () => {
|
|
81
|
+
const rows = ['a', 'b', 'c'].map((id): EditableItem => ({ id, title: `Item ${id}`, status: 'open' }));
|
|
82
|
+
const m = memory(rows);
|
|
83
|
+
const { log } = await run(m.seam, rows.map((r): VoiceAction => ({ type: 'done', itemId: r.id })), createMemoryActionLog(), 'bulk');
|
|
84
|
+
expect([...m.items.values()].every((i) => i.status === 'done')).toBe(true);
|
|
85
|
+
const undone = await run(m.seam, [{ type: 'undo' }], log, 'u1');
|
|
86
|
+
expect([...m.items.values()].every((i) => i.status === 'open')).toBe(true);
|
|
87
|
+
expect(undone.out.text).toBe('Undid all three changes.');
|
|
88
|
+
});
|
|
89
|
+
it('a reply with one change still undoes just that one', async () => {
|
|
90
|
+
const rows = ['a', 'b'].map((id): EditableItem => ({ id, title: `Item ${id}`, status: 'open' }));
|
|
91
|
+
const m = memory(rows);
|
|
92
|
+
const { log } = await run(m.seam, [{ type: 'done', itemId: 'a' }], createMemoryActionLog(), 'one');
|
|
93
|
+
await run(m.seam, [{ type: 'done', itemId: 'b' }], log, 'two');
|
|
94
|
+
await run(m.seam, [{ type: 'undo' }], log, 'u1');
|
|
95
|
+
expect(m.items.get('a')!.status).toBe('done');
|
|
96
|
+
expect(m.items.get('b')!.status).toBe('open');
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -109,7 +109,18 @@ describe('long answers: whole on the screen, short aloud; Ask starts beside rout
|
|
|
109
109
|
const brain = createConverseBrain({ ...s.deps, ask: async () => ({ answer: LIST }) });
|
|
110
110
|
const out = await brain(input('what are my commitments this week'));
|
|
111
111
|
expect(out.text).toContain('5. Call the bank');
|
|
112
|
-
expect(out.spoken).toBe('This week, the following tasks are due. Plan the week. Build lead QC. Launch lead. And 2 more.');
|
|
112
|
+
expect(out.spoken).toBe('This week, the following tasks are due. Plan the week. Build lead QC. Launch lead. And 2 more. Want the rest?');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('"yes" after a shortened answer reads the rest; "yes" after a short one is not special', async () => {
|
|
116
|
+
const s = setup();
|
|
117
|
+
const brain = createConverseBrain({ ...s.deps, ask: async () => ({ answer: 'unused' }) });
|
|
118
|
+
const out = await brain({ ...input('yes'), history: [{ role: 'user', text: 'what is due' }, { role: 'assistant', text: LIST }] });
|
|
119
|
+
expect(out.text).toBe('Order the bench. Call the bank.');
|
|
120
|
+
expect(out.spoken).toBeUndefined();
|
|
121
|
+
const ask = vi.fn(async () => ({ answer: 'Sure.' }));
|
|
122
|
+
await createConverseBrain({ ...s.deps, ask })({ ...input('yes'), history: [{ role: 'assistant', text: 'The bench is due today.' }] });
|
|
123
|
+
expect(ask).toHaveBeenCalled();
|
|
113
124
|
});
|
|
114
125
|
|
|
115
126
|
it('a short answer has no separate spoken version', async () => {
|
|
@@ -328,6 +339,23 @@ describe('briefing one item at a time', () => {
|
|
|
328
339
|
expect(s.rows.get('item:bench')?.data.status).not.toBe('open');
|
|
329
340
|
});
|
|
330
341
|
|
|
342
|
+
it('a skipped item stays out of the next briefing the same day, and comes back the next day', async () => {
|
|
343
|
+
const s = setup();
|
|
344
|
+
const rows = [
|
|
345
|
+
{ id: 'bench', title: "Order dad's bench", status: 'open', dueAt: '2026-11-04', ownerSub: ME, focusName: 'Home' },
|
|
346
|
+
{ id: 'lease', title: 'Call the lease office', status: 'open', dueAt: '2026-11-04', ownerSub: ME, focusName: 'Home' },
|
|
347
|
+
] as never;
|
|
348
|
+
const brain = createConverseBrain({ ...s.deps, loadItems: async () => rows });
|
|
349
|
+
const started = await brain(say('brief me'));
|
|
350
|
+
expect(started.text).toMatch(/Order dad's bench|Call the lease office/);
|
|
351
|
+
const first = started.briefing!.queue[0].itemId;
|
|
352
|
+
await brain(say('skip', started.briefing));
|
|
353
|
+
const again = await brain(say('brief me'));
|
|
354
|
+
expect(again.briefing?.queue.map((q: any) => q.itemId)).not.toContain(first);
|
|
355
|
+
const tomorrow = await brain({ ...say('brief me'), now: NOW + 86_400_000 });
|
|
356
|
+
expect(tomorrow.briefing?.queue.map((q: any) => q.itemId)).toContain(first);
|
|
357
|
+
});
|
|
358
|
+
|
|
331
359
|
it('an answer about something the relay waits on goes to the relay with the item named', async () => {
|
|
332
360
|
const s = setup();
|
|
333
361
|
const brain = createConverseBrain({ ...s.deps, loadItems: async () => [] as never, loadFleetStatus: async () => ({ text: '## Waiting on Quinn\n- Crochets: flip the 8 category pages Tuesday morning?', updatedAt: new Date(NOW).toISOString() }) });
|
|
@@ -506,3 +534,38 @@ describe('routing: work for the relay, fleet status, no filler', () => {
|
|
|
506
534
|
expect(llm.write).not.toHaveBeenCalled();
|
|
507
535
|
});
|
|
508
536
|
});
|
|
537
|
+
|
|
538
|
+
describe('which-one clarification carries to the next turn (startsim-ym54h.31)', () => {
|
|
539
|
+
function twoBenches() {
|
|
540
|
+
const s = setup();
|
|
541
|
+
s.rows.set('item:bench2', { id: 'bench2', entity_type: 'commitment', external_id: 'item:bench2', name: 'Sand the garden bench', data: { title: 'Sand the garden bench', status: 'open', owner_sub: ME, subtype: 'action', due_at: '2026-11-04' } });
|
|
542
|
+
return s;
|
|
543
|
+
}
|
|
544
|
+
it('an ambiguous instruction asks which and keeps the question pending, not sent to Ask', async () => {
|
|
545
|
+
const s = twoBenches();
|
|
546
|
+
const out = await s.brain({ utterance: 'move the bench one to friday', history: [], timeZone: TZ, now: NOW });
|
|
547
|
+
expect(s.ask).not.toHaveBeenCalled();
|
|
548
|
+
expect(out.text).toMatch(/which/i);
|
|
549
|
+
expect(out.pending?.utterance).toBe('move the bench one to friday');
|
|
550
|
+
expect(out.pending?.question).toBe(out.text);
|
|
551
|
+
});
|
|
552
|
+
it('the next turn answers it: "the dad one" resolves with the earlier words', async () => {
|
|
553
|
+
const s = twoBenches();
|
|
554
|
+
const first = await s.brain({ utterance: 'move the bench one to friday', history: [], timeZone: TZ, now: NOW });
|
|
555
|
+
const out = await s.brain({ utterance: "the dad one", history: [], timeZone: TZ, now: NOW, pending: first.pending });
|
|
556
|
+
expect(out.text).toBe("Moved Order dad's bench to Friday.");
|
|
557
|
+
expect(out.pending).toBeNull();
|
|
558
|
+
expect(s.ask).not.toHaveBeenCalled();
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
describe('an Ask answer keeps its sources and the items it listed (startsim-ym54h.24, .35)', () => {
|
|
563
|
+
it('citations from Ask become the thread sources and the items for "the second one"', async () => {
|
|
564
|
+
const s = setup();
|
|
565
|
+
const doc = (id: string, title: string, extra = {}) => ({ id, title, ...extra });
|
|
566
|
+
const brain = createConverseBrain({ ...(s.deps as any), ask: async () => ({ answer: 'Two things on the website.', status: 'answered', citations: [{ document: doc('item:a', 'Fix header') }, { document: doc('item:b', 'Ship footer') }, { document: doc('doc1', 'Kickoff notes', { source: 'granola' }) }] }) });
|
|
567
|
+
const out = await brain({ utterance: 'what is open on the website', history: [], timeZone: TZ, now: NOW });
|
|
568
|
+
expect(out.sources?.map((x) => x.title)).toEqual(['Fix header', 'Ship footer', 'Kickoff notes']);
|
|
569
|
+
expect(out.context?.items).toEqual([{ id: 'a', title: 'Fix header' }, { id: 'b', title: 'Ship footer' }]);
|
|
570
|
+
});
|
|
571
|
+
});
|
|
@@ -58,6 +58,14 @@ describe('End hands the conversation on', () => {
|
|
|
58
58
|
expect(extractTodos).toHaveBeenCalledWith('900');
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
+
it('reports the project it filed under, by name', async () => {
|
|
62
|
+
const { deps } = setup();
|
|
63
|
+
const a = await handleConverseTurn(deps, { text: 'plan the hours import' });
|
|
64
|
+
const end = await handleConverseEnd(deps, { conversationId: a.conversation_id });
|
|
65
|
+
expect(end.project).toBe('Hours');
|
|
66
|
+
expect(end.filed).toEqual(['Email Michelle about the Hours import', 'Fix it']);
|
|
67
|
+
});
|
|
68
|
+
|
|
61
69
|
it('a project the model invented files nothing; no asks means no extraction', async () => {
|
|
62
70
|
const t1 = setup({ analyzer: { analyze: async () => ({ title: 't', summary: 's', focusId: 'nope' }) } });
|
|
63
71
|
const a = await handleConverseTurn(t1.deps, { text: 'hi there' });
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { describe, expect, it } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import { buildQueue, firstPrompt, relayItemsFrom, stepBriefing, BRIEF_ME, NEEDS_ME } from '../corpus/converse/briefing-queue';
|
|
8
|
+
import { buildQueue, firstPrompt, rankQueue, relayItemsFrom, startBriefing, stepBriefing, BRIEF_ME, NEEDS_ME, type BriefingState } from '../corpus/converse/briefing-queue';
|
|
9
9
|
import type { BriefingItem } from '../corpus/briefing/types';
|
|
10
10
|
|
|
11
11
|
const NOW = Date.parse('2026-11-16T17:00:00Z');
|
|
@@ -32,7 +32,7 @@ describe('the trigger', () => {
|
|
|
32
32
|
describe('the queue', () => {
|
|
33
33
|
it('is ordered by project, overdue and due-today items only, done items left out', () => {
|
|
34
34
|
const q = buildQueue({ items: ITEMS, relayItems: [], now: NOW, timeZone: TZ });
|
|
35
|
-
expect(q.map((i) => `${i.project}:${i.itemId}`)).toEqual(['Crochets:
|
|
35
|
+
expect(q.map((i) => `${i.project}:${i.itemId}`)).toEqual(['Crochets:a', 'Crochets:b', 'Tandem:c']);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it('puts what the relay waits on Quinn for after his own items, under its project', () => {
|
|
@@ -63,19 +63,19 @@ describe('one item at a time', () => {
|
|
|
63
63
|
it('says one sentence and one question, nothing else', () => {
|
|
64
64
|
const s = start();
|
|
65
65
|
const said = firstPrompt(s);
|
|
66
|
-
expect(said).toBe('Crochets, item 1:
|
|
66
|
+
expect(said).toBe('Crochets, item 1: Flip the 8 category pages on Tuesday morning, due today. Do it today?');
|
|
67
67
|
expect(said.split(/[.?]\s/).length).toBeLessThanOrEqual(3);
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
it('after an answer says Noted., then the next item; on a new project says that is the project first', () => {
|
|
71
71
|
let s = start();
|
|
72
72
|
let r = stepBriefing(s, 'yes');
|
|
73
|
-
expect(r.reply).toBe('Noted. Crochets, item 2:
|
|
74
|
-
expect(r.effect).toEqual({ kind: 'todo', action: { type: 'pull_today', itemId: '
|
|
73
|
+
expect(r.reply).toBe('Noted. Crochets, item 2: Review the checkout copy, overdue. Do it today?');
|
|
74
|
+
expect(r.effect).toEqual({ kind: 'todo', action: { type: 'pull_today', itemId: 'a' } });
|
|
75
75
|
s = r.state!;
|
|
76
76
|
r = stepBriefing(s, 'later');
|
|
77
77
|
expect(r.reply).toBe('Noted. That is Crochets. Now Tandem, item 1: Ship the combined roll, due today. Do it today?');
|
|
78
|
-
expect(r.effect).toEqual({ kind: 'todo', action: { type: 'defer', itemId: '
|
|
78
|
+
expect(r.effect).toEqual({ kind: 'todo', action: { type: 'defer', itemId: 'b', to: 'later' } });
|
|
79
79
|
s = r.state!;
|
|
80
80
|
r = stepBriefing(s, 'done');
|
|
81
81
|
expect(r.reply).toBe('Noted. That is everything.');
|
|
@@ -86,7 +86,7 @@ describe('one item at a time', () => {
|
|
|
86
86
|
it('holds the rest until answered: "tell me more" gives the detail and asks the same question again', () => {
|
|
87
87
|
const s = start();
|
|
88
88
|
const r = stepBriefing(s, 'tell me more');
|
|
89
|
-
expect(r.reply).toMatch(/^
|
|
89
|
+
expect(r.reply).toMatch(/^Flip the 8 category pages/);
|
|
90
90
|
expect(r.reply).toMatch(/Do it today\?$/);
|
|
91
91
|
expect(r.state?.index).toBe(0);
|
|
92
92
|
expect(r.effect).toBeUndefined();
|
|
@@ -95,7 +95,7 @@ describe('one item at a time', () => {
|
|
|
95
95
|
it('skip moves on without a change; stop ends the briefing; repeat says the item again', () => {
|
|
96
96
|
const s = start();
|
|
97
97
|
expect(stepBriefing(s, 'skip').reply).toMatch(/^Noted\. Crochets, item 2:/);
|
|
98
|
-
expect(stepBriefing(s, 'skip').effect).
|
|
98
|
+
expect(stepBriefing(s, 'skip').effect).toEqual({ kind: 'skip', key: 'a' });
|
|
99
99
|
const stop = stepBriefing(s, "that's all");
|
|
100
100
|
expect(stop.reply).toBe('Okay, stopping.');
|
|
101
101
|
expect(stop.state).toBeNull();
|
|
@@ -120,3 +120,67 @@ describe('one item at a time', () => {
|
|
|
120
120
|
expect(r.state?.index).toBe(0);
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
|
+
|
|
124
|
+
describe('briefing quality: importance, unfiled, snoozes, skips', () => {
|
|
125
|
+
const day = (n: number) => new Date(Date.parse('2026-11-16T12:00:00Z') - n * 86_400_000).toISOString().slice(0, 10);
|
|
126
|
+
const many = [
|
|
127
|
+
...Array.from({ length: 10 }, (_, n) => item(`old${n}`, `Old chore ${n}`, 'Tandem', day(30 + n))),
|
|
128
|
+
item('recent', 'Recent overdue chore', 'Tandem', day(2)),
|
|
129
|
+
item('today1', 'Due today chore', 'Tandem', day(0)),
|
|
130
|
+
item('urgent', 'Urgent but ancient', 'Tandem', day(90), { priority: 1 }),
|
|
131
|
+
item('loose', 'No project item', '', day(0)),
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
it('does not open with a flood of old overdue items: urgent and today first, a handful of the rest, newest overdue first', () => {
|
|
135
|
+
const { queue, older } = rankQueue({ items: many, relayItems: [], now: NOW, timeZone: TZ });
|
|
136
|
+
const ids = queue.map((q) => q.itemId);
|
|
137
|
+
expect(ids.slice(0, 2)).toEqual(['urgent', 'today1']);
|
|
138
|
+
expect(ids).toContain('recent');
|
|
139
|
+
expect(ids.filter((id) => id?.startsWith('old')).length).toBeLessThanOrEqual(2);
|
|
140
|
+
expect(older).toBe(many.length - queue.length);
|
|
141
|
+
expect(ids.indexOf('recent')).toBeLessThan(ids.indexOf('old0') === -1 ? 99 : ids.indexOf('old0'));
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('names an item with no project "Unfiled", not Personal', () => {
|
|
145
|
+
const q = buildQueue({ items: many, relayItems: [], now: NOW, timeZone: TZ });
|
|
146
|
+
expect(q.find((i) => i.itemId === 'loose')?.project).toBe('Unfiled');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('says how many older overdue items are still open, once, at the end', () => {
|
|
150
|
+
const state = startBriefing({ items: many, relayItems: [], now: NOW, timeZone: TZ })!;
|
|
151
|
+
expect(state.older).toBeGreaterThan(0);
|
|
152
|
+
let s: typeof state | null = state;
|
|
153
|
+
let last = '';
|
|
154
|
+
for (let n = 0; s && n < 20; n += 1) { const r = stepBriefing(s, 'skip', { now: NOW, timeZone: TZ }); last = r.reply; s = r.state; }
|
|
155
|
+
expect(last).toMatch(/older overdue items? (?:is|are) still open/);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('"tomorrow" and "next week" move the item to that date; they do not clear the due date', () => {
|
|
159
|
+
const s = { queue: buildQueue({ items: ITEMS, relayItems: [], now: NOW, timeZone: TZ }), index: 0 };
|
|
160
|
+
const tomorrow = stepBriefing(s, 'tomorrow', { now: NOW, timeZone: TZ });
|
|
161
|
+
expect(tomorrow.effect).toEqual({ kind: 'todo', action: { type: 'defer', itemId: 'a', to: '2026-11-17', label: 'tomorrow' } });
|
|
162
|
+
const week = stepBriefing(s, 'next week', { now: NOW, timeZone: TZ });
|
|
163
|
+
expect(week.effect).toMatchObject({ kind: 'todo', action: { type: 'defer', itemId: 'a', to: '2026-11-23' } });
|
|
164
|
+
const friday = stepBriefing(s, 'push it to Friday', { now: NOW, timeZone: TZ });
|
|
165
|
+
expect(friday.effect).toMatchObject({ action: { type: 'defer', to: '2026-11-20' } });
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('"later today" changes nothing and asks again at the end of the walk', () => {
|
|
169
|
+
let s: BriefingState | null = { queue: buildQueue({ items: ITEMS, relayItems: [], now: NOW, timeZone: TZ }), index: 0 };
|
|
170
|
+
const r = stepBriefing(s, 'later today', { now: NOW, timeZone: TZ });
|
|
171
|
+
expect(r.effect).toBeUndefined();
|
|
172
|
+
expect(r.reply).toMatch(/^Noted, I will ask again at the end\./);
|
|
173
|
+
s = r.state;
|
|
174
|
+
s = stepBriefing(s!, 'done', { now: NOW, timeZone: TZ }).state;
|
|
175
|
+
s = stepBriefing(s!, 'done', { now: NOW, timeZone: TZ }).state;
|
|
176
|
+
const again = firstPrompt(s!);
|
|
177
|
+
expect(again).toMatch(/Flip the 8 category pages/);
|
|
178
|
+
const end = stepBriefing(s!, 'later today', { now: NOW, timeZone: TZ });
|
|
179
|
+
expect(end.state).toBeNull(); // asked only once more
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('a skipped item is left out of the next briefing today', () => {
|
|
183
|
+
const s = startBriefing({ items: ITEMS, relayItems: [], now: NOW, timeZone: TZ, skipped: ['a'] })!;
|
|
184
|
+
expect(s.queue.map((q) => q.itemId)).toEqual(['c', 'b']);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { createMeetingController, type MeetingApi, type MeetingIO, type MeetingState } from '../corpus/converse';
|
|
4
|
+
|
|
5
|
+
const blob = () => new Blob([new Uint8Array([1])], { type: 'audio/mp4' });
|
|
6
|
+
const turnResult = (n: number) => ({
|
|
7
|
+
conversation_id: 'c1', turn_id: `t${n}`, turn: n, transcript: `said ${n}`, reply_text: `reply ${n}`, audio_url: `/a/${n}`, audio_reason: null,
|
|
8
|
+
});
|
|
9
|
+
const settle = async (check: () => boolean) => { for (let i = 0; i < 300 && !check(); i += 1) await new Promise((r) => setTimeout(r, 5)); };
|
|
10
|
+
|
|
11
|
+
/** A duplex io: listen runs all the time and can be handed an utterance or told "speech started" by the test. */
|
|
12
|
+
function rig(opts: { speak?: MeetingIO['speak']; turn?: MeetingApi<Blob>['turn'] } = {}) {
|
|
13
|
+
let n = 0;
|
|
14
|
+
const client: MeetingApi<Blob> = { turn: opts.turn ?? vi.fn(async () => turnResult(++n)), end: vi.fn(async () => ({ saved: true as const, conversation_id: 'c1', record_id: '1', turns: n, asks: [], decisions: [] })) as never };
|
|
15
|
+
const heard: Array<{ signal: AbortSignal; hooks?: { onSpeechStart?: () => void }; deliver: (a: Blob | null) => void }> = [];
|
|
16
|
+
const io: MeetingIO<Blob> = {
|
|
17
|
+
duplex: true,
|
|
18
|
+
listen: vi.fn((signal: AbortSignal, _c: unknown, hooks?: { onSpeechStart?: () => void }) => new Promise((resolve) => {
|
|
19
|
+
heard.push({ signal, hooks, deliver: (a) => resolve(a ? { audio: a } : { audio: null }) });
|
|
20
|
+
signal.addEventListener('abort', () => resolve({ audio: null, cancelled: true }));
|
|
21
|
+
})),
|
|
22
|
+
speak: opts.speak ?? vi.fn(async () => undefined),
|
|
23
|
+
};
|
|
24
|
+
const states: MeetingState[] = [];
|
|
25
|
+
const c = createMeetingController({ client, io, onChange: (s) => states.push(s) });
|
|
26
|
+
return { c, client, io, heard, states };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('the mic never switches off while a meeting runs (duplex io)', () => {
|
|
30
|
+
it('keeps listening while the reply is thinking and while it is spoken', async () => {
|
|
31
|
+
let finishSpeak: () => void = () => undefined;
|
|
32
|
+
const speak = vi.fn((_r: unknown, signal: AbortSignal) => new Promise<void>((resolve) => { finishSpeak = resolve; signal.addEventListener('abort', () => resolve()); }));
|
|
33
|
+
const { c, heard, io } = rig({ speak });
|
|
34
|
+
c.start();
|
|
35
|
+
await settle(() => heard.length >= 1);
|
|
36
|
+
heard[0].deliver(blob());
|
|
37
|
+
await settle(() => c.state().phase === 'speaking');
|
|
38
|
+
// A pause sent the data; the mic is already listening again, even though the reply is being spoken.
|
|
39
|
+
await settle(() => heard.length >= 2);
|
|
40
|
+
expect(heard.length).toBe(2);
|
|
41
|
+
expect(heard[1].signal.aborted).toBe(false);
|
|
42
|
+
expect(c.state().micLive).toBe(true);
|
|
43
|
+
finishSpeak();
|
|
44
|
+
await settle(() => c.state().phase === 'listening');
|
|
45
|
+
expect(heard[1].signal.aborted).toBe(false);
|
|
46
|
+
expect((io.listen as any).mock.calls.length).toBe(2);
|
|
47
|
+
await c.end();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('speech while the reply is spoken cuts the reply off and that utterance is the next turn', async () => {
|
|
51
|
+
const speak = vi.fn((_r: unknown, signal: AbortSignal) => new Promise<void>((resolve) => signal.addEventListener('abort', () => resolve())));
|
|
52
|
+
const { c, heard, client } = rig({ speak });
|
|
53
|
+
c.start();
|
|
54
|
+
await settle(() => heard.length >= 1);
|
|
55
|
+
heard[0].deliver(blob());
|
|
56
|
+
await settle(() => c.state().phase === 'speaking');
|
|
57
|
+
await settle(() => heard.length >= 2);
|
|
58
|
+
heard[1].hooks?.onSpeechStart?.();
|
|
59
|
+
await settle(() => c.state().phase !== 'speaking');
|
|
60
|
+
expect(c.state().phase).toBe('listening');
|
|
61
|
+
heard[1].deliver(blob());
|
|
62
|
+
await settle(() => (client.turn as any).mock.calls.length >= 2);
|
|
63
|
+
expect((client.turn as any).mock.calls.length).toBe(2);
|
|
64
|
+
await c.end();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('speech while it is only thinking does not cut anything; the reply waits until he has finished, then is spoken', async () => {
|
|
68
|
+
const speak = vi.fn(async () => undefined);
|
|
69
|
+
let release: () => void = () => undefined;
|
|
70
|
+
const turn = vi.fn(() => new Promise<any>((resolve) => { release = () => resolve(turnResult(1)); }));
|
|
71
|
+
const { c, heard } = rig({ speak, turn: turn as never });
|
|
72
|
+
c.start();
|
|
73
|
+
await settle(() => heard.length >= 1);
|
|
74
|
+
heard[0].deliver(blob());
|
|
75
|
+
await settle(() => c.state().phase === 'thinking');
|
|
76
|
+
await settle(() => heard.length >= 2);
|
|
77
|
+
heard[1].hooks?.onSpeechStart?.();
|
|
78
|
+
release();
|
|
79
|
+
await new Promise((r) => setTimeout(r, 120));
|
|
80
|
+
expect(speak).not.toHaveBeenCalled();
|
|
81
|
+
heard[1].deliver(null);
|
|
82
|
+
await settle(() => speak.mock.calls.length >= 1);
|
|
83
|
+
expect(speak).toHaveBeenCalledTimes(1);
|
|
84
|
+
await c.end();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('stop()', () => {
|
|
89
|
+
it('stops the readout at once and listens', async () => {
|
|
90
|
+
const speak = vi.fn((_r: unknown, signal: AbortSignal) => new Promise<void>((resolve) => signal.addEventListener('abort', () => resolve())));
|
|
91
|
+
const { c, heard } = rig({ speak });
|
|
92
|
+
c.start();
|
|
93
|
+
await settle(() => heard.length >= 1);
|
|
94
|
+
heard[0].deliver(blob());
|
|
95
|
+
await settle(() => c.state().phase === 'speaking');
|
|
96
|
+
c.stop();
|
|
97
|
+
await settle(() => c.state().phase === 'listening');
|
|
98
|
+
expect(c.state().phase).toBe('listening');
|
|
99
|
+
expect(c.state().micLive).toBe(true);
|
|
100
|
+
await c.end();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('while it is thinking, the reply that arrives is shown but not spoken', async () => {
|
|
104
|
+
const speak = vi.fn(async () => undefined);
|
|
105
|
+
let release: () => void = () => undefined;
|
|
106
|
+
const turn = vi.fn(() => new Promise<any>((resolve) => { release = () => resolve(turnResult(1)); }));
|
|
107
|
+
const { c, heard } = rig({ speak, turn: turn as never });
|
|
108
|
+
c.start();
|
|
109
|
+
await settle(() => heard.length >= 1);
|
|
110
|
+
heard[0].deliver(blob());
|
|
111
|
+
await settle(() => c.state().phase === 'thinking');
|
|
112
|
+
c.stop();
|
|
113
|
+
release();
|
|
114
|
+
await settle(() => c.state().lines.length >= 2);
|
|
115
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
116
|
+
expect(speak).not.toHaveBeenCalled();
|
|
117
|
+
expect(c.state().lines.at(-1)?.text).toBe('reply 1');
|
|
118
|
+
expect(c.state().phase).toBe('listening');
|
|
119
|
+
await c.end();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('a typed turn with a duplex mic', () => {
|
|
124
|
+
it('does not stop the listening', async () => {
|
|
125
|
+
const { c, heard } = rig();
|
|
126
|
+
c.start();
|
|
127
|
+
await settle(() => heard.length >= 1);
|
|
128
|
+
await c.sendText('hello');
|
|
129
|
+
expect(heard[0].signal.aborted).toBe(false);
|
|
130
|
+
await c.end();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { ConverseClientError, createMeetingController, type MeetingApi, type MeetingIO } from '../corpus/converse';
|
|
4
|
+
|
|
5
|
+
const blob = () => new Blob([new Uint8Array([1])], { type: 'audio/mp4' });
|
|
6
|
+
const settle = async (check: () => boolean) => { for (let i = 0; i < 300 && !check(); i += 1) await new Promise((r) => setTimeout(r, 5)); };
|
|
7
|
+
const relayTurn = (n: number) => ({ turn: n, turn_id: `r${n}`, at: 't', who: 'relay' as const, transcript: '', reply_text: 'relay says hi', audio_url: `/a/${n}`, audio_reason: null, for_relay: false });
|
|
8
|
+
|
|
9
|
+
function rig(duplex: boolean, turn?: MeetingApi<Blob>['turn']) {
|
|
10
|
+
let queued: any[] = [];
|
|
11
|
+
const client: MeetingApi<Blob> = {
|
|
12
|
+
turn: turn ?? vi.fn(async () => ({ conversation_id: 'c1', turn_id: 't', turn: 1, transcript: 'said', reply_text: 'ok', audio_url: null, audio_reason: 'x' })),
|
|
13
|
+
end: vi.fn() as never,
|
|
14
|
+
thread: vi.fn(async (_id: string, after: number) => ({ conversation_id: 'c1', status: 'open' as const, updated_at: 't', turns: queued.filter((t) => t.turn > after) })),
|
|
15
|
+
};
|
|
16
|
+
const listens: Array<{ signal: AbortSignal; hooks?: { onSpeechStart?: () => void }; resolve: (v: any) => void }> = [];
|
|
17
|
+
const events: string[] = [];
|
|
18
|
+
const io: MeetingIO<Blob> = {
|
|
19
|
+
duplex,
|
|
20
|
+
listen: vi.fn((signal: AbortSignal, _c: unknown, hooks?: { onSpeechStart?: () => void }) => new Promise((resolve) => {
|
|
21
|
+
listens.push({ signal, hooks, resolve });
|
|
22
|
+
// like the phone: aborting with 'finish' while he was speaking hands back what he said; a plain abort throws it away
|
|
23
|
+
signal.addEventListener('abort', () => resolve(signal.reason === 'finish' && hooks && (hooks as any).__spoke ? { audio: blob() } : { audio: null, cancelled: true }));
|
|
24
|
+
})),
|
|
25
|
+
speak: vi.fn(async () => { events.push('speak'); }),
|
|
26
|
+
};
|
|
27
|
+
const ctl = createMeetingController({ client, io, config: { relayPollMs: 20, resendMs: 20 } });
|
|
28
|
+
return { ctl, client, io, listens, events, push: (...t: any[]) => { queued = [...queued, ...t]; } };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('an incoming relay reply never throws away what he is saying', () => {
|
|
32
|
+
it('a phone that cannot record and play at once finishes his utterance (sends it) instead of discarding it', async () => {
|
|
33
|
+
const r = rig(false);
|
|
34
|
+
r.ctl.start();
|
|
35
|
+
await settle(() => r.listens.length >= 1);
|
|
36
|
+
(r.listens[0].hooks as any).__spoke = true; // he is mid-sentence
|
|
37
|
+
await r.ctl.sendText('hello'); // establishes the conversation and starts polling
|
|
38
|
+
await settle(() => r.listens.length >= 2);
|
|
39
|
+
(r.listens[r.listens.length - 1].hooks as any).__spoke = true;
|
|
40
|
+
const before = r.listens.length;
|
|
41
|
+
r.push(relayTurn(5));
|
|
42
|
+
await settle(() => r.listens[before - 1].signal.aborted);
|
|
43
|
+
expect(r.listens[before - 1].signal.aborted).toBe(true);
|
|
44
|
+
expect(r.listens[before - 1].signal.reason).toBe('finish');
|
|
45
|
+
await r.ctl.end();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('with an open mic the relay is held back while he is speaking, then read', async () => {
|
|
49
|
+
const r = rig(true);
|
|
50
|
+
r.ctl.start();
|
|
51
|
+
await settle(() => r.listens.length >= 1);
|
|
52
|
+
await r.ctl.sendText('hello'); // opens the conversation; its reply has no audio
|
|
53
|
+
r.listens[0].hooks?.onSpeechStart?.(); // he starts a long message
|
|
54
|
+
r.push(relayTurn(5));
|
|
55
|
+
await settle(() => r.ctl.getState().lines.some((l) => l.role === 'relay'));
|
|
56
|
+
await new Promise((res) => setTimeout(res, 100));
|
|
57
|
+
expect(r.io.speak).not.toHaveBeenCalled();
|
|
58
|
+
expect(r.listens[0].signal.aborted).toBe(false); // his recording is untouched
|
|
59
|
+
r.listens[0].resolve({ audio: blob() }); // he finishes: sent
|
|
60
|
+
await settle(() => (r.client.turn as any).mock.calls.length >= 2);
|
|
61
|
+
expect((r.client.turn as any).mock.calls.length).toBe(2);
|
|
62
|
+
await settle(() => (r.io.speak as any).mock.calls.length >= 1);
|
|
63
|
+
expect(r.io.speak).toHaveBeenCalledTimes(1);
|
|
64
|
+
await r.ctl.end();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('a turn that fails to send keeps his audio and is retried', () => {
|
|
69
|
+
it('the same recording is sent again until it goes through', async () => {
|
|
70
|
+
let calls = 0;
|
|
71
|
+
const turn = vi.fn(async (input: any) => {
|
|
72
|
+
calls += 1;
|
|
73
|
+
if (calls < 3) throw new ConverseClientError('network down', 0, 'network');
|
|
74
|
+
return { conversation_id: 'c1', turn_id: 't', turn: 1, transcript: 'said', reply_text: 'ok', audio_url: null, audio_reason: 'x', _in: input };
|
|
75
|
+
});
|
|
76
|
+
const r = rig(true, turn as never);
|
|
77
|
+
r.ctl.start();
|
|
78
|
+
await settle(() => r.listens.length >= 1);
|
|
79
|
+
const audio = blob();
|
|
80
|
+
r.listens[0].resolve({ audio });
|
|
81
|
+
await settle(() => calls >= 3 && r.ctl.state().lines.length >= 2, );
|
|
82
|
+
expect(calls).toBe(3);
|
|
83
|
+
expect(turn.mock.calls[2][0].audio).toBe(audio);
|
|
84
|
+
expect(r.ctl.state().lines[0].text).toBe('said');
|
|
85
|
+
await r.ctl.end();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -17,7 +17,7 @@ function run(levels: Array<[level: number, ms: number]>, config = cfg) {
|
|
|
17
17
|
describe('resolveMeetingConfig', () => {
|
|
18
18
|
it('defaults, partial overrides, and ignores nonsense', () => {
|
|
19
19
|
const d = resolveMeetingConfig();
|
|
20
|
-
expect(d).toMatchObject({ silenceMs: 1200, minUtteranceMs: 400, maxUtteranceMs: 60000, interruptOnSpeech:
|
|
20
|
+
expect(d).toMatchObject({ silenceMs: 1200, minUtteranceMs: 400, maxUtteranceMs: 60000, interruptOnSpeech: true });
|
|
21
21
|
expect(resolveMeetingConfig({ silenceMs: 800, interruptOnSpeech: true })).toMatchObject({ silenceMs: 800, interruptOnSpeech: true, minUtteranceMs: 400 });
|
|
22
22
|
expect(resolveMeetingConfig({ silenceMs: -5, speechLevel: Number.NaN }).silenceMs).toBe(1200);
|
|
23
23
|
});
|
|
@@ -16,4 +16,14 @@ describe('what the voice says: dates, ticket ids and markup are said the way a p
|
|
|
16
16
|
it('leaves a plain sentence alone (null = nothing to change)', () => {
|
|
17
17
|
expect(toSpoken('Yesterday you added 12 new to-dos.', TODAY)).toBeNull();
|
|
18
18
|
});
|
|
19
|
+
it('drops leading filler on the voice only', () => {
|
|
20
|
+
expect(toSpoken('Yes, the to-do Order the bench is due Friday.', TODAY)).toBe('Order the bench is due Friday.');
|
|
21
|
+
expect(toSpoken('Sure, it is done.', TODAY)).toBe('It is done.');
|
|
22
|
+
expect(toSpoken('Okay. Moved it to Friday.', TODAY)).toBe('Moved it to Friday.');
|
|
23
|
+
expect(toSpoken('Yes you have three items.', TODAY)).toBe('You have three items.');
|
|
24
|
+
});
|
|
25
|
+
it('does not strip a word that is part of the sentence', () => {
|
|
26
|
+
expect(toSpoken('Yesterday you added 12 new to-dos.', TODAY)).toBeNull();
|
|
27
|
+
expect(toSpoken('Okayama trip is due 2026-11-20.', TODAY)).toBe('Okayama trip is due Friday.');
|
|
28
|
+
});
|
|
19
29
|
});
|