blazen 0.5.4 → 0.6.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/index.js CHANGED
@@ -586,6 +586,8 @@ module.exports.ApiProtocol = nativeBinding.ApiProtocol
586
586
  module.exports.JsApiProtocol = nativeBinding.JsApiProtocol
587
587
  module.exports.AssignmentContext = nativeBinding.AssignmentContext
588
588
  module.exports.JsAssignmentContext = nativeBinding.JsAssignmentContext
589
+ module.exports.AudioGenBackend = nativeBinding.AudioGenBackend
590
+ module.exports.JsAudioGenBackend = nativeBinding.JsAudioGenBackend
589
591
  module.exports.AudioMusicProviderDefaults = nativeBinding.AudioMusicProviderDefaults
590
592
  module.exports.JsAudioMusicProviderDefaults = nativeBinding.JsAudioMusicProviderDefaults
591
593
  module.exports.AudioSpeechProviderDefaults = nativeBinding.AudioSpeechProviderDefaults
@@ -596,8 +598,6 @@ module.exports.BackgroundRemovalProvider = nativeBinding.BackgroundRemovalProvid
596
598
  module.exports.JsBackgroundRemovalProvider = nativeBinding.JsBackgroundRemovalProvider
597
599
  module.exports.BackgroundRemovalProviderDefaults = nativeBinding.BackgroundRemovalProviderDefaults
598
600
  module.exports.JsBackgroundRemovalProviderDefaults = nativeBinding.JsBackgroundRemovalProviderDefaults
599
- module.exports.BaseProvider = nativeBinding.BaseProvider
600
- module.exports.JsBaseProvider = nativeBinding.JsBaseProvider
601
601
  module.exports.BaseProviderDefaults = nativeBinding.BaseProviderDefaults
602
602
  module.exports.JsBaseProviderDefaults = nativeBinding.JsBaseProviderDefaults
603
603
  module.exports.BatchConfig = nativeBinding.BatchConfig
@@ -612,8 +612,8 @@ module.exports.BlazenPeerServer = nativeBinding.BlazenPeerServer
612
612
  module.exports.JsBlazenPeerServer = nativeBinding.JsBlazenPeerServer
613
613
  module.exports.BytesWrapper = nativeBinding.BytesWrapper
614
614
  module.exports.JsBytesWrapper = nativeBinding.JsBytesWrapper
615
- module.exports.CachedCompletionModel = nativeBinding.CachedCompletionModel
616
- module.exports.JsCachedCompletionModel = nativeBinding.JsCachedCompletionModel
615
+ module.exports.CachedModel = nativeBinding.CachedModel
616
+ module.exports.JsCachedModel = nativeBinding.JsCachedModel
617
617
  module.exports.CacheMiddleware = nativeBinding.CacheMiddleware
618
618
  module.exports.JsCacheMiddleware = nativeBinding.JsCacheMiddleware
619
619
  module.exports.CandleEmbedProvider = nativeBinding.CandleEmbedProvider
@@ -632,12 +632,10 @@ module.exports.CheckpointStore = nativeBinding.CheckpointStore
632
632
  module.exports.JsCheckpointStore = nativeBinding.JsCheckpointStore
633
633
  module.exports.Citation = nativeBinding.Citation
634
634
  module.exports.JsCitationClass = nativeBinding.JsCitationClass
635
+ module.exports.CodecBackendHandle = nativeBinding.CodecBackendHandle
636
+ module.exports.JsCodecBackendHandle = nativeBinding.JsCodecBackendHandle
635
637
  module.exports.CohereProvider = nativeBinding.CohereProvider
636
638
  module.exports.JsCohereProvider = nativeBinding.JsCohereProvider
637
- module.exports.CompletionModel = nativeBinding.CompletionModel
638
- module.exports.JsCompletionModel = nativeBinding.JsCompletionModel
639
- module.exports.CompletionProviderDefaults = nativeBinding.CompletionProviderDefaults
640
- module.exports.JsCompletionProviderDefaults = nativeBinding.JsCompletionProviderDefaults
641
639
  module.exports.ContentStore = nativeBinding.ContentStore
642
640
  module.exports.JsContentStore = nativeBinding.JsContentStore
643
641
  module.exports.Context = nativeBinding.Context
@@ -658,6 +656,8 @@ module.exports.DynamicEvent = nativeBinding.DynamicEvent
658
656
  module.exports.JsDynamicEvent = nativeBinding.JsDynamicEvent
659
657
  module.exports.EmbeddingModel = nativeBinding.EmbeddingModel
660
658
  module.exports.JsEmbeddingModel = nativeBinding.JsEmbeddingModel
659
+ module.exports.EmbeddingProvider = nativeBinding.EmbeddingProvider
660
+ module.exports.JsEmbeddingProvider = nativeBinding.JsEmbeddingProvider
661
661
  module.exports.EmbeddingProviderDefaults = nativeBinding.EmbeddingProviderDefaults
662
662
  module.exports.JsEmbeddingProviderDefaults = nativeBinding.JsEmbeddingProviderDefaults
663
663
  module.exports.EmbedProvider = nativeBinding.EmbedProvider
@@ -672,6 +672,8 @@ module.exports.FalProvider = nativeBinding.FalProvider
672
672
  module.exports.JsFalProvider = nativeBinding.JsFalProvider
