@openclaw/voice-call 2026.7.1-beta.2 → 2026.7.1-beta.4
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 +1 -0
- package/dist/{config-DNtTB7Iw.js → config-CgigQDrF.js} +31 -13
- package/dist/{config-compat-CCEjHjAJ.js → config-compat-DAFd5tVH.js} +3 -2
- package/dist/doctor-contract-api.js +4 -22
- package/dist/{guarded-json-api-7ITxTL6G.js → guarded-json-api-BrBbW_RJ.js} +19 -57
- package/dist/index.js +46 -33
- package/dist/{mock-YAo3QDri.js → mock-YsvBTX-7.js} +18 -2
- package/dist/{plivo-wmeT9r_t.js → plivo-BnCuAGwj.js} +25 -6
- package/dist/{realtime-handler-DdViwdCW.js → realtime-handler-Bz-MNWtD.js} +103 -43
- package/dist/response-generator-PXuisI3L.js +272 -0
- package/dist/{runtime-entry-DN7HllXj.js → runtime-entry-kCq5Xjph.js} +234 -96
- package/dist/runtime-entry.js +1 -1
- package/dist/setup-api.js +1 -1
- package/dist/{store-8M2m4Isq.js → store-DtewuuOb.js} +23 -6
- package/dist/{telnyx-DuUBsPW2.js → telnyx-DTHQGeaW.js} +1 -1
- package/dist/{twilio-CsJBvC3a.js → twilio-xNIXGJ-M.js} +16 -8
- package/dist/webhook-replay-aaP79dI8.js +32 -0
- package/node_modules/commander/Readme.md +11 -15
- package/node_modules/commander/index.js +14 -17
- package/node_modules/commander/lib/argument.js +3 -6
- package/node_modules/commander/lib/command.js +46 -33
- package/node_modules/commander/lib/error.js +2 -5
- package/node_modules/commander/lib/help.js +4 -20
- package/node_modules/commander/lib/option.js +3 -6
- package/node_modules/commander/lib/suggestSimilar.js +2 -4
- package/node_modules/commander/package.json +10 -28
- package/node_modules/commander/typings/index.d.ts +3 -3
- package/node_modules/typebox/build/compile/validator.d.mts +2 -7
- package/node_modules/typebox/build/compile/validator.mjs +6 -36
- package/node_modules/typebox/build/error/errors.d.mts +1 -7
- package/node_modules/typebox/build/format/_idna.mjs +36 -6
- package/node_modules/typebox/build/format/_puny.mjs +4 -1
- package/node_modules/typebox/build/format/uuid.d.mts +2 -2
- package/node_modules/typebox/build/format/uuid.mjs +3 -3
- package/node_modules/typebox/build/guard/emit.d.mts +0 -4
- package/node_modules/typebox/build/guard/emit.mjs +0 -8
- package/node_modules/typebox/build/guard/guard.d.mts +4 -8
- package/node_modules/typebox/build/guard/guard.mjs +5 -13
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/schema.mjs +5 -10
- package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
- package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/types/index.mjs +0 -1
- package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
- package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
- package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
- package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
- package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
- package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
- package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
- package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
- package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
- package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
- package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
- package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
- package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
- package/node_modules/typebox/build/type/action/index.d.mts +7 -4
- package/node_modules/typebox/build/type/action/index.mjs +7 -4
- package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
- package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
- package/node_modules/typebox/build/type/action/module.d.mts +8 -7
- package/node_modules/typebox/build/type/action/module.mjs +7 -6
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
- package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -5
- package/node_modules/typebox/build/type/action/with.d.mts +11 -0
- package/node_modules/typebox/build/type/action/with.mjs +11 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
- package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
- package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
- package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
- package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
- package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
- package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/index.mjs +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
- package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
- package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
- package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
- package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
- package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
- package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
- package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
- package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
- package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
- package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
- package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
- package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
- package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
- package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
- package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
- package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
- package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
- package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
- package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
- package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
- package/node_modules/typebox/build/type/extends/object.mjs +25 -3
- package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
- package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
- package/node_modules/typebox/build/type/extends/record.mjs +23 -0
- package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
- package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
- package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
- package/node_modules/typebox/build/type/extends/union.mjs +2 -2
- package/node_modules/typebox/build/type/script/mapping.d.mts +84 -99
- package/node_modules/typebox/build/type/script/mapping.mjs +81 -85
- package/node_modules/typebox/build/type/script/parser.d.mts +40 -40
- package/node_modules/typebox/build/type/script/parser.mjs +22 -22
- package/node_modules/typebox/build/type/script/script.d.mts +3 -4
- package/node_modules/typebox/build/type/script/script.mjs +3 -2
- package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
- package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
- package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
- package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
- package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
- package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
- package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
- package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
- package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
- package/node_modules/typebox/build/type/types/call.d.mts +3 -3
- package/node_modules/typebox/build/type/types/call.mjs +3 -2
- package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
- package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
- package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
- package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
- package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
- package/node_modules/typebox/build/type/types/enum.mjs +5 -0
- package/node_modules/typebox/build/type/types/index.d.mts +1 -4
- package/node_modules/typebox/build/type/types/index.mjs +1 -4
- package/node_modules/typebox/build/type/types/number.d.mts +1 -1
- package/node_modules/typebox/build/type/types/number.mjs +1 -1
- package/node_modules/typebox/build/type/types/record.d.mts +13 -7
- package/node_modules/typebox/build/type/types/record.mjs +15 -9
- package/node_modules/typebox/build/type/types/static.d.mts +2 -5
- package/node_modules/typebox/build/typebox.d.mts +4 -8
- package/node_modules/typebox/build/typebox.mjs +4 -8
- package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
- package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
- package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
- package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
- package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
- package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
- package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
- package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
- package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
- package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
- package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/index.d.mts +0 -1
- package/node_modules/typebox/build/value/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
- package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
- package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
- package/node_modules/typebox/build/value/value.d.mts +0 -1
- package/node_modules/typebox/build/value/value.mjs +0 -1
- package/node_modules/typebox/package.json +25 -25
- package/node_modules/typebox/readme.md +97 -80
- package/npm-shrinkwrap.json +12 -12
- package/openclaw.plugin.json +8 -0
- package/package.json +6 -6
- package/dist/response-generator-CXBGKbAp.js +0 -212
- package/node_modules/commander/esm.mjs +0 -16
- package/node_modules/commander/typings/esm.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
- package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
- package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
- package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
- package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
- package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
- package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
- package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
- package/node_modules/typebox/build/type/action/options.d.mts +0 -11
- package/node_modules/typebox/build/type/action/options.mjs +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
- package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
- package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
- package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/base.d.mts +0 -50
- package/node_modules/typebox/build/type/types/base.mjs +0 -84
- package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
- package/node_modules/typebox/build/type/types/promise.mjs +0 -29
- package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
- package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
- package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
- package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
- package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
- package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
- package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
- package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
- package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
- package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
- package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
- package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
- package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { isBlockedHostnameOrIp, isRequestBodyLimitError, readRequestBodyWithLimit, requestBodyErrorToText } from "./runtime-api.js";
|
|
2
2
|
import "./api.js";
|
|
3
|
-
import { a as resolveVoiceCallEffectiveConfig, c as validateProviderConfig, i as resolveVoiceCallConfig, n as normalizeVoiceCallConfig, o as resolveVoiceCallNumberRouteKeyForCall, r as resolveTwilioAuthToken, s as resolveVoiceCallSessionKey
|
|
4
|
-
import { c as
|
|
3
|
+
import { a as resolveVoiceCallEffectiveConfig, c as validateProviderConfig, d as deepMergeDefined, i as resolveVoiceCallConfig, n as normalizeVoiceCallConfig, o as resolveVoiceCallNumberRouteKeyForCall, r as resolveTwilioAuthToken, s as resolveVoiceCallSessionKey } from "./config-CgigQDrF.js";
|
|
4
|
+
import { c as findCallMatchesInStore, f as persistCallRecord, g as TerminalStates, h as setVoiceCallStateRuntime, l as getCallHistoryFromStore, u as loadActiveCallsFromStore } from "./store-DtewuuOb.js";
|
|
5
5
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
6
6
|
import { isLoopbackHost } from "openclaw/plugin-sdk/gateway-runtime";
|
|
7
7
|
import { MAX_TIMER_TIMEOUT_MS, asDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
8
|
+
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
|
|
8
9
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
10
|
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
10
11
|
import { REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME, buildRealtimeVoiceAgentConsultPolicyInstructions, consultRealtimeVoiceAgent, convertPcmToMulaw8k, createTalkSessionController, recordTalkObservabilityEvent, resolveRealtimeVoiceAgentConsultTools, resolveRealtimeVoiceAgentConsultToolsAllow, resolveRealtimeVoiceFastContextConsult } from "openclaw/plugin-sdk/realtime-voice";
|
|
12
|
+
import { WEBHOOK_BODY_READ_DEFAULTS, createWebhookInFlightLimiter, normalizeWebhookPath } from "openclaw/plugin-sdk/webhook-ingress";
|
|
11
13
|
import fs from "node:fs";
|
|
12
14
|
import os from "node:os";
|
|
13
15
|
import path from "node:path";
|
|
14
16
|
import crypto from "node:crypto";
|
|
15
17
|
import { root } from "openclaw/plugin-sdk/security-runtime";
|
|
18
|
+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
16
19
|
import { parseTtsDirectives } from "openclaw/plugin-sdk/speech";
|
|
17
20
|
import { spawn } from "node:child_process";
|
|
18
21
|
import http from "node:http";
|
|
19
22
|
import { URL as URL$1 } from "node:url";
|
|
20
23
|
import { resolveConfiguredCapabilityProvider } from "openclaw/plugin-sdk/provider-selection-runtime";
|
|
21
|
-
import {
|
|
22
|
-
import { WebSocket as WebSocket$1, WebSocketServer } from "ws";
|
|
24
|
+
import { WebSocket, WebSocketServer } from "ws";
|
|
23
25
|
//#region extensions/voice-call/src/allowlist.ts
|
|
24
26
|
/** Normalize a phone number to digits only. */
|
|
25
27
|
function normalizePhoneNumber(input) {
|
|
@@ -36,7 +38,7 @@ function isAllowlistedCaller(normalizedFrom, allowFrom) {
|
|
|
36
38
|
}
|
|
37
39
|
//#endregion
|
|
38
40
|
//#region extensions/voice-call/src/manager/state.ts
|
|
39
|
-
const ConversationStates = new Set(["speaking", "listening"]);
|
|
41
|
+
const ConversationStates = /* @__PURE__ */ new Set(["speaking", "listening"]);
|
|
40
42
|
const StateOrder = [
|
|
41
43
|
"initiated",
|
|
42
44
|
"ringing",
|
|
@@ -311,6 +313,7 @@ async function initiateCall(ctx, to, sessionKey, options) {
|
|
|
311
313
|
const mode = opts.mode ?? ctx.config.outbound.defaultMode;
|
|
312
314
|
const dtmfSequence = opts.dtmfSequence;
|
|
313
315
|
const requesterSessionKey = opts.requesterSessionKey?.trim();
|
|
316
|
+
const agentId = normalizeAgentId(opts.agentId ?? ctx.config.agentId);
|
|
314
317
|
if (dtmfSequence) {
|
|
315
318
|
const validationError = validateDtmfDigits(dtmfSequence);
|
|
316
319
|
if (validationError) return {
|
|
@@ -354,12 +357,16 @@ async function initiateCall(ctx, to, sessionKey, options) {
|
|
|
354
357
|
from,
|
|
355
358
|
to,
|
|
356
359
|
sessionKey: resolveVoiceCallSessionKey({
|
|
357
|
-
config:
|
|
360
|
+
config: {
|
|
361
|
+
...ctx.config,
|
|
362
|
+
agentId
|
|
363
|
+
},
|
|
358
364
|
callId,
|
|
359
365
|
phone: to,
|
|
360
366
|
explicitSessionKey: sessionKey,
|
|
361
367
|
coreSession: ctx.coreSession
|
|
362
368
|
}),
|
|
369
|
+
agentId,
|
|
363
370
|
startedAt: Date.now(),
|
|
364
371
|
transcript: [],
|
|
365
372
|
processedEventIds: [],
|
|
@@ -422,7 +429,7 @@ async function initiateCall(ctx, to, sessionKey, options) {
|
|
|
422
429
|
};
|
|
423
430
|
}
|
|
424
431
|
}
|
|
425
|
-
async function speak(ctx, callId, text) {
|
|
432
|
+
async function speak(ctx, callId, text, options) {
|
|
426
433
|
const connected = requireConnectedCall(ctx, callId);
|
|
427
434
|
if (!connected.ok) return {
|
|
428
435
|
success: false,
|
|
@@ -442,11 +449,13 @@ async function speak(ctx, callId, text) {
|
|
|
442
449
|
persistCallRecord(ctx.storePath, call);
|
|
443
450
|
const numberRouteKey = resolveVoiceCallNumberRouteKeyForCall(call);
|
|
444
451
|
const voice = resolvePreferredTtsVoice(resolveVoiceCallEffectiveConfig(ctx.config, numberRouteKey).config);
|
|
452
|
+
const playbackOptions = options?.listenAfterPlayback ? { listenAfterPlayback: true } : {};
|
|
445
453
|
await provider.playTts({
|
|
446
454
|
callId,
|
|
447
455
|
providerCallId,
|
|
448
456
|
text,
|
|
449
|
-
voice
|
|
457
|
+
voice,
|
|
458
|
+
...playbackOptions
|
|
450
459
|
});
|
|
451
460
|
addTranscriptEntry(call, "bot", text);
|
|
452
461
|
persistCallRecord(ctx.storePath, call);
|
|
@@ -677,6 +686,7 @@ function createWebhookCall(params) {
|
|
|
677
686
|
callId,
|
|
678
687
|
phone: params.direction === "outbound" ? params.to : params.from
|
|
679
688
|
}),
|
|
689
|
+
agentId: normalizeAgentId(effectiveConfig.agentId),
|
|
680
690
|
startedAt: Date.now(),
|
|
681
691
|
transcript: [],
|
|
682
692
|
processedEventIds: [],
|
|
@@ -713,7 +723,7 @@ function persistRejectedInboundCall(params) {
|
|
|
713
723
|
}
|
|
714
724
|
function processEvent(ctx, event) {
|
|
715
725
|
const dedupeKey = event.dedupeKey || event.id;
|
|
716
|
-
if (ctx.processedEventIds.has(dedupeKey)) return;
|
|
726
|
+
if (ctx.processedEventIds.has(dedupeKey)) return { kind: "ignored" };
|
|
717
727
|
let call = findCall({
|
|
718
728
|
activeCalls: ctx.activeCalls,
|
|
719
729
|
providerCallIdMap: ctx.providerCallIdMap,
|
|
@@ -726,10 +736,10 @@ function processEvent(ctx, event) {
|
|
|
726
736
|
const pid = providerCallId;
|
|
727
737
|
if (!ctx.provider) {
|
|
728
738
|
console.warn(`[voice-call] Inbound call rejected by policy but no provider to hang up (providerCallId: ${pid}, from: ${event.from}); call will time out on provider side.`);
|
|
729
|
-
return;
|
|
739
|
+
return { kind: "ignored" };
|
|
730
740
|
}
|
|
731
741
|
ctx.processedEventIds.add(dedupeKey);
|
|
732
|
-
if (ctx.rejectedProviderCallIds.has(pid)) return;
|
|
742
|
+
if (ctx.rejectedProviderCallIds.has(pid)) return { kind: "ignored" };
|
|
733
743
|
ctx.rejectedProviderCallIds.add(pid);
|
|
734
744
|
const callId = event.callId ?? pid;
|
|
735
745
|
persistRejectedInboundCall({
|
|
@@ -748,7 +758,7 @@ function processEvent(ctx, event) {
|
|
|
748
758
|
const message = formatErrorMessage(err);
|
|
749
759
|
console.warn(`[voice-call] Failed to reject inbound call ${pid}:`, message);
|
|
750
760
|
});
|
|
751
|
-
return;
|
|
761
|
+
return { kind: "processed" };
|
|
752
762
|
}
|
|
753
763
|
call = createWebhookCall({
|
|
754
764
|
ctx,
|
|
@@ -759,7 +769,7 @@ function processEvent(ctx, event) {
|
|
|
759
769
|
});
|
|
760
770
|
event.callId = call.callId;
|
|
761
771
|
}
|
|
762
|
-
if (!call) return;
|
|
772
|
+
if (!call) return { kind: "ignored" };
|
|
763
773
|
if (event.providerCallId && event.providerCallId !== call.providerCallId) {
|
|
764
774
|
const previousProviderCallId = call.providerCallId;
|
|
765
775
|
call.providerCallId = event.providerCallId;
|
|
@@ -772,6 +782,7 @@ function processEvent(ctx, event) {
|
|
|
772
782
|
ctx.processedEventIds.add(dedupeKey);
|
|
773
783
|
call.processedEventIds.push(dedupeKey);
|
|
774
784
|
}
|
|
785
|
+
let result = { kind: "processed" };
|
|
775
786
|
switch (event.type) {
|
|
776
787
|
case "call.initiated":
|
|
777
788
|
transitionState(call, "initiated");
|
|
@@ -815,6 +826,7 @@ function processEvent(ctx, event) {
|
|
|
815
826
|
transitionState(call, "active");
|
|
816
827
|
break;
|
|
817
828
|
case "call.speaking":
|
|
829
|
+
case "call.assistant-speech":
|
|
818
830
|
ensureMaxDurationTimerForLiveCall({
|
|
819
831
|
ctx,
|
|
820
832
|
call,
|
|
@@ -824,6 +836,7 @@ function processEvent(ctx, event) {
|
|
|
824
836
|
}
|
|
825
837
|
});
|
|
826
838
|
transitionState(call, "speaking");
|
|
839
|
+
if (event.type === "call.assistant-speech" && event.transcript.trim()) addTranscriptEntry(call, "bot", event.transcript);
|
|
827
840
|
break;
|
|
828
841
|
case "call.speech":
|
|
829
842
|
if (event.isFinal) {
|
|
@@ -831,9 +844,16 @@ function processEvent(ctx, event) {
|
|
|
831
844
|
const resolved = resolveTranscriptWaiter(ctx, call.callId, event.transcript, event.turnToken);
|
|
832
845
|
if (hadWaiter && !resolved) {
|
|
833
846
|
console.warn(`[voice-call] Ignoring speech event with mismatched turn token for ${call.callId}`);
|
|
847
|
+
result = { kind: "ignored" };
|
|
834
848
|
break;
|
|
835
849
|
}
|
|
836
850
|
addTranscriptEntry(call, "user", event.transcript);
|
|
851
|
+
result = {
|
|
852
|
+
kind: "final-speech",
|
|
853
|
+
call,
|
|
854
|
+
transcript: event.transcript,
|
|
855
|
+
waiterResolved: resolved
|
|
856
|
+
};
|
|
837
857
|
}
|
|
838
858
|
ensureMaxDurationTimerForLiveCall({
|
|
839
859
|
ctx,
|
|
@@ -854,7 +874,7 @@ function processEvent(ctx, event) {
|
|
|
854
874
|
endReason: event.reason,
|
|
855
875
|
endedAt: event.timestamp
|
|
856
876
|
});
|
|
857
|
-
return;
|
|
877
|
+
return { kind: "processed" };
|
|
858
878
|
case "call.error":
|
|
859
879
|
if (!event.retryable) {
|
|
860
880
|
finalizeCall({
|
|
@@ -864,11 +884,12 @@ function processEvent(ctx, event) {
|
|
|
864
884
|
endedAt: event.timestamp,
|
|
865
885
|
transcriptRejectReason: `Call error: ${event.error}`
|
|
866
886
|
});
|
|
867
|
-
return;
|
|
887
|
+
return { kind: "processed" };
|
|
868
888
|
}
|
|
869
889
|
break;
|
|
870
890
|
}
|
|
871
891
|
persistCallRecord(ctx.storePath, call);
|
|
892
|
+
return result;
|
|
872
893
|
}
|
|
873
894
|
//#endregion
|
|
874
895
|
//#region extensions/voice-call/src/utils.ts
|
|
@@ -1053,8 +1074,8 @@ var CallManager = class {
|
|
|
1053
1074
|
/**
|
|
1054
1075
|
* Speak to user in an active call.
|
|
1055
1076
|
*/
|
|
1056
|
-
async speak(callId, text) {
|
|
1057
|
-
return speak(this.getContext(), callId, text);
|
|
1077
|
+
async speak(callId, text, options) {
|
|
1078
|
+
return speak(this.getContext(), callId, text, options);
|
|
1058
1079
|
}
|
|
1059
1080
|
/**
|
|
1060
1081
|
* Send DTMF digits to an active call.
|
|
@@ -1105,7 +1126,7 @@ var CallManager = class {
|
|
|
1105
1126
|
* Process a webhook event.
|
|
1106
1127
|
*/
|
|
1107
1128
|
processEvent(event) {
|
|
1108
|
-
processEvent(this.getContext(), event);
|
|
1129
|
+
return processEvent(this.getContext(), event);
|
|
1109
1130
|
}
|
|
1110
1131
|
shouldDeferConversationInitialMessageUntilStreamConnect() {
|
|
1111
1132
|
if (!this.provider || this.provider.name !== "twilio" || !this.config.streaming.enabled) return false;
|
|
@@ -1147,6 +1168,13 @@ var CallManager = class {
|
|
|
1147
1168
|
getActiveCalls() {
|
|
1148
1169
|
return Array.from(this.activeCalls.values());
|
|
1149
1170
|
}
|
|
1171
|
+
/** Resolve a status record from active state or the retained event store. */
|
|
1172
|
+
async getCallFromMemoryOrStore(callId) {
|
|
1173
|
+
const active = this.getCall(callId) ?? this.getCallByProviderCallId(callId);
|
|
1174
|
+
if (active) return active;
|
|
1175
|
+
const persisted = await findCallMatchesInStore(this.storePath, callId);
|
|
1176
|
+
return persisted.byCallId ?? persisted.byProviderCallId;
|
|
1177
|
+
}
|
|
1150
1178
|
/**
|
|
1151
1179
|
* Get call history (from persisted logs).
|
|
1152
1180
|
*/
|
|
@@ -1159,7 +1187,7 @@ var CallManager = class {
|
|
|
1159
1187
|
/** Limit injected context while preserving an explicit truncation marker. */
|
|
1160
1188
|
function limitText(text, maxChars) {
|
|
1161
1189
|
if (text.length <= maxChars) return text;
|
|
1162
|
-
return `${text
|
|
1190
|
+
return `${truncateUtf16Safe(text, Math.max(0, maxChars - 32)).trimEnd()}\n[truncated]`;
|
|
1163
1191
|
}
|
|
1164
1192
|
/** Read configured workspace context files through the safe workspace root. */
|
|
1165
1193
|
async function readWorkspaceVoiceContextFiles(params) {
|
|
@@ -1227,6 +1255,12 @@ async function resolveRealtimeFastContextConsult(params) {
|
|
|
1227
1255
|
});
|
|
1228
1256
|
}
|
|
1229
1257
|
//#endregion
|
|
1258
|
+
//#region extensions/voice-call/src/resolve-call-agent-id.ts
|
|
1259
|
+
/** Keep one agent owner for the full call, including legacy stored records. */
|
|
1260
|
+
function resolveCallAgentId(call, config) {
|
|
1261
|
+
return normalizeAgentId(call.agentId ?? config.agentId);
|
|
1262
|
+
}
|
|
1263
|
+
//#endregion
|
|
1230
1264
|
//#region extensions/voice-call/src/response-model.ts
|
|
1231
1265
|
/** Resolve provider/model fields from explicit voice config or agent defaults. */
|
|
1232
1266
|
function resolveVoiceResponseModel(params) {
|
|
@@ -1351,7 +1385,7 @@ function collectTelephonyProviderConfigs(ttsConfig) {
|
|
|
1351
1385
|
const normalized = normalizeProviderId(providerId) ?? providerId;
|
|
1352
1386
|
entries[normalized] = asProviderConfig(value);
|
|
1353
1387
|
}
|
|
1354
|
-
const reservedKeys = new Set([
|
|
1388
|
+
const reservedKeys = /* @__PURE__ */ new Set([
|
|
1355
1389
|
"auto",
|
|
1356
1390
|
"enabled",
|
|
1357
1391
|
"maxTextLength",
|
|
@@ -1435,6 +1469,13 @@ function runTailscaleCommand(args, timeoutMs = 2500) {
|
|
|
1435
1469
|
clearTimeout(timer);
|
|
1436
1470
|
resolve(result);
|
|
1437
1471
|
};
|
|
1472
|
+
const timer = setTimeout(() => {
|
|
1473
|
+
proc.kill("SIGKILL");
|
|
1474
|
+
finish({
|
|
1475
|
+
code: -1,
|
|
1476
|
+
stdout: ""
|
|
1477
|
+
});
|
|
1478
|
+
}, timeoutMs);
|
|
1438
1479
|
proc.stdout.on("data", (data) => {
|
|
1439
1480
|
stdout = appendTailscaleCommandStdout(stdout, data);
|
|
1440
1481
|
if (stdout.exceeded) {
|
|
@@ -1445,13 +1486,13 @@ function runTailscaleCommand(args, timeoutMs = 2500) {
|
|
|
1445
1486
|
});
|
|
1446
1487
|
}
|
|
1447
1488
|
});
|
|
1448
|
-
|
|
1489
|
+
proc.stdout.on("error", () => {
|
|
1449
1490
|
proc.kill("SIGKILL");
|
|
1450
1491
|
finish({
|
|
1451
1492
|
code: -1,
|
|
1452
1493
|
stdout: ""
|
|
1453
1494
|
});
|
|
1454
|
-
}
|
|
1495
|
+
});
|
|
1455
1496
|
proc.on("error", () => {
|
|
1456
1497
|
finish({
|
|
1457
1498
|
code: -1,
|
|
@@ -1535,6 +1576,10 @@ async function cleanupTailscaleExposure(config) {
|
|
|
1535
1576
|
//#endregion
|
|
1536
1577
|
//#region extensions/voice-call/src/tunnel.ts
|
|
1537
1578
|
const NGROK_LOG_BUFFER_MAX_CHARS = 16384;
|
|
1579
|
+
function listenForChildStreamErrors(proc, onError) {
|
|
1580
|
+
proc.stdout.on("error", (error) => onError("stdout", error));
|
|
1581
|
+
proc.stderr.on("error", (error) => onError("stderr", error));
|
|
1582
|
+
}
|
|
1538
1583
|
/**
|
|
1539
1584
|
* Start an ngrok tunnel to expose the local webhook server.
|
|
1540
1585
|
*
|
|
@@ -1567,6 +1612,7 @@ async function startNgrokTunnel(config) {
|
|
|
1567
1612
|
"pipe"
|
|
1568
1613
|
] });
|
|
1569
1614
|
let resolved = false;
|
|
1615
|
+
let closed = false;
|
|
1570
1616
|
let publicUrl = null;
|
|
1571
1617
|
let outputBuffer = "";
|
|
1572
1618
|
const timeout = setTimeout(() => {
|
|
@@ -1576,6 +1622,14 @@ async function startNgrokTunnel(config) {
|
|
|
1576
1622
|
reject(/* @__PURE__ */ new Error("ngrok startup timed out (30s)"));
|
|
1577
1623
|
}
|
|
1578
1624
|
}, 3e4);
|
|
1625
|
+
const rejectIfPending = (message, kill = false) => {
|
|
1626
|
+
if (!resolved) {
|
|
1627
|
+
resolved = true;
|
|
1628
|
+
clearTimeout(timeout);
|
|
1629
|
+
if (kill && !closed) proc.kill("SIGKILL");
|
|
1630
|
+
reject(new Error(message));
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1579
1633
|
const processLine = (line) => {
|
|
1580
1634
|
try {
|
|
1581
1635
|
const log = JSON.parse(line);
|
|
@@ -1590,10 +1644,24 @@ async function startNgrokTunnel(config) {
|
|
|
1590
1644
|
publicUrl: fullUrl,
|
|
1591
1645
|
provider: "ngrok",
|
|
1592
1646
|
stop: async () => {
|
|
1593
|
-
|
|
1647
|
+
if (closed) return;
|
|
1594
1648
|
await new Promise((res) => {
|
|
1595
|
-
|
|
1596
|
-
|
|
1649
|
+
let finished = false;
|
|
1650
|
+
const finish = () => {
|
|
1651
|
+
if (finished) return;
|
|
1652
|
+
finished = true;
|
|
1653
|
+
clearTimeout(fallback);
|
|
1654
|
+
proc.off("close", finish);
|
|
1655
|
+
res();
|
|
1656
|
+
};
|
|
1657
|
+
if (closed) {
|
|
1658
|
+
res();
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
proc.once("close", finish);
|
|
1662
|
+
const fallback = setTimeout(finish, 2e3);
|
|
1663
|
+
proc.kill("SIGTERM");
|
|
1664
|
+
if (closed) finish();
|
|
1597
1665
|
});
|
|
1598
1666
|
}
|
|
1599
1667
|
});
|
|
@@ -1608,23 +1676,16 @@ async function startNgrokTunnel(config) {
|
|
|
1608
1676
|
});
|
|
1609
1677
|
proc.stderr.on("data", (data) => {
|
|
1610
1678
|
const msg = data.toString();
|
|
1611
|
-
if (msg.includes("ERR_NGROK")) {
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
const output = appendBoundedChildOutput(emptyBoundedChildOutput(), msg);
|
|
1616
|
-
reject(/* @__PURE__ */ new Error(`ngrok error: ${formatBoundedChildOutput(output)}`));
|
|
1617
|
-
}
|
|
1618
|
-
}
|
|
1679
|
+
if (msg.includes("ERR_NGROK")) rejectIfPending(`ngrok error: ${formatBoundedChildOutput(appendBoundedChildOutput(emptyBoundedChildOutput(), msg))}`, true);
|
|
1680
|
+
});
|
|
1681
|
+
listenForChildStreamErrors(proc, (stream, error) => {
|
|
1682
|
+
rejectIfPending(`ngrok ${stream} error: ${error.message}`, true);
|
|
1619
1683
|
});
|
|
1620
1684
|
proc.on("error", (err) => {
|
|
1621
|
-
|
|
1622
|
-
resolved = true;
|
|
1623
|
-
clearTimeout(timeout);
|
|
1624
|
-
reject(/* @__PURE__ */ new Error(`Failed to start ngrok: ${err.message}`));
|
|
1625
|
-
}
|
|
1685
|
+
rejectIfPending(`Failed to start ngrok: ${err.message}`);
|
|
1626
1686
|
});
|
|
1627
1687
|
proc.on("close", (code) => {
|
|
1688
|
+
closed = true;
|
|
1628
1689
|
if (!resolved) {
|
|
1629
1690
|
resolved = true;
|
|
1630
1691
|
clearTimeout(timeout);
|
|
@@ -1645,20 +1706,32 @@ async function runNgrokCommand(args) {
|
|
|
1645
1706
|
] });
|
|
1646
1707
|
let stdout = emptyBoundedChildOutput();
|
|
1647
1708
|
let stderr = emptyBoundedChildOutput();
|
|
1709
|
+
let settled = false;
|
|
1710
|
+
const rejectIfPending = (error, kill = false) => {
|
|
1711
|
+
if (settled) return;
|
|
1712
|
+
settled = true;
|
|
1713
|
+
if (kill) proc.kill("SIGKILL");
|
|
1714
|
+
reject(error);
|
|
1715
|
+
};
|
|
1648
1716
|
proc.stdout.on("data", (data) => {
|
|
1649
1717
|
stdout = appendBoundedChildOutput(stdout, data.toString());
|
|
1650
1718
|
});
|
|
1651
1719
|
proc.stderr.on("data", (data) => {
|
|
1652
1720
|
stderr = appendBoundedChildOutput(stderr, data.toString());
|
|
1653
1721
|
});
|
|
1722
|
+
listenForChildStreamErrors(proc, (stream, error) => {
|
|
1723
|
+
rejectIfPending(/* @__PURE__ */ new Error(`ngrok command ${stream} error: ${error.message}`), true);
|
|
1724
|
+
});
|
|
1654
1725
|
proc.on("close", (code) => {
|
|
1726
|
+
if (settled) return;
|
|
1727
|
+
settled = true;
|
|
1655
1728
|
if (code === 0) resolve(stdout.text);
|
|
1656
1729
|
else {
|
|
1657
1730
|
const output = stderr.text ? stderr : stdout;
|
|
1658
1731
|
reject(/* @__PURE__ */ new Error(`ngrok command failed: ${formatBoundedChildOutput(output)}`));
|
|
1659
1732
|
}
|
|
1660
1733
|
});
|
|
1661
|
-
proc.on("error",
|
|
1734
|
+
proc.on("error", (error) => rejectIfPending(error));
|
|
1662
1735
|
});
|
|
1663
1736
|
}
|
|
1664
1737
|
/**
|
|
@@ -1682,11 +1755,18 @@ async function startTailscaleTunnel(config) {
|
|
|
1682
1755
|
"pipe",
|
|
1683
1756
|
"pipe"
|
|
1684
1757
|
] });
|
|
1758
|
+
let resolved = false;
|
|
1685
1759
|
let stdout = emptyBoundedChildOutput();
|
|
1686
1760
|
let stderr = emptyBoundedChildOutput();
|
|
1761
|
+
const rejectIfPending = (error, kill = false) => {
|
|
1762
|
+
if (resolved) return;
|
|
1763
|
+
resolved = true;
|
|
1764
|
+
clearTimeout(timeout);
|
|
1765
|
+
if (kill) proc.kill("SIGKILL");
|
|
1766
|
+
reject(error);
|
|
1767
|
+
};
|
|
1687
1768
|
const timeout = setTimeout(() => {
|
|
1688
|
-
|
|
1689
|
-
reject(/* @__PURE__ */ new Error(`Tailscale ${config.mode} timed out`));
|
|
1769
|
+
rejectIfPending(/* @__PURE__ */ new Error(`Tailscale ${config.mode} timed out`), true);
|
|
1690
1770
|
}, 1e4);
|
|
1691
1771
|
proc.stdout.on("data", (data) => {
|
|
1692
1772
|
stdout = appendBoundedChildOutput(stdout, data.toString());
|
|
@@ -1694,8 +1774,13 @@ async function startTailscaleTunnel(config) {
|
|
|
1694
1774
|
proc.stderr.on("data", (data) => {
|
|
1695
1775
|
stderr = appendBoundedChildOutput(stderr, data.toString());
|
|
1696
1776
|
});
|
|
1777
|
+
listenForChildStreamErrors(proc, (stream, error) => {
|
|
1778
|
+
rejectIfPending(/* @__PURE__ */ new Error(`Tailscale ${config.mode} ${stream} error: ${error.message}`), true);
|
|
1779
|
+
});
|
|
1697
1780
|
proc.on("close", (code) => {
|
|
1698
1781
|
clearTimeout(timeout);
|
|
1782
|
+
if (resolved) return;
|
|
1783
|
+
resolved = true;
|
|
1699
1784
|
if (code === 0) {
|
|
1700
1785
|
const publicUrl = `https://${dnsName}${path}`;
|
|
1701
1786
|
console.log(`[voice-call] Tailscale ${config.mode} active: ${publicUrl}`);
|
|
@@ -1713,8 +1798,7 @@ async function startTailscaleTunnel(config) {
|
|
|
1713
1798
|
}
|
|
1714
1799
|
});
|
|
1715
1800
|
proc.on("error", (err) => {
|
|
1716
|
-
|
|
1717
|
-
reject(err);
|
|
1801
|
+
rejectIfPending(err);
|
|
1718
1802
|
});
|
|
1719
1803
|
});
|
|
1720
1804
|
}
|
|
@@ -1736,6 +1820,10 @@ async function stopTailscaleTunnel(mode, path) {
|
|
|
1736
1820
|
clearTimeout(timeout);
|
|
1737
1821
|
resolve();
|
|
1738
1822
|
});
|
|
1823
|
+
proc.on("error", () => {
|
|
1824
|
+
clearTimeout(timeout);
|
|
1825
|
+
resolve();
|
|
1826
|
+
});
|
|
1739
1827
|
});
|
|
1740
1828
|
}
|
|
1741
1829
|
/**
|
|
@@ -1836,7 +1924,7 @@ const CLOSE_REASON_LOG_MAX_CHARS = 120;
|
|
|
1836
1924
|
function sanitizeLogText(value, maxChars) {
|
|
1837
1925
|
const sanitized = value.replace(/\p{Cc}/gu, " ").replace(/\s+/g, " ").trim();
|
|
1838
1926
|
if (sanitized.length <= maxChars) return sanitized;
|
|
1839
|
-
return `${sanitized
|
|
1927
|
+
return `${truncateUtf16Safe(sanitized, maxChars)}...`;
|
|
1840
1928
|
}
|
|
1841
1929
|
function normalizeWsMessageData(data) {
|
|
1842
1930
|
if (Buffer.isBuffer(data)) return data;
|
|
@@ -2099,11 +2187,11 @@ var MediaStreamHandler = class {
|
|
|
2099
2187
|
error: error instanceof Error ? error.message : String(error)
|
|
2100
2188
|
}
|
|
2101
2189
|
});
|
|
2102
|
-
if (this.sessions.get(session.streamSid) === session && session.ws.readyState === WebSocket
|
|
2190
|
+
if (this.sessions.get(session.streamSid) === session && session.ws.readyState === WebSocket.OPEN) session.ws.close(1011, "STT connection failed");
|
|
2103
2191
|
else session.sttSession.close();
|
|
2104
2192
|
return;
|
|
2105
2193
|
}
|
|
2106
|
-
if (this.sessions.get(session.streamSid) !== session || session.ws.readyState !== WebSocket
|
|
2194
|
+
if (this.sessions.get(session.streamSid) !== session || session.ws.readyState !== WebSocket.OPEN) {
|
|
2107
2195
|
session.sttSession.close();
|
|
2108
2196
|
return;
|
|
2109
2197
|
}
|
|
@@ -2199,7 +2287,7 @@ Content-Length: ${Buffer.byteLength(body)}\r\n\r
|
|
|
2199
2287
|
*/
|
|
2200
2288
|
getOpenSession(streamSid) {
|
|
2201
2289
|
const session = this.sessions.get(streamSid);
|
|
2202
|
-
return session?.ws.readyState === WebSocket
|
|
2290
|
+
return session?.ws.readyState === WebSocket.OPEN ? session : void 0;
|
|
2203
2291
|
}
|
|
2204
2292
|
/**
|
|
2205
2293
|
* Send a message to a stream's WebSocket if available.
|
|
@@ -2213,7 +2301,7 @@ Content-Length: ${Buffer.byteLength(body)}\r\n\r
|
|
|
2213
2301
|
};
|
|
2214
2302
|
const readyState = session.ws.readyState;
|
|
2215
2303
|
const bufferedBeforeBytes = session.ws.bufferedAmount;
|
|
2216
|
-
if (readyState !== WebSocket
|
|
2304
|
+
if (readyState !== WebSocket.OPEN) return {
|
|
2217
2305
|
sent: false,
|
|
2218
2306
|
readyState,
|
|
2219
2307
|
bufferedBeforeBytes,
|
|
@@ -2464,20 +2552,33 @@ function normalizeProviderStatus(status) {
|
|
|
2464
2552
|
}
|
|
2465
2553
|
/** Map terminal provider status strings to OpenClaw end reasons. */
|
|
2466
2554
|
function mapProviderStatusToEndReason(status) {
|
|
2467
|
-
|
|
2555
|
+
const normalized = normalizeProviderStatus(status);
|
|
2556
|
+
return TERMINAL_PROVIDER_STATUS_TO_END_REASON[normalized] ?? null;
|
|
2468
2557
|
}
|
|
2469
2558
|
/** Return true when a provider status is terminal. */
|
|
2470
2559
|
function isProviderStatusTerminal(status) {
|
|
2471
2560
|
return mapProviderStatusToEndReason(status) !== null;
|
|
2472
2561
|
}
|
|
2473
2562
|
//#endregion
|
|
2563
|
+
//#region extensions/voice-call/src/proxy-ip.ts
|
|
2564
|
+
function normalizeProxyIp(value) {
|
|
2565
|
+
const trimmed = value?.trim();
|
|
2566
|
+
if (!trimmed) return;
|
|
2567
|
+
const normalized = (trimmed.startsWith("[") && trimmed.endsWith("]") ? trimmed.slice(1, -1) : trimmed).toLowerCase();
|
|
2568
|
+
if (normalized.startsWith("::ffff:")) {
|
|
2569
|
+
const mappedIpv4 = normalized.slice(7);
|
|
2570
|
+
if (/^\d{1,3}(?:\.\d{1,3}){3}$/.test(mappedIpv4)) return mappedIpv4;
|
|
2571
|
+
}
|
|
2572
|
+
return normalized;
|
|
2573
|
+
}
|
|
2574
|
+
//#endregion
|
|
2474
2575
|
//#region extensions/voice-call/src/webhook/stale-call-reaper.ts
|
|
2475
2576
|
const CHECK_INTERVAL_MS = 3e4;
|
|
2476
2577
|
/** States that indicate a live conversation with speech/transcription.
|
|
2477
2578
|
* Inbound Twilio calls may never fire a call.answered event, so answeredAt
|
|
2478
2579
|
* can be absent even while the call is actively transcribing. These states
|
|
2479
2580
|
* prove the call is live and should not be reaped. */
|
|
2480
|
-
const LiveConversationStates = new Set(["speaking", "listening"]);
|
|
2581
|
+
const LiveConversationStates = /* @__PURE__ */ new Set(["speaking", "listening"]);
|
|
2481
2582
|
/** Start a stale-call reaper and return its cleanup callback. */
|
|
2482
2583
|
function startStaleCallReaper(params) {
|
|
2483
2584
|
const maxAgeSeconds = params.staleCallReaperSeconds;
|
|
@@ -2508,11 +2609,11 @@ const MISSING_REMOTE_ADDRESS_IN_FLIGHT_KEY = "__voice_call_no_remote__";
|
|
|
2508
2609
|
const STREAM_DISCONNECT_HANGUP_GRACE_MS = 2e3;
|
|
2509
2610
|
const TRANSCRIPT_LOG_MAX_CHARS = 200;
|
|
2510
2611
|
const loadRealtimeTranscriptionRuntime = createLazyRuntimeModule(() => import("./realtime-transcription.runtime-CbJAs5t_.js"));
|
|
2511
|
-
const loadResponseGeneratorModule = createLazyRuntimeModule(() => import("./response-generator-
|
|
2612
|
+
const loadResponseGeneratorModule = createLazyRuntimeModule(() => import("./response-generator-PXuisI3L.js"));
|
|
2512
2613
|
function sanitizeTranscriptForLog(value) {
|
|
2513
2614
|
const sanitized = value.replace(/\p{Cc}/gu, " ").replace(/\s+/g, " ").trim();
|
|
2514
2615
|
if (sanitized.length <= TRANSCRIPT_LOG_MAX_CHARS) return sanitized;
|
|
2515
|
-
return `${sanitized
|
|
2616
|
+
return `${truncateUtf16Safe(sanitized, TRANSCRIPT_LOG_MAX_CHARS)}...`;
|
|
2516
2617
|
}
|
|
2517
2618
|
function appendRecentTalkEventMetadata(call, event) {
|
|
2518
2619
|
const metadata = call.metadata ?? {};
|
|
@@ -2533,16 +2634,6 @@ function appendRecentTalkEventMetadata(call, event) {
|
|
|
2533
2634
|
function buildRequestUrl(requestUrl) {
|
|
2534
2635
|
return new URL$1(requestUrl ?? "/", "http://localhost");
|
|
2535
2636
|
}
|
|
2536
|
-
function normalizeProxyIp(value) {
|
|
2537
|
-
const trimmed = value?.trim();
|
|
2538
|
-
if (!trimmed) return;
|
|
2539
|
-
const normalized = (trimmed.startsWith("[") && trimmed.endsWith("]") ? trimmed.slice(1, -1) : trimmed).toLowerCase();
|
|
2540
|
-
if (normalized.startsWith("::ffff:")) {
|
|
2541
|
-
const mappedIpv4 = normalized.slice(7);
|
|
2542
|
-
if (/^\d{1,3}(?:\.\d{1,3}){3}$/.test(mappedIpv4)) return mappedIpv4;
|
|
2543
|
-
}
|
|
2544
|
-
return normalized;
|
|
2545
|
-
}
|
|
2546
2637
|
function resolveForwardedClientIp(request, trustedProxyIPs) {
|
|
2547
2638
|
const normalizedTrustedProxyIps = new Set(trustedProxyIPs.map((ip) => normalizeProxyIp(ip)).filter((ip) => Boolean(ip)));
|
|
2548
2639
|
const forwardedFor = getHeader(request.headers, "x-forwarded-for");
|
|
@@ -2738,11 +2829,7 @@ var VoiceCallWebhookServer = class {
|
|
|
2738
2829
|
transcript,
|
|
2739
2830
|
isFinal: true
|
|
2740
2831
|
};
|
|
2741
|
-
this.
|
|
2742
|
-
const callMode = call.metadata?.mode;
|
|
2743
|
-
if (call.direction === "inbound" || callMode === "conversation") this.handleInboundResponse(call.callId, transcript).catch((err) => {
|
|
2744
|
-
console.warn(`[voice-call] Failed to auto-respond:`, err);
|
|
2745
|
-
});
|
|
2832
|
+
this.processEventWithAutoResponse(event);
|
|
2746
2833
|
},
|
|
2747
2834
|
onSpeechStart: (providerCallId) => {
|
|
2748
2835
|
if (this.provider.name !== "twilio") return;
|
|
@@ -2881,15 +2968,8 @@ var VoiceCallWebhookServer = class {
|
|
|
2881
2968
|
return null;
|
|
2882
2969
|
}
|
|
2883
2970
|
}
|
|
2884
|
-
normalizeWebhookPathForMatch(pathname) {
|
|
2885
|
-
const trimmed = pathname.trim();
|
|
2886
|
-
if (!trimmed) return "/";
|
|
2887
|
-
const prefixed = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
2888
|
-
if (prefixed === "/") return prefixed;
|
|
2889
|
-
return prefixed.endsWith("/") ? prefixed.slice(0, -1) : prefixed;
|
|
2890
|
-
}
|
|
2891
2971
|
isWebhookPathMatch(requestPath, configuredPath) {
|
|
2892
|
-
return
|
|
2972
|
+
return normalizeWebhookPath(requestPath) === normalizeWebhookPath(configuredPath);
|
|
2893
2973
|
}
|
|
2894
2974
|
/**
|
|
2895
2975
|
* Handle incoming HTTP request.
|
|
@@ -3084,8 +3164,8 @@ var VoiceCallWebhookServer = class {
|
|
|
3084
3164
|
const pathname = buildRequestUrl(req.url).pathname;
|
|
3085
3165
|
const pattern = this.realtimeHandler?.getStreamPathPattern();
|
|
3086
3166
|
if (!pattern) return false;
|
|
3087
|
-
const normalizedPattern =
|
|
3088
|
-
const normalizedPathname =
|
|
3167
|
+
const normalizedPattern = normalizeWebhookPath(pattern);
|
|
3168
|
+
const normalizedPathname = normalizeWebhookPath(pathname);
|
|
3089
3169
|
if (normalizedPattern === "/") return true;
|
|
3090
3170
|
return normalizedPathname === normalizedPattern || normalizedPathname.startsWith(`${normalizedPattern}/`);
|
|
3091
3171
|
} catch {
|
|
@@ -3112,11 +3192,20 @@ var VoiceCallWebhookServer = class {
|
|
|
3112
3192
|
}
|
|
3113
3193
|
processParsedEvents(events) {
|
|
3114
3194
|
for (const event of events) try {
|
|
3115
|
-
this.
|
|
3195
|
+
this.processEventWithAutoResponse(event);
|
|
3116
3196
|
} catch (err) {
|
|
3117
3197
|
console.error(`[voice-call] Error processing event ${event.type}:`, err);
|
|
3118
3198
|
}
|
|
3119
3199
|
}
|
|
3200
|
+
processEventWithAutoResponse(event) {
|
|
3201
|
+
const result = this.manager.processEvent(event);
|
|
3202
|
+
if (result.kind !== "final-speech" || result.waiterResolved) return;
|
|
3203
|
+
const callMode = result.call.metadata?.mode;
|
|
3204
|
+
if (result.call.direction !== "inbound" && callMode !== "conversation") return;
|
|
3205
|
+
this.handleInboundResponse(result.call.callId, result.transcript).catch((err) => {
|
|
3206
|
+
console.warn(`[voice-call] Failed to auto-respond:`, err);
|
|
3207
|
+
});
|
|
3208
|
+
}
|
|
3120
3209
|
writeWebhookResponse(res, payload) {
|
|
3121
3210
|
res.statusCode = payload.statusCode;
|
|
3122
3211
|
if (payload.headers) for (const [key, value] of Object.entries(payload.headers)) res.setHeader(key, value);
|
|
@@ -3161,16 +3250,21 @@ var VoiceCallWebhookServer = class {
|
|
|
3161
3250
|
callId,
|
|
3162
3251
|
sessionKey: call.sessionKey,
|
|
3163
3252
|
from: call.from,
|
|
3253
|
+
agentId: resolveCallAgentId(call, effectiveConfig),
|
|
3164
3254
|
transcript: call.transcript,
|
|
3165
|
-
userMessage
|
|
3255
|
+
userMessage,
|
|
3256
|
+
onEarlyText: async (text) => {
|
|
3257
|
+
console.log(`[voice-call] Early AI response: "${text}"`);
|
|
3258
|
+
return (await this.manager.speak(callId, text, { listenAfterPlayback: true })).success;
|
|
3259
|
+
}
|
|
3166
3260
|
});
|
|
3167
3261
|
if (result.error) {
|
|
3168
3262
|
console.error(`[voice-call] Response generation error: ${result.error}`);
|
|
3169
3263
|
return;
|
|
3170
3264
|
}
|
|
3171
|
-
if (result.text) {
|
|
3265
|
+
if (result.text && !result.deliveredEarly) {
|
|
3172
3266
|
console.log(`[voice-call] AI response: "${result.text}"`);
|
|
3173
|
-
await this.manager.speak(callId, result.text);
|
|
3267
|
+
await this.manager.speak(callId, result.text, { listenAfterPlayback: true });
|
|
3174
3268
|
}
|
|
3175
3269
|
} catch (err) {
|
|
3176
3270
|
console.error(`[voice-call] Auto-response error:`, err);
|
|
@@ -3187,12 +3281,12 @@ const REALTIME_VOICE_CONSULT_SYSTEM_PROMPT = [
|
|
|
3187
3281
|
"Do not print secret values or dump environment variables; only check whether required configuration is present.",
|
|
3188
3282
|
"Be accurate, brief, and speakable."
|
|
3189
3283
|
].join(" ");
|
|
3190
|
-
const loadTelnyxProvider = createLazyRuntimeModule(() => import("./telnyx-
|
|
3191
|
-
const loadTwilioProvider = createLazyRuntimeModule(() => import("./twilio-
|
|
3192
|
-
const loadPlivoProvider = createLazyRuntimeModule(() => import("./plivo-
|
|
3193
|
-
const loadMockProvider = createLazyRuntimeModule(() => import("./mock-
|
|
3284
|
+
const loadTelnyxProvider = createLazyRuntimeModule(() => import("./telnyx-DTHQGeaW.js"));
|
|
3285
|
+
const loadTwilioProvider = createLazyRuntimeModule(() => import("./twilio-xNIXGJ-M.js"));
|
|
3286
|
+
const loadPlivoProvider = createLazyRuntimeModule(() => import("./plivo-BnCuAGwj.js"));
|
|
3287
|
+
const loadMockProvider = createLazyRuntimeModule(() => import("./mock-YsvBTX-7.js"));
|
|
3194
3288
|
const loadRealtimeVoiceRuntime = createLazyRuntimeModule(() => import("./realtime-voice.runtime-vtdCOWg-.js"));
|
|
3195
|
-
const loadRealtimeHandler = createLazyRuntimeModule(() => import("./realtime-handler-
|
|
3289
|
+
const loadRealtimeHandler = createLazyRuntimeModule(() => import("./realtime-handler-Bz-MNWtD.js"));
|
|
3196
3290
|
function resolveVoiceCallConsultSessionKey(call) {
|
|
3197
3291
|
return resolveVoiceCallSessionKey({
|
|
3198
3292
|
config: call.config,
|
|
@@ -3259,7 +3353,8 @@ async function resolveProvider(config) {
|
|
|
3259
3353
|
const { TwilioProvider } = await loadTwilioProvider();
|
|
3260
3354
|
return new TwilioProvider({
|
|
3261
3355
|
accountSid: config.twilio?.accountSid,
|
|
3262
|
-
authToken: resolveTwilioAuthToken(config)
|
|
3356
|
+
authToken: resolveTwilioAuthToken(config),
|
|
3357
|
+
region: config.twilio?.region
|
|
3263
3358
|
}, {
|
|
3264
3359
|
allowNgrokFreeTierLoopbackBypass,
|
|
3265
3360
|
publicUrl: config.publicUrl,
|
|
@@ -3295,6 +3390,47 @@ async function resolveRealtimeProvider(params) {
|
|
|
3295
3390
|
cfg: params.fullConfig
|
|
3296
3391
|
});
|
|
3297
3392
|
}
|
|
3393
|
+
function listRealtimeAgentIds(config, coreConfig) {
|
|
3394
|
+
const agentIds = /* @__PURE__ */ new Set([normalizeAgentId(config.agentId)]);
|
|
3395
|
+
for (const agent of coreConfig.agents?.list ?? []) agentIds.add(normalizeAgentId(agent.id));
|
|
3396
|
+
for (const route of Object.values(config.numbers)) if (route.agentId) agentIds.add(normalizeAgentId(route.agentId));
|
|
3397
|
+
return [...agentIds];
|
|
3398
|
+
}
|
|
3399
|
+
async function createRealtimeInstructionsResolver(params) {
|
|
3400
|
+
const genericConfig = {
|
|
3401
|
+
...params.config,
|
|
3402
|
+
realtime: {
|
|
3403
|
+
...params.config.realtime,
|
|
3404
|
+
agentContext: {
|
|
3405
|
+
...params.config.realtime.agentContext,
|
|
3406
|
+
enabled: false
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
};
|
|
3410
|
+
const genericInstructions = await buildRealtimeVoiceInstructions({
|
|
3411
|
+
baseInstructions: params.config.realtime.instructions,
|
|
3412
|
+
config: genericConfig,
|
|
3413
|
+
coreConfig: params.coreConfig,
|
|
3414
|
+
agentRuntime: params.agentRuntime
|
|
3415
|
+
});
|
|
3416
|
+
const entries = await Promise.all(listRealtimeAgentIds(params.config, params.coreConfig).map(async (agentId) => {
|
|
3417
|
+
return [agentId, await buildRealtimeVoiceInstructions({
|
|
3418
|
+
baseInstructions: params.config.realtime.instructions,
|
|
3419
|
+
config: {
|
|
3420
|
+
...params.config,
|
|
3421
|
+
agentId
|
|
3422
|
+
},
|
|
3423
|
+
coreConfig: params.coreConfig,
|
|
3424
|
+
agentRuntime: params.agentRuntime
|
|
3425
|
+
})];
|
|
3426
|
+
}));
|
|
3427
|
+
const instructionsByAgentId = new Map(entries);
|
|
3428
|
+
return (call) => {
|
|
3429
|
+
const numberRouteKey = resolveVoiceCallNumberRouteKeyForCall(call);
|
|
3430
|
+
const effectiveConfig = resolveVoiceCallEffectiveConfig(params.config, numberRouteKey).config;
|
|
3431
|
+
return instructionsByAgentId.get(resolveCallAgentId(call, effectiveConfig)) ?? genericInstructions;
|
|
3432
|
+
};
|
|
3433
|
+
}
|
|
3298
3434
|
async function createVoiceCallRuntime(params) {
|
|
3299
3435
|
const { config: rawConfig, coreConfig, fullConfig, agentRuntime, stateRuntime, ttsRuntime, logger } = params;
|
|
3300
3436
|
const log = logger ?? {
|
|
@@ -3319,25 +3455,27 @@ async function createVoiceCallRuntime(params) {
|
|
|
3319
3455
|
const webhookServer = new VoiceCallWebhookServer(config, manager, provider, coreConfig, fullConfig ?? coreConfig, agentRuntime, log);
|
|
3320
3456
|
if (realtimeProvider) {
|
|
3321
3457
|
const { RealtimeCallHandler } = await loadRealtimeHandler();
|
|
3322
|
-
const
|
|
3323
|
-
baseInstructions: config.realtime.instructions,
|
|
3458
|
+
const resolveRealtimeInstructions = await createRealtimeInstructionsResolver({
|
|
3324
3459
|
config,
|
|
3325
|
-
coreConfig,
|
|
3460
|
+
coreConfig: cfg,
|
|
3326
3461
|
agentRuntime
|
|
3327
3462
|
});
|
|
3328
3463
|
const realtimeHandler = new RealtimeCallHandler({
|
|
3329
3464
|
...config.realtime,
|
|
3330
|
-
instructions: realtimeInstructions,
|
|
3331
3465
|
tools: resolveRealtimeVoiceAgentConsultTools(config.realtime.toolPolicy, config.realtime.tools)
|
|
3332
|
-
}, manager, provider, realtimeProvider.provider, realtimeProvider.providerConfig, config.serve.path, cfg);
|
|
3466
|
+
}, manager, provider, realtimeProvider.provider, realtimeProvider.providerConfig, config.serve.path, cfg, resolveRealtimeInstructions);
|
|
3333
3467
|
if (config.realtime.toolPolicy !== "none") realtimeHandler.registerToolHandler(REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME, async (args, callId, handlerContext) => {
|
|
3334
3468
|
const call = manager.getCall(callId);
|
|
3335
3469
|
if (!call) return { error: `Call "${callId}" not found` };
|
|
3336
|
-
const
|
|
3337
|
-
const
|
|
3470
|
+
const numberRouteKey = resolveVoiceCallNumberRouteKeyForCall(call);
|
|
3471
|
+
const effectiveConfig = resolveVoiceCallEffectiveConfig(config, numberRouteKey).config;
|
|
3472
|
+
const agentId = resolveCallAgentId(call, effectiveConfig);
|
|
3338
3473
|
const sessionKey = resolveVoiceCallConsultSessionKey({
|
|
3339
3474
|
...call,
|
|
3340
|
-
config:
|
|
3475
|
+
config: {
|
|
3476
|
+
...effectiveConfig,
|
|
3477
|
+
agentId
|
|
3478
|
+
},
|
|
3341
3479
|
coreSession: cfg.session
|
|
3342
3480
|
});
|
|
3343
3481
|
const requesterSessionKey = typeof call.metadata?.requesterSessionKey === "string" ? call.metadata.requesterSessionKey : void 0;
|
|
@@ -3456,4 +3594,4 @@ async function createVoiceCallRuntime(params) {
|
|
|
3456
3594
|
}
|
|
3457
3595
|
}
|
|
3458
3596
|
//#endregion
|
|
3459
|
-
export {
|
|
3597
|
+
export { mapVoiceToPolly as _, normalizeProviderStatus as a, cleanupTailscaleExposureRoute as c, TELEPHONY_DEFAULT_TTS_TIMEOUT_MS as d, chunkAudio as f, escapeXml as g, resolveUserPath as h, mapProviderStatusToEndReason as i, getTailscaleSelfInfo as l, resolveCallAgentId as m, normalizeProxyIp as n, getHeader as o, resolveVoiceResponseModel as p, isProviderStatusTerminal as r, resolveWebhookExposureStatus as s, createVoiceCallRuntime as t, setupTailscaleExposureRoute as u };
|