@startsimpli/integrations 0.2.200 → 0.2.202

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.
Files changed (147) hide show
  1. package/package.json +7 -7
  2. package/src/__tests__/briefing-actions.test.ts +11 -0
  3. package/src/__tests__/briefing-edits.test.ts +98 -0
  4. package/src/__tests__/briefing-markdown.test.ts +64 -0
  5. package/src/__tests__/converse-brain.test.ts +64 -1
  6. package/src/__tests__/converse-cards.test.ts +53 -0
  7. package/src/__tests__/converse-handoff.test.ts +8 -0
  8. package/src/__tests__/converse-meeting-brief.test.ts +72 -8
  9. package/src/__tests__/converse-meeting-duplex.test.ts +132 -0
  10. package/src/__tests__/converse-meeting-keep-speech.test.ts +87 -0
  11. package/src/__tests__/converse-meeting-vad.test.ts +1 -1
  12. package/src/__tests__/converse-page.test.tsx +148 -37
  13. package/src/__tests__/converse-roci.test.ts +22 -0
  14. package/src/__tests__/converse-spoken-form.test.ts +10 -0
  15. package/src/__tests__/converse-spoken-summary.test.ts +27 -6
  16. package/src/__tests__/converse-structure.test.ts +27 -0
  17. package/src/__tests__/converse-view.test.ts +46 -0
  18. package/src/__tests__/converse.test.ts +29 -2
  19. package/src/__tests__/corpus-ask.test.ts +22 -0
  20. package/src/__tests__/corpus-tracker.test.tsx +42 -174
  21. package/src/__tests__/data-table-logic.test.ts +75 -0
  22. package/src/__tests__/data-table.test.tsx +133 -0
  23. package/src/__tests__/extract-classify.test.ts +17 -0
  24. package/src/__tests__/fleet-page.test.tsx +57 -0
  25. package/src/__tests__/fleet-view.test.ts +149 -0
  26. package/src/__tests__/home-brief.test.tsx +25 -40
  27. package/src/__tests__/library-call-shape.test.tsx +164 -0
  28. package/src/__tests__/load-error.test.tsx +1 -1
  29. package/src/__tests__/mini-markdown.test.tsx +24 -0
  30. package/src/__tests__/overview-page.test.tsx +36 -6
  31. package/src/__tests__/plan-shell.test.tsx +6 -4
  32. package/src/__tests__/project-basis-entity.test.ts +19 -0
  33. package/src/__tests__/project-basis.test.ts +21 -0
  34. package/src/__tests__/relay-cli.test.ts +10 -1
  35. package/src/__tests__/task-detail-project-guess.test.tsx +46 -0
  36. package/src/__tests__/timeline-events.test.ts +65 -0
  37. package/src/__tests__/timeline-table.test.tsx +66 -0
  38. package/src/__tests__/todo-table-model.test.ts +75 -0
  39. package/src/__tests__/todo-table.test.tsx +202 -0
  40. package/src/__tests__/tracker-timeline-component.test.tsx +4 -4
  41. package/src/__tests__/tracker-timeline-reader.test.ts +1 -1
  42. package/src/comms/__tests__/app-sends-page.test.tsx +69 -0
  43. package/src/comms/api/comms.ts +23 -0
  44. package/src/comms/components/ResultsPanel.tsx +2 -2
  45. package/src/comms/components/SendLog.tsx +20 -8
  46. package/src/comms/components/index.ts +1 -0
  47. package/src/comms/components/pages/AppSendsPage.tsx +58 -0
  48. package/src/comms/hooks/index.ts +8 -3
  49. package/src/components/FolderTree.tsx +12 -3
  50. package/src/components/index.ts +4 -1
  51. package/src/components/pages/ConversePage.tsx +114 -105
  52. package/src/components/pages/FleetPage.tsx +115 -0
  53. package/src/components/pages/LibraryPage.tsx +63 -24
  54. package/src/components/pages/TaskDetailPage.tsx +27 -1
  55. package/src/components/pages/TrackerPage.tsx +170 -474
  56. package/src/components/pages/converse/CardView.tsx +72 -0
  57. package/src/components/pages/converse/SettingsMenu.tsx +37 -0
  58. package/src/components/pages/converse/Thread.tsx +48 -33
  59. package/src/components/pages/converse/useNeedsYou.ts +60 -0
  60. package/src/components/pages/home/BriefCard.tsx +16 -7
  61. package/src/components/pages/home/HomeBriefPage.tsx +6 -91
  62. package/src/components/pages/home/MiniMarkdown.tsx +51 -0
  63. package/src/components/pages/home/{DueSoonLine.tsx → dueSoonText.ts} +2 -11
  64. package/src/components/pages/home/index.ts +1 -1
  65. package/src/components/pages/overview/OverviewPage.tsx +46 -83
  66. package/src/components/pages/plan/TalkPage.tsx +5 -14
  67. package/src/components/pages/plan/TimelinePage.tsx +4 -2
  68. package/src/components/pages/task-tracker/ProjectGuess.tsx +42 -0
  69. package/src/components/pages/tracker/SweepPanel.tsx +108 -0
  70. package/src/components/pages/tracker/TimelineTable.tsx +70 -0
  71. package/src/components/pages/tracker/TrackerTimeline.tsx +32 -15
  72. package/src/components/table/DataTable.tsx +92 -0
  73. package/src/components/table/RowMenu.tsx +35 -0
  74. package/src/components/table/TablePagination.tsx +63 -0
  75. package/src/components/table/TableToolbar.tsx +56 -0
  76. package/src/components/table/TodoTable.tsx +142 -0
  77. package/src/components/table/index.ts +10 -0
  78. package/src/components/table/table-logic.ts +60 -0
  79. package/src/components/table/todo-model.ts +93 -0
  80. package/src/corpus/ask-items.ts +7 -4
  81. package/src/corpus/ask.ts +1 -1
  82. package/src/corpus/briefing/actions/confirm.ts +9 -1
  83. package/src/corpus/briefing/actions/execute.ts +71 -11
  84. package/src/corpus/briefing/actions/log.ts +1 -1
  85. package/src/corpus/briefing/actions/seam.ts +18 -2
  86. package/src/corpus/briefing/actions/types.ts +14 -0
  87. package/src/corpus/briefing/generate-weekly.ts +4 -0
  88. package/src/corpus/briefing/generate.ts +4 -0
  89. package/src/corpus/briefing/index.ts +1 -0
  90. package/src/corpus/briefing/intent/describe.ts +5 -1
  91. package/src/corpus/briefing/intent/edits.ts +92 -0
  92. package/src/corpus/briefing/intent/grammar.ts +3 -0
  93. package/src/corpus/briefing/intent/ground.ts +5 -1
  94. package/src/corpus/briefing/intent/match.ts +3 -1
  95. package/src/corpus/briefing/intent/model.ts +36 -3
  96. package/src/corpus/briefing/intent/resolve.ts +12 -1
  97. package/src/corpus/briefing/intent/types.ts +8 -0
  98. package/src/corpus/briefing/markdown.ts +71 -0
  99. package/src/corpus/briefing/speak.ts +13 -0
  100. package/src/corpus/client.ts +40 -146
  101. package/src/corpus/converse/brain.ts +41 -13
  102. package/src/corpus/converse/briefing-queue.ts +105 -27
  103. package/src/corpus/converse/cards.ts +69 -0
  104. package/src/corpus/converse/client.ts +6 -0
  105. package/src/corpus/converse/fleet-view.ts +126 -0
  106. package/src/corpus/converse/fleet.ts +18 -5
  107. package/src/corpus/converse/followups.ts +12 -2
  108. package/src/corpus/converse/handle.ts +21 -12
  109. package/src/corpus/converse/handoff.ts +7 -2
  110. package/src/corpus/converse/index.ts +11 -3
  111. package/src/corpus/converse/meeting-config.ts +8 -4
  112. package/src/corpus/converse/meeting.ts +66 -11
  113. package/src/corpus/converse/respond.ts +14 -2
  114. package/src/corpus/converse/roci.ts +13 -0
  115. package/src/corpus/converse/spoken-form.ts +9 -2
  116. package/src/corpus/converse/spoken-summary.ts +30 -8
  117. package/src/corpus/converse/store.ts +2 -0
  118. package/src/corpus/converse/structure.ts +39 -0
  119. package/src/corpus/converse/types.ts +14 -1
  120. package/src/corpus/converse/view.ts +34 -0
  121. package/src/corpus/entities.ts +2 -0
  122. package/src/corpus/extract.ts +9 -4
  123. package/src/corpus/index.ts +2 -0
  124. package/src/corpus/participants.ts +220 -0
  125. package/src/corpus/project-basis.ts +23 -0
  126. package/src/corpus/timeline-events.ts +83 -0
  127. package/src/corpus/tracker-sort.ts +9 -3
  128. package/src/corpus/tracker-timeline-client.ts +2 -0
  129. package/src/corpus/tracker-timeline.ts +4 -0
  130. package/src/corpus/types.ts +38 -5
  131. package/src/native/app/__tests__/plan-talk-registry.test.tsx +2 -1
  132. package/src/native/app/converseServices.ts +5 -3
  133. package/src/native/app/device.ts +2 -0
  134. package/src/native/converse/ConverseScreen.tsx +30 -4
  135. package/src/native/converse/__tests__/liveScreen.test.tsx +35 -2
  136. package/src/native/converse/__tests__/meetingIO.test.ts +55 -1
  137. package/src/native/converse/format.ts +2 -2
  138. package/src/native/converse/io.ts +15 -5
  139. package/src/native/home/HomeScreen.tsx +1 -1
  140. package/src/native/home/tab.tsx +1 -2
  141. package/src/native/plan/PlanTab.tsx +1 -2
  142. package/src/native/plan/__tests__/plan-tab.test.tsx +5 -5
  143. package/src/native/talk/TalkTab.tsx +1 -1
  144. package/src/native/talk/__tests__/talk-tab.test.tsx +1 -1
  145. package/src/__tests__/home-needs-your-call.test.tsx +0 -65
  146. package/src/components/pages/tracker/TrackerBoard.tsx +0 -45
  147. package/src/components/pages/tracker/TrackerToolbar.tsx +0 -44
