@startsimpli/integrations 0.2.149 → 0.2.151
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 +3 -3
- package/src/__tests__/connection-check-reason.test.tsx +85 -0
- package/src/__tests__/focus-history.test.ts +90 -0
- package/src/__tests__/goal-rows.test.ts +51 -0
- package/src/__tests__/goals-page.test.tsx +124 -0
- package/src/__tests__/helpers/question-tenant.ts +45 -0
- package/src/__tests__/question-checkin.test.ts +139 -0
- package/src/__tests__/question-voice-parse.test.ts +110 -0
- package/src/__tests__/question-voice.test.ts +208 -0
- package/src/__tests__/stated-date-extract.test.ts +119 -0
- package/src/__tests__/stated-date.test.ts +107 -0
- package/src/__tests__/tracker-done-stamp.test.ts +42 -0
- package/src/__tests__/tracker-timeline-component.test.tsx +81 -0
- package/src/__tests__/tracker-timeline-reader.test.ts +94 -0
- package/src/__tests__/tracker-timeline.test.ts +209 -0
- package/src/components/index.ts +1 -0
- package/src/components/pages/PlanningPage.tsx +16 -2
- package/src/components/pages/TrackerPage.tsx +8 -0
- package/src/components/pages/connections/ConnectionCard.tsx +12 -0
- package/src/components/pages/connections/bound-api.ts +1 -1
- package/src/components/pages/goals/FocusProgressHistory.tsx +77 -0
- package/src/components/pages/goals/GoalsPage.tsx +186 -0
- package/src/components/pages/goals/index.ts +4 -0
- package/src/components/pages/tracker/TrackerTimeline.tsx +123 -0
- package/src/components/pages/types.ts +2 -2
- package/src/corpus/client.ts +27 -1
- package/src/corpus/commitments.ts +3 -1
- package/src/corpus/extract.ts +8 -6
- package/src/corpus/focus-history.ts +104 -0
- package/src/corpus/goal-rows.ts +29 -0
- package/src/corpus/index.ts +6 -0
- package/src/corpus/questions/checkin-handle.ts +67 -0
- package/src/corpus/questions/checkin.ts +103 -0
- package/src/corpus/questions/index.ts +9 -0
- package/src/corpus/questions/respond.ts +76 -0
- package/src/corpus/questions/store.ts +5 -1
- package/src/corpus/questions/sync.ts +1 -0
- package/src/corpus/questions/types.ts +10 -2
- package/src/corpus/questions/voice-parse.ts +98 -0
- package/src/corpus/questions/voice.ts +225 -0
- package/src/corpus/spoken-time.ts +4 -4
- package/src/corpus/stated-date.ts +187 -0
- package/src/corpus/tracker-timeline-client.ts +117 -0
- package/src/corpus/tracker-timeline.ts +228 -0
- package/src/corpus/types.ts +25 -1
- package/src/corpus/work-item-logic.ts +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Answering a clarifying question by voice (bd startsim-tmrvi.5). The words people
|
|
3
|
+
* actually say to "When is this due?" / "Which project?" become one answer, or a
|
|
4
|
+
* short question back. Never a briefing action: "skip it" must not drop a to-do.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { parseSpokenAnswer } from '../corpus/questions/voice-parse';
|
|
9
|
+
import type { OpenQuestion } from '../corpus/questions';
|
|
10
|
+
|
|
11
|
+
const NOW = Date.parse('2026-11-04T15:00:00Z'); // Wednesday 10:00 in New York
|
|
12
|
+
const TZ = 'America/New_York';
|
|
13
|
+
|
|
14
|
+
const q = (over: Partial<OpenQuestion>): OpenQuestion => ({
|
|
15
|
+
id: 'q1', itemId: 'i1', kind: 'due_date', question: 'When is this due?', status: 'open', candidates: [],
|
|
16
|
+
score: 70, ownerSub: 'me', createdAt: '', updatedAt: '', ...over,
|
|
17
|
+
});
|
|
18
|
+
const ctx = (options: Array<{ value: string; label: string }> = []) => ({ now: NOW, timeZone: TZ, options });
|
|
19
|
+
|
|
20
|
+
const PROJECTS = [
|
|
21
|
+
{ value: 'f-mkt', label: 'Marketing' },
|
|
22
|
+
{ value: 'f-web', label: 'Website redesign' },
|
|
23
|
+
{ value: 'f-ops', label: 'Operations' },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
describe('parseSpokenAnswer: due date', () => {
|
|
27
|
+
const due = q({ assumed: { value: '2026-11-06', confidence: 0.5, reason: 'by Friday' } });
|
|
28
|
+
|
|
29
|
+
it.each([
|
|
30
|
+
['today', '2026-11-04'],
|
|
31
|
+
['tomorrow', '2026-11-05'],
|
|
32
|
+
['next week', '2026-11-09'],
|
|
33
|
+
['make it Friday please', '2026-11-06'],
|
|
34
|
+
["let's say next Tuesday", '2026-11-10'],
|
|
35
|
+
])('%s -> %s', (said, date) => {
|
|
36
|
+
const out = parseSpokenAnswer(due, said, ctx());
|
|
37
|
+
expect(out).toMatchObject({ kind: 'answer', value: date });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('later clears the due date', () => {
|
|
41
|
+
expect(parseSpokenAnswer(due, 'someday', ctx())).toMatchObject({ kind: 'answer', value: '' });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('keeps the guess on a yes', () => {
|
|
45
|
+
for (const said of ['yes', 'yeah that is right', 'keep it', 'sounds good', "that's fine"]) {
|
|
46
|
+
expect(parseSpokenAnswer(due, said, ctx())).toEqual({ kind: 'accept' });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('skip is a skip, not a drop', () => {
|
|
51
|
+
for (const said of ['skip it', 'not now', 'ask me later', 'pass']) {
|
|
52
|
+
expect(parseSpokenAnswer(due, said, ctx())).toEqual({ kind: 'skip' });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('asks again on something that is not a date', () => {
|
|
57
|
+
const out = parseSpokenAnswer(due, 'banana', ctx());
|
|
58
|
+
expect(out.kind).toBe('unclear');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('undo is its own thing', () => {
|
|
62
|
+
expect(parseSpokenAnswer(due, 'undo that', ctx())).toEqual({ kind: 'undo' });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('a yes with no guess to keep asks for the answer', () => {
|
|
66
|
+
const out = parseSpokenAnswer(q({}), 'yes', ctx());
|
|
67
|
+
expect(out.kind).toBe('unclear');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('parseSpokenAnswer: a choice (project, team, owner)', () => {
|
|
72
|
+
const project = q({ kind: 'project', question: 'Which project is this for?', candidates: [
|
|
73
|
+
{ value: 'f-mkt', confidence: 0.5, reason: '' }, { value: 'f-web', confidence: 0.4, reason: '' },
|
|
74
|
+
] });
|
|
75
|
+
|
|
76
|
+
it("that's the marketing project", () => {
|
|
77
|
+
expect(parseSpokenAnswer(project, "that's the marketing project", ctx(PROJECTS))).toMatchObject({ kind: 'answer', value: 'f-mkt', label: 'Marketing' });
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('picks by position among the options just offered', () => {
|
|
81
|
+
expect(parseSpokenAnswer(project, 'the second one', ctx(PROJECTS))).toMatchObject({ kind: 'answer', value: 'f-web' });
|
|
82
|
+
expect(parseSpokenAnswer(project, 'the first', ctx(PROJECTS))).toMatchObject({ kind: 'answer', value: 'f-mkt' });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('names an option that was not among the candidates', () => {
|
|
86
|
+
expect(parseSpokenAnswer(project, 'operations', ctx(PROJECTS))).toMatchObject({ kind: 'answer', value: 'f-ops' });
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('asks which one when the words fit two', () => {
|
|
90
|
+
const two = [{ value: 'a', label: 'Marketing site' }, { value: 'b', label: 'Marketing email' }];
|
|
91
|
+
const out = parseSpokenAnswer(project, 'marketing', ctx(two));
|
|
92
|
+
expect(out).toMatchObject({ kind: 'unclear' });
|
|
93
|
+
expect((out as { question: string }).question).toMatch(/Marketing site/);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('offers the candidates when nothing fits', () => {
|
|
97
|
+
const out = parseSpokenAnswer(project, 'the purple thing', ctx(PROJECTS));
|
|
98
|
+
expect(out.kind).toBe('unclear');
|
|
99
|
+
expect((out as { question: string }).question).toMatch(/Marketing/);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('accepts the guess on a yes', () => {
|
|
103
|
+
const guessed = q({ kind: 'project', assumed: { value: 'f-mkt', display: 'Marketing', confidence: 0.6, reason: '' } });
|
|
104
|
+
expect(parseSpokenAnswer(guessed, 'yes', ctx(PROJECTS))).toEqual({ kind: 'accept' });
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('skip works here too', () => {
|
|
108
|
+
expect(parseSpokenAnswer(project, 'skip it', ctx(PROJECTS))).toEqual({ kind: 'skip' });
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
/**
|
|
3
|
+
* Answering the clarifying-question queue by voice (bd startsim-tmrvi.5): one press answers the best open
|
|
4
|
+
* question, says it back, and asks the next. Real parser, real queue, real answer path, in-memory tenant.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { commitmentEditSeam } from '../corpus/briefing/actions/seam';
|
|
9
|
+
import { createMemoryActionLog } from '../corpus/briefing/actions/log';
|
|
10
|
+
import { createPlanningApi } from '../corpus/client';
|
|
11
|
+
import { guessOf, unknownGuess } from '../corpus/extraction-fields';
|
|
12
|
+
import { listOpenQuestions, syncOpenQuestions } from '../corpus/questions';
|
|
13
|
+
import { storeFor } from '../corpus/questions/sync';
|
|
14
|
+
import { answerQuestionByVoice, VoiceAnswerError, type VoiceAnswerDeps } from '../corpus/questions/voice';
|
|
15
|
+
import { tenant } from './helpers/question-tenant';
|
|
16
|
+
|
|
17
|
+
const SCOPE = { orgId: 'o' } as never;
|
|
18
|
+
const ME = 'user-me';
|
|
19
|
+
const NOW = Date.parse('2026-11-04T15:00:00Z'); // Wednesday, 10:00 in New York
|
|
20
|
+
const TZ = 'America/New_York';
|
|
21
|
+
|
|
22
|
+
const item = (id: string, data: Record<string, unknown> = {}) => ({
|
|
23
|
+
id, entity_type: 'commitment', external_id: `commit:${id}`, name: String(data.title ?? id),
|
|
24
|
+
data: { title: `Item ${id}`, status: 'open', mentions: [{ document_id: 'note1', quote: 'q' }], ...data },
|
|
25
|
+
});
|
|
26
|
+
const held = (id: string, title: string) => item(id, {
|
|
27
|
+
title, sync_state: 'needs_team', open_question_kind: 'team', open_question: 'Which team is this for?',
|
|
28
|
+
});
|
|
29
|
+
const fields = (over: object) => ({
|
|
30
|
+
due: unknownGuess('x'), project: unknownGuess('x'), owner: unknownGuess('x'), priority: unknownGuess('x'), estimate: unknownGuess('x'), ...over,
|
|
31
|
+
});
|
|
32
|
+
const note = (records: unknown[]) => ({
|
|
33
|
+
id: 'note1', entity_type: 'source_document', external_id: 'voice:n1', name: 'Voice note',
|
|
34
|
+
data: { source: 'voice', title: 'Voice note', voice_items: JSON.stringify(records) },
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const TEAMS = [{ value: 'team-eng', label: 'Engineering' }, { value: 'team-ops', label: 'Operations' }];
|
|
38
|
+
|
|
39
|
+
function setup(rows: Parameters<typeof tenant>[0], extra: Partial<VoiceAnswerDeps> = {}) {
|
|
40
|
+
const t = tenant(rows);
|
|
41
|
+
const api = createPlanningApi({ http: t.http, scope: SCOPE, supportedFilters: [], resolveParticipants: false } as never);
|
|
42
|
+
const clock = { now: NOW };
|
|
43
|
+
const deps: VoiceAnswerDeps = {
|
|
44
|
+
http: t.http, scope: SCOPE, ownerSub: ME, now: () => clock.now, timeZone: TZ,
|
|
45
|
+
seam: commitmentEditSeam({ api, http: t.http, scope: SCOPE }),
|
|
46
|
+
patchItem: vi.fn(async (id: string, wire: Record<string, unknown>) => { const r = t.rows.get(id)!; r.data = { ...r.data, ...wire }; }),
|
|
47
|
+
fileItem: vi.fn(async () => undefined),
|
|
48
|
+
setPersonalContainer: vi.fn(async () => undefined),
|
|
49
|
+
options: async (q) => (q.kind === 'team' ? TEAMS : []),
|
|
50
|
+
log: createMemoryActionLog(),
|
|
51
|
+
...extra,
|
|
52
|
+
};
|
|
53
|
+
return { t, deps, clock };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const vet = () => [
|
|
57
|
+
item('vet', { title: 'Call the vet', due_at: '2026-11-06' }),
|
|
58
|
+
note([{ section: 's', title: 'Call the vet', fields: fields({
|
|
59
|
+
due: guessOf('2026-11-06', 0.5, 'assumed', 'said Friday on a Friday', { question: 'Did you mean today or next Friday?' }),
|
|
60
|
+
}) }]),
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
let press = 0;
|
|
64
|
+
const say = (deps: VoiceAnswerDeps, utterance: string, over: object = {}) =>
|
|
65
|
+
answerQuestionByVoice(deps, { clientActionId: `press-${String(++press).padStart(4, '0')}`, utterance, ...over });
|
|
66
|
+
|
|
67
|
+
describe('answerQuestionByVoice', () => {
|
|
68
|
+
it('answers a due date, says it back, and asks the next question', async () => {
|
|
69
|
+
const { t, deps } = setup([...vet(), held('bench', "Order dad's bench")]);
|
|
70
|
+
await syncOpenQuestions(deps);
|
|
71
|
+
// the team question outranks the due date, so it is asked first
|
|
72
|
+
const first = await say(deps, 'operations');
|
|
73
|
+
expect(first).toMatchObject({ kind: 'answered' });
|
|
74
|
+
expect(first.spoken).toMatch(/Operations/);
|
|
75
|
+
expect(first.next?.kind).toBe('due_date');
|
|
76
|
+
expect(first.spoken).toMatch(/Call the vet/);
|
|
77
|
+
expect(deps.patchItem).toHaveBeenCalledWith('bench', expect.objectContaining({ external_container_id: 'team-ops' }));
|
|
78
|
+
|
|
79
|
+
const second = await say(deps, 'tomorrow');
|
|
80
|
+
expect(second).toMatchObject({ kind: 'answered', next: null, remaining: 0 });
|
|
81
|
+
expect(second.spoken).toMatch(/due tomorrow/);
|
|
82
|
+
expect(second.spoken).toMatch(/everything/i);
|
|
83
|
+
expect(String(t.rows.get('vet')!.data.due_at)).toContain('2026-11-05');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('a repeat press does nothing twice', async () => {
|
|
87
|
+
const { t, deps } = setup(vet());
|
|
88
|
+
await syncOpenQuestions(deps);
|
|
89
|
+
const a = await answerQuestionByVoice(deps, { clientActionId: 'press-repeat-1', utterance: 'today' });
|
|
90
|
+
const writes = [...t.rows.values()].map((r) => r.version).join(',');
|
|
91
|
+
const b = await answerQuestionByVoice(deps, { clientActionId: 'press-repeat-1', utterance: 'today' });
|
|
92
|
+
expect(b.replayed).toBe(true);
|
|
93
|
+
expect(b.spoken).toBe(a.spoken);
|
|
94
|
+
expect([...t.rows.values()].map((r) => r.version).join(',')).toBe(writes);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('yes keeps the guess and confirms the item', async () => {
|
|
98
|
+
const { t, deps } = setup(vet());
|
|
99
|
+
await syncOpenQuestions(deps);
|
|
100
|
+
const out = await say(deps, 'yes keep it');
|
|
101
|
+
expect(out.kind).toBe('accepted');
|
|
102
|
+
expect(String(t.rows.get('vet')!.data.due_at)).toContain('2026-11-06');
|
|
103
|
+
expect(await listOpenQuestions(deps)).toEqual([]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('never says an id aloud when keeping a guess', async () => {
|
|
107
|
+
const { deps } = setup([held('bench', "Order dad's bench")]);
|
|
108
|
+
await syncOpenQuestions(deps);
|
|
109
|
+
const q = (await listOpenQuestions(deps))[0];
|
|
110
|
+
await storeFor(deps).put(q.itemId, q.kind, q.question, { assumed: JSON.stringify({ value: 'team-ops', confidence: 0.5, reason: 'r' }) });
|
|
111
|
+
const out = await say(deps, 'yes');
|
|
112
|
+
expect(out.kind).toBe('accepted');
|
|
113
|
+
expect(out.spoken).toMatch(/Operations/);
|
|
114
|
+
expect(out.spoken).not.toMatch(/team-ops/);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('skip leaves the item alone and does not ask again until later', async () => {
|
|
118
|
+
const { t, deps, clock } = setup([held('bench', "Order dad's bench")]);
|
|
119
|
+
await syncOpenQuestions(deps);
|
|
120
|
+
const out = await say(deps, 'skip it');
|
|
121
|
+
expect(out.kind).toBe('skipped');
|
|
122
|
+
expect(t.rows.get('bench')!.data.status).toBe('open'); // not dropped
|
|
123
|
+
await syncOpenQuestions(deps);
|
|
124
|
+
expect(await listOpenQuestions(deps)).toEqual([]); // snoozed
|
|
125
|
+
clock.now += 13 * 3_600_000;
|
|
126
|
+
await syncOpenQuestions(deps);
|
|
127
|
+
expect(await listOpenQuestions(deps)).toHaveLength(1); // a held item is asked again
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('asks back instead of guessing, and keeps the question open', async () => {
|
|
131
|
+
const { deps } = setup([held('bench', "Order dad's bench")]);
|
|
132
|
+
await syncOpenQuestions(deps);
|
|
133
|
+
const out = await say(deps, 'the purple one');
|
|
134
|
+
expect(out.kind).toBe('clarify');
|
|
135
|
+
expect(out.spoken).toMatch(/Engineering/);
|
|
136
|
+
expect(out.next).toBeNull();
|
|
137
|
+
expect(await listOpenQuestions(deps)).toHaveLength(1);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('undo puts a due date back and reopens the question', async () => {
|
|
141
|
+
const { t, deps } = setup(vet());
|
|
142
|
+
await syncOpenQuestions(deps);
|
|
143
|
+
await say(deps, 'next week');
|
|
144
|
+
expect(String(t.rows.get('vet')!.data.due_at)).toContain('2026-11-09');
|
|
145
|
+
const out = await say(deps, 'undo that');
|
|
146
|
+
expect(out.kind).toBe('undone');
|
|
147
|
+
expect(String(t.rows.get('vet')!.data.due_at)).toContain('2026-11-06');
|
|
148
|
+
expect(await listOpenQuestions(deps)).toHaveLength(1);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('says plainly when an answer cannot be undone by voice', async () => {
|
|
152
|
+
const { deps } = setup([held('bench', "Order dad's bench")]);
|
|
153
|
+
await syncOpenQuestions(deps);
|
|
154
|
+
await say(deps, 'engineering');
|
|
155
|
+
const out = await say(deps, 'undo');
|
|
156
|
+
expect(out.kind).toBe('clarify');
|
|
157
|
+
expect(out.spoken).toMatch(/cannot undo/);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('says so when nothing is waiting', async () => {
|
|
161
|
+
const { deps } = setup([item('plain')]);
|
|
162
|
+
await syncOpenQuestions(deps);
|
|
163
|
+
expect((await say(deps, 'today')).kind).toBe('nothing');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('answers a named question, not just the best one', async () => {
|
|
167
|
+
const { deps } = setup([...vet(), held('bench', "Order dad's bench")]);
|
|
168
|
+
await syncOpenQuestions(deps);
|
|
169
|
+
const due = (await listOpenQuestions(deps)).find((q) => q.kind === 'due_date')!;
|
|
170
|
+
const out = await say(deps, 'today', { questionId: due.id });
|
|
171
|
+
expect(out.question?.id).toBe(due.id);
|
|
172
|
+
expect(out.next?.kind).toBe('team');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('transcribes a recording, offering the choices as vocabulary', async () => {
|
|
176
|
+
const transcribe = vi.fn(async () => 'engineering');
|
|
177
|
+
const { deps } = setup([held('bench', "Order dad's bench")], { transcribe });
|
|
178
|
+
await syncOpenQuestions(deps);
|
|
179
|
+
const out = await answerQuestionByVoice(deps, { clientActionId: 'press-audio-01', audio: { audio: new Uint8Array([1]), mimeType: 'audio/mp4' } });
|
|
180
|
+
expect(out.kind).toBe('answered');
|
|
181
|
+
expect(transcribe).toHaveBeenCalledWith(expect.objectContaining({ hints: ['Engineering', 'Operations'] }));
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('speaks the reply when speech is configured, and still answers in text when it fails', async () => {
|
|
185
|
+
const put = vi.fn(async () => 'ref-1');
|
|
186
|
+
const ok = setup([held('bench', "Order dad's bench")], {
|
|
187
|
+
synthesize: async () => ({ audio: new Uint8Array([1, 2]), mimeType: 'audio/mpeg', model: 'm', provider: 'p', usage: {} }),
|
|
188
|
+
audio: { put }, audioPath: (id) => `/corpus/questions/audio/${id}`,
|
|
189
|
+
});
|
|
190
|
+
await syncOpenQuestions(ok.deps);
|
|
191
|
+
const spoken = await say(ok.deps, 'engineering');
|
|
192
|
+
expect(spoken.audioUrl).toMatch(/\/corpus\/questions\/audio\/press-/);
|
|
193
|
+
|
|
194
|
+
const bad = setup([held('bench', "Order dad's bench")], {
|
|
195
|
+
synthesize: async () => { throw new Error('quota'); }, audio: { put }, audioPath: (id) => `/a/${id}`,
|
|
196
|
+
});
|
|
197
|
+
await syncOpenQuestions(bad.deps);
|
|
198
|
+
const text = await say(bad.deps, 'engineering');
|
|
199
|
+
expect(text.audioUrl).toBeNull();
|
|
200
|
+
expect(text.kind).toBe('answered');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('rejects a bad press id and an empty request', async () => {
|
|
204
|
+
const { deps } = setup([]);
|
|
205
|
+
await expect(answerQuestionByVoice(deps, { clientActionId: 'x', utterance: 'hi' })).rejects.toBeInstanceOf(VoiceAnswerError);
|
|
206
|
+
await expect(answerQuestionByVoice(deps, { clientActionId: 'press-empty-1' })).rejects.toMatchObject({ status: 400 });
|
|
207
|
+
});
|
|
208
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The extractor carries the dates a meeting states onto the rows it creates
|
|
3
|
+
* (bd startsim-768w.38.30) - and invents none.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { mergeDrafts, reconcile } from '../corpus/commitments';
|
|
8
|
+
import { extractCommitments, extractSystemPrompt, rulesExtract } from '../corpus/extract';
|
|
9
|
+
import { createFixtureCorpusApi, createFixtureExtractor, FIXTURE_ORG } from '../corpus/fixtures';
|
|
10
|
+
import type { Commitment, CorpusExtractorLlm, SourceDocument } from '../corpus/types';
|
|
11
|
+
|
|
12
|
+
const TANDEM = { orgId: FIXTURE_ORG };
|
|
13
|
+
const MEETING = '2026-08-05T15:00:00Z';
|
|
14
|
+
|
|
15
|
+
const BODY = [
|
|
16
|
+
'## Discussion',
|
|
17
|
+
'',
|
|
18
|
+
'- Kevin said the vendor contract will be signed by 29th July, nothing else changes there.',
|
|
19
|
+
'- Peggy will circulate the revised budget tomorrow after the board call.',
|
|
20
|
+
'- Julia thinks someone should probably revisit the onboarding emails at some point.',
|
|
21
|
+
'',
|
|
22
|
+
'## Next Steps',
|
|
23
|
+
'',
|
|
24
|
+
'- **Complete the equity item today** (Jonathan)',
|
|
25
|
+
'- **Pay the Rexford invoice by 11th August** (Kate)',
|
|
26
|
+
'- **Schedule call with Peggy for next week**',
|
|
27
|
+
'- **Review the data room permissions urgently** (Brian)',
|
|
28
|
+
'- **Send the revised term sheet on Wednesday** (Kevin)',
|
|
29
|
+
].join('\n');
|
|
30
|
+
|
|
31
|
+
function meeting(occurredAt: string | null = MEETING): SourceDocument {
|
|
32
|
+
return {
|
|
33
|
+
id: 'm1', title: 'Weekly sync', body: BODY, sections: [], occurredAt,
|
|
34
|
+
source: 'granola', sourceLabel: 'Granola', sourceRef: 'granola:m1', participants: [], scope: TANDEM,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const modelItems = (): CorpusExtractorLlm => ({
|
|
39
|
+
...createFixtureExtractor(),
|
|
40
|
+
async extract() {
|
|
41
|
+
return {
|
|
42
|
+
items: [
|
|
43
|
+
// the date is in the quote: code resolves it, whatever the model wrote
|
|
44
|
+
{ documentId: 'm1', title: 'Circulate the revised budget', quote: 'Peggy will circulate the revised budget tomorrow after the board call.', dueAt: '2031-01-01' },
|
|
45
|
+
{ documentId: 'm1', title: 'Get the vendor contract signed', quote: 'the vendor contract will be signed by 29th July', dueAt: null },
|
|
46
|
+
// the model estimated a date nobody stated
|
|
47
|
+
{ documentId: 'm1', title: 'Revisit the onboarding emails', quote: 'someone should probably revisit the onboarding emails at some point', dueAt: '2026-08-12' },
|
|
48
|
+
],
|
|
49
|
+
resolutions: [],
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('rules extraction carries stated dates', () => {
|
|
55
|
+
const byTitle = (occurredAt?: string | null) => Object.fromEntries(rulesExtract(meeting(occurredAt)).map((d) => [d.title, d]));
|
|
56
|
+
|
|
57
|
+
it('resolves absolute and relative dates against the meeting date', () => {
|
|
58
|
+
const d = byTitle();
|
|
59
|
+
expect(d['Complete the equity item today'].dueAt).toBe('2026-08-05T23:59:59Z');
|
|
60
|
+
expect(d['Pay the Rexford invoice by 11th August'].dueAt).toBe('2026-08-11T23:59:59Z');
|
|
61
|
+
expect(d['Send the revised term sheet on Wednesday']?.dueAt).toBeUndefined(); // said on a Wednesday: ambiguous
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('records what it read, as the row\'s due basis', () => {
|
|
65
|
+
const d = byTitle()['Complete the equity item today'];
|
|
66
|
+
expect(d.dueBasis).toContain('today');
|
|
67
|
+
expect(d.dueConfidence).toBeGreaterThan(0.8);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('leaves spans, urgency and undated items without a date', () => {
|
|
71
|
+
const d = byTitle();
|
|
72
|
+
expect(d['Schedule call with Peggy for next week'].dueAt).toBeUndefined();
|
|
73
|
+
expect(d['Review the data room permissions urgently'].dueAt).toBeUndefined();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('cannot resolve "today" without a meeting date, but still reads an absolute one', () => {
|
|
77
|
+
const d = byTitle(null);
|
|
78
|
+
expect(d['Complete the equity item today'].dueAt).toBeUndefined();
|
|
79
|
+
expect(d['Pay the Rexford invoice by 11th August'].dueAt).toBeUndefined(); // no year, no anchor: a guess
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('model extraction never supplies a date of its own', () => {
|
|
84
|
+
it('resolves the date from the quote, ignores the model\'s own dueAt, and leaves undated items unset', async () => {
|
|
85
|
+
const corpus = createFixtureCorpusApi({ scope: TANDEM, documents: [meeting()] });
|
|
86
|
+
const rows: Commitment[] = [];
|
|
87
|
+
(corpus as { listCommitments?: unknown }).listCommitments = async () => ({ count: 0, next: null, previous: null, results: [] });
|
|
88
|
+
(corpus as { saveCommitments?: unknown }).saveCommitments = async (items: Commitment[]) => { rows.push(...items); };
|
|
89
|
+
await extractCommitments({ scope: TANDEM }, { corpus, extractor: modelItems() });
|
|
90
|
+
const row = (needle: string) => rows.find((r) => r.title.includes(needle));
|
|
91
|
+
|
|
92
|
+
expect(row('Circulate the revised budget')?.dueAt).toBe('2026-08-06T23:59:59Z');
|
|
93
|
+
expect(row('vendor contract signed')?.dueAt).toBe('2026-07-29T23:59:59Z');
|
|
94
|
+
expect(row('Revisit the onboarding emails')).toBeDefined();
|
|
95
|
+
expect(row('Revisit the onboarding emails')?.dueAt).toBeUndefined();
|
|
96
|
+
expect(row('Complete the equity item today')?.dueAt).toBe('2026-08-05T23:59:59Z');
|
|
97
|
+
expect(row('Schedule call with Peggy')?.dueAt).toBeUndefined();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('still tells the model never to estimate a date', () => {
|
|
101
|
+
expect(extractSystemPrompt()).toMatch(/never estimate/i);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('rows that already exist are not touched', () => {
|
|
106
|
+
it('does not fill a due date onto an existing row, only onto a row it creates', () => {
|
|
107
|
+
const doc = meeting();
|
|
108
|
+
const drafts = rulesExtract(doc);
|
|
109
|
+
const first = reconcile([], mergeDrafts(drafts), { scope: TANDEM, documents: [doc] });
|
|
110
|
+
// The live rows were written before dates were read: none has one.
|
|
111
|
+
const live = first.commitments.map((c) => { const { dueAt, dueBasis, dueConfidence, ...rest } = c; void dueAt; void dueBasis; void dueConfidence; return rest; });
|
|
112
|
+
const second = reconcile(live, mergeDrafts(drafts), { scope: TANDEM, documents: [doc] });
|
|
113
|
+
expect(second.created).toBe(0);
|
|
114
|
+
expect(second.commitments.every((c) => c.dueAt === undefined)).toBe(true);
|
|
115
|
+
expect(second.touched).toEqual([]);
|
|
116
|
+
// ...while a fresh row does carry it.
|
|
117
|
+
expect(first.commitments.find((c) => c.title.includes('equity'))?.dueAt).toBe('2026-08-05T23:59:59Z');
|
|
118
|
+
});
|
|
119
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dates a meeting STATES -> due dates (bd startsim-768w.38.30). Pure and model-free:
|
|
3
|
+
* the date is computed from the meeting's own date; nothing is ever estimated.
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { resolveStatedDate } from '../corpus/stated-date';
|
|
8
|
+
|
|
9
|
+
// Wed 2026-08-05, the meeting the bead was measured on.
|
|
10
|
+
const MEETING = '2026-08-05T15:00:00Z';
|
|
11
|
+
const due = (text: string, anchor = MEETING, timeZone?: string) => resolveStatedDate(text, anchor, timeZone ? { timeZone } : {})?.dueAt ?? null;
|
|
12
|
+
|
|
13
|
+
describe('resolveStatedDate', () => {
|
|
14
|
+
it.each([
|
|
15
|
+
// relative, anchored to the meeting date
|
|
16
|
+
['Complete the equity item today', '2026-08-05T23:59:59Z'],
|
|
17
|
+
['**Complete the equity item** (Jonathan) - today', '2026-08-05T23:59:59Z'],
|
|
18
|
+
['Send the deck this afternoon', '2026-08-05T23:59:59Z'],
|
|
19
|
+
['Send the deck tonight', '2026-08-05T23:59:59Z'],
|
|
20
|
+
['Send the deck by end of day', '2026-08-05T23:59:59Z'],
|
|
21
|
+
['Send the deck tomorrow', '2026-08-06T23:59:59Z'],
|
|
22
|
+
['Send the deck the day after tomorrow', '2026-08-07T23:59:59Z'],
|
|
23
|
+
['Send the deck by Friday', '2026-08-07T23:59:59Z'],
|
|
24
|
+
['Send the deck on Monday', '2026-08-10T23:59:59Z'],
|
|
25
|
+
['Send the deck this Thursday', '2026-08-06T23:59:59Z'],
|
|
26
|
+
['Send the deck in 2 days', '2026-08-07T23:59:59Z'],
|
|
27
|
+
['Send the deck in two weeks', '2026-08-19T23:59:59Z'],
|
|
28
|
+
['Send the deck in a week', '2026-08-12T23:59:59Z'],
|
|
29
|
+
// absolute
|
|
30
|
+
['Pay the invoice by 29th July', '2026-07-29T23:59:59Z'],
|
|
31
|
+
['Pay the invoice by July 29', '2026-07-29T23:59:59Z'],
|
|
32
|
+
['Pay the invoice by 11th August', '2026-08-11T23:59:59Z'],
|
|
33
|
+
['Pay the invoice by 11 of August', '2026-08-11T23:59:59Z'],
|
|
34
|
+
['Pay the invoice by Oct 29', '2026-10-29T23:59:59Z'],
|
|
35
|
+
['Pay the invoice by October 29th, 2027', '2027-10-29T23:59:59Z'],
|
|
36
|
+
['Pay the invoice by 2026-09-01', '2026-09-01T23:59:59Z'],
|
|
37
|
+
// the same date said twice is still one date
|
|
38
|
+
['Send the deck tomorrow, yes tomorrow', '2026-08-06T23:59:59Z'],
|
|
39
|
+
])('%s -> %s', (text, expected) => {
|
|
40
|
+
expect(due(text)).toBe(expected);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it.each([
|
|
44
|
+
// no date at all
|
|
45
|
+
['Follow up with the vendor'],
|
|
46
|
+
['Look into the pricing page'],
|
|
47
|
+
// urgency is not a date
|
|
48
|
+
['Fix the login bug urgently'],
|
|
49
|
+
['Send the deck asap'],
|
|
50
|
+
['Send the deck soon'],
|
|
51
|
+
// a span, not a day: choosing a day would be estimating
|
|
52
|
+
['Send the deck next week'],
|
|
53
|
+
['Send the deck this week'],
|
|
54
|
+
['Send the deck by end of week'],
|
|
55
|
+
['Send the deck next month'],
|
|
56
|
+
['Send the deck in a few days'],
|
|
57
|
+
['Send the deck in a couple of weeks'],
|
|
58
|
+
// "next Friday" has two readings
|
|
59
|
+
['Send the deck next Friday'],
|
|
60
|
+
// said on a Wednesday: today or a week from now
|
|
61
|
+
['Send the deck on Wednesday'],
|
|
62
|
+
// two different dates in one item
|
|
63
|
+
['Send the deck tomorrow and the contract by 29th July'],
|
|
64
|
+
['Send the deck on Monday, review it by Friday'],
|
|
65
|
+
// past tense references and a bare month
|
|
66
|
+
['Revisit what we agreed last Friday'],
|
|
67
|
+
['Revisit what we agreed 3 days ago'],
|
|
68
|
+
['Send the deck in May'],
|
|
69
|
+
// not a calendar day
|
|
70
|
+
['Fix bug 29 in July build'],
|
|
71
|
+
['Pay the invoice by February 30'],
|
|
72
|
+
// a date so far from the meeting that the year is a guess
|
|
73
|
+
['Pay the invoice by March 3'],
|
|
74
|
+
// not a date
|
|
75
|
+
['Review the Monday.com integration'],
|
|
76
|
+
[''],
|
|
77
|
+
])('stays unset: %s', (text) => {
|
|
78
|
+
expect(due(text)).toBeNull();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('is computed in the stated time zone, so a late-evening meeting keeps its own day', () => {
|
|
82
|
+
// 2026-08-06 03:30Z is still Wed 5 Aug 20:30 in Los Angeles.
|
|
83
|
+
const late = '2026-08-06T03:30:00Z';
|
|
84
|
+
expect(due('Send the deck today', late)).toBe('2026-08-06T23:59:59Z');
|
|
85
|
+
expect(resolveStatedDate('Send the deck today', late, { timeZone: 'America/Los_Angeles' })?.date).toBe('2026-08-05');
|
|
86
|
+
expect(due('Send the deck today', late, 'America/Los_Angeles')).toBe('2026-08-06T06:59:59.000Z'.replace('.000Z', 'Z'));
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('says what it read and how sure it is', () => {
|
|
90
|
+
const r = resolveStatedDate('Pay it by 29th July', MEETING);
|
|
91
|
+
expect(r).toMatchObject({ date: '2026-07-29', kind: 'absolute', phrase: expect.stringMatching(/29th July/i) });
|
|
92
|
+
expect(r?.basis).toContain('29th July');
|
|
93
|
+
const t = resolveStatedDate('Send it tomorrow', MEETING);
|
|
94
|
+
expect(t).toMatchObject({ date: '2026-08-06', kind: 'relative' });
|
|
95
|
+
expect(t?.basis).toContain('2026-08-05');
|
|
96
|
+
expect(t!.confidence).toBeGreaterThan(0.8);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('needs a usable meeting date for relative phrases, but not for absolute ones', () => {
|
|
100
|
+
expect(due('Send it tomorrow', '')).toBeNull();
|
|
101
|
+
expect(due('Send it tomorrow', 'not a date')).toBeNull();
|
|
102
|
+
expect(due('Send it by 2026-09-01', '')).toBe('2026-09-01T23:59:59Z');
|
|
103
|
+
expect(due('Send it by 29th July 2026', 'not a date')).toBe('2026-07-29T23:59:59Z');
|
|
104
|
+
// no year and no meeting date: the year would be a guess
|
|
105
|
+
expect(due('Send it by 29th July', '')).toBeNull();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marking a to-do done stamps WHEN (`resolved_at`), so the Tracker timeline's
|
|
3
|
+
* "done per day" is a real date and not a guess. Only the transition to done
|
|
4
|
+
* stamps, and a value the caller supplied is never overwritten.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { createPlanningApi } from '../corpus/client';
|
|
9
|
+
import type { Commitment } from '../corpus/types';
|
|
10
|
+
|
|
11
|
+
const NOW = Date.parse('2026-11-07T15:00:00Z');
|
|
12
|
+
const scope = { orgId: 'o' } as never;
|
|
13
|
+
|
|
14
|
+
function api() {
|
|
15
|
+
const post = vi.fn().mockResolvedValue({ id: 'c1', external_id: 'item:c1', data: { title: 'x', status: 'done' } });
|
|
16
|
+
return { post, api: createPlanningApi({ http: { get: vi.fn(), post } as never, scope, now: () => NOW }) };
|
|
17
|
+
}
|
|
18
|
+
const sent = (post: ReturnType<typeof vi.fn>) => post.mock.calls[0][1].data as Record<string, unknown>;
|
|
19
|
+
const row = (status: Commitment['status']) => ({ id: 'c1', externalId: 'item:c1', status }) as Commitment;
|
|
20
|
+
|
|
21
|
+
describe('updateCommitment stamps resolved_at', () => {
|
|
22
|
+
it('when an open item becomes done', async () => {
|
|
23
|
+
const { post, api: a } = api();
|
|
24
|
+
await a.updateCommitment!(row('open'), { status: 'done' });
|
|
25
|
+
expect(sent(post).resolved_at).toBe('2026-11-07T15:00:00.000Z');
|
|
26
|
+
});
|
|
27
|
+
it('never overwrites a value the caller supplied', async () => {
|
|
28
|
+
const { post, api: a } = api();
|
|
29
|
+
await a.updateCommitment!(row('open'), { status: 'done', resolvedAt: '2026-11-01T00:00:00Z' });
|
|
30
|
+
expect(sent(post).resolved_at).toBe('2026-11-01T00:00:00Z');
|
|
31
|
+
});
|
|
32
|
+
it('does not re-stamp an item that was already done', async () => {
|
|
33
|
+
const { post, api: a } = api();
|
|
34
|
+
await a.updateCommitment!(row('done'), { status: 'done', title: 'renamed' });
|
|
35
|
+
expect(sent(post)).not.toHaveProperty('resolved_at');
|
|
36
|
+
});
|
|
37
|
+
it('does not stamp other status changes', async () => {
|
|
38
|
+
const { post, api: a } = api();
|
|
39
|
+
await a.updateCommitment!(row('open'), { status: 'blocked' });
|
|
40
|
+
expect(sent(post)).not.toHaveProperty('resolved_at');
|
|
41
|
+
});
|
|
42
|
+
});
|