@startsimpli/integrations 0.2.226 → 0.2.227

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 (45) hide show
  1. package/package.json +6 -6
  2. package/src/__tests__/attention-orgs.test.ts +61 -0
  3. package/src/__tests__/attention-run.test.ts +3 -3
  4. package/src/__tests__/converse-meeting-vad.test.ts +25 -3
  5. package/src/__tests__/converse-meeting.test.ts +29 -0
  6. package/src/__tests__/converse-soak.test.ts +28 -0
  7. package/src/__tests__/converse.test.ts +23 -1
  8. package/src/__tests__/relay-items.test.ts +1 -1
  9. package/src/corpus/attention/importance.ts +1 -1
  10. package/src/corpus/attention/index.ts +1 -0
  11. package/src/corpus/attention/orgs.ts +41 -0
  12. package/src/corpus/attention/policy.ts +2 -0
  13. package/src/corpus/attention/push.ts +2 -1
  14. package/src/corpus/attention/queue.ts +3 -1
  15. package/src/corpus/attention/run-steps.ts +1 -1
  16. package/src/corpus/attention/run.ts +4 -3
  17. package/src/corpus/attention/types.ts +1 -1
  18. package/src/corpus/converse/handle.ts +7 -2
  19. package/src/corpus/converse/meeting-config.ts +8 -2
  20. package/src/corpus/converse/meeting.ts +5 -3
  21. package/src/corpus/converse/respond.ts +2 -2
  22. package/src/corpus/converse/types.ts +2 -0
  23. package/src/corpus/converse/vad.ts +16 -1
  24. package/src/corpus/notify/types.ts +2 -0
  25. package/src/native/app/FoundryApp.tsx +1 -1
  26. package/src/native/app/__tests__/launch.test.ts +4 -1
  27. package/src/native/app/converseServices.ts +2 -1
  28. package/src/native/app/device.ts +3 -0
  29. package/src/native/app/launch.ts +4 -0
  30. package/src/native/app/registry.tsx +6 -1
  31. package/src/native/briefing/audioPlayer.ts +2 -1
  32. package/src/native/converse/ConverseScreen.tsx +45 -78
  33. package/src/native/converse/__tests__/bargeInIO.test.ts +3 -0
  34. package/src/native/converse/__tests__/liveScreen.test.tsx +59 -63
  35. package/src/native/converse/__tests__/speedScreen.test.tsx +6 -2
  36. package/src/native/converse/index.ts +2 -1
  37. package/src/native/converse/stateBanner.tsx +41 -0
  38. package/src/native/push/NeedsYouCard.tsx +11 -7
  39. package/src/native/push/__tests__/decisionsApp.test.tsx +2 -3
  40. package/src/native/push/__tests__/needsYou.test.tsx +23 -9
  41. package/src/native/push/fake.ts +5 -5
  42. package/src/native/talk/TalkTab.tsx +16 -13
  43. package/src/native/talk/__tests__/talk-tab.test.tsx +18 -0
  44. package/src/native/converse/DriveScreen.tsx +0 -47
  45. package/src/native/converse/__tests__/driveScreen.test.tsx +0 -54
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.226",
3
+ "version": "0.2.227",
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.211",
53
54
  "@startsimpli/auth": "^0.4.64",
54
- "@startsimpli/utils": "^0.4.23",
55
- "@startsimpli/ui": "^0.4.211"
55
+ "@startsimpli/utils": "^0.4.23"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -98,11 +98,11 @@
98
98
  "vitest": "^3.0.0",
99
99
  "react-native": "0.85.3",
100
100
  "react-native-safe-area-context": "~5.7.0",
101
+ "@startsimpli/llm": "0.4.31",
101
102
  "@startsimpli/ui": "0.4.211",
102
- "@startsimpli/auth": "0.4.64",
103
103
  "@startsimpli/ui-native": "0.1.15",
104
- "@startsimpli/utils": "0.4.23",
105
- "@startsimpli/llm": "0.4.31"
104
+ "@startsimpli/auth": "0.4.64",
105
+ "@startsimpli/utils": "0.4.23"
106
106
  },