@@ -1,5 +1,5 @@
1
1
  export { handleConverseTurn, handleConverseEnd } from './handle';
2
- export { converseResponse, converseEndResponse, converseAudioResponse, converseRelayReplyResponse, converseThreadResponse, converseFleetStatusResponse, converseRelayInboxResponse } from './respond';
2
+ export { converseResponse, converseEndResponse, converseAudioResponse, converseRelayReplyResponse, converseThreadResponse, converseFleetStatusResponse, converseFleetViewResponse, converseRelayInboxResponse } from './respond';
3
3
  export { handleRelayInbox, handleRelayReply, handleThread, MAX_RELAY_TEXT } from './relay';
4
4
  export { addRelayOrder, loadRelayOrders, clearRelayOrders, relayInboxExternalId } from './relay-inbox';
5
5
  export type { RelayOrder } from './relay-inbox';
@@ -26,13 +26,21 @@ export type { MeetingConfig } from './meeting-config';
26
26
  export { createUtteranceDetector } from './vad';
27
27
  export type { UtteranceDetector, UtteranceEvent } from './vad';
28
28
  export { createMeetingController } from './meeting';
29
- export type { ListenReason, MeetingApi, MeetingController, MeetingIO, MeetingLine, MeetingPhase, MeetingReply, MeetingState } from './meeting';
29
+ export type { ListenReason, ListenHooks, MeetingApi, MeetingController, MeetingIO, MeetingLine, MeetingPhase, MeetingReply, MeetingState } from './meeting';
30
30
  export { routeUtterance, parseRoute } from './route';
31
31
  export type { ConverseRoute } from './route';
32
- export { saveFleetSnapshot, loadFleetSnapshot, fleetExternalId, FLEET_SOURCE, ageWords, FLEET_FRESH_MS } from './fleet';
32
+ export { cleanFleetInputs, saveFleetSnapshot, loadFleetSnapshot, fleetExternalId, FLEET_SOURCE, ageWords, FLEET_FRESH_MS } from './fleet';
33
33
  export type { FleetSnapshot } from './fleet';
34
+ export { buildFleetView, parseBridgeFind, parseLoops, parsePorts, parseRoles } from './fleet-view';
35
+ export type { FleetInputs, FleetLead, FleetPort, FleetSection, FleetSession, FleetView, RoleRow } from './fleet-view';
34
36
  export { PASSED_TO_RELAY, NO_FLEET_STATUS, NO_FILLER } from './brain';
35
37
  export { ACTIVITY_QUESTION, activityOf, composeActivity, forOwner, loadActivity } from '../activity';
36
38
  export type { Activity, ActivityWindow, ActivityNote } from '../activity';
37
39
  export { askSources, sourceOf, sourcesOfDocs } from './sources';
38
40
  export { itemAnswer } from './item-answers';
