@athenaintel/react 0.23.2 → 0.24.0
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/README.md +46 -1
- package/dist/assets/AssetPanel.cjs +1 -1
- package/dist/assets/AssetPanel.cjs.map +1 -1
- package/dist/assets/AssetPanel.js +1 -1
- package/dist/assets/AssetPanel.js.map +1 -1
- package/dist/assets/AthenaAssetEmbed.cjs +1 -1
- package/dist/assets/AthenaAssetEmbed.cjs.map +1 -1
- package/dist/assets/AthenaAssetEmbed.js +1 -1
- package/dist/assets/AthenaAssetEmbed.js.map +1 -1
- package/dist/chat/AthenaChat.cjs +138 -46
- package/dist/chat/AthenaChat.cjs.map +1 -1
- package/dist/chat/AthenaChat.d.ts +37 -1
- package/dist/chat/AthenaChat.js +139 -47
- package/dist/chat/AthenaChat.js.map +1 -1
- package/dist/chat/StatewireApprovalCard.cjs +3 -18
- package/dist/chat/StatewireApprovalCard.cjs.map +1 -1
- package/dist/chat/StatewireApprovalCard.js +3 -18
- package/dist/chat/StatewireApprovalCard.js.map +1 -1
- package/dist/chat/StatewireClientToolBridge.cjs +2 -16
- package/dist/chat/StatewireClientToolBridge.cjs.map +1 -1
- package/dist/chat/StatewireClientToolBridge.js +2 -16
- package/dist/chat/StatewireClientToolBridge.js.map +1 -1
- package/dist/chat/StatewireQueuedMessages.cjs +5 -16
- package/dist/chat/StatewireQueuedMessages.cjs.map +1 -1
- package/dist/chat/StatewireQueuedMessages.js +5 -16
- package/dist/chat/StatewireQueuedMessages.js.map +1 -1
- package/dist/chat/WaitingOnYouBanner.cjs +3 -18
- package/dist/chat/WaitingOnYouBanner.cjs.map +1 -1
- package/dist/chat/WaitingOnYouBanner.js +3 -18
- package/dist/chat/WaitingOnYouBanner.js.map +1 -1
- package/dist/chat/athena-composer-controls.js +1 -1
- package/dist/chat/run-activity.cjs +0 -16
- package/dist/chat/run-activity.cjs.map +1 -1
- package/dist/chat/run-activity.js +0 -16
- package/dist/chat/run-activity.js.map +1 -1
- package/dist/chat/statewire-client-tools.cjs +21 -17
- package/dist/chat/statewire-client-tools.cjs.map +1 -1
- package/dist/chat/statewire-client-tools.d.ts +27 -0
- package/dist/chat/statewire-client-tools.js +21 -17
- package/dist/chat/statewire-client-tools.js.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.cjs +0 -16
- package/dist/chat/super-grouping/activity-timeline.cjs.map +1 -1
- package/dist/chat/super-grouping/activity-timeline.js +0 -16
- package/dist/chat/super-grouping/activity-timeline.js.map +1 -1
- package/dist/chat/tiptap-text.cjs +1 -17
- package/dist/chat/tiptap-text.cjs.map +1 -1
- package/dist/chat/tiptap-text.js +1 -17
- package/dist/chat/tiptap-text.js.map +1 -1
- package/dist/chat/use-athena-run-live.cjs +0 -15
- package/dist/chat/use-athena-run-live.cjs.map +1 -1
- package/dist/chat/use-athena-run-live.d.ts +7 -0
- package/dist/chat/use-athena-run-live.js +0 -15
- package/dist/chat/use-athena-run-live.js.map +1 -1
- package/dist/chat/use-statewire-approval-request.cjs +4 -16
- package/dist/chat/use-statewire-approval-request.cjs.map +1 -1
- package/dist/chat/use-statewire-approval-request.d.ts +2 -0
- package/dist/chat/use-statewire-approval-request.js +4 -16
- package/dist/chat/use-statewire-approval-request.js.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.cjs +17 -17
- package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
- package/dist/chat-ui/composer/tiptap-composer.js +17 -17
- package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
- package/dist/chat-ui/index.cjs +0 -16
- package/dist/chat-ui/index.cjs.map +1 -1
- package/dist/chat-ui/index.js +0 -16
- package/dist/chat-ui/index.js.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.cjs +1 -16
- package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
- package/dist/chat-ui/mentions/mention-chip.js +1 -16
- package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs +4 -6
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js +4 -6
- package/dist/chat-ui/mentions/suggestions/data/sources/asset-type-icons.js.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs +2 -9
- package/dist/chat-ui/mentions/suggestions/data/sources/index.cjs.map +1 -1
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js +2 -9
- package/dist/chat-ui/mentions/suggestions/data/sources/index.js.map +1 -1
- package/dist/chat-ui/messages/message-components.cjs +5 -19
- package/dist/chat-ui/messages/message-components.cjs.map +1 -1
- package/dist/chat-ui/messages/message-components.js +5 -19
- package/dist/chat-ui/messages/message-components.js.map +1 -1
- package/dist/chat-ui/messages/runtime-message.cjs +1 -16
- package/dist/chat-ui/messages/runtime-message.cjs.map +1 -1
- package/dist/chat-ui/messages/runtime-message.js +1 -16
- package/dist/chat-ui/messages/runtime-message.js.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.cjs +3 -15
- package/dist/chat-ui/messages/statewire-continue-run.cjs.map +1 -1
- package/dist/chat-ui/messages/statewire-continue-run.js +3 -15
- package/dist/chat-ui/messages/statewire-continue-run.js.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.cjs +0 -16
- package/dist/chat-ui/messages/user-edit-composer.cjs.map +1 -1
- package/dist/chat-ui/messages/user-edit-composer.js +0 -16
- package/dist/chat-ui/messages/user-edit-composer.js.map +1 -1
- package/dist/chat-ui/messages/wake-marker.cjs +1 -16
- package/dist/chat-ui/messages/wake-marker.cjs.map +1 -1
- package/dist/chat-ui/messages/wake-marker.js +1 -16
- package/dist/chat-ui/messages/wake-marker.js.map +1 -1
- package/dist/chat-ui/statewire.cjs +0 -16
- package/dist/chat-ui/statewire.cjs.map +1 -1
- package/dist/chat-ui/statewire.js +0 -16
- package/dist/chat-ui/statewire.js.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.cjs +2 -17
- package/dist/chat-ui/thread/statewire-history-edge.cjs.map +1 -1
- package/dist/chat-ui/thread/statewire-history-edge.js +2 -17
- package/dist/chat-ui/thread/statewire-history-edge.js.map +1 -1
- package/dist/composer/composer-handoff.cjs +121 -0
- package/dist/composer/composer-handoff.cjs.map +1 -0
- package/dist/composer/composer-handoff.d.ts +89 -0
- package/dist/composer/composer-handoff.js +121 -0
- package/dist/composer/composer-handoff.js.map +1 -0
- package/dist/composer/index.d.ts +2 -0
- package/dist/composer/useAppendToComposer.cjs +19 -7
- package/dist/composer/useAppendToComposer.cjs.map +1 -1
- package/dist/composer/useAppendToComposer.d.ts +22 -4
- package/dist/composer/useAppendToComposer.js +20 -8
- package/dist/composer/useAppendToComposer.js.map +1 -1
- package/dist/composer/useSendMessage.cjs +26 -8
- package/dist/composer/useSendMessage.cjs.map +1 -1
- package/dist/composer/useSendMessage.d.ts +8 -0
- package/dist/composer/useSendMessage.js +27 -9
- package/dist/composer/useSendMessage.js.map +1 -1
- package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
- package/dist/diagnostics/athena-diagnostics.d.ts +1 -1
- package/dist/diagnostics/athena-diagnostics.js.map +1 -1
- package/dist/diagnostics/errors.cjs +2 -0
- package/dist/diagnostics/errors.cjs.map +1 -1
- package/dist/diagnostics/errors.d.ts +2 -0
- package/dist/diagnostics/errors.js +2 -0
- package/dist/diagnostics/errors.js.map +1 -1
- package/dist/dictation/DictationStrip.cjs +61 -0
- package/dist/dictation/DictationStrip.cjs.map +1 -0
- package/dist/dictation/DictationStrip.d.ts +27 -0
- package/dist/dictation/DictationStrip.js +61 -0
- package/dist/dictation/DictationStrip.js.map +1 -0
- package/dist/dictation/audio-level-history.cjs +68 -0
- package/dist/dictation/audio-level-history.cjs.map +1 -0
- package/dist/dictation/audio-level-history.d.ts +27 -0
- package/dist/dictation/audio-level-history.js +68 -0
- package/dist/dictation/audio-level-history.js.map +1 -0
- package/dist/dictation/dictation-controls.cjs +60 -0
- package/dist/dictation/dictation-controls.cjs.map +1 -0
- package/dist/dictation/dictation-controls.d.ts +15 -0
- package/dist/dictation/dictation-controls.js +60 -0
- package/dist/dictation/dictation-controls.js.map +1 -0
- package/dist/dictation/dictation-engine.cjs +128 -0
- package/dist/dictation/dictation-engine.cjs.map +1 -0
- package/dist/dictation/dictation-engine.d.ts +95 -0
- package/dist/dictation/dictation-engine.js +128 -0
- package/dist/dictation/dictation-engine.js.map +1 -0
- package/dist/dictation/dictation-state.cjs +68 -0
- package/dist/dictation/dictation-state.cjs.map +1 -0
- package/dist/dictation/dictation-state.d.ts +58 -0
- package/dist/dictation/dictation-state.js +68 -0
- package/dist/dictation/dictation-state.js.map +1 -0
- package/dist/dictation/recorded-dictation-engine.cjs +153 -0
- package/dist/dictation/recorded-dictation-engine.cjs.map +1 -0
- package/dist/dictation/recorded-dictation-engine.d.ts +66 -0
- package/dist/dictation/recorded-dictation-engine.js +153 -0
- package/dist/dictation/recorded-dictation-engine.js.map +1 -0
- package/dist/dictation/use-athena-dictation-engine.cjs +64 -0
- package/dist/dictation/use-athena-dictation-engine.cjs.map +1 -0
- package/dist/dictation/use-athena-dictation-engine.d.ts +25 -0
- package/dist/dictation/use-athena-dictation-engine.js +64 -0
- package/dist/dictation/use-athena-dictation-engine.js.map +1 -0
- package/dist/dictation/use-dictation.cjs +215 -0
- package/dist/dictation/use-dictation.cjs.map +1 -0
- package/dist/dictation/use-dictation.d.ts +63 -0
- package/dist/dictation/use-dictation.js +215 -0
- package/dist/dictation/use-dictation.js.map +1 -0
- package/dist/index.cjs +41 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -0
- package/dist/index.js +23 -21
- package/dist/index.js.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/edit-command.js.map +1 -1
- package/dist/packages/agent-runtime/src/errors.cjs +18 -0
- package/dist/packages/agent-runtime/src/errors.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/errors.js +19 -1
- package/dist/packages/agent-runtime/src/errors.js.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs +1 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js +1 -0
- package/dist/packages/agent-runtime/src/generated/runconfig-contract.js.map +1 -1
- package/dist/packages/agent-runtime/src/interrupts.cjs +61 -12
- package/dist/packages/agent-runtime/src/interrupts.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/interrupts.js +61 -12
- package/dist/packages/agent-runtime/src/interrupts.js.map +1 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs +49 -0
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js +49 -0
- package/dist/packages/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
- package/dist/packages/agent-runtime/src/thread-status.js +1 -1
- package/dist/packages/agent-runtime/src/tool-metadata.cjs +1 -37
- package/dist/packages/agent-runtime/src/tool-metadata.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/tool-metadata.js +1 -37
- package/dist/packages/agent-runtime/src/tool-metadata.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js +0 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-config.js.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
- package/dist/packages/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
- package/dist/packages/react/package.json.cjs +1 -1
- package/dist/packages/react/package.json.js +1 -1
- package/dist/provider/AthenaProvider.cjs +45 -20
- package/dist/provider/AthenaProvider.cjs.map +1 -1
- package/dist/provider/AthenaProvider.d.ts +1 -1
- package/dist/provider/AthenaProvider.js +46 -21
- package/dist/provider/AthenaProvider.js.map +1 -1
- package/dist/runtime/statewire-lifecycle.cjs +0 -16
- package/dist/runtime/statewire-lifecycle.cjs.map +1 -1
- package/dist/runtime/statewire-lifecycle.js +0 -16
- package/dist/runtime/statewire-lifecycle.js.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.cjs +3 -17
- package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
- package/dist/runtime/useAthenaStatewireRuntime.js +3 -17
- package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/threads/statewire-thread-list.cjs +4 -17
- package/dist/threads/statewire-thread-list.cjs.map +1 -1
- package/dist/threads/statewire-thread-list.js +4 -17
- package/dist/threads/statewire-thread-list.js.map +1 -1
- package/dist/threads/use-rest-conversation-history.cjs +2 -16
- package/dist/threads/use-rest-conversation-history.cjs.map +1 -1
- package/dist/threads/use-rest-conversation-history.js +2 -16
- package/dist/threads/use-rest-conversation-history.js.map +1 -1
- package/dist/threads/use-statewire-conversation-history.cjs +2 -16
- package/dist/threads/use-statewire-conversation-history.cjs.map +1 -1
- package/dist/threads/use-statewire-conversation-history.js +2 -16
- package/dist/threads/use-statewire-conversation-history.js.map +1 -1
- package/dist/toolkits/index.cjs +0 -7
- package/dist/toolkits/index.cjs.map +1 -1
- package/dist/toolkits/index.d.ts +0 -2
- package/dist/toolkits/index.js +0 -7
- package/dist/toolkits/index.js.map +1 -1
- package/dist/tools/index.cjs +4 -20
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +1 -17
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/misc-tool-uis.cjs +2 -17
- package/dist/tools/misc-tool-uis.cjs.map +1 -1
- package/dist/tools/misc-tool-uis.js +2 -17
- package/dist/tools/misc-tool-uis.js.map +1 -1
- package/dist/tools/primitives.cjs +1 -16
- package/dist/tools/primitives.cjs.map +1 -1
- package/dist/tools/primitives.js +1 -16
- package/dist/tools/primitives.js.map +1 -1
- package/dist/tools/tool-fallback.cjs +2 -17
- package/dist/tools/tool-fallback.cjs.map +1 -1
- package/dist/tools/tool-fallback.js +2 -17
- package/dist/tools/tool-fallback.js.map +1 -1
- package/dist/tools/voice-update-tool-ui.cjs +1 -17
- package/dist/tools/voice-update-tool-ui.cjs.map +1 -1
- package/dist/tools/voice-update-tool-ui.js +1 -17
- package/dist/tools/voice-update-tool-ui.js.map +1 -1
- package/package.json +1 -1
- package/dist/node_modules/qrcode-generator/dist/qrcode.cjs +0 -32
- package/dist/node_modules/qrcode-generator/dist/qrcode.cjs.map +0 -1
- package/dist/node_modules/qrcode-generator/dist/qrcode.js +0 -31
- package/dist/node_modules/qrcode-generator/dist/qrcode.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/errors.cjs +0 -44
- package/dist/node_modules/zod/v4/classic/errors.cjs.map +0 -1
- package/dist/node_modules/zod/v4/classic/errors.js +0 -44
- package/dist/node_modules/zod/v4/classic/errors.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/iso.cjs +0 -43
- package/dist/node_modules/zod/v4/classic/iso.cjs.map +0 -1
- package/dist/node_modules/zod/v4/classic/iso.js +0 -43
- package/dist/node_modules/zod/v4/classic/iso.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/parse.cjs +0 -29
- package/dist/node_modules/zod/v4/classic/parse.cjs.map +0 -1
- package/dist/node_modules/zod/v4/classic/parse.js +0 -29
- package/dist/node_modules/zod/v4/classic/parse.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/schemas.cjs +0 -871
- package/dist/node_modules/zod/v4/classic/schemas.cjs.map +0 -1
- package/dist/node_modules/zod/v4/classic/schemas.js +0 -871
- package/dist/node_modules/zod/v4/classic/schemas.js.map +0 -1
- package/dist/node_modules/zod/v4/core/api.cjs +0 -570
- package/dist/node_modules/zod/v4/core/api.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/api.js +0 -570
- package/dist/node_modules/zod/v4/core/api.js.map +0 -1
- package/dist/node_modules/zod/v4/core/checks.cjs +0 -411
- package/dist/node_modules/zod/v4/core/checks.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/checks.js +0 -411
- package/dist/node_modules/zod/v4/core/checks.js.map +0 -1
- package/dist/node_modules/zod/v4/core/core.cjs +0 -77
- package/dist/node_modules/zod/v4/core/core.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/core.js +0 -77
- package/dist/node_modules/zod/v4/core/core.js.map +0 -1
- package/dist/node_modules/zod/v4/core/doc.cjs +0 -38
- package/dist/node_modules/zod/v4/core/doc.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/doc.js +0 -38
- package/dist/node_modules/zod/v4/core/doc.js.map +0 -1
- package/dist/node_modules/zod/v4/core/errors.cjs +0 -76
- package/dist/node_modules/zod/v4/core/errors.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/errors.js +0 -76
- package/dist/node_modules/zod/v4/core/errors.js.map +0 -1
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs +0 -312
- package/dist/node_modules/zod/v4/core/json-schema-processors.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +0 -312
- package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +0 -1
- package/dist/node_modules/zod/v4/core/parse.cjs +0 -96
- package/dist/node_modules/zod/v4/core/parse.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/parse.js +0 -96
- package/dist/node_modules/zod/v4/core/parse.js.map +0 -1
- package/dist/node_modules/zod/v4/core/regexes.cjs +0 -86
- package/dist/node_modules/zod/v4/core/regexes.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/regexes.js +0 -86
- package/dist/node_modules/zod/v4/core/regexes.js.map +0 -1
- package/dist/node_modules/zod/v4/core/registries.cjs +0 -52
- package/dist/node_modules/zod/v4/core/registries.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/registries.js +0 -52
- package/dist/node_modules/zod/v4/core/registries.js.map +0 -1
- package/dist/node_modules/zod/v4/core/schemas.cjs +0 -1412
- package/dist/node_modules/zod/v4/core/schemas.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/schemas.js +0 -1413
- package/dist/node_modules/zod/v4/core/schemas.js.map +0 -1
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs +0 -370
- package/dist/node_modules/zod/v4/core/to-json-schema.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -370
- package/dist/node_modules/zod/v4/core/to-json-schema.js.map +0 -1
- package/dist/node_modules/zod/v4/core/util.cjs +0 -444
- package/dist/node_modules/zod/v4/core/util.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/util.js +0 -444
- package/dist/node_modules/zod/v4/core/util.js.map +0 -1
- package/dist/node_modules/zod/v4/core/versions.cjs +0 -9
- package/dist/node_modules/zod/v4/core/versions.cjs.map +0 -1
- package/dist/node_modules/zod/v4/core/versions.js +0 -9
- package/dist/node_modules/zod/v4/core/versions.js.map +0 -1
- package/dist/packages/agent-runtime/src/thread-handoff.cjs +0 -85
- package/dist/packages/agent-runtime/src/thread-handoff.cjs.map +0 -1
- package/dist/packages/agent-runtime/src/thread-handoff.js +0 -85
- package/dist/packages/agent-runtime/src/thread-handoff.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dictation.cjs","sources":["../../src/dictation/use-dictation.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport {\n createWebSpeechDictationEngine,\n DICTATION_ENGINE_ERROR_KINDS,\n type DictationEngine,\n type DictationEngineError,\n type DictationEngineSession,\n} from './dictation-engine';\nimport {\n DICTATION_STATUSES,\n dictationReducer,\n INITIAL_DICTATION_STATE,\n joinSpeech,\n spokenText,\n type DictationStatus,\n type DictationTranscript,\n} from './dictation-state';\n\nexport interface UseDictationOptions {\n /**\n * Speech engine. Defaults to the browser's Web Speech API; `AthenaChat`\n * passes the record-then-transcribe engine from `useAthenaDictationEngine`.\n */\n engine?: DictationEngine;\n /** BCP-47 language tag. Defaults to the document language, else `en-US`. */\n lang?: string;\n /**\n * Open the microphone through `getUserMedia` so callers get a `stream` for\n * a waveform. Web Speech opens its own capture; this second capture is\n * what the level meter reads. Defaults to true.\n */\n captureStream?: boolean;\n /**\n * The engine ended on its own (silence window, recognizer timeout) while\n * listening, without `stop()` or `cancel()`. Receives the spoken text so\n * the words are not lost; the composer puts them into the draft.\n */\n onAutoEnd?: (spoken: string) => void;\n}\n\nexport interface DictationStopResult {\n /** Spoken text (final plus interim tail) gathered before the engine closed. */\n text: string;\n /**\n * The engine error reported during this session, if any. When set the\n * transcript may be incomplete: a recorded engine whose upload failed has no\n * words to hand over, so callers should not send the draft as if it were.\n */\n error: DictationEngineError | null;\n}\n\nexport interface DictationController {\n status: DictationStatus;\n /** True while starting, listening or stopping. */\n isActive: boolean;\n transcript: DictationTranscript;\n /** `final` plus the interim tail, ready to hand to the composer. */\n text: string;\n error: DictationEngineError | null;\n /** The microphone stream while active (for a waveform), else null. */\n stream: MediaStream | null;\n /** Whether the engine can run here. Hide the control when false. */\n isSupported: boolean;\n /** The engine in use (for its `stoppingLabel` and diagnostics). */\n engine: DictationEngine;\n start: () => void;\n /**\n * Finish recording. Resolves once the engine has flushed (bounded wait), so\n * trailing words are not lost, with the spoken text and any error raised\n * along the way.\n */\n stop: () => Promise<DictationStopResult>;\n /** Discard the session and its transcript. */\n cancel: () => void;\n}\n\n/** How long `stop()` waits for a live engine's final flush before giving up. */\nconst DEFAULT_STOP_FLUSH_TIMEOUT_MS = 1500;\n\ntype StopResolver = (result: DictationStopResult) => void;\n\nconst EMPTY_TRANSCRIPT: DictationTranscript = { final: '', interim: '' };\n\nfunction documentLanguage(): string {\n if (typeof document !== 'undefined' && document.documentElement.lang) {\n return document.documentElement.lang;\n }\n if (typeof navigator !== 'undefined' && navigator.language) return navigator.language;\n return 'en-US';\n}\n\nasync function openMicrophone(): Promise<MediaStream | null> {\n if (typeof navigator === 'undefined' || !navigator.mediaDevices?.getUserMedia) return null;\n return navigator.mediaDevices.getUserMedia({ audio: true });\n}\n\nfunction releaseStream(stream: MediaStream | null): void {\n if (!stream) return;\n for (const track of stream.getTracks()) track.stop();\n}\n\n/**\n * Drive a dictation session: microphone, speech engine, and the transcript\n * state machine. The composer renders the waveform from `stream` and the\n * live caption from `transcript`; on `stop()` it appends `text` to the draft.\n */\nexport function useDictation(options: UseDictationOptions = {}): DictationController {\n const engine = useMemo(() => options.engine ?? createWebSpeechDictationEngine(), [options.engine]);\n const { lang, captureStream = true, onAutoEnd } = options;\n const [state, dispatch] = useReducer(dictationReducer, INITIAL_DICTATION_STATE);\n const [stream, setStream] = useState<MediaStream | null>(null);\n const [isSupported, setIsSupported] = useState(false);\n\n const sessionRef = useRef<DictationEngineSession | null>(null);\n const streamRef = useRef<MediaStream | null>(null);\n const stateRef = useRef(state);\n stateRef.current = state;\n // The authoritative transcript, updated synchronously as the engine reports\n // it. The reducer's copy renders the caption; this one is what `stop()` and\n // `onAutoEnd` hand over, so an engine that flushes its last words and ends\n // in the same tick — before React has rendered — loses nothing.\n const transcriptRef = useRef<DictationTranscript>(EMPTY_TRANSCRIPT);\n const onAutoEndRef = useRef(onAutoEnd);\n onAutoEndRef.current = onAutoEnd;\n // stop() callers waiting for the engine's final flush.\n const stopWaitersRef = useRef<StopResolver[]>([]);\n // Last engine error of the current session, handed to stop() callers\n // synchronously (the reducer's copy may not have rendered yet).\n const sessionErrorRef = useRef<DictationEngineError | null>(null);\n // Distinguishes a fresh session from the callbacks of a torn-down one.\n const generationRef = useRef(0);\n\n useEffect(() => {\n setIsSupported(engine.isSupported());\n }, [engine]);\n\n const settleWaiters = useCallback((spoken: string) => {\n const waiters = stopWaitersRef.current;\n stopWaitersRef.current = [];\n const result: DictationStopResult = { text: spoken, error: sessionErrorRef.current };\n for (const resolve of waiters) resolve(result);\n }, []);\n\n const releaseSession = useCallback(() => {\n sessionRef.current = null;\n releaseStream(streamRef.current);\n streamRef.current = null;\n setStream(null);\n }, []);\n\n const teardown = useCallback(() => {\n generationRef.current += 1;\n sessionRef.current?.abort();\n releaseSession();\n transcriptRef.current = EMPTY_TRANSCRIPT;\n settleWaiters('');\n }, [releaseSession, settleWaiters]);\n\n const reportEngineError = useCallback(\n (engineError: DictationEngineError) => {\n athenaDiagnostics.emit('composer.dictation', {\n level: 'warn',\n data: { phase: 'error', engine: engine.id, kind: engineError.kind },\n });\n sessionErrorRef.current = engineError;\n dispatch({ type: 'error', error: engineError });\n },\n [engine.id],\n );\n\n const start = useCallback(() => {\n if (sessionRef.current) return;\n const generation = generationRef.current + 1;\n generationRef.current = generation;\n transcriptRef.current = EMPTY_TRANSCRIPT;\n sessionErrorRef.current = null;\n dispatch({ type: 'start' });\n athenaDiagnostics.emit('composer.dictation', {\n level: 'debug',\n data: { phase: 'start', engine: engine.id },\n });\n\n const run = async () => {\n let microphone: MediaStream | null = null;\n if (captureStream) {\n try {\n microphone = await openMicrophone();\n } catch (error) {\n if (generationRef.current !== generation) {\n releaseStream(microphone);\n return;\n }\n dispatch({\n type: 'error',\n error: {\n kind: DICTATION_ENGINE_ERROR_KINDS.permission,\n message:\n error instanceof DOMException && error.name === 'NotFoundError'\n ? 'No microphone was found.'\n : 'Microphone access was denied. Allow the microphone for this site and try again.',\n },\n });\n return;\n }\n }\n if (generationRef.current !== generation) {\n releaseStream(microphone);\n return;\n }\n streamRef.current = microphone;\n setStream(microphone);\n\n // An engine may fail synchronously inside start() (Web Speech throws\n // when recognition.start() is refused) and run onError/onEnd before we\n // hold the session. Those callbacks flip this flag so a dead session is\n // never stored, which would make every later mic click return early.\n let terminated = false;\n const endSession = () => {\n terminated = true;\n const current = stateRef.current;\n const spoken = spokenText(transcriptRef.current);\n // No stop() is waiting: the engine gave up on its own. Hand the\n // words over so they land in the draft instead of vanishing.\n const endedOnItsOwn =\n stopWaitersRef.current.length === 0 && current.status === DICTATION_STATUSES.listening;\n // The reducer keeps an error status through 'ended', so an error\n // reported just before the engine closed stays on screen.\n dispatch({ type: 'ended' });\n releaseSession();\n settleWaiters(spoken);\n if (endedOnItsOwn) onAutoEndRef.current?.(spoken);\n };\n let session: DictationEngineSession;\n try {\n session = engine.start({\n stream: microphone,\n lang: lang ?? documentLanguage(),\n callbacks: {\n onTranscript: (update) => {\n if (generationRef.current !== generation) return;\n transcriptRef.current = {\n final: joinSpeech(transcriptRef.current.final, update.final),\n interim: update.interim,\n };\n dispatch({ type: 'transcript', update });\n },\n onError: (engineError) => {\n if (generationRef.current !== generation) return;\n // A silence timeout is the engine giving up politely; keep the\n // words we have instead of showing an error.\n if (engineError.kind === DICTATION_ENGINE_ERROR_KINDS.noSpeech) return;\n reportEngineError(engineError);\n },\n onEnd: () => {\n if (generationRef.current !== generation) return;\n endSession();\n },\n },\n });\n } catch (error) {\n // A relay engine that cannot build its session must not strand the\n // microphone or leave the composer in `starting`.\n releaseSession();\n reportEngineError({\n kind: DICTATION_ENGINE_ERROR_KINDS.connection,\n message: error instanceof Error ? error.message : 'Dictation could not start.',\n });\n return;\n }\n if (terminated) return;\n sessionRef.current = session;\n dispatch({ type: 'listening' });\n };\n void run();\n }, [captureStream, engine, lang, releaseSession, reportEngineError, settleWaiters]);\n\n const stop = useCallback((): Promise<DictationStopResult> => {\n const session = sessionRef.current;\n if (!session) {\n // Stopped while the microphone prompt was still open: nothing was heard\n // yet, and the pending start must not bring the engine up afterwards.\n if (stateRef.current.status === DICTATION_STATUSES.starting) {\n teardown();\n dispatch({ type: 'cancel' });\n return Promise.resolve({ text: '', error: null });\n }\n return Promise.resolve({ text: spokenText(transcriptRef.current), error: sessionErrorRef.current });\n }\n dispatch({ type: 'stop' });\n const flushed = new Promise<DictationStopResult>((resolve) => {\n stopWaitersRef.current.push(resolve);\n window.setTimeout(() => {\n // Bounded wait: a recognizer that never fires onend must not hold the\n // composer hostage. Force the session closed and hand over what was\n // heard so far. An engine that had nothing to show yet (a recorded\n // clip still transcribing) surfaces that as an error rather than\n // passing off silence as the result.\n if (sessionRef.current === session) {\n // Report before abort(): an engine that ends synchronously on\n // abort settles the waiters, and they must see this error.\n if (!spokenText(transcriptRef.current)) {\n reportEngineError({\n kind: DICTATION_ENGINE_ERROR_KINDS.connection,\n message: 'Transcription timed out. Try again.',\n });\n }\n session.abort();\n dispatch({ type: 'ended' });\n releaseSession();\n settleWaiters(spokenText(transcriptRef.current));\n }\n }, engine.flushTimeoutMs ?? DEFAULT_STOP_FLUSH_TIMEOUT_MS);\n });\n session.stop();\n return flushed;\n }, [engine.flushTimeoutMs, releaseSession, reportEngineError, settleWaiters, teardown]);\n\n const cancel = useCallback(() => {\n teardown();\n dispatch({ type: 'cancel' });\n }, [teardown]);\n\n // Release the microphone with the component.\n useEffect(() => () => teardown(), [teardown]);\n\n const isActive =\n state.status === DICTATION_STATUSES.starting ||\n state.status === DICTATION_STATUSES.listening ||\n state.status === DICTATION_STATUSES.stopping;\n\n return {\n status: state.status,\n isActive,\n transcript: state.transcript,\n text: spokenText(state.transcript),\n error: state.error,\n stream,\n isSupported,\n engine,\n start,\n stop,\n cancel,\n };\n}\n"],"names":["useMemo","createWebSpeechDictationEngine","useReducer","dictationReducer","INITIAL_DICTATION_STATE","useState","useRef","useEffect","useCallback","athenaDiagnostics","DICTATION_ENGINE_ERROR_KINDS","spokenText","DICTATION_STATUSES","joinSpeech"],"mappings":";;;;;;AA8EA,MAAM,gCAAgC;AAItC,MAAM,mBAAwC,EAAE,OAAO,IAAI,SAAS,GAAA;AAEpE,SAAS,mBAA2B;AAClC,MAAI,OAAO,aAAa,eAAe,SAAS,gBAAgB,MAAM;AACpE,WAAO,SAAS,gBAAgB;AAAA,EAClC;AACA,MAAI,OAAO,cAAc,eAAe,UAAU,iBAAiB,UAAU;AAC7E,SAAO;AACT;AAEA,eAAe,iBAA8C;;AAC3D,MAAI,OAAO,cAAc,eAAe,GAAC,eAAU,iBAAV,mBAAwB,cAAc,QAAO;AACtF,SAAO,UAAU,aAAa,aAAa,EAA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B,GAAG,CAAC,QAAQ,CAAC;AAGbD,QAAAA,UAAU,MAAM,MAAM,YAAY,CAAC,QAAQ,CAAC;AAE5C,QAAM,WACJ,MAAM,WAAWK,eAAAA,mBAAmB,YACpC,MAAM,WAAWA,eAAAA,mBAAmB,aACpC,MAAM,WAAWA,eAAAA,mBAAmB;AAEtC,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd;AAAA,IACA,YAAY,MAAM;AAAA,IAClB,MAAMD,eAAAA,WAAW,MAAM,UAAU;AAAA,IACjC,OAAO,MAAM;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type DictationEngine, type DictationEngineError } from './dictation-engine';
|
|
2
|
+
import { type DictationStatus, type DictationTranscript } from './dictation-state';
|
|
3
|
+
export interface UseDictationOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Speech engine. Defaults to the browser's Web Speech API; `AthenaChat`
|
|
6
|
+
* passes the record-then-transcribe engine from `useAthenaDictationEngine`.
|
|
7
|
+
*/
|
|
8
|
+
engine?: DictationEngine;
|
|
9
|
+
/** BCP-47 language tag. Defaults to the document language, else `en-US`. */
|
|
10
|
+
lang?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Open the microphone through `getUserMedia` so callers get a `stream` for
|
|
13
|
+
* a waveform. Web Speech opens its own capture; this second capture is
|
|
14
|
+
* what the level meter reads. Defaults to true.
|
|
15
|
+
*/
|
|
16
|
+
captureStream?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The engine ended on its own (silence window, recognizer timeout) while
|
|
19
|
+
* listening, without `stop()` or `cancel()`. Receives the spoken text so
|
|
20
|
+
* the words are not lost; the composer puts them into the draft.
|
|
21
|
+
*/
|
|
22
|
+
onAutoEnd?: (spoken: string) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface DictationStopResult {
|
|
25
|
+
/** Spoken text (final plus interim tail) gathered before the engine closed. */
|
|
26
|
+
text: string;
|
|
27
|
+
/**
|
|
28
|
+
* The engine error reported during this session, if any. When set the
|
|
29
|
+
* transcript may be incomplete: a recorded engine whose upload failed has no
|
|
30
|
+
* words to hand over, so callers should not send the draft as if it were.
|
|
31
|
+
*/
|
|
32
|
+
error: DictationEngineError | null;
|
|
33
|
+
}
|
|
34
|
+
export interface DictationController {
|
|
35
|
+
status: DictationStatus;
|
|
36
|
+
/** True while starting, listening or stopping. */
|
|
37
|
+
isActive: boolean;
|
|
38
|
+
transcript: DictationTranscript;
|
|
39
|
+
/** `final` plus the interim tail, ready to hand to the composer. */
|
|
40
|
+
text: string;
|
|
41
|
+
error: DictationEngineError | null;
|
|
42
|
+
/** The microphone stream while active (for a waveform), else null. */
|
|
43
|
+
stream: MediaStream | null;
|
|
44
|
+
/** Whether the engine can run here. Hide the control when false. */
|
|
45
|
+
isSupported: boolean;
|
|
46
|
+
/** The engine in use (for its `stoppingLabel` and diagnostics). */
|
|
47
|
+
engine: DictationEngine;
|
|
48
|
+
start: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Finish recording. Resolves once the engine has flushed (bounded wait), so
|
|
51
|
+
* trailing words are not lost, with the spoken text and any error raised
|
|
52
|
+
* along the way.
|
|
53
|
+
*/
|
|
54
|
+
stop: () => Promise<DictationStopResult>;
|
|
55
|
+
/** Discard the session and its transcript. */
|
|
56
|
+
cancel: () => void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Drive a dictation session: microphone, speech engine, and the transcript
|
|
60
|
+
* state machine. The composer renders the waveform from `stream` and the
|
|
61
|
+
* live caption from `transcript`; on `stop()` it appends `text` to the draft.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useDictation(options?: UseDictationOptions): DictationController;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { useMemo, useReducer, useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
+
import { athenaDiagnostics } from "../diagnostics/athena-diagnostics.js";
|
|
3
|
+
import { createWebSpeechDictationEngine, DICTATION_ENGINE_ERROR_KINDS } from "./dictation-engine.js";
|
|
4
|
+
import { dictationReducer, INITIAL_DICTATION_STATE, DICTATION_STATUSES, spokenText, joinSpeech } from "./dictation-state.js";
|
|
5
|
+
const DEFAULT_STOP_FLUSH_TIMEOUT_MS = 1500;
|
|
6
|
+
const EMPTY_TRANSCRIPT = { final: "", interim: "" };
|
|
7
|
+
function documentLanguage() {
|
|
8
|
+
if (typeof document !== "undefined" && document.documentElement.lang) {
|
|
9
|
+
return document.documentElement.lang;
|
|
10
|
+
}
|
|
11
|
+
if (typeof navigator !== "undefined" && navigator.language) return navigator.language;
|
|
12
|
+
return "en-US";
|
|
13
|
+
}
|
|
14
|
+
async function openMicrophone() {
|
|
15
|
+
var _a;
|
|
16
|
+
if (typeof navigator === "undefined" || !((_a = navigator.mediaDevices) == null ? void 0 : _a.getUserMedia)) return null;
|
|
17
|
+
return navigator.mediaDevices.getUserMedia({ audio: true });
|
|
18
|
+
}
|
|
19
|
+
function releaseStream(stream) {
|
|
20
|
+
if (!stream) return;
|
|
21
|
+
for (const track of stream.getTracks()) track.stop();
|
|
22
|
+
}
|
|
23
|
+
function useDictation(options = {}) {
|
|
24
|
+
const engine = useMemo(() => options.engine ?? createWebSpeechDictationEngine(), [options.engine]);
|
|
25
|
+
const { lang, captureStream = true, onAutoEnd } = options;
|
|
26
|
+
const [state, dispatch] = useReducer(dictationReducer, INITIAL_DICTATION_STATE);
|
|
27
|
+
const [stream, setStream] = useState(null);
|
|
28
|
+
const [isSupported, setIsSupported] = useState(false);
|
|
29
|
+
const sessionRef = useRef(null);
|
|
30
|
+
const streamRef = useRef(null);
|
|
31
|
+
const stateRef = useRef(state);
|
|
32
|
+
stateRef.current = state;
|
|
33
|
+
const transcriptRef = useRef(EMPTY_TRANSCRIPT);
|
|
34
|
+
const onAutoEndRef = useRef(onAutoEnd);
|
|
35
|
+
onAutoEndRef.current = onAutoEnd;
|
|
36
|
+
const stopWaitersRef = useRef([]);
|
|
37
|
+
const sessionErrorRef = useRef(null);
|
|
38
|
+
const generationRef = useRef(0);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
setIsSupported(engine.isSupported());
|
|
41
|
+
}, [engine]);
|
|
42
|
+
const settleWaiters = useCallback((spoken) => {
|
|
43
|
+
const waiters = stopWaitersRef.current;
|
|
44
|
+
stopWaitersRef.current = [];
|
|
45
|
+
const result = { text: spoken, error: sessionErrorRef.current };
|
|
46
|
+
for (const resolve of waiters) resolve(result);
|
|
47
|
+
}, []);
|
|
48
|
+
const releaseSession = useCallback(() => {
|
|
49
|
+
sessionRef.current = null;
|
|
50
|
+
releaseStream(streamRef.current);
|
|
51
|
+
streamRef.current = null;
|
|
52
|
+
setStream(null);
|
|
53
|
+
}, []);
|
|
54
|
+
const teardown = useCallback(() => {
|
|
55
|
+
var _a;
|
|
56
|
+
generationRef.current += 1;
|
|
57
|
+
(_a = sessionRef.current) == null ? void 0 : _a.abort();
|
|
58
|
+
releaseSession();
|
|
59
|
+
transcriptRef.current = EMPTY_TRANSCRIPT;
|
|
60
|
+
settleWaiters("");
|
|
61
|
+
}, [releaseSession, settleWaiters]);
|
|
62
|
+
const reportEngineError = useCallback(
|
|
63
|
+
(engineError) => {
|
|
64
|
+
athenaDiagnostics.emit("composer.dictation", {
|
|
65
|
+
level: "warn",
|
|
66
|
+
data: { phase: "error", engine: engine.id, kind: engineError.kind }
|
|
67
|
+
});
|
|
68
|
+
sessionErrorRef.current = engineError;
|
|
69
|
+
dispatch({ type: "error", error: engineError });
|
|
70
|
+
},
|
|
71
|
+
[engine.id]
|
|
72
|
+
);
|
|
73
|
+
const start = useCallback(() => {
|
|
74
|
+
if (sessionRef.current) return;
|
|
75
|
+
const generation = generationRef.current + 1;
|
|
76
|
+
generationRef.current = generation;
|
|
77
|
+
transcriptRef.current = EMPTY_TRANSCRIPT;
|
|
78
|
+
sessionErrorRef.current = null;
|
|
79
|
+
dispatch({ type: "start" });
|
|
80
|
+
athenaDiagnostics.emit("composer.dictation", {
|
|
81
|
+
level: "debug",
|
|
82
|
+
data: { phase: "start", engine: engine.id }
|
|
83
|
+
});
|
|
84
|
+
const run = async () => {
|
|
85
|
+
let microphone = null;
|
|
86
|
+
if (captureStream) {
|
|
87
|
+
try {
|
|
88
|
+
microphone = await openMicrophone();
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (generationRef.current !== generation) {
|
|
91
|
+
releaseStream(microphone);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
dispatch({
|
|
95
|
+
type: "error",
|
|
96
|
+
error: {
|
|
97
|
+
kind: DICTATION_ENGINE_ERROR_KINDS.permission,
|
|
98
|
+
message: error instanceof DOMException && error.name === "NotFoundError" ? "No microphone was found." : "Microphone access was denied. Allow the microphone for this site and try again."
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (generationRef.current !== generation) {
|
|
105
|
+
releaseStream(microphone);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
streamRef.current = microphone;
|
|
109
|
+
setStream(microphone);
|
|
110
|
+
let terminated = false;
|
|
111
|
+
const endSession = () => {
|
|
112
|
+
var _a;
|
|
113
|
+
terminated = true;
|
|
114
|
+
const current = stateRef.current;
|
|
115
|
+
const spoken = spokenText(transcriptRef.current);
|
|
116
|
+
const endedOnItsOwn = stopWaitersRef.current.length === 0 && current.status === DICTATION_STATUSES.listening;
|
|
117
|
+
dispatch({ type: "ended" });
|
|
118
|
+
releaseSession();
|
|
119
|
+
settleWaiters(spoken);
|
|
120
|
+
if (endedOnItsOwn) (_a = onAutoEndRef.current) == null ? void 0 : _a.call(onAutoEndRef, spoken);
|
|
121
|
+
};
|
|
122
|
+
let session;
|
|
123
|
+
try {
|
|
124
|
+
session = engine.start({
|
|
125
|
+
stream: microphone,
|
|
126
|
+
lang: lang ?? documentLanguage(),
|
|
127
|
+
callbacks: {
|
|
128
|
+
onTranscript: (update) => {
|
|
129
|
+
if (generationRef.current !== generation) return;
|
|
130
|
+
transcriptRef.current = {
|
|
131
|
+
final: joinSpeech(transcriptRef.current.final, update.final),
|
|
132
|
+
interim: update.interim
|
|
133
|
+
};
|
|
134
|
+
dispatch({ type: "transcript", update });
|
|
135
|
+
},
|
|
136
|
+
onError: (engineError) => {
|
|
137
|
+
if (generationRef.current !== generation) return;
|
|
138
|
+
if (engineError.kind === DICTATION_ENGINE_ERROR_KINDS.noSpeech) return;
|
|
139
|
+
reportEngineError(engineError);
|
|
140
|
+
},
|
|
141
|
+
onEnd: () => {
|
|
142
|
+
if (generationRef.current !== generation) return;
|
|
143
|
+
endSession();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
} catch (error) {
|
|
148
|
+
releaseSession();
|
|
149
|
+
reportEngineError({
|
|
150
|
+
kind: DICTATION_ENGINE_ERROR_KINDS.connection,
|
|
151
|
+
message: error instanceof Error ? error.message : "Dictation could not start."
|
|
152
|
+
});
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (terminated) return;
|
|
156
|
+
sessionRef.current = session;
|
|
157
|
+
dispatch({ type: "listening" });
|
|
158
|
+
};
|
|
159
|
+
void run();
|
|
160
|
+
}, [captureStream, engine, lang, releaseSession, reportEngineError, settleWaiters]);
|
|
161
|
+
const stop = useCallback(() => {
|
|
162
|
+
const session = sessionRef.current;
|
|
163
|
+
if (!session) {
|
|
164
|
+
if (stateRef.current.status === DICTATION_STATUSES.starting) {
|
|
165
|
+
teardown();
|
|
166
|
+
dispatch({ type: "cancel" });
|
|
167
|
+
return Promise.resolve({ text: "", error: null });
|
|
168
|
+
}
|
|
169
|
+
return Promise.resolve({ text: spokenText(transcriptRef.current), error: sessionErrorRef.current });
|
|
170
|
+
}
|
|
171
|
+
dispatch({ type: "stop" });
|
|
172
|
+
const flushed = new Promise((resolve) => {
|
|
173
|
+
stopWaitersRef.current.push(resolve);
|
|
174
|
+
window.setTimeout(() => {
|
|
175
|
+
if (sessionRef.current === session) {
|
|
176
|
+
if (!spokenText(transcriptRef.current)) {
|
|
177
|
+
reportEngineError({
|
|
178
|
+
kind: DICTATION_ENGINE_ERROR_KINDS.connection,
|
|
179
|
+
message: "Transcription timed out. Try again."
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
session.abort();
|
|
183
|
+
dispatch({ type: "ended" });
|
|
184
|
+
releaseSession();
|
|
185
|
+
settleWaiters(spokenText(transcriptRef.current));
|
|
186
|
+
}
|
|
187
|
+
}, engine.flushTimeoutMs ?? DEFAULT_STOP_FLUSH_TIMEOUT_MS);
|
|
188
|
+
});
|
|
189
|
+
session.stop();
|
|
190
|
+
return flushed;
|
|
191
|
+
}, [engine.flushTimeoutMs, releaseSession, reportEngineError, settleWaiters, teardown]);
|
|
192
|
+
const cancel = useCallback(() => {
|
|
193
|
+
teardown();
|
|
194
|
+
dispatch({ type: "cancel" });
|
|
195
|
+
}, [teardown]);
|
|
196
|
+
useEffect(() => () => teardown(), [teardown]);
|
|
197
|
+
const isActive = state.status === DICTATION_STATUSES.starting || state.status === DICTATION_STATUSES.listening || state.status === DICTATION_STATUSES.stopping;
|
|
198
|
+
return {
|
|
199
|
+
status: state.status,
|
|
200
|
+
isActive,
|
|
201
|
+
transcript: state.transcript,
|
|
202
|
+
text: spokenText(state.transcript),
|
|
203
|
+
error: state.error,
|
|
204
|
+
stream,
|
|
205
|
+
isSupported,
|
|
206
|
+
engine,
|
|
207
|
+
start,
|
|
208
|
+
stop,
|
|
209
|
+
cancel
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
export {
|
|
213
|
+
useDictation
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=use-dictation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-dictation.js","sources":["../../src/dictation/use-dictation.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';\nimport { athenaDiagnostics } from '../diagnostics/athena-diagnostics';\nimport {\n createWebSpeechDictationEngine,\n DICTATION_ENGINE_ERROR_KINDS,\n type DictationEngine,\n type DictationEngineError,\n type DictationEngineSession,\n} from './dictation-engine';\nimport {\n DICTATION_STATUSES,\n dictationReducer,\n INITIAL_DICTATION_STATE,\n joinSpeech,\n spokenText,\n type DictationStatus,\n type DictationTranscript,\n} from './dictation-state';\n\nexport interface UseDictationOptions {\n /**\n * Speech engine. Defaults to the browser's Web Speech API; `AthenaChat`\n * passes the record-then-transcribe engine from `useAthenaDictationEngine`.\n */\n engine?: DictationEngine;\n /** BCP-47 language tag. Defaults to the document language, else `en-US`. */\n lang?: string;\n /**\n * Open the microphone through `getUserMedia` so callers get a `stream` for\n * a waveform. Web Speech opens its own capture; this second capture is\n * what the level meter reads. Defaults to true.\n */\n captureStream?: boolean;\n /**\n * The engine ended on its own (silence window, recognizer timeout) while\n * listening, without `stop()` or `cancel()`. Receives the spoken text so\n * the words are not lost; the composer puts them into the draft.\n */\n onAutoEnd?: (spoken: string) => void;\n}\n\nexport interface DictationStopResult {\n /** Spoken text (final plus interim tail) gathered before the engine closed. */\n text: string;\n /**\n * The engine error reported during this session, if any. When set the\n * transcript may be incomplete: a recorded engine whose upload failed has no\n * words to hand over, so callers should not send the draft as if it were.\n */\n error: DictationEngineError | null;\n}\n\nexport interface DictationController {\n status: DictationStatus;\n /** True while starting, listening or stopping. */\n isActive: boolean;\n transcript: DictationTranscript;\n /** `final` plus the interim tail, ready to hand to the composer. */\n text: string;\n error: DictationEngineError | null;\n /** The microphone stream while active (for a waveform), else null. */\n stream: MediaStream | null;\n /** Whether the engine can run here. Hide the control when false. */\n isSupported: boolean;\n /** The engine in use (for its `stoppingLabel` and diagnostics). */\n engine: DictationEngine;\n start: () => void;\n /**\n * Finish recording. Resolves once the engine has flushed (bounded wait), so\n * trailing words are not lost, with the spoken text and any error raised\n * along the way.\n */\n stop: () => Promise<DictationStopResult>;\n /** Discard the session and its transcript. */\n cancel: () => void;\n}\n\n/** How long `stop()` waits for a live engine's final flush before giving up. */\nconst DEFAULT_STOP_FLUSH_TIMEOUT_MS = 1500;\n\ntype StopResolver = (result: DictationStopResult) => void;\n\nconst EMPTY_TRANSCRIPT: DictationTranscript = { final: '', interim: '' };\n\nfunction documentLanguage(): string {\n if (typeof document !== 'undefined' && document.documentElement.lang) {\n return document.documentElement.lang;\n }\n if (typeof navigator !== 'undefined' && navigator.language) return navigator.language;\n return 'en-US';\n}\n\nasync function openMicrophone(): Promise<MediaStream | null> {\n if (typeof navigator === 'undefined' || !navigator.mediaDevices?.getUserMedia) return null;\n return navigator.mediaDevices.getUserMedia({ audio: true });\n}\n\nfunction releaseStream(stream: MediaStream | null): void {\n if (!stream) return;\n for (const track of stream.getTracks()) track.stop();\n}\n\n/**\n * Drive a dictation session: microphone, speech engine, and the transcript\n * state machine. The composer renders the waveform from `stream` and the\n * live caption from `transcript`; on `stop()` it appends `text` to the draft.\n */\nexport function useDictation(options: UseDictationOptions = {}): DictationController {\n const engine = useMemo(() => options.engine ?? createWebSpeechDictationEngine(), [options.engine]);\n const { lang, captureStream = true, onAutoEnd } = options;\n const [state, dispatch] = useReducer(dictationReducer, INITIAL_DICTATION_STATE);\n const [stream, setStream] = useState<MediaStream | null>(null);\n const [isSupported, setIsSupported] = useState(false);\n\n const sessionRef = useRef<DictationEngineSession | null>(null);\n const streamRef = useRef<MediaStream | null>(null);\n const stateRef = useRef(state);\n stateRef.current = state;\n // The authoritative transcript, updated synchronously as the engine reports\n // it. The reducer's copy renders the caption; this one is what `stop()` and\n // `onAutoEnd` hand over, so an engine that flushes its last words and ends\n // in the same tick — before React has rendered — loses nothing.\n const transcriptRef = useRef<DictationTranscript>(EMPTY_TRANSCRIPT);\n const onAutoEndRef = useRef(onAutoEnd);\n onAutoEndRef.current = onAutoEnd;\n // stop() callers waiting for the engine's final flush.\n const stopWaitersRef = useRef<StopResolver[]>([]);\n // Last engine error of the current session, handed to stop() callers\n // synchronously (the reducer's copy may not have rendered yet).\n const sessionErrorRef = useRef<DictationEngineError | null>(null);\n // Distinguishes a fresh session from the callbacks of a torn-down one.\n const generationRef = useRef(0);\n\n useEffect(() => {\n setIsSupported(engine.isSupported());\n }, [engine]);\n\n const settleWaiters = useCallback((spoken: string) => {\n const waiters = stopWaitersRef.current;\n stopWaitersRef.current = [];\n const result: DictationStopResult = { text: spoken, error: sessionErrorRef.current };\n for (const resolve of waiters) resolve(result);\n }, []);\n\n const releaseSession = useCallback(() => {\n sessionRef.current = null;\n releaseStream(streamRef.current);\n streamRef.current = null;\n setStream(null);\n }, []);\n\n const teardown = useCallback(() => {\n generationRef.current += 1;\n sessionRef.current?.abort();\n releaseSession();\n transcriptRef.current = EMPTY_TRANSCRIPT;\n settleWaiters('');\n }, [releaseSession, settleWaiters]);\n\n const reportEngineError = useCallback(\n (engineError: DictationEngineError) => {\n athenaDiagnostics.emit('composer.dictation', {\n level: 'warn',\n data: { phase: 'error', engine: engine.id, kind: engineError.kind },\n });\n sessionErrorRef.current = engineError;\n dispatch({ type: 'error', error: engineError });\n },\n [engine.id],\n );\n\n const start = useCallback(() => {\n if (sessionRef.current) return;\n const generation = generationRef.current + 1;\n generationRef.current = generation;\n transcriptRef.current = EMPTY_TRANSCRIPT;\n sessionErrorRef.current = null;\n dispatch({ type: 'start' });\n athenaDiagnostics.emit('composer.dictation', {\n level: 'debug',\n data: { phase: 'start', engine: engine.id },\n });\n\n const run = async () => {\n let microphone: MediaStream | null = null;\n if (captureStream) {\n try {\n microphone = await openMicrophone();\n } catch (error) {\n if (generationRef.current !== generation) {\n releaseStream(microphone);\n return;\n }\n dispatch({\n type: 'error',\n error: {\n kind: DICTATION_ENGINE_ERROR_KINDS.permission,\n message:\n error instanceof DOMException && error.name === 'NotFoundError'\n ? 'No microphone was found.'\n : 'Microphone access was denied. Allow the microphone for this site and try again.',\n },\n });\n return;\n }\n }\n if (generationRef.current !== generation) {\n releaseStream(microphone);\n return;\n }\n streamRef.current = microphone;\n setStream(microphone);\n\n // An engine may fail synchronously inside start() (Web Speech throws\n // when recognition.start() is refused) and run onError/onEnd before we\n // hold the session. Those callbacks flip this flag so a dead session is\n // never stored, which would make every later mic click return early.\n let terminated = false;\n const endSession = () => {\n terminated = true;\n const current = stateRef.current;\n const spoken = spokenText(transcriptRef.current);\n // No stop() is waiting: the engine gave up on its own. Hand the\n // words over so they land in the draft instead of vanishing.\n const endedOnItsOwn =\n stopWaitersRef.current.length === 0 && current.status === DICTATION_STATUSES.listening;\n // The reducer keeps an error status through 'ended', so an error\n // reported just before the engine closed stays on screen.\n dispatch({ type: 'ended' });\n releaseSession();\n settleWaiters(spoken);\n if (endedOnItsOwn) onAutoEndRef.current?.(spoken);\n };\n let session: DictationEngineSession;\n try {\n session = engine.start({\n stream: microphone,\n lang: lang ?? documentLanguage(),\n callbacks: {\n onTranscript: (update) => {\n if (generationRef.current !== generation) return;\n transcriptRef.current = {\n final: joinSpeech(transcriptRef.current.final, update.final),\n interim: update.interim,\n };\n dispatch({ type: 'transcript', update });\n },\n onError: (engineError) => {\n if (generationRef.current !== generation) return;\n // A silence timeout is the engine giving up politely; keep the\n // words we have instead of showing an error.\n if (engineError.kind === DICTATION_ENGINE_ERROR_KINDS.noSpeech) return;\n reportEngineError(engineError);\n },\n onEnd: () => {\n if (generationRef.current !== generation) return;\n endSession();\n },\n },\n });\n } catch (error) {\n // A relay engine that cannot build its session must not strand the\n // microphone or leave the composer in `starting`.\n releaseSession();\n reportEngineError({\n kind: DICTATION_ENGINE_ERROR_KINDS.connection,\n message: error instanceof Error ? error.message : 'Dictation could not start.',\n });\n return;\n }\n if (terminated) return;\n sessionRef.current = session;\n dispatch({ type: 'listening' });\n };\n void run();\n }, [captureStream, engine, lang, releaseSession, reportEngineError, settleWaiters]);\n\n const stop = useCallback((): Promise<DictationStopResult> => {\n const session = sessionRef.current;\n if (!session) {\n // Stopped while the microphone prompt was still open: nothing was heard\n // yet, and the pending start must not bring the engine up afterwards.\n if (stateRef.current.status === DICTATION_STATUSES.starting) {\n teardown();\n dispatch({ type: 'cancel' });\n return Promise.resolve({ text: '', error: null });\n }\n return Promise.resolve({ text: spokenText(transcriptRef.current), error: sessionErrorRef.current });\n }\n dispatch({ type: 'stop' });\n const flushed = new Promise<DictationStopResult>((resolve) => {\n stopWaitersRef.current.push(resolve);\n window.setTimeout(() => {\n // Bounded wait: a recognizer that never fires onend must not hold the\n // composer hostage. Force the session closed and hand over what was\n // heard so far. An engine that had nothing to show yet (a recorded\n // clip still transcribing) surfaces that as an error rather than\n // passing off silence as the result.\n if (sessionRef.current === session) {\n // Report before abort(): an engine that ends synchronously on\n // abort settles the waiters, and they must see this error.\n if (!spokenText(transcriptRef.current)) {\n reportEngineError({\n kind: DICTATION_ENGINE_ERROR_KINDS.connection,\n message: 'Transcription timed out. Try again.',\n });\n }\n session.abort();\n dispatch({ type: 'ended' });\n releaseSession();\n settleWaiters(spokenText(transcriptRef.current));\n }\n }, engine.flushTimeoutMs ?? DEFAULT_STOP_FLUSH_TIMEOUT_MS);\n });\n session.stop();\n return flushed;\n }, [engine.flushTimeoutMs, releaseSession, reportEngineError, settleWaiters, teardown]);\n\n const cancel = useCallback(() => {\n teardown();\n dispatch({ type: 'cancel' });\n }, [teardown]);\n\n // Release the microphone with the component.\n useEffect(() => () => teardown(), [teardown]);\n\n const isActive =\n state.status === DICTATION_STATUSES.starting ||\n state.status === DICTATION_STATUSES.listening ||\n state.status === DICTATION_STATUSES.stopping;\n\n return {\n status: state.status,\n isActive,\n transcript: state.transcript,\n text: spokenText(state.transcript),\n error: state.error,\n stream,\n isSupported,\n engine,\n start,\n stop,\n cancel,\n };\n}\n"],"names":[],"mappings":";;;;AA8EA,MAAM,gCAAgC;AAItC,MAAM,mBAAwC,EAAE,OAAO,IAAI,SAAS,GAAA;AAEpE,SAAS,mBAA2B;AAClC,MAAI,OAAO,aAAa,eAAe,SAAS,gBAAgB,MAAM;AACpE,WAAO,SAAS,gBAAgB;AAAA,EAClC;AACA,MAAI,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BAAmB,YACpC,MAAM,WAAW,mBAAmB,aACpC,MAAM,WAAW,mBAAmB;AAEtC,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd;AAAA,IACA,YAAY,MAAM;AAAA,IAClB,MAAM,WAAW,MAAM,UAAU;AAAA,IACjC,OAAO,MAAM;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
package/dist/index.cjs
CHANGED
|
@@ -40,27 +40,6 @@ const toolUis = require("./tools/tool-uis.cjs");
|
|
|
40
40
|
const primitives = require("./tools/primitives.cjs");
|
|
41
41
|
const miscToolUis = require("./tools/misc-tool-uis.cjs");
|
|
42
42
|
const toolIcons = require("./tools/tool-icons.cjs");
|
|
43
|
-
require("./packages/agent-runtime/src/generated/runconfig-contract.cjs");
|
|
44
|
-
require("react");
|
|
45
|
-
require("@assistant-ui/tap");
|
|
46
|
-
require("statewire");
|
|
47
|
-
require("./packages/agent-runtime/src/statewire-suspended.cjs");
|
|
48
|
-
const conversationList = require("./packages/agent-runtime/src/conversation-list.cjs");
|
|
49
|
-
const toolMetadata = require("./packages/agent-runtime/src/tool-metadata.cjs");
|
|
50
|
-
const toolResult = require("./packages/agent-runtime/src/tool-result.cjs");
|
|
51
|
-
require("@tanstack/react-query");
|
|
52
|
-
const interrupts = require("./packages/agent-runtime/src/interrupts.cjs");
|
|
53
|
-
require("./packages/agent-runtime/src/messages.cjs");
|
|
54
|
-
require("./packages/agent-runtime/src/statewire-state.cjs");
|
|
55
|
-
const threadExtras = require("./packages/agent-runtime/src/thread-extras.cjs");
|
|
56
|
-
require("@assistant-ui/store");
|
|
57
|
-
require("./packages/agent-runtime/src/quota-safe-local-storage-session.cjs");
|
|
58
|
-
require("./packages/agent-runtime/src/statewire-attach-observer.cjs");
|
|
59
|
-
require("./packages/agent-runtime/src/thread-status.cjs");
|
|
60
|
-
require("@assistant-ui/react-statewire");
|
|
61
|
-
const githubWakeEvent = require("./packages/agent-runtime/src/github-wake-event.cjs");
|
|
62
|
-
require("@assistant-ui/core");
|
|
63
|
-
require("./packages/agent-runtime/src/thread-handoff.cjs");
|
|
64
43
|
const writeTodosToolUi = require("./tools/write-todos-tool-ui.cjs");
|
|
65
44
|
const todoPlanStore = require("./tools/todo-plan-store.cjs");
|
|
66
45
|
const fileToolUis = require("./tools/file-tool-uis.cjs");
|
|
@@ -88,7 +67,14 @@ const threadPrefetcher = require("./threads/thread-prefetcher.cjs");
|
|
|
88
67
|
const useRestConversationHistory = require("./threads/use-rest-conversation-history.cjs");
|
|
89
68
|
const useStatewireConversationHistory = require("./threads/use-statewire-conversation-history.cjs");
|
|
90
69
|
const useAthenaThreadManager = require("./threads/useAthenaThreadManager.cjs");
|
|
70
|
+
const useDictation = require("./dictation/use-dictation.cjs");
|
|
71
|
+
const DictationStrip = require("./dictation/DictationStrip.cjs");
|
|
72
|
+
const dictationEngine = require("./dictation/dictation-engine.cjs");
|
|
73
|
+
const recordedDictationEngine = require("./dictation/recorded-dictation-engine.cjs");
|
|
74
|
+
const useAthenaDictationEngine = require("./dictation/use-athena-dictation-engine.cjs");
|
|
75
|
+
const dictationState = require("./dictation/dictation-state.cjs");
|
|
91
76
|
const useAppendToComposer = require("./composer/useAppendToComposer.cjs");
|
|
77
|
+
const composerHandoff = require("./composer/composer-handoff.cjs");
|
|
92
78
|
const useSendMessage = require("./composer/useSendMessage.cjs");
|
|
93
79
|
const useComposerAttachment = require("./composer/useComposerAttachment.cjs");
|
|
94
80
|
const useFileUpload = require("./composer/useFileUpload.cjs");
|
|
@@ -103,7 +89,13 @@ const tooltip = require("./ui/tooltip.cjs");
|
|
|
103
89
|
const collapsible = require("./ui/collapsible.cjs");
|
|
104
90
|
const index = require("./toolkits/index.cjs");
|
|
105
91
|
const index$1 = require("./theme/index.cjs");
|
|
92
|
+
const interrupts = require("./packages/agent-runtime/src/interrupts.cjs");
|
|
93
|
+
const toolResult = require("./packages/agent-runtime/src/tool-result.cjs");
|
|
106
94
|
const cnfast = require("cnfast");
|
|
95
|
+
const conversationList = require("./packages/agent-runtime/src/conversation-list.cjs");
|
|
96
|
+
const toolMetadata = require("./packages/agent-runtime/src/tool-metadata.cjs");
|
|
97
|
+
const githubWakeEvent = require("./packages/agent-runtime/src/github-wake-event.cjs");
|
|
98
|
+
const threadExtras = require("./packages/agent-runtime/src/thread-extras.cjs");
|
|
107
99
|
const toolAppearance = require("./tools/tool-appearance.cjs");
|
|
108
100
|
exports.ATHENA_REACT_SDK_VERSION = version.ATHENA_REACT_SDK_VERSION;
|
|
109
101
|
exports.athenaDiagnostics = athenaDiagnostics.athenaDiagnostics;
|
|
@@ -213,24 +205,6 @@ exports.truncate = primitives.truncate;
|
|
|
213
205
|
exports.InstallPackageToolUI = miscToolUis.InstallPackageToolUI;
|
|
214
206
|
exports.TOOL_ICONS = toolIcons.TOOL_ICONS;
|
|
215
207
|
exports.toolIcon = toolIcons.toolIcon;
|
|
216
|
-
exports.deriveConversationAttention = conversationList.deriveConversationAttention;
|
|
217
|
-
exports.describeToolArgs = toolMetadata.describeToolArgs;
|
|
218
|
-
exports.formatToolName = toolMetadata.formatToolName;
|
|
219
|
-
exports.getToolDisplayMeta = toolMetadata.getToolDisplayMeta;
|
|
220
|
-
exports.toolActiveLabel = toolMetadata.toolActiveLabel;
|
|
221
|
-
exports.toolCompletedLabel = toolMetadata.toolCompletedLabel;
|
|
222
|
-
exports.classifyToolResult = toolResult.classifyToolResult;
|
|
223
|
-
exports.isToolResultSuccess = toolResult.isToolResultSuccess;
|
|
224
|
-
exports.resultMessage = toolResult.resultMessage;
|
|
225
|
-
exports.HITL_PENDING_RESUME_GRACE_MS = interrupts.HITL_PENDING_RESUME_GRACE_MS;
|
|
226
|
-
exports.asHitlApproval = interrupts.asHitlApproval;
|
|
227
|
-
exports.isPendingInterrupt = interrupts.isPendingInterrupt;
|
|
228
|
-
exports.readInterruptMessage = interrupts.readInterruptMessage;
|
|
229
|
-
exports.hasStatewireThreadExtras = threadExtras.hasStatewireThreadExtras;
|
|
230
|
-
exports.githubWakeEventLabel = githubWakeEvent.githubWakeEventLabel;
|
|
231
|
-
exports.githubWakeMarkerText = githubWakeEvent.githubWakeMarkerText;
|
|
232
|
-
exports.isGithubWakeMessage = githubWakeEvent.isGithubWakeMessage;
|
|
233
|
-
exports.readGithubWakeEvent = githubWakeEvent.readGithubWakeEvent;
|
|
234
208
|
exports.HiddenWriteTodosToolUI = writeTodosToolUi.HiddenWriteTodosToolUI;
|
|
235
209
|
exports.WriteTodosToolUI = writeTodosToolUi.WriteTodosToolUI;
|
|
236
210
|
exports.parseTodoPlan = writeTodosToolUi.parseTodoPlan;
|
|
@@ -300,7 +274,17 @@ exports.useRestConversationHistory = useRestConversationHistory.useRestConversat
|
|
|
300
274
|
exports.conversationSummaryFromIndexEntry = useStatewireConversationHistory.conversationSummaryFromIndexEntry;
|
|
301
275
|
exports.useStatewireConversationHistory = useStatewireConversationHistory.useStatewireConversationHistory;
|
|
302
276
|
exports.useAthenaThreadManager = useAthenaThreadManager.useAthenaThreadManager;
|
|
277
|
+
exports.useDictation = useDictation.useDictation;
|
|
278
|
+
exports.DictationStrip = DictationStrip.DictationStrip;
|
|
279
|
+
exports.DictationWaveform = DictationStrip.DictationWaveform;
|
|
280
|
+
exports.DICTATION_ENGINE_ERROR_KINDS = dictationEngine.DICTATION_ENGINE_ERROR_KINDS;
|
|
281
|
+
exports.createWebSpeechDictationEngine = dictationEngine.createWebSpeechDictationEngine;
|
|
282
|
+
exports.createRecordedDictationEngine = recordedDictationEngine.createRecordedDictationEngine;
|
|
283
|
+
exports.useAthenaDictationEngine = useAthenaDictationEngine.useAthenaDictationEngine;
|
|
284
|
+
exports.DICTATION_STATUSES = dictationState.DICTATION_STATUSES;
|
|
285
|
+
exports.composeDictationDraft = dictationState.composeDictationDraft;
|
|
303
286
|
exports.useAppendToComposer = useAppendToComposer.useAppendToComposer;
|
|
287
|
+
exports.useComposerReady = composerHandoff.useComposerReady;
|
|
304
288
|
exports.useSendMessage = useSendMessage.useSendMessage;
|
|
305
289
|
exports.useComposerAttachment = useComposerAttachment.useComposerAttachment;
|
|
306
290
|
exports.useFileUpload = useFileUpload.useFileUpload;
|
|
@@ -329,9 +313,27 @@ exports.CollapsibleTrigger = collapsible.CollapsibleTrigger;
|
|
|
329
313
|
exports.Toolkits = index.Toolkits;
|
|
330
314
|
exports.themeToStyleVars = index$1.themeToStyleVars;
|
|
331
315
|
exports.themes = index$1.themes;
|
|
316
|
+
exports.HITL_PENDING_RESUME_GRACE_MS = interrupts.HITL_PENDING_RESUME_GRACE_MS;
|
|
317
|
+
exports.asHitlApproval = interrupts.asHitlApproval;
|
|
318
|
+
exports.isPendingInterrupt = interrupts.isPendingInterrupt;
|
|
319
|
+
exports.readInterruptMessage = interrupts.readInterruptMessage;
|
|
320
|
+
exports.classifyToolResult = toolResult.classifyToolResult;
|
|
321
|
+
exports.isToolResultSuccess = toolResult.isToolResultSuccess;
|
|
322
|
+
exports.resultMessage = toolResult.resultMessage;
|
|
332
323
|
Object.defineProperty(exports, "cn", {
|
|
333
324
|
enumerable: true,
|
|
334
325
|
get: () => cnfast.cn
|
|
335
326
|
});
|
|
327
|
+
exports.deriveConversationAttention = conversationList.deriveConversationAttention;
|
|
328
|
+
exports.describeToolArgs = toolMetadata.describeToolArgs;
|
|
329
|
+
exports.formatToolName = toolMetadata.formatToolName;
|
|
330
|
+
exports.getToolDisplayMeta = toolMetadata.getToolDisplayMeta;
|
|
331
|
+
exports.toolActiveLabel = toolMetadata.toolActiveLabel;
|
|
332
|
+
exports.toolCompletedLabel = toolMetadata.toolCompletedLabel;
|
|
333
|
+
exports.githubWakeEventLabel = githubWakeEvent.githubWakeEventLabel;
|
|
334
|
+
exports.githubWakeMarkerText = githubWakeEvent.githubWakeMarkerText;
|
|
335
|
+
exports.isGithubWakeMessage = githubWakeEvent.isGithubWakeMessage;
|
|
336
|
+
exports.readGithubWakeEvent = githubWakeEvent.readGithubWakeEvent;
|
|
337
|
+
exports.hasStatewireThreadExtras = threadExtras.hasStatewireThreadExtras;
|
|
336
338
|
exports.useToolAppearance = toolAppearance.useToolAppearance;
|
|
337
339
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -114,7 +114,21 @@ export { conversationDisplayTitle, useRestConversationHistory, type RestConversa
|
|
|
114
114
|
export { conversationSummaryFromIndexEntry, useStatewireConversationHistory, type UseStatewireConversationHistoryOptions, } from './threads/use-statewire-conversation-history';
|
|
115
115
|
export { useAthenaThreadManager } from './threads/useAthenaThreadManager';
|
|
116
116
|
export type { AthenaThreadManagerState } from './threads/useAthenaThreadManager';
|
|
117
|
+
export { useDictation } from './dictation/use-dictation';
|
|
118
|
+
export type { DictationController, DictationStopResult, UseDictationOptions, } from './dictation/use-dictation';
|
|
119
|
+
export { DictationStrip, DictationWaveform } from './dictation/DictationStrip';
|
|
120
|
+
export type { DictationStripProps } from './dictation/DictationStrip';
|
|
121
|
+
export { createWebSpeechDictationEngine, DICTATION_ENGINE_ERROR_KINDS, } from './dictation/dictation-engine';
|
|
122
|
+
export type { DictationEngine, DictationEngineCallbacks, DictationEngineError, DictationEngineErrorKind, DictationEngineSession, DictationTranscriptUpdate, } from './dictation/dictation-engine';
|
|
123
|
+
export { createRecordedDictationEngine } from './dictation/recorded-dictation-engine';
|
|
124
|
+
export type { DictationTranscribeContext, DictationTranscriber, RecordedDictationEngineOptions, } from './dictation/recorded-dictation-engine';
|
|
125
|
+
export { useAthenaDictationEngine } from './dictation/use-athena-dictation-engine';
|
|
126
|
+
export { composeDictationDraft, DICTATION_STATUSES } from './dictation/dictation-state';
|
|
127
|
+
export type { DictationStatus, DictationTranscript } from './dictation/dictation-state';
|
|
128
|
+
export type { AthenaChatComposerSlots, AthenaChatDictationOptions } from './chat/AthenaChat';
|
|
117
129
|
export { useAppendToComposer } from './composer/useAppendToComposer';
|
|
130
|
+
export type { AppendToComposerOptions } from './composer/useAppendToComposer';
|
|
131
|
+
export { useComposerReady } from './composer/composer-handoff';
|
|
118
132
|
export { useSendMessage } from './composer/useSendMessage';
|
|
119
133
|
export type { SendMessageOptions } from './composer/useSendMessage';
|
|
120
134
|
export { useComposerAttachment } from './composer/useComposerAttachment';
|
package/dist/index.js
CHANGED
|
@@ -38,27 +38,6 @@ import { BrowseToolUI, CreateDocumentToolUI, CreateEmailDraftToolUI, CreateNoteb
|
|
|
38
38
|
import { CopyToolSpecButton, ExpandableSection, ToolCard, normalizeResult, truncate } from "./tools/primitives.js";
|
|
39
39
|
import { InstallPackageToolUI } from "./tools/misc-tool-uis.js";
|
|
40
40
|
import { TOOL_ICONS, toolIcon } from "./tools/tool-icons.js";
|
|
41
|
-
import "./packages/agent-runtime/src/generated/runconfig-contract.js";
|
|
42
|
-
import "react";
|
|
43
|
-
import "@assistant-ui/tap";
|
|
44
|
-
import "statewire";
|
|
45
|
-
import "./packages/agent-runtime/src/statewire-suspended.js";
|
|
46
|
-
import { deriveConversationAttention } from "./packages/agent-runtime/src/conversation-list.js";
|
|
47
|
-
import { describeToolArgs, formatToolName, getToolDisplayMeta, toolActiveLabel, toolCompletedLabel } from "./packages/agent-runtime/src/tool-metadata.js";
|
|
48
|
-
import { classifyToolResult, isToolResultSuccess, resultMessage } from "./packages/agent-runtime/src/tool-result.js";
|
|
49
|
-
import "@tanstack/react-query";
|
|
50
|
-
import { HITL_PENDING_RESUME_GRACE_MS, asHitlApproval, isPendingInterrupt, readInterruptMessage } from "./packages/agent-runtime/src/interrupts.js";
|
|
51
|
-
import "./packages/agent-runtime/src/messages.js";
|
|
52
|
-
import "./packages/agent-runtime/src/statewire-state.js";
|
|
53
|
-
import { hasStatewireThreadExtras } from "./packages/agent-runtime/src/thread-extras.js";
|
|
54
|
-
import "@assistant-ui/store";
|
|
55
|
-
import "./packages/agent-runtime/src/quota-safe-local-storage-session.js";
|
|
56
|
-
import "./packages/agent-runtime/src/statewire-attach-observer.js";
|
|
57
|
-
import "./packages/agent-runtime/src/thread-status.js";
|
|
58
|
-
import "@assistant-ui/react-statewire";
|
|
59
|
-
import { githubWakeEventLabel, githubWakeMarkerText, isGithubWakeMessage, readGithubWakeEvent } from "./packages/agent-runtime/src/github-wake-event.js";
|
|
60
|
-
import "@assistant-ui/core";
|
|
61
|
-
import "./packages/agent-runtime/src/thread-handoff.js";
|
|
62
41
|
import { HiddenWriteTodosToolUI, WriteTodosToolUI, parseTodoPlan } from "./tools/write-todos-tool-ui.js";
|
|
63
42
|
import { useLatestTodoPlan } from "./tools/todo-plan-store.js";
|
|
64
43
|
import { EditFileToolUI, ListFilesToolUI, ReadFileToolUI, SearchFilesToolUI, WriteFileToolUI, friendlyWorkspacePath } from "./tools/file-tool-uis.js";
|
|
@@ -86,7 +65,14 @@ import { THREAD_PREFETCH_HOVER_DELAY_MS, THREAD_PREFETCH_MAX_CONCURRENT } from "
|
|
|
86
65
|
import { conversationDisplayTitle, useRestConversationHistory } from "./threads/use-rest-conversation-history.js";
|
|
87
66
|
import { conversationSummaryFromIndexEntry, useStatewireConversationHistory } from "./threads/use-statewire-conversation-history.js";
|
|
88
67
|
import { useAthenaThreadManager } from "./threads/useAthenaThreadManager.js";
|
|
68
|
+
import { useDictation } from "./dictation/use-dictation.js";
|
|
69
|
+
import { DictationStrip, DictationWaveform } from "./dictation/DictationStrip.js";
|
|
70
|
+
import { DICTATION_ENGINE_ERROR_KINDS, createWebSpeechDictationEngine } from "./dictation/dictation-engine.js";
|
|
71
|
+
import { createRecordedDictationEngine } from "./dictation/recorded-dictation-engine.js";
|
|
72
|
+
import { useAthenaDictationEngine } from "./dictation/use-athena-dictation-engine.js";
|
|
73
|
+
import { DICTATION_STATUSES, composeDictationDraft } from "./dictation/dictation-state.js";
|
|
89
74
|
import { useAppendToComposer } from "./composer/useAppendToComposer.js";
|
|
75
|
+
import { useComposerReady } from "./composer/composer-handoff.js";
|
|
90
76
|
import { useSendMessage } from "./composer/useSendMessage.js";
|
|
91
77
|
import { useComposerAttachment } from "./composer/useComposerAttachment.js";
|
|
92
78
|
import { useFileUpload } from "./composer/useFileUpload.js";
|
|
@@ -101,7 +87,13 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/t
|
|
|
101
87
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./ui/collapsible.js";
|
|
102
88
|
import { Toolkits } from "./toolkits/index.js";
|
|
103
89
|
import { themeToStyleVars, themes } from "./theme/index.js";
|
|
90
|
+
import { HITL_PENDING_RESUME_GRACE_MS, asHitlApproval, isPendingInterrupt, readInterruptMessage } from "./packages/agent-runtime/src/interrupts.js";
|
|
91
|
+
import { classifyToolResult, isToolResultSuccess, resultMessage } from "./packages/agent-runtime/src/tool-result.js";
|
|
104
92
|
import { cn } from "cnfast";
|
|
93
|
+
import { deriveConversationAttention } from "./packages/agent-runtime/src/conversation-list.js";
|
|
94
|
+
import { describeToolArgs, formatToolName, getToolDisplayMeta, toolActiveLabel, toolCompletedLabel } from "./packages/agent-runtime/src/tool-metadata.js";
|
|
95
|
+
import { githubWakeEventLabel, githubWakeMarkerText, isGithubWakeMessage, readGithubWakeEvent } from "./packages/agent-runtime/src/github-wake-event.js";
|
|
96
|
+
import { hasStatewireThreadExtras } from "./packages/agent-runtime/src/thread-extras.js";
|
|
105
97
|
import { useToolAppearance } from "./tools/tool-appearance.js";
|
|
106
98
|
export {
|
|
107
99
|
ATHENA_REACT_SDK_VERSION,
|
|
@@ -142,7 +134,11 @@ export {
|
|
|
142
134
|
DEFAULT_STATEWIRE_MODEL,
|
|
143
135
|
DEFAULT_STATEWIRE_SYNC_URL,
|
|
144
136
|
DEFAULT_TOOLKIT_THEME,
|
|
137
|
+
DICTATION_ENGINE_ERROR_KINDS,
|
|
138
|
+
DICTATION_STATUSES,
|
|
145
139
|
DescribeDatabaseToolUI,
|
|
140
|
+
DictationStrip,
|
|
141
|
+
DictationWaveform,
|
|
146
142
|
EditFileToolUI,
|
|
147
143
|
EmailSearchToolUI,
|
|
148
144
|
ExpandableSection,
|
|
@@ -223,13 +219,16 @@ export {
|
|
|
223
219
|
clearAutoOpenedAssets,
|
|
224
220
|
cn,
|
|
225
221
|
collectStatewireClientTools,
|
|
222
|
+
composeDictationDraft,
|
|
226
223
|
conversationDisplayTitle,
|
|
227
224
|
conversationSummaryFromIndexEntry,
|
|
228
225
|
countActivityTools,
|
|
229
226
|
createAssetToolUI,
|
|
230
227
|
createAthenaSpacesUrl,
|
|
228
|
+
createRecordedDictationEngine,
|
|
231
229
|
createThread,
|
|
232
230
|
createToolBasedGroupingFunction,
|
|
231
|
+
createWebSpeechDictationEngine,
|
|
233
232
|
defaultGetToolGroupKey,
|
|
234
233
|
deriveAthenaApiUrl,
|
|
235
234
|
deriveAthenaAppUrl,
|
|
@@ -304,6 +303,7 @@ export {
|
|
|
304
303
|
useAthenaCitationLinkHandler,
|
|
305
304
|
useAthenaConfig,
|
|
306
305
|
useAthenaDiagnostics,
|
|
306
|
+
useAthenaDictationEngine,
|
|
307
307
|
useAthenaLinkClickHandler,
|
|
308
308
|
useAthenaRepoSearch,
|
|
309
309
|
useAthenaRunLive,
|
|
@@ -315,6 +315,8 @@ export {
|
|
|
315
315
|
useAthenaThreadId,
|
|
316
316
|
useAthenaThreadManager,
|
|
317
317
|
useComposerAttachment,
|
|
318
|
+
useComposerReady,
|
|
319
|
+
useDictation,
|
|
318
320
|
useFileUpload,
|
|
319
321
|
useLatestTodoPlan,
|
|
320
322
|
useNestedPtcComponents,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|