107
107
  "scripts": {
108
108
  "type-check": "tsc --noEmit && tsc --noEmit -p tsconfig.native.json",
@@ -0,0 +1,61 @@
1
+ // @vitest-environment node
2
+ /** QuinnAI orgs as a needs-you source: one item per RUNNING org with asks or a hold for Quinn; quiet when the endpoint is down. */
3
+ import { describe, expect, it, vi } from 'vitest';
4
+ import { ATTENTION_DEFAULTS, buildNeedsYou, fetchOrgOverview, orgItems, type OrgOverviewRow } from '../corpus/attention';
5
+
6
+ const row = (o: Partial<OrgOverviewRow>): OrgOverviewRow => ({ name: 'qlo-personal', status: 'running', live: true, waiting_on_you: 0, hold: null, ...o });
7
+ const BASE = 'http://localhost:4370';
8
+
9
+ describe('orgItems', () => {
10
+ it('one item per running org with open asks or a hold, linking to the orgs page', () => {
11
+ const items = orgItems([row({ waiting_on_you: 8, hold: 'Board 00:12: pause idle workers until refresh' }), row({ name: 'toon-satire' })], BASE);
12
+ expect(items).toHaveLength(1);
13
+ expect(items[0]).toMatchObject({ id: 'org:qlo-personal', source: 'org', from: 'qlo-personal', link: `${BASE}/orgs` });
14
+ expect(items[0].text).toContain('qlo-personal');
15
+ expect(items[0].text).toContain('8 waiting on you');
16
+ expect(items[0].text).toContain('pause idle workers');
17
+ });
18
+ it('a hold alone is enough; asks alone are enough', () => {
19
+ expect(orgItems([row({ hold: 'Needs a budget decision' })], BASE)).toHaveLength(1);
20
+ expect(orgItems([row({ waiting_on_you: 1 })], BASE)[0].text).toContain('1 waiting on you');
21
+ });
22
+ it('skips stopped, stalled and not-live orgs even with asks (bridge, crochet-companion)', () => {
23
+ expect(orgItems([row({ name: 'bridge', status: 'stopped', live: false, waiting_on_you: 10, hold: 'stopped' }), row({ name: 'x', status: 'stalled', live: false, waiting_on_you: 3 }), row({ name: 'y', live: false, waiting_on_you: 3 })], BASE)).toEqual([]);
24
+ });
25
+ it('ignores malformed rows instead of throwing', () => {
26
+ expect(orgItems([null, {}, { name: 5 }] as never, BASE)).toEqual([]);
27
+ expect(orgItems(undefined as never, BASE)).toEqual([]);
28
+ });
29
+ });
30
+
31
+ describe('fetchOrgOverview degrades quietly', () => {
32
+ it('returns the rows on success', async () => {
33
+ const f = vi.fn(async () => new Response(JSON.stringify({ orgs: [row({ waiting_on_you: 2 })] }), { status: 200 })) as unknown as typeof fetch;
34
+ expect(await fetchOrgOverview(BASE, f)).toHaveLength(1);
35
+ expect((f as unknown as ReturnType<typeof vi.fn>).mock.calls[0][0]).toBe(`${BASE}/api/orgs/overview`);
36
+ });
37
+ it('returns [] when the endpoint is down, errors, or sends junk, and never throws', async () => {
38
+ expect(await fetchOrgOverview(BASE, (async () => { throw new Error('ECONNREFUSED'); }) as never)).toEqual([]);
39
+ expect(await fetchOrgOverview(BASE, (async () => new Response('nope', { status: 502 })) as never)).toEqual([]);
40
+ expect(await fetchOrgOverview(BASE, (async () => new Response('not json', { status: 200 })) as never)).toEqual([]);
41
+ expect(await fetchOrgOverview(BASE, (async () => new Response('{"orgs":"x"}', { status: 200 })) as never)).toEqual([]);
42
+ });
43
+ });
44
+
45
+ describe('in the needs-you queue', () => {
46
+ const orgs = orgItems([row({ waiting_on_you: 8, hold: 'Board 00:12: pause non-essential idle workers' })], BASE);
47
+ it('is a needs-answer item carrying a score, even when the hold text contains "hold"', () => {
48
+ const q = buildNeedsYou({ view: null, decisions: [], policy: ATTENTION_DEFAULTS, orgs });
49
+ expect(q.items).toHaveLength(1);
50
+ expect(q.items[0]).toMatchObject({ source: 'org', class: 'needs-answer' });
51
+ expect(q.items[0].importance).toBeGreaterThanOrEqual(ATTENTION_DEFAULTS.callMeMinImportance);
52
+ });
53
+ it('a hold that mentions money scores higher than a plain one (the importance score is reused)', () => {
54
+ const plain = buildNeedsYou({ view: null, decisions: [], policy: ATTENTION_DEFAULTS, orgs: orgItems([row({ waiting_on_you: 1, hold: 'Pick the next goal' })], BASE) });
55
+ const money = buildNeedsYou({ view: null, decisions: [], policy: ATTENTION_DEFAULTS, orgs: orgItems([row({ waiting_on_you: 1, hold: 'Would cost $718/day, approve the budget' })], BASE) });
56
+ expect(money.items[0].importance).toBeGreaterThan(plain.items[0].importance);
57
+ });
58
+ it('no orgs given: the queue is unchanged', () => {
59
+ expect(buildNeedsYou({ view: { waitingOnQuinn: ['Approve the staging promote'] }, decisions: [], policy: ATTENTION_DEFAULTS }).items).toHaveLength(1);
60
+ });
61
+ });
@@ -50,7 +50,7 @@ describe('walking the queue', () => {
50
50
  it('one item reads "One thing needs you"; an empty queue says so and is not active', () => {
51
51
  expect(startRun({ conversationId: 'conv-0001', items: items.slice(0, 1), now: NOW }).reply.text).toMatch(/^One thing needs you\. Question 1 of 1:/);
52
52
  const none = startRun({ conversationId: 'conv-0001', items: [], now: NOW });
53
- expect(none.reply).toMatchObject({ text: 'Nothing is waiting on you right now.', active: false });
53
+ expect(none.reply).toMatchObject({ text: 'Nothing is waiting on you right now. Ask me what is in flight for a short status.', active: false });
54
54
  });
55
55
  it('an empty answer is asked again, not recorded', () => {
56
56
  const { run } = startRun({ conversationId: 'conv-0001', items, now: NOW });
@@ -103,7 +103,7 @@ describe('the stored run', () => {
103
103
  it('plain fleet lines are never asked (no yes/no on prose); they stay in the queue', async () => {
104
104
  const { deps, fleet } = tenant();
105
105
  fleet('Who owns the site?', 'Approve the staging promote');
106
- expect(await createAttentionRun(deps).start('conv-0005')).toMatchObject({ text: 'Nothing is waiting on you right now.', active: false });
106
+ expect(await createAttentionRun(deps).start('conv-0005')).toMatchObject({ text: 'Nothing is waiting on you right now. Ask me what is in flight for a short status.', active: false });
107
107
  const st = await loadState(deps);
108
108
  const q = buildNeedsYou({ view: buildFleetView({ loops: '## Waiting on Quinn\n- Who owns the site?\n- Approve the staging promote\n' }), decisions: [], policy: policyFrom(st.attention) });
109
109
  expect(q.items).toHaveLength(2);
@@ -121,7 +121,7 @@ describe('the stored run', () => {
121
121
  });
122
122
  it('nothing waiting: says so and is not active', async () => {
123
123
  const { deps } = tenant();
124
- expect(await createAttentionRun(deps).start('conv-0003')).toMatchObject({ text: 'Nothing is waiting on you right now.', active: false });
124
+ expect(await createAttentionRun(deps).start('conv-0003')).toMatchObject({ text: 'Nothing is waiting on you right now. Ask me what is in flight for a short status.', active: false });
125
125
  });
126
126
  it('asks only a batch at a time, most important first', async () => {
127
127
  const { deps } = tenant();
@@ -17,9 +17,9 @@ function run(levels: Array<[level: number, ms: number]>, config = cfg) {
17
17
  describe('resolveMeetingConfig', () => {
18
18
  it('defaults, partial overrides, and ignores nonsense', () => {
19
19
  const d = resolveMeetingConfig();
20
- expect(d).toMatchObject({ silenceMs: 1200, minUtteranceMs: 400, maxUtteranceMs: 60000, interruptOnSpeech: true });
21
- expect(resolveMeetingConfig({ silenceMs: 800, interruptOnSpeech: true })).toMatchObject({ silenceMs: 800, interruptOnSpeech: true, minUtteranceMs: 400 });
22
- expect(resolveMeetingConfig({ silenceMs: -5, speechLevel: Number.NaN }).silenceMs).toBe(1200);
20
+ expect(d).toMatchObject({ silenceMs: 850, minUtteranceMs: 250, maxUtteranceMs: 60000, interruptOnSpeech: true });
21
+ expect(resolveMeetingConfig({ silenceMs: 800, interruptOnSpeech: true })).toMatchObject({ silenceMs: 800, interruptOnSpeech: true, minUtteranceMs: 250 });
22
+ expect(resolveMeetingConfig({ silenceMs: -5, speechLevel: Number.NaN }).silenceMs).toBe(850);
23
23
  });
24
24
  });
25
25
 
@@ -59,3 +59,25 @@ describe('end-of-speech detector', () => {
59
59
  expect(ev.map((e) => e.type)).toEqual(['start', 'end', 'start', 'end']);
60
60
  });
61
61
  });
62
+
63
+ describe('end-of-speech detector with background noise (a drive)', () => {
64
+ const car = resolveMeetingConfig({}); // production defaults: silence 850 ms, adaptive floor
65
+ it('road noise above the fixed threshold does not run the utterance to the 60 s cap: the end is found', () => {
66
+ // 0.03 hum is over speechLevel (0.02): a fixed threshold calls it speech forever. 1 s of hum, 1.5 s voice at 0.2, back to hum.
67
+ const ev = run([[0.03, 2000], [0.2, 1500], [0.03, 3000]], car);
68
+ expect(ev.map((e) => e.type)).toEqual(['start', 'end']);
69
+ expect(ev[1]!.reason).toBeUndefined();
70
+ expect(ev[1]!.at).toBeLessThan(2000 + 1500 + 1200);
71
+ });
72
+ it('every short utterance is a turn: 20 short words over noise are 20 start/end pairs', () => {
73
+ const seq: Array<[number, number]> = [[0.03, 1500]];
74
+ for (let i = 0; i < 20; i += 1) seq.push([0.15, 400], [0.03, 1400]);
75
+ const ev = run(seq, car);
76
+ expect(ev.filter((e) => e.type === 'end')).toHaveLength(20);
77
+ expect(ev.filter((e) => e.type === 'discard')).toHaveLength(0);
78
+ });
79
+ it('a quiet voice in a quiet room still starts and ends (no noise: the plain threshold)', () => {
80
+ const ev = run([[0.005, 1000], [0.05, 1000], [0.005, 2000]], car);
81
+ expect(ev.map((e) => e.type)).toEqual(['start', 'end']);
82
+ });
83
+ });
@@ -348,6 +348,35 @@ describe('a turn that wraps the conversation up, and the intent and sources a re
348
348
  });
349
349
  });
350
350
 
351
+ describe('a spoken "did not catch that" is never swallowed', () => {
352
+ it('a turn with no transcript but a spoken apology shows it, speaks it, logs it, and listens again', async () => {
353
+ const heals: string[] = [];
354
+ const queue = [blob()];
355
+ const client = { turn: vi.fn(async () => turnResult(1, { transcript: '', reply_text: 'Sorry, I did not catch that. Can you say that again?' })), end: vi.fn() } as never;
356
+ const speak = vi.fn(async () => undefined);
357
+ const io: MeetingIO = { listen: vi.fn((signal: AbortSignal) => new Promise((resolve) => { const n = queue.shift(); if (n) { resolve({ audio: n }); return; } signal.addEventListener('abort', () => resolve({ audio: null, cancelled: true })); })), speak };
358
+ const c = createMeetingController({ client, io, config: {}, onHeal: (e) => heals.push(e) });
359
+ c.start();
360
+ await settle(() => (speak as any).mock.calls.length >= 1);
361
+ expect(c.state().lines.filter((l) => l.role === 'user')).toEqual([]);
362
+ expect(c.state().lines.some((l) => l.role === 'assistant' && /did not catch/.test(l.text))).toBe(true);
363
+ expect((speak as any).mock.calls.length).toBe(1);
364
+ expect(heals).toContain('no-words');
365
+ await c.end();
366
+ });
367
+ it('a quiet drop (no apology audio) is still logged', async () => {
368
+ const heals: string[] = [];
369
+ const client = { turn: vi.fn(async () => turnResult(1, { transcript: '', reply_text: 'Sorry', audio_url: null, audio_reason: 'nothing was heard' })), end: vi.fn() } as never;
370
+ const queue = [blob()];
371
+ const io: MeetingIO = { listen: vi.fn((signal: AbortSignal) => new Promise((resolve) => { const n = queue.shift(); if (n) { resolve({ audio: n }); return; } signal.addEventListener('abort', () => resolve({ audio: null, cancelled: true })); })), speak: vi.fn(async () => undefined) };
372
+ const c = createMeetingController({ client, io, config: {}, onHeal: (e) => heals.push(e) });
373
+ c.start();
374
+ await settle(() => heals.length > 0);
375
+ expect(heals).toContain('no-words-quiet');
376
+ await c.end();
377
+ });
378
+ });
379
+
351
380
  describe('a recording with no words', () => {
352
381
  it('is dropped quietly: no line, no reply spoken, and the meeting listens again', async () => {
353
382
  const { c, speak } = rig({ utterances: [blob()], turn: vi.fn(async () => turnResult(1, { transcript: '', reply_text: 'Sorry, I did not catch that. Can you say that again?', audio_url: null, audio_reason: 'nothing was heard' })) as never });
@@ -59,3 +59,31 @@ describe('a long drive (soak)', () => {
59
59
  }, 30_000);
60
60
  }
61
61
  });
62
+
63
+ describe('short answers in a row', () => {
64
+ it('20 consecutive short utterances ("yes") produce 20 turns, none dropped while thinking or speaking', async () => {
65
+ let n = 0; let utter = 0;
66
+ const client: MeetingApi<Blob> = {
67
+ async turn(input) { await sleep(8); const mine = ++n; return { conversation_id: 'c1', turn_id: input.turnId ?? `t${mine}`, turn: mine, transcript: 'Yes.', reply_text: `reply ${mine}`, audio_url: `/a/${mine}`, audio_reason: null } as never; },
68
+ async end() { return { saved: true as const, conversation_id: 'c1', record_id: '1', turns: n, asks: [], decisions: [] } as never; },
69
+ };
70
+ const io: MeetingIO<Blob> = {
71
+ duplex: true,
72
+ listen(signal, _c, hooks) {
73
+ return new Promise((resolve) => {
74
+ // He says "yes" every 20 ms regardless of what the assistant is doing (thinking, speaking).
75
+ const t = utter < 20 ? setTimeout(() => { utter += 1; hooks?.onSpeechStart?.(); resolve({ audio: new Blob([new Uint8Array([1])]) }); }, 20) : null;
76
+ signal.addEventListener('abort', () => { if (t) clearTimeout(t); resolve({ audio: null, cancelled: true }); }, { once: true });
77
+ });
78
+ },
79
+ speak: (_r, signal) => new Promise<void>((resolve) => { const t = setTimeout(resolve, 15); signal.addEventListener('abort', () => { clearTimeout(t); resolve(); }, { once: true }); }),
80
+ };
81
+ const c = createMeetingController({ client, io, config: {} });
82
+ c.start();
83
+ const t0 = Date.now();
84
+ while (n < 20 && Date.now() - t0 < 10_000) await sleep(20);
85
+ expect(n).toBe(20);
86
+ expect(c.state().lines.filter((l) => l.role === 'user').length).toBe(20);
87
+ await c.end();
88
+ }, 20_000);
89
+ });
@@ -375,7 +375,7 @@ describe('an audio turn', () => {
375
375
  expect(t.rows.size).toBe(0);
376
376
  });
377
377
 
378
- it('an empty transcript asks to repeat and does not call the brain', async () => {
378
+ it('an empty transcript of a SHORT clip (a cough, road noise) asks to repeat quietly and does not call the brain', async () => {
379
379
  const { deps, brain } = setup({ transcribe: async () => ' ' });
380
380
  const out = await handleConverseTurn(deps, { audio });
381
381
  expect(out.reply_text).toMatch(/did not catch/i);
@@ -383,6 +383,28 @@ describe('an audio turn', () => {
383
383
  expect(brain).not.toHaveBeenCalled();
384
384
  });
385
385
 
386
+ it('an empty transcript of a LONG clip (he really spoke) SPEAKS "did not catch that": a turn is never silent', async () => {
387
+ const { deps, brain, synthesize } = setup({ transcribe: async () => '' });
388
+ const out = await handleConverseTurn(deps, { audio: { audio: new Uint8Array(40_000), mimeType: 'audio/mp4' } });
389
+ expect(out.reply_text).toMatch(/did not catch/i);
390
+ expect(out.audio_url).not.toBeNull();
391
+ expect(synthesize).toHaveBeenCalledTimes(1);
392
+ expect(brain).not.toHaveBeenCalled();
393
+ });
394
+
395
+ it('sound-event tags are not words: "[singing] Yes. [singing]" is heard as "Yes."', async () => {
396
+ const { deps, brain } = setup({ transcribe: async () => '[singing] Yes. [singing]' });
397
+ await handleConverseTurn(deps, { audio });
398
+ expect(brain.mock.calls[0][0].utterance).toBe('Yes.');
399
+ });
400
+
401
+ it('a recording that is ONLY sound-event tags is heard as no words', async () => {
402
+ const { deps, brain } = setup({ transcribe: async () => '[music] [laughter]' });
403
+ const out = await handleConverseTurn(deps, { audio });
404
+ expect(out.transcript).toBe('');
405
+ expect(brain).not.toHaveBeenCalled();
406
+ });
407
+
386
408
  it('keeps the text when speech synthesis fails: audio_url is null', async () => {
387
409
  const { deps } = setup({ synthesize: async () => { throw new Error('tts down'); } });
388
410
  const out = await handleConverseTurn(deps, { text: 'hello' });
@@ -76,7 +76,7 @@ describe('the queue and the briefing', () => {
76
76
  expect(delivered).toEqual([{ id: 'prod-mail-poll', answer: 'yes', text: Q1.text }]);
77
77
  expect((await relayAnswers(deps))[0]).toMatchObject({ answered: true, answer: 'yes', delivered: true });
78
78
  // a second start finds nothing waiting
79
- expect((await run.start('conv-0002'))!.text).toBe('Nothing is waiting on you right now.');
79
+ expect((await run.start('conv-0002'))!.text).toBe('Nothing is waiting on you right now. Ask me what is in flight for a short status.');
80
80
  });
81
81
  it('a failing delivery does not lose the answer: it stays stored, marked undelivered, for the relay to read back', async () => {
82
82
  const { deps } = tenant();
@@ -11,7 +11,7 @@ export function importanceOf(item: AttentionItem, cls: AttentionClass, policy: A
11
11
  let score = BASE[cls];
12
12
  if (hits(policy.moneyPatterns, item.text)) score += w.money;
13
13
  if (hits(policy.outwardPatterns, item.text)) score += w.outward;
14
- if (item.source === 'decision' || hits(policy.onlyYouPatterns, item.text)) score += w.onlyYou;
14
+ if (item.source === 'decision' || item.source === 'org' || hits(policy.onlyYouPatterns, item.text)) score += w.onlyYou;
15
15
  // A digest line waits for the daily brief however much it touches; it never reaches the call-me threshold.
16
16
  return Math.min(score, cls === 'digest' ? Math.max(0, policy.callMeMinImportance - 1) : 95);
17
17
  }
@@ -1,6 +1,7 @@
1
1
  export * from './types';
2
2
  export { classifyItem, inQuietHours, isQuiet, type QuietMode, itemId, resolveAttentionPolicy } from './policy';
3
3
  export { buildNeedsYou } from './queue';
4
+ export { fetchOrgOverview, loadOrgItems, orgItems, ORGS_BASE_DEFAULT, type OrgItem, type OrgOverviewRow } from './orgs';
4
5
  export { importanceOf } from './importance';
5
6
  export { callMeTitle, runAttention, type AttentionPush } from './push';
6
7
  export { mergeAttention, policyFrom, settingsView, type AttentionSettings as AttentionSettingsValues, type StoredAttention } from './settings';
@@ -0,0 +1,41 @@
1
+ /**
2
+ * QuinnAI orgs as a needs-you source (bd startsim-nd3qa). Reads the QuinnAI coordinator's stable contract,
3
+ * GET <base>/api/orgs/overview -> { orgs: [{ name, status, live, waiting_on_you, hold, ... }] }, and turns each RUNNING org that
4
+ * has open asks or a hold for Quinn into one needs-you item linking to <base>/orgs. Stopped / stalled orgs are skipped.
5
+ * The endpoint is local: when it is down, slow or sends junk the source is simply empty, never an error.
6
+ */
7
+ export interface OrgOverviewRow { name: string; status: string; live: boolean; waiting_on_you: number; hold?: string | null }
8
+ export interface OrgItem { id: string; text: string; source: 'org'; from: string; link: string }
9
+
10
+ export const ORGS_BASE_DEFAULT = 'http://localhost:4370';
11
+ const clip = (s: string, n: number) => (s.length > n ? `${s.slice(0, n - 1).trimEnd()}…` : s);
12
+
13
+ export function orgItems(rows: unknown, base: string = ORGS_BASE_DEFAULT): OrgItem[] {
14
+ if (!Array.isArray(rows)) return [];
15
+ const out: OrgItem[] = [];
16
+ for (const r of rows as Array<Partial<OrgOverviewRow> | null>) {
17
+ if (!r || typeof r.name !== 'string' || !r.name) continue;
18
+ if (r.status !== 'running' || r.live !== true) continue;
19
+ const waiting = Number(r.waiting_on_you) || 0;
20
+ const hold = typeof r.hold === 'string' ? r.hold.replace(/\s+/g, ' ').trim() : '';
21
+ if (waiting <= 0 && !hold) continue;
22
+ const parts = [waiting > 0 ? `${waiting} waiting on you` : '', hold ? clip(hold, 160) : ''].filter(Boolean);
23
+ out.push({ id: `org:${r.name}`, text: `${r.name}: ${parts.join(' — ')}`, source: 'org', from: r.name, link: `${base.replace(/\/+$/, '')}/orgs` });
24
+ }
25
+ return out;
26
+ }
27
+
28
+ /** The overview rows, or [] on any failure (down, timeout, non-200, bad JSON). */
29
+ export async function fetchOrgOverview(base: string = ORGS_BASE_DEFAULT, fetchFn: typeof fetch = fetch, timeoutMs = 1500): Promise<OrgOverviewRow[]> {
30
+ try {
31
+ const res = await fetchFn(`${base.replace(/\/+$/, '')}/api/orgs/overview`, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(timeoutMs), cache: 'no-store' } as RequestInit);
32
+ if (!res.ok) return [];
33
+ const body = (await res.json()) as { orgs?: unknown };
34
+ return Array.isArray(body?.orgs) ? (body.orgs as OrgOverviewRow[]) : [];
35
+ } catch { return []; }
36
+ }
37
+
38
+ /** The deps' org source, never throwing. */
39
+ export async function loadOrgItems(deps: { orgs?: () => Promise<OrgItem[]> }): Promise<OrgItem[]> {
40
+ try { return (await deps.orgs?.()) ?? []; } catch { return []; }
41
+ }
@@ -17,6 +17,8 @@ export function classifyItem(item: AttentionItem, policy: AttentionPolicy): Atte
17
17
  const words = policy.urgentWords.map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).filter(Boolean).map((w) => `(^|[^\\w])${w}($|[^\\w])`);
18
18
  if (compile([...policy.urgentPatterns, ...words]).some((r) => r.test(item.text))) return 'urgent';
19
19
  if (compile(policy.noisePatterns).some((r) => r.test(item.text))) return 'noise';
20
+ // A running org waiting on him is a real ask however its hold is worded ("hold" is a digest word elsewhere).
21
+ if (item.source === 'org') return 'needs-answer';
20
22
  if (compile(policy.digestPatterns).some((r) => r.test(item.text))) return 'digest';
21
23
  if (item.source === 'decision') return 'needs-answer';
22
24
  return policy.notifyScope === 'decisions+fleet' ? 'needs-answer' : 'digest';
@@ -10,6 +10,7 @@ import { notify } from '../notify/handle';
10
10
  import type { NotifyDeps } from '../notify/types';
11
11
  import { isQuiet, itemId, resolveAttentionPolicy } from './policy';
12
12
  import { policyFrom } from './settings';
13
+ import { loadOrgItems } from './orgs';
13
14
  import { buildNeedsYou } from './queue';
14
15
  import { answerRoutine, sendBatches } from './rhythm';
15
16
  import type { AttentionPolicyInput, NeedsYouQueue, QueuedItem } from './types';
@@ -24,7 +25,7 @@ export async function runAttention(deps: NotifyDeps, input: { view: Pick<FleetVi
24
25
  const autoAnswered = await answerRoutine(deps, policy);
25
26
  const state = autoAnswered.length ? await loadState(deps) : first;
26
27
  const now = input.now ?? (deps.now ?? Date.now)();
27
- const queue = buildNeedsYou({ view: input.view, decisions: state.decisions, policy, answered: state.answered, relay: state.relay_items });
28
+ const queue = buildNeedsYou({ view: input.view, decisions: state.decisions, policy, answered: state.answered, relay: state.relay_items, orgs: await loadOrgItems(deps) });
28
29
  const pushed: AttentionPush[] = [];
29
30
 
30
31
  for (const it of queue.items.filter((i): i is QueuedItem => i.class === 'urgent')) {
@@ -1,6 +1,7 @@
1
1
  /** The "needs you" queue: the fleet's waiting-on-Quinn lines plus his pending decisions, classified. */
2
2
  import type { FleetView } from '../converse/fleet-view';
3
3
  import type { DecisionIndexRow, RelayItem } from '../notify/types';
4
+ import type { OrgItem } from './orgs';
4
5
  import { importanceOf } from './importance';
5
6
  import { classifyItem, itemId } from './policy';
6
7
  import type { AttentionClass, AttentionItem, AttentionPolicy, NeedsYouQueue, QueuedItem } from './types';
@@ -8,10 +9,11 @@ import type { AttentionClass, AttentionItem, AttentionPolicy, NeedsYouQueue, Que
8
9
  const ORDER: AttentionClass[] = ['urgent', 'needs-answer', 'digest', 'noise'];
9
10
  const clean = (s: string) => s.replace(/`|\*\*/g, '').replace(/\s+/g, ' ').trim();
10
11
 
11
- export function buildNeedsYou(input: { view: Pick<FleetView, 'waitingOnQuinn'> | null; decisions: DecisionIndexRow[]; policy: AttentionPolicy; /** Items already answered (by id): they leave the queue. */ answered?: Record<string, unknown>; /** Questions the relay posted for him (their own list, never touched by the fleet snapshot). */ relay?: RelayItem[] }): NeedsYouQueue {
12
+ export function buildNeedsYou(input: { view: Pick<FleetView, 'waitingOnQuinn'> | null; decisions: DecisionIndexRow[]; policy: AttentionPolicy; /** Items already answered (by id): they leave the queue. */ answered?: Record<string, unknown>; /** Questions the relay posted for him (their own list, never touched by the fleet snapshot). */ relay?: RelayItem[]; /** Running QuinnAI orgs with asks or a hold for him (see orgs.ts). */ orgs?: OrgItem[] }): NeedsYouQueue {
12
13
  type Raw = Omit<AttentionItem, 'id'> & { id?: string };
13
14
  const rawIn: Raw[] = [
14
15
  ...(input.relay ?? []).map((r) => ({ id: `relay:${r.id}`, text: clean(r.text), source: 'relay' as const, ...(r.options?.length ? { options: r.options } : {}), ...(r.source ? { from: r.source } : {}), ...(r.link ? { link: r.link } : {}) })),
16
+ ...(input.orgs ?? []).map((o) => ({ id: o.id, text: clean(o.text), source: 'org' as const, from: o.from, link: o.link })),
15
17
  ...input.decisions.filter((d) => d.status === 'pending').map((d) => ({ text: clean(d.title), source: 'decision' as const, ref: d.id })),
16
18
  ...(input.view?.waitingOnQuinn ?? []).map((t) => ({ text: clean(t), source: 'fleet' as const })),
17
19
  ];
@@ -45,7 +45,7 @@ const reply = (run: AttentionRunState, text: string, recorded?: RunReply['record
45
45
 
46
46
  export function startRun(input: { conversationId: string; items: RunItem[]; now: string }): { run: AttentionRunState; reply: RunReply } {
47
47
  const run: AttentionRunState = { conversation_id: input.conversationId, items: input.items, index: 0, answers: {}, skipped: [], status: input.items.length ? 'asking' : 'done', started_at: input.now };
48
- if (!input.items.length) return { run, reply: reply(run, 'Nothing is waiting on you right now.') };
48
+ if (!input.items.length) return { run, reply: reply(run, 'Nothing is waiting on you right now. Ask me what is in flight for a short status.') };
49
49
  const n = input.items.length;
50
50
  return { run, reply: reply(run, `${n === 1 ? 'One thing needs you.' : `${n} things need you, most important first.`} ${questionText(run)}`) };
51
51
  }
@@ -4,6 +4,7 @@ import { buildFleetView } from '../converse/fleet-view';
4
4
  import { answerDecision, getDecision } from '../notify/handle';
5
5
  import { loadState, saveState } from '../notify/state';
6
6
  import type { NotifyDeps } from '../notify/types';
7
+ import { loadOrgItems } from './orgs';
7
8
  import { buildNeedsYou } from './queue';
8
9
  import { startRun, stepRun, type RunReply } from './run-steps';
9
10
  import { policyFrom } from './settings';
@@ -18,16 +19,16 @@ export interface AttentionRunApi {
18
19
  /** What the relay is told when he answers one of its questions. */
19
20
  export interface RelayDelivery { id: string; text: string; answer: string; source?: string; link?: string }
20
21
 
21
- export function createAttentionRun(deps: Pick<NotifyDeps, 'http' | 'ownerSub' | 'now'>, opts: { batch?: number; /** Tells the relay his answer (the server runs the bridge). A failure keeps the answer stored for the relay to read back. */ deliverRelay?: (d: RelayDelivery) => Promise<void> } = {}): AttentionRunApi {
22
+ export function createAttentionRun(deps: Pick<NotifyDeps, 'http' | 'ownerSub' | 'now' | 'orgs'>, opts: { batch?: number; /** Tells the relay his answer (the server runs the bridge). A failure keeps the answer stored for the relay to read back. */ deliverRelay?: (d: RelayDelivery) => Promise<void> } = {}): AttentionRunApi {
22
23
  const nowIso = () => new Date((deps.now ?? Date.now)()).toISOString();
23
24
  return {
24
25
  async start(conversationId) {
25
26
  const state = await loadState(deps);
26
27
  const snap = await loadFleetSnapshot(deps as never).catch(() => null);
27
28
  const policy = policyFrom(state.attention);
28
- const queue = buildNeedsYou({ view: snap?.inputs ? buildFleetView(snap.inputs) : null, decisions: state.decisions, policy, answered: state.answered, relay: state.relay_items });
29
+ const queue = buildNeedsYou({ view: snap?.inputs ? buildFleetView(snap.inputs) : null, decisions: state.decisions, policy, answered: state.answered, relay: state.relay_items, orgs: await loadOrgItems(deps) });
29
30
  // Fleet lines are prose, not questions: they stay in the queue (and still drive pushes) but are never asked as yes/no. The relay posts real questions through relay-items, with options.
30
- const items = queue.items.filter((i) => i.source !== 'fleet' && (i.class === 'urgent' || i.class === 'needs-answer')).slice(0, opts.batch ?? policy.briefBatch).map((i) => ({ id: i.id, text: i.text, ...(i.ref ? { ref: i.ref } : {}), ...(i.options?.length ? { options: i.options } : {}) }));
31
+ const items = queue.items.filter((i) => i.source !== 'fleet' && i.source !== 'org' && (i.class === 'urgent' || i.class === 'needs-answer')).slice(0, opts.batch ?? policy.briefBatch).map((i) => ({ id: i.id, text: i.text, ...(i.ref ? { ref: i.ref } : {}), ...(i.options?.length ? { options: i.options } : {}) }));
31
32
  const { run, reply } = startRun({ conversationId, items, now: nowIso() });
32
33
  await saveState(deps as never, { ...state, attention_run: run });
33
34
  return reply;
@@ -4,7 +4,7 @@
4
4
  * approvals ping, self-answering routine questions) are fields here, never constants in the logic.
5
5
  */
6
6
  export type AttentionClass = 'urgent' | 'needs-answer' | 'digest' | 'noise';
7
- export type AttentionSource = 'fleet' | 'decision' | 'relay';
7
+ export type AttentionSource = 'fleet' | 'decision' | 'relay' | 'org';
8
8
 
9
9
  export interface AttentionItem { id: string; text: string; source: AttentionSource; /** The decision id, for an item that is a pending decision (opens its card). */ ref?: string; /** A relay item's choices ("schedule" or "manual"): asked as a choice, not yes/no. */ options?: string[]; /** Who asked, in plain words (a relay item's source project). */ from?: string; /** Where to look at it, when there is somewhere. */ link?: string }
10
10
  export interface QueuedItem extends AttentionItem { class: AttentionClass; /** 0-100; urgent 100. Orders the queue and gates call-me. */ importance: number }
@@ -32,6 +32,10 @@ function filedText(filed: string[], project?: string | null): string {
32
32
  const list = more > 0 ? `${titles.join(', ')}, and ${more} more` : titles.length <= 2 ? titles.join(' and ') : `${titles.slice(0, -1).join(', ')} and ${titles[titles.length - 1]}`;
33
33
  return `Filed the note${where} and ${filed.length} to-do${filed.length === 1 ? '' : 's'}: ${list}.`;
34
34
  }
35
+ /** A clip this big had real speech in it (about 3 s of AAC): when it comes back with no words, the apology is SPOKEN. Smaller is a cough or road noise: quiet. */
36
+ const SPEAK_NOT_HEARD_MIN_BYTES = 24_000;
37
+ /** The speech-to-text marks non-speech sounds like "[singing]" or "[music]": they are not words. */
38
+ const SOUND_TAGS = /\[[^\[\]]{1,40}\]/g;
35
39
  const NOT_HEARD = 'Sorry, I did not catch that. Can you say that again?';
36
40
  const BRAIN_FAILED = 'I am having trouble thinking right now. Your words are saved. Try again in a moment.';
37
41
 
@@ -91,7 +95,7 @@ export async function handleConverseTurn(deps: ConverseDeps, req: ConverseTurnRe
91
95
  if (req.audio && req.audio.audio.byteLength > 0) {
92
96
  if (!deps.transcribe) throw new ConverseError('Speech to text is not set up.', 503, 'transcription_unavailable');
93
97
  try {
94
- utterance = (await deps.transcribe({ audio: req.audio.audio, mimeType: req.audio.mimeType, hints })).trim();
98
+ utterance = (await deps.transcribe({ audio: req.audio.audio, mimeType: req.audio.mimeType, hints })).replace(SOUND_TAGS, ' ').replace(/\s+/g, ' ').trim();
95
99
  } catch (error) {
96
100
  if (error instanceof Error && /no speech providers|provider is not configured|not configured/i.test(error.message)) {
97
101
  throw new ConverseError('Voice is not set up on this server. You can type instead.', 503, 'speech_unavailable');
@@ -181,7 +185,8 @@ export async function handleConverseTurn(deps: ConverseDeps, req: ConverseTurnRe
181
185
  }
182
186
  lap('keep_user_audio');
183
187
  // Nothing was heard: the page stays quiet and listens again, so there is nothing to speak (the text is still kept).
184
- const assistant = req.audio && !utterance
188
+ const quietMiss = Boolean(req.audio && !utterance && req.audio.audio.byteLength < SPEAK_NOT_HEARD_MIN_BYTES);
189
+ const assistant = quietMiss
185
190
  ? { text: replyText, audio_reason: 'nothing was heard' }
186
191
  : await speakSide(deps, `${conversationId}-t${n}-reply`, replyText, spokenText ?? toSpoken(replyText, localDate(now, timeZone)) ?? undefined);
187
192
  lap('tts');
@@ -11,6 +11,12 @@ export interface MeetingConfig {
11
11
  maxUtteranceMs: number;
12
12
  /** Mic level (0..1 RMS) that counts as speech. */
13
13
  speechLevel: number;
14
+ /** Adaptive threshold: to START, the level must exceed the tracked background by this factor (never below `speechLevel`). */
15
+ startOverNoise: number;
16
+ /** To CONTINUE speaking, the level need only exceed the background by this factor. */
17
+ stayOverNoise: number;
18
+ /** The tracked background never counts as louder than this. */
19
+ noiseFloorMax: number;
14
20
  /** The level must hold this long to count as the start of speech. */
15
21
  speechStartMs: number;
16
22
  /** Speaking during Tandem's reply stops the reply and listens (barge-in). Acts only when the io is duplex (echo-cancelled mic). */
@@ -38,14 +44,14 @@ export interface MeetingConfig {
38
44
  }
39
45
 
40
46
  export const MEETING_DEFAULTS: MeetingConfig = {
41
- silenceMs: 1200, minUtteranceMs: 400, maxUtteranceMs: 60_000, speechLevel: 0.02, speechStartMs: 150, bargeInLevel: 0.08,
47
+ silenceMs: 850, minUtteranceMs: 250, maxUtteranceMs: 60_000, speechLevel: 0.02, speechStartMs: 150, bargeInLevel: 0.08, startOverNoise: 3, stayOverNoise: 1.6, noiseFloorMax: 0.05,
42
48
  interruptOnSpeech: true, idleRotateMs: 30_000, relayPollMs: 4000, resendMs: 3000,
43
49
  thinkingMaxMs: 25_000, speakingMaxMs: 120_000, listenStallMs: 15_000, watchdogTickMs: 1000, listenRetryMs: 1500, assistantName: 'Roci',
44
50
  };
45
51
 
46
52
  export function resolveMeetingConfig(over: Partial<MeetingConfig> = {}): MeetingConfig {
47
53
  const out: MeetingConfig = { ...MEETING_DEFAULTS };
48
- for (const key of ['silenceMs', 'minUtteranceMs', 'maxUtteranceMs', 'speechLevel', 'speechStartMs', 'bargeInLevel', 'idleRotateMs', 'relayPollMs', 'resendMs', 'thinkingMaxMs', 'speakingMaxMs', 'listenStallMs', 'watchdogTickMs', 'listenRetryMs'] as const) {
54
+ for (const key of ['silenceMs', 'minUtteranceMs', 'maxUtteranceMs', 'speechLevel', 'speechStartMs', 'bargeInLevel', 'startOverNoise', 'stayOverNoise', 'noiseFloorMax', 'idleRotateMs', 'relayPollMs', 'resendMs', 'thinkingMaxMs', 'speakingMaxMs', 'listenStallMs', 'watchdogTickMs', 'listenRetryMs'] as const) {
49
55
  const v = over[key];
50
56
  if (typeof v === 'number' && Number.isFinite(v) && v > 0) out[key] = v;
51
57
  }
@@ -212,10 +212,12 @@ export function createMeetingController<A = Blob>(options: {
212
212
  // A recording with no words in it (a cough, a pause, the room): no line, no "sorry", no sound. Listen again.
213
213
  if (input.audio && !(out.transcript ?? '').trim()) {
214
214
  set({ conversationId: out.conversation_id });
215
- return true;
215
+ // A turn is never silent when he really spoke: the server then sends a spoken "did not catch that", shown and played like any reply.
216
+ if (!out.audio_url) { wdLog('no-words-quiet', { turn: out.turn }); return true; }
217
+ wdLog('no-words', { turn: out.turn });
216
218
  }
217
- // A briefing turn the assistant began itself has no words from him: nothing is shown as his message.
218
- const hisWords = out.briefing && !out.transcript ? [] : [{ role: 'user' as const, text: normalizeAssistantName(out.transcript, config.assistantName) }];
219
+ // A briefing turn the assistant began itself, or a recording with no words, has no words from him: nothing is shown as his message.
220
+ const hisWords = !out.transcript ? [] : [{ role: 'user' as const, text: normalizeAssistantName(out.transcript, config.assistantName) }];
219
221
  set({
220
222
  conversationId: out.conversation_id,
221
223
  lines: [...s.lines, ...hisWords, { role: 'assistant', text: out.reply_text, ...(out.intent ? { intent: out.intent } : {}), ...(out.sources?.length ? { sources: out.sources } : {}) }],
@@ -4,7 +4,7 @@
4
4
  * POST /corpus/converse/end JSON {conversation_id}
5
5
  * GET /corpus/converse/<id>/turn/<n>/audio[?who=user] a turn's recording, to its owner only
6
6
  */
7
- import { buildNeedsYou, policyFrom } from '../attention';
7
+ import { buildNeedsYou, loadOrgItems, policyFrom } from '../attention';
8
8
  import { loadState } from '../notify/state';
9
9
  import { parseTodoSyncRecord } from './sync-health';
10
10
  import { isTimeZone } from '../spoken-time';
@@ -158,7 +158,7 @@ export async function converseFleetViewResponse(deps: ConverseDeps): Promise<Res
158
158
  const snap = await loadFleetSnapshot(deps);
159
159
  const view = snap?.inputs ? buildFleetView(snap.inputs) : null;
160
160
  const state = await loadState(deps);
161
- const needs_you = buildNeedsYou({ view, decisions: state.decisions, policy: policyFrom(state.attention), answered: state.answered, relay: state.relay_items });
161
+ const needs_you = buildNeedsYou({ view, decisions: state.decisions, policy: policyFrom(state.attention), answered: state.answered, relay: state.relay_items, orgs: await loadOrgItems(deps) });
162
162
  const body = snap
163
163
  ? { snapshot: { text: snap.text, updatedAt: snap.updatedAt, view, todoSync: parseTodoSyncRecord(snap.inputs?.todo_sync) }, needs_you }
164
164
  : { snapshot: null, needs_you };
@@ -214,6 +214,8 @@ export interface ConverseDeps {
214
214
  /** After End has saved: files the conversation like a voice note (under a project, asks as to-dos). Default: none. See ./handoff. */
215
215
  handoff?: (input: ConverseHandoffInput) => Promise<void | { project?: string | null }>;
216
216
  store?: ConversationStore;
217
+ /** Running QuinnAI orgs that need him, as needs-you items (best-effort; absent or failing means none). */
218
+ orgs?: () => Promise<import('../attention/orgs').OrgItem[]>;
217
219
  now?: () => number;
218
220
  newId?: () => string;
219
221
  /** How many earlier lines the brain sees. Default 24. */
@@ -20,13 +20,28 @@ export function createUtteranceDetector(config: Partial<MeetingConfig> = {}): Ut
20
20
  let loudSince: number | null = null;
21
21
  let startedAt: number | null = null;
22
22
  let lastVoiceAt = 0;
23
+ /** The background level (road, wind, music): follows quiet down fast and noise up slowly, so the thresholds ride above it. */
24
+ let floor: number | null = null;
23
25
 
24
26
  const reset = () => { loudSince = null; startedAt = null; lastVoiceAt = 0; };
27
+ const track = (level: number, speaking: boolean) => {
28
+ if (floor === null) { floor = Math.min(level, c.noiseFloorMax); return; }
29
+ const up = speaking ? 0.002 : 0.03;
30
+ floor = level < floor ? floor + (level - floor) * 0.3 : floor + (level - floor) * up;
31
+ floor = Math.min(Math.max(floor, 0.0005), c.noiseFloorMax);
32
+ };
25
33
 
26
34
  return {
27
35
  reset,
28
36
  feed(level, now) {
29
- const loud = level >= c.speechLevel;
37
+ // Adaptive: a voice must stand clear of the background to start, and only has to stay a little above it to continue.
38
+ if (floor === null) track(level, false); // the first sample calibrates the background
39
+ const f = floor ?? 0;
40
+ const startAt = Math.max(c.speechLevel, f * c.startOverNoise);
41
+ const stayAt = Math.max(c.speechLevel * 0.6, f * c.stayOverNoise);
42
+ const speaking = startedAt !== null;
43
+ const loud = level >= (speaking ? stayAt : startAt);
44
+ if (!loud || speaking) track(level, speaking);
30
45
  if (startedAt === null) {
31
46
  if (!loud) { loudSince = null; return null; }
32
47
  loudSince ??= now;
@@ -65,6 +65,8 @@ export interface NotifyDeps {
65
65
  sender?: PushSender;
66
66
  now?: () => number;
67
67
  newId?: () => string;
68
+ /** Running QuinnAI orgs that need him, as needs-you items. Optional and best-effort: absent or failing means none. */
69
+ orgs?: () => Promise<import('../attention/orgs').OrgItem[]>;
68
70
  }
69
71
 
70
72
  export class NotifyError extends Error {
@@ -150,7 +150,7 @@ function Root({ config, device, registry }: { config: FoundryAppConfig; device:
150
150
  const recordRef = useRef<ReactNode>(record);
151
151
  recordRef.current = record;
152
152
  const tabs = useMemo(
153
- () => buildFoundryTabs({ config: appConfig, corpus: data.corpus, notes: data.notes, record: () => recordRef.current, member: data.member, itemsChanged: services.briefing?.itemsChanged, briefing: services.briefing ? { controller: services.briefing.controller, reply: services.briefing.reply } : null, strings, converse: services.converse?.controller ?? null, converseSpeed: services.converse?.speed ?? null, notify: services.notify, openUrl: data.openUrl ?? ((url) => Linking.openURL(url)) }, registry),
153
+ () => buildFoundryTabs({ config: appConfig, corpus: data.corpus, notes: data.notes, record: () => recordRef.current, member: data.member, itemsChanged: services.briefing?.itemsChanged, briefing: services.briefing ? { controller: services.briefing.controller, reply: services.briefing.reply } : null, strings, converse: services.converse?.controller ?? null, converseSpeed: services.converse?.speed ?? null, converseDrive: services.converse?.drive ?? null, startInDrive: launch.drive, notify: services.notify, openUrl: data.openUrl ?? ((url) => Linking.openURL(url)) }, registry),
154
154
  [appConfig, data, registry],
155
155
  );
156
156