41
+ export { converseView, MIC_COLORS } from './view';
42
+ export type { ConverseView } from './view';
43
+ export { ASSISTANT_NAME, normalizeAssistantName } from './roci';
44
+ export { structureReply } from './structure';
45
+ export { CARD_CHIP, DEFAULT_SENDER, briefCard, decisionCard, resolveCard } from './cards';
46
+ export type { CardAction, CardType, ThreadCard } from './cards';
@@ -13,22 +13,26 @@ export interface MeetingConfig {
13
13
  speechLevel: number;
14
14
  /** The level must hold this long to count as the start of speech. */
15
15
  speechStartMs: number;
16
- /** Speaking during Tandem's reply stops the reply and listens. Default off: the mic ignores the speaker. */
16
+ /** Speaking during Tandem's reply stops the reply and listens (barge-in). Acts only when the io is duplex (echo-cancelled mic). */
17
17
  interruptOnSpeech: boolean;
18
+ /** While the reply is being spoken, the voice must be this loud (0..1 RMS) to count as a barge-in: the speaker leaking into the mic is quieter. */
19
+ bargeInLevel: number;
18
20
  /** While nobody speaks, throw the recorded silence away this often so it never grows. */
19
21
  idleRotateMs: number;
22
+ /** A recording that could not be sent is sent again after this long. */
23
+ resendMs: number;
20
24
  /** How often an open conversation asks whether the relay wrote into it. */
21
25
  relayPollMs: number;
22
26
  }
23
27
 
24
28
  export const MEETING_DEFAULTS: MeetingConfig = {
25
- silenceMs: 1200, minUtteranceMs: 400, maxUtteranceMs: 60_000, speechLevel: 0.02, speechStartMs: 150,
26
- interruptOnSpeech: false, idleRotateMs: 30_000, relayPollMs: 4000,
29
+ silenceMs: 1200, minUtteranceMs: 400, maxUtteranceMs: 60_000, speechLevel: 0.02, speechStartMs: 150, bargeInLevel: 0.08,
30
+ interruptOnSpeech: true, idleRotateMs: 30_000, relayPollMs: 4000, resendMs: 3000,
27
31
  };
28
32
 