673
673
  module.exports.FastEmbedModel = nativeBinding.FastEmbedModel
674
674
  module.exports.JsFastEmbedModel = nativeBinding.JsFastEmbedModel
675
+ module.exports.FasterWhisperBackend = nativeBinding.FasterWhisperBackend
676
+ module.exports.JsFasterWhisperBackend = nativeBinding.JsFasterWhisperBackend
675
677
  module.exports.FireworksProvider = nativeBinding.FireworksProvider
676
678
  module.exports.JsFireworksProvider = nativeBinding.JsFireworksProvider
677
679
  module.exports.GeminiProvider = nativeBinding.GeminiProvider
@@ -686,6 +688,8 @@ module.exports.HttpPeerClient = nativeBinding.HttpPeerClient
686
688
  module.exports.JsHttpPeerClient = nativeBinding.JsHttpPeerClient
687
689
  module.exports.ImageGenerationProviderDefaults = nativeBinding.ImageGenerationProviderDefaults
688
690
  module.exports.JsImageGenerationProviderDefaults = nativeBinding.JsImageGenerationProviderDefaults
691
+ module.exports.ImageGenProvider = nativeBinding.ImageGenProvider
692
+ module.exports.JsImageGenProvider = nativeBinding.JsImageGenProvider
689
693
  module.exports.ImageModel = nativeBinding.ImageModel
690
694
  module.exports.JsImageModel = nativeBinding.JsImageModel
691
695
  module.exports.ImageProvider = nativeBinding.ImageProvider
@@ -712,6 +716,8 @@ module.exports.JobHandle = nativeBinding.JobHandle
712
716
  module.exports.JsJobHandleClass = nativeBinding.JsJobHandleClass
713
717
  module.exports.JsonlBackend = nativeBinding.JsonlBackend
714
718
  module.exports.JsJsonlBackend = nativeBinding.JsJsonlBackend
719
+ module.exports.JsonlDataset = nativeBinding.JsonlDataset
720
+ module.exports.JsJsonlDataset = nativeBinding.JsJsonlDataset
715
721
  module.exports.LangfuseConfig = nativeBinding.LangfuseConfig
716
722
  module.exports.JsLangfuseConfig = nativeBinding.JsLangfuseConfig
717
723
  module.exports.LlamaCppChatMessageInput = nativeBinding.LlamaCppChatMessageInput
@@ -726,8 +732,14 @@ module.exports.LlamaCppInferenceUsage = nativeBinding.LlamaCppInferenceUsage
726
732
  module.exports.JsLlamaCppInferenceUsage = nativeBinding.JsLlamaCppInferenceUsage
727
733
  module.exports.LlamaCppProvider = nativeBinding.LlamaCppProvider
728
734
  module.exports.JsLlamaCppProvider = nativeBinding.JsLlamaCppProvider
735
+ module.exports.LLMProvider = nativeBinding.LLMProvider
736
+ module.exports.JsLLMProvider = nativeBinding.JsLLMProvider
737
+ module.exports.LlmProviderDefaults = nativeBinding.LlmProviderDefaults
738
+ module.exports.JsBaseProvider = nativeBinding.JsBaseProvider
729
739
  module.exports.LocalModel = nativeBinding.LocalModel
730
740
  module.exports.JsLocalModel = nativeBinding.JsLocalModel
741
+ module.exports.LoopStage = nativeBinding.LoopStage
742
+ module.exports.JsLoopStage = nativeBinding.JsLoopStage
731
743
  module.exports.Memory = nativeBinding.Memory
732
744
  module.exports.JsMemory = nativeBinding.JsMemory
733
745
  module.exports.MemoryBackend = nativeBinding.MemoryBackend
@@ -742,12 +754,22 @@ module.exports.MistralProvider = nativeBinding.MistralProvider
742
754
  module.exports.JsMistralProvider = nativeBinding.JsMistralProvider
743
755
  module.exports.MistralRsProvider = nativeBinding.MistralRsProvider
744
756
  module.exports.JsMistralRsProvider = nativeBinding.JsMistralRsProvider
757
+ module.exports.Model = nativeBinding.Model
758
+ module.exports.JsModel = nativeBinding.JsModel
745
759
  module.exports.ModelCache = nativeBinding.ModelCache
746
760
  module.exports.JsModelCache = nativeBinding.JsModelCache
761
+ module.exports.ModelClient = nativeBinding.ModelClient
762
+ module.exports.JsModelClient = nativeBinding.JsModelClient
747
763
  module.exports.ModelManager = nativeBinding.ModelManager
748
764
  module.exports.JsModelManager = nativeBinding.JsModelManager
749
765
  module.exports.ModelRegistry = nativeBinding.ModelRegistry
750
766
  module.exports.JsModelRegistry = nativeBinding.JsModelRegistry
767
+ module.exports.MusicBackendHandle = nativeBinding.MusicBackendHandle
768
+ module.exports.JsMusicBackendHandle = nativeBinding.JsMusicBackendHandle
769
+ module.exports.MusicgenBackend = nativeBinding.MusicgenBackend
770
+ module.exports.JsMusicgenBackend = nativeBinding.JsMusicgenBackend
771
+ module.exports.MusicModel = nativeBinding.MusicModel
772
+ module.exports.JsMusicModel = nativeBinding.JsMusicModel
751
773
  module.exports.MusicProvider = nativeBinding.MusicProvider
