@startsimpli/integrations 0.2.196 → 0.2.200

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.196",
3
+ "version": "0.2.200",
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/ui": "^0.4.190",
54
53
  "@startsimpli/auth": "^0.4.53",
55
- "@startsimpli/utils": "^0.4.20"
54
+ "@startsimpli/utils": "^0.4.20",
55
+ "@startsimpli/ui": "^0.4.192"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -99,7 +99,7 @@
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.190",
102
+ "@startsimpli/ui": "0.4.192",
103
103
  "@startsimpli/ui-native": "0.1.15",
104
104
  "@startsimpli/auth": "0.4.53",
105
105
  "@startsimpli/utils": "0.4.20"
@@ -53,6 +53,20 @@ describe('itemIntent', () => {
53
53
  const i = itemIntent('what did I commit to this week?', NOW)!;
54
54
  expect([i.focus, i.from, i.to, i.mine]).toEqual(['committed', '2026-11-09', '2026-11-15', true]);
55
55
  });
56
+ it('reads a month name as that whole month', () => {
57
+ const i = itemIntent('What is due in December?', NOW)!;
58
+ expect([i.focus, i.from, i.to]).toEqual(['due', '2026-12-01', '2026-12-31']);
59
+ expect(itemIntent('what is due in February 2027', NOW)!.to).toBe('2027-02-28');
60
+ });
61
+ it('reads a month already passed this year as next year, and the current month whole', () => {
62
+ expect(itemIntent('what is due in March', NOW)!.from).toBe('2027-03-01');
63
+ const nov = itemIntent('what is due in November', NOW)!;
64
+ expect([nov.from, nov.to]).toEqual(['2026-11-01', '2026-11-30']);
65
+ });
66
+ it('reads next month', () => {
67
+ const i = itemIntent('what is due next month', NOW)!;
68
+ expect([i.from, i.to]).toEqual(['2026-12-01', '2026-12-31']);
69
+ });
56
70
  it('uses the reader zone for today', () => {
57
71
  expect(itemIntent('what is overdue', Date.parse('2026-11-12T02:00:00Z'), 'America/New_York')!.today).toBe('2026-11-11');
58
72
  });
