@dxos/plugin-transcription 0.8.0 → 0.8.1-main.013e445

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 (152) hide show
  1. package/dist/lib/browser/{TranscriptContainer-SX6PNFEC.mjs → TranscriptContainer-TJXP6ICP.mjs} +3 -3
  2. package/dist/lib/browser/app-graph-builder-ZIIDYMHP.mjs +39 -0
  3. package/dist/lib/browser/app-graph-builder-ZIIDYMHP.mjs.map +7 -0
  4. package/dist/lib/browser/{chunk-AS364WZZ.mjs → chunk-3NWYXRZS.mjs} +2 -2
  5. package/dist/lib/browser/chunk-MD4NQO6W.mjs +252 -0
  6. package/dist/lib/browser/chunk-MD4NQO6W.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-N3VKF2J3.mjs +415 -0
  8. package/dist/lib/browser/chunk-N3VKF2J3.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-YEVVZZTC.mjs +19 -0
  10. package/dist/lib/browser/chunk-YEVVZZTC.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-QIHUPVQD.mjs → chunk-YRW4MNRE.mjs} +23 -24
  12. package/dist/lib/browser/chunk-YRW4MNRE.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +203 -366
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/intent-resolver-AC6LFBE4.mjs +73 -0
  16. package/dist/lib/browser/intent-resolver-AC6LFBE4.mjs.map +7 -0
  17. package/dist/lib/browser/meta.json +1 -1
  18. package/dist/lib/browser/{react-surface-FOEWLLTZ.mjs → react-surface-OM2EECBI.mjs} +15 -8
  19. package/dist/lib/browser/{react-surface-FOEWLLTZ.mjs.map → react-surface-OM2EECBI.mjs.map} +2 -2
  20. package/dist/lib/browser/types/index.mjs +2 -1
  21. package/dist/lib/node/{TranscriptContainer-HU763SN3.cjs → TranscriptContainer-KNTN76RZ.cjs} +8 -8
  22. package/dist/lib/node/{TranscriptContainer-HU763SN3.cjs.map → TranscriptContainer-KNTN76RZ.cjs.map} +2 -2
  23. package/dist/lib/node/app-graph-builder-CJSNQYJZ.cjs +52 -0
  24. package/dist/lib/node/app-graph-builder-CJSNQYJZ.cjs.map +7 -0
  25. package/dist/lib/node/chunk-EKSRBQX7.cjs +437 -0
  26. package/dist/lib/node/chunk-EKSRBQX7.cjs.map +7 -0
  27. package/dist/lib/node/{chunk-QWXLQPP5.cjs → chunk-I6CUIAQH.cjs} +5 -5
  28. package/dist/lib/node/{app-graph-builder-YFBX3OTP.cjs → chunk-LEHTJHKP.cjs} +23 -7
  29. package/dist/lib/node/chunk-LEHTJHKP.cjs.map +7 -0
  30. package/dist/lib/node/chunk-T4W4AKGM.cjs +279 -0
  31. package/dist/lib/node/chunk-T4W4AKGM.cjs.map +7 -0
  32. package/dist/lib/node/{chunk-UIHEGU6Q.cjs → chunk-ZAE2IOZC.cjs} +25 -27
  33. package/dist/lib/node/chunk-ZAE2IOZC.cjs.map +7 -0
  34. package/dist/lib/node/index.cjs +220 -378
  35. package/dist/lib/node/index.cjs.map +4 -4
  36. package/dist/lib/node/intent-resolver-ZSQ2MHJJ.cjs +84 -0
  37. package/dist/lib/node/intent-resolver-ZSQ2MHJJ.cjs.map +7 -0
  38. package/dist/lib/node/meta.json +1 -1
  39. package/dist/lib/node/{react-surface-AGGGDOUC.cjs → react-surface-ZENSCF6S.cjs} +18 -12
  40. package/dist/lib/node/{react-surface-AGGGDOUC.cjs.map → react-surface-ZENSCF6S.cjs.map} +2 -2
  41. package/dist/lib/node/types/index.cjs +8 -7
  42. package/dist/lib/node/types/index.cjs.map +2 -2
  43. package/dist/lib/node-esm/{TranscriptContainer-DVBXQIQ4.mjs → TranscriptContainer-MOWZQSEO.mjs} +3 -3
  44. package/dist/lib/node-esm/app-graph-builder-ARTLU4U5.mjs +40 -0
  45. package/dist/lib/node-esm/app-graph-builder-ARTLU4U5.mjs.map +7 -0
  46. package/dist/lib/node-esm/chunk-4A6BWPRB.mjs +253 -0
  47. package/dist/lib/node-esm/chunk-4A6BWPRB.mjs.map +7 -0
  48. package/dist/lib/node-esm/{chunk-KEG3ME4O.mjs → chunk-DLXORY7Y.mjs} +22 -24
  49. package/dist/lib/node-esm/chunk-DLXORY7Y.mjs.map +7 -0
  50. package/dist/lib/node-esm/{chunk-WEZGRUG6.mjs → chunk-NFPDIQYG.mjs} +2 -2
  51. package/dist/lib/node-esm/chunk-SB5TLXBU.mjs +21 -0
  52. package/dist/lib/node-esm/chunk-SB5TLXBU.mjs.map +7 -0
  53. package/dist/lib/node-esm/chunk-SWV74BYU.mjs +416 -0
  54. package/dist/lib/node-esm/chunk-SWV74BYU.mjs.map +7 -0
  55. package/dist/lib/node-esm/index.mjs +203 -366
  56. package/dist/lib/node-esm/index.mjs.map +4 -4
  57. package/dist/lib/node-esm/intent-resolver-XU4BLUSF.mjs +74 -0
  58. package/dist/lib/node-esm/intent-resolver-XU4BLUSF.mjs.map +7 -0
  59. package/dist/lib/node-esm/meta.json +1 -1
  60. package/dist/lib/node-esm/{react-surface-6AYPLJ2B.mjs → react-surface-5CBEXLXJ.mjs} +15 -8
  61. package/dist/lib/node-esm/{react-surface-6AYPLJ2B.mjs.map → react-surface-5CBEXLXJ.mjs.map} +2 -2
  62. package/dist/lib/node-esm/types/index.mjs +2 -1
  63. package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
  64. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -0
  65. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  66. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  67. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  68. package/dist/types/src/components/Transcript/Transcript.d.ts +2 -0
  69. package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
  70. package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
  71. package/dist/types/src/components/TranscriptContainer.d.ts +1 -0
  72. package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
  73. package/dist/types/src/components/index.d.ts +1 -0
  74. package/dist/types/src/components/index.d.ts.map +1 -1
  75. package/dist/types/src/components/transcription.stories.d.ts +3 -2
  76. package/dist/types/src/components/transcription.stories.d.ts.map +1 -1
  77. package/dist/types/src/hooks/index.d.ts +0 -1
  78. package/dist/types/src/hooks/index.d.ts.map +1 -1
  79. package/dist/types/src/index.d.ts +1 -0
  80. package/dist/types/src/index.d.ts.map +1 -1
  81. package/dist/types/src/meta.d.ts +2 -9
  82. package/dist/types/src/meta.d.ts.map +1 -1
  83. package/dist/types/src/transcriber/index.d.ts +1 -0
  84. package/dist/types/src/transcriber/index.d.ts.map +1 -1
  85. package/dist/types/src/transcriber/media-stream-recorder.d.ts +1 -0
  86. package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
  87. package/dist/types/src/transcriber/summarize.d.ts +5 -0
  88. package/dist/types/src/transcriber/summarize.d.ts.map +1 -0
  89. package/dist/types/src/transcription-manager.d.ts +39 -0
  90. package/dist/types/src/transcription-manager.d.ts.map +1 -0
  91. package/dist/types/src/translations.d.ts +5 -6
  92. package/dist/types/src/translations.d.ts.map +1 -1
  93. package/dist/types/src/types/schema.d.ts +9 -15
  94. package/dist/types/src/types/schema.d.ts.map +1 -1
  95. package/dist/types/src/types/types.d.ts +13 -6
  96. package/dist/types/src/types/types.d.ts.map +1 -1
  97. package/dist/types/src/util/random-queue-dxn.d.ts +2 -2
  98. package/dist/types/src/util/random-queue-dxn.d.ts.map +1 -1
  99. package/package.json +40 -37
  100. package/src/TranscriptionPlugin.tsx +1 -2
  101. package/src/capabilities/app-graph-builder.ts +25 -2
  102. package/src/capabilities/intent-resolver.ts +24 -2
  103. package/src/capabilities/react-surface.tsx +2 -2
  104. package/src/components/Transcript/Transcript.stories.tsx +46 -27
  105. package/src/components/Transcript/Transcript.tsx +205 -49
  106. package/src/components/TranscriptContainer.tsx +12 -147
  107. package/src/components/transcription.stories.tsx +11 -13
  108. package/src/hooks/index.ts +0 -1
  109. package/src/index.ts +1 -0
  110. package/src/meta.ts +2 -2
  111. package/src/transcriber/index.ts +1 -0
  112. package/src/transcriber/media-stream-recorder.ts +4 -0
  113. package/src/transcriber/summarize.ts +77 -0
  114. package/src/transcription-manager.ts +183 -0
  115. package/src/translations.ts +2 -2
  116. package/src/types/schema.ts +5 -3
  117. package/src/types/types.ts +12 -2
  118. package/src/util/random-queue-dxn.ts +2 -2
  119. package/dist/lib/browser/app-graph-builder-ZSSJIFY7.mjs +0 -7
  120. package/dist/lib/browser/app-graph-builder-ZSSJIFY7.mjs.map +0 -7
  121. package/dist/lib/browser/chunk-QIHUPVQD.mjs.map +0 -7
  122. package/dist/lib/browser/chunk-R4HHS6FA.mjs +0 -241
  123. package/dist/lib/browser/chunk-R4HHS6FA.mjs.map +0 -7
  124. package/dist/lib/browser/chunk-ZMES3U2D.mjs +0 -78
  125. package/dist/lib/browser/chunk-ZMES3U2D.mjs.map +0 -7
  126. package/dist/lib/browser/intent-resolver-EAR2TFK2.mjs +0 -32
  127. package/dist/lib/browser/intent-resolver-EAR2TFK2.mjs.map +0 -7
  128. package/dist/lib/node/app-graph-builder-YFBX3OTP.cjs.map +0 -7
  129. package/dist/lib/node/chunk-JBN3P6ZF.cjs +0 -97
  130. package/dist/lib/node/chunk-JBN3P6ZF.cjs.map +0 -7
  131. package/dist/lib/node/chunk-UIHEGU6Q.cjs.map +0 -7
  132. package/dist/lib/node/chunk-YV74Z74I.cjs +0 -267
  133. package/dist/lib/node/chunk-YV74Z74I.cjs.map +0 -7
  134. package/dist/lib/node/intent-resolver-3KJZGGUQ.cjs +0 -44
  135. package/dist/lib/node/intent-resolver-3KJZGGUQ.cjs.map +0 -7
  136. package/dist/lib/node-esm/app-graph-builder-77GQG6UF.mjs +0 -9
  137. package/dist/lib/node-esm/app-graph-builder-77GQG6UF.mjs.map +0 -7
  138. package/dist/lib/node-esm/chunk-36EQXBWR.mjs +0 -242
  139. package/dist/lib/node-esm/chunk-36EQXBWR.mjs.map +0 -7
  140. package/dist/lib/node-esm/chunk-KEG3ME4O.mjs.map +0 -7
  141. package/dist/lib/node-esm/chunk-XYU6B73V.mjs +0 -80
  142. package/dist/lib/node-esm/chunk-XYU6B73V.mjs.map +0 -7
  143. package/dist/lib/node-esm/intent-resolver-UGLYRD4X.mjs +0 -33
  144. package/dist/lib/node-esm/intent-resolver-UGLYRD4X.mjs.map +0 -7
  145. package/dist/types/src/hooks/useIsSpeaking.d.ts +0 -2
  146. package/dist/types/src/hooks/useIsSpeaking.d.ts.map +0 -1
  147. package/src/hooks/useIsSpeaking.ts +0 -77
  148. /package/dist/lib/browser/{TranscriptContainer-SX6PNFEC.mjs.map → TranscriptContainer-TJXP6ICP.mjs.map} +0 -0
  149. /package/dist/lib/browser/{chunk-AS364WZZ.mjs.map → chunk-3NWYXRZS.mjs.map} +0 -0
  150. /package/dist/lib/node/{chunk-QWXLQPP5.cjs.map → chunk-I6CUIAQH.cjs.map} +0 -0
  151. /package/dist/lib/node-esm/{TranscriptContainer-DVBXQIQ4.mjs.map → TranscriptContainer-MOWZQSEO.mjs.map} +0 -0
  152. /package/dist/lib/node-esm/{chunk-WEZGRUG6.mjs.map → chunk-NFPDIQYG.mjs.map} +0 -0