752
774
  module.exports.JsMusicProvider = nativeBinding.JsMusicProvider
753
775
  module.exports.NoopUsageEmitter = nativeBinding.NoopUsageEmitter
@@ -782,8 +804,8 @@ module.exports.PipelineResult = nativeBinding.PipelineResult
782
804
  module.exports.JsPipelineResult = nativeBinding.JsPipelineResult
783
805
  module.exports.PipelineSnapshot = nativeBinding.PipelineSnapshot
784
806
  module.exports.JsPipelineSnapshot = nativeBinding.JsPipelineSnapshot
785
- module.exports.PiperProvider = nativeBinding.PiperProvider
786
- module.exports.JsPiperProvider = nativeBinding.JsPiperProvider
807
+ module.exports.PreferenceJsonlDataset = nativeBinding.PreferenceJsonlDataset
808
+ module.exports.JsPreferenceJsonlDataset = nativeBinding.JsPreferenceJsonlDataset
787
809
  module.exports.ProgressCallback = nativeBinding.ProgressCallback
788
810
  module.exports.JsProgressCallback = nativeBinding.JsProgressCallback
789
811
  module.exports.PromptFile = nativeBinding.PromptFile
@@ -792,6 +814,10 @@ module.exports.PromptRegistry = nativeBinding.PromptRegistry
792
814
  module.exports.JsPromptRegistry = nativeBinding.JsPromptRegistry
793
815
  module.exports.PromptTemplate = nativeBinding.PromptTemplate
794
816
  module.exports.JsPromptTemplate = nativeBinding.JsPromptTemplate
817
+ module.exports.ProviderDefaults = nativeBinding.ProviderDefaults
818
+ module.exports.JsProviderDefaults = nativeBinding.JsProviderDefaults
819
+ module.exports.RatedJsonlDataset = nativeBinding.RatedJsonlDataset
820
+ module.exports.JsRatedJsonlDataset = nativeBinding.JsRatedJsonlDataset
795
821
  module.exports.ReasoningTrace = nativeBinding.ReasoningTrace
796
822
  module.exports.JsReasoningTraceClass = nativeBinding.JsReasoningTraceClass
797
823
  module.exports.RedbCheckpointStore = nativeBinding.RedbCheckpointStore
@@ -800,16 +826,22 @@ module.exports.RegistryKey = nativeBinding.RegistryKey
800
826
  module.exports.JsRegistryKey = nativeBinding.JsRegistryKey
801
827
  module.exports.RequestTiming = nativeBinding.RequestTiming
802
828
  module.exports.JsRequestTimingClass = nativeBinding.JsRequestTimingClass
803
- module.exports.RetryCompletionModel = nativeBinding.RetryCompletionModel
804
- module.exports.JsRetryCompletionModel = nativeBinding.JsRetryCompletionModel
805
829
  module.exports.RetryMemoryBackend = nativeBinding.RetryMemoryBackend
806
830
  module.exports.JsRetryMemoryBackend = nativeBinding.JsRetryMemoryBackend
807
831
  module.exports.RetryMiddleware = nativeBinding.RetryMiddleware
808
832
  module.exports.JsRetryMiddleware = nativeBinding.JsRetryMiddleware
833
+ module.exports.RetryModel = nativeBinding.RetryModel
834
+ module.exports.JsRetryModel = nativeBinding.JsRetryModel
835
+ module.exports.RvcBackend = nativeBinding.RvcBackend
836
+ module.exports.JsRvcBackend = nativeBinding.JsRvcBackend
809
837
  module.exports.SessionNamespace = nativeBinding.SessionNamespace
810
838
  module.exports.JsSessionNamespace = nativeBinding.JsSessionNamespace
811
839
  module.exports.SessionRefRegistry = nativeBinding.SessionRefRegistry
812
840
  module.exports.JsSessionRefRegistry = nativeBinding.JsSessionRefRegistry
841
+ module.exports.SparkTtsBackend = nativeBinding.SparkTtsBackend
842
+ module.exports.JsSparkTtsBackend = nativeBinding.JsSparkTtsBackend
843
+ module.exports.StableAudioBackend = nativeBinding.StableAudioBackend
844
+ module.exports.JsStableAudioBackend = nativeBinding.JsStableAudioBackend
813
845
  module.exports.Stage = nativeBinding.Stage
814
846
  module.exports.JsStage = nativeBinding.JsStage
815
847
  module.exports.StageResult = nativeBinding.StageResult
@@ -830,6 +862,12 @@ module.exports.StopEvent = nativeBinding.StopEvent
830
862
  module.exports.JsStopEventClass = nativeBinding.JsStopEventClass
831
863
  module.exports.StructuredOutput = nativeBinding.StructuredOutput
832
864
  module.exports.JsStructuredOutput = nativeBinding.JsStructuredOutput
