@dxos/plugin-transcription 0.8.4-main.28f8d3d → 0.8.4-main.406dc2a

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 (153) hide show
  1. package/dist/lib/browser/TranscriptContainer-QN5WUMWJ.mjs +11 -0
  2. package/dist/lib/browser/blueprint-definition-GO6GTEBT.mjs +150 -0
  3. package/dist/lib/browser/blueprint-definition-GO6GTEBT.mjs.map +7 -0
  4. package/dist/lib/browser/{chunk-UKUSJTQW.mjs → chunk-77NWYLC6.mjs} +2 -2
  5. package/dist/lib/browser/{chunk-5WH45KBY.mjs → chunk-7LNCQDTT.mjs} +9 -4
  6. package/dist/lib/browser/chunk-7LNCQDTT.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-KJIQQHJB.mjs → chunk-COBQIZ6B.mjs} +78 -98
  8. package/dist/lib/browser/{chunk-KJIQQHJB.mjs.map → chunk-COBQIZ6B.mjs.map} +3 -3
  9. package/dist/lib/browser/chunk-GGHMOEKZ.mjs +63 -0
  10. package/dist/lib/browser/chunk-GGHMOEKZ.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-SREIAQSP.mjs → chunk-LCK3YRQF.mjs} +5 -5
  12. package/dist/lib/browser/chunk-LCK3YRQF.mjs.map +7 -0
  13. package/dist/lib/browser/{chunk-BJWYA2BU.mjs → chunk-ZS2FXKEF.mjs} +141 -168
  14. package/dist/lib/browser/chunk-ZS2FXKEF.mjs.map +7 -0
  15. package/dist/lib/browser/index.mjs +22 -18
  16. package/dist/lib/browser/index.mjs.map +3 -3
  17. package/dist/lib/browser/intent-resolver-52EPFRMR.mjs +25 -0
  18. package/dist/lib/browser/intent-resolver-52EPFRMR.mjs.map +7 -0
  19. package/dist/lib/browser/meta.json +1 -1
  20. package/dist/lib/browser/{react-surface-4MEJMKYQ.mjs → react-surface-LCP2D2MF.mjs} +10 -10
  21. package/dist/lib/browser/react-surface-LCP2D2MF.mjs.map +7 -0
  22. package/dist/lib/browser/{transcriber-V77CN7XX.mjs → transcriber-NG5MRCP6.mjs} +7 -7
  23. package/dist/lib/browser/{transcriber-V77CN7XX.mjs.map → transcriber-NG5MRCP6.mjs.map} +1 -1
  24. package/dist/lib/browser/types/index.mjs +6 -8
  25. package/dist/lib/node-esm/{TranscriptContainer-GEUOOYHX.mjs → TranscriptContainer-WCUWVVSD.mjs} +4 -4
  26. package/dist/lib/node-esm/blueprint-definition-6SU7GLBR.mjs +151 -0
  27. package/dist/lib/node-esm/blueprint-definition-6SU7GLBR.mjs.map +7 -0
  28. package/dist/lib/node-esm/{chunk-A33GNR44.mjs → chunk-A6SB234F.mjs} +78 -98
  29. package/dist/lib/node-esm/{chunk-A33GNR44.mjs.map → chunk-A6SB234F.mjs.map} +3 -3
  30. package/dist/lib/node-esm/chunk-FTTZ4YSX.mjs +64 -0
  31. package/dist/lib/node-esm/chunk-FTTZ4YSX.mjs.map +7 -0
  32. package/dist/lib/node-esm/{chunk-XMUCZBP3.mjs → chunk-KLTPFUKN.mjs} +8 -4
  33. package/dist/lib/node-esm/chunk-KLTPFUKN.mjs.map +7 -0
  34. package/dist/lib/node-esm/{chunk-PHP7MCAY.mjs → chunk-N5Z4SKPH.mjs} +2 -2
  35. package/dist/lib/node-esm/{chunk-Y7PCJ34K.mjs → chunk-PEZRQYKO.mjs} +141 -168
  36. package/dist/lib/node-esm/chunk-PEZRQYKO.mjs.map +7 -0
  37. package/dist/lib/node-esm/{chunk-TM2ASOZA.mjs → chunk-RWRG3S2O.mjs} +5 -5
  38. package/dist/lib/node-esm/chunk-RWRG3S2O.mjs.map +7 -0
  39. package/dist/lib/node-esm/index.mjs +22 -18
  40. package/dist/lib/node-esm/index.mjs.map +3 -3
  41. package/dist/lib/node-esm/intent-resolver-DZBQQRHN.mjs +26 -0
  42. package/dist/lib/node-esm/intent-resolver-DZBQQRHN.mjs.map +7 -0
  43. package/dist/lib/node-esm/meta.json +1 -1
  44. package/dist/lib/node-esm/{react-surface-EZUPNHUC.mjs → react-surface-7UC2YXX2.mjs} +10 -10
  45. package/dist/lib/node-esm/react-surface-7UC2YXX2.mjs.map +7 -0
  46. package/dist/lib/node-esm/{transcriber-3SX3DNLV.mjs → transcriber-SMU7HD6F.mjs} +7 -7
  47. package/dist/lib/node-esm/{transcriber-3SX3DNLV.mjs.map → transcriber-SMU7HD6F.mjs.map} +1 -1
  48. package/dist/lib/node-esm/types/index.mjs +6 -8
  49. package/dist/types/src/TranscriptionPlugin.d.ts +1 -1
  50. package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
  51. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
  52. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  53. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  54. package/dist/types/src/capabilities/index.d.ts +3 -2
  55. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  56. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  57. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  58. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  59. package/dist/types/src/capabilities/transcriber.d.ts +1 -1
  60. package/dist/types/src/components/Transcript/Transcript.d.ts +5 -5
  61. package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
  62. package/dist/types/src/components/Transcript/Transcript.stories.d.ts +31 -16
  63. package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
  64. package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +3 -3
  65. package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +1 -1
  66. package/dist/types/src/components/Transcript/transcript-extension.d.ts +1 -5
  67. package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +1 -1
  68. package/dist/types/src/components/TranscriptContainer.d.ts +2 -2
  69. package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
  70. package/dist/types/src/components/stories/FileTranscription.stories.d.ts +8 -4
  71. package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
  72. package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts +13 -6
  73. package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +1 -1
  74. package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +10 -6
  75. package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
  76. package/dist/types/src/components/stories/TranscriptionStory.d.ts +2 -1
  77. package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -1
  78. package/dist/types/src/functions/index.d.ts +3 -0
  79. package/dist/types/src/functions/index.d.ts.map +1 -0
  80. package/dist/types/src/functions/open.d.ts +7 -0
  81. package/dist/types/src/functions/open.d.ts.map +1 -0
  82. package/dist/types/src/functions/summarize.d.ts +11 -0
  83. package/dist/types/src/functions/summarize.d.ts.map +1 -0
  84. package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
  85. package/dist/types/src/meta.d.ts +0 -1
  86. package/dist/types/src/meta.d.ts.map +1 -1
  87. package/dist/types/src/segments-normalization/normalization.d.ts +376 -331
  88. package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
  89. package/dist/types/src/testing/testing.d.ts +1 -1
  90. package/dist/types/src/testing/testing.d.ts.map +1 -1
  91. package/dist/types/src/transcriber/transcription-manager.d.ts +3 -7
  92. package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
  93. package/dist/types/src/types/Transcript.d.ts +30 -0
  94. package/dist/types/src/types/Transcript.d.ts.map +1 -0
  95. package/dist/types/src/types/TranscriptAction.d.ts +23 -0
  96. package/dist/types/src/types/TranscriptAction.d.ts.map +1 -0
  97. package/dist/types/src/types/index.d.ts +2 -1
  98. package/dist/types/src/types/index.d.ts.map +1 -1
  99. package/dist/types/src/types/types.d.ts +0 -26
  100. package/dist/types/src/types/types.d.ts.map +1 -1
  101. package/dist/types/tsconfig.tsbuildinfo +1 -1
  102. package/package.json +61 -62
  103. package/src/TranscriptionPlugin.tsx +57 -53
  104. package/src/capabilities/blueprint-definition.ts +31 -0
  105. package/src/capabilities/capabilities.ts +3 -3
  106. package/src/capabilities/index.ts +1 -0
  107. package/src/capabilities/intent-resolver.ts +4 -10
  108. package/src/capabilities/react-surface.tsx +2 -2
  109. package/src/components/Transcript/Transcript.stories.tsx +32 -30
  110. package/src/components/Transcript/Transcript.tsx +17 -25
  111. package/src/components/Transcript/deprecated/OldTranscript.tsx +7 -7
  112. package/src/components/Transcript/transcript-extension.ts +2 -39
  113. package/src/components/TranscriptContainer.tsx +6 -6
  114. package/src/components/stories/FileTranscription.stories.tsx +42 -30
  115. package/src/components/stories/KeyWordRecognition.stories.tsx +16 -9
  116. package/src/components/stories/MicrophoneTranscription.stories.tsx +36 -32
  117. package/src/components/stories/TranscriptionStory.tsx +10 -6
  118. package/src/functions/index.ts +6 -0
  119. package/src/functions/open.ts +39 -0
  120. package/src/functions/summarize.ts +103 -0
  121. package/src/hooks/useAudioFile.ts +49 -53
  122. package/src/meta.ts +1 -3
  123. package/src/segments-normalization/normalization.test.ts +1 -1
  124. package/src/segments-normalization/normalization.ts +1 -1
  125. package/src/testing/testing.ts +5 -5
  126. package/src/transcriber/transcription-manager.ts +17 -38
  127. package/src/types/{schema.ts → Transcript.ts} +12 -9
  128. package/src/types/TranscriptAction.ts +24 -0
  129. package/src/types/index.ts +2 -1
  130. package/src/types/types.ts +0 -24
  131. package/dist/lib/browser/TranscriptContainer-FH7VAWYA.mjs +0 -11
  132. package/dist/lib/browser/chunk-5WH45KBY.mjs.map +0 -7
  133. package/dist/lib/browser/chunk-BJWYA2BU.mjs.map +0 -7
  134. package/dist/lib/browser/chunk-KWOOVS5G.mjs +0 -55
  135. package/dist/lib/browser/chunk-KWOOVS5G.mjs.map +0 -7
  136. package/dist/lib/browser/chunk-SREIAQSP.mjs.map +0 -7
  137. package/dist/lib/browser/intent-resolver-AOVQ7JI4.mjs +0 -30
  138. package/dist/lib/browser/intent-resolver-AOVQ7JI4.mjs.map +0 -7
  139. package/dist/lib/browser/react-surface-4MEJMKYQ.mjs.map +0 -7
  140. package/dist/lib/node-esm/chunk-IKQMDRY6.mjs +0 -56
  141. package/dist/lib/node-esm/chunk-IKQMDRY6.mjs.map +0 -7
  142. package/dist/lib/node-esm/chunk-TM2ASOZA.mjs.map +0 -7
  143. package/dist/lib/node-esm/chunk-XMUCZBP3.mjs.map +0 -7
  144. package/dist/lib/node-esm/chunk-Y7PCJ34K.mjs.map +0 -7
  145. package/dist/lib/node-esm/intent-resolver-P4XPIKQF.mjs +0 -31
  146. package/dist/lib/node-esm/intent-resolver-P4XPIKQF.mjs.map +0 -7
  147. package/dist/lib/node-esm/react-surface-EZUPNHUC.mjs.map +0 -7
  148. package/dist/types/src/types/schema.d.ts +0 -41
  149. package/dist/types/src/types/schema.d.ts.map +0 -1
  150. /package/dist/lib/browser/{TranscriptContainer-FH7VAWYA.mjs.map → TranscriptContainer-QN5WUMWJ.mjs.map} +0 -0
  151. /package/dist/lib/browser/{chunk-UKUSJTQW.mjs.map → chunk-77NWYLC6.mjs.map} +0 -0
  152. /package/dist/lib/node-esm/{TranscriptContainer-GEUOOYHX.mjs.map → TranscriptContainer-WCUWVVSD.mjs.map} +0 -0
  153. /package/dist/lib/node-esm/{chunk-PHP7MCAY.mjs.map → chunk-N5Z4SKPH.mjs.map} +0 -0
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export { default as open } from './open';
6
+ export { default as summarize } from './summarize';
@@ -0,0 +1,39 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+ import * as Schema from 'effect/Schema';
7
+
8
+ import { ArtifactId } from '@dxos/assistant';
9
+ import { Obj } from '@dxos/echo';
10
+ import { DatabaseService, QueueService, defineFunction } from '@dxos/functions';
11
+ import { DataType } from '@dxos/schema';
12
+
13
+ import { renderByline } from '../components';
14
+ import { Transcript } from '../types';
15
+
16
+ export default defineFunction({
17
+ key: 'dxos.org/function/transcription/open',
18
+ name: 'Open',
19
+ description: 'Opens and reads the contents of a transcription object.',
20
+ inputSchema: Schema.Struct({
21
+ id: ArtifactId.annotations({
22
+ description: 'The ID of the transcription object.',
23
+ }),
24
+ }),
25
+ outputSchema: Schema.Struct({
26
+ content: Schema.String,
27
+ }),
28
+ handler: Effect.fn(function* ({ data: { id } }) {
29
+ const transcript = yield* DatabaseService.resolve(ArtifactId.toDXN(id), Transcript.Transcript);
30
+ const { dxn } = yield* Effect.promise(() => transcript.queue.load());
31
+ const queue = yield* QueueService.getQueue(dxn);
32
+ yield* Effect.promise(() => queue?.queryObjects());
33
+ const content = queue?.objects
34
+ .filter((message) => Obj.instanceOf(DataType.Message, message))
35
+ .flatMap((message, index) => renderByline([])(message, index))
36
+ .join('\n\n');
37
+ return { content };
38
+ }),
39
+ });
@@ -0,0 +1,103 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Array from 'effect/Array';
6
+ import * as Effect from 'effect/Effect';
7
+ import * as Function from 'effect/Function';
8
+ import * as Layer from 'effect/Layer';
9
+ import * as Option from 'effect/Option';
10
+ import * as Schema from 'effect/Schema';
11
+
12
+ import { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';
13
+ import { AiSession, GenerationObserver } from '@dxos/assistant';
14
+ import { TracingService, defineFunction } from '@dxos/functions';
15
+ import { trim } from '@dxos/util';
16
+
17
+ /**
18
+ * Summarize a transcript of a meeting.
19
+ */
20
+ export default defineFunction({
21
+ key: 'dxos.org/function/transcription/summarize',
22
+ name: 'Summarize',
23
+ description: 'Summarize a transcript of a meeting.',
24
+ inputSchema: Schema.Struct({
25
+ transcript: Schema.String.annotations({
26
+ description: 'The transcript of the meeting.',
27
+ }),
28
+ notes: Schema.optional(Schema.String).annotations({
29
+ description: 'Additional notes from the participants.',
30
+ }),
31
+ }),
32
+ outputSchema: Schema.Struct({
33
+ summary: Schema.String.annotations({
34
+ description: 'The summary of the transcript.',
35
+ }),
36
+ }),
37
+ handler: Effect.fnUntraced(
38
+ function* ({ data: { transcript, notes } }) {
39
+ const result = yield* new AiSession().run({
40
+ prompt: `Transcript: ${transcript}\n\nNotes: ${notes}`,
41
+ history: [],
42
+ system: systemPrompt,
43
+ observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'summarize' })),
44
+ });
45
+
46
+ const summary = Function.pipe(
47
+ result,
48
+ Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),
49
+ Option.flatMap((msg) =>
50
+ Function.pipe(
51
+ msg.blocks,
52
+ Array.findLast((block) => block._tag === 'text'),
53
+ Option.map((block) => block.text),
54
+ ),
55
+ ),
56
+ Option.getOrThrowWith(() => new Error('No summary found')),
57
+ );
58
+
59
+ return { summary };
60
+ },
61
+ Effect.provide(
62
+ Layer.mergeAll(
63
+ AiService.model('@anthropic/claude-sonnet-4-0'),
64
+ ToolResolverService.layerEmpty,
65
+ ToolExecutionService.layerEmpty,
66
+ TracingService.layerNoop,
67
+ ),
68
+ ),
69
+ ),
70
+ });
71
+
72
+ const systemPrompt = trim`
73
+ You are a helpful assistant that summarizes transcripts of meetings.
74
+
75
+ # Goal
76
+ Create a markdown summary of the meeting transcript with text notes provided.
77
+ Notes are very important so make sure to include them in the summary if they contain meaningful information.
78
+
79
+ # Formatting
80
+ - Format the summary as a markdown document without extra comments like "Here is the summary of the transcript:".
81
+ - Use markdown formatting for headings and bullet points.
82
+ - Format the summary as a list of key points and takeaways.
83
+ - All names of people should be in bold.
84
+
85
+ # Note Taking
86
+ - Correlate items in the summary with the person of origin to build a coherent narrative.
87
+ - Include short quotes verbatim where appropriate. Especially when concerned with design decisions and problem descriptions.
88
+
89
+ # Tasks
90
+ At the end of the summary include tasks.
91
+ Extract only the tasks that are:
92
+ - Directly actionable.
93
+ - Clearly assigned to a person or team (or can easily be inferred).
94
+ - Strongly implied by the conversation and/or user note (no speculative tasks).
95
+ - Specific enough that someone reading them would know exactly what to do next.
96
+
97
+ Format all tasks as markdown checkboxes using the syntax:
98
+ - [ ] Task description.
99
+
100
+ Additional information can be included (indented).
101
+
102
+ If no actionable tasks are found, omit this tasks section.
103
+ `;
@@ -20,67 +20,63 @@ export const useAudioFile = (audioUrl: string, constraints?: MediaTrackConstrain
20
20
  const ctx = new Context();
21
21
 
22
22
  scheduleTask(ctx, async () => {
23
- const response = await fetch(audioUrl);
24
- const blob = await response.blob();
25
- const objectUrl = URL.createObjectURL(blob);
26
- ctx.onDispose(() => {
27
- URL.revokeObjectURL(objectUrl);
28
- });
23
+ // TODO(wittjosiah): Fetch to external url fails in headless storybook test.
24
+ try {
25
+ const response = await fetch(audioUrl);
26
+ const blob = await response.blob();
27
+ const objectUrl = URL.createObjectURL(blob);
28
+ ctx.onDispose(() => {
29
+ URL.revokeObjectURL(objectUrl);
30
+ });
29
31
 
30
- const audio = new Audio();
31
- audio.src = objectUrl;
32
+ const audio = new Audio();
33
+ audio.src = objectUrl;
32
34
 
33
- await new Promise<void>((resolve, reject) => {
34
- audio.addEventListener(
35
- 'error',
36
- (err) => {
37
- log.error('error', { err });
38
- reject(err);
39
- },
40
- { once: true },
41
- );
42
- audio.addEventListener(
43
- 'canplay',
44
- async () => {
45
- log.info('starting...');
46
- try {
47
- // Try to play the audio
48
- await audio.play();
35
+ await new Promise<void>((resolve, reject) => {
36
+ audio.addEventListener(
37
+ 'error',
38
+ (err) => {
39
+ log.error('error', { err });
40
+ reject(err);
41
+ },
42
+ { once: true },
43
+ );
44
+ audio.addEventListener(
45
+ 'canplay',
46
+ async () => {
49
47
  resolve();
50
- } catch (playError) {
51
- log.error('Play failed', { playError });
52
- // Still resolve as the audio is ready, even if autoplay failed.
53
- resolve();
54
- }
55
- },
56
- { once: true },
57
- );
58
- audio.load();
59
- });
48
+ },
49
+ { once: true },
50
+ );
51
+ audio.load();
52
+ });
60
53
 
61
- const audioCtx = new AudioContext();
54
+ const audioCtx = new AudioContext();
62
55
 
63
- // Resume AudioContext if it's suspended.
64
- if (audioCtx.state === 'suspended') {
65
- await audioCtx.resume();
66
- }
56
+ // Resume AudioContext if it's suspended.
57
+ if (audioCtx.state === 'suspended') {
58
+ await audioCtx.resume();
59
+ }
67
60
 
68
- const destination = audioCtx.createMediaStreamDestination();
69
- destination.channelCount = 1;
61
+ const destination = audioCtx.createMediaStreamDestination();
62
+ destination.channelCount = 1;
70
63
 
71
- const source = audioCtx.createMediaElementSource(audio);
72
- source.connect(destination);
73
- const track = destination.stream.getAudioTracks()[0];
74
- if (constraints) {
75
- await track.applyConstraints(constraints).catch((err) => log.catch(err));
76
- }
64
+ const source = audioCtx.createMediaElementSource(audio);
65
+ source.connect(destination);
66
+ const track = destination.stream.getAudioTracks()[0];
67
+ if (constraints) {
68
+ await track.applyConstraints(constraints).catch((err) => log.catch(err));
69
+ }
77
70
 
78
- // Also connect to speakers so audio is audible.
79
- setStream({
80
- audio,
81
- stream: destination.stream,
82
- track: destination.stream.getAudioTracks()[0],
83
- });
71
+ // Also connect to speakers so audio is audible.
72
+ setStream({
73
+ audio,
74
+ stream: destination.stream,
75
+ track: destination.stream.getAudioTracks()[0],
76
+ });
77
+ } catch (err) {
78
+ log.catch(err);
79
+ }
84
80
  });
85
81
 
86
82
  return () => {
package/src/meta.ts CHANGED
@@ -4,10 +4,8 @@
4
4
 
5
5
  import { type PluginMeta } from '@dxos/app-framework';
6
6
 
7
- export const TRANSCRIPTION_PLUGIN = 'dxos.org/plugin/transcription';
8
-
9
7
  export const meta: PluginMeta = {
10
- id: TRANSCRIPTION_PLUGIN,
8
+ id: 'dxos.org/plugin/transcription',
11
9
  name: 'Transcription',
12
10
  description: 'Voice transcription.',
13
11
  icon: 'ph--microphone--regular',
@@ -8,8 +8,8 @@ import { describe, test } from 'vitest';
8
8
  import { scheduleTaskInterval } from '@dxos/async';
9
9
  import { Context } from '@dxos/context';
10
10
  import { Obj } from '@dxos/echo';
11
+ import { createQueueDXN } from '@dxos/echo/internal';
11
12
  import { MemoryQueue } from '@dxos/echo-db';
12
- import { createQueueDXN } from '@dxos/echo-schema';
13
13
  import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
14
14
  import { log } from '@dxos/log';
15
15
  import { DataType } from '@dxos/schema';
@@ -5,7 +5,7 @@
5
5
  // ISSUE(burdon): defineFunction
6
6
  // @ts-nocheck
7
7
 
8
- import { Schema } from 'effect';
8
+ import * as Schema from 'effect/Schema';
9
9
 
10
10
  import { AiService, DEFAULT_EDGE_MODEL } from '@dxos/ai';
11
11
  import { AiSession } from '@dxos/assistant';
@@ -2,15 +2,15 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import { useEffect, useMemo, useState } from 'react';
7
7
 
8
- import { extractionAnthropicFn, processTranscriptMessage } from '@dxos/assistant/extraction';
8
+ import { extractionAnthropicFunction, processTranscriptMessage } from '@dxos/assistant/extraction';
9
9
  import { scheduleTaskInterval } from '@dxos/async';
10
10
  import { Filter, type Queue } from '@dxos/client/echo';
11
11
  import { Context } from '@dxos/context';
12
12
  import { type Key, Obj, Ref, Type } from '@dxos/echo';
13
- import { createQueueDXN } from '@dxos/echo-schema';
13
+ import { createQueueDXN } from '@dxos/echo/internal';
14
14
  import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
15
15
  import { IdentityDid } from '@dxos/keys';
16
16
  import { log } from '@dxos/log';
@@ -74,7 +74,7 @@ export class MessageBuilder extends AbstractMessageBuilder {
74
74
  const obj = this._space.db.add(Obj.make(TestItem, { title: label, description: faker.lorem.paragraph() }));
75
75
  const dxn = Ref.make(obj).dxn.toString();
76
76
  const words = text.split(' ');
77
- words.splice(Math.floor(Math.random() * words.length), 0, `[${label}][${dxn}]`);
77
+ words.splice(Math.floor(Math.random() * words.length), 0, `[${label}](${dxn})`);
78
78
  text = words.join(' ');
79
79
  }
80
80
 
@@ -130,7 +130,7 @@ class EntityExtractionMessageBuilder extends AbstractMessageBuilder {
130
130
  const { message: enhancedMessage } = await processTranscriptMessage({
131
131
  input: { message },
132
132
  executor: this.executor,
133
- function: extractionAnthropicFn,
133
+ function: extractionAnthropicFunction,
134
134
  });
135
135
 
136
136
  return enhancedMessage;
@@ -90,19 +90,17 @@ export class TranscriptionManager extends Resource {
90
90
  return this;
91
91
  }
92
92
 
93
- /**
94
- * Enable or disable transcription.
95
- * @param enabled - Whether to enable transcription.
96
- */
97
- @synchronized
98
- async setEnabled(enabled?: boolean): Promise<void> {
93
+ async setEnabled(enabled: boolean): Promise<void> {
99
94
  if (this._enabled.value === enabled) {
100
95
  return;
101
96
  }
102
97
 
103
98
  this._enabled.value = enabled ?? false;
104
- // TODO(burdon): Why is toggle called here?
105
- this.isOpen && (await this._toggleTranscriber());
99
+ if (enabled) {
100
+ await this._maybeRestartTranscriber();
101
+ } else {
102
+ await this._stopTranscriber();
103
+ }
106
104
  }
107
105
 
108
106
  @synchronized
@@ -112,44 +110,19 @@ export class TranscriptionManager extends Resource {
112
110
  }
113
111
 
114
112
  this._audioStreamTrack = track;
115
- this.isOpen && (await this._toggleTranscriber());
113
+ await this._maybeRestartTranscriber();
116
114
  }
117
115
 
118
116
  protected override async _open(): Promise<void> {
119
- await this._toggleTranscriber();
117
+ await this._maybeRestartTranscriber();
120
118
  }
121
119
 
122
120
  protected override async _close(): Promise<void> {
123
- void this._transcriber?.close();
124
- }
125
-
126
- // TODO(burdon): Change this to setEnables (explicit), not toggle.
127
- private async _toggleTranscriber(): Promise<void> {
128
- await this._maybeReinitTranscriber();
129
-
130
- // Open or close transcriber if transcription is enabled or disabled.
131
- if (this._enabled.value) {
132
- await this._transcriber?.open();
133
- // TODO(burdon): Started and stopped blocks appear twice.
134
- const block = Obj.make(DataType.Message, {
135
- created: new Date().toISOString(),
136
- blocks: [{ _tag: 'transcript', text: 'Started', started: new Date().toISOString() }],
137
- sender: { role: 'assistant' },
138
- });
139
- await this._queue?.append([block]);
140
- } else {
141
- await this._transcriber?.close();
142
- const block = Obj.make(DataType.Message, {
143
- created: new Date().toISOString(),
144
- blocks: [{ _tag: 'transcript', text: 'Stopped', started: new Date().toISOString() }],
145
- sender: { role: 'assistant' },
146
- });
147
- await this._queue?.append([block]);
148
- }
121
+ await this._stopTranscriber();
149
122
  }
150
123
 
151
- private async _maybeReinitTranscriber(): Promise<void> {
152
- if (!this._audioStreamTrack || !this._enabled.value) {
124
+ private async _maybeRestartTranscriber(): Promise<void> {
125
+ if (!this._audioStreamTrack || !this._enabled.value || !this.isOpen) {
153
126
  return;
154
127
  }
155
128
 
@@ -172,9 +145,15 @@ export class TranscriptionManager extends Resource {
172
145
  recorder: this._mediaRecorder,
173
146
  onSegments: (segments) => this._onSegments(segments),
174
147
  });
148
+
149
+ await this._transcriber?.open();
175
150
  }
176
151
  }
177
152
 
153
+ private async _stopTranscriber(): Promise<void> {
154
+ await this._transcriber?.close();
155
+ }
156
+
178
157
  private async _onSegments(segments: DataType.MessageBlock.Transcript[]): Promise<void> {
179
158
  if (!this.isOpen || !this._queue) {
180
159
  return;
@@ -2,16 +2,15 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
 
7
7
  import { Queue } from '@dxos/client/echo';
8
- import { Type } from '@dxos/echo';
9
- import { TypedObject } from '@dxos/echo-schema';
8
+ import { type DXN, Obj, Ref, Type } from '@dxos/echo';
10
9
 
11
10
  /**
12
11
  * Root transcript object created when the user starts a transcription.
13
12
  */
14
- export const TranscriptSchema = Schema.Struct({
13
+ export const Transcript = Schema.Struct({
15
14
  // TODO(wittjosiah): Remove?
16
15
  // TODO(burdon): Use Date or string?
17
16
  started: Schema.optional(Schema.String),
@@ -21,12 +20,14 @@ export const TranscriptSchema = Schema.Struct({
21
20
  * Queue containing TranscriptBlock objects.
22
21
  */
23
22
  queue: Type.Ref(Queue),
24
- });
23
+ }).pipe(
24
+ Type.Obj({
25
+ typename: 'dxos.org/type/Transcript',
26
+ version: '0.1.0',
27
+ }),
28
+ );
25
29
 
26
- export class TranscriptType extends TypedObject({
27
- typename: 'dxos.org/type/Transcript',
28
- version: '0.1.0',
29
- })(TranscriptSchema.fields) {}
30
+ export type Transcript = Schema.Schema.Type<typeof Transcript>;
30
31
 
31
32
  // TODO(burdon): Do these need to be kept in sync with EDGE?
32
33
 
@@ -39,3 +40,5 @@ const TranscriptHeader = Schema.Struct({
39
40
  });
40
41
 
41
42
  export type TranscriptHeader = Schema.Schema.Type<typeof TranscriptHeader>;
43
+
44
+ export const makeTranscript = (queueDxn: DXN) => Obj.make(Transcript, { queue: Ref.fromDXN(queueDxn) });
@@ -0,0 +1,24 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { SpaceSchema } from '@dxos/client/echo';
8
+
9
+ import { meta } from '../meta';
10
+
11
+ import { Transcript } from './Transcript';
12
+
13
+ /**
14
+ * Endpoint to the calls service.
15
+ */
16
+ export class Create extends Schema.TaggedClass<Create>()(`${meta.id}/action/create`, {
17
+ input: Schema.Struct({
18
+ name: Schema.optional(Schema.String),
19
+ space: SpaceSchema,
20
+ }),
21
+ output: Schema.Struct({
22
+ object: Transcript,
23
+ }),
24
+ }) {}
@@ -2,5 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './schema';
5
+ export * as TranscriptAction from './TranscriptAction';
6
+ export * as Transcript from './Transcript';
6
7
  export * from './types';
@@ -2,32 +2,8 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
-
7
- import { SpaceId } from '@dxos/react-client/echo';
8
-
9
- import { TRANSCRIPTION_PLUGIN } from '../meta';
10
-
11
- import { TranscriptType } from './schema';
12
-
13
- // TODO(burdon): Move to separate proto.
14
-
15
5
  /**
16
6
  * Endpoint to the calls service.
17
7
  */
18
8
  // TODO(burdon): Reconfigure/move.
19
9
  export const TRANSCRIPTION_URL = 'https://calls-service.dxos.workers.dev';
20
-
21
- export namespace TranscriptionAction {
22
- const TRANSCRIPTION_ACTION = `${TRANSCRIPTION_PLUGIN}/action`;
23
-
24
- export class Create extends Schema.TaggedClass<Create>()(`${TRANSCRIPTION_ACTION}/create`, {
25
- input: Schema.Struct({
26
- name: Schema.optional(Schema.String),
27
- spaceId: SpaceId,
28
- }),
29
- output: Schema.Struct({
30
- object: TranscriptType,
31
- }),
32
- }) {}
33
- }
@@ -1,11 +0,0 @@
1
- import {
2
- TranscriptContainer_default,
3
- TranscriptionContainer
4
- } from "./chunk-BJWYA2BU.mjs";
5
- import "./chunk-SREIAQSP.mjs";
6
- import "./chunk-5WH45KBY.mjs";
7
- export {
8
- TranscriptionContainer,
9
- TranscriptContainer_default as default
10
- };
11
- //# sourceMappingURL=TranscriptContainer-FH7VAWYA.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\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: PluginMeta = {\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/plugin-transcription',\n tags: ['labs'],\n screenshots: [],\n};\n"],
5
- "mappings": ";AAMO,IAAMA,uBAAuB;AAE7B,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;EACPC,aAAa,CAAA;AACf;",
6
- "names": ["TRANSCRIPTION_PLUGIN", "meta", "id", "name", "description", "icon", "source", "tags", "screenshots"]
7
- }