@dxos/plugin-transcription 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
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/dist/lib/browser/blueprints/index.mjs +1 -1
- package/dist/lib/browser/blueprints/index.mjs.map +3 -3
- package/dist/lib/browser/{chunk-5LWSJZTZ.mjs → chunk-3L623EVL.mjs} +2 -2
- package/dist/lib/browser/chunk-3L623EVL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HOOPZ7EM.mjs → chunk-KAEXRX3Y.mjs} +1 -1
- package/dist/lib/browser/{chunk-RIUSFL62.mjs → chunk-L4HW35L6.mjs} +4 -5
- package/dist/lib/browser/chunk-L4HW35L6.mjs.map +7 -0
- package/dist/lib/browser/chunk-MLRJWAQH.mjs +179 -0
- package/dist/lib/browser/chunk-MLRJWAQH.mjs.map +7 -0
- package/dist/lib/browser/chunk-NQQK7UZQ.mjs +244 -0
- package/dist/lib/browser/chunk-NQQK7UZQ.mjs.map +7 -0
- package/dist/lib/browser/components/index.mjs +207 -0
- package/dist/lib/browser/components/index.mjs.map +7 -0
- package/dist/lib/browser/{create-IZPB7VZW.mjs → create-ULR5DPJZ.mjs} +6 -4
- package/dist/lib/browser/create-ULR5DPJZ.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +17 -0
- package/dist/lib/browser/hooks/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +93 -831
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/open-SFMPLZVW.mjs +27 -0
- package/dist/lib/browser/open-SFMPLZVW.mjs.map +7 -0
- package/dist/lib/browser/operations/index.mjs +3 -3
- package/dist/lib/browser/operations/index.mjs.map +3 -3
- package/dist/lib/browser/{summarize-5MZENAU5.mjs → summarize-BDFX4APN.mjs} +15 -8
- package/dist/lib/browser/summarize-BDFX4APN.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/blueprints/index.mjs +1 -1
- package/dist/lib/node-esm/blueprints/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-3GSFEN4L.mjs → chunk-7UIZWCD4.mjs} +4 -5
- package/dist/lib/node-esm/chunk-7UIZWCD4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-C3AE2NYJ.mjs +181 -0
- package/dist/lib/node-esm/chunk-C3AE2NYJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X74WYCCE.mjs → chunk-KO3IOD2O.mjs} +2 -2
- package/dist/lib/node-esm/chunk-KO3IOD2O.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MQK4R6GT.mjs +245 -0
- package/dist/lib/node-esm/chunk-MQK4R6GT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NVM2QUMX.mjs → chunk-O533NBMK.mjs} +1 -1
- package/dist/lib/node-esm/components/index.mjs +208 -0
- package/dist/lib/node-esm/components/index.mjs.map +7 -0
- package/dist/lib/node-esm/{create-TQDGXQBL.mjs → create-A5QHNWRF.mjs} +6 -4
- package/dist/lib/node-esm/create-A5QHNWRF.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +18 -0
- package/dist/lib/node-esm/hooks/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +93 -831
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/open-OI24QNTO.mjs +28 -0
- package/dist/lib/node-esm/open-OI24QNTO.mjs.map +7 -0
- package/dist/lib/node-esm/operations/index.mjs +3 -3
- package/dist/lib/node-esm/operations/index.mjs.map +3 -3
- package/dist/lib/node-esm/{summarize-RVOSRHEC.mjs → summarize-3UNN24I2.mjs} +15 -8
- package/dist/lib/node-esm/summarize-3UNN24I2.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/TranscriptionPlugin.d.ts +1 -0
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/TranscriptionPlugin.node.d.ts +4 -0
- package/dist/types/src/TranscriptionPlugin.node.d.ts.map +1 -0
- package/dist/types/src/TranscriptionPlugin.test.d.ts +2 -0
- package/dist/types/src/TranscriptionPlugin.test.d.ts.map +1 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts +2 -2
- package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +2 -2
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/transcriber.d.ts.map +1 -1
- package/dist/types/src/components/Transcription/Transcription.d.ts +1 -1
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts +7 -7
- package/dist/types/src/components/Transcription/Transcription.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcription/transcription-extension.d.ts.map +1 -1
- package/dist/types/src/containers/TranscriptionContainer/TranscriptionContainer.d.ts.map +1 -1
- package/dist/types/src/hooks/useAudioFile.d.ts.map +1 -1
- package/dist/types/src/hooks/useAudioTrack.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/hooks/useVoiceInput.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/model/model.d.ts +2 -2
- package/dist/types/src/model/model.d.ts.map +1 -1
- package/dist/types/src/{segments-normalization → normalization}/index.d.ts +1 -1
- package/dist/types/src/normalization/index.d.ts.map +1 -0
- package/dist/types/src/normalization/message-normalizer.d.ts.map +1 -0
- package/dist/types/src/{segments-normalization → normalization}/normalization.d.ts +155 -153
- package/dist/types/src/normalization/normalization.d.ts.map +1 -0
- package/dist/types/src/normalization/normalization.test.d.ts.map +1 -0
- package/dist/types/src/normalization/utils.d.ts.map +1 -0
- package/dist/types/src/operations/create.d.ts +1 -1
- package/dist/types/src/operations/create.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +394 -382
- package/dist/types/src/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +1 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/operations/open.d.ts +1 -1
- package/dist/types/src/operations/open.d.ts.map +1 -1
- package/dist/types/src/operations/summarize.d.ts +1 -1
- package/dist/types/src/operations/summarize.d.ts.map +1 -1
- package/dist/types/src/{components/stories → stories}/FileTranscription.stories.d.ts +3 -3
- package/dist/types/src/stories/FileTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/stories/KeyWordRecognition.stories.d.ts.map +1 -0
- package/dist/types/src/{components/stories → stories}/MicrophoneTranscription.stories.d.ts +1 -1
- package/dist/types/src/stories/MicrophoneTranscription.stories.d.ts.map +1 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts +23 -0
- package/dist/types/src/stories/TranscriptionStory.d.ts.map +1 -0
- package/dist/types/src/stories/useIsSpeaking.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/index.d.ts +1 -1
- package/dist/types/src/transcriber/index.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +57 -2
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.test.d.ts +2 -0
- package/dist/types/src/transcriber/transcriber.test.d.ts.map +1 -0
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +7 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +2 -1
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/{types.d.ts → defs.d.ts} +1 -1
- package/dist/types/src/types/defs.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/array.d.ts.map +1 -1
- package/dist/types/src/util/get-time-str.d.ts.map +1 -1
- package/dist/types/src/util/monitor-audio-level.d.ts.map +1 -1
- package/dist/types/src/util/render-byline.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +76 -67
- package/src/TranscriptionPlugin.node.ts +48 -0
- package/src/TranscriptionPlugin.test.ts +31 -0
- package/src/TranscriptionPlugin.tsx +7 -3
- package/src/blueprints/transcription-blueprint.ts +2 -3
- package/src/capabilities/blueprint-definition.ts +2 -0
- package/src/capabilities/index.ts +2 -1
- package/src/capabilities/operation-handler.ts +1 -1
- package/src/capabilities/react-surface.tsx +4 -2
- package/src/capabilities/transcriber.ts +2 -0
- package/src/components/Transcription/Transcription.stories.tsx +3 -5
- package/src/containers/TranscriptionContainer/TranscriptionContainer.tsx +4 -2
- package/src/hooks/useTranscriber.ts +3 -1
- package/src/index.ts +9 -4
- package/src/model/model.test.ts +3 -3
- package/src/model/model.ts +3 -3
- package/src/{segments-normalization → normalization}/message-normalizer.ts +1 -5
- package/src/{segments-normalization → normalization}/normalization.ts +5 -5
- package/src/operations/create.ts +4 -2
- package/src/operations/definitions.ts +3 -4
- package/src/operations/index.ts +1 -1
- package/src/operations/open.ts +5 -8
- package/src/operations/summarize.ts +11 -7
- package/src/{components/stories → stories}/FileTranscription.stories.tsx +24 -5
- package/src/{components/stories → stories}/KeyWordRecognition.stories.tsx +30 -28
- package/src/{components/stories → stories}/MicrophoneTranscription.stories.tsx +3 -3
- package/src/stories/TranscriptionStory.tsx +93 -0
- package/src/transcriber/index.ts +1 -1
- package/src/transcriber/transcriber.test.ts +104 -0
- package/src/transcriber/transcriber.ts +92 -51
- package/src/types/capabilities.ts +6 -1
- package/src/types/index.ts +1 -1
- package/dist/lib/browser/chunk-5LWSJZTZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-RIUSFL62.mjs.map +0 -7
- package/dist/lib/browser/create-IZPB7VZW.mjs.map +0 -7
- package/dist/lib/browser/open-SN5O5I6X.mjs +0 -29
- package/dist/lib/browser/open-SN5O5I6X.mjs.map +0 -7
- package/dist/lib/browser/summarize-5MZENAU5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3GSFEN4L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-X74WYCCE.mjs.map +0 -7
- package/dist/lib/node-esm/create-TQDGXQBL.mjs.map +0 -7
- package/dist/lib/node-esm/open-4GAAWWKJ.mjs +0 -30
- package/dist/lib/node-esm/open-4GAAWWKJ.mjs.map +0 -7
- package/dist/lib/node-esm/summarize-RVOSRHEC.mjs.map +0 -7
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/KeyWordRecognition.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +0 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +0 -12
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +0 -1
- package/dist/types/src/components/stories/useIsSpeaking.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/index.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/normalization.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/normalization.test.d.ts.map +0 -1
- package/dist/types/src/segments-normalization/utils.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/components/stories/TranscriptionStory.tsx +0 -43
- package/dist/lib/browser/{chunk-HOOPZ7EM.mjs.map → chunk-KAEXRX3Y.mjs.map} +0 -0
- package/dist/lib/node-esm/{chunk-NVM2QUMX.mjs.map → chunk-O533NBMK.mjs.map} +0 -0
- package/dist/types/src/{segments-normalization → normalization}/message-normalizer.d.ts +0 -0
- package/dist/types/src/{segments-normalization → normalization}/normalization.test.d.ts +0 -0
- package/dist/types/src/{segments-normalization → normalization}/utils.d.ts +0 -0
- package/dist/types/src/{components/stories → stories}/KeyWordRecognition.stories.d.ts +0 -0
- package/dist/types/src/{components/stories → stories}/useIsSpeaking.d.ts +0 -0
- package/src/{segments-normalization → normalization}/index.ts +1 -1
- /package/src/{segments-normalization → normalization}/normalization.test.ts +0 -0
- /package/src/{segments-normalization → normalization}/utils.ts +0 -0
- /package/src/{components/stories → stories}/useIsSpeaking.tsx +0 -0
- /package/src/types/{types.ts → defs.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Summarize
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-L4HW35L6.mjs";
|
|
4
4
|
import "./chunk-J5LGTIGS.mjs";
|
|
5
5
|
|
|
6
6
|
// src/operations/summarize.ts
|
|
@@ -10,13 +10,12 @@ import * as Function from "effect/Function";
|
|
|
10
10
|
import * as Layer from "effect/Layer";
|
|
11
11
|
import * as Option from "effect/Option";
|
|
12
12
|
import { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from "@dxos/ai";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import { Operation } from "@dxos/operation";
|
|
13
|
+
import { AiRequest, GenerationObserver } from "@dxos/assistant";
|
|
14
|
+
import { Trace, Operation, OperationRegistry } from "@dxos/compute";
|
|
15
|
+
import { Database } from "@dxos/echo";
|
|
17
16
|
import { trim } from "@dxos/util";
|
|
18
17
|
var handler = Summarize.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ transcript, notes }) {
|
|
19
|
-
const result = yield* new
|
|
18
|
+
const result = yield* new AiRequest({
|
|
20
19
|
observer: GenerationObserver.fromPrinter(new ConsolePrinter({
|
|
21
20
|
tag: "summarize"
|
|
22
21
|
}))
|
|
@@ -31,7 +30,15 @@ Notes: ${notes}`,
|
|
|
31
30
|
return {
|
|
32
31
|
summary
|
|
33
32
|
};
|
|
34
|
-
}, Effect.provide(Layer.mergeAll(AiService.model("@anthropic/claude-sonnet-4-0"), ToolResolverService.layerEmpty, ToolExecutionService.layerEmpty,
|
|
33
|
+
}, Effect.provide(Layer.mergeAll(AiService.model("@anthropic/claude-sonnet-4-0"), ToolResolverService.layerEmpty, ToolExecutionService.layerEmpty, Trace.writerLayerNoop, Database.notAvailable, Layer.succeed(Operation.Service, {
|
|
34
|
+
invoke: () => Effect.die("Not available."),
|
|
35
|
+
schedule: () => Effect.die("Not available."),
|
|
36
|
+
invokePromise: async () => ({
|
|
37
|
+
error: new Error("Not available.")
|
|
38
|
+
})
|
|
39
|
+
}), Layer.succeed(OperationRegistry.Service, {
|
|
40
|
+
resolve: () => Effect.succeed(void 0)
|
|
41
|
+
}))))));
|
|
35
42
|
var summarize_default = handler;
|
|
36
43
|
var systemPrompt = trim`
|
|
37
44
|
You are a helpful assistant that summarizes transcripts of meetings.
|
|
@@ -68,4 +75,4 @@ var systemPrompt = trim`
|
|
|
68
75
|
export {
|
|
69
76
|
summarize_default as default
|
|
70
77
|
};
|
|
71
|
-
//# sourceMappingURL=summarize-
|
|
78
|
+
//# sourceMappingURL=summarize-BDFX4APN.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/operations/summarize.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Array from 'effect/Array';\nimport * as Effect from 'effect/Effect';\nimport * as Function from 'effect/Function';\nimport * as Layer from 'effect/Layer';\nimport * as Option from 'effect/Option';\n\nimport { AiService, ConsolePrinter, ToolExecutionService, ToolResolverService } from '@dxos/ai';\nimport { AiRequest, GenerationObserver } from '@dxos/assistant';\nimport { Trace, Operation, OperationRegistry } from '@dxos/compute';\nimport { Database } from '@dxos/echo';\nimport { trim } from '@dxos/util';\n\nimport { Summarize } from './definitions';\n\n/**\n * Summarize a transcript of a meeting.\n */\nconst handler: Operation.WithHandler<typeof Summarize> = Summarize.pipe(\n Operation.withHandler(\n Effect.fnUntraced(\n function* ({ transcript, notes }) {\n const result = yield* new AiRequest({\n observer: GenerationObserver.fromPrinter(new ConsolePrinter({ tag: 'summarize' })),\n }).run({\n prompt: `Transcript: ${transcript}\\n\\nNotes: ${notes}`,\n history: [],\n system: systemPrompt,\n });\n\n const summary = Function.pipe(\n result,\n Array.findLast((msg) => msg.sender.role === 'assistant' && msg.blocks.some((block) => block._tag === 'text')),\n Option.flatMap((msg) =>\n Function.pipe(\n msg.blocks,\n Array.findLast((block) => block._tag === 'text'),\n Option.map((block) => block.text),\n ),\n ),\n Option.getOrThrowWith(() => new Error('No summary found')),\n );\n\n return { summary };\n },\n Effect.provide(\n Layer.mergeAll(\n AiService.model('@anthropic/claude-sonnet-4-0'),\n ToolResolverService.layerEmpty,\n ToolExecutionService.layerEmpty,\n Trace.writerLayerNoop,\n Database.notAvailable,\n Layer.succeed(Operation.Service, {\n invoke: () => Effect.die('Not available.'),\n schedule: () => Effect.die('Not available.'),\n invokePromise: async () => ({ error: new Error('Not available.') }),\n } as any),\n Layer.succeed(OperationRegistry.Service, { resolve: () => Effect.succeed(undefined) } as any),\n ),\n ),\n ),\n ),\n);\n\nexport default handler;\n\nconst systemPrompt = trim`\n You are a helpful assistant that summarizes transcripts of meetings.\n\n # Goal\n Create a markdown summary of the meeting transcript with text notes provided.\n Notes are very important so make sure to include them in the summary if they contain meaningful information.\n\n # Formatting\n - Format the summary as a markdown document without extra comments like \"Here is the summary of the transcript:\".\n - Use markdown formatting for headings and bullet points.\n - Format the summary as a list of key points and takeaways.\n - All names of people should be in bold.\n\n # Note Taking\n - Correlate items in the summary with the person of origin to build a coherent narrative.\n - Include short quotes verbatim where appropriate. Especially when concerned with design decisions and problem descriptions.\n\n # Tasks\n At the end of the summary include tasks.\n Extract only the tasks that are:\n - Directly actionable.\n - Clearly assigned to a person or team (or can easily be inferred).\n - Strongly implied by the conversation and/or user note (no speculative tasks).\n - Specific enough that someone reading them would know exactly what to do next.\n\n Format all tasks as markdown checkboxes using the syntax:\n - [ ] Task description.\n\n Additional information can be included (indented).\n\n If no actionable tasks are found, omit this tasks section.\n`;\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,YAAYA,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,cAAc;AAC1B,YAAYC,WAAW;AACvB,YAAYC,YAAY;AAExB,SAASC,WAAWC,gBAAgBC,sBAAsBC,2BAA2B;AACrF,SAASC,WAAWC,0BAA0B;AAC9C,SAASC,OAAOC,WAAWC,yBAAyB;AACpD,SAASC,gBAAgB;AACzB,SAASC,YAAY;AAOrB,IAAMC,UAAmDC,UAAUC,KACjEC,UAAUC,YACDC,kBACL,WAAW,EAAEC,YAAYC,MAAK,GAAE;AAC9B,QAAMC,SAAS,OAAO,IAAIC,UAAU;IAClCC,UAAUC,mBAAmBC,YAAY,IAAIC,eAAe;MAAEC,KAAK;IAAY,CAAA,CAAA;EACjF,CAAA,EAAGC,IAAI;IACLC,QAAQ,eAAeV,UAAAA;;SAAwBC,KAAAA;IAC/CU,SAAS,CAAA;IACTC,QAAQC;EACV,CAAA;AAEA,QAAMC,UAAmBlB,cACvBM,QACMa,eAAS,CAACC,QAAQA,IAAIC,OAAOC,SAAS,eAAeF,IAAIG,OAAOC,KAAK,CAACC,UAAUA,MAAMC,SAAS,MAAA,CAAA,GAC9FC,eAAQ,CAACP,QACLpB,cACPoB,IAAIG,QACEJ,eAAS,CAACM,UAAUA,MAAMC,SAAS,MAAA,GAClCE,WAAI,CAACH,UAAUA,MAAMI,IAAI,CAAA,CAAA,GAG7BC,sBAAe,MAAM,IAAIC,MAAM,kBAAA,CAAA,CAAA;AAGxC,SAAO;IAAEb;EAAQ;AACnB,GACOc,eACCC,eACJC,UAAUC,MAAM,8BAAA,GAChBC,oBAAoBC,YACpBC,qBAAqBD,YACrBE,MAAMC,iBACNC,SAASC,cACHC,cAAQ1C,UAAU2C,SAAS;EAC/BC,QAAQ,MAAaC,WAAI,gBAAA;EACzBC,UAAU,MAAaD,WAAI,gBAAA;EAC3BE,eAAe,aAAa;IAAEC,OAAO,IAAIlB,MAAM,gBAAA;EAAkB;AACnE,CAAA,GACMY,cAAQO,kBAAkBN,SAAS;EAAEO,SAAS,MAAaR,eAAQS,MAAAA;AAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAO9F,IAAA,oBAAetD;AAEf,IAAMmB,eAAeoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;",
|
|
6
|
+
"names": ["Array", "Effect", "Function", "Layer", "Option", "AiService", "ConsolePrinter", "ToolExecutionService", "ToolResolverService", "AiRequest", "GenerationObserver", "Trace", "Operation", "OperationRegistry", "Database", "trim", "handler", "Summarize", "pipe", "Operation", "withHandler", "fnUntraced", "transcript", "notes", "result", "AiRequest", "observer", "GenerationObserver", "fromPrinter", "ConsolePrinter", "tag", "run", "prompt", "history", "system", "systemPrompt", "summary", "findLast", "msg", "sender", "role", "blocks", "some", "block", "_tag", "flatMap", "map", "text", "getOrThrowWith", "Error", "provide", "mergeAll", "AiService", "model", "ToolResolverService", "layerEmpty", "ToolExecutionService", "Trace", "writerLayerNoop", "Database", "notAvailable", "succeed", "Service", "invoke", "die", "schedule", "invokePromise", "error", "OperationRegistry", "resolve", "undefined", "trim"]
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
2
2
|
import "../chunk-HSLMI22Q.mjs";
|
|
3
3
|
|
|
4
4
|
// src/blueprints/transcription-blueprint.ts
|
|
5
|
-
import { Blueprint, Template } from "@dxos/
|
|
5
|
+
import { Blueprint, Template } from "@dxos/compute";
|
|
6
6
|
import { trim } from "@dxos/util";
|
|
7
7
|
import { TranscriptOperation } from "#operations";
|
|
8
8
|
var BLUEPRINT_KEY = "org.dxos.blueprint.transcription";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/blueprints/transcription-blueprint.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": ";;;;
|
|
6
|
-
"names": ["Blueprint", "Template", "trim", "TranscriptOperation", "BLUEPRINT_KEY", "make", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Blueprint, Template } from '@dxos/compute';\nimport { trim } from '@dxos/util';\n\nimport { TranscriptOperation } from '#operations';\n\nconst BLUEPRINT_KEY = 'org.dxos.blueprint.transcription';\n\nconst make = () =>\n Blueprint.make({\n key: BLUEPRINT_KEY,\n name: 'Transcription',\n tools: Blueprint.toolDefinitions({ operations: [TranscriptOperation.Open, TranscriptOperation.Summarize] }),\n instructions: Template.make({\n source: trim`\n You can open and summarize a meeting transcript.\n `,\n }),\n });\n\nconst blueprint: Blueprint.Definition = {\n key: BLUEPRINT_KEY,\n make,\n};\n\nexport default blueprint;\n"],
|
|
5
|
+
"mappings": ";;;;AAIA,SAASA,WAAWC,gBAAgB;AACpC,SAASC,YAAY;AAErB,SAASC,2BAA2B;AAEpC,IAAMC,gBAAgB;AAEtB,IAAMC,OAAO,MACXL,UAAUK,KAAK;EACbC,KAAKF;EACLG,MAAM;EACNC,OAAOR,UAAUS,gBAAgB;IAAEC,YAAY;MAACP,oBAAoBQ;MAAMR,oBAAoBS;;EAAW,CAAA;EACzGC,cAAcZ,SAASI,KAAK;IAC1BS,QAAQZ;;;EAGV,CAAA;AACF,CAAA;AAEF,IAAMa,YAAkC;EACtCT,KAAKF;EACLC;AACF;AAEA,IAAA,kCAAeU;",
|
|
6
|
+
"names": ["Blueprint", "Template", "trim", "TranscriptOperation", "BLUEPRINT_KEY", "make", "key", "name", "tools", "toolDefinitions", "operations", "Open", "Summarize", "instructions", "source", "blueprint"]
|
|
7
7
|
}
|
|
@@ -17,9 +17,8 @@ __export(definitions_exports, {
|
|
|
17
17
|
import * as Schema from "effect/Schema";
|
|
18
18
|
import { AiService } from "@dxos/ai";
|
|
19
19
|
import { SpaceSchema } from "@dxos/client/echo";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { Operation } from "@dxos/operation";
|
|
20
|
+
import { Operation } from "@dxos/compute";
|
|
21
|
+
import { Database, Feed, Ref } from "@dxos/echo";
|
|
23
22
|
import { Message, Transcript } from "@dxos/types";
|
|
24
23
|
import { meta } from "#meta";
|
|
25
24
|
var TRANSCRIPT_OPERATION = `${meta.id}.operation`;
|
|
@@ -57,7 +56,7 @@ var Open = Operation.make({
|
|
|
57
56
|
}),
|
|
58
57
|
services: [
|
|
59
58
|
Database.Service,
|
|
60
|
-
|
|
59
|
+
Feed.FeedService
|
|
61
60
|
]
|
|
62
61
|
});
|
|
63
62
|
var Summarize = Operation.make({
|
|
@@ -110,4 +109,4 @@ export {
|
|
|
110
109
|
Summarize,
|
|
111
110
|
definitions_exports
|
|
112
111
|
};
|
|
113
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-7UIZWCD4.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/operations/definitions.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { AiService } from '@dxos/ai';\nimport { SpaceSchema } from '@dxos/client/echo';\nimport { Operation } from '@dxos/compute';\nimport { Database, Feed, Ref } from '@dxos/echo';\nimport { Message, Transcript } from '@dxos/types';\n\nimport { meta } from '#meta';\n\nconst TRANSCRIPT_OPERATION = `${meta.id}.operation`;\n\nexport const Create = Operation.make({\n meta: { key: `${TRANSCRIPT_OPERATION}.create`, name: 'Create Transcript' },\n input: Schema.Struct({\n name: Schema.optional(Schema.String),\n space: SpaceSchema,\n }),\n output: Schema.Struct({\n object: Transcript.Transcript,\n }),\n});\n\nexport const MessageWithRangeId = Schema.extend(\n Message.Message,\n Schema.Struct({\n rangeId: Schema.optional(Schema.Array(Schema.String)).annotations({\n description: 'The IDs of the messages that contain the sentences.',\n }),\n }),\n);\n\nexport type MessageWithRangeIdType = Schema.Schema.Type<typeof MessageWithRangeId>;\n\nexport const Open = Operation.make({\n meta: {\n key: 'org.dxos.function.transcription.open',\n name: 'Open',\n description: 'Opens and reads the contents of a transcription object.',\n },\n input: Schema.Struct({\n transcript: Ref.Ref(Transcript.Transcript).annotations({\n description: 'The ID of the transcription object.',\n }),\n }),\n output: Schema.Struct({\n content: Schema.String,\n }),\n services: [Database.Service, Feed.FeedService],\n});\n\nexport const Summarize = Operation.make({\n meta: {\n key: 'org.dxos.function.transcription.summarize',\n name: 'Summarize',\n description: 'Summarize a transcript of a meeting.',\n },\n input: Schema.Struct({\n transcript: Schema.String.annotations({\n description: 'The transcript of the meeting.',\n }),\n notes: Schema.optional(Schema.String).annotations({\n description: 'Additional notes from the participants.',\n }),\n }),\n output: Schema.Struct({\n summary: Schema.String.annotations({\n description: 'The summary of the transcript.',\n }),\n }),\n services: [AiService.AiService],\n});\n\nexport const SentenceNormalizationInput = Schema.Struct({\n messages: Schema.Array(MessageWithRangeId).annotations({\n description: 'Messages to normalize into sentences.',\n }),\n});\n\nexport type SentenceNormalizationInputType = Schema.Schema.Type<typeof SentenceNormalizationInput>;\n\nexport const SentenceNormalizationOutput = Schema.Struct({\n sentences: Schema.Array(MessageWithRangeId.pipe(Schema.mutable)).pipe(Schema.mutable).annotations({\n description: 'The sentences of the transcript.',\n }),\n});\n\nexport const SentenceNormalization = Operation.make({\n meta: {\n key: 'org.dxos.function.transcription.sentence-normalization',\n name: 'Sentence Normalization',\n description: 'Post process of transcription for sentence normalization',\n },\n input: SentenceNormalizationInput,\n output: SentenceNormalizationOutput,\n services: [],\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;AAAA;;;;;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,iBAAiB;AAC1B,SAASC,mBAAmB;AAC5B,SAASC,iBAAiB;AAC1B,SAASC,UAAUC,MAAMC,WAAW;AACpC,SAASC,SAASC,kBAAkB;AAEpC,SAASC,YAAY;AAErB,IAAMC,uBAAuB,GAAGD,KAAKE,EAAE;AAEhC,IAAMC,SAAST,UAAUU,KAAK;EACnCJ,MAAM;IAAEK,KAAK,GAAGJ,oBAAAA;IAA+BK,MAAM;EAAoB;EACzEC,OAAcC,cAAO;IACnBF,MAAaG,gBAAgBC,aAAM;IACnCC,OAAOlB;EACT,CAAA;EACAmB,QAAeJ,cAAO;IACpBK,QAAQd,WAAWA;EACrB,CAAA;AACF,CAAA;AAEO,IAAMe,qBAA4BC,cACvCjB,QAAQA,SACDU,cAAO;EACZQ,SAAgBP,gBAAgBQ,aAAaP,aAAM,CAAA,EAAGQ,YAAY;IAChEC,aAAa;EACf,CAAA;AACF,CAAA,CAAA;AAKK,IAAMC,OAAO1B,UAAUU,KAAK;EACjCJ,MAAM;IACJK,KAAK;IACLC,MAAM;IACNa,aAAa;EACf;EACAZ,OAAcC,cAAO;IACnBa,YAAYxB,IAAIA,IAAIE,WAAWA,UAAU,EAAEmB,YAAY;MACrDC,aAAa;IACf,CAAA;EACF,CAAA;EACAP,QAAeJ,cAAO;IACpBc,SAAgBZ;EAClB,CAAA;EACAa,UAAU;IAAC5B,SAAS6B;IAAS5B,KAAK6B;;AACpC,CAAA;AAEO,IAAMC,YAAYhC,UAAUU,KAAK;EACtCJ,MAAM;IACJK,KAAK;IACLC,MAAM;IACNa,aAAa;EACf;EACAZ,OAAcC,cAAO;IACnBa,YAAmBX,cAAOQ,YAAY;MACpCC,aAAa;IACf,CAAA;IACAQ,OAAclB,gBAAgBC,aAAM,EAAEQ,YAAY;MAChDC,aAAa;IACf,CAAA;EACF,CAAA;EACAP,QAAeJ,cAAO;IACpBoB,SAAgBlB,cAAOQ,YAAY;MACjCC,aAAa;IACf,CAAA;EACF,CAAA;EACAI,UAAU;IAAC/B,UAAUA;;AACvB,CAAA;AAEO,IAAMqC,6BAAoCrB,cAAO;EACtDsB,UAAiBb,aAAMH,kBAAAA,EAAoBI,YAAY;IACrDC,aAAa;EACf,CAAA;AACF,CAAA;AAIO,IAAMY,8BAAqCvB,cAAO;EACvDwB,WAAkBf,aAAMH,mBAAmBmB,KAAYC,cAAO,CAAA,EAAGD,KAAYC,cAAO,EAAEhB,YAAY;IAChGC,aAAa;EACf,CAAA;AACF,CAAA;AAEO,IAAMgB,wBAAwBzC,UAAUU,KAAK;EAClDJ,MAAM;IACJK,KAAK;IACLC,MAAM;IACNa,aAAa;EACf;EACAZ,OAAOsB;EACPjB,QAAQmB;EACRR,UAAU,CAAA;AACZ,CAAA;",
|
|
6
|
+
"names": ["Schema", "AiService", "SpaceSchema", "Operation", "Database", "Feed", "Ref", "Message", "Transcript", "meta", "TRANSCRIPT_OPERATION", "id", "Create", "make", "key", "name", "input", "Struct", "optional", "String", "space", "output", "object", "MessageWithRangeId", "extend", "rangeId", "Array", "annotations", "description", "Open", "transcript", "content", "services", "Service", "FeedService", "Summarize", "notes", "summary", "SentenceNormalizationInput", "messages", "SentenceNormalizationOutput", "sentences", "pipe", "mutable", "SentenceNormalization"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/model/model.ts
|
|
4
|
+
import { Text } from "@codemirror/state";
|
|
5
|
+
import { Event } from "@dxos/async";
|
|
6
|
+
import { invariant } from "@dxos/invariant";
|
|
7
|
+
import { log } from "@dxos/log";
|
|
8
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/model/model.ts";
|
|
9
|
+
var DocumentAdapter = class {
|
|
10
|
+
_view;
|
|
11
|
+
constructor(_view) {
|
|
12
|
+
this._view = _view;
|
|
13
|
+
}
|
|
14
|
+
/** The document must always have at least one line. */
|
|
15
|
+
lineCount() {
|
|
16
|
+
return this._view.state.doc.lines - 1;
|
|
17
|
+
}
|
|
18
|
+
replaceLines(from, remove, insert) {
|
|
19
|
+
log("replaceLines", {
|
|
20
|
+
count: this._view.state.doc.lines,
|
|
21
|
+
from,
|
|
22
|
+
remove,
|
|
23
|
+
insert
|
|
24
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 19, S: this });
|
|
25
|
+
const numLines = this._view.state.doc.lines;
|
|
26
|
+
const posFrom = this._view.state.doc.line(from).from;
|
|
27
|
+
const posTo = remove === 0 ? posFrom : this._view.state.doc.line(Math.min(numLines, from + remove)).from;
|
|
28
|
+
let text = insert.join("\n");
|
|
29
|
+
if (posTo === this._view.state.doc.length) {
|
|
30
|
+
text += "\n";
|
|
31
|
+
}
|
|
32
|
+
this._view.dispatch({
|
|
33
|
+
changes: {
|
|
34
|
+
from: posFrom,
|
|
35
|
+
to: posTo,
|
|
36
|
+
insert: text
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var SerializationModel = class {
|
|
42
|
+
_renderer;
|
|
43
|
+
/** Emits when the document is updated. */
|
|
44
|
+
update = new Event();
|
|
45
|
+
/** Ordered set of chunks. */
|
|
46
|
+
_chunks = [];
|
|
47
|
+
/** Map of chunk IDs to their current line counts. */
|
|
48
|
+
_chunkLineCounts = /* @__PURE__ */ new Map();
|
|
49
|
+
/** Map of line numbers to chunk IDs. */
|
|
50
|
+
_lineToChunk = /* @__PURE__ */ new Map();
|
|
51
|
+
/** Track chunk changes since last sync. */
|
|
52
|
+
_changes = [];
|
|
53
|
+
constructor(_renderer, initialChunks = []) {
|
|
54
|
+
this._renderer = _renderer;
|
|
55
|
+
initialChunks.forEach((chunk) => {
|
|
56
|
+
this.appendChunk(chunk);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
toJSON() {
|
|
60
|
+
return {
|
|
61
|
+
chunks: this._chunks.length,
|
|
62
|
+
changes: this._changes.length
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
get doc() {
|
|
66
|
+
return Text.of([
|
|
67
|
+
...this._chunks.flatMap((chunk, index) => this._renderer(chunk, index)),
|
|
68
|
+
""
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
get chunks() {
|
|
72
|
+
return this._chunks;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the block ID at the given line number.
|
|
76
|
+
*/
|
|
77
|
+
getChunkAtLine(line) {
|
|
78
|
+
return this._lineToChunk.get(line);
|
|
79
|
+
}
|
|
80
|
+
reset() {
|
|
81
|
+
this._chunks.length = 0;
|
|
82
|
+
this._chunkLineCounts.clear();
|
|
83
|
+
this._lineToChunk.clear();
|
|
84
|
+
this.update.emit();
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
appendChunk(chunk) {
|
|
88
|
+
const index = this._chunks.length;
|
|
89
|
+
this._chunks.push(chunk);
|
|
90
|
+
this._changes.push({
|
|
91
|
+
type: "append",
|
|
92
|
+
index,
|
|
93
|
+
chunk
|
|
94
|
+
});
|
|
95
|
+
this.update.emit();
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
updateChunk(chunk) {
|
|
99
|
+
const index = this._chunks.findIndex((c) => c.id === chunk.id);
|
|
100
|
+
invariant(index !== -1, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 102, S: this, A: ["index !== -1", ""] });
|
|
101
|
+
this._chunks[index] = chunk;
|
|
102
|
+
this._changes.push({
|
|
103
|
+
type: "update",
|
|
104
|
+
index,
|
|
105
|
+
chunk
|
|
106
|
+
});
|
|
107
|
+
this.update.emit();
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
deleteBlock(id) {
|
|
111
|
+
const index = this._chunks.findIndex((c) => c.id === id);
|
|
112
|
+
invariant(index !== -1, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 114, S: this, A: ["index !== -1", ""] });
|
|
113
|
+
this._chunks.splice(index, 1);
|
|
114
|
+
this._changes.push({
|
|
115
|
+
type: "delete",
|
|
116
|
+
index,
|
|
117
|
+
id
|
|
118
|
+
});
|
|
119
|
+
this.update.emit();
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Syncs the tracked changes with the ChunkDocument.
|
|
124
|
+
*/
|
|
125
|
+
sync(document) {
|
|
126
|
+
log("sync", {
|
|
127
|
+
changes: this._changes
|
|
128
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 127, S: this });
|
|
129
|
+
for (const change of this._changes) {
|
|
130
|
+
switch (change.type) {
|
|
131
|
+
case "append": {
|
|
132
|
+
const lines = this._renderer(change.chunk, change.index);
|
|
133
|
+
const lastLine = document.lineCount();
|
|
134
|
+
document.replaceLines(lastLine + 1, 0, lines);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
case "update": {
|
|
138
|
+
let lineStart = 1;
|
|
139
|
+
for (let i = 0; i < change.index; i++) {
|
|
140
|
+
lineStart += this._chunkLineCounts.get(this._chunks[i].id);
|
|
141
|
+
}
|
|
142
|
+
const previousLineCount = this._chunkLineCounts.get(change.chunk.id);
|
|
143
|
+
const newLines = this._renderer(change.chunk, change.index);
|
|
144
|
+
document.replaceLines(lineStart, previousLineCount, newLines);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
case "delete": {
|
|
148
|
+
let lineStart = 1;
|
|
149
|
+
for (let i = 0; i < change.index; i++) {
|
|
150
|
+
lineStart += this._chunkLineCounts.get(this._chunks[i].id);
|
|
151
|
+
}
|
|
152
|
+
const previousLineCount = this._chunkLineCounts.get(change.id);
|
|
153
|
+
document.replaceLines(lineStart, previousLineCount, []);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
this._lineToChunk.clear();
|
|
159
|
+
let currentLine = 1;
|
|
160
|
+
for (const [index, chunk] of this._chunks.entries()) {
|
|
161
|
+
const lineCount = this._renderer(chunk, index).length;
|
|
162
|
+
this._chunkLineCounts.set(chunk.id, lineCount);
|
|
163
|
+
this._lineToChunk.set(currentLine, chunk);
|
|
164
|
+
currentLine += lineCount;
|
|
165
|
+
}
|
|
166
|
+
const chunkIds = new Set(this._chunks.map((chunk) => chunk.id));
|
|
167
|
+
for (const id of this._chunkLineCounts.keys()) {
|
|
168
|
+
if (!chunkIds.has(id)) {
|
|
169
|
+
this._chunkLineCounts.delete(id);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
this._changes.length = 0;
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
DocumentAdapter,
|
|
179
|
+
SerializationModel
|
|
180
|
+
};
|
|
181
|
+
//# sourceMappingURL=chunk-C3AE2NYJ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/model/model.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Text } from '@codemirror/state';\nimport { type EditorView } from '@codemirror/view';\n\nimport { Event } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nexport type Chunk = { id: string };\n\n/**\n * Covert block to a set of markdown lines.\n */\nexport type ChunkRenderer<T extends Chunk> = (chunk: T, index: number, debug?: boolean) => string[];\n\n/**\n * Abstract representation of the document model.\n */\nexport interface ChunkDocument {\n lineCount(): number;\n replaceLines(from: number, remove: number, insert: string[]): void;\n}\n\n/**\n * Codemirror document adapter.\n */\nexport class DocumentAdapter implements ChunkDocument {\n constructor(private readonly _view: EditorView) {}\n\n /** The document must always have at least one line. */\n lineCount(): number {\n return this._view.state.doc.lines - 1;\n }\n\n replaceLines(from: number, remove: number, insert: string[]): void {\n log('replaceLines', { count: this._view.state.doc.lines, from, remove, insert });\n\n const numLines = this._view.state.doc.lines;\n const posFrom = this._view.state.doc.line(from).from;\n const posTo = remove === 0 ? posFrom : this._view.state.doc.line(Math.min(numLines, from + remove)).from;\n\n // Don't remove the last line.\n let text = insert.join('\\n');\n if (posTo === this._view.state.doc.length) {\n text += '\\n';\n }\n\n this._view.dispatch({\n changes: { from: posFrom, to: posTo, insert: text },\n });\n }\n}\n\ntype ChunkChange<T extends Chunk> =\n | {\n type: 'append';\n index: number;\n chunk: T;\n }\n | {\n type: 'update';\n index: number;\n chunk: T;\n }\n | {\n type: 'delete';\n index: number;\n id: string;\n };\n\n/**\n * Each Chunk can be converted into a set of lines.\n * Chunks can be added, updated or deleted from the Queue.\n * A Document is an immutable projection that represents a flat list of lines corresponding to the Queue.\n *\n * Ideally we would implement a custom virtual Text model for the View, but this currently isn't possible in Codemirror.\n * Instead this model tracks changes and syncs them with the ChunkDocument.\n */\nexport class SerializationModel<T extends Chunk> {\n /** Emits when the document is updated. */\n public readonly update = new Event<void>();\n\n /** Ordered set of chunks. */\n private readonly _chunks: T[] = [];\n\n /** Map of chunk IDs to their current line counts. */\n private readonly _chunkLineCounts = new Map<string, number>();\n\n /** Map of line numbers to chunk IDs. */\n private readonly _lineToChunk = new Map<number, T>();\n\n /** Track chunk changes since last sync. */\n private readonly _changes: Array<ChunkChange<T>> = [];\n\n constructor(\n private readonly _renderer: ChunkRenderer<T>,\n initialChunks: T[] = [],\n ) {\n initialChunks.forEach((chunk) => {\n this.appendChunk(chunk);\n });\n }\n\n toJSON(): { chunks: number; changes: number } {\n return {\n chunks: this._chunks.length,\n changes: this._changes.length,\n };\n }\n\n get doc() {\n return Text.of([...this._chunks.flatMap((chunk, index) => this._renderer(chunk, index)), '']);\n }\n\n get chunks() {\n return this._chunks;\n }\n\n /**\n * Get the block ID at the given line number.\n */\n getChunkAtLine(line: number): T | undefined {\n return this._lineToChunk.get(line);\n }\n\n reset(): this {\n this._chunks.length = 0;\n this._chunkLineCounts.clear();\n this._lineToChunk.clear();\n this.update.emit();\n return this;\n }\n\n appendChunk(chunk: T): this {\n const index = this._chunks.length;\n this._chunks.push(chunk);\n this._changes.push({ type: 'append', index, chunk });\n this.update.emit();\n return this;\n }\n\n updateChunk(chunk: T): this {\n const index = this._chunks.findIndex((c) => c.id === chunk.id);\n invariant(index !== -1);\n this._chunks[index] = chunk;\n this._changes.push({ type: 'update', index, chunk });\n this.update.emit();\n return this;\n }\n\n deleteBlock(id: string): this {\n const index = this._chunks.findIndex((c) => c.id === id);\n invariant(index !== -1);\n this._chunks.splice(index, 1);\n this._changes.push({ type: 'delete', index, id });\n this.update.emit();\n return this;\n }\n\n /**\n * Syncs the tracked changes with the ChunkDocument.\n */\n sync(document: ChunkDocument): this {\n log('sync', { changes: this._changes });\n\n // Process each change in order.\n for (const change of this._changes) {\n switch (change.type) {\n case 'append': {\n // For appends, convert block to lines and add at the end.\n const lines = this._renderer(change.chunk, change.index);\n const lastLine = document.lineCount();\n document.replaceLines(lastLine + 1, 0, lines);\n break;\n }\n\n case 'update': {\n // For updates, find the block's line range and replace with new lines.\n let lineStart = 1;\n for (let i = 0; i < change.index; i++) {\n lineStart += this._chunkLineCounts.get(this._chunks[i].id)!;\n }\n const previousLineCount = this._chunkLineCounts.get(change.chunk.id)!;\n const newLines = this._renderer(change.chunk, change.index);\n document.replaceLines(lineStart, previousLineCount, newLines);\n break;\n }\n\n case 'delete': {\n // For deletes, find the block's line range and remove those lines.\n let lineStart = 1;\n for (let i = 0; i < change.index; i++) {\n lineStart += this._chunkLineCounts.get(this._chunks[i].id)!;\n }\n const previousLineCount = this._chunkLineCounts.get(change.id)!;\n document.replaceLines(lineStart, previousLineCount, []);\n break;\n }\n }\n }\n\n // Clear the line-to-block mapping.\n this._lineToChunk.clear();\n\n // Update all block line counts and line-to-block mapping after processing changes.\n let currentLine = 1;\n for (const [index, chunk] of this._chunks.entries()) {\n const lineCount = this._renderer(chunk, index).length;\n this._chunkLineCounts.set(chunk.id, lineCount);\n this._lineToChunk.set(currentLine, chunk);\n currentLine += lineCount;\n }\n\n // Clean up deleted blocks.\n const chunkIds = new Set(this._chunks.map((chunk) => chunk.id));\n for (const id of this._chunkLineCounts.keys()) {\n if (!chunkIds.has(id)) {\n this._chunkLineCounts.delete(id);\n }\n }\n\n // Clear changes after sync.\n this._changes.length = 0;\n return this;\n }\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Text", "Event", "invariant", "log", "_view", "replaceLines", "from", "remove", "insert", "count", "state", "posFrom", "line", "posTo", "text", "dispatch", "_chunkLineCounts", "_lineToChunk", "_changes", "_renderer", "initialChunks", "forEach", "chunk", "appendChunk", "toJSON", "chunks", "changes", "doc", "reset", "clear", "update", "_chunks", "push", "type", "index", "updateChunk", "deleteBlock", "splice", "id", "change", "document", "lastLine", "lines", "lineStart", "previousLineCount", "get", "newLines", "currentLine", "lineCount", "set", "chunkIds"]
|
|
7
|
+
}
|
|
@@ -9,11 +9,11 @@ import { meta } from "#meta";
|
|
|
9
9
|
})(TranscriptionCapabilities || (TranscriptionCapabilities = {}));
|
|
10
10
|
var TranscriptionCapabilities;
|
|
11
11
|
|
|
12
|
-
// src/types/
|
|
12
|
+
// src/types/defs.ts
|
|
13
13
|
var TRANSCRIPTION_URL = "https://calls-service.dxos.workers.dev";
|
|
14
14
|
|
|
15
15
|
export {
|
|
16
16
|
TranscriptionCapabilities,
|
|
17
17
|
TRANSCRIPTION_URL
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-KO3IOD2O.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/capabilities.ts", "../../../src/types/defs.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nimport { meta } from '#meta';\n\nimport {\n type MediaStreamRecorderProps,\n type Transcriber,\n type TranscriberProps,\n type TranscriptMessageEnricher,\n type TranscriptionManager,\n} from '../transcriber';\n\nexport namespace TranscriptionCapabilities {\n export type GetTranscriberProps = {\n audioStreamTrack: MediaStreamTrack;\n recorderConfig?: Partial<MediaStreamRecorderProps['config']>;\n transcriberConfig?: Partial<TranscriberProps['config']>;\n onSegments: TranscriberProps['onSegments'];\n transcribe?: TranscriberProps['transcribe'];\n };\n\n export type GetTranscriber = (props: GetTranscriberProps) => Transcriber;\n\n export type GetTranscriptionManagerProps = {\n messageEnricher?: TranscriptMessageEnricher;\n };\n\n export type GetTranscriptionManager = (props: GetTranscriptionManagerProps) => TranscriptionManager;\n\n export const Transcriber = Capability.make<GetTranscriber>(`${meta.id}.capability.transcriber`);\n\n export const TranscriptionManager = Capability.make<GetTranscriptionManager>(\n `${meta.id}.capability.transcription-manager`,\n );\n}\n", "//\n// Copyright 2025 DXOS.org\n//\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"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,kBAAkB;AAE3B,SAASC,YAAY;UAUJC,4BAAAA;6BAiBFC,cAAcH,WAAWI,KAAqB,GAAGH,KAAKI,EAAE,yBAAyB;6BAEjFC,uBAAuBN,WAAWI,KAC7C,GAAGH,KAAKI,EAAE,mCAAmC;AAEjD,GAtBiBH,8BAAAA,4BAAAA,CAAAA,EAAAA;;;;ACRV,IAAMK,oBAAoB;",
|
|
6
|
+
"names": ["Capability", "meta", "TranscriptionCapabilities", "Transcriber", "make", "id", "TranscriptionManager", "TRANSCRIPTION_URL"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
SerializationModel
|
|
4
|
+
} from "./chunk-C3AE2NYJ.mjs";
|
|
5
|
+
|
|
6
|
+
// src/hooks/useAudioFile.ts
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import { scheduleTask } from "@dxos/async";
|
|
9
|
+
import { Context } from "@dxos/context";
|
|
10
|
+
import { log } from "@dxos/log";
|
|
11
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useAudioFile.ts";
|
|
12
|
+
var useAudioFile = (audioUrl, constraints) => {
|
|
13
|
+
const [{ audio, stream, track }, setStream] = useState({});
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const ctx = new Context(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 11 });
|
|
16
|
+
scheduleTask(ctx, async () => {
|
|
17
|
+
try {
|
|
18
|
+
const response = await fetch(audioUrl);
|
|
19
|
+
const blob = await response.blob();
|
|
20
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
21
|
+
ctx.onDispose(() => {
|
|
22
|
+
URL.revokeObjectURL(objectUrl);
|
|
23
|
+
});
|
|
24
|
+
const audio2 = new Audio();
|
|
25
|
+
audio2.src = objectUrl;
|
|
26
|
+
await new Promise((resolve, reject) => {
|
|
27
|
+
audio2.addEventListener("error", (err) => {
|
|
28
|
+
log.error("error", {
|
|
29
|
+
err
|
|
30
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 25, S: void 0 });
|
|
31
|
+
reject(err);
|
|
32
|
+
}, {
|
|
33
|
+
once: true
|
|
34
|
+
});
|
|
35
|
+
audio2.addEventListener("canplay", async () => {
|
|
36
|
+
resolve();
|
|
37
|
+
}, {
|
|
38
|
+
once: true
|
|
39
|
+
});
|
|
40
|
+
audio2.load();
|
|
41
|
+
});
|
|
42
|
+
const audioCtx = new AudioContext();
|
|
43
|
+
if (audioCtx.state === "suspended") {
|
|
44
|
+
await audioCtx.resume();
|
|
45
|
+
}
|
|
46
|
+
const destination = audioCtx.createMediaStreamDestination();
|
|
47
|
+
destination.channelCount = 1;
|
|
48
|
+
const source = audioCtx.createMediaElementSource(audio2);
|
|
49
|
+
source.connect(destination);
|
|
50
|
+
const track2 = destination.stream.getAudioTracks()[0];
|
|
51
|
+
if (constraints) {
|
|
52
|
+
await track2.applyConstraints(constraints).catch((err) => log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 50, S: void 0 }));
|
|
53
|
+
}
|
|
54
|
+
setStream({
|
|
55
|
+
audio: audio2,
|
|
56
|
+
stream: destination.stream,
|
|
57
|
+
track: destination.stream.getAudioTracks()[0]
|
|
58
|
+
});
|
|
59
|
+
} catch (err) {
|
|
60
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 59, S: void 0 });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return () => {
|
|
64
|
+
void ctx.dispose();
|
|
65
|
+
};
|
|
66
|
+
}, [
|
|
67
|
+
audioUrl
|
|
68
|
+
]);
|
|
69
|
+
return {
|
|
70
|
+
audio,
|
|
71
|
+
stream,
|
|
72
|
+
track
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/hooks/useAudioTrack.ts
|
|
77
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
78
|
+
var useAudioTrack = (active, constraints) => {
|
|
79
|
+
const [track, setTrack] = useState2();
|
|
80
|
+
useEffect2(() => {
|
|
81
|
+
if (!active) {
|
|
82
|
+
track?.stop();
|
|
83
|
+
setTrack(void 0);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const initAudio = async () => {
|
|
87
|
+
const audio = new Audio();
|
|
88
|
+
audio.srcObject = await navigator.mediaDevices.getUserMedia({
|
|
89
|
+
audio: constraints ?? true
|
|
90
|
+
});
|
|
91
|
+
const [track2] = audio.srcObject.getAudioTracks();
|
|
92
|
+
if (track2) {
|
|
93
|
+
setTrack(track2);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
if (active) {
|
|
97
|
+
void initAudio();
|
|
98
|
+
}
|
|
99
|
+
}, [
|
|
100
|
+
active
|
|
101
|
+
]);
|
|
102
|
+
return track;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/hooks/useQueueModelAdapter.ts
|
|
106
|
+
import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
|
|
107
|
+
var useQueueModelAdapter = (renderer, queue, initialChunks = []) => {
|
|
108
|
+
const model = useMemo(() => new SerializationModel(renderer, initialChunks), [
|
|
109
|
+
queue
|
|
110
|
+
]);
|
|
111
|
+
const [loaded, setLoaded] = useState3(false);
|
|
112
|
+
useEffect3(() => {
|
|
113
|
+
if (!queue) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const update = () => {
|
|
117
|
+
for (const block of queue?.objects ?? []) {
|
|
118
|
+
model.appendChunk(block);
|
|
119
|
+
}
|
|
120
|
+
setLoaded(true);
|
|
121
|
+
};
|
|
122
|
+
let i;
|
|
123
|
+
if (queue.isLoading) {
|
|
124
|
+
i = setInterval(() => {
|
|
125
|
+
if (!queue?.isLoading) {
|
|
126
|
+
clearInterval(i);
|
|
127
|
+
update();
|
|
128
|
+
}
|
|
129
|
+
}, 1e3);
|
|
130
|
+
} else {
|
|
131
|
+
update();
|
|
132
|
+
}
|
|
133
|
+
return () => clearTimeout(i);
|
|
134
|
+
}, [
|
|
135
|
+
model,
|
|
136
|
+
queue
|
|
137
|
+
]);
|
|
138
|
+
useEffect3(() => {
|
|
139
|
+
if (!loaded || !queue || model.chunks.length === queue.objects.length) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const chunk = queue.objects.at(-1);
|
|
143
|
+
if (chunk) {
|
|
144
|
+
model.appendChunk(chunk);
|
|
145
|
+
}
|
|
146
|
+
}, [
|
|
147
|
+
model,
|
|
148
|
+
loaded,
|
|
149
|
+
queue?.objects.length
|
|
150
|
+
]);
|
|
151
|
+
return model;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/hooks/useTranscriber.ts
|
|
155
|
+
import { useEffect as useEffect4, useMemo as useMemo2 } from "react";
|
|
156
|
+
import { useCapabilities } from "@dxos/app-framework/ui";
|
|
157
|
+
import { TranscriptionCapabilities } from "#types";
|
|
158
|
+
var useTranscriber = ({ audioStreamTrack, recorderConfig, transcriberConfig, onSegments, transcribe }) => {
|
|
159
|
+
const [getTranscriber] = useCapabilities(TranscriptionCapabilities.Transcriber);
|
|
160
|
+
const transcriber = useMemo2(() => {
|
|
161
|
+
if (!getTranscriber || !audioStreamTrack || !onSegments) {
|
|
162
|
+
return void 0;
|
|
163
|
+
}
|
|
164
|
+
return getTranscriber({
|
|
165
|
+
audioStreamTrack,
|
|
166
|
+
recorderConfig,
|
|
167
|
+
transcriberConfig,
|
|
168
|
+
onSegments,
|
|
169
|
+
transcribe
|
|
170
|
+
});
|
|
171
|
+
}, [
|
|
172
|
+
getTranscriber,
|
|
173
|
+
audioStreamTrack,
|
|
174
|
+
recorderConfig,
|
|
175
|
+
transcriberConfig,
|
|
176
|
+
onSegments,
|
|
177
|
+
transcribe
|
|
178
|
+
]);
|
|
179
|
+
useEffect4(() => {
|
|
180
|
+
return () => {
|
|
181
|
+
void transcriber?.close();
|
|
182
|
+
};
|
|
183
|
+
}, [
|
|
184
|
+
transcriber
|
|
185
|
+
]);
|
|
186
|
+
return transcriber;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// src/hooks/useVoiceInput.ts
|
|
190
|
+
import { useCallback, useEffect as useEffect5, useState as useState4 } from "react";
|
|
191
|
+
import { scheduleMicroTask } from "@dxos/async";
|
|
192
|
+
import { Context as Context2 } from "@dxos/context";
|
|
193
|
+
import { log as log2 } from "@dxos/log";
|
|
194
|
+
import { useSoundEffect } from "@dxos/react-ui-sfx";
|
|
195
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-transcription/src/hooks/useVoiceInput.ts";
|
|
196
|
+
var useVoiceInput = ({ active, onUpdate }) => {
|
|
197
|
+
const soundStart = useSoundEffect("StartRecording");
|
|
198
|
+
const soundStop = useSoundEffect("StopRecording");
|
|
199
|
+
const handleSegments = useCallback(async (segments) => {
|
|
200
|
+
const text = segments.map((str) => str.text.trim().replace(/[^\w\s]/g, "")).join(" ");
|
|
201
|
+
onUpdate(text);
|
|
202
|
+
}, []);
|
|
203
|
+
const [recording, setRecording] = useState4(false);
|
|
204
|
+
const track = useAudioTrack(active);
|
|
205
|
+
const transcriber = useTranscriber({
|
|
206
|
+
audioStreamTrack: track,
|
|
207
|
+
onSegments: handleSegments
|
|
208
|
+
});
|
|
209
|
+
useEffect5(() => {
|
|
210
|
+
const ctx = new Context2(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 29 });
|
|
211
|
+
scheduleMicroTask(ctx, async () => {
|
|
212
|
+
if (active && transcriber) {
|
|
213
|
+
await transcriber.open();
|
|
214
|
+
log2.info("starting...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 33, S: void 0 });
|
|
215
|
+
setRecording(true);
|
|
216
|
+
void soundStart.play();
|
|
217
|
+
transcriber.startChunksRecording();
|
|
218
|
+
} else if (!active && transcriber?.isOpen) {
|
|
219
|
+
transcriber?.stopChunksRecording();
|
|
220
|
+
await transcriber?.close();
|
|
221
|
+
log2.info("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 40, S: void 0 });
|
|
222
|
+
setRecording(false);
|
|
223
|
+
void soundStop.play();
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
return () => {
|
|
227
|
+
void ctx.dispose();
|
|
228
|
+
};
|
|
229
|
+
}, [
|
|
230
|
+
active,
|
|
231
|
+
transcriber
|
|
232
|
+
]);
|
|
233
|
+
return {
|
|
234
|
+
recording
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export {
|
|
239
|
+
useAudioFile,
|
|
240
|
+
useAudioTrack,
|
|
241
|
+
useQueueModelAdapter,
|
|
242
|
+
useTranscriber,
|
|
243
|
+
useVoiceInput
|
|
244
|
+
};
|
|
245
|
+
//# sourceMappingURL=chunk-MQK4R6GT.mjs.map
|