@startsimpli/integrations 0.2.124 → 0.2.126

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.
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Fuzzy match of a spoken description ("the bench one", "the dentist thing")
3
+ * against item titles, focus names and ticket codes. Deterministic, no model.
4
+ *
5
+ * A word matches when equal or when both share a 4+ letter stem (print/printer,
6
+ * flight/flights). The score is the share of the SPOKEN words found, so a short
7
+ * description that fits one item scores 1, and two items that fit equally tie,
8
+ * which is what makes it ambiguous rather than a guess.
9
+ */
10
+ import type { IntentItem } from './types';
11
+
12
+ const STOP = new Set(['the', 'a', 'an', 'to', 'of', 'for', 'and', 'my', 'with', 'about', 'up', 'on', 'in', 'at', 'it',
13
+ 'that', 'this', 'one', 'thing', 'things', 'item', 'task', 'todo', 'other', 'please', 'out', 'i', 'is', 'are', 'was',
14
+ 'be', 'as', 'its', 'mine', 'those', 'these', 'back', 'off', 'into', 'from', 'but', 'then', 'now', 'just', 'also',
15
+ 'you', 'we', 'me', 'do']);
16
+
17
+ export const words = (text: string): string[] =>
18
+ text.toLowerCase().replace(/['’]/g, '').split(/[^a-z0-9]+/).filter(Boolean);
19
+
20
+ /** The content words of a description: what is left after the filler. */
21
+ export const contentWords = (text: string): string[] => words(text).filter((w) => !STOP.has(w));
22
+
23
+ const same = (a: string, b: string) => a === b || (a.length >= 4 && b.length >= 4 && (a.startsWith(b.slice(0, 4)) && b.startsWith(a.slice(0, 4))));
24
+
25
+ export interface Scored { item: IntentItem; score: number }
26
+
27
+ export function scoreItems(query: string, items: IntentItem[]): Scored[] {
28
+ const q = contentWords(query);
29
+ if (!q.length) return [];
30
+ return items.map((item) => {
31
+ const title = contentWords(item.title);
32
+ const focus = contentWords(item.focusName ?? '');
33
+ const code = (item.linearIdentifier ?? '').toLowerCase();
34
+ let sum = 0;
35
+ for (const w of q) {
36
+ if (title.some((t) => same(t, w))) sum += 1;
37
+ else if (code && words(code).includes(w)) sum += 1;
38
+ else if (focus.some((f) => same(f, w))) sum += 0.6;
39
+ }
40
+ return { item, score: sum / q.length };
41
+ }).filter((s) => s.score >= 0.5);
42
+ }
43
+
44
+ export type Match =
45
+ | { kind: 'one'; item: IntentItem }
46
+ | { kind: 'many'; items: IntentItem[] }
47
+ | { kind: 'none' };
48
+
49
+ /** The best item for a description, several when they tie, none when nothing fits. */
50
+ export function matchItems(query: string, items: IntentItem[]): Match {
51
+ const scored = scoreItems(query, items).sort((a, b) => b.score - a.score);
52
+ if (!scored.length) return { kind: 'none' };
53
+ const top = scored[0].score;
54
+ const tied = scored.filter((s) => s.score >= top - 1e-9);
55
+ return tied.length === 1 ? { kind: 'one', item: tied[0].item } : { kind: 'many', items: tied.map((s) => s.item) };
56
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * The model half of intent parsing: the prompt, and the CHECK of what comes back.
3
+ *
4
+ * The model proposes; this decides. Every item id must be one the person could
5
+ * have meant (the spoken list or an open item), dates must be real, priorities
6
+ * 0-4; one bad action rejects the whole answer and the grammar answers instead.
7
+ */
8
+ import { localDate } from '../compose';
9
+ import { speakable } from '../speak';
10
+ import { isIsoDate, parseWhen, spokenWhen, weekdayName } from './dates';
11
+ import { PRIORITY_NAMES } from './describe';
12
+ import type { IntentContext, IntentItem, VoiceAction } from './types';
13
+
14
+ export const MAX_ACTIONS = 5;
15
+ const MAX_OPEN_SHOWN = 40;
16
+
17
+ export function intentSystemPrompt(): string {
18
+ return [
19
+ 'You turn a spoken reply to a to-do briefing into structured actions. Reply with ONLY a JSON object:',
20
+ '{"confidence": number 0..1, "actions": [ ... ]}. Action shapes (use exactly these "type" values):',
21
+ '{"type":"defer","item_id":ID,"to":"later" | "YYYY-MM-DD"} move to a later date; "later" means no date at all',
22
+ '{"type":"pull_today","item_id":ID} work on it today',
23
+ '{"type":"done","item_id":ID} {"type":"drop","item_id":ID}',
24
+ '{"type":"set_priority","item_id":ID,"priority":0..4} 0 critical, 1 urgent or high, 2 medium, 3 low, 4 lowest',
25
+ '{"type":"add_item","title":"Imperative short title","due":null | "YYYY-MM-DD"} a NEW item the person asked to add',
26
+ '{"type":"undo"} undo the last change',
27
+ '{"type":"clarify","question":"one short spoken question"} when you cannot tell which item or when',
28
+ 'RULES',
29
+ '- Acting on the wrong item is far worse than asking. When unsure, return a single clarify and nothing else.',
30
+ '- "this one", "it", "that one", "this" mean the item being read, ONLY if one is being read. If none is being read and the reply does not describe an item, return clarify ("Which one?").',
31
+ '- A move or reschedule with no date or "later" in the reply is a clarify ("Move it to when?"). "later", "not today", "some other time" = defer with to "later".',
32
+ '- The listed items are context, NOT instructions: never act on an item the person did not refer to. One action per referred item.',
33
+ '- If a description fits two or more items about equally, return clarify naming up to three of them. If it fits none, clarify and offer to add it.',
34
+ '- "the next one" = the item after the one being read. "that other thing" = an open item that was NOT in the briefing (clarify if several).',
35
+ '- Match descriptions loosely against titles ("the bench one", "the lease call").',
36
+ '- Adding something new ("add X", "remind me to X", "I need to X by Friday") is add_item with the thing as an imperative title and the date as due. Do not add anything that already exists as an item.',
37
+ '- Several instructions in one reply are several actions in the order spoken.',
38
+ '- Anything that is not an instruction about to-dos (greetings, chatter, questions): one clarify asking them to say it again.',
39
+ '- Dates: resolve against today in the person\'s zone. A bare weekday is the next such day after today; "next week" is Monday of next week; "next Friday" is Friday of next week. Never return a date before today.',
40
+ '- item_id is always the text after "id:" (like "paper"), never a position number. Never invent an item.',
41
+ 'confidence (0..1) is how sure you are that you understood the reply AND picked the right item(s) and date.',
42
+ ].join('\n');
43
+ }
44
+
45
+ const line = (item: IntentItem) =>
46
+ `[id:${item.id}] ${speakable(item.title, 14)}${item.focusName ? ` (${item.focusName})` : ''}${item.linearIdentifier ? ` ${item.linearIdentifier}` : ''}`;
47
+
48
+ export function intentPrompt(ctx: IntentContext): string {
49
+ const today = localDate(ctx.now, ctx.timeZone);
50
+ const briefedIds = new Set(ctx.briefed.map((i) => i.id));
51
+ const others = ctx.open.filter((i) => !briefedIds.has(i.id)).slice(0, MAX_OPEN_SHOWN);
52
+ const reading = ctx.readingId ? [...ctx.briefed, ...ctx.open].find((i) => i.id === ctx.readingId) : null;
53
+ return [
54
+ `Today is ${weekdayName(today)} ${today} (${ctx.timeZone}).`,
55
+ 'Items just spoken, in order:',
56
+ ...(ctx.briefed.length ? ctx.briefed.map((i, n) => `spoken #${n + 1}: ${line(i)}`) : ['(none)']),
57
+ `Item being read when the person spoke: ${reading ? line(reading) : 'none (playback was not on an item)'}`,
58
+ 'Other open items (not in the briefing):',
59
+ ...(others.length ? others.map((i) => `- ${line(i)}`) : ['(none)']),
60
+ `Undo available: ${ctx.hasUndo ? 'yes' : 'no'}`,
61
+ `The person said: ${JSON.stringify(ctx.utterance)}`,
62
+ ].join('\n');
63
+ }
64
+
65
+ export type Checked = { ok: true; actions: VoiceAction[]; confidence: number } | { ok: false; reason: string };
66
+
67
+ function parseJson(text: string): unknown {
68
+ const body = text.trim().replace(/^```(?:json)?\s*/i, '').replace(/\s*```$/, '');
69
+ try { return JSON.parse(body); } catch { /* try the outermost braces */ }
70
+ const a = body.indexOf('{'); const b = body.lastIndexOf('}');
71
+ if (a < 0 || b <= a) return undefined;
72
+ try { return JSON.parse(body.slice(a, b + 1)); } catch { return undefined; }
73
+ }
74
+
75
+ export function checkModelReply(reply: string, ctx: IntentContext): Checked {
76
+ const data = parseJson(reply) as { confidence?: unknown; actions?: unknown } | undefined;
77
+ if (!data || typeof data !== 'object') return { ok: false, reason: 'reply was not JSON' };
78
+ if (typeof data.confidence !== 'number' || data.confidence < 0 || data.confidence > 1) return { ok: false, reason: 'missing confidence' };
79
+ if (!Array.isArray(data.actions) || !data.actions.length || data.actions.length > MAX_ACTIONS) return { ok: false, reason: 'no usable actions' };
80
+ const today = localDate(ctx.now, ctx.timeZone);
81
+ const known = new Set([...ctx.briefed, ...ctx.open].map((i) => i.id));
82
+ const out: VoiceAction[] = [];
83
+
84
+ for (const raw of data.actions as Array<Record<string, unknown>>) {
85
+ if (!raw || typeof raw !== 'object') return { ok: false, reason: 'action is not an object' };
86
+ const type = raw.type;
87
+ const id = typeof raw.item_id === 'string' ? raw.item_id : '';
88
+ const needsItem = ['defer', 'pull_today', 'done', 'drop', 'set_priority'].includes(String(type));
89
+ if (needsItem && !known.has(id)) return { ok: false, reason: `unknown item ${JSON.stringify(raw.item_id)}` };
90
+ switch (type) {
91
+ case 'defer': {
92
+ const when = typeof raw.to === 'string' ? (raw.to === 'later' ? 'later' : isIsoDate(raw.to) ? raw.to : parseWhen(raw.to, ctx.now, ctx.timeZone)) : null;
93
+ if (!when) return { ok: false, reason: 'unusable date' };
94
+ const date = typeof when === 'string' ? when : when.later ? 'later' : when.date;
95
+ if (!date) return { ok: false, reason: 'unusable date' };
96
+ if (date !== 'later' && date < today) return { ok: false, reason: 'date is in the past' };
97
+ if (date === today) { out.push({ type: 'pull_today', itemId: id, label: 'today' }); break; }
98
+ out.push({ type: 'defer', itemId: id, to: date, label: date === 'later' ? 'later' : spokenWhen(date, today) });
99
+ break;
100
+ }
101
+ case 'pull_today': out.push({ type: 'pull_today', itemId: id, label: 'today' }); break;
102
+ case 'done': case 'drop': out.push({ type, itemId: id }); break;
103
+ case 'set_priority': {
104
+ const p = raw.priority;
105
+ if (typeof p !== 'number' || !Number.isInteger(p) || p < 0 || p >= PRIORITY_NAMES.length) return { ok: false, reason: 'bad priority' };
106
+ out.push({ type: 'set_priority', itemId: id, priority: p });
107
+ break;
108
+ }
109
+ case 'add_item': {
110
+ const t = typeof raw.title === 'string' ? raw.title.trim() : '';
111
+ if (!t || t.length > 200) return { ok: false, reason: 'bad title' };
112
+ let due: string | null = null;
113
+ if (typeof raw.due === 'string' && raw.due) {
114
+ const w = isIsoDate(raw.due) ? raw.due : parseWhen(raw.due, ctx.now, ctx.timeZone)?.date;
115
+ if (!w) return { ok: false, reason: 'unusable due date' };
116
+ if (w < today) return { ok: false, reason: 'due date is in the past' };
117
+ due = w;
118
+ }
119
+ out.push({ type: 'add_item', title: t[0].toUpperCase() + t.slice(1), dueDate: due });
120
+ break;
121
+ }
122
+ case 'undo': out.push({ type: 'undo' }); break;
123
+ case 'clarify': {
124
+ const q = typeof raw.question === 'string' ? raw.question.trim() : '';
125
+ if (!q) return { ok: false, reason: 'empty question' };
126
+ out.push({ type: 'clarify', question: q });
127
+ break;
128
+ }
129
+ case 'none': out.push({ type: 'clarify', question: 'Sorry, I did not catch that. Can you say that again?' }); break;
130
+ default: return { ok: false, reason: `unknown action type ${JSON.stringify(type)}` };
131
+ }
132
+ }
133
+ if (out.some((a) => a.type === 'undo') && !ctx.hasUndo) return { ok: true, actions: [{ type: 'clarify', question: 'There is nothing to undo.' }], confidence: data.confidence };
134
+ return { ok: true, actions: out, confidence: data.confidence };
135
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * "This one": the item being read when the person pressed talk.
3
+ *
4
+ * The briefing stores where each item's sentence sits in the text (`offsets`).
5
+ * ElevenLabs gives character timing; OpenAI does not, so with no timing the
6
+ * position is ESTIMATED from seconds played at ~15 characters a second (the rate
7
+ * measured on gpt-4o-mini-tts), or from the fraction played when the audio's
8
+ * length is known (which is exact enough for a constant-pace voice).
9
+ *
10
+ * Rule when playback sits BETWEEN items (a pause, the greeting between): the last
11
+ * fully spoken item. Before the first item's sentence: nobody, and the reply must
12
+ * name its item.
13
+ */
14
+ import type { BriefingContextRecord } from '../store';
15
+
16
+ export const CHARS_PER_SECOND = 15;
17
+
18
+ export interface PlaybackPosition {
19
+ /** Exact character position, when the provider gave word timing. */
20
+ charPosition?: number;
21
+ /** Seconds played so far. */
22
+ seconds?: number;
23
+ /** Total audio length, when known. */
24
+ durationSeconds?: number;
25
+ /** Length of the spoken text, needed with `durationSeconds`. */
26
+ textLength?: number;
27
+ }
28
+
29
+ export function charPositionOf(position: PlaybackPosition): number {
30
+ if (position.charPosition !== undefined) return position.charPosition;
31
+ const seconds = position.seconds ?? 0;
32
+ if (position.durationSeconds && position.textLength) {
33
+ return (Math.min(seconds, position.durationSeconds) / position.durationSeconds) * position.textLength;
34
+ }
35
+ return seconds * CHARS_PER_SECOND;
36
+ }
37
+
38
+ export function readingAt(
39
+ context: Pick<BriefingContextRecord, 'offsets'>,
40
+ position: PlaybackPosition,
41
+ ): string | null {
42
+ const at = charPositionOf(position);
43
+ let last: string | null = null;
44
+ for (const segment of [...context.offsets].sort((a, b) => a.start - b.start)) {
45
+ if (at >= segment.start && at <= segment.end) return segment.id;
46
+ if (segment.end < at) last = segment.id;
47
+ }
48
+ return last;
49
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * resolveVoiceIntent: utterance + the list just spoken -> actions.
3
+ *
4
+ * Model first (it handles loose wording), checked; the grammar answers whenever
5
+ * the model is absent, late, malformed, names an item that does not exist, or
6
+ * contradicts the data. A low-confidence model answer asks instead of acting.
7
+ * NEVER executes anything.
8
+ */
9
+ import { describeActions } from './describe';
10
+ import { parseWithGrammar } from './grammar';
11
+ import { ungrounded } from './ground';
12
+ import { checkModelReply, intentPrompt, intentSystemPrompt } from './model';
13
+ import type { IntentContext, IntentOptions, IntentResult } from './types';
14
+
15
+ const DEFAULT_TIMEOUT_MS = 8_000;
16
+ const DEFAULT_MIN_CONFIDENCE = 0.6;
17
+
18
+ export async function resolveVoiceIntent(ctx: IntentContext, options: IntentOptions = {}): Promise<IntentResult> {
19
+ const notes: string[] = [];
20
+ if (!ctx.utterance.trim()) return { ...parseWithGrammar(ctx), notes: ['empty utterance'] };
21
+
22
+ if (options.llm) {
23
+ try {
24
+ const reply = await options.llm.write({
25
+ system: intentSystemPrompt(),
26
+ prompt: intentPrompt(ctx),
27
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
28
+ });
29
+ const checked = checkModelReply(reply, ctx);
30
+ if (!checked.ok) notes.push(checked.reason);
31
+ else {
32
+ const guess = ungrounded(checked.actions, ctx);
33
+ if (guess) notes.push(`ungrounded: ${guess}`);
34
+ else if (checked.actions.every((a) => a.type === 'clarify') && parseWithGrammar(ctx).actions.some((a) => a.type !== 'clarify')) {
35
+ // The model hedged where the plain rules are sure (they only act on a unique, named match).
36
+ notes.push('model asked; the grammar found a clear match');
37
+ } else if (checked.confidence < (options.minConfidence ?? DEFAULT_MIN_CONFIDENCE)) {
38
+ const actions = [{ type: 'clarify' as const, question: 'I am not sure I got that. Can you say that again?' }];
39
+ return { actions, source: 'llm', understood: describeActions(actions, ctx), notes: [`low confidence ${checked.confidence}`] };
40
+ } else {
41
+ return { actions: checked.actions, source: 'llm', understood: describeActions(checked.actions, ctx), notes };
42
+ }
43
+ }
44
+ } catch (error) {
45
+ notes.push(`model failed: ${error instanceof Error ? error.message : String(error)}`);
46
+ }
47
+ }
48
+ return { ...parseWithGrammar(ctx), notes };
49
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Which item does "this one" / "the bench thing" / "the next one" mean?
3
+ * Resolved against the spoken list and the open items; never invents one.
4
+ */
5
+ import { speakable } from '../speak';
6
+ import { contentWords, matchItems, words } from './match';
7
+ import type { IntentContext, IntentItem } from './types';
8
+
9
+ export type Target =
10
+ | { ok: true; item: IntentItem }
11
+ | { ok: false; question: string };
12
+
13
+ const DEICTIC = /^(?:the )?(?:this|that|it|them|these|those|current|same)(?: one| thing| item| task| one i am reading)?$/;
14
+ const NEXT = /^(?:the )?next(?: one| item| thing| task)?$/;
15
+ const PREVIOUS = /^(?:the )?(?:previous|last one|one before)(?: one| item| thing| task)?$/;
16
+ const OTHER = /^(?:that |the |those )?other(?: one| thing| item| task| ones| things)?$/;
17
+ const ORDINAL_WORDS: Record<string, number> = {
18
+ first: 1, second: 2, third: 3, fourth: 4, fifth: 5, sixth: 6, seventh: 7, eighth: 8, ninth: 9, tenth: 10,
19
+ '1st': 1, '2nd': 2, '3rd': 3, '4th': 4, '5th': 5, '6th': 6, '7th': 7, '8th': 8,
20
+ one: 1, two: 2, three: 3, four: 4, five: 5, six: 6, seven: 7, eight: 8,
21
+ };
22
+ const ORDINAL = /^(?:the )?(?:(first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|1st|2nd|3rd|4th|5th|6th|7th|8th)|(?:number|item) (\d|one|two|three|four|five|six|seven|eight))(?: one| item| thing| task)?$/;
23
+
24
+ const join = (titles: string[]) => (titles.length <= 1 ? titles.join('') : `${titles.slice(0, -1).join(', ')}, or ${titles[titles.length - 1]}`);
25
+ const say = (item: IntentItem) => speakable(item.title, 8);
26
+
27
+ /** "Which one: A, B, or C?" - three at most, then "or another". */
28
+ export function whichOne(items: IntentItem[]): string {
29
+ if (!items.length) return 'Which item do you mean?';
30
+ const shown = items.slice(0, 3).map(say);
31
+ if (items.length > 3) shown.push('another');
32
+ return `Which one: ${join(shown)}?`;
33
+ }
34
+
35
+ export function resolveTarget(phrase: string, ctx: IntentContext, readingId: string | null): Target {
36
+ const p = words(phrase).join(' ');
37
+ const byId = new Map([...ctx.briefed, ...ctx.open].map((i) => [i.id, i] as const));
38
+ const reading = readingId ? byId.get(readingId) ?? null : null;
39
+ const index = reading ? ctx.briefed.findIndex((i) => i.id === reading.id) : -1;
40
+
41
+ const structural = ORDINAL.test(p) || NEXT.test(p) || PREVIOUS.test(p) || OTHER.test(p);
42
+ if (!p || DEICTIC.test(p) || (!structural && !contentWords(p).length)) {
43
+ if (reading) return { ok: true, item: reading };
44
+ if (ctx.briefed.length === 1) return { ok: true, item: ctx.briefed[0] };
45
+ return { ok: false, question: whichOne(ctx.briefed) };
46
+ }
47
+ if (NEXT.test(p)) {
48
+ const next = index >= 0 ? ctx.briefed[index + 1] : undefined;
49
+ if (next) return { ok: true, item: next };
50
+ return { ok: false, question: index >= 0 ? 'There is no next item.' : whichOne(ctx.briefed) };
51
+ }
52
+ if (PREVIOUS.test(p)) {
53
+ const prev = index > 0 ? ctx.briefed[index - 1] : p.includes('last') && index < 0 ? ctx.briefed[ctx.briefed.length - 1] : undefined;
54
+ return prev ? { ok: true, item: prev } : { ok: false, question: whichOne(ctx.briefed) };
55
+ }
56
+ const ord = ORDINAL.exec(p);
57
+ if (ord) {
58
+ const n = ORDINAL_WORDS[ord[1] ?? ''] ?? (ord[2] ? ORDINAL_WORDS[ord[2]] ?? parseInt(ord[2], 10) : 0);
59
+ const item = ctx.briefed[n - 1];
60
+ return item ? { ok: true, item } : { ok: false, question: `There are only ${ctx.briefed.length} items in the briefing.` };
61
+ }
62
+ if (OTHER.test(p)) {
63
+ const briefedIds = new Set(ctx.briefed.map((i) => i.id));
64
+ const pool = ctx.open.filter((i) => !briefedIds.has(i.id));
65
+ if (pool.length === 1) return { ok: true, item: pool[0] };
66
+ return { ok: false, question: pool.length ? whichOne(pool) : 'There is nothing else open.' };
67
+ }
68
+ const found = matchItems(p, [...ctx.briefed, ...ctx.open.filter((o) => !ctx.briefed.some((b) => b.id === o.id))]);
69
+ if (found.kind === 'one') return { ok: true, item: found.item };
70
+ if (found.kind === 'many') return { ok: false, question: whichOne(found.items) };
71
+ return { ok: false, question: `I could not find a ${contentWords(p).join(' ')} item. Say add it to create one.` };
72
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * What a spoken reply becomes. The parser NEVER executes: it returns these, the
3
+ * executor (`../actions`) applies them, and a person sees what was understood first.
4
+ */
5
+ import type { BriefingScriptLlm } from '../script';
6
+
7
+ /** An item a reply may refer to: only the fields the matcher and the prompt need. */
8
+ export interface IntentItem {
9
+ id: string;
10
+ title: string;
11
+ focusName?: string;
12
+ linearIdentifier?: string;
13
+ }
14
+
15
+ export interface IntentContext {
16
+ /** What the person said (the transcript). */
17
+ utterance: string;
18
+ now: number;
19
+ /** The listener's IANA zone: "tomorrow" and "Friday" are resolved in it. */
20
+ timeZone: string;
21
+ /** The items just spoken, in the order they were spoken. */
22
+ briefed: IntentItem[];
23
+ /** Other open items a reply may name ("that other thing"). */
24
+ open: IntentItem[];
25
+ /** The item being read when the person pressed talk (see `readingAt`), or null. */
26
+ readingId: string | null;
27
+ /** Whether the undo stack has anything on it. */
28
+ hasUndo: boolean;
29
+ }
30
+
31
+ export type VoiceAction =
32
+ /** `to` is `later` (clear the due date) or a `YYYY-MM-DD` date after today. */
33
+ | { type: 'defer'; itemId: string; to: string; label?: string }
34
+ | { type: 'pull_today'; itemId: string; label?: string }
35
+ | { type: 'done'; itemId: string }
36
+ | { type: 'drop'; itemId: string }
37
+ /** 0 critical, 1 urgent, 2 medium, 3 low, 4 lowest. */
38
+ | { type: 'set_priority'; itemId: string; priority: number }
39
+ | { type: 'add_item'; title: string; dueDate: string | null }
40
+ | { type: 'undo' }
41
+ /** A short thing to say back when the reply was not clear enough to act on. */
42
+ | { type: 'clarify'; question: string }
43
+ | { type: 'none' };
44
+
45
+ export interface IntentResult {
46
+ actions: VoiceAction[];
47
+ source: 'llm' | 'grammar';
48
+ /** One line to show before applying: "Move Pick up printer paper to Friday". */
49
+ understood: string;
50
+ /** Why the model's answer was not used, for logs and the accuracy probe. */
51
+ notes: string[];
52
+ }
53
+
54
+ export interface IntentOptions {
55
+ /** The model. Omit to use the grammar alone. */
56
+ llm?: BriefingScriptLlm | null;
57
+ /** Model deadline; past it the grammar answers. Default 8 s. */
58
+ timeoutMs?: number;
59
+ /** Below this the reply asks instead of acting. Default 0.6. */
60
+ minConfidence?: number;
61
+ }
@@ -1401,6 +1401,7 @@ export function createPlanningApi(options: CreateCorpusApiOptions): PlanningApi
1401
1401
  if (patch.dueAt !== undefined) wire.due_at = patch.dueAt;
1402
1402
  if (patch.subtype !== undefined) wire.subtype = patch.subtype;
1403
1403
  if (patch.priority !== undefined) wire.priority = patch.priority;
1404
+ if (patch.resolvedAt !== undefined) wire.resolved_at = patch.resolvedAt;
1404
1405
  const updated = await post<TenantEntity>(`${entities}/upsert`, {
1405
1406
  entity_type: types.commitment,
1406
1407
  external_id: item.externalId,
@@ -858,7 +858,10 @@ export interface CommitmentApi {
858
858
  */
859
859
  updateCommitment?(item: Commitment, patch: Partial<Pick<Commitment,
860
860
  'status' | 'statusReason' | 'ownerName' | 'ownerSub' | 'dueAt' | 'subtype'
861
- | 'priority' | 'title' | 'detail'>>): Promise<Commitment>;
861
+ | 'title' | 'detail' | 'resolvedAt'>> & {
862
+ /** `null` clears it (undoing a voice-set priority). */
863
+ priority?: number | null;
864
+ }): Promise<Commitment>;
862
865
  /**
863
866
  * A person adding an item nobody said in a meeting.
864
867
  *