@@ -0,0 +1,52 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ import { CompactItemRow } from '../components/pages/home/CompactItemRow';
5
+ import { renderExtractPrompt, extractSystemPrompt } from '../corpus/extract';
6
+ import { commitmentToEntity } from '../corpus/entities';
7
+ import type { Commitment } from '../corpus/types';
8
+
9
+ const base = {
10
+ id: 'c1', title: 'Send pricing sheet to Pat', detail: '', subtype: 'action', status: 'open', ownerName: 'Owner',
11
+ firstSeenAt: '2026-11-15T10:00:00Z', lastSeenAt: '2026-11-15T10:00:00Z', source: 'extracted',
12
+ } as unknown as Commitment;
13
+ const mention = (documentKind?: string) => ({
14
+ documentId: 'd1', originKey: 'model:send', occurredAt: '2026-11-15T10:00:00Z', quote: 'sending the pricing sheet tomorrow morning',
15
+ extractor: 'model' as const, ...(documentKind ? { documentKind } : {}),
16
+ ...(documentKind === 'email' ? { documentUrl: 'https://mail.example/#all/t1', documentTitle: 'Re: Atlas' } : {}),
17
+ });
18
+
19
+ describe('email evidence', () => {
20
+ it('says "an email" on the item when the mention came from mail, "a meeting" otherwise', () => {
21
+ const { rerender } = render(<ul><CompactItemRow item={{ ...base, mentions: [mention('email')] }} days={null} due={null} /></ul>);
22
+ expect(screen.getByTestId('item-evidence').textContent).toMatch(/^From an email/);
23
+ rerender(<ul><CompactItemRow item={{ ...base, mentions: [mention('meeting')] }} days={null} due={null} /></ul>);
24
+ expect(screen.getByTestId('item-evidence').textContent).toMatch(/^From a meeting/);
25
+ });
26
+
27
+ it('keeps the document kind through the tenant round trip', () => {
28
+ const entity = commitmentToEntity({ ...base, mentions: [mention('email')] });
29
+ const written = (entity.data.mentions as Array<Record<string, unknown>>)[0];
30
+ expect(written.document_kind).toBe('email');
31
+ expect(written.document_url).toBe('https://mail.example/#all/t1');
32
+ expect(written.document_title).toBe('Re: Atlas');
33
+ });
34
+
35
+ it('prompt tells the model a document is an email and how to read waiting-on', () => {
36
+ const prompt = renderExtractPrompt({ documents: [{ id: 'd1', title: 'Re: Atlas', source: 'Google', occurredAt: null, participants: ['Pat'], kind: 'email', text: 'From: Pat\nDirection: received\n\nhi', alreadyFound: [] }] });
37
+ expect(prompt).toContain('kind: email');
38
+ expect(extractSystemPrompt()).toMatch(/waiting on/i);
39
+ expect(extractSystemPrompt()).toMatch(/ENG-42/);
40
+ });
41
+ });
42
+
43
+ describe('email push switch', () => {
44
+ it('is stored only when off, and a save of other fields keeps it', async () => {
45
+ const { readTaskSync, withTaskSync } = await import('../task-tracker/sync-config');
46
+ const off = { config: { task_sync: { push_from_email: false, default_container_id: 't1' } } };
47
+ expect(readTaskSync(off).push_from_email).toBe(false);
48
+ expect(withTaskSync(off, { default_project_id: 'p1' }).push_from_email).toBe(false);
49
+ expect('push_from_email' in withTaskSync(off, { push_from_email: undefined })).toBe(false);
50
+ expect('push_from_email' in withTaskSync({ config: {} }, { default_container_id: 't1' })).toBe(false);
51
+ });
52
+ });
@@ -37,6 +37,10 @@ describe('resolveSpokenTime', () => {
37
37
  ['by the end of the month', '2026-11-30'],
38
38
  ['on November 20', '2026-11-20'],
39
39
  ['by the 20th', '2026-11-20'],
40
+ ['due on the fifteenth', '2026-11-15'],
41
+ ['by the twenty-first', '2026-11-21'],
42
+ ['on the third', '2026-12-03'],
43
+ ['the thirtieth', '2026-11-30'],
40
44
  ['ASAP', '2026-11-06'],
41
45
  ['right away', '2026-11-06'],
42
46
  ['sometime in the next few hours', '2026-11-06'],
@@ -0,0 +1,26 @@
1
+ /**
2
+ * A date stated in a LATER sentence about the same thing belongs to that item (bd startsim-tmrvi.23, found in the
3
+ * tmrvi.8 measurement): "Today I have to pay the AWS bill. The AWS bill is due on the fifteenth." was acted on as today.
4
+ */
5
+ import { describe, expect, it } from 'vitest';
6
+
7
+ import { resolveItemFields } from '../corpus/voice-due';
8
+ import type { VoiceItem, VoiceSection } from '../corpus/voice-sections';
9
+
10
+ const TRANSCRIPT = 'Today I have to call the vet and pay the AWS bill. The AWS bill is due on the fifteenth. Also fix the login bug.';
11
+ const ctx = { now: Date.parse('2026-11-09T17:00:00Z'), timeZone: 'America/Boise', transcript: TRANSCRIPT, noteWhen: 'today' };
12
+ const section: VoiceSection = { label: 'Work', kind: 'other', focusId: null, items: [], when: 'today' } as never;
13
+ const item = (title: string, when?: string): VoiceItem => ({ title, ...(when ? { when } : {}) });
14
+
15
+ describe('a date stated in a later sentence about the item', () => {
16
+ it('is the item\'s due date, stated, not the day of the note', () => {
17
+ const f = resolveItemFields(item('Pay the AWS bill'), section, ctx);
18
+ expect(f.due.value).toBe('2026-11-15');
19
+ expect(f.due.source).toBe('stated');
20
+ });
21
+
22
+ it('does not reach items the sentence is not about', () => {
23
+ const f = resolveItemFields(item('Fix the login bug'), section, ctx);
24
+ expect(f.due.value).not.toBe('2026-11-15');
25
+ });
26
+ });
@@ -226,8 +226,8 @@ function build(request: Requester): MemberConnectionsApi {
226
226
  * A card that is not mine answers 404 rather than 403 — on this surface
227
227
  * existence is itself the payload.
228
228
  */
229
- disconnect(id: string): Promise<void> {
230
- return request<void>(`${BASE}/${id}/`, { method: 'DELETE' });
229
+ disconnect(id: string, options?: { removeData?: boolean }): Promise<void> {
230
+ return request<void>(`${BASE}/${id}/${options?.removeData ? '?remove_data=true' : ''}`, { method: 'DELETE' });
231
231
  },
232
232
 
233
233
  /** Recent activity on my card: a merge over the run tables it owns. */
@@ -314,7 +314,7 @@ export function TaskDetailPage({
314
314
  {item.mentions.map((m) => (
315
315
  <li key={`${m.documentId}:${m.originKey}`}>
316
316
  <button type="button" className="text-sm text-blue-700 underline" onClick={() => onOpenDocument?.(m.documentId)}>
317
- {m.occurredAt ? new Date(m.occurredAt).toLocaleDateString() : 'Undated meeting'}
317
+ {m.occurredAt ? new Date(m.occurredAt).toLocaleDateString() : m.documentKind === 'email' ? 'Undated email' : 'Undated meeting'}{m.documentKind === 'email' ? ' (email)' : ''}
318
318
  </button>
319
319
  {m.quote ? <span className={`ml-2 ${cn.muted}`}>“{m.quote}”</span> : null}
320
320
  </li>
@@ -40,6 +40,7 @@ export function ConnectionCard({
40
40
  const [replacing, setReplacing] = React.useState(false);
41
41
  const [settingsOpen, setSettingsOpen] = React.useState(false);
42
42
  const [confirmingDisconnect, setConfirmingDisconnect] = React.useState(false);
43
+ const [removeData, setRemoveData] = React.useState(false);
43
44
  const [activityOpen, setActivityOpen] = React.useState(false);
44
45
  /** `null` is NOT LOADED YET, which reads differently from a connection that
45
46
  has never run — the distinction the empty state below turns on. */
@@ -339,6 +340,15 @@ export function ConnectionCard({
339
340
  here, marked disabled, and you can connect it again later with a new
340
341
  key.
341
342
  </p>
343
+ {entry?.kind === 'mailbox' ? (
344
+ <label className="flex items-start gap-2 text-sm text-gray-800">
345
+ <input type="checkbox" checked={removeData} onChange={(e) => setRemoveData(e.target.checked)} />
346
+ <span>
347
+ Also delete the emails, events and people this account brought into Tandem. To-dos you made from them
348
+ stay, but their link back to the email stops working.
349
+ </span>
350
+ </label>
351
+ ) : null}
342
352
  {trackerApi ? (
343
353
  <p className={cn.muted}>
344
354
  {`Your to-dos stay in Tandem. Nothing is deleted in ${connection.connector_name}; they simply stop syncing.`}
@@ -350,8 +360,9 @@ export function ConnectionCard({
350
360
  className={cn.button}
351
361
  disabled={Boolean(busy)}
352
362
  onClick={() => void guard('disconnect', async () => {
353
- await api.disconnect(connection.id);
363
+ await (removeData ? api.disconnect(connection.id, { removeData: true }) : api.disconnect(connection.id));
354
364
  setConfirmingDisconnect(false);
365
+ setRemoveData(false);
355
366
  setNotice('Disconnected.');
356
367
  onChanged();
357
368
  })}
@@ -53,7 +53,7 @@ export interface BoundApi {
53
53
  }): Promise<Connection>;
54
54
  checkConnection(id: string): Promise<{ ok: boolean; account_label: string; detail: string; reason?: string; next_step?: string }>;
55
55
  rotateCredential(id: string, credentials: Record<string, unknown>): Promise<Connection>;
56
- disconnect(id: string): Promise<void>;
56
+ disconnect(id: string, options?: { removeData?: boolean }): Promise<void>;
57
57
  updateConnection?(id: string, input: {
58
58
  name?: string; capabilities_enabled?: string[]; config?: Record<string, unknown>;
59
59
  }): Promise<Connection>;
@@ -50,7 +50,7 @@ function MeetingEvidence({ item }: { item: Commitment }) {
50
50
  const more = item.mentions.length > 1 ? ` · +${item.mentions.length - 1} more` : '';
51
51
  return (
52
52
  <span className="block truncate text-xs text-gray-500" data-testid="item-evidence">
53
- From a meeting{when ? ` ${when}` : ''}: “{stripMarkdown(latest.quote)}”{more}
53
+ From {latest.documentKind === 'email' ? 'an email' : 'a meeting'}{when ? ` ${when}` : ''}: “{stripMarkdown(latest.quote)}”{more}
54
54
  </span>
55
55
  );
56
56
  }
@@ -70,6 +70,19 @@ export function TaskTrackerSettings({ api, connection, classNames: cn, onSaved }
70
70
  {picker('Your private space for personal to-dos', 'personal_container_id', 'team', 'Not set (personal to-dos stay in Tandem)')}
71
71
  {picker(`Also bring in ${tracker} issues assigned to`, 'assignee_id', 'user', 'Nobody in particular')}
72
72
 
73
+ <label className="flex items-start gap-2 text-sm text-gray-900">
74
+ <input
75
+ type="checkbox"
76
+ checked={s.value.push_from_email !== false}
77
+ disabled={s.loading}
78
+ onChange={(e) => controller.set({ push_from_email: e.target.checked ? undefined : false })}
79
+ />
80
+ <span>
81
+ {`Send to-dos that came from my email to ${tracker}`}
82
+ <span className="block text-xs text-gray-500">Each one gets a “Pushed from email” link to the message. Turn off to keep them in Tandem only; turning it back on sends them.</span>
83
+ </span>
84
+ </label>
85
+
73
86
  <div>
74
87
  <p className="text-sm font-medium text-gray-900">{`${tracker} states and Tandem status`}</p>
75
88
  {s.rows.length === 0 && !s.loading ? <p className={cn.muted}>No states found.</p> : null}
@@ -447,7 +447,8 @@ export interface MemberConnectionsApi {
447
447
  /** What a task-tracker account reaches (teams, projects, states, users): `kind` picks the list. */
448
448
  connectionChoices?(id: string, params?: { kind?: string; cursor?: string }): Promise<ConnectionChoicePage>;
449
449
  rotateCredential(id: string, credentials: Record<string, unknown>): Promise<Connection>;
450
- disconnect(id: string): Promise<void>;
450
+ /** `removeData` also deletes what the account brought in (mailbox connectors). */
451
+ disconnect(id: string, options?: { removeData?: boolean }): Promise<void>;
451
452
  connectionRuns(id: string): Promise<{ results: ConnectionRun[] }>;
452
453
  /**
453
454
  * The OAuth half of the surface (bd startsim-768w.22.25.14/.21). Optional so
@@ -183,7 +183,7 @@ export function WorkItemRow({
183
183
  ) : (
184
184
  <details className="mt-2">
185
185
  <summary className="cursor-pointer text-sm text-gray-600">
186
- From {item.mentions.length} meeting{item.mentions.length === 1 ? '' : 's'}
186
+ From {item.mentions.length} {item.mentions.every((m) => m.documentKind === 'email') ? 'email' : item.mentions.some((m) => m.documentKind === 'email') ? 'source' : 'meeting'}{item.mentions.length === 1 ? '' : 's'}
187
187
  </summary>
188
188
  <div className="mt-2 space-y-2">
189
189
  {item.mentions.map((mention) => (
@@ -196,7 +196,7 @@ export function WorkItemRow({
196
196
  >
197
197
  {mention.occurredAt
198
198
  ? new Date(mention.occurredAt).toLocaleDateString()
199
- : 'Undated meeting'}
199
+ : mention.documentKind === 'email' ? 'Undated email' : 'Undated meeting'}
200
200
  </button>
201
201
  {/* Where the row came from. A model-derived item and one the
202
202
  summariser itself wrote down are different levels of
@@ -32,6 +32,13 @@ export const addDays = (day: string, n: number): string => {
32
32
  d.setUTCDate(d.getUTCDate() + n);
33
33
  return d.toISOString().slice(0, 10);
34
34
  };
35
+ const MONTHS = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
36
+ const monthBounds = (year: number, month0: number): { from: string; to: string } => {
37
+ const mm = String(month0 + 1).padStart(2, '0');
38
+ const first = `${year}-${mm}-01`;
39
+ const lastDay = new Date(Date.UTC(year, month0 + 1, 0)).getUTCDate();
40
+ return { from: first, to: `${year}-${mm}-${String(lastDay).padStart(2, '0')}` };
41
+ };
35
42
  const weekdayOf = (day: string): number => new Date(`${day}T00:00:00Z`).getUTCDay();
36
43
 
37
44
  /** Monday-first week containing `day`. */
@@ -41,6 +48,14 @@ function weekOf(day: string): { from: string; to: string } {
41
48
  return { from, to: addDays(from, 6) };
42
49
  }
43
50
 
51
+ /** A month name with an optional year ("in december", "february 2027"); "may" only after in/during/of. */
52
+ function monthNamed(q: string): { index: number; year?: number } | null {
53
+ const m = q.match(new RegExp(`\\b(?:(?:in|during|of|for|by)\\s+)?(${MONTHS.join('|')})\\b(?:\\s+(20\\d{2}))?`));
54
+ if (!m) return null;
55
+ if (m[1] === 'may' && !/\b(?:in|during|of|for|by)\s+may\b/.test(q)) return null;
56
+ return { index: MONTHS.indexOf(m[1]), ...(m[2] ? { year: Number(m[2]) } : {}) };
57
+ }
58
+
44
59
  /** The calendar window a question names ("yesterday", "last week", "this month"), in the reader's zone, or null. */
45
60
  export function questionWindow(question: string, now: number, timeZone = 'UTC'): { from: string; to: string; label: string } | null {
46
61
  const q = question.toLowerCase();
@@ -53,6 +68,15 @@ export function questionWindow(question: string, now: number, timeZone = 'UTC'):
53
68
  else if (/\bthis week\b|\bthe week\b/.test(q)) { const w = weekOf(today); set(w.from, w.to, 'this week'); }
54
69
  else if (/\blast month\b/.test(q)) { const first = `${today.slice(0, 8)}01`; const end = addDays(first, -1); set(`${end.slice(0, 8)}01`, end, 'last month'); }
55
70
  else if (/\bthis month\b/.test(q)) set(`${today.slice(0, 8)}01`, today, 'this month');
71
+ else if (/\bnext month\b/.test(q)) { const m = monthBounds(Number(today.slice(0, 4)), Number(today.slice(5, 7))); set(m.from, m.to, 'next month'); }
72
+ else if (monthNamed(q)) {
73
+ // "in December", "in February 2027". A bare month already past this year means the coming one.
74
+ const { index, year } = monthNamed(q)!;
75
+ const thisYear = Number(today.slice(0, 4));
76
+ const y = year ?? (index >= Number(today.slice(5, 7)) - 1 ? thisYear : thisYear + 1);
77
+ const m = monthBounds(y, index);
78
+ set(m.from, m.to, `${MONTHS[index][0].toUpperCase()}${MONTHS[index].slice(1)} ${y}`);
79
+ }
56
80
  else if (/\btomorrow\b/.test(q)) set(addDays(today, 1), addDays(today, 1), 'tomorrow');
57
81
  else if (/\btoday\b/.test(q)) set(today, today, 'today');
58
82
  else if (/\byesterday\b/.test(q)) set(addDays(today, -1), addDays(today, -1), 'yesterday');
@@ -395,6 +395,8 @@ function toMention(draft: CommitmentDraft, document: SourceDocument): Commitment
395
395
  return {
396
396
  documentId: draft.documentId,
397
397
  originKey: draft.originKey,
398
+ ...(document.subtype ? { documentKind: document.subtype } : {}),
399
+ ...(document.subtype === 'email' && document.url ? { documentUrl: document.url, documentTitle: document.title } : {}),
398
400
  occurredAt: iso(document.occurredAt),
399
401
  quote: draft.quote ?? '',
400
402
  extractor: draft.extractor,
@@ -784,6 +784,8 @@ function toMention(value: unknown): CommitmentMention | null {
784
784
  return {
785
785
  documentId,
786
786
  originKey: asText(pick(data, 'origin_key', 'originKey')),
787
+ ...(asText(pick(data, 'document_kind', 'documentKind')) ? { documentKind: asText(pick(data, 'document_kind', 'documentKind')) } : {}),
788
+ ...(asText(pick(data, 'document_url', 'documentUrl')) ? { documentUrl: asText(pick(data, 'document_url', 'documentUrl')), documentTitle: asText(pick(data, 'document_title', 'documentTitle')) } : {}),
787
789
  occurredAt: asIso(pick(data, 'occurred_at', 'occurredAt')),
788
790
  quote: asText(pick(data, 'quote')),
789
791
  extractor: extractor === 'model' ? 'model' : 'rules',
@@ -832,6 +834,8 @@ export function commitmentToEntity(commitment: Commitment): {
832
834
  mentions: commitment.mentions.slice(-MAX_MENTIONS).map((mention) => ({
833
835
  document_id: mention.documentId,
834
836
  origin_key: mention.originKey,
837
+ ...(mention.documentKind ? { document_kind: mention.documentKind } : {}),
838
+ ...(mention.documentUrl ? { document_url: mention.documentUrl, document_title: (mention.documentTitle ?? '').slice(0, 200) } : {}),
835
839
  occurred_at: mention.occurredAt,
836
840
  quote: mention.quote.slice(0, 400),
837
841
  extractor: mention.extractor,
@@ -276,6 +276,9 @@ export function extractSystemPrompt(): string {
276
276
  'Set "subject" to what the item is ABOUT — a matter or case number, a property, a client, a system, a person. Copy an identifier verbatim when the text has one.',
277
277
  'Set "owner" only to a name the document actually names. Leave it out otherwise.',
278
278
  'Never estimate or invent a due date, and do not compute one: the system reads the date itself from your "quote". When the item has a stated date or day ("by 29th July", "tomorrow", "on Monday"), make sure those exact words are inside the quote; when the document states none, say nothing about a date.',
279
+ 'Some documents are EMAILS (kind: email). The text starts with From, To and Direction lines. Direction "sent" means the mailbox owner wrote it, so commitments in it ("I will send...", "I will update...") belong to the owner. Direction "received" means somebody wrote to the owner: what the sender promises is theirs, what they ask for is the owner\'s.',
280
+ 'In an email, "waiting on" matters as much as "to do": when the writer says they are blocked on, or waiting for, another person ("waiting on your reply", "I need the sheet before Friday"), report a "need" with status "blocked", owner set to the person being waited on, and the writer named in the detail. Quoted older messages (lines starting with >) are history, not new statements.',
281
+ 'An issue key such as ENG-42 in a document is a strong "subject": copy it verbatim, including when the email says the work is finished or moved.',
279
282
  'Also report RESOLUTIONS: statements that something previously outstanding is now done or abandoned. Give the subject, what happened, and a verbatim quote.',
280
283
  'Respond with JSON only: {"items":[{"documentId":string,"subtype":"action"|"decision"|"need"|"risk"|"question","title":string,"detail":string,"status":"open"|"done"|"blocked","owner":string,"subject":string,"quote":string}],"resolutions":[{"documentId":string,"subject":string,"statement":string,"quote":string,"outcome":"done"|"dropped"}]}',
281
284
  '"title" must be one short imperative line.',
@@ -286,7 +289,7 @@ export function extractSystemPrompt(): string {
286
289
  export function renderExtractPrompt(input: {
287
290
  documents: Array<{
288
291
  id: string; title: string; source: string; occurredAt: string | null;
289
- participants: string[]; text: string; alreadyFound: string[];
292
+ participants: string[]; kind?: string; text: string; alreadyFound: string[];
290
293
  }>;
291
294
  }): string {
292
295
  const blocks = input.documents.map((document) =>
@@ -294,6 +297,7 @@ export function renderExtractPrompt(input: {
294
297
  `<document id="${document.id}">`,
295
298
  `title: ${document.title}`,
296
299
  `source: ${document.source}`,
300
+ document.kind ? `kind: ${document.kind}` : '',
297
301
  `occurred_at: ${document.occurredAt ?? 'unknown'}`,
298
302
  document.participants.length ? `participants: ${document.participants.join(', ')}` : '',
299
303
  document.alreadyFound.length
@@ -505,6 +509,7 @@ export async function extractCommitments(
505
509
  source: document.sourceLabel || document.source,
506
510
  occurredAt: document.occurredAt,
507
511
  participants: document.participants.map((party) => party.name),
512
+ ...(document.subtype ? { kind: document.subtype } : {}),
508
513
  text: promptText.get(document.id) ?? '',
509
514
  alreadyFound: foundByDocument.get(document.id) ?? [],
510
515
  })),
@@ -191,8 +191,8 @@ function findDay(text: string, today: string, wd: number, ctx: { now: number; ti
191
191
  return hit(`${year}-${pad(month)}-${pad(day)}`, m[0], 0.95, 'exact', `said "${m[0]}"`);
192
192
  }
193
193
  }
194
- if ((m = /\bthe (\d{1,2})(?:st|nd|rd|th)\b/i.exec(text))) {
195
- const day = Number(m[1]);
194
+ if ((m = new RegExp(`\\bthe (\\d{1,2}(?:st|nd|rd|th)|${ORDINAL_WORD})\\b`, 'i').exec(text))) {
195
+ const day = ordinalDay(m[1]);
196
196
  if (day >= 1 && day <= 31) {
197
197
  let [y, mo] = [ty, tm];
198
198
  if (`${y}-${pad(mo)}-${pad(day)}` < today) { mo += 1; if (mo > 12) { mo = 1; y += 1; } }
@@ -204,6 +204,22 @@ function findDay(text: string, today: string, wd: number, ctx: { now: number; ti
204
204
  return null;
205
205
  }
206
206
 
207
+ const ORD_UNITS: Record<string, number> = { first: 1, second: 2, third: 3, fourth: 4, fifth: 5, sixth: 6, seventh: 7, eighth: 8, ninth: 9 };
208
+ const ORD_TEENS: Record<string, number> = {
209
+ tenth: 10, eleventh: 11, twelfth: 12, thirteenth: 13, fourteenth: 14, fifteenth: 15, sixteenth: 16, seventeenth: 17,
210
+ eighteenth: 18, nineteenth: 19, twentieth: 20, thirtieth: 30,
211
+ };
212
+ /** "fifteenth", "twenty-first" (or "twenty first"): the spoken form a transcript writes for a day of the month. */
213
+ const ORDINAL_WORD = `(?:(?:twenty|thirty)[- ](?:${Object.keys(ORD_UNITS).join('|')})|${Object.keys(ORD_TEENS).join('|')}|${Object.keys(ORD_UNITS).join('|')})`;
214
+
215
+ function ordinalDay(token: string): number {
216
+ const t = token.toLowerCase();
217
+ if (/^\d/.test(t)) return Number(t.replace(/\D/g, ''));
218
+ const [head, tail] = t.split(/[- ]/);
219
+ if (tail !== undefined) return (head === 'twenty' ? 20 : 30) + ORD_UNITS[tail];
220
+ return ORD_TEENS[t] ?? ORD_UNITS[t];
221
+ }
222
+
207
223
  interface TimeHit { time: string; phrase: string; score: number; confidence: SpokenConfidence; alt?: string }
208
224
 
209
225
  function findClock(text: string): TimeHit | null {
@@ -639,6 +639,11 @@ export interface CommitmentMention {
639
639
  documentId: string;
640
640
  /** Stable within a document: the vendor's own bullet, or the model's item. */
641
641
  originKey: string;
642
+ /** What kind of document the mention came from (`email`, `meeting`, ...): the evidence line says "email", never "meeting", for mail. */
643
+ documentKind?: string;
644
+ /** Link back to the original (an email in its mailbox) and its title: what a pushed tracker item points at. */
645
+ documentUrl?: string;
646
+ documentTitle?: string;
642
647
  /** When the meeting happened — NOT when the row was written. */
643
648
  occurredAt: string | null;
644
649
  /** Verbatim span from that document, so the claim can be checked. */
@@ -1088,6 +1093,8 @@ export interface ExtractionRequest {
1088
1093
  source: string;
1089
1094
  occurredAt: string | null;
1090
1095
  participants: string[];
1096
+ /** `email`, `meeting`, ...: lets the prompt read a message as a message. */
1097
+ kind?: string;
1091
1098
  text: string;
1092
1099
  /**
1093
1100
  * What the deterministic pre-pass already found in this document. Sent so
@@ -138,6 +138,29 @@ function saidAboutAnother(said: string, title: string, transcript: string): bool
138
138
  return words.length >= 2 && !words.some((w) => own.has(w));
139
139
  }
140
140
 
141
+ /**
142
+ * A date stated in ANOTHER sentence about the same thing: "...pay the AWS bill. The AWS bill is due on the fifteenth."
143
+ * `evidenceSentence` needs two long content words, which a short title ("Pay the AWS bill") does not have, so this
144
+ * looks at every sentence that shares ALL of the title's distinctive words (or two of them) and states a date of its
145
+ * own. An explicit date beats a day-plan ("today"), which is why it is picked over the sentence the item came from.
146
+ */
147
+ function datedSentenceTime(title: string, transcript: string, ctx: DueContext): SpokenTime | null {
148
+ const words = [...new Set(title.split(/\s+/).map(stem).filter((w) => w.length >= 3 && !STOP.has(w) && !FILLER.has(w)))];
149
+ if (words.length === 0) return null;
150
+ const need = Math.min(2, words.length);
151
+ const today = resolveSpokenTime('today', ctx)?.date;
152
+ let fallback: SpokenTime | null = null;
153
+ for (const text of transcript.split(/(?<=[.!?])\s+/)) {
154
+ const have = new Set(text.split(/\s+/).map(stem));
155
+ if (words.filter((w) => have.has(w)).length < need) continue;
156
+ const res = resolveSpokenTime(text, ctx);
157
+ if (!res || res.kind !== 'dated') continue;
158
+ if (res.date !== today) return res;
159
+ fallback ??= res;
160
+ }
161
+ return fallback;
162
+ }
163
+
141
164
  function dueGuess(item: VoiceItem, section: VoiceSection, ctx: DueContext): { due: FieldGuess<string>; priority?: number } {
142
165
  const resolve = (text: string | undefined) => (text ? resolveSpokenTime(text, ctx) : null);
143
166
  const sentence = evidenceSentence(item.title, ctx.transcript);
@@ -153,6 +176,7 @@ function dueGuess(item: VoiceItem, section: VoiceSection, ctx: DueContext): { du
153
176
  const levels: Array<{ res: SpokenTime | null; source: 'stated' | 'assumed'; cap: number; where: string; said?: string }> = [
154
177
  { res: itemLevel, source: 'stated', cap: 1, where: 'the speaker' },
155
178
  { res: resolve(item.title), source: 'stated', cap: 1, where: 'the item' },
179
+ { res: datedSentenceTime(item.title, ctx.transcript, ctx), source: 'stated', cap: 0.9, where: 'a sentence about it' },
156
180
  { res: sentence ? resolve(sentence) : null, source: 'stated', cap: 0.9, where: 'the sentence it came from' },
157
181
  { res: resolve(section.when), source: 'assumed', cap: 0.75, where: 'the section', said: section.when },
158
182
  { res: resolve(ctx.noteWhen), source: 'assumed', cap: 0.75, where: 'the note', said: ctx.noteWhen },
@@ -22,6 +22,8 @@ export interface TaskSyncConfig {
22
22
  /** tracker workflow state id -> Tandem status. */
23
23
  state_overrides?: Record<string, TrackerStatus>;
24
24
  assignee_id?: string;
25
+ /** `false` pauses sending to-dos that exist only because of an email; absent means on. */
26
+ push_from_email?: boolean;
25
27
  }
26
28
 
27
29
  export const TASK_SYNC_KEY = 'task_sync';
@@ -50,6 +52,7 @@ export function readTaskSync(connection: Pick<Connection, 'config'>): TaskSyncCo
50
52
  const src = raw as Record<string, unknown>;
51
53
  const out: Record<string, unknown> = {};
52
54
  for (const k of STRINGS) if (typeof src[k] === 'string' && src[k]) out[k] = src[k];
55
+ if (src.push_from_email === false) out.push_from_email = false;
53
56
  for (const k of MAPS) {
54
57
  const m = src[k];
55
58
  if (m && typeof m === 'object' && Object.keys(m).length) out[k] = { ...(m as object) };
@@ -61,6 +64,7 @@ export function readTaskSync(connection: Pick<Connection, 'config'>): TaskSyncCo
61
64
  export function withTaskSync(connection: Pick<Connection, 'config'>, edit: Partial<TaskSyncConfig>): TaskSyncConfig {
62
65
  const merged: Record<string, unknown> = { ...readTaskSync(connection), ...edit };
63
66
  for (const k of STRINGS) if (!merged[k]) delete merged[k];
67
+ if (merged.push_from_email !== false) delete merged.push_from_email;
64
68
  for (const k of MAPS) {
65
69
  const m = merged[k] as Record<string, unknown> | undefined;
66
70
  if (!m || !Object.keys(m).length) delete merged[k];