865
+ module.exports.SttBackendHandle = nativeBinding.SttBackendHandle
866
+ module.exports.JsSttBackendHandle = nativeBinding.JsSttBackendHandle
867
+ module.exports.SubExecutable = nativeBinding.SubExecutable
868
+ module.exports.JsSubExecutable = nativeBinding.JsSubExecutable
869
+ module.exports.SubPipelineStep = nativeBinding.SubPipelineStep
870
+ module.exports.JsSubPipelineStep = nativeBinding.JsSubPipelineStep
833
871
  module.exports.SubWorkflowStep = nativeBinding.SubWorkflowStep
834
872
  module.exports.JsSubWorkflowStep = nativeBinding.JsSubWorkflowStep
835
873
  module.exports.ThreeDProvider = nativeBinding.ThreeDProvider
@@ -856,6 +894,10 @@ module.exports.Transcription = nativeBinding.Transcription
856
894
  module.exports.JsTranscription = nativeBinding.JsTranscription
857
895
  module.exports.TranscriptionProviderDefaults = nativeBinding.TranscriptionProviderDefaults
858
896
  module.exports.JsTranscriptionProviderDefaults = nativeBinding.JsTranscriptionProviderDefaults
897
+ module.exports.TtsBackendHandle = nativeBinding.TtsBackendHandle
898
+ module.exports.JsTtsBackendHandle = nativeBinding.JsTtsBackendHandle
899
+ module.exports.TtsProvider = nativeBinding.TtsProvider
900
+ module.exports.JsTtsProvider = nativeBinding.JsTtsProvider
859
901
  module.exports.TTSProvider = nativeBinding.TTSProvider
860
902
  module.exports.JsTTSProvider = nativeBinding.JsTTSProvider
861
903
  module.exports.TypedTool = nativeBinding.TypedTool
@@ -864,14 +906,18 @@ module.exports.UpstashBackend = nativeBinding.UpstashBackend
864
906
  module.exports.JsUpstashBackend = nativeBinding.JsUpstashBackend
865
907
  module.exports.UsageEmitter = nativeBinding.UsageEmitter
866
908
  module.exports.JsUsageEmitter = nativeBinding.JsUsageEmitter
867
- module.exports.UsageRecordingCompletionModel = nativeBinding.UsageRecordingCompletionModel
868
- module.exports.JsUsageRecordingCompletionModel = nativeBinding.JsUsageRecordingCompletionModel
869
909
  module.exports.UsageRecordingEmbeddingModel = nativeBinding.UsageRecordingEmbeddingModel
870
910
  module.exports.JsUsageRecordingEmbeddingModel = nativeBinding.JsUsageRecordingEmbeddingModel
911
+ module.exports.UsageRecordingModel = nativeBinding.UsageRecordingModel
912
+ module.exports.JsUsageRecordingModel = nativeBinding.JsUsageRecordingModel
871
913
  module.exports.ValkeyBackend = nativeBinding.ValkeyBackend
872
914
  module.exports.JsValkeyBackend = nativeBinding.JsValkeyBackend
873
915
  module.exports.ValkeyCheckpointStore = nativeBinding.ValkeyCheckpointStore
874
916
  module.exports.JsValkeyCheckpointStore = nativeBinding.JsValkeyCheckpointStore
917
+ module.exports.VcModel = nativeBinding.VcModel
918
+ module.exports.JsVcModel = nativeBinding.JsVcModel
919
+ module.exports.VcProvider = nativeBinding.VcProvider
920
+ module.exports.JsVcProvider = nativeBinding.JsVcProvider
875
921
  module.exports.VideoProvider = nativeBinding.VideoProvider
876
922
  module.exports.JsVideoProvider = nativeBinding.JsVideoProvider
877
923
  module.exports.VideoProviderDefaults = nativeBinding.VideoProviderDefaults
@@ -899,6 +945,8 @@ module.exports.JsXaiProvider = nativeBinding.JsXaiProvider
899
945
  module.exports.addUsageToTokenUsage = nativeBinding.addUsageToTokenUsage
900
946
  module.exports.audioInput = nativeBinding.audioInput
901
947
  module.exports.cadInput = nativeBinding.cadInput
948
+ module.exports.CapabilityKind = nativeBinding.CapabilityKind
949
+ module.exports.JsCapabilityKind = nativeBinding.JsCapabilityKind
902
950
  module.exports.ChatRole = nativeBinding.ChatRole
903
951
  module.exports.JsChatRole = nativeBinding.JsChatRole
904
952
  module.exports.completeBatch = nativeBinding.completeBatch
@@ -935,13 +983,19 @@ module.exports.JoinStrategy = nativeBinding.JoinStrategy
935
983
  module.exports.JsJoinStrategy = nativeBinding.JsJoinStrategy
936
984
  module.exports.JsAdmissionModeTag = nativeBinding.JsAdmissionModeTag
937
985
  module.exports.JsAuthMethod = nativeBinding.JsAuthMethod
986
+ module.exports.JsBackendHint = nativeBinding.JsBackendHint
938
987
  module.exports.JsCacheStrategy = nativeBinding.JsCacheStrategy
939
988
  module.exports.JsContentKind = nativeBinding.JsContentKind
940
989
  module.exports.JsDiffusionScheduler = nativeBinding.JsDiffusionScheduler
941
990
  module.exports.JsFalLlmEndpointKind = nativeBinding.JsFalLlmEndpointKind
942
991
  module.exports.JsJobStatus = nativeBinding.JsJobStatus
