@startsimpli/integrations 0.2.179 → 0.2.181
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/__tests__/converse-handoff.test.ts +129 -0
- package/src/__tests__/converse-meeting.test.ts +41 -0
- package/src/__tests__/converse-relay.test.ts +19 -3
- package/src/__tests__/corpus-ask-projects.test.ts +74 -0
- package/src/__tests__/home-brief.test.tsx +12 -24
- package/src/__tests__/home-needs-your-call.test.tsx +13 -16
- package/src/__tests__/library-asks-line.test.ts +27 -0
- package/src/__tests__/plan-shell.test.tsx +160 -0
- package/src/components/DocumentDetail.tsx +15 -4
- package/src/components/documentText.ts +33 -0
- package/src/components/index.ts +1 -0
- package/src/components/pages/AskPage.tsx +9 -1
- package/src/components/pages/LibraryPage.tsx +4 -0
- package/src/components/pages/PlanningPage.tsx +20 -10
- package/src/components/pages/TrackerPage.tsx +16 -3
- package/src/components/pages/home/DueSoonLine.tsx +28 -0
- package/src/components/pages/home/HomeBriefPage.tsx +19 -52
- package/src/components/pages/home/index.ts +1 -3
- package/src/components/pages/plan/ProjectsPage.tsx +54 -0
- package/src/components/pages/plan/TalkPage.tsx +48 -0
- package/src/components/pages/plan/TimelinePage.tsx +33 -0
- package/src/components/pages/plan/index.ts +6 -0
- package/src/corpus/ask-projects.ts +94 -0
- package/src/corpus/ask.ts +21 -2
- package/src/corpus/converse/handle.ts +10 -3
- package/src/corpus/converse/handled-asks.ts +29 -0
- package/src/corpus/converse/handoff.ts +52 -0
- package/src/corpus/converse/index.ts +4 -2
- package/src/corpus/converse/meeting.ts +23 -7
- package/src/corpus/converse/relay.ts +8 -4
- package/src/corpus/converse/store.ts +2 -0
- package/src/corpus/converse/transcript.ts +9 -0
- package/src/corpus/converse/types.ts +14 -0
- package/src/corpus/index.ts +5 -0
- package/src/corpus/nav-copy.ts +31 -0
- package/src/corpus/view-text.ts +3 -2
- package/src/native/__tests__/design-screens.test.tsx +3 -2
- package/src/native/app/FoundryApp.tsx +1 -1
- package/src/native/app/__tests__/plan-talk-registry.test.tsx +74 -0
- package/src/native/app/briefingServices.ts +1 -0
- package/src/native/app/config/defaults.ts +8 -2
- package/src/native/app/config/types.ts +1 -1
- package/src/native/app/converseServices.ts +1 -0
- package/src/native/app/registry.tsx +26 -6
- package/src/native/app/services.ts +3 -2
- package/src/native/components/NoteDetailScreen.tsx +16 -4
- package/src/native/components/__tests__/notes-screens.test.tsx +8 -8
- package/src/native/converse/ConverseScreen.tsx +24 -5
- package/src/native/converse/__tests__/liveScreen.test.tsx +15 -2
- package/src/native/home/HomeScreen.tsx +20 -7
- package/src/native/home/controller.ts +15 -5
- package/src/native/home/tab.tsx +31 -6
- package/src/native/plan/NewProjectRow.tsx +30 -0
- package/src/native/plan/PlanTab.tsx +105 -0
- package/src/native/plan/ProjectTodos.tsx +24 -0
- package/src/native/plan/TimelineScreen.tsx +68 -0
- package/src/native/plan/__tests__/plan-tab.test.tsx +76 -0
- package/src/native/plan/index.ts +5 -0
- package/src/native/plan/timeline.ts +56 -0
- package/src/native/recording/__tests__/recorderAudio.test.ts +10 -2
- package/src/native/recording/recorderAudio.ts +6 -2
- package/src/native/screens/__tests__/tabs.test.tsx +13 -0
- package/src/native/screens/ask/AskScreen.tsx +4 -2
- package/src/native/screens/library/LibraryDetailScreen.tsx +11 -4
- package/src/native/screens/planning/PlanningScreens.tsx +30 -13
- package/src/native/screens/tabs.tsx +5 -4
- package/src/native/talk/TalkTab.tsx +65 -0
- package/src/native/talk/__tests__/talk-tab.test.tsx +57 -0
- package/src/native/tracker/TrackerListScreen.tsx +7 -3
- package/src/native/tracker/tab.tsx +33 -8
- package/src/components/pages/home/DueAcrossProjects.tsx +0 -76
- package/src/components/pages/home/RecentNotes.tsx +0 -69
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* PLAN > TIMELINE: what was created, finished and overdue over time, with the to-dos
|
|
5
|
+
* behind the numbers in a table. The same strip the tracker used to carry under its
|
|
6
|
+
* list, mounted on its own so the To-dos sub-tab is only the working list.
|
|
7
|
+
*/
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
|
|
10
|
+
import type { CommitmentTrackerApi, CorpusScope } from '../../../corpus/types';
|
|
11
|
+
import { TrackerTimeline } from '../tracker/TrackerTimeline';
|
|
12
|
+
|
|
13
|
+
const NO_FILTER = {};
|
|
14
|
+
|
|
15
|
+
export interface TimelinePageProps {
|
|
16
|
+
api: Pick<CommitmentTrackerApi, 'timeline'>;
|
|
17
|
+
scope: CorpusScope;
|
|
18
|
+
/** Injectable clock. Frozen once when absent, for the reason spelled out on `TrackerPageProps.now`. */
|
|
19
|
+
now?: number;
|
|
20
|
+
timeZone?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function TimelinePage({ api, scope, now, timeZone, className }: TimelinePageProps) {
|
|
25
|
+
const [mountedAt] = React.useState(() => Date.now());
|
|
26
|
+
if (!api.timeline) return <p className="text-sm text-gray-500">The timeline is not available in this workspace.</p>;
|
|
27
|
+
return (
|
|
28
|
+
<TrackerTimeline
|
|
29
|
+
api={api} orgId={scope.orgId} now={now ?? mountedAt} timeZone={timeZone}
|
|
30
|
+
filter={NO_FILTER} className={className}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { TimelinePage } from './TimelinePage';
|
|
2
|
+
export type { TimelinePageProps } from './TimelinePage';
|
|
3
|
+
export { ProjectsPage } from './ProjectsPage';
|
|
4
|
+
export type { ProjectsPageProps } from './ProjectsPage';
|
|
5
|
+
export { TalkPage } from './TalkPage';
|
|
6
|
+
export type { TalkPageProps } from './TalkPage';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projects (focuses, goals) as ANSWERABLE, CITABLE records, the way tracked items are (bd startsim-tmrvi).
|
|
3
|
+
*
|
|
4
|
+
* Ask used to retrieve documents only. "What projects are active?" therefore searched a workspace's briefings and
|
|
5
|
+
* conversations for the word "projects" and answered "none of them matched" while 64 projects existed (live QA
|
|
6
|
+
* tenant, 2026-11-16). A project question is a question about states, which a keyword ranker over documents cannot
|
|
7
|
+
* answer: the projects are selected by status here, in code, and the model only phrases what it was handed.
|
|
8
|
+
* The id is `project:<id>`, which can never collide with a document or an `item:` id.
|
|
9
|
+
*/
|
|
10
|
+
import { displayProgress, focusStatusLabel } from './planning';
|
|
11
|
+
import { isInScope } from './retrieval';
|
|
12
|
+
import type { CorpusScope, Focus, FocusStatus, PlanningApi, RetrievedDocument, SourceDocument } from './types';
|
|
13
|
+
|
|
14
|
+
export const PROJECT_ID_PREFIX = 'project:';
|
|
15
|
+
/** The project id behind a cited record id, or null when it is a document or an item. */
|
|
16
|
+
export const projectIdOf = (documentId: string): string | null =>
|
|
17
|
+
documentId.startsWith(PROJECT_ID_PREFIX) ? documentId.slice(PROJECT_ID_PREFIX.length) : null;
|
|
18
|
+
export const PROJECT_SUBTYPE = 'project';
|
|
19
|
+
|
|
20
|
+
const PROJECT_WORDS = /\b(projects?|goals?|initiatives?|objectives?|okrs?)\b/i;
|
|
21
|
+
const IN_PLAY: FocusStatus[] = ['active', 'on_track', 'at_risk', 'off_track'];
|
|
22
|
+
const NOT_CANCELLED: FocusStatus[] = ['draft', 'active', 'on_track', 'at_risk', 'off_track', 'completed'];
|
|
23
|
+
|
|
24
|
+
export interface ProjectIntent { statuses: FocusStatus[] }
|
|
25
|
+
|
|
26
|
+
/** The intent, or null when the question is not about projects or goals at all. */
|
|
27
|
+
export function projectIntent(question: string): ProjectIntent | null {
|
|
28
|
+
const q = question.toLowerCase();
|
|
29
|
+
if (!PROJECT_WORDS.test(q)) return null;
|
|
30
|
+
let statuses: FocusStatus[] = NOT_CANCELLED;
|
|
31
|
+
if (/\bat[\s-]risk\b/.test(q)) statuses = ['at_risk'];
|
|
32
|
+
else if (/\boff[\s-]track\b|\bbehind\b|\bslipping\b/.test(q)) statuses = ['off_track'];
|
|
33
|
+
else if (/\bon[\s-]track\b/.test(q)) statuses = ['on_track'];
|
|
34
|
+
else if (/\bdraft(?:s|ed)?\b|\bplanned\b|\bnot started\b/.test(q)) statuses = ['draft'];
|
|
35
|
+
else if (/\b(complete[d]?|finish(?:ed)?|done|achieved|shipped)\b/.test(q)) statuses = ['completed'];
|
|
36
|
+
else if (/\b(cancel(?:l)?ed|dropped|abandoned)\b/.test(q)) statuses = ['cancelled'];
|
|
37
|
+
else if (/\b(active|current(?:ly)?|open|in progress|running|live|underway|ongoing)\b/.test(q)) statuses = IN_PLAY;
|
|
38
|
+
return { statuses };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** One project as a record the model can read and the screen can cite. */
|
|
42
|
+
export function projectAsDocument(focus: Focus): SourceDocument {
|
|
43
|
+
const progress = displayProgress(focus, null);
|
|
44
|
+
const lines = [
|
|
45
|
+
`Status: ${focusStatusLabel(focus.status)}`,
|
|
46
|
+
// "Active" in a question means in play: on track, at risk and off track projects are all active.
|
|
47
|
+
`Active (in play): ${IN_PLAY.includes(focus.status) ? 'yes' : 'no'}`,
|
|
48
|
+
focus.category ? `Category: ${focus.category}` : '',
|
|
49
|
+
focus.endDate ? `Due: ${focus.endDate.slice(0, 10)}` : '',
|
|
50
|
+
progress !== null && progress !== undefined ? `Progress: ${Math.round(progress * 100)}%` : '',
|
|
51
|
+
focus.targetValue ? `Target: ${focus.currentValue ?? 0} of ${focus.targetValue}${focus.unit ? ` ${focus.unit}` : ''}` : '',
|
|
52
|
+
focus.detail ? `Detail: ${focus.detail}` : '',
|
|
53
|
+
].filter(Boolean);
|
|
54
|
+
return {
|
|
55
|
+
id: `${PROJECT_ID_PREFIX}${focus.id}`,
|
|
56
|
+
title: focus.title,
|
|
57
|
+
body: lines.join('\n'),
|
|
58
|
+
sections: [],
|
|
59
|
+
occurredAt: focus.startDate ?? null,
|
|
60
|
+
source: 'planning',
|
|
61
|
+
sourceLabel: 'Project',
|
|
62
|
+
subtype: PROJECT_SUBTYPE,
|
|
63
|
+
sourceRef: focus.id,
|
|
64
|
+
participants: [],
|
|
65
|
+
scope: focus.scope,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Which of `focuses` the intent asks about, in the order worth reading. Pure. */
|
|
70
|
+
export function selectProjects(focuses: Focus[], intent: ProjectIntent): Focus[] {
|
|
71
|
+
const wanted = new Set(intent.statuses);
|
|
72
|
+
return focuses
|
|
73
|
+
.filter((f) => wanted.has(f.status))
|
|
74
|
+
.sort((a, b) => a.title.localeCompare(b.title));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Projects for a question: read, scope-check, select, convert. Empty when it is not a project question. */
|
|
78
|
+
export async function retrieveProjects(
|
|
79
|
+
question: string,
|
|
80
|
+
api: Pick<PlanningApi, 'listFocuses'> | undefined,
|
|
81
|
+
scope: CorpusScope,
|
|
82
|
+
limit: number,
|
|
83
|
+
): Promise<{ intent: ProjectIntent | null; retrieved: RetrievedDocument[]; matched: number }> {
|
|
84
|
+
const intent = projectIntent(question);
|
|
85
|
+
if (!intent || !api) return { intent: null, retrieved: [], matched: 0 };
|
|
86
|
+
const page = await api.listFocuses({ pageSize: 200 }).catch(() => null);
|
|
87
|
+
if (!page) return { intent, retrieved: [], matched: 0 };
|
|
88
|
+
const selected = selectProjects(page.results.filter((f) => isInScope(f, scope)), intent);
|
|
89
|
+
const retrieved = selected.slice(0, limit).map((focus): RetrievedDocument => {
|
|
90
|
+
const document = projectAsDocument(focus);
|
|
91
|
+
return { document, score: 1, matchedTerms: [], snippet: document.body.split('\n').slice(0, 2).join(' · ') };
|
|
92
|
+
});
|
|
93
|
+
return { intent, retrieved, matched: selected.length };
|
|
94
|
+
}
|
package/src/corpus/ask.ts
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* given has invented a source, and the only safe rendering of that is to say so.
|
|
20
20
|
*/
|
|
21
21
|
import { retrieveItems } from './ask-items';
|
|
22
|
+
import { retrieveProjects } from './ask-projects';
|
|
22
23
|
import { moneyEventAsDocument } from './entities';
|
|
23
24
|
import { retrieveForQuestion, searchTermFor } from './retrieval';
|
|
24
25
|
import { documentText } from './text';
|
|
@@ -30,6 +31,7 @@ import type {
|
|
|
30
31
|
CommitmentApi,
|
|
31
32
|
CorpusApi,
|
|
32
33
|
CorpusLlm,
|
|
34
|
+
PlanningApi,
|
|
33
35
|
PromptDocument,
|
|
34
36
|
RetrievedDocument,
|
|
35
37
|
SourceDocument,
|
|
@@ -349,7 +351,7 @@ function noEvidenceCopy(total: number): string {
|
|
|
349
351
|
*/
|
|
350
352
|
export async function askCorpus(
|
|
351
353
|
request: AskRequest,
|
|
352
|
-
deps: { corpus: CorpusApi; llm: CorpusLlm; commitments?: Pick<CommitmentApi, 'listCommitments'> },
|
|
354
|
+
deps: { corpus: CorpusApi; llm: CorpusLlm; commitments?: Pick<CommitmentApi, 'listCommitments'>; /** Lets a project or goal question be answered from the projects themselves. */ projects?: Pick<PlanningApi, 'listFocuses'> },
|
|
353
355
|
options: AskCorpusOptions = {},
|
|
354
356
|
): Promise<AskResult> {
|
|
355
357
|
const { candidateLimit, contextLimit, maxCharsPerDocument, itemLimit } = { ...DEFAULTS, ...options };
|
|
@@ -384,10 +386,27 @@ export async function askCorpus(
|
|
|
384
386
|
itemLimit,
|
|
385
387
|
)
|
|
386
388
|
: { intent: null, retrieved: [], matched: 0 };
|
|
387
|
-
|
|
389
|
+
// PROJECTS, the same way: a question about them is answered from their status, not from document text.
|
|
390
|
+
const projectHits = request.mode === 'ask'
|
|
391
|
+
? await retrieveProjects(request.question, deps.projects, request.scope, itemLimit)
|
|
392
|
+
: { intent: null, retrieved: [], matched: 0 };
|
|
393
|
+
const retrieved = [...items.retrieved, ...projectHits.retrieved, ...documents];
|
|
388
394
|
|
|
389
395
|
const freshness = await corpus.listSources().catch(() => [] as SourceFreshness[]);
|
|
390
396
|
|
|
397
|
+
if (retrieved.length === 0 && projectHits.intent && deps.projects) {
|
|
398
|
+
return {
|
|
399
|
+
status: 'no_evidence',
|
|
400
|
+
answer: 'No projects match that, and no documents do either.',
|
|
401
|
+
citations: [],
|
|
402
|
+
considered: [],
|
|
403
|
+
unresolvedCitations: [],
|
|
404
|
+
droppedOutOfScope,
|
|
405
|
+
provider: llm.describe(),
|
|
406
|
+
freshness,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
391
410
|
if (retrieved.length === 0 && items.intent && deps.commitments) {
|
|
392
411
|
return {
|
|
393
412
|
status: 'no_evidence',
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* gets a sentence saying so and the conversation goes on. Request-free so a Next route, a worker and a test
|
|
9
9
|
* all call the same thing.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { unhandledAsks } from './handled-asks';
|
|
12
|
+
import { renderNextSteps, renderTranscript, titleFor } from './transcript';
|
|
12
13
|
import { createEntityConversationStore } from './store';
|
|
13
14
|
import { speakSide } from './speak';
|
|
14
15
|
import { addRelayOrder } from './relay-inbox';
|
|
@@ -118,7 +119,7 @@ export async function handleConverseTurn(deps: ConverseDeps, req: ConverseTurnRe
|
|
|
118
119
|
return resultOf(conversationId, turn);
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
/** End: finish the record, write the transcript as its document body, pull out asks and decisions. Idempotent. */
|
|
122
|
+
/** End: finish the record, write the transcript as its document body, pull out asks and decisions, then file it (project + to-dos). Idempotent. */
|
|
122
123
|
export async function handleConverseEnd(deps: ConverseDeps, req: { conversationId: string }): Promise<ConverseEndResult> {
|
|
123
124
|
if (!CLIENT_ID.test(req.conversationId ?? '')) throw new ConverseError('Say which conversation to end.', 400);
|
|
124
125
|
const store = deps.store ?? createEntityConversationStore(deps.http, deps.ownerSub);
|
|
@@ -140,5 +141,11 @@ export async function handleConverseEnd(deps: ConverseDeps, req: { conversationI
|
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
const withAsks = { ...base, asks, decisions };
|
|
143
|
-
|
|
144
|
+
// An ask the assistant already added as a to-do during the conversation is not filed again by the extraction.
|
|
145
|
+
const open = unhandledAsks(asks, record.turns);
|
|
146
|
+
const summary = renderNextSteps(open);
|
|
147
|
+
const saved = await store.save({ ...withAsks, body: renderTranscript(withAsks), ...(summary ? { summary } : {}) });
|
|
148
|
+
// Filed like a voice note: under a project, and each ask a to-do. The transcript is already kept, so this never fails End.
|
|
149
|
+
if (deps.handoff) await deps.handoff({ record: saved, asks: open, decisions }).catch((error) => console.error('[converse] handoff failed (conversation kept)', error));
|
|
150
|
+
return done(saved);
|
|
144
151
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asks the assistant already acted on while the conversation ran. A typed or spoken "call the landlord" is answered with
|
|
3
|
+
* "Added Call the landlord ..." and the to-do exists; End's extraction then reads the same words again and would file a
|
|
4
|
+
* second copy. A turn's `did` lines say what was added; an ask that matches one is already a to-do.
|
|
5
|
+
*/
|
|
6
|
+
import type { ConverseTurn } from './types';
|
|
7
|
+
|
|
8
|
+
const STOP = new Set(['a', 'an', 'the', 'to', 'for', 'by', 'of', 'on', 'in', 'and', 'me', 'my', 'i', 'it']);
|
|
9
|
+
const words = (text: string): string[] => text.toLowerCase().replace(/[^a-z0-9\s]/g, ' ').split(/\s+/).filter((w) => w && !STOP.has(w));
|
|
10
|
+
|
|
11
|
+
/** The titles of to-dos the assistant added, read off its spoken `did` lines. */
|
|
12
|
+
function addedTitles(turns: ConverseTurn[]): string[][] {
|
|
13
|
+
return turns.flatMap((t) => t.did ?? []).filter((d) => /^added\s/i.test(d)).map((d) => words(d.replace(/^added\s+/i, '')));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The asks that are NOT already a to-do: an ask is handled when it is mostly the added title, or nearly all of that title is in it. */
|
|
17
|
+
export function unhandledAsks(asks: string[], turns: ConverseTurn[]): string[] {
|
|
18
|
+
const added = addedTitles(turns);
|
|
19
|
+
if (!added.length) return asks;
|
|
20
|
+
return asks.filter((ask) => {
|
|
21
|
+
const a = new Set(words(ask));
|
|
22
|
+
return !added.some((title) => {
|
|
23
|
+
if (!title.length || !a.size) return false;
|
|
24
|
+
const shared = title.filter((w) => a.has(w)).length;
|
|
25
|
+
// The spoken line adds a date word or two to the title ('... for Monday the twenty-third'), so mostly-contained either way counts.
|
|
26
|
+
return shared / a.size >= 0.75 || (shared / title.length >= 0.7 && shared / a.size >= 0.5);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHAT END DOES WITH A FINISHED CONVERSATION: the same two things a recorded voice note gets.
|
|
3
|
+
*
|
|
4
|
+
* 1. FILED UNDER A PROJECT, as an `about_focus` edge (corpus/filing). The model only chooses from the
|
|
5
|
+
* projects it is given (the voice analyzer, reused as is); no project fits or no model = unfiled.
|
|
6
|
+
* 2. EACH ASK A TO-DO: the saved record's `## Next steps` summary is read by the same extraction a voice
|
|
7
|
+
* note goes through, so the rows land in the Tracker, Planning and the iOS To-dos tab like any other.
|
|
8
|
+
*
|
|
9
|
+
* Both are best-effort and independent: one failing leaves the other and the saved transcript alone.
|
|
10
|
+
* Seams are injected (analyzer, focus list, extraction), so the app supplies its keys and this stays pure.
|
|
11
|
+
*/
|
|
12
|
+
import type { CorpusHttp } from '../client';
|
|
13
|
+
import { fileDocument } from '../filing';
|
|
14
|
+
import type { FocusChoice } from '../filing';
|
|
15
|
+
import type { VoiceAnalyzer } from '../voice';
|
|
16
|
+
import type { ConverseHandoffInput } from './types';
|
|
17
|
+
|
|
18
|
+
export interface ConverseHandoffDeps {
|
|
19
|
+
http: CorpusHttp;
|
|
20
|
+
analyzer: VoiceAnalyzer | null;
|
|
21
|
+
listFocuses: () => Promise<FocusChoice[]>;
|
|
22
|
+
/** Runs the to-do extraction over just this document (the app's `extractCommitments`). */
|
|
23
|
+
extractTodos: (documentId: string) => Promise<unknown>;
|
|
24
|
+
now?: () => number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function createConverseHandoff(deps: ConverseHandoffDeps) {
|
|
28
|
+
return async ({ record, asks }: ConverseHandoffInput): Promise<void> => {
|
|
29
|
+
const transcript = record.body ?? '';
|
|
30
|
+
if (deps.analyzer && transcript) {
|
|
31
|
+
try {
|
|
32
|
+
const focuses = await deps.listFocuses();
|
|
33
|
+
if (focuses.length) {
|
|
34
|
+
const analysis = await deps.analyzer.analyze({
|
|
35
|
+
transcript, focuses, now: deps.now?.() ?? Date.parse(record.startedAt), ...(record.timeZone ? { timeZone: record.timeZone } : {}),
|
|
36
|
+
});
|
|
37
|
+
// Only an id from the offered list files anything.
|
|
38
|
+
if (analysis.focusId && focuses.some((f) => f.id === analysis.focusId)) await fileDocument(deps.http, record.id, analysis.focusId);
|
|
39
|
+
}
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('[converse] filing under a project failed (conversation kept)', error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (asks.length) {
|
|
45
|
+
try {
|
|
46
|
+
await deps.extractTodos(record.id);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('[converse] to-do extraction failed (conversation kept)', error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -5,10 +5,10 @@ export { addRelayOrder, loadRelayOrders, clearRelayOrders, relayInboxExternalId
|
|
|
5
5
|
export type { RelayOrder } from './relay-inbox';
|
|
6
6
|
export type { RelayReplyResult } from './relay';
|
|
7
7
|
export { createEntityConversationStore, conversationExternalId } from './store';
|
|
8
|
-
export { renderTranscript, titleFor } from './transcript';
|
|
8
|
+
export { renderNextSteps, renderTranscript, titleFor } from './transcript';
|
|
9
9
|
export { ConverseError, CONVERSATION_SOURCE, turnAudioPath } from './types';
|
|
10
10
|
export type {
|
|
11
|
-
ConversationRecord, ConversationStore, ConverseBrain, ConverseBrainInput, ConverseBrainOutput, ConverseDeps, ConverseEndResult,
|
|
11
|
+
ConversationRecord, ConversationStore, ConverseBrain, ConverseBrainInput, ConverseBrainOutput, ConverseDeps, ConverseEndResult, ConverseHandoffInput,
|
|
12
12
|
ConverseThread, ConverseThreadTurn, ConverseTurn, ConverseTurnRequest, ConverseTurnResult, HistoryLine,
|
|
13
13
|
} from './types';
|
|
14
14
|
export { createConverseBrain, questionWithHistory, speakableAnswer } from './brain';
|
|
@@ -17,6 +17,8 @@ export { createConverseClient, ConverseClientError } from './client';
|
|
|
17
17
|
export type { ConverseClient } from './client';
|
|
18
18
|
export { converseEnv } from './config';
|
|
19
19
|
export { createConverseExtractor, parseExtract } from './extract';
|
|
20
|
+
export { createConverseHandoff } from './handoff';
|
|
21
|
+
export type { ConverseHandoffDeps } from './handoff';
|
|
20
22
|
export type { ConverseExtract } from './extract';
|
|
21
23
|
export { CANNOT_SEE } from './brain';
|
|
22
24
|
export { MEETING_DEFAULTS, resolveMeetingConfig } from './meeting-config';
|
|
@@ -115,7 +115,8 @@ export function createMeetingController<A = Blob>(options: {
|
|
|
115
115
|
});
|
|
116
116
|
if (out.audio_url) {
|
|
117
117
|
lastReply = { conversationId: out.conversation_id, turn: out.turn, replyText: out.reply_text, audioUrl: out.audio_url };
|
|
118
|
-
|
|
118
|
+
// A typed message speaks its reply even before Start: the person asked in text, but the screen is a voice one.
|
|
119
|
+
if (running || input.text) await playReply(lastReply);
|
|
119
120
|
} else {
|
|
120
121
|
lastReply = null;
|
|
121
122
|
set({ noAudio: out.audio_reason ?? 'no audio was produced' });
|
|
@@ -211,15 +212,30 @@ export function createMeetingController<A = Blob>(options: {
|
|
|
211
212
|
async sendText(text) {
|
|
212
213
|
const t = text.trim();
|
|
213
214
|
if (!t) return;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
// The microphone is still open here: stop listening before the reply plays (a phone cannot record and play in one session),
|
|
216
|
+
// and hold the loop (`gate`) until the reply is done, exactly like a relay message.
|
|
217
|
+
const done = turnChain.then(async () => {
|
|
218
|
+
if (running) listenAbort.abort();
|
|
219
|
+
await takeTurn({ text: t });
|
|
220
|
+
if (running && s.phase !== 'stopped') set({ phase: 'listening' });
|
|
221
|
+
else if (!running && (s.phase === 'thinking' || s.phase === 'speaking')) set({ phase: 'idle' });
|
|
222
|
+
});
|
|
223
|
+
gate = done.catch(() => undefined);
|
|
224
|
+
turnChain = gate;
|
|
225
|
+
await done;
|
|
218
226
|
},
|
|
219
227
|
dismissNotice() { set({ relayNotice: null }); },
|
|
220
228
|
async replay() {
|
|
221
|
-
if (lastReply)
|
|
222
|
-
|
|
229
|
+
if (!lastReply) return;
|
|
230
|
+
const reply = lastReply;
|
|
231
|
+
const done = turnChain.then(async () => {
|
|
232
|
+
if (running) listenAbort.abort();
|
|
233
|
+
await playReply(reply);
|
|
234
|
+
if (running) set({ phase: 'listening' });
|
|
235
|
+
});
|
|
236
|
+
gate = done.catch(() => undefined);
|
|
237
|
+
turnChain = gate;
|
|
238
|
+
await done;
|
|
223
239
|
},
|
|
224
240
|
async end() {
|
|
225
241
|
running = false;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Both run as the person (their bearer), so a relay holding a token for the person's account reaches exactly their
|
|
8
8
|
* own conversations. A reply is a turn like any other: it is spoken (the recording is kept), saved, and numbered.
|
|
9
|
-
* `reply_id` makes a resend of the same message a no-op.
|
|
9
|
+
* `reply_id` makes a resend of the same message a no-op. A reply to a conversation the person has already ended is still
|
|
10
|
+
* delivered: it is appended to the thread (the conversation stays ended), and `onRelayReplyAfterEnd` lets the app tell them.
|
|
10
11
|
*/
|
|
11
12
|
import { createEntityConversationStore } from './store';
|
|
12
13
|
import { speakSide } from './speak';
|
|
@@ -25,6 +26,8 @@ export interface RelayReplyResult {
|
|
|
25
26
|
reply_text: string;
|
|
26
27
|
audio_url: string | null;
|
|
27
28
|
audio_reason: string | null;
|
|
29
|
+
/** True when the conversation had already ended: the person is told by push rather than seeing it arrive live. */
|
|
30
|
+
after_end?: boolean;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
const resultOf = (id: string, t: ConverseTurn): RelayReplyResult => ({
|
|
@@ -45,7 +48,6 @@ export async function handleRelayReply(
|
|
|
45
48
|
const store = deps.store ?? createEntityConversationStore(deps.http, deps.ownerSub);
|
|
46
49
|
const record = await store.get(req.conversationId);
|
|
47
50
|
if (!record) throw new ConverseError('Not found.', 404);
|
|
48
|
-
if (record.status === 'ended') throw new ConverseError('That conversation has ended.', 409, 'ended');
|
|
49
51
|
const again = req.replyId ? record.turns.find((t) => t.turn_id === req.replyId) : undefined;
|
|
50
52
|
if (again) return resultOf(record.conversationId, again);
|
|
51
53
|
|
|
@@ -57,10 +59,12 @@ export async function handleRelayReply(
|
|
|
57
59
|
const turn: ConverseTurn = { n, turn_id: turnId, at: new Date(now).toISOString(), from: 'relay', user: { text: '' }, assistant };
|
|
58
60
|
await store.save({ ...record, turns: [...record.turns, turn] });
|
|
59
61
|
await clearRelayOrders(deps, record.conversationId).catch(() => undefined);
|
|
60
|
-
|
|
62
|
+
const afterEnd = record.status === 'ended';
|
|
63
|
+
if (afterEnd) await deps.onRelayReplyAfterEnd?.({ conversationId: record.conversationId, text }).catch(() => undefined);
|
|
64
|
+
return { ...resultOf(record.conversationId, turn), ...(afterEnd ? { after_end: true } : {}) };
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
const lastChange = (r: ConversationRecord) => r.endedAt
|
|
67
|
+
const lastChange = (r: ConversationRecord) => [r.endedAt, r.turns[r.turns.length - 1]?.at].filter(Boolean).sort().pop() ?? r.startedAt;
|
|
64
68
|
|
|
65
69
|
const threadTurn = (id: string, t: ConverseTurn): ConverseThreadTurn => ({
|
|
66
70
|
turn: t.n, turn_id: t.turn_id, at: t.at, who: t.from === 'relay' ? 'relay' : 'you',
|
|
@@ -27,6 +27,7 @@ function toRecord(entity: TenantEntity): ConversationRecord {
|
|
|
27
27
|
title: text(d.title),
|
|
28
28
|
turns: Array.isArray(d.turns) ? (d.turns as ConverseTurn[]) : [],
|
|
29
29
|
...(d.body ? { body: text(d.body) } : {}),
|
|
30
|
+
...(d.summary ? { summary: text(d.summary) } : {}),
|
|
30
31
|
...(d.asks ? { asks: list(d.asks) } : {}),
|
|
31
32
|
...(d.decisions ? { decisions: list(d.decisions) } : {}),
|
|
32
33
|
};
|
|
@@ -64,6 +65,7 @@ export function createEntityConversationStore(http: ConverseDeps['http'], ownerS
|
|
|
64
65
|
time_zone: record.timeZone ?? '',
|
|
65
66
|
turns: record.turns,
|
|
66
67
|
...(record.body !== undefined ? { body: record.body } : {}),
|
|
68
|
+
...(record.summary ? { summary: record.summary } : {}),
|
|
67
69
|
...(record.asks ? { asks: record.asks } : {}),
|
|
68
70
|
...(record.decisions ? { decisions: record.decisions } : {}),
|
|
69
71
|
},
|
|
@@ -20,3 +20,12 @@ export function titleFor(startedAt: string, firstWords: string): string {
|
|
|
20
20
|
const words = firstWords.replace(/\s+/g, ' ').trim().split(' ').slice(0, 7).join(' ');
|
|
21
21
|
return words ? `Conversation ${day}: ${words}` : `Conversation ${day}`;
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The asks as the summary a voice note would carry: a `## Next steps` list of bold bullets, which is the shape the
|
|
26
|
+
* to-do extraction reads (corpus/extract rulesExtract). Empty when there are no asks.
|
|
27
|
+
*/
|
|
28
|
+
export function renderNextSteps(asks: string[]): string {
|
|
29
|
+
if (!asks.length) return '';
|
|
30
|
+
return ['## Next steps', ...asks.map((a) => `- **${a.replace(/\*\*/g, '')}**`)].join('\n');
|
|
31
|
+
}
|
|
@@ -50,6 +50,8 @@ export interface ConversationRecord {
|
|
|
50
50
|
turns: ConverseTurn[];
|
|
51
51
|
/** Set at End: the transcript as a document, and what the handoff pulled out of it. */
|
|
52
52
|
body?: string;
|
|
53
|
+
/** The asks as a `## Next steps` list: what the to-do extraction (and every other reader of a note's summary) reads. */
|
|
54
|
+
summary?: string;
|
|
53
55
|
asks?: string[];
|
|
54
56
|
decisions?: string[];
|
|
55
57
|
}
|
|
@@ -132,6 +134,14 @@ export interface ConverseEndResult {
|
|
|
132
134
|
decisions: string[];
|
|
133
135
|
}
|
|
134
136
|
|
|
137
|
+
/** What End hands on once the record is saved. */
|
|
138
|
+
export interface ConverseHandoffInput {
|
|
139
|
+
/** The saved record: `id` is the document row, `body` the transcript. */
|
|
140
|
+
record: ConversationRecord;
|
|
141
|
+
asks: string[];
|
|
142
|
+
decisions: string[];
|
|
143
|
+
}
|
|
144
|
+
|
|
135
145
|
export interface ConverseDeps {
|
|
136
146
|
http: Pick<CorpusHttp, 'get'> & { post<T>(path: string, body?: unknown): Promise<T> };
|
|
137
147
|
ownerSub: string;
|
|
@@ -141,11 +151,15 @@ export interface ConverseDeps {
|
|
|
141
151
|
transcribe?: (input: { audio: Uint8Array; mimeType: string; hints: string[] }) => Promise<string>;
|
|
142
152
|
/** Pulls asks and decisions out of a finished conversation. Default: none. */
|
|
143
153
|
extract?: (input: { transcript: string }) => Promise<{ asks: string[]; decisions: string[] }>;
|
|
154
|
+
/** After End has saved: files the conversation like a voice note (under a project, asks as to-dos). Default: none. See ./handoff. */
|
|
155
|
+
handoff?: (input: ConverseHandoffInput) => Promise<void>;
|
|
144
156
|
store?: ConversationStore;
|
|
145
157
|
now?: () => number;
|
|
146
158
|
newId?: () => string;
|
|
147
159
|
/** How many earlier lines the brain sees. Default 24. */
|
|
148
160
|
historyLines?: number;
|
|
161
|
+
/** Called when the relay answers a conversation the person has already ended, so they can be told (a push). Errors are ignored. */
|
|
162
|
+
onRelayReplyAfterEnd?: (info: { conversationId: string; text: string }) => Promise<void>;
|
|
149
163
|
}
|
|
150
164
|
|
|
151
165
|
/** An error the route turns into a status; `code` lets the app choose its message. */
|
package/src/corpus/index.ts
CHANGED
|
@@ -328,3 +328,8 @@ export * from './owner-backfill';
|
|
|
328
328
|
export * from './liabilities';
|
|
329
329
|
export * from './liability-plan';
|
|
330
330
|
export * from './liability-client';
|
|
331
|
+
// Tab names and one-line subtitles shared by the web and iPhone shells.
|
|
332
|
+
export * from './nav-copy';
|
|
333
|
+
|
|
334
|
+
// Projects as answerable records for Ask.
|
|
335
|
+
export { PROJECT_ID_PREFIX, projectIdOf, projectIntent, retrieveProjects, selectProjects } from './ask-projects';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one-line, plain-language subtitle under every Tandem tab and sub-tab, and the
|
|
3
|
+
* labels of the four top-level tabs. One source for web and iPhone so the two never
|
|
4
|
+
* describe a screen in different words. Pure strings: safe in any bundle.
|
|
5
|
+
*/
|
|
6
|
+
export const TAB_COPY = {
|
|
7
|
+
today: { label: 'Today', subtitle: 'Your morning brief and what is due soon.' },
|
|
8
|
+
talk: { label: 'Talk', subtitle: 'Talk or type to Tandem: plans, questions, and notes. Asks you make become to-dos.' },
|
|
9
|
+
plan: { label: 'Plan', subtitle: 'Everything you owe, and what you are aiming for.' },
|
|
10
|
+
more: { label: 'More', subtitle: 'Library, Decisions, Connections, Admin.' },
|
|
11
|
+
} as const;
|
|
12
|
+
|
|
13
|
+
export const PLAN_TABS = [
|
|
14
|
+
{ key: 'todos', label: 'To-dos', subtitle: 'The one list of everything you owe: add, tick off, filter.' },
|
|
15
|
+
{ key: 'timeline', label: 'Timeline', subtitle: 'What was created, finished and overdue over time.' },
|
|
16
|
+
{ key: 'projects', label: 'Projects', subtitle: 'Your projects and goals, with progress. Open one to see its to-dos.' },
|
|
17
|
+
] as const;
|
|
18
|
+
export type PlanTabKey = (typeof PLAN_TABS)[number]['key'];
|
|
19
|
+
|
|
20
|
+
export const MORE_ENTRIES = [
|
|
21
|
+
{ key: 'library', label: 'Library', subtitle: 'Everything Tandem has pulled in: documents, notes and recordings.' },
|
|
22
|
+
{ key: 'decisions', label: 'Decisions', subtitle: 'Questions your agents need you to answer.' },
|
|
23
|
+
{ key: 'connections', label: 'Connections', subtitle: 'The accounts and data sources Tandem reads from.' },
|
|
24
|
+
{ key: 'admin', label: 'Admin', subtitle: 'Records, organisation and build settings.' },
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
27
|
+
export const TALK_MODES = [
|
|
28
|
+
{ key: 'talk', label: 'Talk', subtitle: TAB_COPY.talk.subtitle },
|
|
29
|
+
{ key: 'ask', label: 'Ask', subtitle: 'Ask a question and get an answer with the sources it came from.' },
|
|
30
|
+
] as const;
|
|
31
|
+
export type TalkMode = (typeof TALK_MODES)[number]['key'];
|
package/src/corpus/view-text.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* No React and no DOM in here: the native bundle imports it.
|
|
7
7
|
*/
|
|
8
|
-
import { summaryOf } from '../components/documentText';
|
|
8
|
+
import { summaryOf, withoutNextSteps } from '../components/documentText';
|
|
9
9
|
import type { AskResult, SourceDocument } from './types';
|
|
10
10
|
|
|
11
11
|
/** Markdown flattened to plain prose, for one-line previews, titles and labels. */
|
|
@@ -63,7 +63,8 @@ export function askFailureMessage(err: unknown): string {
|
|
|
63
63
|
* truncated heading and half a bold span are worse than plain prose.
|
|
64
64
|
*/
|
|
65
65
|
export function documentPreview(document: SourceDocument, length = 180): string {
|
|
66
|
-
|
|
66
|
+
// A note's Next steps are to-dos, which live only in Plan: never in a row's preview either.
|
|
67
|
+
const text = stripMarkdown(withoutNextSteps(summaryOf(document)).text || document.body || document.sections[0]?.text || '');
|
|
67
68
|
if (!text) return '';
|
|
68
69
|
return text.length > length ? `${text.slice(0, length).trim()}…` : text;
|
|
69
70
|
}
|
|
@@ -71,12 +71,13 @@ describe('To-dos', () => {
|
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
describe('Note detail', () => {
|
|
74
|
-
it('uses the scaffold: hero with the project tag, to-dos
|
|
74
|
+
it('uses the scaffold: hero with the project tag, a link to its to-dos in Plan, project section, delete in the footer', async () => {
|
|
75
75
|
const controller = createVoiceNotesController({ api: createFakeVoiceApi(), pollMs: 60_000 });
|
|
76
76
|
const r = render(<NoteDetailScreen controller={controller} noteId="n1" onBack={vi.fn()} />);
|
|
77
77
|
await settle(); await settle();
|
|
78
78
|
const text = allText(r);
|
|
79
|
-
expect(text.indexOf('Voice note')).toBeLessThan(text.indexOf('
|
|
79
|
+
expect(text.indexOf('Voice note')).toBeLessThan(text.indexOf('to-dos from this note'));
|
|
80
|
+
expect(maybeById(r, 'note-todos-in-plan')).toHaveLength(1);
|
|
80
81
|
expect(text).toContain('Project');
|
|
81
82
|
expect(text.indexOf('Project')).toBeLessThan(text.indexOf('Delete note'));
|
|
82
83
|
expect(maybeById(r, 'note-delete')).toHaveLength(1);
|
|
@@ -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, 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, notify: services.notify, openUrl: data.openUrl ?? ((url) => Linking.openURL(url)) }, registry),
|
|
154
154
|
[appConfig, data, registry],
|
|
155
155
|
);
|
|
156
156
|
|