@@ -49,6 +49,10 @@ export class MediaStreamRecorder implements AudioRecorder {
49
49
  };
50
50
  }
51
51
 
52
+ get mediaStreamTrack() {
53
+ return this._mediaStreamTrack;
54
+ }
55
+
52
56
  setOnChunk(onChunk: (chunk: AudioChunk) => void): void {
53
57
  this._onChunk = onChunk;
54
58
  }
@@ -0,0 +1,77 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { Message } from '@dxos/artifact';
6
+ import { DEFAULT_EDGE_MODEL, MixedStreamParser, type AIServiceClient } from '@dxos/assistant';
7
+ import { QueueImpl } from '@dxos/echo-db';
8
+ import { createStatic, isInstanceOf } from '@dxos/echo-schema';
9
+ import { invariant } from '@dxos/invariant';
10
+ import { DXN } from '@dxos/keys';
11
+ import { log } from '@dxos/log';
12
+ import { type EdgeHttpClient } from '@dxos/react-edge-client';
13
+
14
+ import { TranscriptBlock, type TranscriptType } from '../types';
15
+
16
+ export const summarizeTranscript = async (
17
+ edge: EdgeHttpClient,
18
+ ai: AIServiceClient,
19
+ transcript: TranscriptType,
20
+ // TODO(wittjosiah): Add additional context into the prompt.
21
+ context?: string,
22
+ ): Promise<string> => {
23
+ invariant(transcript.queue, 'No queue for transcript');
24
+
25
+ const queue = new QueueImpl(edge, DXN.parse(transcript.queue));
26
+ await queue.refresh();
27
+ const content = queue.items
28
+ .filter((block) => isInstanceOf(TranscriptBlock, block))
29
+ .map((block) => `${block.authorName}: ${block.segments.map((segment) => segment.text).join('\n')}`)
30
+ .join('\n\n');
31
+
32
+ const parser = new MixedStreamParser();
33
+
34
+ log.info('summarizing transcript', { blockCount: queue.items.length });
35
+ const output = await parser.parse(
36
+ await ai.exec({
37
+ model: DEFAULT_EDGE_MODEL,
38
+ systemPrompt: SUMMARIZE_PROMPT,
39
+ history: [createStatic(Message, { role: 'user', content: [{ type: 'text', text: content }] })],
40
+ }),
41
+ );
42
+
43
+ log.info('transcript summary', { output });
44
+ invariant(output[0].content[0].type === 'text', 'Expected text content');
45
+ return output[0].content[0].text;
46
+ };
47
+
48
+ // TODO(dmaretskyi): Add example to set consistent structure for the summary.
49
+ const SUMMARIZE_PROMPT = `
50
+ # Goal
51
+ Create a markdown summary of the transcript provided.
52
+
53
+ # Formatting
54
+ - Format the summary as a markdown document without extra comments like "Here is the summary of the transcript:".
55
+ - Use markdown formatting for headings and bullet points.
56
+ - Format the summary as a list of key points and takeaways.
57
+ - All names of people should be in bold.
58
+
59
+ # Note Taking
60
+ - Correlate items in the summary with the person of origin to build a coherent narrative.
61
+ - Include short quotes verbatim where appropriate. Especially when concerned with design decisions and problem descriptions.
62
+
63
+ # Tasks
64
+ At the end of the summary include tasks.
65
+ Extract only the tasks that are:
66
+ - Directly actionable.
67
+ - Clearly assigned to a person or team (or can easily be inferred).
68
+ - Strongly implied by the conversation and/or user note (no speculative tasks).
69
+ - Specific enough that someone reading them would know exactly what to do next.
70
+
71
+ Format all tasks as markdown checkboxes using the syntax:
72
+ - [ ] Task description.
73
+
74
+ Additional information can be included (indented).
75
+
76
+ If no actionable tasks are found, omit this tasks section.
77
+ `;
@@ -0,0 +1,183 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { synchronized } from '@dxos/async';
6
+ import { Resource } from '@dxos/context';
7
+ import { QueueImpl, type Queue } from '@dxos/echo-db';
8
+ import { createStatic } from '@dxos/echo-schema';
9
+ import { invariant } from '@dxos/invariant';
10
+ import { DXN } from '@dxos/keys';
11
+ import { type EdgeHttpClient } from '@dxos/react-edge-client';
12
+ import { type HuePalette } from '@dxos/react-ui-theme';
13
+
14
+ import { MediaStreamRecorder, Transcriber } from './transcriber';
15
+ import { TranscriptBlock, type TranscriptSegment } from './types';
16
+
17
+ /**
18
+ * Length of the chunk in ms.
19
+ */
20
+ const RECORD_INTERVAL = 200;
21
+
22
+ /**
23
+ * Number of chunks to save before the user starts speaking.
24
+ */
25
+ const PREFIXED_CHUNKS_AMOUNT = 10;
26
+
27
+ /**
28
+ * Number of chunks to transcribe automatically after.
29
+ * Combined should be mess than 25MB or whisper would fail.
30
+ */
31
+ const TRANSCRIBE_AFTER_CHUNKS_AMOUNT = 50;
32
+
33
+ /**
34
+ * Manages transcription state.
35
+ */
36
+ // TODO(mykola): Reconcile with useTranscriber hook.
37
+ export class TranscriptionManager extends Resource {
38
+ private readonly _edgeClient: EdgeHttpClient;
39
+ private _audioStreamTrack?: MediaStreamTrack = undefined;
40
+ private _name?: string = undefined;
41
+ private _hue?: HuePalette = undefined;
42
+ private _mediaRecorder?: MediaStreamRecorder = undefined;
43
+ private _transcriber?: Transcriber = undefined;
44
+ private _enabled = false;
45
+ private _queue?: Queue<TranscriptBlock> = undefined;
46
+
47
+ constructor(edgeClient: EdgeHttpClient) {
48
+ super();
49
+ this._edgeClient = edgeClient;
50
+ }
51
+
52
+ protected override async _open() {
53
+ await this._toggleTranscriber();
54
+ }
55
+
56
+ protected override async _close() {
57
+ void this._transcriber?.close();
58
+ }
59
+
60
+ @synchronized
61
+ setRecording(recording?: boolean) {
62
+ if (!this.isOpen || !this._enabled) {
63
+ return;
64
+ }
65
+
66
+ if (recording) {
67
+ this._transcriber?.startChunksRecording();
68
+ } else {
69
+ this._transcriber?.stopChunksRecording();
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Enable or disable transcription.
75
+ * @param enabled - Whether to enable transcription.
76
+ */
77
+ @synchronized
78
+ async setEnabled(enabled?: boolean) {
79
+ if (this._enabled === enabled) {
80
+ return;
81
+ }
82
+ this._enabled = enabled ?? false;
83
+ this.isOpen && (await this._toggleTranscriber());
84
+ }
85
+
86
+ @synchronized
87
+ async setAudioTrack(track?: MediaStreamTrack) {
88
+ if (this._audioStreamTrack === track) {
89
+ return;
90
+ }
91
+ this._audioStreamTrack = track;
92
+ this.isOpen && (await this._toggleTranscriber());
93
+ }
94
+
95
+ /**
96
+ * Set the queue to save the transcription to.
97
+ * @param queue - The queue to save the transcription to or the DXN of the queue.
98
+ */
99
+ @synchronized
100
+ setQueue(queue?: Queue<TranscriptBlock> | string) {
101
+ switch (typeof queue) {
102
+ case 'string':
103
+ if (this._queue?.dxn.toString() === queue) {
104
+ return;
105
+ }
106
+ this._queue = new QueueImpl<TranscriptBlock>(this._edgeClient, DXN.parse(queue));
107
+ break;
108
+ case 'object':
109
+ if (this._queue === queue) {
110
+ return;
111
+ }
112
+ invariant(queue instanceof QueueImpl);
113
+ this._queue = queue;
114
+ break;
115
+ case 'undefined':
116
+ this._queue = undefined;
117
+ break;
118
+ }
119
+ }
120
+
121
+ @synchronized
122
+ setName(name: string) {
123
+ if (this._name === name) {
124
+ return;
125
+ }
126
+ this._name = name;
127
+ }
128
+
129
+ @synchronized
130
+ setHue(hue: HuePalette) {
131
+ if (this._hue === hue) {
132
+ return;
133
+ }
134
+ this._hue = hue;
135
+ }
136
+
137
+ private async _toggleTranscriber() {
138
+ await this._maybeReinitTranscriber();
139
+
140
+ // Open or close transcriber if transcription is enabled or disabled.
141
+ if (this._enabled) {
142
+ await this._transcriber?.open();
143
+ } else {
144
+ await this._transcriber?.close();
145
+ }
146
+ }
147
+
148
+ private async _maybeReinitTranscriber() {
149
+ if (!this._audioStreamTrack || !this._enabled) {
150
+ return;
151
+ }
152
+
153
+ // Reinitialize transcriber if queue or media stream track has changed.
154
+ let needReinit = false;
155
+ if (this._audioStreamTrack !== this._mediaRecorder?.mediaStreamTrack) {
156
+ this._mediaRecorder = new MediaStreamRecorder({
157
+ mediaStreamTrack: this._audioStreamTrack,
158
+ interval: RECORD_INTERVAL,
159
+ });
160
+ needReinit = true;
161
+ }
162
+ if (needReinit) {
163
+ await this._transcriber?.close();
164
+ this._transcriber = new Transcriber({
165
+ config: {
166
+ transcribeAfterChunksAmount: TRANSCRIBE_AFTER_CHUNKS_AMOUNT,
167
+ prefixBufferChunksAmount: PREFIXED_CHUNKS_AMOUNT,
168
+ },
169
+ recorder: this._mediaRecorder,
170
+ onSegments: (segments) => this._onSegments(segments),
171
+ });
172
+ }
173
+ }
174
+
175
+ private async _onSegments(segments: TranscriptSegment[]) {
176
+ if (!this.isOpen || !this._queue) {
177
+ return;
178
+ }
179
+
180
+ const block = createStatic(TranscriptBlock, { authorName: this._name, authorHue: this._hue, segments });
181
+ this._queue.append([block]);
182
+ }
183
+ }
@@ -10,6 +10,7 @@ export default [
10
10
  'en-US': {
11
11
  [TranscriptType.typename]: {
12
12
  'typename label': 'Transcript',
13
+ 'object name placeholder': 'New transcript',
13
14
  },
14
15
  [TRANSCRIPTION_PLUGIN]: {
15
16
  'plugin name': 'Transcription',
@@ -20,8 +21,7 @@ export default [
20
21
 
21
22
  'delete button': 'Delete',
22
23
  'bookmark button': 'Bookmark',
23
- 'summary button': 'Create summary',
24
- 'summarizing label': 'Summarizing...',
24
+ 'scroll to end label': 'Scroll to latest',
25
25
  },
26
26
  },
27
27
  },
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { EchoObject, ObjectId, S, TypedObject } from '@dxos/echo-schema';
5
+ import { EchoObject, S, TypedObject } from '@dxos/echo-schema';
6
6
 
7
7
  /**
8
8
  * Root transcript object created when the user starts a transcription.
@@ -17,6 +17,7 @@ export const TranscriptSchema = S.Struct({
17
17
  /**
18
18
  * Queue containing TranscriptBlock objects.
19
19
  */
20
+ // TODO(wittjosiah): Should be a ref to a queue.
20
21
  queue: S.optional(S.String),
21
22
  });
22
23
 
@@ -52,8 +53,9 @@ export type TranscriptSegment = S.Schema.Type<typeof TranscriptSegment>;
52
53
  * Transcription block (from single speaker).
53
54
  */
54
55
  export const TranscriptBlock = S.Struct({
55
- id: ObjectId,
56
- author: S.optional(S.String), // TODO(burdon): DID?
56
+ id: S.String,
57
+ authorName: S.optional(S.String), // TODO(burdon): IdentityDid.
58
+ authorHue: S.optional(S.String),
57
59
  segments: S.Array(TranscriptSegment),
58
60
  }).pipe(EchoObject('dxos.org/type/TranscriptBlock', '0.1.0'));
59
61
 
@@ -5,7 +5,7 @@
5
5
  import { S, isInstanceOf } from '@dxos/echo-schema';
6
6
  import { isReactiveObject } from '@dxos/react-client/echo';
7
7
 
8
- import { TranscriptSchema, TranscriptType } from './schema';
8
+ import { TranscriptType } from './schema';
9
9
  import { TRANSCRIPTION_PLUGIN } from '../meta';
10
10
 
11
11
  // TODO(burdon): Move to separate proto.
@@ -22,11 +22,21 @@ export namespace TranscriptionAction {
22
22
  export class Create extends S.TaggedClass<Create>()(`${TRANSCRIPTION_ACTION}/create`, {
23
23
  input: S.Struct({
24
24
  name: S.optional(S.String),
25
+ // TODO(wittjosiah): SpaceId.
26
+ spaceId: S.String,
25
27
  }),
26
28
  output: S.Struct({
27
- object: TranscriptSchema,
29
+ object: TranscriptType,
28
30
  }),
29
31
  }) {}
32
+
33
+ export class Summarize extends S.TaggedClass<Summarize>()(`${TRANSCRIPTION_ACTION}/summarize`, {
34
+ input: S.Struct({
35
+ transcript: TranscriptType,
36
+ context: S.optional(S.String),
37
+ }),
38
+ output: S.String,
39
+ }) {}
30
40
  }
31
41
 
32
42
  export const isTranscript = (object: unknown): object is typeof TranscriptType => {
@@ -5,5 +5,5 @@
5
5
  import { ObjectId } from '@dxos/echo-schema';
6
6
  import { DXN, QueueSubspaceTags, SpaceId } from '@dxos/keys';
7
7
 
8
- export const randomQueueDxn = () =>
9
- new DXN(DXN.kind.QUEUE, [QueueSubspaceTags.DATA, SpaceId.random(), ObjectId.random()]);
8
+ export const randomQueueDxn = (spaceId?: SpaceId) =>
9
+ new DXN(DXN.kind.QUEUE, [QueueSubspaceTags.DATA, spaceId ?? SpaceId.random(), ObjectId.random()]);
@@ -1,7 +0,0 @@
1
- // packages/plugins/experimental/plugin-transcription/src/capabilities/app-graph-builder.ts
2
- import { Capabilities, contributes } from "@dxos/app-framework";
3
- var app_graph_builder_default = (context) => contributes(Capabilities.AppGraphBuilder, []);
4
- export {
5
- app_graph_builder_default as default
6
- };
7
- //# sourceMappingURL=app-graph-builder-ZSSJIFY7.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/app-graph-builder.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';\n\nexport default (context: PluginsContext) => contributes(Capabilities.AppGraphBuilder, []);\n"],
5
- "mappings": ";AAIA,SAASA,cAAcC,mBAAwC;AAE/D,IAAA,4BAAe,CAACC,YAA4BC,YAAYC,aAAaC,iBAAiB,CAAA,CAAE;",
6
- "names": ["Capabilities", "contributes", "context", "contributes", "Capabilities", "AppGraphBuilder"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts", "../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { EchoObject, ObjectId, S, TypedObject } from '@dxos/echo-schema';\n\n/**\n * Root transcript object created when the user starts a transcription.\n */\nexport const TranscriptSchema = S.Struct({\n name: S.String,\n\n // TODO(burdon): Use string for dates?\n started: S.optional(S.Date),\n ended: S.optional(S.Date),\n\n /**\n * Queue containing TranscriptBlock objects.\n */\n queue: S.optional(S.String),\n});\n\nexport class TranscriptType extends TypedObject({\n typename: 'dxos.org/type/Transcript',\n version: '0.1.0',\n})(TranscriptSchema.fields) {}\n\n// TODO(burdon): Do these need to be kept in sync with EDGE?\n\n/**\n * First message in queue.\n * Contains metadata for the recording and transcript.\n */\nconst TranscriptHeader = S.Struct({\n started: S.optional(S.Date),\n});\n\nexport type TranscriptHeader = S.Schema.Type<typeof TranscriptHeader>;\n\n/**\n * Transcription fragment.\n */\nconst TranscriptSegment = S.Struct({\n // TODO(burdon): TS from service is not Unix TS (x1000).\n started: S.Date,\n text: S.String,\n});\n\nexport type TranscriptSegment = S.Schema.Type<typeof TranscriptSegment>;\n\n/**\n * Transcription block (from single speaker).\n */\nexport const TranscriptBlock = S.Struct({\n id: ObjectId,\n author: S.optional(S.String), // TODO(burdon): DID?\n segments: S.Array(TranscriptSegment),\n}).pipe(EchoObject('dxos.org/type/TranscriptBlock', '0.1.0'));\n\nexport type TranscriptBlock = S.Schema.Type<typeof TranscriptBlock>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { S, isInstanceOf } from '@dxos/echo-schema';\nimport { isReactiveObject } from '@dxos/react-client/echo';\n\nimport { TranscriptSchema, TranscriptType } from './schema';\nimport { TRANSCRIPTION_PLUGIN } from '../meta';\n\n// TODO(burdon): Move to separate proto.\n\n/**\n * Endpoint to the calls service.\n */\n// TODO(burdon): Reconfigure/move.\nexport const TRANSCRIPTION_URL = 'https://calls-service.dxos.workers.dev';\n\nexport namespace TranscriptionAction {\n const TRANSCRIPTION_ACTION = `${TRANSCRIPTION_PLUGIN}/action`;\n\n export class Create extends S.TaggedClass<Create>()(`${TRANSCRIPTION_ACTION}/create`, {\n input: S.Struct({\n name: S.optional(S.String),\n }),\n output: S.Struct({\n object: TranscriptSchema,\n }),\n }) {}\n}\n\nexport const isTranscript = (object: unknown): object is typeof TranscriptType => {\n return isReactiveObject(object) && isInstanceOf(TranscriptType, object);\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const TRANSCRIPTION_PLUGIN = 'dxos.org/plugin/transcription';\n\nexport const meta = {\n id: TRANSCRIPTION_PLUGIN,\n name: 'Transcription',\n description: 'Voice transcription.',\n icon: 'ph--microphone--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-transcription',\n tags: ['experimental'],\n screenshots: [],\n} satisfies PluginMeta;\n"],
5
- "mappings": ";AAIA,SAASA,YAAYC,UAAUC,GAAGC,mBAAmB;AAK9C,IAAMC,mBAAmBC,EAAEC,OAAO;EACvCC,MAAMF,EAAEG;;EAGRC,SAASJ,EAAEK,SAASL,EAAEM,IAAI;EAC1BC,OAAOP,EAAEK,SAASL,EAAEM,IAAI;;;;EAKxBE,OAAOR,EAAEK,SAASL,EAAEG,MAAM;AAC5B,CAAA;AAEO,IAAMM,iBAAN,cAA6BC,YAAY;EAC9CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAGb,iBAAiBc,MAAM,EAAA;AAAG;AAQ7B,IAAMC,mBAAmBd,EAAEC,OAAO;EAChCG,SAASJ,EAAEK,SAASL,EAAEM,IAAI;AAC5B,CAAA;AAOA,IAAMS,oBAAoBf,EAAEC,OAAO;;EAEjCG,SAASJ,EAAEM;EACXU,MAAMhB,EAAEG;AACV,CAAA;AAOO,IAAMc,kBAAkBjB,EAAEC,OAAO;EACtCiB,IAAIC;EACJC,QAAQpB,EAAEK,SAASL,EAAEG,MAAM;EAC3BkB,UAAUrB,EAAEsB,MAAMP,iBAAAA;AACpB,CAAA,EAAGQ,KAAKC,WAAW,iCAAiC,OAAA,CAAA;;;ACrDpD,SAASC,KAAAA,IAAGC,oBAAoB;AAChC,SAASC,wBAAwB;;;ACC1B,IAAMC,uBAAuB;AAE7B,IAAMC,OAAO;EAClBC,IAAIF;EACJG,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa,CAAA;AACf;;;ADAO,IAAMC,oBAAoB;;UAEhBC,sBAAAA;AACf,QAAMC,uBAAuB,GAAGC,oBAAAA;EAEzB,MAAMC,eAAeC,GAAEC,YAAW,EAAW,GAAGJ,oBAAAA,WAA+B;IACpFK,OAAOF,GAAEG,OAAO;MACdC,MAAMJ,GAAEK,SAASL,GAAEM,MAAM;IAC3B,CAAA;IACAC,QAAQP,GAAEG,OAAO;MACfK,QAAQC;IACV,CAAA;EACF,CAAA,EAAA;EAAI;uBAPSV,SAAAA;AAQf,GAXiBH,wBAAAA,sBAAAA,CAAAA,EAAAA;AAaV,IAAMc,eAAe,CAACF,WAAAA;AAC3B,SAAOG,iBAAiBH,MAAAA,KAAWI,aAAaC,gBAAgBL,MAAAA;AAClE;",
6
- "names": ["EchoObject", "ObjectId", "S", "TypedObject", "TranscriptSchema", "S", "Struct", "name", "String", "started", "optional", "Date", "ended", "queue", "TranscriptType", "TypedObject", "typename", "version", "fields", "TranscriptHeader", "TranscriptSegment", "text", "TranscriptBlock", "id", "ObjectId", "author", "segments", "Array", "pipe", "EchoObject", "S", "isInstanceOf", "isReactiveObject", "TRANSCRIPTION_PLUGIN", "meta", "id", "name", "description", "icon", "source", "tags", "screenshots", "TRANSCRIPTION_URL", "TranscriptionAction", "TRANSCRIPTION_ACTION", "TRANSCRIPTION_PLUGIN", "Create", "S", "TaggedClass", "input", "Struct", "name", "optional", "String", "output", "object", "TranscriptSchema", "isTranscript", "isReactiveObject", "isInstanceOf", "TranscriptType"]
7
- }
@@ -1,241 +0,0 @@
1
- import {
2
- TRANSCRIPTION_PLUGIN,
3
- TranscriptBlock
4
- } from "./chunk-QIHUPVQD.mjs";
5
-
6
- // packages/plugins/experimental/plugin-transcription/src/components/TranscriptContainer.tsx
7
- import { pipe } from "effect";
8
- import React2, { useCallback, useMemo, useState } from "react";
9
- import { chain, createIntent, LayoutAction, useIntentDispatcher } from "@dxos/app-framework";
10
- import { Message } from "@dxos/artifact";
11
- import { AIServiceClientImpl, DEFAULT_LLM_MODEL, MixedStreamParser } from "@dxos/assistant";
12
- import { create, getSpace, makeRef } from "@dxos/client/echo";
13
- import { QueueImpl } from "@dxos/echo-db";
14
- import { createStatic, isInstanceOf } from "@dxos/echo-schema";
15
- import { invariant } from "@dxos/invariant";
16
- import { DXN } from "@dxos/keys";
17
- import { log } from "@dxos/log";
18
- import { DocumentType } from "@dxos/plugin-markdown/types";
19
- import { CollectionType, SpaceAction } from "@dxos/plugin-space/types";
20
- import { useConfig } from "@dxos/react-client";
21
- import { useEdgeClient, useQueue } from "@dxos/react-edge-client";
22
- import { IconButton as IconButton2, Toolbar, useTranslation as useTranslation2 } from "@dxos/react-ui";
23
- import { ScrollContainer } from "@dxos/react-ui-components";
24
- import { StackItem } from "@dxos/react-ui-stack";
25
- import { TextType } from "@dxos/schema";
26
-
27
- // packages/plugins/experimental/plugin-transcription/src/components/Transcript/Transcript.tsx
28
- import { formatDistanceToNow } from "date-fns/formatDistanceToNow";
29
- import React from "react";
30
- import { Icon, IconButton, useTranslation } from "@dxos/react-ui";
31
- var Transcript = ({ blocks }) => {
32
- const { t } = useTranslation(TRANSCRIPTION_PLUGIN);
33
- const hoverButton = "p-1 min-bs-1 transition-opacity duration-250 opacity-10 group-hover:opacity-100";
34
- return /* @__PURE__ */ React.createElement("div", {
35
- role: "list",
36
- className: "flex flex-col grow gap-2 m-1"
37
- }, blocks?.map((block) => /* @__PURE__ */ React.createElement("div", {
38
- role: "listitem",
39
- key: block.id,
40
- className: "flex flex-col py-1 border border-transparent hover:border-separator rounded"
41
- }, /* @__PURE__ */ React.createElement("div", {
42
- className: "group flex items-center px-2"
43
- }, /* @__PURE__ */ React.createElement(Icon, {
44
- icon: "ph--user--regular"
45
- }), /* @__PURE__ */ React.createElement("div", {
46
- className: "px-2 text-sm text-subdued"
47
- }, block.author), /* @__PURE__ */ React.createElement("div", {
48
- className: "grow"
49
- }), /* @__PURE__ */ React.createElement(IconButton, {
50
- disabled: true,
51
- icon: "ph--x--regular",
52
- label: t("delete button"),
53
- iconOnly: true,
54
- size: 4,
55
- classNames: hoverButton
56
- })), block.segments.map((segment, i) => /* @__PURE__ */ React.createElement("div", {
57
- key: i,
58
- className: "group flex flex-col"
59
- }, /* @__PURE__ */ React.createElement("div", {
60
- className: "px-2"
61
- }, segment.text), /* @__PURE__ */ React.createElement("div", {
62
- className: "flex gap-1 items-center justify-between px-2"
63
- }, /* @__PURE__ */ React.createElement("div", {
64
- className: "grow"
65
- }), /* @__PURE__ */ React.createElement("div", {
66
- className: "truncate text-xs text-subdued"
67
- }, formatDistanceToNow(segment.started, {
68
- addSuffix: true
69
- })), /* @__PURE__ */ React.createElement(IconButton, {
70
- disabled: true,
71
- icon: "ph--bookmark-simple--regular",
72
- label: t("bookmark button"),
73
- iconOnly: true,
74
- size: 4,
75
- classNames: hoverButton
76
- })))))));
77
- };
78
-
79
- // packages/plugins/experimental/plugin-transcription/src/components/TranscriptContainer.tsx
80
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/experimental/plugin-transcription/src/components/TranscriptContainer.tsx";
81
- var TranscriptionContainer = ({ transcript }) => {
82
- const { t } = useTranslation2(TRANSCRIPTION_PLUGIN);
83
- const edge = useEdgeClient();
84
- const aiService = useAiServiceClient();
85
- const { dispatchPromise: dispatch } = useIntentDispatcher();
86
- const queue = useQueue(edge, transcript.queue ? DXN.parse(transcript.queue) : void 0, {
87
- pollInterval: 1e3
88
- });
89
- const [isSummarizing, setIsSummarizing] = useState(false);
90
- const handleSummarize = useCallback(async () => {
91
- setIsSummarizing(true);
92
- try {
93
- const document = await summarizeTranscript(edge, aiService, transcript);
94
- const space = getSpace(transcript);
95
- const target = space?.properties[CollectionType.typename]?.target;
96
- await dispatch(pipe(createIntent(SpaceAction.AddObject, {
97
- object: document,
98
- target
99
- }), chain(LayoutAction.Open, {
100
- part: "main"
101
- })));
102
- } finally {
103
- setIsSummarizing(false);
104
- }
105
- }, [
106
- transcript,
107
- edge
108
- ]);
109
- return /* @__PURE__ */ React2.createElement(StackItem.Content, {
110
- toolbar: true
111
- }, /* @__PURE__ */ React2.createElement(StackItem.Heading, null, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
112
- classNames: "flex gap-2"
113
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
114
- icon: "ph--subtitles--regular",
115
- iconOnly: true,
116
- size: 5,
117
- disabled: isSummarizing,
118
- onClick: handleSummarize,
119
- label: t("summary button")
120
- }), isSummarizing && /* @__PURE__ */ React2.createElement("div", {
121
- className: "text-sm"
122
- }, t("summarizing label")))), /* @__PURE__ */ React2.createElement(ScrollContainer, null, /* @__PURE__ */ React2.createElement(Transcript, {
123
- blocks: queue?.items
124
- })));
125
- };
126
- var TranscriptContainer_default = TranscriptionContainer;
127
- var summarizeTranscript = async (edgeClient, aiService, transcript) => {
128
- invariant(transcript.queue, "No queue found for transcript", {
129
- F: __dxlog_file,
130
- L: 90,
131
- S: void 0,
132
- A: [
133
- "transcript.queue",
134
- "'No queue found for transcript'"
135
- ]
136
- });
137
- const queue = new QueueImpl(edgeClient, DXN.parse(transcript.queue));
138
- await queue.refresh();
139
- const content = queue.items.filter((block) => isInstanceOf(TranscriptBlock, block)).map((block) => `${block.author}: ${block.segments.map((segment) => segment.text).join("\n")}`).join("\n\n");
140
- const parser = new MixedStreamParser();
141
- log.info("summarizing transcript", {
142
- blockCount: queue.items.length
143
- }, {
144
- F: __dxlog_file,
145
- L: 101,
146
- S: void 0,
147
- C: (f, a) => f(...a)
148
- });
149
- const output = await parser.parse(await aiService.exec({
150
- model: DEFAULT_LLM_MODEL,
151
- systemPrompt: SUMMARIZE_PROMPT,
152
- history: [
153
- createStatic(Message, {
154
- role: "user",
155
- content: [
156
- {
157
- type: "text",
158
- text: content
159
- }
160
- ]
161
- })
162
- ]
163
- }));
164
- log.info("transcript summary", {
165
- output
166
- }, {
167
- F: __dxlog_file,
168
- L: 110,
169
- S: void 0,
170
- C: (f, a) => f(...a)
171
- });
172
- invariant(output[0].content[0].type === "text", "Expected text content", {
173
- F: __dxlog_file,
174
- L: 111,
175
- S: void 0,
176
- A: [
177
- "output[0].content[0].type === 'text'",
178
- "'Expected text content'"
179
- ]
180
- });
181
- const summary = output[0].content[0].text;
182
- const name = `Summary ${(transcript.started ?? /* @__PURE__ */ new Date()).toLocaleString("en-US", {
183
- year: "numeric",
184
- month: "long",
185
- day: "numeric",
186
- hour: "2-digit",
187
- minute: "2-digit"
188
- })}`;
189
- return create(DocumentType, {
190
- name,
191
- content: makeRef(create(TextType, {
192
- content: summary
193
- })),
194
- threads: []
195
- });
196
- };
197
- var SUMMARIZE_PROMPT = `
198
- # Goal
199
- Create a markdown summary of the transcript provided.
200
-
201
- # Formatting
202
- - Format the summary as a markdown document without extra comments like "Here is the summary of the transcript:".
203
- - Use markdown formatting for headings and bullet points.
204
- - Format the summary as a list of key points and takeaways.
205
- - All names of people should be in bold.
206
-
207
- # Note Taking
208
- - Correlate items in the summary with the person of origin to build a coherent narrative.
209
- - Include short quotes verbatim where appropriate. Especially when concerned with design decisions and problem descriptions.
210
-
211
- # Tasks
212
- At the end of the summary include tasks.
213
- Extract only the tasks that are:
214
- - Directly actionable
215
- - Clearly assigned to a person or team (or can easily be inferred)
216
- - Strongly implied by the conversation and/or user note (no speculative tasks)
217
- - Specific enough that someone reading them would know exactly what to do next
218
-
219
- Format all tasks as markdown checkboxes using the syntax:
220
- - [ ] Task description
221
-
222
- Additional information can be included (indented).
223
-
224
- If no actionable tasks are found, omit this tasks section.
225
- `;
226
- var useAiServiceClient = () => {
227
- const config = useConfig();
228
- const endpoint = config.values.runtime?.services?.ai?.server ?? "http://localhost:8788";
229
- return useMemo(() => new AIServiceClientImpl({
230
- endpoint
231
- }), [
232
- endpoint
233
- ]);
234
- };
235
-
236
- export {
237
- Transcript,
238
- TranscriptionContainer,
239
- TranscriptContainer_default
240
- };
241
- //# sourceMappingURL=chunk-R4HHS6FA.mjs.map