992
+ module.exports.JsMixedPrecision = nativeBinding.JsMixedPrecision
993
+ module.exports.JsMusicgenVariant = nativeBinding.JsMusicgenVariant
943
994
  module.exports.JsRole = nativeBinding.JsRole
944
995
  module.exports.JsRunStatus = nativeBinding.JsRunStatus
996
+ module.exports.JsSchedulerKind = nativeBinding.JsSchedulerKind
997
+ module.exports.JsStableAudioVariant = nativeBinding.JsStableAudioVariant
998
+ module.exports.JsTtsModel = nativeBinding.JsTtsModel
945
999
  module.exports.JsWhisperModel = nativeBinding.JsWhisperModel
946
1000
  module.exports.LlamaCppChatRole = nativeBinding.LlamaCppChatRole
947
1001
  module.exports.JsLlamaCppChatRole = nativeBinding.JsLlamaCppChatRole
@@ -949,10 +1003,14 @@ module.exports.loadClientTls = nativeBinding.loadClientTls
949
1003
  module.exports.loadServerTls = nativeBinding.loadServerTls
950
1004
  module.exports.lookupPricing = nativeBinding.lookupPricing
951
1005
  module.exports.lookupStepBuilder = nativeBinding.lookupStepBuilder
1006
+ module.exports.LoopDecision = nativeBinding.LoopDecision
1007
+ module.exports.JsLoopDecision = nativeBinding.JsLoopDecision
952
1008
  module.exports.Modality = nativeBinding.Modality
953
1009
  module.exports.JsModality = nativeBinding.JsModality
954
1010
  module.exports.newRetryStack = nativeBinding.newRetryStack
955
1011
  module.exports.newUsageEvent = nativeBinding.newUsageEvent
1012
+ module.exports.OtlpProtocol = nativeBinding.OtlpProtocol
1013
+ module.exports.JsOtlpProtocol = nativeBinding.JsOtlpProtocol
956
1014
  module.exports.PauseReason = nativeBinding.PauseReason
957
1015
  module.exports.JsPauseReason = nativeBinding.JsPauseReason
958
1016
  module.exports.peerEnvelopeVersion = nativeBinding.peerEnvelopeVersion
@@ -970,6 +1028,7 @@ module.exports.refreshPricing = nativeBinding.refreshPricing
970
1028
  module.exports.registeredStepIds = nativeBinding.registeredStepIds
971
1029
  module.exports.registerEventDeserializer = nativeBinding.registerEventDeserializer
972
1030
  module.exports.registerFromModelInfo = nativeBinding.registerFromModelInfo
1031
+ module.exports.registerNativeSerializer = nativeBinding.registerNativeSerializer
973
1032
  module.exports.registerPricing = nativeBinding.registerPricing
974
1033
  module.exports.registerStepBuilder = nativeBinding.registerStepBuilder
975
1034
  module.exports.resolveApiKey = nativeBinding.resolveApiKey
@@ -994,166 +1053,102 @@ module.exports.unlimitedHttpClientConfig = nativeBinding.unlimitedHttpClientConf
994
1053
  module.exports.version = nativeBinding.version
995
1054
  module.exports.videoInput = nativeBinding.videoInput
996
1055
 