29
33
  export function resolveMeetingConfig(over: Partial<MeetingConfig> = {}): MeetingConfig {
30
34
  const out: MeetingConfig = { ...MEETING_DEFAULTS };
31
- for (const key of ['silenceMs', 'minUtteranceMs', 'maxUtteranceMs', 'speechLevel', 'speechStartMs', 'idleRotateMs', 'relayPollMs'] as const) {
35
+ for (const key of ['silenceMs', 'minUtteranceMs', 'maxUtteranceMs', 'speechLevel', 'speechStartMs', 'bargeInLevel', 'idleRotateMs', 'relayPollMs', 'resendMs'] as const) {
32
36
  const v = over[key];
33
37
  if (typeof v === 'number' && Number.isFinite(v) && v > 0) out[key] = v;
34
38
  }
@@ -34,6 +34,8 @@ export interface MeetingState {
34
34
  relayNotice: string | null;
35
35
  /** The small mic: true = the meeting listens; false = it does not (typing still works). */
36
36
  micOn: boolean;
37
+ /** True while the microphone is actually open. With a duplex io it stays true while the reply is thought about and spoken. */
38
+ micLive: boolean;
37
39
  }
38
40
 
39
41
  /** Why `listen` returned: the platform's detector says, the controller only needs `audio` and `cancelled`. */
@@ -50,15 +52,24 @@ export interface MeetingApi<A = Blob> {
50
52
  /** What `speak` is given: everything about the reply, so the platform fetches (with its bearer) and plays the bytes. */
51
53
  export interface MeetingReply { conversationId: string; turn: number; replyText: string; audioUrl: string }
52
54
 
55
+ export interface ListenHooks {
56
+ /** Called when the voice starts (a barge-in when the reply is being spoken). */
57
+ onSpeechStart?: () => void;
58
+ }
59
+
53
60
  export interface MeetingIO<A = Blob> {
61
+ /** True when the microphone can stay open while the reply is spoken (echo-cancelled). The loop then never stops listening for a reply. */
62
+ duplex?: boolean;
54
63
  /** Resolves when one utterance is over (end of speech) with its recording, or `{audio: null}` when there was none or it was cancelled. */
55
- listen(signal: AbortSignal, config: MeetingConfig): Promise<{ audio: A | null; cancelled?: boolean; reason?: ListenReason }>;
64
+ listen(signal: AbortSignal, config: MeetingConfig, hooks?: ListenHooks): Promise<{ audio: A | null; cancelled?: boolean; reason?: ListenReason }>;
56
65
  /** Plays the reply and resolves when it has finished (or was stopped); never rejects the loop. `signal` aborts it. */
57
66
  speak(reply: MeetingReply, signal: AbortSignal, config: MeetingConfig): Promise<void>;
58
67
  }
59
68
 
60
69
  export interface MeetingController {
61
70
  start(): void;
71
+ /** The Stop button: cuts off the reply being spoken (or about to be) and goes back to listening. The text stays on screen. */
72
+ stop(): void;
62
73
  /** The mic control. On: listen (starting the meeting if needed, keeping the open conversation). Off: stop listening and SEND what was said so far; the conversation stays open. */
63
74
  mic(on: boolean): void;
64
75
  getState(): MeetingState;
@@ -82,7 +93,8 @@ export function createMeetingController<A = Blob>(options: {
82
93
  }): MeetingController {
83
94
  const { client, io } = options;
84
95
  const config = resolveMeetingConfig(options.config);
85
- let s: MeetingState = { phase: 'idle', retryable: false, lines: [], error: null, noAudio: null, conversationId: null, saved: null, relayNotice: null, micOn: false };
96
+ let s: MeetingState = { phase: 'idle', retryable: false, lines: [], error: null, noAudio: null, conversationId: null, saved: null, relayNotice: null, micOn: false, micLive: false };
97
+ const duplex = options.io.duplex === true;
86
98
  let running = false;
87
99
  /** Wakes the loop when the mic is turned back on. */
88
100
  let resume: (() => void) | null = null;
@@ -90,6 +102,8 @@ export function createMeetingController<A = Blob>(options: {
90
102
  let listenAbort = new AbortController();
91
103
  let speakAbort = new AbortController();
92
104
  let lastReply: MeetingReply | null = null;
105
+ /** Bumped by stop(): a reply whose turn began before it is shown but not spoken. */
106
+ let stopEpoch = 0;
93
107
  /** The newest turn number this meeting has seen, its own or the relay's. */
94
108
  let seen = 0;
95
109
  /** While a relay message is being spoken, listening waits. */
@@ -103,9 +117,20 @@ export function createMeetingController<A = Blob>(options: {
103
117
  const restPhase = (): MeetingPhase => (s.micOn ? 'listening' : 'idle');
104
118
 
105
119
  const listeners = new Set<(state: MeetingState) => void>();
106
- const set = (patch: Partial<MeetingState>) => { s = { ...s, ...patch }; options.onChange?.(s); listeners.forEach((l) => l(s)); };
120
+ /** The mic is live while listening, and (duplex) also while thinking and speaking. */
121
+ const liveNow = (next: MeetingState) => running && next.micOn && (duplex ? ['listening', 'thinking', 'speaking', 'idle'].includes(next.phase) : next.phase === 'listening');
122
+ const set = (patch: Partial<MeetingState>) => { s = { ...s, ...patch }; s = { ...s, micLive: liveNow(s) }; options.onChange?.(s); listeners.forEach((l) => l(s)); };
123
+
124
+ /** A phone that cannot record and play at once stops listening for a reply; a duplex io keeps the mic open. */
125
+ /** `finish`: if he was speaking, what he said so far is SENT, never discarded. */
126
+ const pauseListening = () => { if (!duplex) listenAbort.abort('finish'); };
127
+
128
+ /** True from the moment he starts talking until his utterance is handed over. */
129
+ let userSpeaking = false;
107
130
 
108
131
  async function playReply(reply: MeetingReply) {
132
+ // A reply (a relay message, a slow answer) never talks over him: wait until his utterance is over.
133
+ while (duplex && running && userSpeaking) await new Promise((r) => setTimeout(r, 50));
109
134
  speakAbort = new AbortController();
110
135
  set({ phase: 'speaking', noAudio: null });
111
136
  try {
@@ -113,11 +138,13 @@ export function createMeetingController<A = Blob>(options: {
113
138
  } catch (e) {
114
139
  set({ noAudio: `${e instanceof Error ? e.message : 'playback failed'}` });
115
140
  }
141
+ if (duplex && running && s.phase === 'speaking') set({ phase: restPhase() });
116
142
  }
117
143
 
118
144
  /** Sends one turn; resolves true when it produced a reply. Never throws except to stop the meeting. */
119
- async function takeTurn(input: { audio?: A; text?: string }): Promise<boolean> {
120
- const turnId = freshId();
145
+ async function takeTurn(input: { audio?: A; text?: string }, again?: string): Promise<boolean> {
146
+ const turnId = again ?? freshId();
147
+ const epoch = stopEpoch;
121
148
  set({ phase: 'thinking', error: null, retryable: false });
122
149
  for (let attempt = 0; attempt < 2; attempt += 1) {
123
150
  try {
@@ -143,7 +170,7 @@ export function createMeetingController<A = Blob>(options: {
143
170
  if (out.audio_url) {
144
171
  lastReply = { conversationId: out.conversation_id, turn: out.turn, replyText: out.reply_text, audioUrl: out.audio_url };
145
172
  // A typed message speaks its reply even before Start: the person asked in text, but the screen is a voice one.
146
- if (running || input.text) await playReply(lastReply);
173
+ if ((running || input.text) && epoch === stopEpoch) await playReply(lastReply);
147
174
  } else {
148
175
  lastReply = null;
149
176
  set({ noAudio: out.audio_reason ?? 'no audio was produced' });
@@ -153,6 +180,8 @@ export function createMeetingController<A = Blob>(options: {
153
180
  if (isRejected(e)) { set({ phase: 'stopped', micOn: false, error: e instanceof Error ? e.message : 'The session ended.' }); running = false; return false; }
154
181
  if (attempt === 1 || !(e instanceof ConverseClientError && e.retryable)) {
155
182
  set({ error: e instanceof Error ? e.message : 'That turn failed.', retryable: e instanceof ConverseClientError && e.retryable });
183
+ // What he said is never thrown away: the same recording is sent again (same turn id, so the server never doubles it).
184
+ if (input.audio && running) scheduleResend(input, turnId);
156
185
  return false;
157
186
  }
158
187
  // retryable (mis-heard): one more try with the SAME turn id, so the server never doubles it
@@ -161,6 +190,15 @@ export function createMeetingController<A = Blob>(options: {
161
190
  return false;
162
191
  }
163
192
 
193
+ /** Sends a recording that failed again after a pause, until it goes through or the meeting ends. */
194
+ function scheduleResend(input: { audio?: A; text?: string }, turnId: string) {
195
+ setTimeout(() => {
196
+ if (!running) return;
197
+ const turn = turnChain.then(() => (running ? takeTurn(input, turnId) : false));
198
+ turnChain = turn.catch(() => undefined);
199
+ }, config.resendMs);
200
+ }
201
+
164
202
  /** Asks for turns past `seen`; relay ones are shown and, in a running meeting, spoken at once. */
165
203
  async function pollOnce() {
166
204
  const id = s.conversationId;
@@ -179,7 +217,7 @@ export function createMeetingController<A = Blob>(options: {
179
217
  const reply: MeetingReply = { conversationId: id, turn: t.turn, replyText: t.reply_text, audioUrl: t.audio_url };
180
218
  const done = turnChain.then(async () => {
181
219
  if (!running) return;
182
- listenAbort.abort();
220
+ pauseListening();
183
221
  await playReply(reply);
184
222
  if (running && s.phase === 'speaking') set({ phase: restPhase() });
185
223
  });
@@ -213,8 +251,15 @@ export function createMeetingController<A = Blob>(options: {
213
251
  continue;
214
252
  }
215
253
  listenAbort = new AbortController();
216
- set({ phase: 'listening' });
217
- const heard = await io.listen(listenAbort.signal, config);
254
+ if (!duplex || s.phase === 'idle') set({ phase: 'listening' });
255
+ const heard = await io.listen(listenAbort.signal, config, {
256
+ // Barge-in: the person starts talking while the reply is being read: cut it off, what they say is the next turn.
257
+ onSpeechStart: () => {
258
+ userSpeaking = true;
259
+ if (duplex && config.interruptOnSpeech && s.phase === 'speaking') speakAbort.abort('barge-in');
260
+ },
261
+ });
262
+ userSpeaking = false;
218
263
  if (!running) break;
219
264
  // An io with no microphone cancels by itself: wait for End (typing still works) instead of spinning.
220
265
  if (heard.cancelled && !listenAbort.signal.aborted) {
@@ -224,6 +269,11 @@ export function createMeetingController<A = Blob>(options: {
224
269
  if (!heard.audio) continue;
225
270
  const turn = turnChain.then(() => takeTurn({ audio: heard.audio as A }));
226
271
  turnChain = turn.catch(() => undefined);
272
+ // Duplex: listening goes on while the turn runs and the reply is spoken, so a new utterance is picked up at once.
273
+ if (duplex) {
274
+ void turn.then(() => { if (running && s.phase === 'thinking') set({ phase: restPhase() }); }, () => undefined);
275
+ continue;
276
+ }
227
277
  await turn;
228
278
  }
229
279
  }
@@ -249,6 +299,11 @@ export function createMeetingController<A = Blob>(options: {
249
299
  getState: () => s,
250
300
  subscribe(listener) { listeners.add(listener); return () => { listeners.delete(listener); }; },
251
301
  start() { begin(true); },
302
+ stop() {
303
+ stopEpoch += 1;
304
+ speakAbort.abort('stop');
305
+ if (running && s.phase === 'speaking') set({ phase: restPhase() });
306
+ },
252
307
  mic(on) {
253
308
  if (on) {
254
309
  // Typing before the mic: the conversation is already open, so turning the mic on continues it.
@@ -268,7 +323,7 @@ export function createMeetingController<A = Blob>(options: {
268
323
  // The microphone is still open here: stop listening before the reply plays (a phone cannot record and play in one session),
269
324
  // and hold the loop (`gate`) until the reply is done, exactly like a relay message.
270
325
  const done = turnChain.then(async () => {
271
- if (running) listenAbort.abort();
326
+ if (running) pauseListening();
272
327
  await takeTurn({ text: t });
273
328
  if (running && s.phase !== 'stopped') set({ phase: restPhase() });
274
329
  else if (!running && (s.phase === 'thinking' || s.phase === 'speaking')) set({ phase: 'idle' });
@@ -282,7 +337,7 @@ export function createMeetingController<A = Blob>(options: {
282
337
  if (!lastReply) return;
283
338
  const reply = lastReply;
284
339
  const done = turnChain.then(async () => {
285
- if (running) listenAbort.abort();
340
+ if (running) pauseListening();
286
341
  await playReply(reply);
287
342
  if (running) set({ phase: restPhase() });
288
343
  });
@@ -7,7 +7,8 @@
7
7
  import { isTimeZone } from '../spoken-time';
8
8
  import { voiceErrorResponse } from '../voice-manage';
9
9
  import { handleConverseEnd, handleConverseTurn } from './handle';
10
- import { saveFleetSnapshot } from './fleet';
10
+ import { cleanFleetInputs, loadFleetSnapshot, saveFleetSnapshot } from './fleet';
11
+ import { buildFleetView } from './fleet-view';
11
12
  import { handleRelayInbox, handleRelayReply, handleThread } from './relay';
12
13
  import { createEntityConversationStore } from './store';
13
14
  import { CLIENT_ID, ConverseError, MAX_CONVERSE_AUDIO_BYTES, type ConverseDeps, type ConverseTurnRequest } from './types';
@@ -138,13 +139,24 @@ export async function converseThreadResponse(conversationId: string, after: stri
138
139
  export async function converseFleetStatusResponse(request: Request, deps: ConverseDeps): Promise<Response> {
139
140
  try {
140
141
  const { fields } = await fieldsOf(request);
141
- const saved = await saveFleetSnapshot(deps, typeof fields.text === 'string' ? fields.text : '');
142
+ const saved = await saveFleetSnapshot(deps, typeof fields.text === 'string' ? fields.text : '', cleanFleetInputs(fields.inputs));
142
143
  return Response.json({ saved: true, record_id: saved.record_id, updated_at: saved.updatedAt });
143
144
  } catch (error) {
144
145
  return failure(error);
145
146
  }
146
147
  }
147
148
 
149
+ /** GET /corpus/converse/fleet-status: the snapshot as the /fleet page reads it ({text, updatedAt, view}); `snapshot: null` before the relay has posted. */
150
+ export async function converseFleetViewResponse(deps: ConverseDeps): Promise<Response> {
151
+ try {
152
+ const snap = await loadFleetSnapshot(deps);
153
+ const body = snap ? { snapshot: { text: snap.text, updatedAt: snap.updatedAt, view: snap.inputs ? buildFleetView(snap.inputs) : null } } : { snapshot: null };
154
+ return Response.json(body, { headers: { 'cache-control': 'no-store' } });
155
+ } catch (error) {
156
+ return failure(error);
157
+ }
158
+ }
159
+
148
160
  /** GET /corpus/converse/relay-inbox: what the person has asked the relay for that it has not answered yet. */
149
161
  export async function converseRelayInboxResponse(deps: ConverseDeps): Promise<Response> {
150
162
  try {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * THE ASSISTANT'S NAME. It is Roci. There is no wake word: nothing listens for the name. But Quinn types it the way it
3
+ * sounds, "Rossi". Normalised on the way IN, before the model sees the text, so the assistant is never confused about
4
+ * who it is being asked. ONLY "Rossi" (whole word): Rocky, Roxy and Rosie can be real names or other words, so they are
5
+ * left exactly as written.
6
+ */
7
+ export const ASSISTANT_NAME = 'Roci';
8
+
9
+ const ROSSI = /\brossi\b/gi;
10
+
11
+ export function normalizeAssistantName(text: string, name: string = ASSISTANT_NAME): string {
12
+ return text ? text.replace(ROSSI, name) : text;
13
+ }
@@ -8,10 +8,17 @@ import { IDENTIFIER } from '../briefing/speak';
8
8
  const ISO_DATE = /\b(\d{4}-\d{2}-\d{2})\b/g;
9
9
  const MARKUP = /[*_#`~<>|\\]|\[|\]|^\s*[-•>]\s/m;
10
10
 
11
+ /** "Yes, the to-do ..." / "Sure, ..." / "Okay. ...": an answer says the answer, not that it agrees. Voice only. */
12
+ const FILLER = /^(?:(?:yes|yeah|yep|sure|okay|ok|certainly|of course|absolutely|right|alright)\b[,.!]?\s+)+/i;
13
+ const LABEL = /^(?:the |your )?(?:to-?do|task|item|reminder)\s+(?=\S)/i;
14
+ const capital = (s: string) => (s ? s[0].toUpperCase() + s.slice(1) : s);
15
+
11
16
  export function toSpoken(text: string, today: string): string | null {
12
- if (!ISO_DATE.test(text) && !new RegExp(IDENTIFIER.source).test(text) && !MARKUP.test(text)) { ISO_DATE.lastIndex = 0; return null; }
17
+ const lead = text.replace(FILLER, (m) => (m ? '' : m));
18
+ const stripped = lead !== text ? capital(lead.replace(LABEL, '')) : text;
19
+ if (stripped === text && !ISO_DATE.test(text) && !new RegExp(IDENTIFIER.source).test(text) && !MARKUP.test(text)) { ISO_DATE.lastIndex = 0; return null; }
13
20
  ISO_DATE.lastIndex = 0;
14
- const out = text
21
+ const out = stripped
15
22
  .replace(ISO_DATE, (d) => spokenWhen(d, today))
16
23
  .replace(/\s*\(\s*[A-Za-z]{2,10}-\d+\s*\)/g, '')
17
24
  .replace(IDENTIFIER, '')
@@ -1,16 +1,24 @@
1
1
  /**
2
2
  * What is SAID aloud for a long answer (Quinn: short, like a meeting). The full answer stays on the screen; the voice says
3
- * the first three items and "and N more", or the first sentences and "The rest is on your screen." Short answers are
4
- * said whole (this returns undefined).
3
+ * the first three items and "and N more", or the first sentences, and then asks "Want the rest?". Saying yes reads the
4
+ * remainder the same way (`spokenRest`), again a short piece at a time. Short answers are said whole (undefined).
5
5
  */
6
6
  const WORDS = (s: string) => s.trim().split(/\s+/).filter(Boolean);
7
- const SPOKEN_MAX_WORDS = 45;
7
+ const SPOKEN_MAX_WORDS = 30;
8
8
  const LIST_AT = 4;
9
+ const OFFER = 'Want the rest?';
9
10
 
10
11
  const finish = (s: string) => s.replace(/\s+/g, ' ').trim().replace(/[,;:]+$/, '');
11
12
  const endWithStop = (s: string) => (/[.!?]$/.test(s) ? s : `${s}.`);
12
13
 
13
- export function spokenSummary(answer: string): string | undefined {
14
+ export interface SplitAnswer {
15
+ /** What the voice says now, ending in the offer. */
16
+ spoken: string;
17
+ /** What has not been said yet (the text a "yes" reads next). */
18
+ rest: string;
19
+ }
20
+
21
+ export function splitAnswer(answer: string): SplitAnswer | undefined {
14
22
  const text = answer.replace(/\s+/g, ' ').trim();
15
23
  if (!text) return undefined;
16
24
 
@@ -21,7 +29,10 @@ export function spokenSummary(answer: string): string | undefined {
21
29
  const intro = finish(text.slice(0, first));
22
30
  const items = markers.map((m, i) => finish(text.slice((m.index ?? 0) + m[0].length, markers[i + 1]?.index ?? text.length)).replace(/[.]+$/, ''));
23
31
  const head = items.slice(0, 3).map((x) => endWithStop(x)).join(' ');
24
- return `${intro ? `${endWithStop(intro)} ` : ''}${head} And ${items.length - 3} more.`;
32
+ return {
33
+ spoken: `${intro ? `${endWithStop(intro)} ` : ''}${head} And ${items.length - 3} more. ${OFFER}`,
34
+ rest: items.slice(3).map((x) => endWithStop(x)).join(' '),
35
+ };
25
36
  }
26
37
 
27
38
  const words = WORDS(text);
@@ -30,14 +41,25 @@ export function spokenSummary(answer: string): string | undefined {
30
41
  // Prose: whole sentences up to the limit; if the first sentence alone is too long (a list run together with commas), cut it at a comma.
31
42
  const sentences = text.match(/[^.!?]+[.!?]+(?:\s|$)|[^.!?]+$/g)?.map((s) => s.trim()).filter(Boolean) ?? [text];
32
43
  let spoken = '';
44
+ let used = 0;
33
45
  for (const s of sentences) {
34
46
  if (WORDS(`${spoken} ${s}`).length > SPOKEN_MAX_WORDS) break;
35
47
  spoken = `${spoken} ${s}`.trim();
48
+ used += 1;
36
49
  }
37
50
  if (!spoken) {
38
- const cut = words.slice(0, 38).join(' ');
51
+ const cut = words.slice(0, 26).join(' ');
39
52
  const at = Math.max(cut.lastIndexOf(','), cut.lastIndexOf(';'));
40
- spoken = endWithStop(finish(at > 15 ? cut.slice(0, at) : cut));
53
+ const said = at > 12 ? cut.slice(0, at) : cut;
54
+ return { spoken: `${endWithStop(finish(said))} ${OFFER}`, rest: finish(text.slice(said.length).replace(/^[\s,;:]+/, '')) };
41
55
  }
42
- return `${spoken} The rest is on your screen.`;
56
+ return { spoken: `${spoken} ${OFFER}`, rest: sentences.slice(used).join(' ').trim() };
43
57
  }
58
+
59
+ export const spokenSummary = (answer: string): string | undefined => splitAnswer(answer)?.spoken;
60
+
61
+ /** The remainder after the part `spokenSummary` said, or undefined when the whole answer was said. */
62
+ export const spokenRest = (answer: string): string | undefined => splitAnswer(answer)?.rest || undefined;
63
+
64
+ /** "yes", "go on", "the rest": the person wants what was left out. Only ever tried right after a shortened answer. */
65
+ export const WANTS_THE_REST = /^(?:(?:yes|yeah|yep|yup|sure|ok(?:ay)?|please|go on|go ahead|continue|keep going|read (?:it|the rest|more)|the rest|tell me more|more|and then)\b[\s,.!]*){1,4}$/i;
@@ -32,6 +32,7 @@ function toRecord(entity: TenantEntity): ConversationRecord {
32
32
  ...(d.decisions ? { decisions: list(d.decisions) } : {}),
33
33
  ...(d.briefing && typeof d.briefing === 'object' ? { briefing: d.briefing as ConversationRecord['briefing'] } : {}),
34
34
  ...(d.context && typeof d.context === 'object' ? { context: d.context as ConversationRecord['context'] } : {}),
35
+ ...(d.pending && typeof d.pending === 'object' ? { pending: d.pending as ConversationRecord['pending'] } : {}),
35
36
  };
36
37
  }
37
38
 
@@ -72,6 +73,7 @@ export function createEntityConversationStore(http: ConverseDeps['http'], ownerS
72
73
  ...(record.decisions ? { decisions: record.decisions } : {}),
73
74
  briefing: record.briefing ?? null,
74
75
  context: record.context ?? null,
76
+ pending: record.pending ?? null,
75
77
  },
76
78
  });
77
79
  return { ...record, id: String(row.id) };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Roci's words as STRUCTURED text. The server replies in a speakable form (no markup, so it can be read aloud): one
3
+ * run of sentences, or "1. ... 2. ..." inline. On screen that is a wall of text. This gives it shape without changing
4
+ * what is said: a lead line, then short bullets. Text that already has Markdown blocks is left exactly as it is, and a
5
+ * short single sentence stays a sentence. Pure, so web and native share it.
6
+ */
7
+ const BLOCK = /^\s{0,3}(#{1,6}\s|[-*+]\s|\d+[.)]\s)/m;
8
+
9
+ function clean(s: string): string {
10
+ return s.replace(/\s*\(\s*\)/g, '').replace(/\s+([.,;])/g, '$1').replace(/\s{2,}/g, ' ').trim();
11
+ }
12
+
13
+ function sentences(text: string): string[] {
14
+ return text.match(/[^.!?]+(?:[.!?]+(?=\s|$)|$)/g)?.map((s) => s.trim()).filter(Boolean) ?? [text];
15
+ }
16
+
17
+ export function structureReply(text: string): string {
18
+ let t = clean(text ?? '');
19
+ // One line that starts with a bullet but holds a whole numbered run ("- Do a. 2. Do b. 3. Do c."): the bullet was item 1.
20
+ if (!t.includes('\n') && /^[-*+]\s+/.test(t) && /\s2\.\s/.test(t) && /\s3\.\s/.test(t)) t = `1. ${t.replace(/^[-*+]\s+/, '')}`;
21
+ if (!t || (t.includes('\n') && BLOCK.test(t))) return text ?? '';
22
+ if (!t.includes('\n') && BLOCK.test(t) && !/\s2\.\s/.test(t)) return text ?? '';
23
+
24
+ // "Lead. 1. a. 2. b. 3. c. Tail": an inline numbered run.
25
+ const numbered = t.split(/(?:^|\s)\d+\.\s+/);
26
+ if (numbered.length >= 3 && /(?:^|\s)1\.\s/.test(t) && /\s2\.\s/.test(t)) {
27
+ const [lead, ...rest] = numbered;
28
+ const tailAt = rest.length ? rest[rest.length - 1].search(/(?<=[.!?])\s+(?=[A-Z])/) : -1;
29
+ const last = rest[rest.length - 1];
30
+ const items = tailAt > -1 ? [...rest.slice(0, -1), last.slice(0, tailAt)] : rest;
31
+ const tail = tailAt > -1 ? last.slice(tailAt).trim() : '';
32
+ return [lead.trim(), items.map((i) => `- ${i.trim().replace(/[.]$/, '')}`).join('\n'), tail].filter(Boolean).join('\n\n');
33
+ }
34
+
35
+ const parts = sentences(t);
36
+ if (parts.length < 3) return t;
37
+ const [lead, ...rest] = parts;
38
+ return `${lead}\n\n${rest.map((s) => `- ${s}`).join('\n')}`;
39
+ }
@@ -66,6 +66,8 @@ export interface ConversationRecord {
66
66
  briefing?: BriefingState;
67
67
  /** The items the last answer listed, for follow-ups ("the second one"). */
68
68
  context?: { items: PlayedItem[] };
69
+ /** A which-one question just asked about an instruction; the next words answer it. */
70
+ pending?: PendingClarify;
69
71
  }
70
72
 
71
73
  export interface ConversationStore {
@@ -78,7 +80,12 @@ export interface ConversationStore {
78
80
  import type { BriefingState } from './briefing-queue';
79
81
  import type { PlayedItem } from './followups';
80
82
 
83
+ /** The instruction that could not be placed and the question asked back: the next turn reads both together. */
84
+ export interface PendingClarify { utterance: string; question: string }
85
+
81
86
  export interface ConverseBrainInput {
87
+ /** The question asked last turn about an instruction ("which one?"); the utterance answers it. */
88
+ pending?: PendingClarify | null;
82
89
  /** The items the last answer listed, in the order they were said: what "the second one" and "that one" mean. */
83
90
  context?: { items: PlayedItem[] } | null;
84
91
  /** A briefing in progress (the queue and where it is), kept on the conversation; the next answer belongs to it. */
@@ -103,6 +110,8 @@ export interface ConverseBrainOutput {
103
110
  briefing?: BriefingState | null;
104
111
  /** The items this answer listed (null clears; absent keeps what was there). */
105
112
  context?: { items: PlayedItem[] } | null;
113
+ /** A clarifying question just asked (kept for the next turn); null clears; absent keeps nothing. */
114
+ pending?: PendingClarify | null;
106
115
  /** What kind of thing was said (shown by the app, kept on the turn). */
107
116
  intent?: ConverseIntent;
108
117
  /** The records the answer came from. */
@@ -172,6 +181,10 @@ export interface ConverseEndResult {
172
181
  turns: number;
173
182
  asks: string[];
174
183
  decisions: string[];
184
+ /** The asks that were actually filed as to-dos (those already added during the conversation are not filed twice). */
185
+ filed?: string[];
186
+ /** The project it was filed under; null when none fit. Absent when this End did not file (a replay). */
187
+ project?: string | null;
175
188
  }
176
189
 
177
190
  /** What End hands on once the record is saved. */
@@ -192,7 +205,7 @@ export interface ConverseDeps {
192
205
  /** Pulls asks and decisions out of a finished conversation. Default: none. */
193
206
  extract?: (input: { transcript: string }) => Promise<{ asks: string[]; decisions: string[] }>;
194
207
  /** After End has saved: files the conversation like a voice note (under a project, asks as to-dos). Default: none. See ./handoff. */
195
- handoff?: (input: ConverseHandoffInput) => Promise<void>;
208
+ handoff?: (input: ConverseHandoffInput) => Promise<void | { project?: string | null }>;
196
209
  store?: ConversationStore;
197
210
  now?: () => number;
198
211
  newId?: () => string;
@@ -0,0 +1,34 @@
1
+ import type { MeetingState } from './meeting';
2
+
3
+ /** What the Talk screen shows for a meeting state; the web page and the native screen read the same flags. */
4
+ export interface ConverseView {
5
+ /** The mic is on and a conversation is running (`micOn` alone is only the preference, true before anything starts). */
6
+ listening: boolean;
7
+ thinking: boolean;
8
+ speaking: boolean;
9
+ /** The conversation is being saved. */
10
+ busy: boolean;
11
+ /** Stop is offered while a reply is being thought about or spoken. */
12
+ canStop: boolean;
13
+ /** The Voice/Text switch: which side is on. Kept for the native screen; the web page has one mic and no switch. */
14
+ mode: 'voice' | 'text';
15
+ /** The big status word: what the assistant is doing right now. */
16
+ status: 'READY' | 'LISTENING' | 'THINKING' | 'SPEAKING';
17
+ /** What the ONE mic control does when pressed: Talk (start listening), Mute (stop listening and send), Interrupt (cut the reply off). */
18
+ micAction: 'talk' | 'mute' | 'interrupt';
19
+ /** The state, carried by the mic's colour (no banner, no status text). */
20
+ micTone: 'idle' | 'listening' | 'thinking' | 'speaking' | 'muted';
21
+ }
22
+
23
+ /** The mic's colour per state: the phone's mapping (drive-mode-ui ConverseScreen), lifted here so web and iOS share it. White text >= 5:1. */
24
+ export const MIC_COLORS = { idle: '#4F46E5', listening: '#0B6E3A', thinking: '#9A4A06', speaking: '#1D4ED8', muted: '#374151' } as const;
25
+
26
+ export function converseView(s: Pick<MeetingState, 'phase' | 'micOn'>): ConverseView {
27
+ const thinking = s.phase === 'thinking';
28
+ const speaking = s.phase === 'speaking';
29
+ const listening = s.micOn && (s.phase === 'listening' || thinking || speaking);
30
+ const busy = s.phase === 'ending';
31
+ const status = speaking ? 'SPEAKING' : thinking || busy ? 'THINKING' : listening ? 'LISTENING' : 'READY';
32
+ const micAction = thinking || speaking ? 'interrupt' : listening ? 'mute' : 'talk';
33
+ return { listening, thinking, speaking, busy, canStop: thinking || speaking, mode: listening ? 'voice' : 'text', status, micAction, micTone: thinking || busy ? 'thinking' : speaking ? 'speaking' : listening ? 'listening' : s.phase === 'listening' ? 'muted' : 'idle' };
34
+ }
@@ -735,6 +735,7 @@ export function toCommitment(
735
735
  ...(asNumber(pick(data, 'estimate_minutes', 'estimateMinutes')) !== undefined
736
736
  ? { estimateMinutes: asNumber(pick(data, 'estimate_minutes', 'estimateMinutes')) } : {}),
737
737
  ...(pick(data, 'due_basis', 'dueBasis') ? { dueBasis: asText(pick(data, 'due_basis', 'dueBasis')) } : {}),
738
+ ...(pick(data, 'project_basis', 'projectBasis') ? { projectBasis: asText(pick(data, 'project_basis', 'projectBasis')) } : {}),
738
739
  ...(asNumber(pick(data, 'due_confidence', 'dueConfidence')) !== undefined
739
740
  ? { dueConfidence: asNumber(pick(data, 'due_confidence', 'dueConfidence')) } : {}),
740
741
  ...(pick(data, 'owner_sub', 'ownerSub')
@@ -821,6 +822,7 @@ export function commitmentToEntity(commitment: Commitment): {
821
822
  ...(commitment.priority !== undefined ? { priority: commitment.priority } : {}),
822
823
  ...(commitment.estimateMinutes !== undefined ? { estimate_minutes: commitment.estimateMinutes } : {}),
823
824
  ...(commitment.dueBasis ? { due_basis: commitment.dueBasis } : {}),
825
+ ...(commitment.projectBasis ? { project_basis: commitment.projectBasis } : {}),
824
826
  ...(commitment.dueConfidence !== undefined ? { due_confidence: commitment.dueConfidence } : {}),
825
827
  ...(commitment.ownerSub ? { owner_sub: commitment.ownerSub } : {}),
826
828
  ...(commitment.ownerSubs?.length ? { owner_subs: encodeOwnerSubs(commitment.ownerSubs) } : {}),
@@ -41,6 +41,7 @@
41
41
  * fit in a request — one document is about twenty seconds — so the sweep is a
42
42
  * durable, resumable, leased RUN in `./runs`, and this is the step it is made of.
43
43
  */
44
+ import { projectBasisFor } from './project-basis';
44
45
  import { applyDecisions, buildClassifyRequest, candidatesFromFocuses } from './classify';
45
46
  import { applyTeamDecisions, buildTeamRequest } from './classify-team';
46
47
  import { EXTRACTOR_VERSION, applyResolutions, mergeDrafts, reconcile } from './commitments';
@@ -567,6 +568,9 @@ export async function extractCommitments(
567
568
  if (placed?.focusId) {
568
569
  item.focusId = placed.focusId;
569
570
  item.externalFocusId = placed.focusId;
571
+ // Only the item's own words count: a note's section headings are named after projects and would make every guess look stated.
572
+ const basis = projectBasisFor(item, classification.titles.get(placed.focusId) ?? '', '');
573
+ if (basis) item.projectBasis = basis;
570
574
  } else if (placed?.destination) {
571
575
  item.destination = placed.destination;
572
576
  }
@@ -578,6 +582,7 @@ export async function extractCommitments(
578
582
  item.destination = 'personal';
579
583
  delete item.focusId;
580
584
  delete item.externalFocusId;
585
+ delete item.projectBasis;
581
586
  }
582
587
  }
583
588
  const teams = await classifyTeams(fresh, { corpus, extractor, documents, promptText });
@@ -637,17 +642,17 @@ async function classifyFresh(
637
642
  documents: SourceDocument[];
638
643
  promptText: Map<string, string>;
639
644
  },
640
- ): Promise<{ placed: ReturnType<typeof applyDecisions>; failure: ExtractionModelFailure | null }> {
641
- const none = { placed: new Map(), failure: null };
645
+ ): Promise<{ placed: ReturnType<typeof applyDecisions>; titles: Map<string, string>; failure: ExtractionModelFailure | null }> {
646
+ const none = { placed: new Map(), titles: new Map<string, string>(), failure: null };
642
647
  if (!fresh.length || !ctx.extractor.classify || !ctx.corpus.listFocuses) return none;
643
648
  try {
644
649
  const focuses = await readAllFocuses(ctx.corpus.listFocuses.bind(ctx.corpus));
645
650
  const candidates = candidatesFromFocuses(focuses);
646
651
  const request = buildClassifyRequest(fresh, candidates, ctx.documents, (document) => ctx.promptText.get(document.id) ?? '');
647
652
  const draft = await ctx.extractor.classify(request);
648
- return { placed: applyDecisions(request.items, candidates, draft), failure: null };
653
+ return { placed: applyDecisions(request.items, candidates, draft), titles: new Map(candidates.map((c) => [c.id, c.title])), failure: null };
649
654
  } catch (err) {
650
- return { placed: new Map(), failure: describeModelFailure('extract', err) };
655
+ return { placed: new Map(), titles: new Map<string, string>(), failure: describeModelFailure('extract', err) };
651
656
  }
652
657
  }
653
658
 
@@ -6,6 +6,8 @@
6
6
  * `@startsimpli/integrations/corpus-llm` and is server-only.
7
7
  */
8
8
  export type {
9
+ ListDocumentsOptions,
10
+ ListSourcesOptions,
9
11
  AnswerDraft,
10
12
  AnswerRequest,
11
13
  AskMode,