@openclaw/voice-call 2026.7.1-beta.1 → 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-Dnyy7xHB.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-sCM3Jvjh.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-Cwb6vEQf.js → runtime-entry-kCq5Xjph.js} +237 -130
- 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-LSKUJimK.js → telnyx-DTHQGeaW.js} +1 -1
- package/dist/{twilio-GBk6YOP_.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-DOdrErIH.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,24 +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";
|
|
10
|
+
import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
|
|
9
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";
|
|
10
13
|
import fs from "node:fs";
|
|
11
14
|
import os from "node:os";
|
|
12
15
|
import path from "node:path";
|
|
13
16
|
import crypto from "node:crypto";
|
|
14
17
|
import { root } from "openclaw/plugin-sdk/security-runtime";
|
|
18
|
+
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
15
19
|
import { parseTtsDirectives } from "openclaw/plugin-sdk/speech";
|
|
16
20
|
import { spawn } from "node:child_process";
|
|
17
21
|
import http from "node:http";
|
|
18
22
|
import { URL as URL$1 } from "node:url";
|
|
19
23
|
import { resolveConfiguredCapabilityProvider } from "openclaw/plugin-sdk/provider-selection-runtime";
|
|
20
|
-
import {
|
|
21
|
-
import { WebSocket as WebSocket$1, WebSocketServer } from "ws";
|
|
24
|
+
import { WebSocket, WebSocketServer } from "ws";
|
|
22
25
|
//#region extensions/voice-call/src/allowlist.ts
|
|
23
26
|
/** Normalize a phone number to digits only. */
|
|
24
27
|
function normalizePhoneNumber(input) {
|
|
@@ -35,7 +38,7 @@ function isAllowlistedCaller(normalizedFrom, allowFrom) {
|
|
|
35
38
|
}
|
|
36
39
|
//#endregion
|
|
37
40
|
//#region extensions/voice-call/src/manager/state.ts
|
|
38
|
-
const ConversationStates = new Set(["speaking", "listening"]);
|
|
41
|
+
const ConversationStates = /* @__PURE__ */ new Set(["speaking", "listening"]);
|
|
39
42
|
const StateOrder = [
|
|
40
43
|
"initiated",
|
|
41
44
|
"ringing",
|
|
@@ -310,6 +313,7 @@ async function initiateCall(ctx, to, sessionKey, options) {
|
|
|
310
313
|
const mode = opts.mode ?? ctx.config.outbound.defaultMode;
|
|
311
314
|
const dtmfSequence = opts.dtmfSequence;
|
|
312
315
|
const requesterSessionKey = opts.requesterSessionKey?.trim();
|
|
316
|
+
const agentId = normalizeAgentId(opts.agentId ?? ctx.config.agentId);
|
|
313
317
|
if (dtmfSequence) {
|
|
314
318
|
const validationError = validateDtmfDigits(dtmfSequence);
|
|
315
319
|
if (validationError) return {
|
|
@@ -353,12 +357,16 @@ async function initiateCall(ctx, to, sessionKey, options) {
|
|
|
353
357
|
from,
|
|
354
358
|
to,
|
|
355
359
|
sessionKey: resolveVoiceCallSessionKey({
|
|
356
|
-
config:
|
|
360
|
+
config: {
|
|
361
|
+
...ctx.config,
|
|
362
|
+
agentId
|
|
363
|
+
},
|
|
357
364
|
callId,
|
|
358
365
|
phone: to,
|
|
359
366
|
explicitSessionKey: sessionKey,
|
|
360
367
|
coreSession: ctx.coreSession
|
|
361
368
|
}),
|
|
369
|
+
agentId,
|
|
362
370
|
startedAt: Date.now(),
|
|
363
371
|
transcript: [],
|
|
364
372
|
processedEventIds: [],
|
|
@@ -421,7 +429,7 @@ async function initiateCall(ctx, to, sessionKey, options) {
|
|
|
421
429
|
};
|
|
422
430
|
}
|
|
423
431
|
}
|
|
424
|
-
async function speak(ctx, callId, text) {
|
|
432
|
+
async function speak(ctx, callId, text, options) {
|
|
425
433
|
const connected = requireConnectedCall(ctx, callId);
|
|
426
434
|
if (!connected.ok) return {
|
|
427
435
|
success: false,
|
|
@@ -441,11 +449,13 @@ async function speak(ctx, callId, text) {
|
|
|
441
449
|
persistCallRecord(ctx.storePath, call);
|
|
442
450
|
const numberRouteKey = resolveVoiceCallNumberRouteKeyForCall(call);
|
|
443
451
|
const voice = resolvePreferredTtsVoice(resolveVoiceCallEffectiveConfig(ctx.config, numberRouteKey).config);
|
|
452
|
+
const playbackOptions = options?.listenAfterPlayback ? { listenAfterPlayback: true } : {};
|
|
444
453
|
await provider.playTts({
|
|
445
454
|
callId,
|
|
446
455
|
providerCallId,
|
|
447
456
|
text,
|
|
448
|
-
voice
|
|
457
|
+
voice,
|
|
458
|
+
...playbackOptions
|
|
449
459
|
});
|
|
450
460
|
addTranscriptEntry(call, "bot", text);
|
|
451
461
|
persistCallRecord(ctx.storePath, call);
|
|
@@ -676,6 +686,7 @@ function createWebhookCall(params) {
|
|
|
676
686
|
callId,
|
|
677
687
|
phone: params.direction === "outbound" ? params.to : params.from
|
|
678
688
|
}),
|
|
689
|
+
agentId: normalizeAgentId(effectiveConfig.agentId),
|
|
679
690
|
startedAt: Date.now(),
|
|
680
691
|
transcript: [],
|
|
681
692
|
processedEventIds: [],
|
|
@@ -712,7 +723,7 @@ function persistRejectedInboundCall(params) {
|
|
|
712
723
|
}
|
|
713
724
|
function processEvent(ctx, event) {
|
|
714
725
|
const dedupeKey = event.dedupeKey || event.id;
|
|
715
|
-
if (ctx.processedEventIds.has(dedupeKey)) return;
|
|
726
|
+
if (ctx.processedEventIds.has(dedupeKey)) return { kind: "ignored" };
|
|
716
727
|
let call = findCall({
|
|
717
728
|
activeCalls: ctx.activeCalls,
|
|
718
729
|
providerCallIdMap: ctx.providerCallIdMap,
|
|
@@ -725,10 +736,10 @@ function processEvent(ctx, event) {
|
|
|
725
736
|
const pid = providerCallId;
|
|
726
737
|
if (!ctx.provider) {
|
|
727
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.`);
|
|
728
|
-
return;
|
|
739
|
+
return { kind: "ignored" };
|
|
729
740
|
}
|
|
730
741
|
ctx.processedEventIds.add(dedupeKey);
|
|
731
|
-
if (ctx.rejectedProviderCallIds.has(pid)) return;
|
|
742
|
+
if (ctx.rejectedProviderCallIds.has(pid)) return { kind: "ignored" };
|
|
732
743
|
ctx.rejectedProviderCallIds.add(pid);
|
|
733
744
|
const callId = event.callId ?? pid;
|
|
734
745
|
persistRejectedInboundCall({
|
|
@@ -747,7 +758,7 @@ function processEvent(ctx, event) {
|
|
|
747
758
|
const message = formatErrorMessage(err);
|
|
748
759
|
console.warn(`[voice-call] Failed to reject inbound call ${pid}:`, message);
|
|
749
760
|
});
|
|
750
|
-
return;
|
|
761
|
+
return { kind: "processed" };
|
|
751
762
|
}
|
|
752
763
|
call = createWebhookCall({
|
|
753
764
|
ctx,
|
|
@@ -758,7 +769,7 @@ function processEvent(ctx, event) {
|
|
|
758
769
|
});
|
|
759
770
|
event.callId = call.callId;
|
|
760
771
|
}
|
|
761
|
-
if (!call) return;
|
|
772
|
+
if (!call) return { kind: "ignored" };
|
|
762
773
|
if (event.providerCallId && event.providerCallId !== call.providerCallId) {
|
|
763
774
|
const previousProviderCallId = call.providerCallId;
|
|
764
775
|
call.providerCallId = event.providerCallId;
|
|
@@ -771,6 +782,7 @@ function processEvent(ctx, event) {
|
|
|
771
782
|
ctx.processedEventIds.add(dedupeKey);
|
|
772
783
|
call.processedEventIds.push(dedupeKey);
|
|
773
784
|
}
|
|
785
|
+
let result = { kind: "processed" };
|
|
774
786
|
switch (event.type) {
|
|
775
787
|
case "call.initiated":
|
|
776
788
|
transitionState(call, "initiated");
|
|
@@ -814,6 +826,7 @@ function processEvent(ctx, event) {
|
|
|
814
826
|
transitionState(call, "active");
|
|
815
827
|
break;
|
|
816
828
|
case "call.speaking":
|
|
829
|
+
case "call.assistant-speech":
|
|
817
830
|
ensureMaxDurationTimerForLiveCall({
|
|
818
831
|
ctx,
|
|
819
832
|
call,
|
|
@@ -823,6 +836,7 @@ function processEvent(ctx, event) {
|
|
|
823
836
|
}
|
|
824
837
|
});
|
|
825
838
|
transitionState(call, "speaking");
|
|
839
|
+
if (event.type === "call.assistant-speech" && event.transcript.trim()) addTranscriptEntry(call, "bot", event.transcript);
|
|
826
840
|
break;
|
|
827
841
|
case "call.speech":
|
|
828
842
|
if (event.isFinal) {
|
|
@@ -830,9 +844,16 @@ function processEvent(ctx, event) {
|
|
|
830
844
|
const resolved = resolveTranscriptWaiter(ctx, call.callId, event.transcript, event.turnToken);
|
|
831
845
|
if (hadWaiter && !resolved) {
|
|
832
846
|
console.warn(`[voice-call] Ignoring speech event with mismatched turn token for ${call.callId}`);
|
|
847
|
+
result = { kind: "ignored" };
|
|
833
848
|
break;
|
|
834
849
|
}
|
|
835
850
|
addTranscriptEntry(call, "user", event.transcript);
|
|
851
|
+
result = {
|
|
852
|
+
kind: "final-speech",
|
|
853
|
+
call,
|
|
854
|
+
transcript: event.transcript,
|
|
855
|
+
waiterResolved: resolved
|
|
856
|
+
};
|
|
836
857
|
}
|
|
837
858
|
ensureMaxDurationTimerForLiveCall({
|
|
838
859
|
ctx,
|
|
@@ -853,7 +874,7 @@ function processEvent(ctx, event) {
|
|
|
853
874
|
endReason: event.reason,
|
|
854
875
|
endedAt: event.timestamp
|
|
855
876
|
});
|
|
856
|
-
return;
|
|
877
|
+
return { kind: "processed" };
|
|
857
878
|
case "call.error":
|
|
858
879
|
if (!event.retryable) {
|
|
859
880
|
finalizeCall({
|
|
@@ -863,11 +884,12 @@ function processEvent(ctx, event) {
|
|
|
863
884
|
endedAt: event.timestamp,
|
|
864
885
|
transcriptRejectReason: `Call error: ${event.error}`
|
|
865
886
|
});
|
|
866
|
-
return;
|
|
887
|
+
return { kind: "processed" };
|
|
867
888
|
}
|
|
868
889
|
break;
|
|
869
890
|
}
|
|
870
891
|
persistCallRecord(ctx.storePath, call);
|
|
892
|
+
return result;
|
|
871
893
|
}
|
|
872
894
|
//#endregion
|
|
873
895
|
//#region extensions/voice-call/src/utils.ts
|
|
@@ -1052,8 +1074,8 @@ var CallManager = class {
|
|
|
1052
1074
|
/**
|
|
1053
1075
|
* Speak to user in an active call.
|
|
1054
1076
|
*/
|
|
1055
|
-
async speak(callId, text) {
|
|
1056
|
-
return speak(this.getContext(), callId, text);
|
|
1077
|
+
async speak(callId, text, options) {
|
|
1078
|
+
return speak(this.getContext(), callId, text, options);
|
|
1057
1079
|
}
|
|
1058
1080
|
/**
|
|
1059
1081
|
* Send DTMF digits to an active call.
|
|
@@ -1104,7 +1126,7 @@ var CallManager = class {
|
|
|
1104
1126
|
* Process a webhook event.
|
|
1105
1127
|
*/
|
|
1106
1128
|
processEvent(event) {
|
|
1107
|
-
processEvent(this.getContext(), event);
|
|
1129
|
+
return processEvent(this.getContext(), event);
|
|
1108
1130
|
}
|
|
1109
1131
|
shouldDeferConversationInitialMessageUntilStreamConnect() {
|
|
1110
1132
|
if (!this.provider || this.provider.name !== "twilio" || !this.config.streaming.enabled) return false;
|
|
@@ -1146,6 +1168,13 @@ var CallManager = class {
|
|
|
1146
1168
|
getActiveCalls() {
|
|
1147
1169
|
return Array.from(this.activeCalls.values());
|
|
1148
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
|
+
}
|
|
1149
1178
|
/**
|
|
1150
1179
|
* Get call history (from persisted logs).
|
|
1151
1180
|
*/
|
|
@@ -1158,7 +1187,7 @@ var CallManager = class {
|
|
|
1158
1187
|
/** Limit injected context while preserving an explicit truncation marker. */
|
|
1159
1188
|
function limitText(text, maxChars) {
|
|
1160
1189
|
if (text.length <= maxChars) return text;
|
|
1161
|
-
return `${text
|
|
1190
|
+
return `${truncateUtf16Safe(text, Math.max(0, maxChars - 32)).trimEnd()}\n[truncated]`;
|
|
1162
1191
|
}
|
|
1163
1192
|
/** Read configured workspace context files through the safe workspace root. */
|
|
1164
1193
|
async function readWorkspaceVoiceContextFiles(params) {
|
|
@@ -1226,6 +1255,12 @@ async function resolveRealtimeFastContextConsult(params) {
|
|
|
1226
1255
|
});
|
|
1227
1256
|
}
|
|
1228
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
|
|
1229
1264
|
//#region extensions/voice-call/src/response-model.ts
|
|
1230
1265
|
/** Resolve provider/model fields from explicit voice config or agent defaults. */
|
|
1231
1266
|
function resolveVoiceResponseModel(params) {
|
|
@@ -1350,7 +1385,7 @@ function collectTelephonyProviderConfigs(ttsConfig) {
|
|
|
1350
1385
|
const normalized = normalizeProviderId(providerId) ?? providerId;
|
|
1351
1386
|
entries[normalized] = asProviderConfig(value);
|
|
1352
1387
|
}
|
|
1353
|
-
const reservedKeys = new Set([
|
|
1388
|
+
const reservedKeys = /* @__PURE__ */ new Set([
|
|
1354
1389
|
"auto",
|
|
1355
1390
|
"enabled",
|
|
1356
1391
|
"maxTextLength",
|
|
@@ -1434,6 +1469,13 @@ function runTailscaleCommand(args, timeoutMs = 2500) {
|
|
|
1434
1469
|
clearTimeout(timer);
|
|
1435
1470
|
resolve(result);
|
|
1436
1471
|
};
|
|
1472
|
+
const timer = setTimeout(() => {
|
|
1473
|
+
proc.kill("SIGKILL");
|
|
1474
|
+
finish({
|
|
1475
|
+
code: -1,
|
|
1476
|
+
stdout: ""
|
|
1477
|
+
});
|
|
1478
|
+
}, timeoutMs);
|
|
1437
1479
|
proc.stdout.on("data", (data) => {
|
|
1438
1480
|
stdout = appendTailscaleCommandStdout(stdout, data);
|
|
1439
1481
|
if (stdout.exceeded) {
|
|
@@ -1444,13 +1486,13 @@ function runTailscaleCommand(args, timeoutMs = 2500) {
|
|
|
1444
1486
|
});
|
|
1445
1487
|
}
|
|
1446
1488
|
});
|
|
1447
|
-
|
|
1489
|
+
proc.stdout.on("error", () => {
|
|
1448
1490
|
proc.kill("SIGKILL");
|
|
1449
1491
|
finish({
|
|
1450
1492
|
code: -1,
|
|
1451
1493
|
stdout: ""
|
|
1452
1494
|
});
|
|
1453
|
-
}
|
|
1495
|
+
});
|
|
1454
1496
|
proc.on("error", () => {
|
|
1455
1497
|
finish({
|
|
1456
1498
|
code: -1,
|
|
@@ -1534,6 +1576,10 @@ async function cleanupTailscaleExposure(config) {
|
|
|
1534
1576
|
//#endregion
|
|
1535
1577
|
//#region extensions/voice-call/src/tunnel.ts
|
|
1536
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
|
+
}
|
|
1537
1583
|
/**
|
|
1538
1584
|
* Start an ngrok tunnel to expose the local webhook server.
|
|
1539
1585
|
*
|
|
@@ -1566,6 +1612,7 @@ async function startNgrokTunnel(config) {
|
|
|
1566
1612
|
"pipe"
|
|
1567
1613
|
] });
|
|
1568
1614
|
let resolved = false;
|
|
1615
|
+
let closed = false;
|
|
1569
1616
|
let publicUrl = null;
|
|
1570
1617
|
let outputBuffer = "";
|
|
1571
1618
|
const timeout = setTimeout(() => {
|
|
@@ -1575,6 +1622,14 @@ async function startNgrokTunnel(config) {
|
|
|
1575
1622
|
reject(/* @__PURE__ */ new Error("ngrok startup timed out (30s)"));
|
|
1576
1623
|
}
|
|
1577
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
|
+
};
|
|
1578
1633
|
const processLine = (line) => {
|
|
1579
1634
|
try {
|
|
1580
1635
|
const log = JSON.parse(line);
|
|
@@ -1589,10 +1644,24 @@ async function startNgrokTunnel(config) {
|
|
|
1589
1644
|
publicUrl: fullUrl,
|
|
1590
1645
|
provider: "ngrok",
|
|
1591
1646
|
stop: async () => {
|
|
1592
|
-
|
|
1647
|
+
if (closed) return;
|
|
1593
1648
|
await new Promise((res) => {
|
|
1594
|
-
|
|
1595
|
-
|
|
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();
|
|
1596
1665
|
});
|
|
1597
1666
|
}
|
|
1598
1667
|
});
|
|
@@ -1607,23 +1676,16 @@ async function startNgrokTunnel(config) {
|
|
|
1607
1676
|
});
|
|
1608
1677
|
proc.stderr.on("data", (data) => {
|
|
1609
1678
|
const msg = data.toString();
|
|
1610
|
-
if (msg.includes("ERR_NGROK")) {
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
const output = appendBoundedChildOutput(emptyBoundedChildOutput(), msg);
|
|
1615
|
-
reject(/* @__PURE__ */ new Error(`ngrok error: ${formatBoundedChildOutput(output)}`));
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
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);
|
|
1618
1683
|
});
|
|
1619
1684
|
proc.on("error", (err) => {
|
|
1620
|
-
|
|
1621
|
-
resolved = true;
|
|
1622
|
-
clearTimeout(timeout);
|
|
1623
|
-
reject(/* @__PURE__ */ new Error(`Failed to start ngrok: ${err.message}`));
|
|
1624
|
-
}
|
|
1685
|
+
rejectIfPending(`Failed to start ngrok: ${err.message}`);
|
|
1625
1686
|
});
|
|
1626
1687
|
proc.on("close", (code) => {
|
|
1688
|
+
closed = true;
|
|
1627
1689
|
if (!resolved) {
|
|
1628
1690
|
resolved = true;
|
|
1629
1691
|
clearTimeout(timeout);
|
|
@@ -1644,20 +1706,32 @@ async function runNgrokCommand(args) {
|
|
|
1644
1706
|
] });
|
|
1645
1707
|
let stdout = emptyBoundedChildOutput();
|
|
1646
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
|
+
};
|
|
1647
1716
|
proc.stdout.on("data", (data) => {
|
|
1648
1717
|
stdout = appendBoundedChildOutput(stdout, data.toString());
|
|
1649
1718
|
});
|
|
1650
1719
|
proc.stderr.on("data", (data) => {
|
|
1651
1720
|
stderr = appendBoundedChildOutput(stderr, data.toString());
|
|
1652
1721
|
});
|
|
1722
|
+
listenForChildStreamErrors(proc, (stream, error) => {
|
|
1723
|
+
rejectIfPending(/* @__PURE__ */ new Error(`ngrok command ${stream} error: ${error.message}`), true);
|
|
1724
|
+
});
|
|
1653
1725
|
proc.on("close", (code) => {
|
|
1726
|
+
if (settled) return;
|
|
1727
|
+
settled = true;
|
|
1654
1728
|
if (code === 0) resolve(stdout.text);
|
|
1655
1729
|
else {
|
|
1656
1730
|
const output = stderr.text ? stderr : stdout;
|
|
1657
1731
|
reject(/* @__PURE__ */ new Error(`ngrok command failed: ${formatBoundedChildOutput(output)}`));
|
|
1658
1732
|
}
|
|
1659
1733
|
});
|
|
1660
|
-
proc.on("error",
|
|
1734
|
+
proc.on("error", (error) => rejectIfPending(error));
|
|
1661
1735
|
});
|
|
1662
1736
|
}
|
|
1663
1737
|
/**
|
|
@@ -1681,11 +1755,18 @@ async function startTailscaleTunnel(config) {
|
|
|
1681
1755
|
"pipe",
|
|
1682
1756
|
"pipe"
|
|
1683
1757
|
] });
|
|
1758
|
+
let resolved = false;
|
|
1684
1759
|
let stdout = emptyBoundedChildOutput();
|
|
1685
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
|
+
};
|
|
1686
1768
|
const timeout = setTimeout(() => {
|
|
1687
|
-
|
|
1688
|
-
reject(/* @__PURE__ */ new Error(`Tailscale ${config.mode} timed out`));
|
|
1769
|
+
rejectIfPending(/* @__PURE__ */ new Error(`Tailscale ${config.mode} timed out`), true);
|
|
1689
1770
|
}, 1e4);
|
|
1690
1771
|
proc.stdout.on("data", (data) => {
|
|
1691
1772
|
stdout = appendBoundedChildOutput(stdout, data.toString());
|
|
@@ -1693,8 +1774,13 @@ async function startTailscaleTunnel(config) {
|
|
|
1693
1774
|
proc.stderr.on("data", (data) => {
|
|
1694
1775
|
stderr = appendBoundedChildOutput(stderr, data.toString());
|
|
1695
1776
|
});
|
|
1777
|
+
listenForChildStreamErrors(proc, (stream, error) => {
|
|
1778
|
+
rejectIfPending(/* @__PURE__ */ new Error(`Tailscale ${config.mode} ${stream} error: ${error.message}`), true);
|
|
1779
|
+
});
|
|
1696
1780
|
proc.on("close", (code) => {
|
|
1697
1781
|
clearTimeout(timeout);
|
|
1782
|
+
if (resolved) return;
|
|
1783
|
+
resolved = true;
|
|
1698
1784
|
if (code === 0) {
|
|
1699
1785
|
const publicUrl = `https://${dnsName}${path}`;
|
|
1700
1786
|
console.log(`[voice-call] Tailscale ${config.mode} active: ${publicUrl}`);
|
|
@@ -1712,8 +1798,7 @@ async function startTailscaleTunnel(config) {
|
|
|
1712
1798
|
}
|
|
1713
1799
|
});
|
|
1714
1800
|
proc.on("error", (err) => {
|
|
1715
|
-
|
|
1716
|
-
reject(err);
|
|
1801
|
+
rejectIfPending(err);
|
|
1717
1802
|
});
|
|
1718
1803
|
});
|
|
1719
1804
|
}
|
|
@@ -1735,6 +1820,10 @@ async function stopTailscaleTunnel(mode, path) {
|
|
|
1735
1820
|
clearTimeout(timeout);
|
|
1736
1821
|
resolve();
|
|
1737
1822
|
});
|
|
1823
|
+
proc.on("error", () => {
|
|
1824
|
+
clearTimeout(timeout);
|
|
1825
|
+
resolve();
|
|
1826
|
+
});
|
|
1738
1827
|
});
|
|
1739
1828
|
}
|
|
1740
1829
|
/**
|
|
@@ -1835,7 +1924,7 @@ const CLOSE_REASON_LOG_MAX_CHARS = 120;
|
|
|
1835
1924
|
function sanitizeLogText(value, maxChars) {
|
|
1836
1925
|
const sanitized = value.replace(/\p{Cc}/gu, " ").replace(/\s+/g, " ").trim();
|
|
1837
1926
|
if (sanitized.length <= maxChars) return sanitized;
|
|
1838
|
-
return `${sanitized
|
|
1927
|
+
return `${truncateUtf16Safe(sanitized, maxChars)}...`;
|
|
1839
1928
|
}
|
|
1840
1929
|
function normalizeWsMessageData(data) {
|
|
1841
1930
|
if (Buffer.isBuffer(data)) return data;
|
|
@@ -2098,11 +2187,11 @@ var MediaStreamHandler = class {
|
|
|
2098
2187
|
error: error instanceof Error ? error.message : String(error)
|
|
2099
2188
|
}
|
|
2100
2189
|
});
|
|
2101
|
-
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");
|
|
2102
2191
|
else session.sttSession.close();
|
|
2103
2192
|
return;
|
|
2104
2193
|
}
|
|
2105
|
-
if (this.sessions.get(session.streamSid) !== session || session.ws.readyState !== WebSocket
|
|
2194
|
+
if (this.sessions.get(session.streamSid) !== session || session.ws.readyState !== WebSocket.OPEN) {
|
|
2106
2195
|
session.sttSession.close();
|
|
2107
2196
|
return;
|
|
2108
2197
|
}
|
|
@@ -2198,7 +2287,7 @@ Content-Length: ${Buffer.byteLength(body)}\r\n\r
|
|
|
2198
2287
|
*/
|
|
2199
2288
|
getOpenSession(streamSid) {
|
|
2200
2289
|
const session = this.sessions.get(streamSid);
|
|
2201
|
-
return session?.ws.readyState === WebSocket
|
|
2290
|
+
return session?.ws.readyState === WebSocket.OPEN ? session : void 0;
|
|
2202
2291
|
}
|
|
2203
2292
|
/**
|
|
2204
2293
|
* Send a message to a stream's WebSocket if available.
|
|
@@ -2212,7 +2301,7 @@ Content-Length: ${Buffer.byteLength(body)}\r\n\r
|
|
|
2212
2301
|
};
|
|
2213
2302
|
const readyState = session.ws.readyState;
|
|
2214
2303
|
const bufferedBeforeBytes = session.ws.bufferedAmount;
|
|
2215
|
-
if (readyState !== WebSocket
|
|
2304
|
+
if (readyState !== WebSocket.OPEN) return {
|
|
2216
2305
|
sent: false,
|
|
2217
2306
|
readyState,
|
|
2218
2307
|
bufferedBeforeBytes,
|
|
@@ -2463,20 +2552,33 @@ function normalizeProviderStatus(status) {
|
|
|
2463
2552
|
}
|
|
2464
2553
|
/** Map terminal provider status strings to OpenClaw end reasons. */
|
|
2465
2554
|
function mapProviderStatusToEndReason(status) {
|
|
2466
|
-
|
|
2555
|
+
const normalized = normalizeProviderStatus(status);
|
|
2556
|
+
return TERMINAL_PROVIDER_STATUS_TO_END_REASON[normalized] ?? null;
|
|
2467
2557
|
}
|
|
2468
2558
|
/** Return true when a provider status is terminal. */
|
|
2469
2559
|
function isProviderStatusTerminal(status) {
|
|
2470
2560
|
return mapProviderStatusToEndReason(status) !== null;
|
|
2471
2561
|
}
|
|
2472
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
|
|
2473
2575
|
//#region extensions/voice-call/src/webhook/stale-call-reaper.ts
|
|
2474
2576
|
const CHECK_INTERVAL_MS = 3e4;
|
|
2475
2577
|
/** States that indicate a live conversation with speech/transcription.
|
|
2476
2578
|
* Inbound Twilio calls may never fire a call.answered event, so answeredAt
|
|
2477
2579
|
* can be absent even while the call is actively transcribing. These states
|
|
2478
2580
|
* prove the call is live and should not be reaped. */
|
|
2479
|
-
const LiveConversationStates = new Set(["speaking", "listening"]);
|
|
2581
|
+
const LiveConversationStates = /* @__PURE__ */ new Set(["speaking", "listening"]);
|
|
2480
2582
|
/** Start a stale-call reaper and return its cleanup callback. */
|
|
2481
2583
|
function startStaleCallReaper(params) {
|
|
2482
2584
|
const maxAgeSeconds = params.staleCallReaperSeconds;
|
|
@@ -2506,20 +2608,12 @@ const WEBHOOK_BODY_TIMEOUT_MS = WEBHOOK_BODY_READ_DEFAULTS.preAuth.timeoutMs;
|
|
|
2506
2608
|
const MISSING_REMOTE_ADDRESS_IN_FLIGHT_KEY = "__voice_call_no_remote__";
|
|
2507
2609
|
const STREAM_DISCONNECT_HANGUP_GRACE_MS = 2e3;
|
|
2508
2610
|
const TRANSCRIPT_LOG_MAX_CHARS = 200;
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
function loadRealtimeTranscriptionRuntime() {
|
|
2512
|
-
realtimeTranscriptionRuntimePromise ??= import("./realtime-transcription.runtime-CbJAs5t_.js");
|
|
2513
|
-
return realtimeTranscriptionRuntimePromise;
|
|
2514
|
-
}
|
|
2515
|
-
function loadResponseGeneratorModule() {
|
|
2516
|
-
responseGeneratorModulePromise ??= import("./response-generator-DOdrErIH.js");
|
|
2517
|
-
return responseGeneratorModulePromise;
|
|
2518
|
-
}
|
|
2611
|
+
const loadRealtimeTranscriptionRuntime = createLazyRuntimeModule(() => import("./realtime-transcription.runtime-CbJAs5t_.js"));
|
|
2612
|
+
const loadResponseGeneratorModule = createLazyRuntimeModule(() => import("./response-generator-PXuisI3L.js"));
|
|
2519
2613
|
function sanitizeTranscriptForLog(value) {
|
|
2520
2614
|
const sanitized = value.replace(/\p{Cc}/gu, " ").replace(/\s+/g, " ").trim();
|
|
2521
2615
|
if (sanitized.length <= TRANSCRIPT_LOG_MAX_CHARS) return sanitized;
|
|
2522
|
-
return `${sanitized
|
|
2616
|
+
return `${truncateUtf16Safe(sanitized, TRANSCRIPT_LOG_MAX_CHARS)}...`;
|
|
2523
2617
|
}
|
|
2524
2618
|
function appendRecentTalkEventMetadata(call, event) {
|
|
2525
2619
|
const metadata = call.metadata ?? {};
|
|
@@ -2540,16 +2634,6 @@ function appendRecentTalkEventMetadata(call, event) {
|
|
|
2540
2634
|
function buildRequestUrl(requestUrl) {
|
|
2541
2635
|
return new URL$1(requestUrl ?? "/", "http://localhost");
|
|
2542
2636
|
}
|
|
2543
|
-
function normalizeProxyIp(value) {
|
|
2544
|
-
const trimmed = value?.trim();
|
|
2545
|
-
if (!trimmed) return;
|
|
2546
|
-
const normalized = (trimmed.startsWith("[") && trimmed.endsWith("]") ? trimmed.slice(1, -1) : trimmed).toLowerCase();
|
|
2547
|
-
if (normalized.startsWith("::ffff:")) {
|
|
2548
|
-
const mappedIpv4 = normalized.slice(7);
|
|
2549
|
-
if (/^\d{1,3}(?:\.\d{1,3}){3}$/.test(mappedIpv4)) return mappedIpv4;
|
|
2550
|
-
}
|
|
2551
|
-
return normalized;
|
|
2552
|
-
}
|
|
2553
2637
|
function resolveForwardedClientIp(request, trustedProxyIPs) {
|
|
2554
2638
|
const normalizedTrustedProxyIps = new Set(trustedProxyIPs.map((ip) => normalizeProxyIp(ip)).filter((ip) => Boolean(ip)));
|
|
2555
2639
|
const forwardedFor = getHeader(request.headers, "x-forwarded-for");
|
|
@@ -2745,11 +2829,7 @@ var VoiceCallWebhookServer = class {
|
|
|
2745
2829
|
transcript,
|
|
2746
2830
|
isFinal: true
|
|
2747
2831
|
};
|
|
2748
|
-
this.
|
|
2749
|
-
const callMode = call.metadata?.mode;
|
|
2750
|
-
if (call.direction === "inbound" || callMode === "conversation") this.handleInboundResponse(call.callId, transcript).catch((err) => {
|
|
2751
|
-
console.warn(`[voice-call] Failed to auto-respond:`, err);
|
|
2752
|
-
});
|
|
2832
|
+
this.processEventWithAutoResponse(event);
|
|
2753
2833
|
},
|
|
2754
2834
|
onSpeechStart: (providerCallId) => {
|
|
2755
2835
|
if (this.provider.name !== "twilio") return;
|
|
@@ -2888,15 +2968,8 @@ var VoiceCallWebhookServer = class {
|
|
|
2888
2968
|
return null;
|
|
2889
2969
|
}
|
|
2890
2970
|
}
|
|
2891
|
-
normalizeWebhookPathForMatch(pathname) {
|
|
2892
|
-
const trimmed = pathname.trim();
|
|
2893
|
-
if (!trimmed) return "/";
|
|
2894
|
-
const prefixed = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
2895
|
-
if (prefixed === "/") return prefixed;
|
|
2896
|
-
return prefixed.endsWith("/") ? prefixed.slice(0, -1) : prefixed;
|
|
2897
|
-
}
|
|
2898
2971
|
isWebhookPathMatch(requestPath, configuredPath) {
|
|
2899
|
-
return
|
|
2972
|
+
return normalizeWebhookPath(requestPath) === normalizeWebhookPath(configuredPath);
|
|
2900
2973
|
}
|
|
2901
2974
|
/**
|
|
2902
2975
|
* Handle incoming HTTP request.
|
|
@@ -3091,8 +3164,8 @@ var VoiceCallWebhookServer = class {
|
|
|
3091
3164
|
const pathname = buildRequestUrl(req.url).pathname;
|
|
3092
3165
|
const pattern = this.realtimeHandler?.getStreamPathPattern();
|
|
3093
3166
|
if (!pattern) return false;
|
|
3094
|
-
const normalizedPattern =
|
|
3095
|
-
const normalizedPathname =
|
|
3167
|
+
const normalizedPattern = normalizeWebhookPath(pattern);
|
|
3168
|
+
const normalizedPathname = normalizeWebhookPath(pathname);
|
|
3096
3169
|
if (normalizedPattern === "/") return true;
|
|
3097
3170
|
return normalizedPathname === normalizedPattern || normalizedPathname.startsWith(`${normalizedPattern}/`);
|
|
3098
3171
|
} catch {
|
|
@@ -3119,11 +3192,20 @@ var VoiceCallWebhookServer = class {
|
|
|
3119
3192
|
}
|
|
3120
3193
|
processParsedEvents(events) {
|
|
3121
3194
|
for (const event of events) try {
|
|
3122
|
-
this.
|
|
3195
|
+
this.processEventWithAutoResponse(event);
|
|
3123
3196
|
} catch (err) {
|
|
3124
3197
|
console.error(`[voice-call] Error processing event ${event.type}:`, err);
|
|
3125
3198
|
}
|
|
3126
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
|
+
}
|
|
3127
3209
|
writeWebhookResponse(res, payload) {
|
|
3128
3210
|
res.statusCode = payload.statusCode;
|
|
3129
3211
|
if (payload.headers) for (const [key, value] of Object.entries(payload.headers)) res.setHeader(key, value);
|
|
@@ -3168,16 +3250,21 @@ var VoiceCallWebhookServer = class {
|
|
|
3168
3250
|
callId,
|
|
3169
3251
|
sessionKey: call.sessionKey,
|
|
3170
3252
|
from: call.from,
|
|
3253
|
+
agentId: resolveCallAgentId(call, effectiveConfig),
|
|
3171
3254
|
transcript: call.transcript,
|
|
3172
|
-
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
|
+
}
|
|
3173
3260
|
});
|
|
3174
3261
|
if (result.error) {
|
|
3175
3262
|
console.error(`[voice-call] Response generation error: ${result.error}`);
|
|
3176
3263
|
return;
|
|
3177
3264
|
}
|
|
3178
|
-
if (result.text) {
|
|
3265
|
+
if (result.text && !result.deliveredEarly) {
|
|
3179
3266
|
console.log(`[voice-call] AI response: "${result.text}"`);
|
|
3180
|
-
await this.manager.speak(callId, result.text);
|
|
3267
|
+
await this.manager.speak(callId, result.text, { listenAfterPlayback: true });
|
|
3181
3268
|
}
|
|
3182
3269
|
} catch (err) {
|
|
3183
3270
|
console.error(`[voice-call] Auto-response error:`, err);
|
|
@@ -3194,36 +3281,12 @@ const REALTIME_VOICE_CONSULT_SYSTEM_PROMPT = [
|
|
|
3194
3281
|
"Do not print secret values or dump environment variables; only check whether required configuration is present.",
|
|
3195
3282
|
"Be accurate, brief, and speakable."
|
|
3196
3283
|
].join(" ");
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
function loadTelnyxProvider() {
|
|
3204
|
-
telnyxProviderPromise ??= import("./telnyx-LSKUJimK.js");
|
|
3205
|
-
return telnyxProviderPromise;
|
|
3206
|
-
}
|
|
3207
|
-
function loadTwilioProvider() {
|
|
3208
|
-
twilioProviderPromise ??= import("./twilio-GBk6YOP_.js");
|
|
3209
|
-
return twilioProviderPromise;
|
|
3210
|
-
}
|
|
3211
|
-
function loadPlivoProvider() {
|
|
3212
|
-
plivoProviderPromise ??= import("./plivo-sCM3Jvjh.js");
|
|
3213
|
-
return plivoProviderPromise;
|
|
3214
|
-
}
|
|
3215
|
-
function loadMockProvider() {
|
|
3216
|
-
mockProviderPromise ??= import("./mock-YAo3QDri.js");
|
|
3217
|
-
return mockProviderPromise;
|
|
3218
|
-
}
|
|
3219
|
-
function loadRealtimeVoiceRuntime() {
|
|
3220
|
-
realtimeVoiceRuntimePromise ??= import("./realtime-voice.runtime-vtdCOWg-.js");
|
|
3221
|
-
return realtimeVoiceRuntimePromise;
|
|
3222
|
-
}
|
|
3223
|
-
function loadRealtimeHandler() {
|
|
3224
|
-
realtimeHandlerPromise ??= import("./realtime-handler-DdViwdCW.js");
|
|
3225
|
-
return realtimeHandlerPromise;
|
|
3226
|
-
}
|
|
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"));
|
|
3288
|
+
const loadRealtimeVoiceRuntime = createLazyRuntimeModule(() => import("./realtime-voice.runtime-vtdCOWg-.js"));
|
|
3289
|
+
const loadRealtimeHandler = createLazyRuntimeModule(() => import("./realtime-handler-Bz-MNWtD.js"));
|
|
3227
3290
|
function resolveVoiceCallConsultSessionKey(call) {
|
|
3228
3291
|
return resolveVoiceCallSessionKey({
|
|
3229
3292
|
config: call.config,
|
|
@@ -3290,7 +3353,8 @@ async function resolveProvider(config) {
|
|
|
3290
3353
|
const { TwilioProvider } = await loadTwilioProvider();
|
|
3291
3354
|
return new TwilioProvider({
|
|
3292
3355
|
accountSid: config.twilio?.accountSid,
|
|
3293
|
-
authToken: resolveTwilioAuthToken(config)
|
|
3356
|
+
authToken: resolveTwilioAuthToken(config),
|
|
3357
|
+
region: config.twilio?.region
|
|
3294
3358
|
}, {
|
|
3295
3359
|
allowNgrokFreeTierLoopbackBypass,
|
|
3296
3360
|
publicUrl: config.publicUrl,
|
|
@@ -3326,6 +3390,47 @@ async function resolveRealtimeProvider(params) {
|
|
|
3326
3390
|
cfg: params.fullConfig
|
|
3327
3391
|
});
|
|
3328
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
|
+
}
|
|
3329
3434
|
async function createVoiceCallRuntime(params) {
|
|
3330
3435
|
const { config: rawConfig, coreConfig, fullConfig, agentRuntime, stateRuntime, ttsRuntime, logger } = params;
|
|
3331
3436
|
const log = logger ?? {
|
|
@@ -3350,25 +3455,27 @@ async function createVoiceCallRuntime(params) {
|
|
|
3350
3455
|
const webhookServer = new VoiceCallWebhookServer(config, manager, provider, coreConfig, fullConfig ?? coreConfig, agentRuntime, log);
|
|
3351
3456
|
if (realtimeProvider) {
|
|
3352
3457
|
const { RealtimeCallHandler } = await loadRealtimeHandler();
|
|
3353
|
-
const
|
|
3354
|
-
baseInstructions: config.realtime.instructions,
|
|
3458
|
+
const resolveRealtimeInstructions = await createRealtimeInstructionsResolver({
|
|
3355
3459
|
config,
|
|
3356
|
-
coreConfig,
|
|
3460
|
+
coreConfig: cfg,
|
|
3357
3461
|
agentRuntime
|
|
3358
3462
|
});
|
|
3359
3463
|
const realtimeHandler = new RealtimeCallHandler({
|
|
3360
3464
|
...config.realtime,
|
|
3361
|
-
instructions: realtimeInstructions,
|
|
3362
3465
|
tools: resolveRealtimeVoiceAgentConsultTools(config.realtime.toolPolicy, config.realtime.tools)
|
|
3363
|
-
}, manager, provider, realtimeProvider.provider, realtimeProvider.providerConfig, config.serve.path, cfg);
|
|
3466
|
+
}, manager, provider, realtimeProvider.provider, realtimeProvider.providerConfig, config.serve.path, cfg, resolveRealtimeInstructions);
|
|
3364
3467
|
if (config.realtime.toolPolicy !== "none") realtimeHandler.registerToolHandler(REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME, async (args, callId, handlerContext) => {
|
|
3365
3468
|
const call = manager.getCall(callId);
|
|
3366
3469
|
if (!call) return { error: `Call "${callId}" not found` };
|
|
3367
|
-
const
|
|
3368
|
-
const
|
|
3470
|
+
const numberRouteKey = resolveVoiceCallNumberRouteKeyForCall(call);
|
|
3471
|
+
const effectiveConfig = resolveVoiceCallEffectiveConfig(config, numberRouteKey).config;
|
|
3472
|
+
const agentId = resolveCallAgentId(call, effectiveConfig);
|
|
3369
3473
|
const sessionKey = resolveVoiceCallConsultSessionKey({
|
|
3370
3474
|
...call,
|
|
3371
|
-
config:
|
|
3475
|
+
config: {
|
|
3476
|
+
...effectiveConfig,
|
|
3477
|
+
agentId
|
|
3478
|
+
},
|
|
3372
3479
|
coreSession: cfg.session
|
|
3373
3480
|
});
|
|
3374
3481
|
const requesterSessionKey = typeof call.metadata?.requesterSessionKey === "string" ? call.metadata.requesterSessionKey : void 0;
|
|
@@ -3487,4 +3594,4 @@ async function createVoiceCallRuntime(params) {
|
|
|
3487
3594
|
}
|
|
3488
3595
|
}
|
|
3489
3596
|
//#endregion
|
|
3490
|
-
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 };
|