997
- // --- post-build: typed-error wrapping ---
998
- ;(() => {
999
- const errorClasses = require('./error-classes.js')
1000
- const { enrichError } = errorClasses
1001
-
1002
- // Wrap a single function so any thrown error -- sync or async -- is
1003
- // passed through enrichError before reaching the caller.
1004
- const wrap = (fn) => {
1005
- return function blazenWrapped(...args) {
1006
- try {
1007
- const result = fn.apply(this, args)
1008
- if (result && typeof result.then === 'function') {
1009
- return result.then(
1010
- (v) => v,
1011
- (e) => {
1012
- throw enrichError(e)
1013
- },
1014
- )
1015
- }
1016
- return result
1017
- } catch (e) {
1018
- throw enrichError(e)
1019
- }
1020
- }
1021
- }
1022
-
1023
- // Patch a class's prototype methods in-place. Skips the constructor
1024
- // and any non-function or non-configurable property.
1025
- const patchPrototype = (Cls) => {
1026
- if (typeof Cls !== 'function') return
1027
- const proto = Cls.prototype
1028
- if (!proto || typeof proto !== 'object') return
1029
- for (const key of Object.getOwnPropertyNames(proto)) {
1030
- if (key === 'constructor') continue
1031
- const desc = Object.getOwnPropertyDescriptor(proto, key)
1032
- if (!desc || !desc.configurable) continue
1033
- if (typeof desc.value !== 'function') continue
1034
- try {
1035
- Object.defineProperty(proto, key, {
1036
- ...desc,
1037
- value: wrap(desc.value),
1038
- })
1039
- } catch {
1040
- // Some napi prototypes are frozen; skip gracefully.
1041
- }
1042
- }
1043
- }
1044
-
1045
- // Specialised handling for the agent entrypoints. The user's
1046
- // `toolHandler` argument must be wrapped to envelope-format thrown
1047
- // errors (see `wrapToolHandlerForCallerErrors` in error-classes.js);
1048
- // `enrichError` then re-throws the original instance after the agent
1049
- // loop rejects with the `__BLAZEN_CALLER_ERROR__` sentinel. The
1050
- // generic `wrap()` loop below is skipped for these via the
1051
- // `__blazenCallerErrorWrapped` marker.
1052
- const { wrapToolHandlerForCallerErrors, callerErrorStash } = errorClasses
1053
- const AGENT_ENTRYPOINTS = ['runAgent', 'runAgentWithCallback']
1054
- for (const fnName of AGENT_ENTRYPOINTS) {
1055
- const orig = module.exports[fnName]
1056
- if (typeof orig !== 'function') continue
1057
- // toolHandler is positional arg index 3 for both runAgent and
1058
- // runAgentWithCallback in the current TS signatures.
1059
- const TOOL_HANDLER_ARG_INDEX = 3
1060
- const wrapped = function blazenAgentEntrypoint(...args) {
1061
- if (args.length > TOOL_HANDLER_ARG_INDEX) {
1062
- const userHandler = args[TOOL_HANDLER_ARG_INDEX]
1063
- if (typeof userHandler === 'function') {
1064
- args[TOOL_HANDLER_ARG_INDEX] = wrapToolHandlerForCallerErrors(userHandler)
1065
- }
1066
- }
1067
- // Track stash entries created during this run so we can
1068
- // garbage-collect any that the agent loop swallowed (e.g.
1069
- // succeeded after a handler threw, or the loop ended before the
1070
- // napi side surfaced the caller error).
1071
- const stashSnapshot = new Set(callerErrorStash.keys())
1072
- const cleanupNewStash = () => {
1073
- for (const key of callerErrorStash.keys()) {
1074
- if (!stashSnapshot.has(key)) {
1075
- callerErrorStash.delete(key)
1076
- }
1077
- }
1078
- }
1079
- try {
1080
- const result = orig.apply(this, args)
1081
- if (result && typeof result.then === 'function') {
1082
- return result.then(
1083
- (v) => {
1084
- cleanupNewStash()
1085
- return v
1086
- },
1087
- (e) => {
1088
- const enriched = enrichError(e)
1089
- cleanupNewStash()
1090
- throw enriched
1091
- },
1092
- )
1093
- }
1094
- cleanupNewStash()
1095
- return result
1096
- } catch (e) {
1097
- const enriched = enrichError(e)
1098
- cleanupNewStash()
1099
- throw enriched
1100
- }
1101
- }
1102
- wrapped.__blazenCallerErrorWrapped = true
1103
- module.exports[fnName] = wrapped
1104
- }
1105
-
1106
- // Wrap every top-level export. Distinguish functions (call wrap) from
1107
- // constructors (call patchPrototype). Heuristic: a constructor has a
1108
- // `prototype` object with own properties beyond `constructor`. When
1109
- // in doubt we patch the prototype AND wrap the function -- wrapping a
1110
- // constructor call in try/catch is safe (`new wrappedCtor()` still
1111
- // works because `fn.apply(this, args)` on a constructor called with
1112
- // `new` would normally fail, but napi-rs class constructors are
1113
- // exposed as plain factories that do not require `new`).
1114
- for (const key of Object.keys(module.exports)) {
1115
- const orig = module.exports[key]
1116
- if (typeof orig !== 'function') continue
1117
- // Skip the typed-error classes we are about to install.
1118
- if (Object.prototype.hasOwnProperty.call(errorClasses, key)) continue
1119
- // Skip the agent entrypoints we already specialised above.
1120
- if (orig.__blazenCallerErrorWrapped) continue
1121
- if (orig.prototype && typeof orig.prototype === 'object') {
1122
- patchPrototype(orig)
1123
- }
1124
- // Only wrap "plain" functions (lowercase first letter convention) and
1125
- // any function whose prototype is empty (i.e. not a class). napi-rs
1126
- // emits classes with PascalCase names; we leave those callable as-is
1127
- // so `new ClassName(...)` keeps working but their methods are
1128
- // already patched above.
1129
- //
1130
- // Detect "class-ness" via either prototype methods OR own static
1131
- // properties beyond the built-in function metadata fields. Without the
1132
- // static-property check, a class whose only public surface is a static
1133
- // factory (e.g. `UpstashBackend.create`) would slip through and get
1134
- // replaced with a `wrap()`-returned function that loses the static
1135
- // method.
1136
- const FUNCTION_BUILTIN_PROPS = new Set([
1137
- 'length',
1138
- 'name',
1139
- 'arguments',
1140
- 'caller',
1141
- 'prototype',
1142
- ])
1143
- const ownStaticPropNames = Object.getOwnPropertyNames(orig).filter(
1144
- (p) => !FUNCTION_BUILTIN_PROPS.has(p),
1145
- )
1146
- const hasPrototypeMethods =
1147
- orig.prototype &&
1148
- Object.getOwnPropertyNames(orig.prototype).some((p) => p !== 'constructor')
1149
- const isLikelyClass = hasPrototypeMethods || ownStaticPropNames.length > 0
1150
- if (!isLikelyClass) {
1151
- module.exports[key] = wrap(orig)
1152
- }
1153
- }
1154
-
1155
- // Re-export the typed error classes + enrichError.
1156
- for (const [name, value] of Object.entries(errorClasses)) {
1157
- module.exports[name] = value
1158
- }
1159
- })()
1056
+ // --- post-build: cjs-module-lexer hints for native error classes ---
1057
+ module.exports.BlazenError = module.exports.BlazenError
1058
+ module.exports.AuthError = module.exports.AuthError
1059
+ module.exports.RateLimitError = module.exports.RateLimitError
1060
+ module.exports.TimeoutError = module.exports.TimeoutError
1061
+ module.exports.ValidationError = module.exports.ValidationError
1062
+ module.exports.ContentPolicyError = module.exports.ContentPolicyError
1063
+ module.exports.UnsupportedError = module.exports.UnsupportedError
1064
+ module.exports.ComputeError = module.exports.ComputeError
1065
+ module.exports.MediaError = module.exports.MediaError
1066
+ module.exports.ProviderError = module.exports.ProviderError
1067
+ module.exports.LlamaCppError = module.exports.LlamaCppError
1068
+ module.exports.LlamaCppInvalidOptionsError = module.exports.LlamaCppInvalidOptionsError
1069
+ module.exports.LlamaCppModelLoadError = module.exports.LlamaCppModelLoadError
1070
+ module.exports.LlamaCppInferenceError = module.exports.LlamaCppInferenceError
1071
+ module.exports.LlamaCppEngineNotAvailableError = module.exports.LlamaCppEngineNotAvailableError
1072
+ module.exports.LlamaCppAdapterFailedError = module.exports.LlamaCppAdapterFailedError
1073
+ module.exports.CandleLlmError = module.exports.CandleLlmError
1074
+ module.exports.CandleLlmInvalidOptionsError = module.exports.CandleLlmInvalidOptionsError
1075
+ module.exports.CandleLlmModelLoadError = module.exports.CandleLlmModelLoadError
1076
+ module.exports.CandleLlmInferenceError = module.exports.CandleLlmInferenceError
1077
+ module.exports.CandleLlmEngineNotAvailableError = module.exports.CandleLlmEngineNotAvailableError
1078
+ module.exports.CandleLlmUnsupportedError = module.exports.CandleLlmUnsupportedError
1079
+ module.exports.CandleEmbedError = module.exports.CandleEmbedError
1080
+ module.exports.CandleEmbedInvalidOptionsError = module.exports.CandleEmbedInvalidOptionsError
1081
+ module.exports.CandleEmbedModelLoadError = module.exports.CandleEmbedModelLoadError
1082
+ module.exports.CandleEmbedEmbeddingError = module.exports.CandleEmbedEmbeddingError
1083
+ module.exports.CandleEmbedEngineNotAvailableError = module.exports.CandleEmbedEngineNotAvailableError
1084
+ module.exports.CandleEmbedTaskPanickedError = module.exports.CandleEmbedTaskPanickedError
1085
+ module.exports.MistralRsError = module.exports.MistralRsError
1086
+ module.exports.MistralRsInvalidOptionsError = module.exports.MistralRsInvalidOptionsError
1087
+ module.exports.MistralRsInitError = module.exports.MistralRsInitError
1088
+ module.exports.MistralRsInferenceError = module.exports.MistralRsInferenceError
1089
+ module.exports.MistralRsEngineNotAvailableError = module.exports.MistralRsEngineNotAvailableError
1090
+ module.exports.MistralRsAdapterFailedError = module.exports.MistralRsAdapterFailedError
1091
+ module.exports.WhisperError = module.exports.WhisperError
1092
+ module.exports.WhisperInvalidOptionsError = module.exports.WhisperInvalidOptionsError
1093
+ module.exports.WhisperModelLoadError = module.exports.WhisperModelLoadError
1094
+ module.exports.WhisperTranscriptionError = module.exports.WhisperTranscriptionError
1095
+ module.exports.WhisperEngineNotAvailableError = module.exports.WhisperEngineNotAvailableError
1096
+ module.exports.WhisperIoError = module.exports.WhisperIoError
1097
+ module.exports.PiperError = module.exports.PiperError
1098
+ module.exports.PiperInvalidOptionsError = module.exports.PiperInvalidOptionsError
1099
+ module.exports.PiperModelLoadError = module.exports.PiperModelLoadError
1100
+ module.exports.PiperSynthesisError = module.exports.PiperSynthesisError
1101
+ module.exports.PiperEngineNotAvailableError = module.exports.PiperEngineNotAvailableError
1102
+ module.exports.DiffusionError = module.exports.DiffusionError
1103
+ module.exports.DiffusionInvalidOptionsError = module.exports.DiffusionInvalidOptionsError
1104
+ module.exports.DiffusionModelLoadError = module.exports.DiffusionModelLoadError
1105
+ module.exports.DiffusionGenerationError = module.exports.DiffusionGenerationError
1106
+ module.exports.DiffusionEngineNotAvailableError = module.exports.DiffusionEngineNotAvailableError
1107
+ module.exports.FastEmbedError = module.exports.FastEmbedError
1108
+ module.exports.EmbedUnknownModelError = module.exports.EmbedUnknownModelError
1109
+ module.exports.EmbedInitError = module.exports.EmbedInitError
1110
+ module.exports.EmbedEmbedError = module.exports.EmbedEmbedError
1111
+ module.exports.EmbedMutexPoisonedError = module.exports.EmbedMutexPoisonedError
1112
+ module.exports.EmbedTaskPanickedError = module.exports.EmbedTaskPanickedError
1113
+ module.exports.TractError = module.exports.TractError
1114
+ module.exports.PeerEncodeError = module.exports.PeerEncodeError
1115
+ module.exports.PeerTransportError = module.exports.PeerTransportError
1116
+ module.exports.PeerEnvelopeVersionError = module.exports.PeerEnvelopeVersionError
1117
+ module.exports.PeerWorkflowError = module.exports.PeerWorkflowError
1118
+ module.exports.PeerTlsError = module.exports.PeerTlsError
1119
+ module.exports.PeerUnknownStepError = module.exports.PeerUnknownStepError
1120
+ module.exports.PersistError = module.exports.PersistError
1121
+ module.exports.CacheError = module.exports.CacheError
1122
+ module.exports.DownloadError = module.exports.DownloadError
1123
+ module.exports.CacheDirError = module.exports.CacheDirError
1124
+ module.exports.IoError = module.exports.IoError
1125
+ module.exports.PromptError = module.exports.PromptError
1126
+ module.exports.PromptMissingVariableError = module.exports.PromptMissingVariableError
1127
+ module.exports.PromptNotFoundError = module.exports.PromptNotFoundError
1128
+ module.exports.PromptVersionNotFoundError = module.exports.PromptVersionNotFoundError
1129
+ module.exports.PromptIoError = module.exports.PromptIoError
1130
+ module.exports.PromptYamlError = module.exports.PromptYamlError
1131
+ module.exports.PromptJsonError = module.exports.PromptJsonError
1132
+ module.exports.PromptValidationError = module.exports.PromptValidationError
1133
+ module.exports.MemoryError = module.exports.MemoryError
1134
+ module.exports.MemoryNoEmbedderError = module.exports.MemoryNoEmbedderError
1135
+ module.exports.MemoryElidError = module.exports.MemoryElidError
1136
+ module.exports.MemoryEmbeddingError = module.exports.MemoryEmbeddingError
1137
+ module.exports.MemoryNotFoundError = module.exports.MemoryNotFoundError
1138
+ module.exports.MemorySerializationError = module.exports.MemorySerializationError
1139
+ module.exports.MemoryIoError = module.exports.MemoryIoError
1140
+ module.exports.MemoryBackendError = module.exports.MemoryBackendError
1141
+ module.exports.MusicError = module.exports.MusicError
1142
+ module.exports.MusicEngineNotAvailableError = module.exports.MusicEngineNotAvailableError
1143
+ module.exports.MusicNotYetImplementedError = module.exports.MusicNotYetImplementedError
1144
+ module.exports.MusicHfHubError = module.exports.MusicHfHubError
1145
+ module.exports.MusicIoError = module.exports.MusicIoError
1146
+ module.exports.MusicCandleError = module.exports.MusicCandleError
1147
+ module.exports.MusicInvalidInputError = module.exports.MusicInvalidInputError
1148
+ module.exports.VcError = module.exports.VcError
1149
+ module.exports.VcEngineNotAvailableError = module.exports.VcEngineNotAvailableError
1150
+ module.exports.VcModelLoadError = module.exports.VcModelLoadError
1151
+ module.exports.VcConversionError = module.exports.VcConversionError
1152
+ module.exports.VcVoiceNotFoundError = module.exports.VcVoiceNotFoundError
1153
+ module.exports.VcUnsupportedError = module.exports.VcUnsupportedError
1154
+ module.exports.VcIoError = module.exports.VcIoError
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blazen",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "description": "Blazen - Event-driven AI workflow framework for Node.js/TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -50,7 +50,6 @@
50
50
  "files": [
51
51
  "index.js",
52
52
  "index.d.ts",
53
- "error-classes.js",
54
53
  "blazen.workers.js",
55
54
  "blazen.workers.d.ts"
56
55
  ],
@@ -88,13 +87,13 @@
88
87
  "verbose": true
89
88
  },
90
89
  "optionalDependencies": {
91
- "@blazen-dev/blazen-linux-x64-gnu": "0.5.4",
92
- "@blazen-dev/blazen-linux-x64-musl": "0.5.4",
93
- "@blazen-dev/blazen-linux-arm64-gnu": "0.5.4",
94
- "@blazen-dev/blazen-linux-arm64-musl": "0.5.4",
95
- "@blazen-dev/blazen-darwin-arm64": "0.5.4",
96
- "@blazen-dev/blazen-win32-x64-msvc": "0.5.4",
97
- "@blazen-dev/blazen-wasm32-wasi": "0.5.4"
90
+ "@blazen-dev/blazen-linux-x64-gnu": "0.6.0",
91
+ "@blazen-dev/blazen-linux-x64-musl": "0.6.0",
92
+ "@blazen-dev/blazen-linux-arm64-gnu": "0.6.0",
93
+ "@blazen-dev/blazen-linux-arm64-musl": "0.6.0",
94
+ "@blazen-dev/blazen-darwin-arm64": "0.6.0",
95
+ "@blazen-dev/blazen-win32-x64-msvc": "0.6.0",
96
+ "@blazen-dev/blazen-wasm32-wasi": "0.6.0"
98
97
  },
99
98
  "scripts": {
100
99
  "build": "napi build --release --platform --features local-all,langfuse --js index.js && node scripts/post-build.mjs",