@openclaw/imessage 0.0.0 → 2026.8.1-beta.2
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 +27 -1
- package/dist/accounts-D00Njxg2.js +368 -0
- package/dist/actions.runtime-DTFKDN5p.js +451 -0
- package/dist/api.js +14 -0
- package/dist/approval-handler.runtime-BtLs4gho.js +428 -0
- package/dist/catchup-D32oYNxR.js +294 -0
- package/dist/channel-config-api.js +2 -0
- package/dist/channel-lppmI51h.js +620 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-5wpCKQb7.js +236 -0
- package/dist/config-schema-DV0KP5nC.js +140 -0
- package/dist/contract-api.js +3 -0
- package/dist/conversation-bindings-GDQ_Laxj.js +24 -0
- package/dist/doctor-contract-api.js +357 -0
- package/dist/group-policy-DF9xSdik.js +1932 -0
- package/dist/index.js +18 -0
- package/dist/media-contract-BEgdvYhW.js +13 -0
- package/dist/media-contract-api.js +2 -0
- package/dist/message-tool-api-CPDfJJoE.js +315 -0
- package/dist/message-tool-api.js +2 -0
- package/dist/monitor-DnxJ8pW9.js +3550 -0
- package/dist/monitor-reply-cache-DKlYGd5x.js +348 -0
- package/dist/outbound-send-deps-B-QEsLSM.js +4 -0
- package/dist/persisted-echo-cache-BPWGUK-L.js +143 -0
- package/dist/question-reactions-DVe50UhB.js +74 -0
- package/dist/remote-file-DLwO9ved.js +289 -0
- package/dist/runtime-api.js +23 -0
- package/dist/sanitize-outbound-CoTZLXMw.js +896 -0
- package/dist/secret-contract-api.js +5 -0
- package/dist/send-BUXW76tw.js +1176 -0
- package/dist/session-binding-contract-api.js +2 -0
- package/dist/setup-entry.js +11 -0
- package/node_modules/typebox/build/compile/code.d.mts +12 -0
- package/node_modules/typebox/build/compile/code.mjs +65 -0
- package/node_modules/typebox/build/compile/compile.d.mts +6 -0
- package/node_modules/typebox/build/compile/compile.mjs +12 -0
- package/node_modules/typebox/build/compile/index.d.mts +8 -0
- package/node_modules/typebox/build/compile/index.mjs +14 -0
- package/node_modules/typebox/build/compile/validator.d.mts +35 -0
- package/node_modules/typebox/build/compile/validator.mjs +91 -0
- package/node_modules/typebox/build/error/errors.d.mts +208 -0
- package/node_modules/typebox/build/error/errors.mjs +18 -0
- package/node_modules/typebox/build/error/index.d.mts +1 -0
- package/node_modules/typebox/build/error/index.mjs +1 -0
- package/node_modules/typebox/build/format/_idna.d.mts +2 -0
- package/node_modules/typebox/build/format/_idna.mjs +246 -0
- package/node_modules/typebox/build/format/_puny.d.mts +1 -0
- package/node_modules/typebox/build/format/_puny.mjs +77 -0
- package/node_modules/typebox/build/format/_registry.d.mts +15 -0
- package/node_modules/typebox/build/format/_registry.mjs +96 -0
- package/node_modules/typebox/build/format/date.d.mts +6 -0
- package/node_modules/typebox/build/format/date.mjs +19 -0
- package/node_modules/typebox/build/format/date_time.d.mts +6 -0
- package/node_modules/typebox/build/format/date_time.mjs +11 -0
- package/node_modules/typebox/build/format/duration.d.mts +5 -0
- package/node_modules/typebox/build/format/duration.mjs +8 -0
- package/node_modules/typebox/build/format/email.d.mts +5 -0
- package/node_modules/typebox/build/format/email.mjs +8 -0
- package/node_modules/typebox/build/format/format.d.mts +22 -0
- package/node_modules/typebox/build/format/format.mjs +22 -0
- package/node_modules/typebox/build/format/hostname.d.mts +7 -0
- package/node_modules/typebox/build/format/hostname.mjs +18 -0
- package/node_modules/typebox/build/format/idn_email.d.mts +5 -0
- package/node_modules/typebox/build/format/idn_email.mjs +8 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +7 -0
- package/node_modules/typebox/build/format/idn_hostname.mjs +19 -0
- package/node_modules/typebox/build/format/index.d.mts +4 -0
- package/node_modules/typebox/build/format/index.mjs +4 -0
- package/node_modules/typebox/build/format/ipv4.d.mts +6 -0
- package/node_modules/typebox/build/format/ipv4.mjs +38 -0
- package/node_modules/typebox/build/format/ipv6.d.mts +5 -0
- package/node_modules/typebox/build/format/ipv6.mjs +67 -0
- package/node_modules/typebox/build/format/iri.d.mts +5 -0
- package/node_modules/typebox/build/format/iri.mjs +13 -0
- package/node_modules/typebox/build/format/iri_reference.d.mts +5 -0
- package/node_modules/typebox/build/format/iri_reference.mjs +60 -0
- package/node_modules/typebox/build/format/json_pointer.d.mts +6 -0
- package/node_modules/typebox/build/format/json_pointer.mjs +9 -0
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +6 -0
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +9 -0
- package/node_modules/typebox/build/format/regex.d.mts +6 -0
- package/node_modules/typebox/build/format/regex.mjs +17 -0
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +6 -0
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +9 -0
- package/node_modules/typebox/build/format/time.d.mts +5 -0
- package/node_modules/typebox/build/format/time.mjs +27 -0
- package/node_modules/typebox/build/format/uri.d.mts +5 -0
- package/node_modules/typebox/build/format/uri.mjs +135 -0
- package/node_modules/typebox/build/format/uri_reference.d.mts +5 -0
- package/node_modules/typebox/build/format/uri_reference.mjs +9 -0
- package/node_modules/typebox/build/format/uri_template.d.mts +6 -0
- package/node_modules/typebox/build/format/uri_template.mjs +10 -0
- package/node_modules/typebox/build/format/url.d.mts +6 -0
- package/node_modules/typebox/build/format/url.mjs +9 -0
- package/node_modules/typebox/build/format/uuid.d.mts +6 -0
- package/node_modules/typebox/build/format/uuid.mjs +9 -0
- package/node_modules/typebox/build/guard/emit.d.mts +54 -0
- package/node_modules/typebox/build/guard/emit.mjs +186 -0
- package/node_modules/typebox/build/guard/globals.d.mts +35 -0
- package/node_modules/typebox/build/guard/globals.mjs +90 -0
- package/node_modules/typebox/build/guard/guard.d.mts +65 -0
- package/node_modules/typebox/build/guard/guard.mjs +212 -0
- package/node_modules/typebox/build/guard/index.d.mts +6 -0
- package/node_modules/typebox/build/guard/index.mjs +6 -0
- package/node_modules/typebox/build/guard/native.d.mts +20 -0
- package/node_modules/typebox/build/guard/native.mjs +60 -0
- package/node_modules/typebox/build/guard/string.d.mts +6 -0
- package/node_modules/typebox/build/guard/string.mjs +176 -0
- package/node_modules/typebox/build/index.d.mts +8 -0
- package/node_modules/typebox/build/index.mjs +14 -0
- package/node_modules/typebox/build/schema/build.d.mts +39 -0
- package/node_modules/typebox/build/schema/build.mjs +118 -0
- package/node_modules/typebox/build/schema/check.d.mts +6 -0
- package/node_modules/typebox/build/schema/check.mjs +14 -0
- package/node_modules/typebox/build/schema/compile.d.mts +22 -0
- package/node_modules/typebox/build/schema/compile.mjs +46 -0
- package/node_modules/typebox/build/schema/engine/_context.d.mts +35 -0
- package/node_modules/typebox/build/schema/engine/_context.mjs +129 -0
- package/node_modules/typebox/build/schema/engine/_exact_optional.d.mts +3 -0
- package/node_modules/typebox/build/schema/engine/_exact_optional.mjs +20 -0
- package/node_modules/typebox/build/schema/engine/_externals.d.mts +7 -0
- package/node_modules/typebox/build/schema/engine/_externals.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/_functions.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/_functions.mjs +66 -0
- package/node_modules/typebox/build/schema/engine/_reducer.d.mts +4 -0
- package/node_modules/typebox/build/schema/engine/_reducer.mjs +45 -0
- package/node_modules/typebox/build/schema/engine/_refine.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/_refine.mjs +29 -0
- package/node_modules/typebox/build/schema/engine/_stack.d.mts +18 -0
- package/node_modules/typebox/build/schema/engine/_stack.mjs +107 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +2 -0
- package/node_modules/typebox/build/schema/engine/_unique.mjs +5 -0
- package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +50 -0
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +110 -0
- package/node_modules/typebox/build/schema/engine/allOf.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/allOf.mjs +47 -0
- package/node_modules/typebox/build/schema/engine/anyOf.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/anyOf.mjs +52 -0
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +5 -0
- package/node_modules/typebox/build/schema/engine/boolean.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/const.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/const.mjs +30 -0
- package/node_modules/typebox/build/schema/engine/contains.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/contains.mjs +42 -0
- package/node_modules/typebox/build/schema/engine/dependencies.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +45 -0
- package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +40 -0
- package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +38 -0
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/enum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/enum.mjs +33 -0
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/format.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/format.mjs +26 -0
- package/node_modules/typebox/build/schema/engine/if.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/if.mjs +47 -0
- package/node_modules/typebox/build/schema/engine/index.d.mts +48 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +54 -0
- package/node_modules/typebox/build/schema/engine/items.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +68 -0
- package/node_modules/typebox/build/schema/engine/maxContains.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +42 -0
- package/node_modules/typebox/build/schema/engine/maxItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maxItems.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/maxLength.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maxLength.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maxProperties.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/maximum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/maximum.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/minContains.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minContains.mjs +41 -0
- package/node_modules/typebox/build/schema/engine/minItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minItems.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/minLength.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minLength.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/minProperties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minProperties.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/minimum.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/minimum.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/multipleOf.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/not.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/not.mjs +37 -0
- package/node_modules/typebox/build/schema/engine/oneOf.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +58 -0
- package/node_modules/typebox/build/schema/engine/pattern.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/pattern.mjs +28 -0
- package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +44 -0
- package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/prefixItems.mjs +35 -0
- package/node_modules/typebox/build/schema/engine/properties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/properties.mjs +75 -0
- package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +39 -0
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +25 -0
- package/node_modules/typebox/build/schema/engine/ref.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/ref.mjs +58 -0
- package/node_modules/typebox/build/schema/engine/required.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/required.mjs +32 -0
- package/node_modules/typebox/build/schema/engine/schema.d.mts +9 -0
- package/node_modules/typebox/build/schema/engine/schema.mjs +347 -0
- package/node_modules/typebox/build/schema/engine/type.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/type.mjs +70 -0
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +51 -0
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +51 -0
- package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +6 -0
- package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +51 -0
- package/node_modules/typebox/build/schema/errors.d.mts +6 -0
- package/node_modules/typebox/build/schema/errors.mjs +24 -0
- package/node_modules/typebox/build/schema/index.d.mts +3 -0
- package/node_modules/typebox/build/schema/index.mjs +9 -0
- package/node_modules/typebox/build/schema/parse.d.mts +13 -0
- package/node_modules/typebox/build/schema/parse.mjs +27 -0
- package/node_modules/typebox/build/schema/pointer/index.d.mts +2 -0
- package/node_modules/typebox/build/schema/pointer/index.mjs +2 -0
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +10 -0
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +106 -0
- package/node_modules/typebox/build/schema/pointer/pointer_get.d.mts +9 -0
- package/node_modules/typebox/build/schema/pointer/pointer_get.mjs +2 -0
- package/node_modules/typebox/build/schema/resolve/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/resolve/index.mjs +1 -0
- package/node_modules/typebox/build/schema/resolve/ref.d.mts +3 -0
- package/node_modules/typebox/build/schema/resolve/ref.mjs +146 -0
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +1 -0
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +1 -0
- package/node_modules/typebox/build/schema/schema.d.mts +10 -0
- package/node_modules/typebox/build/schema/schema.mjs +10 -0
- package/node_modules/typebox/build/schema/static/_canonical.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/_canonical.mjs +2 -0
- package/node_modules/typebox/build/schema/static/_comparer.d.mts +6 -0
- package/node_modules/typebox/build/schema/static/_comparer.mjs +2 -0
- package/node_modules/typebox/build/schema/static/_elements.d.mts +18 -0
- package/node_modules/typebox/build/schema/static/_elements.mjs +2 -0
- package/node_modules/typebox/build/schema/static/additionalProperties.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/additionalProperties.mjs +3 -0
- package/node_modules/typebox/build/schema/static/allOf.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/allOf.mjs +2 -0
- package/node_modules/typebox/build/schema/static/anyOf.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/anyOf.mjs +2 -0
- package/node_modules/typebox/build/schema/static/const.d.mts +1 -0
- package/node_modules/typebox/build/schema/static/const.mjs +2 -0
- package/node_modules/typebox/build/schema/static/enum.d.mts +1 -0
- package/node_modules/typebox/build/schema/static/enum.mjs +2 -0
- package/node_modules/typebox/build/schema/static/if.d.mts +15 -0
- package/node_modules/typebox/build/schema/static/if.mjs +2 -0
- package/node_modules/typebox/build/schema/static/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/static/index.mjs +1 -0
- package/node_modules/typebox/build/schema/static/items.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/items.mjs +2 -0
- package/node_modules/typebox/build/schema/static/oneOf.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/oneOf.mjs +2 -0
- package/node_modules/typebox/build/schema/static/patternProperties.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/patternProperties.mjs +2 -0
- package/node_modules/typebox/build/schema/static/prefixItems.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/prefixItems.mjs +2 -0
- package/node_modules/typebox/build/schema/static/properties.d.mts +32 -0
- package/node_modules/typebox/build/schema/static/properties.mjs +2 -0
- package/node_modules/typebox/build/schema/static/ref.d.mts +8 -0
- package/node_modules/typebox/build/schema/static/ref.mjs +3 -0
- package/node_modules/typebox/build/schema/static/required.d.mts +3 -0
- package/node_modules/typebox/build/schema/static/required.mjs +3 -0
- package/node_modules/typebox/build/schema/static/schema.d.mts +56 -0
- package/node_modules/typebox/build/schema/static/schema.mjs +2 -0
- package/node_modules/typebox/build/schema/static/static.d.mts +4 -0
- package/node_modules/typebox/build/schema/static/static.mjs +3 -0
- package/node_modules/typebox/build/schema/static/type.d.mts +4 -0
- package/node_modules/typebox/build/schema/static/type.mjs +3 -0
- package/node_modules/typebox/build/schema/static/unevaluatedProperties.d.mts +7 -0
- package/node_modules/typebox/build/schema/static/unevaluatedProperties.mjs +3 -0
- package/node_modules/typebox/build/schema/types/_refine.d.mts +13 -0
- package/node_modules/typebox/build/schema/types/_refine.mjs +18 -0
- package/node_modules/typebox/build/schema/types/additionalItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/additionalItems.mjs +14 -0
- package/node_modules/typebox/build/schema/types/additionalProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/additionalProperties.mjs +14 -0
- package/node_modules/typebox/build/schema/types/allOf.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/allOf.mjs +15 -0
- package/node_modules/typebox/build/schema/types/anchor.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/anchor.mjs +12 -0
- package/node_modules/typebox/build/schema/types/anyOf.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/anyOf.mjs +15 -0
- package/node_modules/typebox/build/schema/types/const.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/const.mjs +12 -0
- package/node_modules/typebox/build/schema/types/contains.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/contains.mjs +14 -0
- package/node_modules/typebox/build/schema/types/contentEncoding.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/contentEncoding.mjs +13 -0
- package/node_modules/typebox/build/schema/types/contentMediaType.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/contentMediaType.mjs +13 -0
- package/node_modules/typebox/build/schema/types/default.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/default.mjs +12 -0
- package/node_modules/typebox/build/schema/types/defs.d.mts +6 -0
- package/node_modules/typebox/build/schema/types/defs.mjs +12 -0
- package/node_modules/typebox/build/schema/types/dependencies.d.mts +11 -0
- package/node_modules/typebox/build/schema/types/dependencies.mjs +16 -0
- package/node_modules/typebox/build/schema/types/dependentRequired.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/dependentRequired.mjs +15 -0
- package/node_modules/typebox/build/schema/types/dependentSchemas.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/dependentSchemas.mjs +15 -0
- package/node_modules/typebox/build/schema/types/dynamicAnchor.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/dynamicAnchor.mjs +12 -0
- package/node_modules/typebox/build/schema/types/dynamicRef.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/dynamicRef.mjs +12 -0
- package/node_modules/typebox/build/schema/types/else.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/else.mjs +14 -0
- package/node_modules/typebox/build/schema/types/enum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/enum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/exclusiveMaximum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/exclusiveMaximum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/exclusiveMinimum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/exclusiveMinimum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/format.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/format.mjs +13 -0
- package/node_modules/typebox/build/schema/types/id.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/id.mjs +13 -0
- package/node_modules/typebox/build/schema/types/if.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/if.mjs +14 -0
- package/node_modules/typebox/build/schema/types/index.d.mts +53 -0
- package/node_modules/typebox/build/schema/types/index.mjs +59 -0
- package/node_modules/typebox/build/schema/types/items.d.mts +19 -0
- package/node_modules/typebox/build/schema/types/items.mjs +26 -0
- package/node_modules/typebox/build/schema/types/maxContains.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maxContains.mjs +13 -0
- package/node_modules/typebox/build/schema/types/maxItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maxItems.mjs +13 -0
- package/node_modules/typebox/build/schema/types/maxLength.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maxLength.mjs +13 -0
- package/node_modules/typebox/build/schema/types/maxProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maxProperties.mjs +13 -0
- package/node_modules/typebox/build/schema/types/maximum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/maximum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minContains.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minContains.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minItems.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minLength.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minLength.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minProperties.mjs +13 -0
- package/node_modules/typebox/build/schema/types/minimum.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/minimum.mjs +13 -0
- package/node_modules/typebox/build/schema/types/multipleOf.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/multipleOf.mjs +13 -0
- package/node_modules/typebox/build/schema/types/not.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/not.mjs +14 -0
- package/node_modules/typebox/build/schema/types/oneOf.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/oneOf.mjs +15 -0
- package/node_modules/typebox/build/schema/types/pattern.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/pattern.mjs +14 -0
- package/node_modules/typebox/build/schema/types/patternProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/patternProperties.mjs +15 -0
- package/node_modules/typebox/build/schema/types/prefixItems.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/prefixItems.mjs +14 -0
- package/node_modules/typebox/build/schema/types/properties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/properties.mjs +15 -0
- package/node_modules/typebox/build/schema/types/propertyNames.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/propertyNames.mjs +15 -0
- package/node_modules/typebox/build/schema/types/recursiveAnchor.d.mts +12 -0
- package/node_modules/typebox/build/schema/types/recursiveAnchor.mjs +19 -0
- package/node_modules/typebox/build/schema/types/recursiveRef.d.mts +8 -0
- package/node_modules/typebox/build/schema/types/recursiveRef.mjs +12 -0
- package/node_modules/typebox/build/schema/types/ref.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/ref.mjs +13 -0
- package/node_modules/typebox/build/schema/types/required.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/required.mjs +14 -0
- package/node_modules/typebox/build/schema/types/schema.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/schema.mjs +14 -0
- package/node_modules/typebox/build/schema/types/then.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/then.mjs +14 -0
- package/node_modules/typebox/build/schema/types/type.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/type.mjs +15 -0
- package/node_modules/typebox/build/schema/types/unevaluatedItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/unevaluatedItems.mjs +14 -0
- package/node_modules/typebox/build/schema/types/unevaluatedProperties.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/unevaluatedProperties.mjs +14 -0
- package/node_modules/typebox/build/schema/types/uniqueItems.d.mts +9 -0
- package/node_modules/typebox/build/schema/types/uniqueItems.mjs +13 -0
- package/node_modules/typebox/build/system/arguments/arguments.d.mts +5 -0
- package/node_modules/typebox/build/system/arguments/arguments.mjs +9 -0
- package/node_modules/typebox/build/system/arguments/index.d.mts +1 -0
- package/node_modules/typebox/build/system/arguments/index.mjs +1 -0
- package/node_modules/typebox/build/system/environment/environment.d.mts +1 -0
- package/node_modules/typebox/build/system/environment/environment.mjs +1 -0
- package/node_modules/typebox/build/system/environment/evaluate.d.mts +9 -0
- package/node_modules/typebox/build/system/environment/evaluate.mjs +37 -0
- package/node_modules/typebox/build/system/environment/index.d.mts +1 -0
- package/node_modules/typebox/build/system/environment/index.mjs +1 -0
- package/node_modules/typebox/build/system/hashing/hash.d.mts +4 -0
- package/node_modules/typebox/build/system/hashing/hash.mjs +232 -0
- package/node_modules/typebox/build/system/hashing/index.d.mts +1 -0
- package/node_modules/typebox/build/system/hashing/index.mjs +1 -0
- package/node_modules/typebox/build/system/index.d.mts +4 -0
- package/node_modules/typebox/build/system/index.mjs +4 -0
- package/node_modules/typebox/build/system/locale/_config.d.mts +7 -0
- package/node_modules/typebox/build/system/locale/_config.mjs +15 -0
- package/node_modules/typebox/build/system/locale/_locale.d.mts +40 -0
- package/node_modules/typebox/build/system/locale/_locale.mjs +40 -0
- package/node_modules/typebox/build/system/locale/ar_001.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ar_001.mjs +40 -0
- package/node_modules/typebox/build/system/locale/bn_BD.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/bn_BD.mjs +40 -0
- package/node_modules/typebox/build/system/locale/cs_CZ.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/cs_CZ.mjs +40 -0
- package/node_modules/typebox/build/system/locale/de_DE.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/de_DE.mjs +40 -0
- package/node_modules/typebox/build/system/locale/el_GR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/el_GR.mjs +40 -0
- package/node_modules/typebox/build/system/locale/en_US.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/en_US.mjs +39 -0
- package/node_modules/typebox/build/system/locale/es_419.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/es_419.mjs +40 -0
- package/node_modules/typebox/build/system/locale/es_AR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/es_AR.mjs +40 -0
- package/node_modules/typebox/build/system/locale/es_ES.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/es_ES.mjs +40 -0
- package/node_modules/typebox/build/system/locale/es_MX.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/es_MX.mjs +40 -0
- package/node_modules/typebox/build/system/locale/fa_IR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/fa_IR.mjs +40 -0
- package/node_modules/typebox/build/system/locale/fil_PH.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/fil_PH.mjs +40 -0
- package/node_modules/typebox/build/system/locale/fr_CA.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/fr_CA.mjs +40 -0
- package/node_modules/typebox/build/system/locale/fr_FR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/fr_FR.mjs +40 -0
- package/node_modules/typebox/build/system/locale/ha_NG.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ha_NG.mjs +40 -0
- package/node_modules/typebox/build/system/locale/hi_IN.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/hi_IN.mjs +40 -0
- package/node_modules/typebox/build/system/locale/hu_HU.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/hu_HU.mjs +40 -0
- package/node_modules/typebox/build/system/locale/id_ID.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/id_ID.mjs +40 -0
- package/node_modules/typebox/build/system/locale/index.d.mts +1 -0
- package/node_modules/typebox/build/system/locale/index.mjs +1 -0
- package/node_modules/typebox/build/system/locale/it_IT.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/it_IT.mjs +40 -0
- package/node_modules/typebox/build/system/locale/ja_JP.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ja_JP.mjs +40 -0
- package/node_modules/typebox/build/system/locale/ko_KR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ko_KR.mjs +40 -0
- package/node_modules/typebox/build/system/locale/ms_MY.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ms_MY.mjs +40 -0
- package/node_modules/typebox/build/system/locale/nl_NL.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/nl_NL.mjs +40 -0
- package/node_modules/typebox/build/system/locale/pl_PL.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/pl_PL.mjs +40 -0
- package/node_modules/typebox/build/system/locale/pt_BR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/pt_BR.mjs +40 -0
- package/node_modules/typebox/build/system/locale/pt_PT.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/pt_PT.mjs +40 -0
- package/node_modules/typebox/build/system/locale/ro_RO.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ro_RO.mjs +40 -0
- package/node_modules/typebox/build/system/locale/ru_RU.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ru_RU.mjs +40 -0
- package/node_modules/typebox/build/system/locale/sv_SE.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/sv_SE.mjs +40 -0
- package/node_modules/typebox/build/system/locale/sw_TZ.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/sw_TZ.mjs +40 -0
- package/node_modules/typebox/build/system/locale/th_TH.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/th_TH.mjs +40 -0
- package/node_modules/typebox/build/system/locale/tr_TR.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/tr_TR.mjs +40 -0
- package/node_modules/typebox/build/system/locale/uk_UA.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/uk_UA.mjs +40 -0
- package/node_modules/typebox/build/system/locale/ur_PK.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/ur_PK.mjs +40 -0
- package/node_modules/typebox/build/system/locale/vi_VN.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/vi_VN.mjs +40 -0
- package/node_modules/typebox/build/system/locale/yo_NG.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/yo_NG.mjs +40 -0
- package/node_modules/typebox/build/system/locale/zh_Hans.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/zh_Hans.mjs +40 -0
- package/node_modules/typebox/build/system/locale/zh_Hant.d.mts +3 -0
- package/node_modules/typebox/build/system/locale/zh_Hant.mjs +40 -0
- package/node_modules/typebox/build/system/memory/assign.d.mts +14 -0
- package/node_modules/typebox/build/system/memory/assign.mjs +11 -0
- package/node_modules/typebox/build/system/memory/clone.d.mts +5 -0
- package/node_modules/typebox/build/system/memory/clone.mjs +110 -0
- package/node_modules/typebox/build/system/memory/create.d.mts +8 -0
- package/node_modules/typebox/build/system/memory/create.mjs +30 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/discard.mjs +17 -0
- package/node_modules/typebox/build/system/memory/index.d.mts +1 -0
- package/node_modules/typebox/build/system/memory/index.mjs +1 -0
- package/node_modules/typebox/build/system/memory/memory.d.mts +6 -0
- package/node_modules/typebox/build/system/memory/memory.mjs +7 -0
- package/node_modules/typebox/build/system/memory/metrics.d.mts +14 -0
- package/node_modules/typebox/build/system/memory/metrics.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +7 -0
- package/node_modules/typebox/build/system/memory/update.mjs +32 -0
- package/node_modules/typebox/build/system/settings/index.d.mts +1 -0
- package/node_modules/typebox/build/system/settings/index.mjs +1 -0
- package/node_modules/typebox/build/system/settings/settings.d.mts +71 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +34 -0
- package/node_modules/typebox/build/system/system.d.mts +6 -0
- package/node_modules/typebox/build/system/system.mjs +6 -0
- package/node_modules/typebox/build/system/unreachable/index.d.mts +1 -0
- package/node_modules/typebox/build/system/unreachable/index.mjs +1 -0
- package/node_modules/typebox/build/system/unreachable/unreachable.d.mts +3 -0
- package/node_modules/typebox/build/system/unreachable/unreachable.mjs +6 -0
- 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/capitalize.d.mts +11 -0
- package/node_modules/typebox/build/type/action/capitalize.mjs +11 -0
- package/node_modules/typebox/build/type/action/conditional.d.mts +12 -0
- package/node_modules/typebox/build/type/action/conditional.mjs +13 -0
- package/node_modules/typebox/build/type/action/constructor_parameters.d.mts +11 -0
- package/node_modules/typebox/build/type/action/constructor_parameters.mjs +11 -0
- package/node_modules/typebox/build/type/action/evaluate.d.mts +11 -0
- package/node_modules/typebox/build/type/action/evaluate.mjs +11 -0
- package/node_modules/typebox/build/type/action/exclude.d.mts +11 -0
- package/node_modules/typebox/build/type/action/exclude.mjs +11 -0
- package/node_modules/typebox/build/type/action/extract.d.mts +11 -0
- package/node_modules/typebox/build/type/action/extract.mjs +11 -0
- package/node_modules/typebox/build/type/action/index.d.mts +30 -0
- package/node_modules/typebox/build/type/action/index.mjs +30 -0
- package/node_modules/typebox/build/type/action/indexed.d.mts +14 -0
- package/node_modules/typebox/build/type/action/indexed.mjs +14 -0
- package/node_modules/typebox/build/type/action/instance_type.d.mts +11 -0
- package/node_modules/typebox/build/type/action/instance_type.mjs +11 -0
- package/node_modules/typebox/build/type/action/interface.d.mts +14 -0
- package/node_modules/typebox/build/type/action/interface.mjs +22 -0
- package/node_modules/typebox/build/type/action/keyof.d.mts +11 -0
- package/node_modules/typebox/build/type/action/keyof.mjs +11 -0
- package/node_modules/typebox/build/type/action/lowercase.d.mts +11 -0
- package/node_modules/typebox/build/type/action/lowercase.mjs +11 -0
- package/node_modules/typebox/build/type/action/mapped.d.mts +13 -0
- package/node_modules/typebox/build/type/action/mapped.mjs +13 -0
- package/node_modules/typebox/build/type/action/module.d.mts +13 -0
- package/node_modules/typebox/build/type/action/module.mjs +13 -0
- package/node_modules/typebox/build/type/action/non_nullable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/non_nullable.mjs +11 -0
- package/node_modules/typebox/build/type/action/omit.d.mts +14 -0
- package/node_modules/typebox/build/type/action/omit.mjs +14 -0
- package/node_modules/typebox/build/type/action/parameters.d.mts +11 -0
- package/node_modules/typebox/build/type/action/parameters.mjs +11 -0
- package/node_modules/typebox/build/type/action/partial.d.mts +11 -0
- package/node_modules/typebox/build/type/action/partial.mjs +11 -0
- package/node_modules/typebox/build/type/action/pick.d.mts +14 -0
- package/node_modules/typebox/build/type/action/pick.mjs +14 -0
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +16 -0
- package/node_modules/typebox/build/type/action/readonly_object.mjs +19 -0
- package/node_modules/typebox/build/type/action/required.d.mts +11 -0
- package/node_modules/typebox/build/type/action/required.mjs +11 -0
- package/node_modules/typebox/build/type/action/return_type.d.mts +11 -0
- package/node_modules/typebox/build/type/action/return_type.mjs +11 -0
- package/node_modules/typebox/build/type/action/uncapitalize.d.mts +11 -0
- package/node_modules/typebox/build/type/action/uncapitalize.mjs +11 -0
- package/node_modules/typebox/build/type/action/uppercase.d.mts +11 -0
- package/node_modules/typebox/build/type/action/uppercase.mjs +11 -0
- 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.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +53 -0
- package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +21 -0
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +49 -0
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.d.mts +13 -0
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +33 -0
- package/node_modules/typebox/build/type/engine/call/resolve_target.d.mts +25 -0
- package/node_modules/typebox/build/type/engine/call/resolve_target.mjs +27 -0
- package/node_modules/typebox/build/type/engine/conditional/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/conditional/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/conditional/instantiate.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/conditional/instantiate.mjs +23 -0
- package/node_modules/typebox/build/type/engine/constructor_parameters/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/constructor_parameters/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +14 -0
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +25 -0
- package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +16 -0
- package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +21 -0
- package/node_modules/typebox/build/type/engine/cyclic/check.mjs +45 -0
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +22 -0
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +47 -0
- package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +28 -0
- package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +47 -0
- package/node_modules/typebox/build/type/engine/cyclic/index.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/cyclic/index.mjs +6 -0
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +17 -0
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +31 -0
- package/node_modules/typebox/build/type/engine/cyclic/target.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/cyclic/target.mjs +16 -0
- package/node_modules/typebox/build/type/engine/enum/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/enum/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/enum/typescript_enum_to_enum_values.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/enum/typescript_enum_to_enum_values.mjs +9 -0
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +43 -0
- package/node_modules/typebox/build/type/engine/evaluate/compare.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/evaluate/compare.mjs +22 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +34 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +67 -0
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +28 -0
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +45 -0
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +26 -0
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +53 -0
- package/node_modules/typebox/build/type/engine/evaluate/flatten.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/evaluate/flatten.mjs +11 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +8 -0
- package/node_modules/typebox/build/type/engine/evaluate/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/evaluate/instantiate.mjs +12 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +11 -0
- package/node_modules/typebox/build/type/engine/exclude/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/exclude/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/exclude/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/exclude/instantiate.mjs +16 -0
- package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +23 -0
- package/node_modules/typebox/build/type/engine/extract/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/extract/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/extract/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/extract/instantiate.mjs +16 -0
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +23 -0
- package/node_modules/typebox/build/type/engine/helpers/index.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/helpers/index.mjs +3 -0
- package/node_modules/typebox/build/type/engine/helpers/keys.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/helpers/keys.mjs +8 -0
- package/node_modules/typebox/build/type/engine/helpers/keys_to_indexer.d.mts +7 -0
- package/node_modules/typebox/build/type/engine/helpers/keys_to_indexer.mjs +15 -0
- package/node_modules/typebox/build/type/engine/helpers/union.d.mts +7 -0
- package/node_modules/typebox/build/type/engine/helpers/union.mjs +3 -0
- 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 +31 -0
- package/node_modules/typebox/build/type/engine/index.mjs +37 -0
- package/node_modules/typebox/build/type/engine/indexable/from_cyclic.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/indexable/from_cyclic.mjs +8 -0
- 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 +6 -0
- package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_intersect.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_literal.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/indexable/from_literal.mjs +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +19 -0
- package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +25 -0
- package/node_modules/typebox/build/type/engine/indexable/from_union.d.mts +4 -0
- package/node_modules/typebox/build/type/engine/indexable/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/indexable/to_indexable.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/indexable/to_indexable.mjs +14 -0
- package/node_modules/typebox/build/type/engine/indexable/to_indexable_keys.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/indexable/to_indexable_keys.mjs +12 -0
- package/node_modules/typebox/build/type/engine/indexed/array_indexer.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/indexed/array_indexer.mjs +18 -0
- package/node_modules/typebox/build/type/engine/indexed/from_array.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/indexed/from_array.mjs +35 -0
- package/node_modules/typebox/build/type/engine/indexed/from_object.d.mts +16 -0
- package/node_modules/typebox/build/type/engine/indexed/from_object.mjs +40 -0
- package/node_modules/typebox/build/type/engine/indexed/from_tuple.d.mts +13 -0
- package/node_modules/typebox/build/type/engine/indexed/from_tuple.mjs +35 -0
- package/node_modules/typebox/build/type/engine/indexed/from_type.d.mts +11 -0
- package/node_modules/typebox/build/type/engine/indexed/from_type.mjs +14 -0
- package/node_modules/typebox/build/type/engine/indexed/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/indexed/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +16 -0
- package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +28 -0
- package/node_modules/typebox/build/type/engine/instance_type/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/instance_type/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/instance_type/instantiate.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/instance_type/instantiate.mjs +21 -0
- package/node_modules/typebox/build/type/engine/instantiate.d.mts +178 -0
- package/node_modules/typebox/build/type/engine/instantiate.mjs +158 -0
- package/node_modules/typebox/build/type/engine/interface/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/interface/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/interface/instantiate.mjs +23 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_literal.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_literal.mjs +9 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +8 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_type.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_type.mjs +13 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_union.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/intrinsics/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/intrinsics/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/intrinsics/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/intrinsics/instantiate.d.mts +38 -0
- package/node_modules/typebox/build/type/engine/intrinsics/instantiate.mjs +52 -0
- package/node_modules/typebox/build/type/engine/intrinsics/mapping.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/intrinsics/mapping.mjs +4 -0
- package/node_modules/typebox/build/type/engine/keyof/from_any.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/keyof/from_any.mjs +8 -0
- package/node_modules/typebox/build/type/engine/keyof/from_array.d.mts +4 -0
- package/node_modules/typebox/build/type/engine/keyof/from_array.mjs +5 -0
- package/node_modules/typebox/build/type/engine/keyof/from_object.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/keyof/from_object.mjs +20 -0
- package/node_modules/typebox/build/type/engine/keyof/from_record.d.mts +4 -0
- package/node_modules/typebox/build/type/engine/keyof/from_record.mjs +5 -0
- package/node_modules/typebox/build/type/engine/keyof/from_tuple.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/keyof/from_tuple.mjs +7 -0
- package/node_modules/typebox/build/type/engine/keyof/from_type.d.mts +15 -0
- package/node_modules/typebox/build/type/engine/keyof/from_type.mjs +23 -0
- package/node_modules/typebox/build/type/engine/keyof/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/keyof/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +16 -0
- package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +29 -0
- package/node_modules/typebox/build/type/engine/mapped/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/mapped/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/mapped/instantiate.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/mapped/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +22 -0
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +42 -0
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +17 -0
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +39 -0
- package/node_modules/typebox/build/type/engine/module/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/module/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +19 -0
- package/node_modules/typebox/build/type/engine/module/instantiate.mjs +36 -0
- package/node_modules/typebox/build/type/engine/non_nullable/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/non_nullable/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/non_nullable/instantiate.d.mts +14 -0
- package/node_modules/typebox/build/type/engine/non_nullable/instantiate.mjs +22 -0
- package/node_modules/typebox/build/type/engine/object/collapse.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/object/collapse.mjs +14 -0
- package/node_modules/typebox/build/type/engine/object/from_cyclic.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/object/from_cyclic.mjs +8 -0
- 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_intersect.d.mts +17 -0
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +22 -0
- package/node_modules/typebox/build/type/engine/object/from_object.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/object/from_object.mjs +4 -0
- package/node_modules/typebox/build/type/engine/object/from_tuple.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/object/from_tuple.mjs +9 -0
- package/node_modules/typebox/build/type/engine/object/from_type.d.mts +16 -0
- package/node_modules/typebox/build/type/engine/object/from_type.mjs +23 -0
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +19 -0
- package/node_modules/typebox/build/type/engine/object/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/object/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/omit/from_type.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/omit/from_type.mjs +18 -0
- package/node_modules/typebox/build/type/engine/omit/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/omit/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/omit/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/omit/instantiate.mjs +16 -0
- 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/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/parameters/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +14 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +25 -0
- package/node_modules/typebox/build/type/engine/partial/from_cyclic.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/partial/from_cyclic.mjs +11 -0
- 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 +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/partial/from_object.mjs +11 -0
- package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +14 -0
- package/node_modules/typebox/build/type/engine/partial/from_type.mjs +20 -0
- package/node_modules/typebox/build/type/engine/partial/from_union.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/partial/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/partial/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/partial/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/partial/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/patterns/index.d.mts +2 -0
- package/node_modules/typebox/build/type/engine/patterns/index.mjs +2 -0
- package/node_modules/typebox/build/type/engine/patterns/pattern.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/patterns/pattern.mjs +11 -0
- package/node_modules/typebox/build/type/engine/patterns/template.d.mts +7 -0
- package/node_modules/typebox/build/type/engine/patterns/template.mjs +20 -0
- package/node_modules/typebox/build/type/engine/pick/from_type.d.mts +13 -0
- package/node_modules/typebox/build/type/engine/pick/from_type.mjs +20 -0
- package/node_modules/typebox/build/type/engine/pick/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/pick/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/pick/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/pick/instantiate.mjs +16 -0
- 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 +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +7 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_cyclic.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_cyclic.mjs +11 -0
- 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 +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +11 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +7 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +18 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +25 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_union.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/readonly_object/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/readonly_object/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/readonly_object/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/readonly_object/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/record/from_key.d.mts +24 -0
- package/node_modules/typebox/build/type/engine/record/from_key.mjs +40 -0
- package/node_modules/typebox/build/type/engine/record/from_key_any.d.mts +4 -0
- package/node_modules/typebox/build/type/engine/record/from_key_any.mjs +6 -0
- package/node_modules/typebox/build/type/engine/record/from_key_boolean.d.mts +7 -0
- package/node_modules/typebox/build/type/engine/record/from_key_boolean.mjs +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +8 -0
- package/node_modules/typebox/build/type/engine/record/from_key_integer.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_integer.mjs +7 -0
- package/node_modules/typebox/build/type/engine/record/from_key_intersect.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_intersect.mjs +8 -0
- package/node_modules/typebox/build/type/engine/record/from_key_literal.d.mts +11 -0
- package/node_modules/typebox/build/type/engine/record/from_key_literal.mjs +10 -0
- package/node_modules/typebox/build/type/engine/record/from_key_number.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_number.mjs +7 -0
- package/node_modules/typebox/build/type/engine/record/from_key_string.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/record/from_key_string.mjs +12 -0
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +12 -0
- package/node_modules/typebox/build/type/engine/record/from_key_union.d.mts +20 -0
- package/node_modules/typebox/build/type/engine/record/from_key_union.mjs +39 -0
- package/node_modules/typebox/build/type/engine/record/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/record/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/record/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/record/instantiate.mjs +17 -0
- package/node_modules/typebox/build/type/engine/record/record_create.d.mts +3 -0
- package/node_modules/typebox/build/type/engine/record/record_create.mjs +7 -0
- package/node_modules/typebox/build/type/engine/ref/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/ref/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +10 -0
- package/node_modules/typebox/build/type/engine/required/from_cyclic.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/required/from_cyclic.mjs +11 -0
- 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 +5 -0
- package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/type/engine/required/from_object.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/required/from_object.mjs +11 -0
- package/node_modules/typebox/build/type/engine/required/from_type.d.mts +14 -0
- package/node_modules/typebox/build/type/engine/required/from_type.mjs +20 -0
- package/node_modules/typebox/build/type/engine/required/from_union.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/required/from_union.mjs +7 -0
- package/node_modules/typebox/build/type/engine/required/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/required/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/required/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/required/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/rest/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/rest/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/rest/spread.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/rest/spread.mjs +19 -0
- package/node_modules/typebox/build/type/engine/return_type/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/return_type/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/return_type/instantiate.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/return_type/instantiate.mjs +21 -0
- package/node_modules/typebox/build/type/engine/template_literal/create.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/template_literal/create.mjs +5 -0
- package/node_modules/typebox/build/type/engine/template_literal/decode.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +81 -0
- package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +33 -0
- package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +81 -0
- package/node_modules/typebox/build/type/engine/template_literal/index.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/template_literal/index.mjs +6 -0
- package/node_modules/typebox/build/type/engine/template_literal/instantiate.d.mts +9 -0
- package/node_modules/typebox/build/type/engine/template_literal/instantiate.mjs +15 -0
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +26 -0
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.d.mts +6 -0
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +10 -0
- package/node_modules/typebox/build/type/engine/template_literal/static.d.mts +18 -0
- package/node_modules/typebox/build/type/engine/template_literal/static.mjs +2 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +16 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.mjs +26 -0
- package/node_modules/typebox/build/type/engine/tuple/to_object.d.mts +12 -0
- package/node_modules/typebox/build/type/engine/tuple/to_object.mjs +14 -0
- package/node_modules/typebox/build/type/engine/with/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/with/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/with/instantiate.mjs +14 -0
- package/node_modules/typebox/build/type/extends/any.d.mts +9 -0
- package/node_modules/typebox/build/type/extends/any.mjs +12 -0
- package/node_modules/typebox/build/type/extends/array.d.mts +20 -0
- package/node_modules/typebox/build/type/extends/array.mjs +21 -0
- package/node_modules/typebox/build/type/extends/bigint.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/bigint.mjs +9 -0
- package/node_modules/typebox/build/type/extends/boolean.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/boolean.mjs +9 -0
- package/node_modules/typebox/build/type/extends/constructor.d.mts +10 -0
- package/node_modules/typebox/build/type/extends/constructor.mjs +17 -0
- 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 +7 -0
- package/node_modules/typebox/build/type/extends/enum.mjs +7 -0
- package/node_modules/typebox/build/type/extends/extends.d.mts +13 -0
- package/node_modules/typebox/build/type/extends/extends.mjs +17 -0
- package/node_modules/typebox/build/type/extends/extends_left.d.mts +53 -0
- package/node_modules/typebox/build/type/extends/extends_left.mjs +80 -0
- package/node_modules/typebox/build/type/extends/extends_right.d.mts +27 -0
- package/node_modules/typebox/build/type/extends/extends_right.mjs +49 -0
- package/node_modules/typebox/build/type/extends/function.d.mts +10 -0
- package/node_modules/typebox/build/type/extends/function.mjs +17 -0
- package/node_modules/typebox/build/type/extends/index.d.mts +2 -0
- package/node_modules/typebox/build/type/extends/index.mjs +2 -0
- package/node_modules/typebox/build/type/extends/inference.d.mts +34 -0
- package/node_modules/typebox/build/type/extends/inference.mjs +62 -0
- package/node_modules/typebox/build/type/extends/integer.d.mts +8 -0
- package/node_modules/typebox/build/type/extends/integer.mjs +10 -0
- package/node_modules/typebox/build/type/extends/intersect.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/intersect.mjs +15 -0
- package/node_modules/typebox/build/type/extends/literal.d.mts +18 -0
- package/node_modules/typebox/build/type/extends/literal.mjs +44 -0
- package/node_modules/typebox/build/type/extends/never.d.mts +8 -0
- package/node_modules/typebox/build/type/extends/never.mjs +9 -0
- package/node_modules/typebox/build/type/extends/null.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/null.mjs +9 -0
- package/node_modules/typebox/build/type/extends/number.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/number.mjs +9 -0
- package/node_modules/typebox/build/type/extends/object.d.mts +32 -0
- package/node_modules/typebox/build/type/extends/object.mjs +109 -0
- package/node_modules/typebox/build/type/extends/parameters.d.mts +15 -0
- package/node_modules/typebox/build/type/extends/parameters.mjs +28 -0
- 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/result.d.mts +24 -0
- package/node_modules/typebox/build/type/extends/result.mjs +36 -0
- package/node_modules/typebox/build/type/extends/return_type.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/return_type.mjs +9 -0
- package/node_modules/typebox/build/type/extends/string.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/string.mjs +9 -0
- package/node_modules/typebox/build/type/extends/symbol.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/symbol.mjs +9 -0
- package/node_modules/typebox/build/type/extends/template_literal.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/template_literal.mjs +7 -0
- package/node_modules/typebox/build/type/extends/tuple.d.mts +22 -0
- package/node_modules/typebox/build/type/extends/tuple.mjs +61 -0
- package/node_modules/typebox/build/type/extends/undefined.d.mts +8 -0
- package/node_modules/typebox/build/type/extends/undefined.mjs +10 -0
- package/node_modules/typebox/build/type/extends/union.d.mts +11 -0
- package/node_modules/typebox/build/type/extends/union.mjs +24 -0
- package/node_modules/typebox/build/type/extends/unknown.d.mts +9 -0
- package/node_modules/typebox/build/type/extends/unknown.mjs +12 -0
- package/node_modules/typebox/build/type/extends/void.d.mts +7 -0
- package/node_modules/typebox/build/type/extends/void.mjs +9 -0
- package/node_modules/typebox/build/type/index.d.mts +5 -0
- package/node_modules/typebox/build/type/index.mjs +5 -0
- package/node_modules/typebox/build/type/script/index.d.mts +1 -0
- package/node_modules/typebox/build/type/script/index.mjs +1 -0
- package/node_modules/typebox/build/type/script/mapping.d.mts +353 -0
- package/node_modules/typebox/build/type/script/mapping.mjs +535 -0
- package/node_modules/typebox/build/type/script/parser.d.mts +262 -0
- package/node_modules/typebox/build/type/script/parser.mjs +136 -0
- package/node_modules/typebox/build/type/script/script.d.mts +16 -0
- package/node_modules/typebox/build/type/script/script.mjs +22 -0
- package/node_modules/typebox/build/type/script/token/bigint.d.mts +8 -0
- package/node_modules/typebox/build/type/script/token/bigint.mjs +14 -0
- package/node_modules/typebox/build/type/script/token/const.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/const.mjs +18 -0
- package/node_modules/typebox/build/type/script/token/ident.d.mts +16 -0
- package/node_modules/typebox/build/type/script/token/ident.mjs +26 -0
- package/node_modules/typebox/build/type/script/token/index.d.mts +12 -0
- package/node_modules/typebox/build/type/script/token/index.mjs +12 -0
- package/node_modules/typebox/build/type/script/token/integer.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/integer.mjs +19 -0
- package/node_modules/typebox/build/type/script/token/internal/char.d.mts +75 -0
- package/node_modules/typebox/build/type/script/token/internal/char.mjs +26 -0
- package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -0
- package/node_modules/typebox/build/type/script/token/internal/guard.mjs +15 -0
- package/node_modules/typebox/build/type/script/token/internal/many.d.mts +7 -0
- package/node_modules/typebox/build/type/script/token/internal/many.mjs +14 -0
- package/node_modules/typebox/build/type/script/token/internal/match.d.mts +6 -0
- package/node_modules/typebox/build/type/script/token/internal/match.mjs +11 -0
- package/node_modules/typebox/build/type/script/token/internal/optional.d.mts +5 -0
- package/node_modules/typebox/build/type/script/token/internal/optional.mjs +9 -0
- package/node_modules/typebox/build/type/script/token/internal/take.d.mts +6 -0
- package/node_modules/typebox/build/type/script/token/internal/take.mjs +30 -0
- package/node_modules/typebox/build/type/script/token/internal/trim.d.mts +19 -0
- package/node_modules/typebox/build/type/script/token/internal/trim.mjs +34 -0
- package/node_modules/typebox/build/type/script/token/number.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/number.mjs +19 -0
- package/node_modules/typebox/build/type/script/token/rest.d.mts +4 -0
- package/node_modules/typebox/build/type/script/token/rest.mjs +9 -0
- package/node_modules/typebox/build/type/script/token/span.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/span.mjs +24 -0
- package/node_modules/typebox/build/type/script/token/string.d.mts +11 -0
- package/node_modules/typebox/build/type/script/token/string.mjs +20 -0
- package/node_modules/typebox/build/type/script/token/unsigned_integer.d.mts +16 -0
- package/node_modules/typebox/build/type/script/token/unsigned_integer.mjs +26 -0
- package/node_modules/typebox/build/type/script/token/unsigned_number.d.mts +17 -0
- package/node_modules/typebox/build/type/script/token/unsigned_number.mjs +38 -0
- package/node_modules/typebox/build/type/script/token/until.d.mts +7 -0
- package/node_modules/typebox/build/type/script/token/until.mjs +21 -0
- package/node_modules/typebox/build/type/script/token/until_1.d.mts +5 -0
- package/node_modules/typebox/build/type/script/token/until_1.mjs +12 -0
- package/node_modules/typebox/build/type/types/_codec.d.mts +30 -0
- package/node_modules/typebox/build/type/types/_codec.mjs +60 -0
- package/node_modules/typebox/build/type/types/_immutable.d.mts +9 -0
- package/node_modules/typebox/build/type/types/_immutable.mjs +18 -0
- package/node_modules/typebox/build/type/types/_optional.d.mts +9 -0
- package/node_modules/typebox/build/type/types/_optional.mjs +18 -0
- package/node_modules/typebox/build/type/types/_readonly.d.mts +9 -0
- package/node_modules/typebox/build/type/types/_readonly.mjs +18 -0
- package/node_modules/typebox/build/type/types/_refine.d.mts +24 -0
- package/node_modules/typebox/build/type/types/_refine.mjs +36 -0
- package/node_modules/typebox/build/type/types/any.d.mts +10 -0
- package/node_modules/typebox/build/type/types/any.mjs +18 -0
- package/node_modules/typebox/build/type/types/array.d.mts +18 -0
- package/node_modules/typebox/build/type/types/array.mjs +25 -0
- package/node_modules/typebox/build/type/types/bigint.d.mts +12 -0
- package/node_modules/typebox/build/type/types/bigint.mjs +21 -0
- package/node_modules/typebox/build/type/types/boolean.d.mts +11 -0
- package/node_modules/typebox/build/type/types/boolean.mjs +17 -0
- package/node_modules/typebox/build/type/types/call.d.mts +16 -0
- package/node_modules/typebox/build/type/types/call.mjs +23 -0
- package/node_modules/typebox/build/type/types/constructor.d.mts +18 -0
- package/node_modules/typebox/build/type/types/constructor.mjs +24 -0
- package/node_modules/typebox/build/type/types/cyclic.d.mts +16 -0
- package/node_modules/typebox/build/type/types/cyclic.mjs +29 -0
- package/node_modules/typebox/build/type/types/deferred.d.mts +13 -0
- package/node_modules/typebox/build/type/types/deferred.mjs +16 -0
- 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 +18 -0
- package/node_modules/typebox/build/type/types/enum.mjs +22 -0
- package/node_modules/typebox/build/type/types/function.d.mts +21 -0
- package/node_modules/typebox/build/type/types/function.mjs +25 -0
- package/node_modules/typebox/build/type/types/generic.d.mts +13 -0
- package/node_modules/typebox/build/type/types/generic.mjs +17 -0
- package/node_modules/typebox/build/type/types/identifier.d.mts +11 -0
- package/node_modules/typebox/build/type/types/identifier.mjs +17 -0
- package/node_modules/typebox/build/type/types/index.d.mts +45 -0
- package/node_modules/typebox/build/type/types/index.mjs +51 -0
- package/node_modules/typebox/build/type/types/infer.d.mts +15 -0
- package/node_modules/typebox/build/type/types/infer.mjs +20 -0
- package/node_modules/typebox/build/type/types/integer.d.mts +12 -0
- package/node_modules/typebox/build/type/types/integer.mjs +21 -0
- package/node_modules/typebox/build/type/types/intersect.d.mts +15 -0
- package/node_modules/typebox/build/type/types/intersect.mjs +24 -0
- package/node_modules/typebox/build/type/types/literal.d.mts +31 -0
- package/node_modules/typebox/build/type/types/literal.mjs +62 -0
- package/node_modules/typebox/build/type/types/never.d.mts +12 -0
- package/node_modules/typebox/build/type/types/never.mjs +22 -0
- package/node_modules/typebox/build/type/types/null.d.mts +11 -0
- package/node_modules/typebox/build/type/types/null.mjs +17 -0
- package/node_modules/typebox/build/type/types/number.d.mts +12 -0
- package/node_modules/typebox/build/type/types/number.mjs +21 -0
- package/node_modules/typebox/build/type/types/object.d.mts +18 -0
- package/node_modules/typebox/build/type/types/object.mjs +28 -0
- package/node_modules/typebox/build/type/types/parameter.d.mts +17 -0
- package/node_modules/typebox/build/type/types/parameter.mjs +21 -0
- package/node_modules/typebox/build/type/types/properties.d.mts +43 -0
- package/node_modules/typebox/build/type/types/properties.mjs +15 -0
- package/node_modules/typebox/build/type/types/record.d.mts +52 -0
- package/node_modules/typebox/build/type/types/record.mjs +66 -0
- package/node_modules/typebox/build/type/types/ref.d.mts +19 -0
- package/node_modules/typebox/build/type/types/ref.mjs +18 -0
- package/node_modules/typebox/build/type/types/rest.d.mts +11 -0
- package/node_modules/typebox/build/type/types/rest.mjs +17 -0
- package/node_modules/typebox/build/type/types/schema.d.mts +176 -0
- package/node_modules/typebox/build/type/types/schema.mjs +15 -0
- package/node_modules/typebox/build/type/types/static.d.mts +45 -0
- package/node_modules/typebox/build/type/types/static.mjs +3 -0
- package/node_modules/typebox/build/type/types/string.d.mts +12 -0
- package/node_modules/typebox/build/type/types/string.mjs +22 -0
- package/node_modules/typebox/build/type/types/symbol.d.mts +11 -0
- package/node_modules/typebox/build/type/types/symbol.mjs +17 -0
- package/node_modules/typebox/build/type/types/template_literal.d.mts +28 -0
- package/node_modules/typebox/build/type/types/template_literal.mjs +37 -0
- package/node_modules/typebox/build/type/types/this.d.mts +14 -0
- package/node_modules/typebox/build/type/types/this.mjs +17 -0
- package/node_modules/typebox/build/type/types/tuple.d.mts +38 -0
- package/node_modules/typebox/build/type/types/tuple.mjs +25 -0
- package/node_modules/typebox/build/type/types/undefined.d.mts +11 -0
- package/node_modules/typebox/build/type/types/undefined.mjs +17 -0
- package/node_modules/typebox/build/type/types/union.d.mts +15 -0
- package/node_modules/typebox/build/type/types/union.mjs +24 -0
- package/node_modules/typebox/build/type/types/unknown.d.mts +10 -0
- package/node_modules/typebox/build/type/types/unknown.mjs +17 -0
- package/node_modules/typebox/build/type/types/unsafe.d.mts +10 -0
- package/node_modules/typebox/build/type/types/unsafe.mjs +20 -0
- package/node_modules/typebox/build/type/types/void.d.mts +11 -0
- package/node_modules/typebox/build/type/types/void.mjs +17 -0
- package/node_modules/typebox/build/typebox.d.mts +69 -0
- package/node_modules/typebox/build/typebox.mjs +85 -0
- package/node_modules/typebox/build/value/assert/assert.d.mts +14 -0
- package/node_modules/typebox/build/value/assert/assert.mjs +28 -0
- package/node_modules/typebox/build/value/assert/index.d.mts +1 -0
- package/node_modules/typebox/build/value/assert/index.mjs +1 -0
- package/node_modules/typebox/build/value/check/check.d.mts +5 -0
- package/node_modules/typebox/build/value/check/check.mjs +11 -0
- package/node_modules/typebox/build/value/check/index.d.mts +1 -0
- package/node_modules/typebox/build/value/check/index.mjs +1 -0
- package/node_modules/typebox/build/value/clean/additional.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/additional.mjs +6 -0
- package/node_modules/typebox/build/value/clean/clean.d.mts +15 -0
- package/node_modules/typebox/build/value/clean/clean.mjs +17 -0
- package/node_modules/typebox/build/value/clean/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_array.mjs +8 -0
- package/node_modules/typebox/build/value/clean/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/clean/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_intersect.mjs +26 -0
- package/node_modules/typebox/build/value/clean/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_object.mjs +31 -0
- package/node_modules/typebox/build/value/clean/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_record.mjs +32 -0
- package/node_modules/typebox/build/value/clean/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_ref.mjs +8 -0
- package/node_modules/typebox/build/value/clean/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_tuple.mjs +14 -0
- package/node_modules/typebox/build/value/clean/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_type.mjs +21 -0
- package/node_modules/typebox/build/value/clean/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/clean/from_union.mjs +12 -0
- package/node_modules/typebox/build/value/clean/index.d.mts +1 -0
- package/node_modules/typebox/build/value/clean/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +5 -0
- package/node_modules/typebox/build/value/clone/clone.mjs +12 -0
- package/node_modules/typebox/build/value/clone/index.d.mts +1 -0
- package/node_modules/typebox/build/value/clone/index.mjs +1 -0
- package/node_modules/typebox/build/value/codec/callback.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/callback.mjs +25 -0
- package/node_modules/typebox/build/value/codec/decode.d.mts +12 -0
- package/node_modules/typebox/build/value/codec/decode.mjs +52 -0
- package/node_modules/typebox/build/value/codec/encode.d.mts +12 -0
- package/node_modules/typebox/build/value/codec/encode.mjs +52 -0
- package/node_modules/typebox/build/value/codec/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_array.mjs +35 -0
- package/node_modules/typebox/build/value/codec/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_cyclic.mjs +8 -0
- package/node_modules/typebox/build/value/codec/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_intersect.mjs +58 -0
- package/node_modules/typebox/build/value/codec/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_object.mjs +42 -0
- package/node_modules/typebox/build/value/codec/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_record.mjs +39 -0
- package/node_modules/typebox/build/value/codec/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_ref.mjs +31 -0
- package/node_modules/typebox/build/value/codec/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_tuple.mjs +32 -0
- package/node_modules/typebox/build/value/codec/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_type.mjs +22 -0
- package/node_modules/typebox/build/value/codec/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/codec/from_union.mjs +39 -0
- package/node_modules/typebox/build/value/codec/has.d.mts +5 -0
- package/node_modules/typebox/build/value/codec/has.mjs +93 -0
- package/node_modules/typebox/build/value/codec/index.d.mts +3 -0
- package/node_modules/typebox/build/value/codec/index.mjs +3 -0
- package/node_modules/typebox/build/value/convert/convert.d.mts +13 -0
- package/node_modules/typebox/build/value/convert/convert.mjs +15 -0
- package/node_modules/typebox/build/value/convert/from_additional.d.mts +6 -0
- package/node_modules/typebox/build/value/convert/from_additional.mjs +18 -0
- package/node_modules/typebox/build/value/convert/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_array.mjs +7 -0
- package/node_modules/typebox/build/value/convert/from_bigint.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_bigint.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_boolean.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_boolean.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_enum.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_enum.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_integer.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_integer.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/value/convert/from_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_literal.mjs +44 -0
- package/node_modules/typebox/build/value/convert/from_null.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_null.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_number.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_number.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_object.mjs +28 -0
- package/node_modules/typebox/build/value/convert/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_record.mjs +23 -0
- package/node_modules/typebox/build/value/convert/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_ref.mjs +8 -0
- package/node_modules/typebox/build/value/convert/from_string.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_string.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_template_literal.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_tuple.mjs +11 -0
- package/node_modules/typebox/build/value/convert/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_type.mjs +43 -0
- package/node_modules/typebox/build/value/convert/from_undefined.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_undefined.mjs +6 -0
- package/node_modules/typebox/build/value/convert/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_union.mjs +13 -0
- package/node_modules/typebox/build/value/convert/from_void.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/from_void.mjs +6 -0
- package/node_modules/typebox/build/value/convert/index.d.mts +1 -0
- package/node_modules/typebox/build/value/convert/index.mjs +1 -0
- package/node_modules/typebox/build/value/convert/try/index.d.mts +1 -0
- package/node_modules/typebox/build/value/convert/try/index.mjs +1 -0
- package/node_modules/typebox/build/value/convert/try/try.d.mts +8 -0
- package/node_modules/typebox/build/value/convert/try/try.mjs +8 -0
- package/node_modules/typebox/build/value/convert/try/try_array.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_array.mjs +6 -0
- package/node_modules/typebox/build/value/convert/try/try_bigint.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_bigint.mjs +45 -0
- package/node_modules/typebox/build/value/convert/try/try_boolean.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_boolean.mjs +41 -0
- package/node_modules/typebox/build/value/convert/try/try_null.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_null.mjs +44 -0
- package/node_modules/typebox/build/value/convert/try/try_number.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_number.mjs +44 -0
- package/node_modules/typebox/build/value/convert/try/try_result.d.mts +8 -0
- package/node_modules/typebox/build/value/convert/try/try_result.mjs +17 -0
- package/node_modules/typebox/build/value/convert/try/try_string.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_string.mjs +12 -0
- package/node_modules/typebox/build/value/convert/try/try_undefined.d.mts +2 -0
- package/node_modules/typebox/build/value/convert/try/try_undefined.mjs +44 -0
- package/node_modules/typebox/build/value/create/create.d.mts +5 -0
- package/node_modules/typebox/build/value/create/create.mjs +11 -0
- package/node_modules/typebox/build/value/create/error.d.mts +5 -0
- package/node_modules/typebox/build/value/create/error.mjs +7 -0
- package/node_modules/typebox/build/value/create/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_array.mjs +10 -0
- package/node_modules/typebox/build/value/create/from_bigint.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_bigint.mjs +7 -0
- package/node_modules/typebox/build/value/create/from_boolean.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_boolean.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_constructor.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_constructor.mjs +10 -0
- package/node_modules/typebox/build/value/create/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/create/from_default.d.mts +3 -0
- package/node_modules/typebox/build/value/create/from_default.mjs +10 -0
- package/node_modules/typebox/build/value/create/from_enum.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_enum.mjs +6 -0
- package/node_modules/typebox/build/value/create/from_function.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_function.mjs +6 -0
- package/node_modules/typebox/build/value/create/from_integer.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_integer.mjs +8 -0
- package/node_modules/typebox/build/value/create/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/value/create/from_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_literal.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_never.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_never.mjs +5 -0
- package/node_modules/typebox/build/value/create/from_null.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_null.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_number.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_number.mjs +8 -0
- package/node_modules/typebox/build/value/create/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_object.mjs +9 -0
- package/node_modules/typebox/build/value/create/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_record.mjs +8 -0
- package/node_modules/typebox/build/value/create/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_ref.mjs +9 -0
- package/node_modules/typebox/build/value/create/from_string.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_string.mjs +9 -0
- package/node_modules/typebox/build/value/create/from_symbol.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_symbol.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_template_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_template_literal.mjs +11 -0
- package/node_modules/typebox/build/value/create/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_tuple.mjs +5 -0
- package/node_modules/typebox/build/value/create/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_type.mjs +61 -0
- package/node_modules/typebox/build/value/create/from_undefined.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_undefined.mjs +4 -0
- package/node_modules/typebox/build/value/create/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_union.mjs +9 -0
- package/node_modules/typebox/build/value/create/from_void.d.mts +2 -0
- package/node_modules/typebox/build/value/create/from_void.mjs +4 -0
- package/node_modules/typebox/build/value/create/index.d.mts +2 -0
- package/node_modules/typebox/build/value/create/index.mjs +2 -0
- package/node_modules/typebox/build/value/default/default.d.mts +13 -0
- package/node_modules/typebox/build/value/default/default.mjs +15 -0
- package/node_modules/typebox/build/value/default/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_array.mjs +12 -0
- package/node_modules/typebox/build/value/default/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_cyclic.mjs +7 -0
- package/node_modules/typebox/build/value/default/from_default.d.mts +3 -0
- package/node_modules/typebox/build/value/default/from_default.mjs +13 -0
- package/node_modules/typebox/build/value/default/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_intersect.mjs +9 -0
- package/node_modules/typebox/build/value/default/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_object.mjs +32 -0
- package/node_modules/typebox/build/value/default/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_record.mjs +26 -0
- package/node_modules/typebox/build/value/default/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_ref.mjs +9 -0
- package/node_modules/typebox/build/value/default/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_tuple.mjs +14 -0
- package/node_modules/typebox/build/value/default/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_type.mjs +25 -0
- package/node_modules/typebox/build/value/default/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/default/from_union.mjs +14 -0
- package/node_modules/typebox/build/value/default/index.d.mts +1 -0
- package/node_modules/typebox/build/value/default/index.mjs +1 -0
- package/node_modules/typebox/build/value/delta/diff.d.mts +10 -0
- package/node_modules/typebox/build/value/delta/diff.mjs +135 -0
- package/node_modules/typebox/build/value/delta/edit.d.mts +24 -0
- package/node_modules/typebox/build/value/delta/edit.mjs +17 -0
- package/node_modules/typebox/build/value/delta/index.d.mts +3 -0
- package/node_modules/typebox/build/value/delta/index.mjs +3 -0
- package/node_modules/typebox/build/value/delta/patch.d.mts +8 -0
- package/node_modules/typebox/build/value/delta/patch.mjs +42 -0
- package/node_modules/typebox/build/value/equal/equal.d.mts +2 -0
- package/node_modules/typebox/build/value/equal/equal.mjs +6 -0
- package/node_modules/typebox/build/value/equal/index.d.mts +1 -0
- package/node_modules/typebox/build/value/equal/index.mjs +1 -0
- package/node_modules/typebox/build/value/errors/errors.d.mts +16 -0
- package/node_modules/typebox/build/value/errors/errors.mjs +17 -0
- package/node_modules/typebox/build/value/errors/index.d.mts +1 -0
- package/node_modules/typebox/build/value/errors/index.mjs +1 -0
- package/node_modules/typebox/build/value/hash/hash.d.mts +6 -0
- package/node_modules/typebox/build/value/hash/hash.mjs +10 -0
- package/node_modules/typebox/build/value/hash/index.d.mts +1 -0
- package/node_modules/typebox/build/value/hash/index.mjs +1 -0
- package/node_modules/typebox/build/value/index.d.mts +20 -0
- package/node_modules/typebox/build/value/index.mjs +29 -0
- package/node_modules/typebox/build/value/parse/index.d.mts +1 -0
- package/node_modules/typebox/build/value/parse/index.mjs +1 -0
- package/node_modules/typebox/build/value/parse/parse.d.mts +11 -0
- package/node_modules/typebox/build/value/parse/parse.mjs +47 -0
- package/node_modules/typebox/build/value/pipeline/index.d.mts +1 -0
- package/node_modules/typebox/build/value/pipeline/index.mjs +1 -0
- package/node_modules/typebox/build/value/pipeline/pipeline.d.mts +10 -0
- package/node_modules/typebox/build/value/pipeline/pipeline.mjs +15 -0
- package/node_modules/typebox/build/value/pointer/index.d.mts +1 -0
- package/node_modules/typebox/build/value/pointer/index.mjs +1 -0
- package/node_modules/typebox/build/value/repair/error.d.mts +7 -0
- package/node_modules/typebox/build/value/repair/error.mjs +8 -0
- package/node_modules/typebox/build/value/repair/from_array.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_array.mjs +39 -0
- package/node_modules/typebox/build/value/repair/from_enum.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_enum.mjs +6 -0
- package/node_modules/typebox/build/value/repair/from_intersect.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_intersect.mjs +8 -0
- package/node_modules/typebox/build/value/repair/from_object.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_object.mjs +33 -0
- package/node_modules/typebox/build/value/repair/from_record.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_record.mjs +33 -0
- package/node_modules/typebox/build/value/repair/from_ref.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_ref.mjs +9 -0
- package/node_modules/typebox/build/value/repair/from_template_literal.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_template_literal.mjs +7 -0
- package/node_modules/typebox/build/value/repair/from_tuple.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_tuple.mjs +12 -0
- package/node_modules/typebox/build/value/repair/from_type.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_type.mjs +88 -0
- package/node_modules/typebox/build/value/repair/from_union.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_union.mjs +24 -0
- package/node_modules/typebox/build/value/repair/from_unknown.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_unknown.mjs +12 -0
- package/node_modules/typebox/build/value/repair/index.d.mts +1 -0
- package/node_modules/typebox/build/value/repair/index.mjs +1 -0
- package/node_modules/typebox/build/value/repair/repair.d.mts +17 -0
- package/node_modules/typebox/build/value/repair/repair.mjs +20 -0
- package/node_modules/typebox/build/value/shared/index.d.mts +3 -0
- package/node_modules/typebox/build/value/shared/index.mjs +4 -0
- package/node_modules/typebox/build/value/shared/optional_undefined.d.mts +2 -0
- package/node_modules/typebox/build/value/shared/optional_undefined.mjs +15 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +7 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +72 -0
- package/node_modules/typebox/build/value/shared/union_score_select.d.mts +3 -0
- package/node_modules/typebox/build/value/shared/union_score_select.mjs +51 -0
- package/node_modules/typebox/build/value/value.d.mts +15 -0
- package/node_modules/typebox/build/value/value.mjs +15 -0
- package/node_modules/typebox/license +23 -0
- package/node_modules/typebox/package.json +87 -0
- package/node_modules/typebox/readme.md +370 -0
- package/node_modules/zod/LICENSE +21 -0
- package/node_modules/zod/README.md +191 -0
- package/node_modules/zod/index.cjs +33 -0
- package/node_modules/zod/index.d.cts +4 -0
- package/node_modules/zod/index.d.ts +4 -0
- package/node_modules/zod/index.js +4 -0
- package/node_modules/zod/locales/index.cjs +17 -0
- package/node_modules/zod/locales/index.d.cts +1 -0
- package/node_modules/zod/locales/index.d.ts +1 -0
- package/node_modules/zod/locales/index.js +1 -0
- package/node_modules/zod/locales/package.json +7 -0
- package/node_modules/zod/mini/index.cjs +32 -0
- package/node_modules/zod/mini/index.d.cts +3 -0
- package/node_modules/zod/mini/index.d.ts +3 -0
- package/node_modules/zod/mini/index.js +3 -0
- package/node_modules/zod/mini/package.json +7 -0
- package/node_modules/zod/package.json +135 -0
- package/node_modules/zod/src/index.ts +4 -0
- package/node_modules/zod/src/locales/index.ts +1 -0
- package/node_modules/zod/src/mini/index.ts +3 -0
- package/node_modules/zod/src/v3/ZodError.ts +330 -0
- package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
- package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
- package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
- package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
- package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
- package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
- package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
- package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
- package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
- package/node_modules/zod/src/v3/errors.ts +13 -0
- package/node_modules/zod/src/v3/external.ts +6 -0
- package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
- package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
- package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
- package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
- package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
- package/node_modules/zod/src/v3/helpers/util.ts +224 -0
- package/node_modules/zod/src/v3/index.ts +4 -0
- package/node_modules/zod/src/v3/locales/en.ts +124 -0
- package/node_modules/zod/src/v3/standard-schema.ts +113 -0
- package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
- package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
- package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
- package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
- package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
- package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
- package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
- package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
- package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
- package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/complex.test.ts +70 -0
- package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
- package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
- package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
- package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
- package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
- package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
- package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
- package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
- package/node_modules/zod/src/v3/tests/function.test.ts +261 -0
- package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
- package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
- package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
- package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
- package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
- package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
- package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
- package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
- package/node_modules/zod/src/v3/tests/nan.test.ts +24 -0
- package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
- package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
- package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
- package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
- package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
- package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
- package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
- package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
- package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
- package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
- package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
- package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
- package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
- package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
- package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
- package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
- package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
- package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
- package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
- package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
- package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
- package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
- package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
- package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
- package/node_modules/zod/src/v3/types.ts +5138 -0
- package/node_modules/zod/src/v4/classic/checks.ts +32 -0
- package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
- package/node_modules/zod/src/v4/classic/compat.ts +70 -0
- package/node_modules/zod/src/v4/classic/errors.ts +82 -0
- package/node_modules/zod/src/v4/classic/external.ts +52 -0
- package/node_modules/zod/src/v4/classic/from-json-schema.ts +659 -0
- package/node_modules/zod/src/v4/classic/index.ts +5 -0
- package/node_modules/zod/src/v4/classic/iso.ts +90 -0
- package/node_modules/zod/src/v4/classic/parse.ts +82 -0
- package/node_modules/zod/src/v4/classic/schemas.ts +2672 -0
- package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/apply.test.ts +59 -0
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
- package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +216 -0
- package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
- package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
- package/node_modules/zod/src/v4/classic/tests/brand.test.ts +106 -0
- package/node_modules/zod/src/v4/classic/tests/catch.test.ts +326 -0
- package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
- package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +573 -0
- package/node_modules/zod/src/v4/classic/tests/codec.test.ts +703 -0
- package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
- package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +374 -0
- package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
- package/node_modules/zod/src/v4/classic/tests/date.test.ts +62 -0
- package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
- package/node_modules/zod/src/v4/classic/tests/default.test.ts +409 -0
- package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
- package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
- package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +694 -0
- package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
- package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +807 -0
- package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
- package/node_modules/zod/src/v4/classic/tests/file.test.ts +96 -0
- package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +179 -0
- package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +895 -0
- package/node_modules/zod/src/v4/classic/tests/function.test.ts +360 -0
- package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
- package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
- package/node_modules/zod/src/v4/classic/tests/hash.test.ts +68 -0
- package/node_modules/zod/src/v4/classic/tests/index.test.ts +939 -0
- package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +60 -0
- package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +198 -0
- package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
- package/node_modules/zod/src/v4/classic/tests/json.test.ts +109 -0
- package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
- package/node_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
- package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +330 -0
- package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
- package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
- package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +101 -0
- package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
- package/node_modules/zod/src/v4/classic/tests/number.test.ts +325 -0
- package/node_modules/zod/src/v4/classic/tests/object.test.ts +717 -0
- package/node_modules/zod/src/v4/classic/tests/optional.test.ts +333 -0
- package/node_modules/zod/src/v4/classic/tests/partial.test.ts +450 -0
- package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +211 -0
- package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +101 -0
- package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +74 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +26 -0
- package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +351 -0
- package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
- package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
- package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
- package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
- package/node_modules/zod/src/v4/classic/tests/record.test.ts +717 -0
- package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +631 -0
- package/node_modules/zod/src/v4/classic/tests/refine.test.ts +633 -0
- package/node_modules/zod/src/v4/classic/tests/registries.test.ts +243 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +181 -0
- package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +134 -0
- package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +125 -0
- package/node_modules/zod/src/v4/classic/tests/string.test.ts +1224 -0
- package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +106 -0
- package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +771 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
- package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +3125 -0
- package/node_modules/zod/src/v4/classic/tests/transform.test.ts +378 -0
- package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +496 -0
- package/node_modules/zod/src/v4/classic/tests/union.test.ts +273 -0
- package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
- package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
- package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
- package/node_modules/zod/src/v4/core/api.ts +1823 -0
- package/node_modules/zod/src/v4/core/checks.ts +1293 -0
- package/node_modules/zod/src/v4/core/config.ts +15 -0
- package/node_modules/zod/src/v4/core/core.ts +153 -0
- package/node_modules/zod/src/v4/core/doc.ts +44 -0
- package/node_modules/zod/src/v4/core/errors.ts +455 -0
- package/node_modules/zod/src/v4/core/index.ts +16 -0
- package/node_modules/zod/src/v4/core/json-schema-generator.ts +126 -0
- package/node_modules/zod/src/v4/core/json-schema-processors.ts +666 -0
- package/node_modules/zod/src/v4/core/json-schema.ts +147 -0
- package/node_modules/zod/src/v4/core/parse.ts +195 -0
- package/node_modules/zod/src/v4/core/regexes.ts +190 -0
- package/node_modules/zod/src/v4/core/registries.ts +105 -0
- package/node_modules/zod/src/v4/core/schemas.ts +4730 -0
- package/node_modules/zod/src/v4/core/standard-schema.ts +159 -0
- package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
- package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
- package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
- package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
- package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +181 -0
- package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
- package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
- package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
- package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
- package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
- package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
- package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +105 -0
- package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +125 -0
- package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
- package/node_modules/zod/src/v4/core/to-json-schema.ts +622 -0
- package/node_modules/zod/src/v4/core/util.ts +983 -0
- package/node_modules/zod/src/v4/core/versions.ts +5 -0
- package/node_modules/zod/src/v4/core/zsf.ts +323 -0
- package/node_modules/zod/src/v4/index.ts +4 -0
- package/node_modules/zod/src/v4/locales/ar.ts +115 -0
- package/node_modules/zod/src/v4/locales/az.ts +111 -0
- package/node_modules/zod/src/v4/locales/be.ts +176 -0
- package/node_modules/zod/src/v4/locales/bg.ts +128 -0
- package/node_modules/zod/src/v4/locales/ca.ts +116 -0
- package/node_modules/zod/src/v4/locales/cs.ts +118 -0
- package/node_modules/zod/src/v4/locales/da.ts +123 -0
- package/node_modules/zod/src/v4/locales/de.ts +116 -0
- package/node_modules/zod/src/v4/locales/el.ts +121 -0
- package/node_modules/zod/src/v4/locales/en.ts +123 -0
- package/node_modules/zod/src/v4/locales/eo.ts +118 -0
- package/node_modules/zod/src/v4/locales/es.ts +141 -0
- package/node_modules/zod/src/v4/locales/fa.ts +126 -0
- package/node_modules/zod/src/v4/locales/fi.ts +121 -0
- package/node_modules/zod/src/v4/locales/fr-CA.ts +116 -0
- package/node_modules/zod/src/v4/locales/fr.ts +132 -0
- package/node_modules/zod/src/v4/locales/he.ts +246 -0
- package/node_modules/zod/src/v4/locales/hr.ts +131 -0
- package/node_modules/zod/src/v4/locales/hu.ts +117 -0
- package/node_modules/zod/src/v4/locales/hy.ts +164 -0
- package/node_modules/zod/src/v4/locales/id.ts +115 -0
- package/node_modules/zod/src/v4/locales/index.ts +52 -0
- package/node_modules/zod/src/v4/locales/is.ts +119 -0
- package/node_modules/zod/src/v4/locales/it.ts +116 -0
- package/node_modules/zod/src/v4/locales/ja.ts +114 -0
- package/node_modules/zod/src/v4/locales/ka.ts +123 -0
- package/node_modules/zod/src/v4/locales/kh.ts +7 -0
- package/node_modules/zod/src/v4/locales/km.ts +119 -0
- package/node_modules/zod/src/v4/locales/ko.ts +121 -0
- package/node_modules/zod/src/v4/locales/lt.ts +239 -0
- package/node_modules/zod/src/v4/locales/mk.ts +118 -0
- package/node_modules/zod/src/v4/locales/ms.ts +115 -0
- package/node_modules/zod/src/v4/locales/nl.ts +121 -0
- package/node_modules/zod/src/v4/locales/no.ts +116 -0
- package/node_modules/zod/src/v4/locales/ota.ts +117 -0
- package/node_modules/zod/src/v4/locales/pl.ts +118 -0
- package/node_modules/zod/src/v4/locales/ps.ts +126 -0
- package/node_modules/zod/src/v4/locales/pt.ts +116 -0
- package/node_modules/zod/src/v4/locales/ro.ts +129 -0
- package/node_modules/zod/src/v4/locales/ru.ts +176 -0
- package/node_modules/zod/src/v4/locales/sl.ts +118 -0
- package/node_modules/zod/src/v4/locales/sv.ts +119 -0
- package/node_modules/zod/src/v4/locales/ta.ts +118 -0
- package/node_modules/zod/src/v4/locales/th.ts +119 -0
- package/node_modules/zod/src/v4/locales/tr.ts +111 -0
- package/node_modules/zod/src/v4/locales/ua.ts +7 -0
- package/node_modules/zod/src/v4/locales/uk.ts +117 -0
- package/node_modules/zod/src/v4/locales/ur.ts +119 -0
- package/node_modules/zod/src/v4/locales/uz.ts +117 -0
- package/node_modules/zod/src/v4/locales/vi.ts +117 -0
- package/node_modules/zod/src/v4/locales/yo.ts +124 -0
- package/node_modules/zod/src/v4/locales/zh-CN.ts +116 -0
- package/node_modules/zod/src/v4/locales/zh-TW.ts +115 -0
- package/node_modules/zod/src/v4/mini/checks.ts +32 -0
- package/node_modules/zod/src/v4/mini/coerce.ts +27 -0
- package/node_modules/zod/src/v4/mini/external.ts +41 -0
- package/node_modules/zod/src/v4/mini/index.ts +3 -0
- package/node_modules/zod/src/v4/mini/iso.ts +66 -0
- package/node_modules/zod/src/v4/mini/parse.ts +14 -0
- package/node_modules/zod/src/v4/mini/schemas.ts +1947 -0
- package/node_modules/zod/src/v4/mini/tests/apply.test.ts +24 -0
- package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
- package/node_modules/zod/src/v4/mini/tests/brand.test.ts +94 -0
- package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
- package/node_modules/zod/src/v4/mini/tests/codec.test.ts +548 -0
- package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
- package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
- package/node_modules/zod/src/v4/mini/tests/functions.test.ts +5 -0
- package/node_modules/zod/src/v4/mini/tests/index.test.ts +993 -0
- package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
- package/node_modules/zod/src/v4/mini/tests/object.test.ts +227 -0
- package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
- package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +325 -0
- package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +50 -0
- package/node_modules/zod/src/v4/mini/tests/string.test.ts +352 -0
- package/node_modules/zod/src/v4-mini/index.ts +3 -0
- package/node_modules/zod/v3/ZodError.cjs +138 -0
- package/node_modules/zod/v3/ZodError.d.cts +164 -0
- package/node_modules/zod/v3/ZodError.d.ts +164 -0
- package/node_modules/zod/v3/ZodError.js +133 -0
- package/node_modules/zod/v3/errors.cjs +17 -0
- package/node_modules/zod/v3/errors.d.cts +5 -0
- package/node_modules/zod/v3/errors.d.ts +5 -0
- package/node_modules/zod/v3/errors.js +9 -0
- package/node_modules/zod/v3/external.cjs +22 -0
- package/node_modules/zod/v3/external.d.cts +6 -0
- package/node_modules/zod/v3/external.d.ts +6 -0
- package/node_modules/zod/v3/external.js +6 -0
- package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
- package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
- package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
- package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
- package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
- package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
- package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/node_modules/zod/v3/helpers/util.cjs +137 -0
- package/node_modules/zod/v3/helpers/util.d.cts +85 -0
- package/node_modules/zod/v3/helpers/util.d.ts +85 -0
- package/node_modules/zod/v3/helpers/util.js +133 -0
- package/node_modules/zod/v3/index.cjs +33 -0
- package/node_modules/zod/v3/index.d.cts +4 -0
- package/node_modules/zod/v3/index.d.ts +4 -0
- package/node_modules/zod/v3/index.js +4 -0
- package/node_modules/zod/v3/locales/en.cjs +112 -0
- package/node_modules/zod/v3/locales/en.d.cts +3 -0
- package/node_modules/zod/v3/locales/en.d.ts +3 -0
- package/node_modules/zod/v3/locales/en.js +109 -0
- package/node_modules/zod/v3/package.json +7 -0
- package/node_modules/zod/v3/standard-schema.cjs +2 -0
- package/node_modules/zod/v3/standard-schema.d.cts +102 -0
- package/node_modules/zod/v3/standard-schema.d.ts +102 -0
- package/node_modules/zod/v3/standard-schema.js +1 -0
- package/node_modules/zod/v3/types.cjs +3777 -0
- package/node_modules/zod/v3/types.d.cts +1034 -0
- package/node_modules/zod/v3/types.d.ts +1034 -0
- package/node_modules/zod/v3/types.js +3695 -0
- package/node_modules/zod/v4/classic/checks.cjs +33 -0
- package/node_modules/zod/v4/classic/checks.d.cts +1 -0
- package/node_modules/zod/v4/classic/checks.d.ts +1 -0
- package/node_modules/zod/v4/classic/checks.js +1 -0
- package/node_modules/zod/v4/classic/coerce.cjs +47 -0
- package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
- package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
- package/node_modules/zod/v4/classic/coerce.js +17 -0
- package/node_modules/zod/v4/classic/compat.cjs +61 -0
- package/node_modules/zod/v4/classic/compat.d.cts +50 -0
- package/node_modules/zod/v4/classic/compat.d.ts +50 -0
- package/node_modules/zod/v4/classic/compat.js +31 -0
- package/node_modules/zod/v4/classic/errors.cjs +74 -0
- package/node_modules/zod/v4/classic/errors.d.cts +30 -0
- package/node_modules/zod/v4/classic/errors.d.ts +30 -0
- package/node_modules/zod/v4/classic/errors.js +48 -0
- package/node_modules/zod/v4/classic/external.cjs +73 -0
- package/node_modules/zod/v4/classic/external.d.cts +16 -0
- package/node_modules/zod/v4/classic/external.d.ts +16 -0
- package/node_modules/zod/v4/classic/external.js +20 -0
- package/node_modules/zod/v4/classic/from-json-schema.cjs +625 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
- package/node_modules/zod/v4/classic/from-json-schema.js +599 -0
- package/node_modules/zod/v4/classic/index.cjs +33 -0
- package/node_modules/zod/v4/classic/index.d.cts +4 -0
- package/node_modules/zod/v4/classic/index.d.ts +4 -0
- package/node_modules/zod/v4/classic/index.js +4 -0
- package/node_modules/zod/v4/classic/iso.cjs +60 -0
- package/node_modules/zod/v4/classic/iso.d.cts +22 -0
- package/node_modules/zod/v4/classic/iso.d.ts +22 -0
- package/node_modules/zod/v4/classic/iso.js +30 -0
- package/node_modules/zod/v4/classic/package.json +7 -0
- package/node_modules/zod/v4/classic/parse.cjs +41 -0
- package/node_modules/zod/v4/classic/parse.d.cts +31 -0
- package/node_modules/zod/v4/classic/parse.d.ts +31 -0
- package/node_modules/zod/v4/classic/parse.js +15 -0
- package/node_modules/zod/v4/classic/schemas.cjs +1511 -0
- package/node_modules/zod/v4/classic/schemas.d.cts +767 -0
- package/node_modules/zod/v4/classic/schemas.d.ts +767 -0
- package/node_modules/zod/v4/classic/schemas.js +1395 -0
- package/node_modules/zod/v4/core/api.cjs +1227 -0
- package/node_modules/zod/v4/core/api.d.cts +325 -0
- package/node_modules/zod/v4/core/api.d.ts +325 -0
- package/node_modules/zod/v4/core/api.js +1087 -0
- package/node_modules/zod/v4/core/checks.cjs +601 -0
- package/node_modules/zod/v4/core/checks.d.cts +278 -0
- package/node_modules/zod/v4/core/checks.d.ts +278 -0
- package/node_modules/zod/v4/core/checks.js +575 -0
- package/node_modules/zod/v4/core/core.cjs +85 -0
- package/node_modules/zod/v4/core/core.d.cts +70 -0
- package/node_modules/zod/v4/core/core.d.ts +70 -0
- package/node_modules/zod/v4/core/core.js +78 -0
- package/node_modules/zod/v4/core/doc.cjs +39 -0
- package/node_modules/zod/v4/core/doc.d.cts +14 -0
- package/node_modules/zod/v4/core/doc.d.ts +14 -0
- package/node_modules/zod/v4/core/doc.js +35 -0
- package/node_modules/zod/v4/core/errors.cjs +216 -0
- package/node_modules/zod/v4/core/errors.d.cts +221 -0
- package/node_modules/zod/v4/core/errors.d.ts +221 -0
- package/node_modules/zod/v4/core/errors.js +185 -0
- package/node_modules/zod/v4/core/index.cjs +47 -0
- package/node_modules/zod/v4/core/index.d.cts +16 -0
- package/node_modules/zod/v4/core/index.d.ts +16 -0
- package/node_modules/zod/v4/core/index.js +16 -0
- package/node_modules/zod/v4/core/json-schema-generator.cjs +99 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
- package/node_modules/zod/v4/core/json-schema-generator.js +95 -0
- package/node_modules/zod/v4/core/json-schema-processors.cjs +644 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.cts +49 -0
- package/node_modules/zod/v4/core/json-schema-processors.d.ts +49 -0
- package/node_modules/zod/v4/core/json-schema-processors.js +601 -0
- package/node_modules/zod/v4/core/json-schema.cjs +2 -0
- package/node_modules/zod/v4/core/json-schema.d.cts +88 -0
- package/node_modules/zod/v4/core/json-schema.d.ts +88 -0
- package/node_modules/zod/v4/core/json-schema.js +1 -0
- package/node_modules/zod/v4/core/package.json +7 -0
- package/node_modules/zod/v4/core/parse.cjs +131 -0
- package/node_modules/zod/v4/core/parse.d.cts +49 -0
- package/node_modules/zod/v4/core/parse.d.ts +49 -0
- package/node_modules/zod/v4/core/parse.js +93 -0
- package/node_modules/zod/v4/core/regexes.cjs +172 -0
- package/node_modules/zod/v4/core/regexes.d.cts +85 -0
- package/node_modules/zod/v4/core/regexes.d.ts +85 -0
- package/node_modules/zod/v4/core/regexes.js +139 -0
- package/node_modules/zod/v4/core/registries.cjs +56 -0
- package/node_modules/zod/v4/core/registries.d.cts +35 -0
- package/node_modules/zod/v4/core/registries.d.ts +35 -0
- package/node_modules/zod/v4/core/registries.js +51 -0
- package/node_modules/zod/v4/core/schemas.cjs +2270 -0
- package/node_modules/zod/v4/core/schemas.d.cts +1184 -0
- package/node_modules/zod/v4/core/schemas.d.ts +1184 -0
- package/node_modules/zod/v4/core/schemas.js +2239 -0
- package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
- package/node_modules/zod/v4/core/standard-schema.d.cts +126 -0
- package/node_modules/zod/v4/core/standard-schema.d.ts +126 -0
- package/node_modules/zod/v4/core/standard-schema.js +1 -0
- package/node_modules/zod/v4/core/to-json-schema.cjs +457 -0
- package/node_modules/zod/v4/core/to-json-schema.d.cts +114 -0
- package/node_modules/zod/v4/core/to-json-schema.d.ts +114 -0
- package/node_modules/zod/v4/core/to-json-schema.js +448 -0
- package/node_modules/zod/v4/core/util.cjs +734 -0
- package/node_modules/zod/v4/core/util.d.cts +200 -0
- package/node_modules/zod/v4/core/util.d.ts +200 -0
- package/node_modules/zod/v4/core/util.js +674 -0
- package/node_modules/zod/v4/core/versions.cjs +8 -0
- package/node_modules/zod/v4/core/versions.d.cts +5 -0
- package/node_modules/zod/v4/core/versions.d.ts +5 -0
- package/node_modules/zod/v4/core/versions.js +5 -0
- package/node_modules/zod/v4/index.cjs +22 -0
- package/node_modules/zod/v4/index.d.cts +3 -0
- package/node_modules/zod/v4/index.d.ts +3 -0
- package/node_modules/zod/v4/index.js +3 -0
- package/node_modules/zod/v4/locales/ar.cjs +133 -0
- package/node_modules/zod/v4/locales/ar.d.cts +5 -0
- package/node_modules/zod/v4/locales/ar.d.ts +4 -0
- package/node_modules/zod/v4/locales/ar.js +106 -0
- package/node_modules/zod/v4/locales/az.cjs +132 -0
- package/node_modules/zod/v4/locales/az.d.cts +5 -0
- package/node_modules/zod/v4/locales/az.d.ts +4 -0
- package/node_modules/zod/v4/locales/az.js +105 -0
- package/node_modules/zod/v4/locales/be.cjs +183 -0
- package/node_modules/zod/v4/locales/be.d.cts +5 -0
- package/node_modules/zod/v4/locales/be.d.ts +4 -0
- package/node_modules/zod/v4/locales/be.js +156 -0
- package/node_modules/zod/v4/locales/bg.cjs +147 -0
- package/node_modules/zod/v4/locales/bg.d.cts +5 -0
- package/node_modules/zod/v4/locales/bg.d.ts +4 -0
- package/node_modules/zod/v4/locales/bg.js +120 -0
- package/node_modules/zod/v4/locales/ca.cjs +134 -0
- package/node_modules/zod/v4/locales/ca.d.cts +5 -0
- package/node_modules/zod/v4/locales/ca.d.ts +4 -0
- package/node_modules/zod/v4/locales/ca.js +107 -0
- package/node_modules/zod/v4/locales/cs.cjs +138 -0
- package/node_modules/zod/v4/locales/cs.d.cts +5 -0
- package/node_modules/zod/v4/locales/cs.d.ts +4 -0
- package/node_modules/zod/v4/locales/cs.js +111 -0
- package/node_modules/zod/v4/locales/da.cjs +142 -0
- package/node_modules/zod/v4/locales/da.d.cts +5 -0
- package/node_modules/zod/v4/locales/da.d.ts +4 -0
- package/node_modules/zod/v4/locales/da.js +115 -0
- package/node_modules/zod/v4/locales/de.cjs +135 -0
- package/node_modules/zod/v4/locales/de.d.cts +5 -0
- package/node_modules/zod/v4/locales/de.d.ts +4 -0
- package/node_modules/zod/v4/locales/de.js +108 -0
- package/node_modules/zod/v4/locales/el.cjs +136 -0
- package/node_modules/zod/v4/locales/el.d.cts +5 -0
- package/node_modules/zod/v4/locales/el.d.ts +4 -0
- package/node_modules/zod/v4/locales/el.js +109 -0
- package/node_modules/zod/v4/locales/en.cjs +140 -0
- package/node_modules/zod/v4/locales/en.d.cts +5 -0
- package/node_modules/zod/v4/locales/en.d.ts +4 -0
- package/node_modules/zod/v4/locales/en.js +113 -0
- package/node_modules/zod/v4/locales/eo.cjs +136 -0
- package/node_modules/zod/v4/locales/eo.d.cts +5 -0
- package/node_modules/zod/v4/locales/eo.d.ts +4 -0
- package/node_modules/zod/v4/locales/eo.js +109 -0
- package/node_modules/zod/v4/locales/es.cjs +159 -0
- package/node_modules/zod/v4/locales/es.d.cts +5 -0
- package/node_modules/zod/v4/locales/es.d.ts +4 -0
- package/node_modules/zod/v4/locales/es.js +132 -0
- package/node_modules/zod/v4/locales/fa.cjs +141 -0
- package/node_modules/zod/v4/locales/fa.d.cts +5 -0
- package/node_modules/zod/v4/locales/fa.d.ts +4 -0
- package/node_modules/zod/v4/locales/fa.js +114 -0
- package/node_modules/zod/v4/locales/fi.cjs +139 -0
- package/node_modules/zod/v4/locales/fi.d.cts +5 -0
- package/node_modules/zod/v4/locales/fi.d.ts +4 -0
- package/node_modules/zod/v4/locales/fi.js +112 -0
- package/node_modules/zod/v4/locales/fr-CA.cjs +134 -0
- package/node_modules/zod/v4/locales/fr-CA.d.cts +5 -0
- package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr-CA.js +107 -0
- package/node_modules/zod/v4/locales/fr.cjs +152 -0
- package/node_modules/zod/v4/locales/fr.d.cts +5 -0
- package/node_modules/zod/v4/locales/fr.d.ts +4 -0
- package/node_modules/zod/v4/locales/fr.js +125 -0
- package/node_modules/zod/v4/locales/he.cjs +241 -0
- package/node_modules/zod/v4/locales/he.d.cts +5 -0
- package/node_modules/zod/v4/locales/he.d.ts +4 -0
- package/node_modules/zod/v4/locales/he.js +214 -0
- package/node_modules/zod/v4/locales/hr.cjs +149 -0
- package/node_modules/zod/v4/locales/hr.d.cts +5 -0
- package/node_modules/zod/v4/locales/hr.d.ts +4 -0
- package/node_modules/zod/v4/locales/hr.js +122 -0
- package/node_modules/zod/v4/locales/hu.cjs +135 -0
- package/node_modules/zod/v4/locales/hu.d.cts +5 -0
- package/node_modules/zod/v4/locales/hu.d.ts +4 -0
- package/node_modules/zod/v4/locales/hu.js +108 -0
- package/node_modules/zod/v4/locales/hy.cjs +174 -0
- package/node_modules/zod/v4/locales/hy.d.cts +5 -0
- package/node_modules/zod/v4/locales/hy.d.ts +4 -0
- package/node_modules/zod/v4/locales/hy.js +147 -0
- package/node_modules/zod/v4/locales/id.cjs +133 -0
- package/node_modules/zod/v4/locales/id.d.cts +5 -0
- package/node_modules/zod/v4/locales/id.d.ts +4 -0
- package/node_modules/zod/v4/locales/id.js +106 -0
- package/node_modules/zod/v4/locales/index.cjs +111 -0
- package/node_modules/zod/v4/locales/index.d.cts +52 -0
- package/node_modules/zod/v4/locales/index.d.ts +52 -0
- package/node_modules/zod/v4/locales/index.js +52 -0
- package/node_modules/zod/v4/locales/is.cjs +136 -0
- package/node_modules/zod/v4/locales/is.d.cts +5 -0
- package/node_modules/zod/v4/locales/is.d.ts +4 -0
- package/node_modules/zod/v4/locales/is.js +109 -0
- package/node_modules/zod/v4/locales/it.cjs +135 -0
- package/node_modules/zod/v4/locales/it.d.cts +5 -0
- package/node_modules/zod/v4/locales/it.d.ts +4 -0
- package/node_modules/zod/v4/locales/it.js +108 -0
- package/node_modules/zod/v4/locales/ja.cjs +134 -0
- package/node_modules/zod/v4/locales/ja.d.cts +5 -0
- package/node_modules/zod/v4/locales/ja.d.ts +4 -0
- package/node_modules/zod/v4/locales/ja.js +107 -0
- package/node_modules/zod/v4/locales/ka.cjs +139 -0
- package/node_modules/zod/v4/locales/ka.d.cts +5 -0
- package/node_modules/zod/v4/locales/ka.d.ts +4 -0
- package/node_modules/zod/v4/locales/ka.js +112 -0
- package/node_modules/zod/v4/locales/kh.cjs +12 -0
- package/node_modules/zod/v4/locales/kh.d.cts +5 -0
- package/node_modules/zod/v4/locales/kh.d.ts +5 -0
- package/node_modules/zod/v4/locales/kh.js +5 -0
- package/node_modules/zod/v4/locales/km.cjs +137 -0
- package/node_modules/zod/v4/locales/km.d.cts +5 -0
- package/node_modules/zod/v4/locales/km.d.ts +4 -0
- package/node_modules/zod/v4/locales/km.js +110 -0
- package/node_modules/zod/v4/locales/ko.cjs +138 -0
- package/node_modules/zod/v4/locales/ko.d.cts +5 -0
- package/node_modules/zod/v4/locales/ko.d.ts +4 -0
- package/node_modules/zod/v4/locales/ko.js +111 -0
- package/node_modules/zod/v4/locales/lt.cjs +230 -0
- package/node_modules/zod/v4/locales/lt.d.cts +5 -0
- package/node_modules/zod/v4/locales/lt.d.ts +4 -0
- package/node_modules/zod/v4/locales/lt.js +203 -0
- package/node_modules/zod/v4/locales/mk.cjs +136 -0
- package/node_modules/zod/v4/locales/mk.d.cts +5 -0
- package/node_modules/zod/v4/locales/mk.d.ts +4 -0
- package/node_modules/zod/v4/locales/mk.js +109 -0
- package/node_modules/zod/v4/locales/ms.cjs +134 -0
- package/node_modules/zod/v4/locales/ms.d.cts +5 -0
- package/node_modules/zod/v4/locales/ms.d.ts +4 -0
- package/node_modules/zod/v4/locales/ms.js +107 -0
- package/node_modules/zod/v4/locales/nl.cjs +137 -0
- package/node_modules/zod/v4/locales/nl.d.cts +5 -0
- package/node_modules/zod/v4/locales/nl.d.ts +4 -0
- package/node_modules/zod/v4/locales/nl.js +110 -0
- package/node_modules/zod/v4/locales/no.cjs +135 -0
- package/node_modules/zod/v4/locales/no.d.cts +5 -0
- package/node_modules/zod/v4/locales/no.d.ts +4 -0
- package/node_modules/zod/v4/locales/no.js +108 -0
- package/node_modules/zod/v4/locales/ota.cjs +136 -0
- package/node_modules/zod/v4/locales/ota.d.cts +5 -0
- package/node_modules/zod/v4/locales/ota.d.ts +4 -0
- package/node_modules/zod/v4/locales/ota.js +109 -0
- package/node_modules/zod/v4/locales/package.json +7 -0
- package/node_modules/zod/v4/locales/pl.cjs +136 -0
- package/node_modules/zod/v4/locales/pl.d.cts +5 -0
- package/node_modules/zod/v4/locales/pl.d.ts +4 -0
- package/node_modules/zod/v4/locales/pl.js +109 -0
- package/node_modules/zod/v4/locales/ps.cjs +141 -0
- package/node_modules/zod/v4/locales/ps.d.cts +5 -0
- package/node_modules/zod/v4/locales/ps.d.ts +4 -0
- package/node_modules/zod/v4/locales/ps.js +114 -0
- package/node_modules/zod/v4/locales/pt.cjs +135 -0
- package/node_modules/zod/v4/locales/pt.d.cts +5 -0
- package/node_modules/zod/v4/locales/pt.d.ts +4 -0
- package/node_modules/zod/v4/locales/pt.js +108 -0
- package/node_modules/zod/v4/locales/ro.cjs +146 -0
- package/node_modules/zod/v4/locales/ro.d.cts +5 -0
- package/node_modules/zod/v4/locales/ro.d.ts +4 -0
- package/node_modules/zod/v4/locales/ro.js +119 -0
- package/node_modules/zod/v4/locales/ru.cjs +183 -0
- package/node_modules/zod/v4/locales/ru.d.cts +5 -0
- package/node_modules/zod/v4/locales/ru.d.ts +4 -0
- package/node_modules/zod/v4/locales/ru.js +156 -0
- package/node_modules/zod/v4/locales/sl.cjs +136 -0
- package/node_modules/zod/v4/locales/sl.d.cts +5 -0
- package/node_modules/zod/v4/locales/sl.d.ts +4 -0
- package/node_modules/zod/v4/locales/sl.js +109 -0
- package/node_modules/zod/v4/locales/sv.cjs +137 -0
- package/node_modules/zod/v4/locales/sv.d.cts +5 -0
- package/node_modules/zod/v4/locales/sv.d.ts +4 -0
- package/node_modules/zod/v4/locales/sv.js +110 -0
- package/node_modules/zod/v4/locales/ta.cjs +137 -0
- package/node_modules/zod/v4/locales/ta.d.cts +5 -0
- package/node_modules/zod/v4/locales/ta.d.ts +4 -0
- package/node_modules/zod/v4/locales/ta.js +110 -0
- package/node_modules/zod/v4/locales/th.cjs +137 -0
- package/node_modules/zod/v4/locales/th.d.cts +5 -0
- package/node_modules/zod/v4/locales/th.d.ts +4 -0
- package/node_modules/zod/v4/locales/th.js +110 -0
- package/node_modules/zod/v4/locales/tr.cjs +132 -0
- package/node_modules/zod/v4/locales/tr.d.cts +5 -0
- package/node_modules/zod/v4/locales/tr.d.ts +4 -0
- package/node_modules/zod/v4/locales/tr.js +105 -0
- package/node_modules/zod/v4/locales/ua.cjs +12 -0
- package/node_modules/zod/v4/locales/ua.d.cts +5 -0
- package/node_modules/zod/v4/locales/ua.d.ts +5 -0
- package/node_modules/zod/v4/locales/ua.js +5 -0
- package/node_modules/zod/v4/locales/uk.cjs +135 -0
- package/node_modules/zod/v4/locales/uk.d.cts +5 -0
- package/node_modules/zod/v4/locales/uk.d.ts +4 -0
- package/node_modules/zod/v4/locales/uk.js +108 -0
- package/node_modules/zod/v4/locales/ur.cjs +137 -0
- package/node_modules/zod/v4/locales/ur.d.cts +5 -0
- package/node_modules/zod/v4/locales/ur.d.ts +4 -0
- package/node_modules/zod/v4/locales/ur.js +110 -0
- package/node_modules/zod/v4/locales/uz.cjs +137 -0
- package/node_modules/zod/v4/locales/uz.d.cts +5 -0
- package/node_modules/zod/v4/locales/uz.d.ts +4 -0
- package/node_modules/zod/v4/locales/uz.js +110 -0
- package/node_modules/zod/v4/locales/vi.cjs +135 -0
- package/node_modules/zod/v4/locales/vi.d.cts +5 -0
- package/node_modules/zod/v4/locales/vi.d.ts +4 -0
- package/node_modules/zod/v4/locales/vi.js +108 -0
- package/node_modules/zod/v4/locales/yo.cjs +134 -0
- package/node_modules/zod/v4/locales/yo.d.cts +5 -0
- package/node_modules/zod/v4/locales/yo.d.ts +4 -0
- package/node_modules/zod/v4/locales/yo.js +107 -0
- package/node_modules/zod/v4/locales/zh-CN.cjs +136 -0
- package/node_modules/zod/v4/locales/zh-CN.d.cts +5 -0
- package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-CN.js +109 -0
- package/node_modules/zod/v4/locales/zh-TW.cjs +134 -0
- package/node_modules/zod/v4/locales/zh-TW.d.cts +5 -0
- package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
- package/node_modules/zod/v4/locales/zh-TW.js +107 -0
- package/node_modules/zod/v4/mini/checks.cjs +34 -0
- package/node_modules/zod/v4/mini/checks.d.cts +1 -0
- package/node_modules/zod/v4/mini/checks.d.ts +1 -0
- package/node_modules/zod/v4/mini/checks.js +1 -0
- package/node_modules/zod/v4/mini/coerce.cjs +52 -0
- package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
- package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
- package/node_modules/zod/v4/mini/coerce.js +22 -0
- package/node_modules/zod/v4/mini/external.cjs +63 -0
- package/node_modules/zod/v4/mini/external.d.cts +13 -0
- package/node_modules/zod/v4/mini/external.d.ts +13 -0
- package/node_modules/zod/v4/mini/external.js +14 -0
- package/node_modules/zod/v4/mini/index.cjs +32 -0
- package/node_modules/zod/v4/mini/index.d.cts +3 -0
- package/node_modules/zod/v4/mini/index.d.ts +3 -0
- package/node_modules/zod/v4/mini/index.js +3 -0
- package/node_modules/zod/v4/mini/iso.cjs +64 -0
- package/node_modules/zod/v4/mini/iso.d.cts +22 -0
- package/node_modules/zod/v4/mini/iso.d.ts +22 -0
- package/node_modules/zod/v4/mini/iso.js +34 -0
- package/node_modules/zod/v4/mini/package.json +7 -0
- package/node_modules/zod/v4/mini/parse.cjs +16 -0
- package/node_modules/zod/v4/mini/parse.d.cts +1 -0
- package/node_modules/zod/v4/mini/parse.d.ts +1 -0
- package/node_modules/zod/v4/mini/parse.js +1 -0
- package/node_modules/zod/v4/mini/schemas.cjs +1083 -0
- package/node_modules/zod/v4/mini/schemas.d.cts +445 -0
- package/node_modules/zod/v4/mini/schemas.d.ts +445 -0
- package/node_modules/zod/v4/mini/schemas.js +961 -0
- package/node_modules/zod/v4/package.json +7 -0
- package/node_modules/zod/v4-mini/index.cjs +32 -0
- package/node_modules/zod/v4-mini/index.d.cts +3 -0
- package/node_modules/zod/v4-mini/index.d.ts +3 -0
- package/node_modules/zod/v4-mini/index.js +3 -0
- package/node_modules/zod/v4-mini/package.json +7 -0
- package/openclaw.plugin.json +904 -0
- package/package.json +139 -8
- package/skills/imsg/SKILL.md +250 -0
|
@@ -0,0 +1,3550 @@
|
|
|
1
|
+
import { C as registerIMessageApprovalReactionTarget, D as buildIMessageApprovalConversationKeyForInbound, E as resolveIMessageReactionContext, I as probeIMessage, S as maybeResolveIMessageApprovalReaction, b as handleIMessageApprovalReaction, r as resolveIMessageInboundConversationId, x as listPendingIMessageApprovalReactionPollTargets, y as extractIMessageApprovalPromptBinding } from "./group-policy-DF9xSdik.js";
|
|
2
|
+
import { d as resolveIMessageChatDbLookupPath, f as resolveIMessageHomeDir, l as resolveIMessageRemoteHost, o as resolveIMessageAccount } from "./accounts-D00Njxg2.js";
|
|
3
|
+
import { c as parseIMessageAllowTarget, i as isAllowedIMessageReplyContextSender, l as parseIMessageTarget, n as formatIMessageChatTarget, s as normalizeIMessageHandle, v as getCachedIMessagePrivateApiStatus, y as imessageRpcSupportsMethod } from "./message-tool-api-CPDfJJoE.js";
|
|
4
|
+
import { c as rememberIMessageReplyCache, f as getIMessageRuntime, s as isKnownFromMeIMessageMessageId } from "./monitor-reply-cache-DKlYGd5x.js";
|
|
5
|
+
import { o as createIMessageRpcClient, r as sanitizeOutboundText } from "./sanitize-outbound-CoTZLXMw.js";
|
|
6
|
+
import { n as resolveIMessageAttachmentRoots, r as resolveIMessageRemoteAttachmentRoots } from "./media-contract-BEgdvYhW.js";
|
|
7
|
+
import { a as resolveCatchupConfig, i as performIMessageCatchup, n as advanceIMessageCatchupCursor } from "./catchup-D32oYNxR.js";
|
|
8
|
+
import { c as stripLeadingEchoTextCorruptionMarkers, i as hasPersistedIMessageEcho, o as resolveIMessageEchoMediaKey } from "./persisted-echo-cache-BPWGUK-L.js";
|
|
9
|
+
import { a as maybeResolveIMessageApprovalPollVote, o as iMessageApprovalControlBindings, t as sendMessageIMessage } from "./send-BUXW76tw.js";
|
|
10
|
+
import { n as maybeResolveIMessageQuestionReaction, t as hasIMessageQuestionReactionTarget } from "./question-reactions-DVe50UhB.js";
|
|
11
|
+
import { bindIngressLifecycleToReplyOptions, createChannelIngressError, createChannelIngressMonitor, createChannelMessageReplyPipeline, createMessageReceiptFromOutboundResults, listMessageReceiptPlatformIds, resolveChannelStreamingBlockEnabled } from "openclaw/plugin-sdk/channel-outbound";
|
|
12
|
+
import { chunkMarkdownTextWithMode as chunkTextWithMode, resolveChunkMode, resolveTextChunkLimit } from "openclaw/plugin-sdk/reply-runtime";
|
|
13
|
+
import { resolveAgentRoute, resolveInboundLastRouteSessionKey } from "openclaw/plugin-sdk/routing";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { expectDefined } from "openclaw/plugin-sdk/expect-runtime";
|
|
16
|
+
import { asSafeIntegerInRange, hasNonEmptyString, isRecord, normalizeOptionalString, normalizeStringEntries, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
17
|
+
import fs from "node:fs/promises";
|
|
18
|
+
import { createNonExitingRuntime, danger, logVerbose, shouldLogVerbose, warn } from "openclaw/plugin-sdk/runtime-env";
|
|
19
|
+
import { asDateTimestampMs, asPositiveFiniteNumber, parseDateStringTimestampMs, resolveExpiresAtMsFromDurationMs, timestampMsToIsoString } from "openclaw/plugin-sdk/number-runtime";
|
|
20
|
+
import { createHash } from "node:crypto";
|
|
21
|
+
import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
|
22
|
+
import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
23
|
+
import { collectErrorGraphCandidates, formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
24
|
+
import { isInboundPathAllowed, kindFromMime } from "openclaw/plugin-sdk/media-runtime";
|
|
25
|
+
import { convertMarkdownTables as convertMarkdownTables$1, findCodeRegions, isInsideCode, sanitizeTerminalText } from "openclaw/plugin-sdk/text-chunking";
|
|
26
|
+
import { buildChannelGroupsScopeTree, resolveChannelGroupPolicy, resolveScopeRequireMention } from "openclaw/plugin-sdk/channel-policy";
|
|
27
|
+
import { buildChannelInboundEventContext, buildMentionRegexes, createChannelInboundDebouncer, createChannelPartialDeliveryError, filterChannelInboundQuoteContext, formatInboundEnvelope, formatInboundFromLabel, formatInboundMediaUnavailableText, formatMediaPlaceholderText, isChannelPartialDeliveryError, logInboundDrop, matchesMentionPatterns, resolveEnvelopeFormatOptions, resolveInboundMentionDecision, resolveInboundSupplementalSenderAllowed, runChannelInboundEvent, shouldDebounceTextInbound, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
|
|
28
|
+
import { openLocalFileSafely, resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
|
|
29
|
+
import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
|
|
30
|
+
import { resolveAgentConfig, resolveHumanDelayConfig } from "openclaw/plugin-sdk/agent-runtime";
|
|
31
|
+
import { CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY } from "openclaw/plugin-sdk/approval-handler-runtime";
|
|
32
|
+
import { logTypingFailure } from "openclaw/plugin-sdk/channel-feedback";
|
|
33
|
+
import { createChannelIngressResolver, defineStableChannelIngressIdentity, fanInChannelIngressLifecycles } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
34
|
+
import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
|
|
35
|
+
import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context";
|
|
36
|
+
import { readChannelAllowFromStore, resolveConfiguredBindingRoute, resolveRuntimeConversationBindingRoute, upsertChannelPairingRequest } from "openclaw/plugin-sdk/conversation-runtime";
|
|
37
|
+
import { channelReadyPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
|
38
|
+
import { redactIdentifier } from "openclaw/plugin-sdk/logging-core";
|
|
39
|
+
import { DEFAULT_GROUP_HISTORY_LIMIT, createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
|
|
40
|
+
import { resolveDefaultGroupPolicy, resolveOpenProviderRuntimeGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
41
|
+
import { getSessionEntry, readSessionUpdatedAt, resolveSendPolicy, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
42
|
+
import { openNodeSqliteDatabase } from "openclaw/plugin-sdk/sqlite-runtime";
|
|
43
|
+
import { waitForTransportReady } from "openclaw/plugin-sdk/transport-ready-runtime";
|
|
44
|
+
import { requireRuntimeConfig } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
45
|
+
import { resolveMarkdownTableMode as resolveMarkdownTableMode$1 } from "openclaw/plugin-sdk/markdown-table-runtime";
|
|
46
|
+
import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
|
|
47
|
+
import { deliverTextOrMediaReply, resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload";
|
|
48
|
+
import { createDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
|
|
49
|
+
import { hasControlCommand } from "openclaw/plugin-sdk/command-auth-native";
|
|
50
|
+
import { resolveChannelContextVisibilityMode } from "openclaw/plugin-sdk/context-visibility-runtime";
|
|
51
|
+
import { isRecord as isRecord$1 } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
|
52
|
+
import { saveMediaBuffer } from "openclaw/plugin-sdk/media-store";
|
|
53
|
+
import { loadWebMedia } from "openclaw/plugin-sdk/web-media";
|
|
54
|
+
import { enqueueSystemEvent } from "openclaw/plugin-sdk/system-event-runtime";
|
|
55
|
+
//#region extensions/imessage/src/approval-reaction-poller.ts
|
|
56
|
+
const RECENT_CHAT_LIMIT = 50;
|
|
57
|
+
const PER_CHAT_HISTORY_LIMIT = 30;
|
|
58
|
+
const OBSERVED_APPROVAL_PROMPT_TARGET_TTL_MS = 300 * 1e3;
|
|
59
|
+
const accountIdsWithCompletedNoTargetDiscovery = /* @__PURE__ */ new Set();
|
|
60
|
+
function normalizeChatId(value) {
|
|
61
|
+
return asPositiveFiniteNumber(value) ?? null;
|
|
62
|
+
}
|
|
63
|
+
function listTargetChatIds(targets) {
|
|
64
|
+
const chatIds = /* @__PURE__ */ new Set();
|
|
65
|
+
for (const target of targets) {
|
|
66
|
+
const chatId = normalizeChatId(target.conversation.chatId);
|
|
67
|
+
if (chatId !== null) chatIds.add(chatId);
|
|
68
|
+
}
|
|
69
|
+
return [...chatIds];
|
|
70
|
+
}
|
|
71
|
+
function hasUnscopedTarget(targets) {
|
|
72
|
+
return targets.some((target) => normalizeChatId(target.conversation.chatId) === null);
|
|
73
|
+
}
|
|
74
|
+
function uniqueChatIds(chatIds) {
|
|
75
|
+
return [...new Set(chatIds)];
|
|
76
|
+
}
|
|
77
|
+
function normalizeMessageGuid(value) {
|
|
78
|
+
return value.trim().replace(/^p:\d+\//iu, "");
|
|
79
|
+
}
|
|
80
|
+
function enumerateMessageGuidCandidates(value) {
|
|
81
|
+
const trimmed = value.trim();
|
|
82
|
+
if (!trimmed) return [];
|
|
83
|
+
return [trimmed, normalizeMessageGuid(trimmed)].filter((candidate, index, candidates) => candidate.length > 0 && candidates.indexOf(candidate) === index);
|
|
84
|
+
}
|
|
85
|
+
function buildPendingTargetsByMessageId(targets) {
|
|
86
|
+
const pendingByMessageId = /* @__PURE__ */ new Map();
|
|
87
|
+
for (const target of targets) for (const candidate of enumerateMessageGuidCandidates(target.messageId)) pendingByMessageId.set(candidate, target);
|
|
88
|
+
return pendingByMessageId;
|
|
89
|
+
}
|
|
90
|
+
async function listRecentChatIds(client) {
|
|
91
|
+
return ((await client.request("chats.list", { limit: RECENT_CHAT_LIMIT }, { timeoutMs: 1e4 })).chats ?? []).map((chat) => normalizeChatId(chat.id)).filter((chatId) => chatId !== null);
|
|
92
|
+
}
|
|
93
|
+
async function fetchRecentHistory(params) {
|
|
94
|
+
return ((await params.client.request("messages.history", {
|
|
95
|
+
chat_id: params.chatId,
|
|
96
|
+
limit: PER_CHAT_HISTORY_LIMIT
|
|
97
|
+
}, { timeoutMs: 1e4 })).messages ?? []).filter((message) => Boolean(message && typeof message === "object"));
|
|
98
|
+
}
|
|
99
|
+
function buildReactionPayload(params) {
|
|
100
|
+
const emoji = params.reaction.emoji?.trim();
|
|
101
|
+
const sender = params.reaction.sender?.trim();
|
|
102
|
+
const targetGuid = params.targetMessage.guid?.trim();
|
|
103
|
+
if (!emoji || !sender || !targetGuid) return null;
|
|
104
|
+
const reactionId = normalizeChatId(params.reaction.id);
|
|
105
|
+
return {
|
|
106
|
+
...reactionId !== null ? { id: reactionId } : {},
|
|
107
|
+
guid: `reaction:${targetGuid}:${sender}:${emoji}:${params.reaction.created_at ?? ""}`,
|
|
108
|
+
chat_id: params.targetMessage.chat_id,
|
|
109
|
+
chat_guid: params.targetMessage.chat_guid,
|
|
110
|
+
chat_identifier: params.targetMessage.chat_identifier,
|
|
111
|
+
chat_name: params.targetMessage.chat_name,
|
|
112
|
+
participants: params.targetMessage.participants,
|
|
113
|
+
is_group: params.targetMessage.is_group,
|
|
114
|
+
sender,
|
|
115
|
+
destination_caller_id: params.targetMessage.destination_caller_id,
|
|
116
|
+
is_from_me: params.reaction.is_from_me,
|
|
117
|
+
text: `${params.reaction.type ?? "reaction"} "${params.targetMessage.text ?? ""}"`,
|
|
118
|
+
created_at: params.reaction.created_at,
|
|
119
|
+
is_reaction: true,
|
|
120
|
+
is_tapback: true,
|
|
121
|
+
associated_message_guid: targetGuid,
|
|
122
|
+
associated_message_type: 2e3,
|
|
123
|
+
reaction_type: params.reaction.type ?? void 0,
|
|
124
|
+
reaction_emoji: emoji,
|
|
125
|
+
is_reaction_add: true,
|
|
126
|
+
reacted_to_guid: targetGuid
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function buildConversationKeyFromMessage(message) {
|
|
130
|
+
return {
|
|
131
|
+
...message.chat_guid?.trim() ? { chatGuid: message.chat_guid.trim() } : {},
|
|
132
|
+
...message.chat_identifier?.trim() ? { chatIdentifier: message.chat_identifier.trim() } : {},
|
|
133
|
+
...normalizeChatId(message.chat_id) !== null ? { chatId: message.chat_id } : {}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function bindObservedConversation(params) {
|
|
137
|
+
const nowMs = asDateTimestampMs(Date.now());
|
|
138
|
+
const expiresAtMs = asDateTimestampMs(params.target.expiresAtMs);
|
|
139
|
+
if (nowMs === void 0 || expiresAtMs === void 0 || expiresAtMs <= nowMs) return;
|
|
140
|
+
const ttlMs = expiresAtMs - nowMs;
|
|
141
|
+
const conversation = buildConversationKeyFromMessage(params.message);
|
|
142
|
+
const messageIds = /* @__PURE__ */ new Set([...enumerateMessageGuidCandidates(params.target.messageId), ...enumerateMessageGuidCandidates(params.message.guid ?? "")]);
|
|
143
|
+
for (const messageId of messageIds) registerIMessageApprovalReactionTarget({
|
|
144
|
+
accountId: params.target.accountId,
|
|
145
|
+
conversation,
|
|
146
|
+
messageId,
|
|
147
|
+
approvalId: params.target.approvalId,
|
|
148
|
+
approvalKind: params.target.approvalKind,
|
|
149
|
+
allowedDecisions: params.target.allowedDecisions,
|
|
150
|
+
ttlMs
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function bindObservedApprovalPrompt(params) {
|
|
154
|
+
if (params.message.is_from_me !== true) return null;
|
|
155
|
+
const messageId = params.message.guid?.trim();
|
|
156
|
+
if (!messageId) return null;
|
|
157
|
+
const binding = extractIMessageApprovalPromptBinding(params.message.text ?? "");
|
|
158
|
+
if (!binding) return null;
|
|
159
|
+
const conversation = buildConversationKeyFromMessage(params.message);
|
|
160
|
+
const expiresAtMs = resolveExpiresAtMsFromDurationMs(OBSERVED_APPROVAL_PROMPT_TARGET_TTL_MS);
|
|
161
|
+
if (expiresAtMs === void 0) return null;
|
|
162
|
+
const target = {
|
|
163
|
+
accountId: params.accountId,
|
|
164
|
+
conversation,
|
|
165
|
+
messageId,
|
|
166
|
+
approvalId: binding.approvalId,
|
|
167
|
+
approvalKind: binding.approvalKind,
|
|
168
|
+
allowedDecisions: binding.allowedDecisions,
|
|
169
|
+
expiresAtMs
|
|
170
|
+
};
|
|
171
|
+
bindObservedConversation({
|
|
172
|
+
target,
|
|
173
|
+
message: params.message
|
|
174
|
+
});
|
|
175
|
+
return target;
|
|
176
|
+
}
|
|
177
|
+
async function pollPendingIMessageApprovalReactions(params) {
|
|
178
|
+
const targets = listPendingIMessageApprovalReactionPollTargets({ accountId: params.accountId });
|
|
179
|
+
const shouldAttemptNoTargetDiscovery = targets.length === 0 && params.allowRecentChatDiscovery === true && !accountIdsWithCompletedNoTargetDiscovery.has(params.accountId);
|
|
180
|
+
if (targets.length === 0 && !shouldAttemptNoTargetDiscovery) return;
|
|
181
|
+
const pendingByMessageId = buildPendingTargetsByMessageId(targets);
|
|
182
|
+
const explicitChatIds = listTargetChatIds(targets);
|
|
183
|
+
const chatIds = params.allowRecentChatDiscovery === true && (targets.length === 0 || hasUnscopedTarget(targets)) ? uniqueChatIds([...explicitChatIds, ...await listRecentChatIds(params.client)]) : explicitChatIds;
|
|
184
|
+
if (chatIds.length === 0) {
|
|
185
|
+
if (shouldAttemptNoTargetDiscovery) accountIdsWithCompletedNoTargetDiscovery.add(params.accountId);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
let hadHistoryFetchError = false;
|
|
189
|
+
for (const chatId of chatIds) {
|
|
190
|
+
let messages;
|
|
191
|
+
try {
|
|
192
|
+
messages = await fetchRecentHistory({
|
|
193
|
+
client: params.client,
|
|
194
|
+
chatId
|
|
195
|
+
});
|
|
196
|
+
} catch (err) {
|
|
197
|
+
hadHistoryFetchError = true;
|
|
198
|
+
params.logVerboseMessage?.(`imessage: approval reaction poll skipped chat_id=${chatId}: ${String(err)}`);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
for (const message of messages) {
|
|
202
|
+
const targetGuid = message.guid?.trim();
|
|
203
|
+
if (!targetGuid) continue;
|
|
204
|
+
const target = pendingByMessageId.get(targetGuid) ?? pendingByMessageId.get(normalizeMessageGuid(targetGuid)) ?? bindObservedApprovalPrompt({
|
|
205
|
+
accountId: params.accountId,
|
|
206
|
+
message
|
|
207
|
+
});
|
|
208
|
+
if (!target) continue;
|
|
209
|
+
bindObservedConversation({
|
|
210
|
+
target,
|
|
211
|
+
message
|
|
212
|
+
});
|
|
213
|
+
for (const reaction of message.reactions ?? []) {
|
|
214
|
+
const reactionPayload = buildReactionPayload({
|
|
215
|
+
targetMessage: message,
|
|
216
|
+
reaction
|
|
217
|
+
});
|
|
218
|
+
if (!reactionPayload) continue;
|
|
219
|
+
const handled = await handleIMessageApprovalReaction({
|
|
220
|
+
cfg: params.cfg,
|
|
221
|
+
accountId: params.accountId,
|
|
222
|
+
message: reactionPayload,
|
|
223
|
+
bodyText: reactionPayload.text ?? "",
|
|
224
|
+
gatewayRuntime: params.gatewayRuntime,
|
|
225
|
+
logVerboseMessage: params.logVerboseMessage
|
|
226
|
+
});
|
|
227
|
+
if (handled.stopPolling) {
|
|
228
|
+
if (shouldAttemptNoTargetDiscovery && handled.stopPollingReason !== "resolver-error") break;
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (shouldAttemptNoTargetDiscovery && !hadHistoryFetchError) accountIdsWithCompletedNoTargetDiscovery.add(params.accountId);
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region extensions/imessage/src/chat.ts
|
|
238
|
+
function buildChatTargetParams(to, opts) {
|
|
239
|
+
const cfg = requireRuntimeConfig(opts.cfg, "iMessage chat action");
|
|
240
|
+
const account = opts.account ?? resolveIMessageAccount({
|
|
241
|
+
cfg,
|
|
242
|
+
accountId: opts.accountId
|
|
243
|
+
});
|
|
244
|
+
const target = parseIMessageTarget(opts.chatId ? formatIMessageChatTarget(opts.chatId) : to);
|
|
245
|
+
const params = {};
|
|
246
|
+
if (target.kind === "chat_id") params.chat_id = target.chatId;
|
|
247
|
+
else if (target.kind === "chat_guid") params.chat_guid = target.chatGuid;
|
|
248
|
+
else if (target.kind === "chat_identifier") params.chat_identifier = target.chatIdentifier;
|
|
249
|
+
else params.to = target.to;
|
|
250
|
+
return {
|
|
251
|
+
params,
|
|
252
|
+
service: opts.service ?? (target.kind === "handle" ? target.service : void 0) ?? account.config.service,
|
|
253
|
+
region: opts.region?.trim() || account.config.region?.trim() || "US",
|
|
254
|
+
account
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
async function runChatAction(method, params, opts) {
|
|
258
|
+
const cfg = requireRuntimeConfig(opts.cfg, "iMessage chat action");
|
|
259
|
+
const account = opts.account ?? resolveIMessageAccount({
|
|
260
|
+
cfg,
|
|
261
|
+
accountId: opts.accountId
|
|
262
|
+
});
|
|
263
|
+
const cliPath = opts.cliPath?.trim() || account.config.cliPath?.trim() || "imsg";
|
|
264
|
+
const dbPath = opts.dbPath?.trim() || account.config.dbPath?.trim();
|
|
265
|
+
const remoteHost = await resolveIMessageRemoteHost({
|
|
266
|
+
cliPath,
|
|
267
|
+
remoteHost: opts.remoteHost ?? account.config.remoteHost
|
|
268
|
+
});
|
|
269
|
+
const client = opts.client ?? await createIMessageRpcClient({
|
|
270
|
+
cliPath,
|
|
271
|
+
dbPath,
|
|
272
|
+
remoteHost
|
|
273
|
+
});
|
|
274
|
+
const shouldClose = !opts.client;
|
|
275
|
+
try {
|
|
276
|
+
return await client.request(method, params, { timeoutMs: opts.timeoutMs });
|
|
277
|
+
} finally {
|
|
278
|
+
if (shouldClose) await client.stop();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async function sendIMessageTyping(to, isTyping, opts) {
|
|
282
|
+
const { params, service } = buildChatTargetParams(to, opts);
|
|
283
|
+
params.typing = isTyping;
|
|
284
|
+
if (service) params.service = service;
|
|
285
|
+
await runChatAction("typing", params, opts);
|
|
286
|
+
}
|
|
287
|
+
async function markIMessageChatRead(to, opts) {
|
|
288
|
+
const { params } = buildChatTargetParams(to, opts);
|
|
289
|
+
await runChatAction("read", params, opts);
|
|
290
|
+
}
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region extensions/imessage/src/monitor/abort-handler.ts
|
|
293
|
+
function attachIMessageMonitorAbortHandler(params) {
|
|
294
|
+
const abort = params.abortSignal;
|
|
295
|
+
if (!abort) return () => {};
|
|
296
|
+
const onAbort = () => {
|
|
297
|
+
const subscriptionId = params.getSubscriptionId();
|
|
298
|
+
if (subscriptionId) params.client.request("watch.unsubscribe", { subscription: subscriptionId }).catch(() => {});
|
|
299
|
+
params.client.stop().catch(() => {});
|
|
300
|
+
};
|
|
301
|
+
abort.addEventListener("abort", onAbort, { once: true });
|
|
302
|
+
return () => abort.removeEventListener("abort", onAbort);
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region extensions/imessage/src/monitor/strip-imsg-length-prefixed-text.ts
|
|
306
|
+
const utf8Decoder = new TextDecoder();
|
|
307
|
+
function readVarint(buf, start) {
|
|
308
|
+
let offset = start;
|
|
309
|
+
let value = 0;
|
|
310
|
+
let shift = 0;
|
|
311
|
+
while (offset < buf.length && shift <= 28) {
|
|
312
|
+
const byte = buf[offset];
|
|
313
|
+
if (byte === void 0) return null;
|
|
314
|
+
offset += 1;
|
|
315
|
+
value |= (byte & 127) << shift;
|
|
316
|
+
if ((byte & 128) === 0) return {
|
|
317
|
+
nextOffset: offset,
|
|
318
|
+
value
|
|
319
|
+
};
|
|
320
|
+
shift += 7;
|
|
321
|
+
}
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
function tryStripImessageLengthPrefixedUtf8Buffer(buf) {
|
|
325
|
+
const key = readVarint(buf, 0);
|
|
326
|
+
if (!key || key.nextOffset >= buf.length) return null;
|
|
327
|
+
if (key.value !== 10) return null;
|
|
328
|
+
const length = readVarint(buf, key.nextOffset);
|
|
329
|
+
if (!length || length.value === 0) return null;
|
|
330
|
+
if (length.nextOffset + length.value !== buf.length) return null;
|
|
331
|
+
return buf.subarray(length.nextOffset, buf.length);
|
|
332
|
+
}
|
|
333
|
+
function stripImessageLengthPrefixedUtf8Text(text) {
|
|
334
|
+
if (!text) return text;
|
|
335
|
+
const stripped = tryStripImessageLengthPrefixedUtf8Buffer(Buffer.from(text, "utf8"));
|
|
336
|
+
if (!stripped) return text;
|
|
337
|
+
const inner = utf8Decoder.decode(stripped);
|
|
338
|
+
return inner.length > 0 ? inner : text;
|
|
339
|
+
}
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region extensions/imessage/src/monitor/parse-notification.ts
|
|
342
|
+
function isOptionalString(value) {
|
|
343
|
+
return value === void 0 || value === null || typeof value === "string";
|
|
344
|
+
}
|
|
345
|
+
function isOptionalStringOrNumber(value) {
|
|
346
|
+
return value === void 0 || value === null || typeof value === "string" || typeof value === "number";
|
|
347
|
+
}
|
|
348
|
+
function isOptionalNumber(value) {
|
|
349
|
+
return value === void 0 || value === null || typeof value === "number";
|
|
350
|
+
}
|
|
351
|
+
function isOptionalBoolean(value) {
|
|
352
|
+
return value === void 0 || value === null || typeof value === "boolean";
|
|
353
|
+
}
|
|
354
|
+
function isOptionalStringArray(value) {
|
|
355
|
+
return value === void 0 || value === null || Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
356
|
+
}
|
|
357
|
+
function isOptionalAttachments(value) {
|
|
358
|
+
if (value === void 0 || value === null) return true;
|
|
359
|
+
if (!Array.isArray(value)) return false;
|
|
360
|
+
return value.every((attachment) => {
|
|
361
|
+
if (!isRecord(attachment)) return false;
|
|
362
|
+
return isOptionalString(attachment.original_path) && isOptionalString(attachment.mime_type) && isOptionalBoolean(attachment.missing) && isOptionalString(attachment.transfer_name) && isOptionalString(attachment.uti);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function parseIMessageNotification(raw) {
|
|
366
|
+
if (!isRecord(raw)) return null;
|
|
367
|
+
const maybeMessage = raw.message;
|
|
368
|
+
if (!isRecord(maybeMessage)) return null;
|
|
369
|
+
const message = maybeMessage;
|
|
370
|
+
if (!isOptionalNumber(message.id) || !isOptionalString(message.guid) || !isOptionalNumber(message.chat_id) || !isOptionalString(message.sender) || !isOptionalString(message.destination_caller_id) || !isOptionalBoolean(message.is_from_me) || !isOptionalString(message.text) || !isOptionalStringOrNumber(message.reply_to_id) || !isOptionalString(message.reply_to_guid) || !isOptionalString(message.reply_to_text) || !isOptionalString(message.reply_to_sender) || !isOptionalString(message.created_at) || !isOptionalBoolean(message.is_reaction) || !isOptionalBoolean(message.is_tapback) || !isOptionalString(message.associated_message_guid) || !isOptionalNumber(message.associated_message_type) || !isOptionalString(message.reaction_type) || !isOptionalString(message.reaction_emoji) || !isOptionalBoolean(message.is_reaction_add) || !isOptionalString(message.reacted_to_guid) || !isOptionalAttachments(message.attachments) || !isOptionalString(message.chat_identifier) || !isOptionalString(message.chat_guid) || !isOptionalString(message.chat_name) || !isOptionalStringArray(message.participants) || !isOptionalBoolean(message.is_group)) return null;
|
|
371
|
+
return {
|
|
372
|
+
...message,
|
|
373
|
+
text: typeof message.text === "string" ? stripImessageLengthPrefixedUtf8Text(message.text) : message.text,
|
|
374
|
+
reply_to_text: typeof message.reply_to_text === "string" ? stripImessageLengthPrefixedUtf8Text(message.reply_to_text) : message.reply_to_text
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region extensions/imessage/src/monitor/catchup-bridge.ts
|
|
379
|
+
const PER_CHAT_HISTORY_LIMIT_CAP = 500;
|
|
380
|
+
const CATCHUP_CHATS_LIST_LIMIT = 200;
|
|
381
|
+
const CATCHUP_RPC_TIMEOUT_MS = 3e4;
|
|
382
|
+
/**
|
|
383
|
+
* Wire `performIMessageCatchup` against the live `imsg` JSON-RPC client.
|
|
384
|
+
*
|
|
385
|
+
* Catchup recovers messages that landed in `chat.db` while the gateway was
|
|
386
|
+
* offline (crash, restart, mac sleep) by:
|
|
387
|
+
* 1. listing recently-active chats via `chats.list`,
|
|
388
|
+
* 2. fetching per-chat history since the cursor via `messages.history`,
|
|
389
|
+
* 3. sorting cross-chat by `rowid`, capping at `perRunLimit`,
|
|
390
|
+
* 4. admitting each row through the same durable GUID queue used by live
|
|
391
|
+
* notifications, so replay, coalescing, echo, and receipt behavior match.
|
|
392
|
+
*
|
|
393
|
+
* Runs at most once per `monitorIMessageProvider` invocation, between
|
|
394
|
+
* `watch.subscribe` and the live dispatch loop. Anything that arrives during
|
|
395
|
+
* catchup itself flows through live admission; queue tombstones reject overlap.
|
|
396
|
+
*/
|
|
397
|
+
async function runIMessageCatchup(params) {
|
|
398
|
+
const { client, accountId, config, includeAttachments, dispatchPayload, runtime } = params;
|
|
399
|
+
const log = (msg) => runtime?.log?.(msg);
|
|
400
|
+
const warnLog = (msg) => runtime?.log?.(warn(msg));
|
|
401
|
+
const payloadByGuid = /* @__PURE__ */ new Map();
|
|
402
|
+
const fetchFn = async ({ sinceMs, sinceRowid, limit }) => {
|
|
403
|
+
const sinceISO = timestampMsToIsoString(sinceMs);
|
|
404
|
+
if (!sinceISO) {
|
|
405
|
+
warnLog(`imessage catchup: invalid since timestamp ${sinceMs}`);
|
|
406
|
+
return {
|
|
407
|
+
resolved: false,
|
|
408
|
+
rows: []
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
let chatsResult;
|
|
412
|
+
try {
|
|
413
|
+
chatsResult = await client.request("chats.list", { limit: CATCHUP_CHATS_LIST_LIMIT }, { timeoutMs: CATCHUP_RPC_TIMEOUT_MS });
|
|
414
|
+
} catch (err) {
|
|
415
|
+
warnLog(`imessage catchup: chats.list failed: ${String(err)}`);
|
|
416
|
+
return {
|
|
417
|
+
resolved: false,
|
|
418
|
+
rows: []
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
const chats = chatsResult?.chats ?? [];
|
|
422
|
+
const collected = [];
|
|
423
|
+
const perChatLimit = Math.min(limit, PER_CHAT_HISTORY_LIMIT_CAP);
|
|
424
|
+
let historyFetchFailed = false;
|
|
425
|
+
let rawWatermarkRowid = -Infinity;
|
|
426
|
+
let rawWatermarkMs = -Infinity;
|
|
427
|
+
for (const chat of chats) {
|
|
428
|
+
const chatId = typeof chat.id === "number" && Number.isFinite(chat.id) ? chat.id : null;
|
|
429
|
+
if (chatId === null) continue;
|
|
430
|
+
const lastMs = typeof chat.last_message_at === "string" ? Date.parse(chat.last_message_at) : NaN;
|
|
431
|
+
if (Number.isFinite(lastMs) && lastMs < sinceMs) continue;
|
|
432
|
+
let historyResult;
|
|
433
|
+
try {
|
|
434
|
+
historyResult = await client.request("messages.history", {
|
|
435
|
+
chat_id: chatId,
|
|
436
|
+
limit: perChatLimit,
|
|
437
|
+
start: sinceISO,
|
|
438
|
+
attachments: includeAttachments
|
|
439
|
+
}, { timeoutMs: CATCHUP_RPC_TIMEOUT_MS });
|
|
440
|
+
} catch (err) {
|
|
441
|
+
historyFetchFailed = true;
|
|
442
|
+
warnLog(`imessage catchup: messages.history failed for chat_id=${chatId}: ${String(err)}`);
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
const messages = Array.isArray(historyResult?.messages) ? historyResult.messages : [];
|
|
446
|
+
for (const raw of messages) {
|
|
447
|
+
const rawRecord = raw && typeof raw === "object" ? raw : null;
|
|
448
|
+
const rawRowid = rawRecord && typeof rawRecord.id === "number" && Number.isFinite(rawRecord.id) ? rawRecord.id : null;
|
|
449
|
+
const rawCreatedAt = rawRecord && typeof rawRecord.created_at === "string" ? rawRecord.created_at : null;
|
|
450
|
+
const rawDateMs = rawCreatedAt ? Date.parse(rawCreatedAt) : NaN;
|
|
451
|
+
if (rawRowid !== null) rawWatermarkRowid = Math.max(rawWatermarkRowid, rawRowid);
|
|
452
|
+
if (Number.isFinite(rawDateMs)) rawWatermarkMs = Math.max(rawWatermarkMs, rawDateMs);
|
|
453
|
+
const payload = parseIMessageNotification({ message: raw });
|
|
454
|
+
if (!payload) continue;
|
|
455
|
+
const guid = payload.guid?.trim();
|
|
456
|
+
const rowid = typeof payload.id === "number" ? payload.id : null;
|
|
457
|
+
const dateMs = typeof payload.created_at === "string" ? Date.parse(payload.created_at) : NaN;
|
|
458
|
+
if (!guid || rowid === null || !Number.isFinite(rowid) || !Number.isFinite(dateMs)) continue;
|
|
459
|
+
if (rowid <= sinceRowid) continue;
|
|
460
|
+
collected.push({
|
|
461
|
+
guid,
|
|
462
|
+
rowid,
|
|
463
|
+
date: dateMs,
|
|
464
|
+
isFromMe: payload.is_from_me === true
|
|
465
|
+
});
|
|
466
|
+
payloadByGuid.set(guid, {
|
|
467
|
+
message: payload,
|
|
468
|
+
rawEnvelope: { message: raw }
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const sorted = collected.toSorted((a, b) => a.rowid - b.rowid);
|
|
473
|
+
const capped = sorted.slice(0, limit);
|
|
474
|
+
const isCapTruncated = capped.length < sorted.length;
|
|
475
|
+
if (isCapTruncated) {
|
|
476
|
+
warnLog(`imessage catchup: fetched ${sorted.length} rows across chats, capped to perRunLimit=${limit} (oldest first); next startup picks up the rest`);
|
|
477
|
+
const keep = new Set(capped.map((row) => row.guid));
|
|
478
|
+
for (const guid of payloadByGuid.keys()) if (!keep.has(guid)) payloadByGuid.delete(guid);
|
|
479
|
+
}
|
|
480
|
+
let effectiveWatermarkRowid = rawWatermarkRowid;
|
|
481
|
+
let effectiveWatermarkMs = rawWatermarkMs;
|
|
482
|
+
if (isCapTruncated && capped.length > 0) {
|
|
483
|
+
const last = capped.at(-1);
|
|
484
|
+
if (last) {
|
|
485
|
+
effectiveWatermarkRowid = Math.min(effectiveWatermarkRowid, last.rowid);
|
|
486
|
+
effectiveWatermarkMs = Math.min(effectiveWatermarkMs, last.date);
|
|
487
|
+
}
|
|
488
|
+
} else if (isCapTruncated && capped.length === 0) {
|
|
489
|
+
effectiveWatermarkRowid = NaN;
|
|
490
|
+
effectiveWatermarkMs = NaN;
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
resolved: true,
|
|
494
|
+
rows: capped,
|
|
495
|
+
fullyCaughtUp: !historyFetchFailed && !isCapTruncated,
|
|
496
|
+
...Number.isFinite(effectiveWatermarkRowid) ? { highWatermarkRowid: effectiveWatermarkRowid } : {},
|
|
497
|
+
...Number.isFinite(effectiveWatermarkMs) ? { highWatermarkMs: effectiveWatermarkMs } : {}
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
const dispatchFn = async (row) => {
|
|
501
|
+
const entry = payloadByGuid.get(row.guid);
|
|
502
|
+
if (!entry) {
|
|
503
|
+
warnLog(`imessage catchup: missing payload for guid=${row.guid}, skipping`);
|
|
504
|
+
return { ok: false };
|
|
505
|
+
}
|
|
506
|
+
try {
|
|
507
|
+
await dispatchPayload(entry.message, entry.rawEnvelope);
|
|
508
|
+
return { ok: true };
|
|
509
|
+
} catch (err) {
|
|
510
|
+
warnLog(`imessage catchup: dispatch threw for guid=${row.guid}: ${String(err)}`);
|
|
511
|
+
return { ok: false };
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
return await performIMessageCatchup({
|
|
515
|
+
accountId,
|
|
516
|
+
config,
|
|
517
|
+
fetch: fetchFn,
|
|
518
|
+
dispatch: dispatchFn,
|
|
519
|
+
observeSkippedFromMe: async (row) => {
|
|
520
|
+
const entry = payloadByGuid.get(row.guid);
|
|
521
|
+
if (!entry) {
|
|
522
|
+
warnLog(`imessage catchup: missing skipped from-me payload for guid=${row.guid}`);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
await params.observeSkippedFromMePayload?.(entry.message);
|
|
526
|
+
},
|
|
527
|
+
log,
|
|
528
|
+
warn: warnLog,
|
|
529
|
+
...params.now ? { now: params.now() } : {}
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region extensions/imessage/src/monitor/coalesce.ts
|
|
534
|
+
/**
|
|
535
|
+
* Bounds on the merged output when multiple inbound iMessage payloads are
|
|
536
|
+
* folded into one agent turn. Caps each merge so a sender who
|
|
537
|
+
* rapid-fires DMs inside the debounce window cannot amplify the downstream
|
|
538
|
+
* prompt past a safe ceiling. Every source GUID still surfaces via
|
|
539
|
+
* `coalescedMessageGuids` so a future replay path can recognize duplicates.
|
|
540
|
+
*/
|
|
541
|
+
const MAX_COALESCED_TEXT_CHARS = 4e3;
|
|
542
|
+
const MAX_COALESCED_ATTACHMENTS = 20;
|
|
543
|
+
const MAX_COALESCED_ENTRIES = 10;
|
|
544
|
+
/**
|
|
545
|
+
* Combine consecutive same-sender iMessage payloads into a single payload for
|
|
546
|
+
* downstream dispatch. Used for the general inbound debounce
|
|
547
|
+
* (`messages.inbound`, off by default) when configured.
|
|
548
|
+
*
|
|
549
|
+
* The first payload anchors the merged shape (preserving its GUID for reply
|
|
550
|
+
* threading). Text is concatenated with deduplication, attachments are merged
|
|
551
|
+
* (capped), and the latest `created_at` wins so downstream sees the most
|
|
552
|
+
* recent activity timestamp.
|
|
553
|
+
*/
|
|
554
|
+
function combineIMessagePayloads(payloads) {
|
|
555
|
+
if (payloads.length === 0) throw new Error("combineIMessagePayloads: cannot combine empty payloads");
|
|
556
|
+
const first = expectDefined(payloads[0], "first iMessage payload to coalesce");
|
|
557
|
+
if (payloads.length === 1) return first;
|
|
558
|
+
const last = expectDefined(payloads.at(-1), "last iMessage payload to coalesce");
|
|
559
|
+
const boundedPayloads = payloads.length > MAX_COALESCED_ENTRIES ? [...payloads.slice(0, MAX_COALESCED_ENTRIES - 1), last] : payloads;
|
|
560
|
+
const seenTexts = /* @__PURE__ */ new Set();
|
|
561
|
+
const textParts = [];
|
|
562
|
+
for (const payload of boundedPayloads) {
|
|
563
|
+
const text = (payload.text ?? "").trim();
|
|
564
|
+
if (!text) continue;
|
|
565
|
+
const normalized = text.toLowerCase();
|
|
566
|
+
if (seenTexts.has(normalized)) continue;
|
|
567
|
+
seenTexts.add(normalized);
|
|
568
|
+
textParts.push(text);
|
|
569
|
+
}
|
|
570
|
+
let combinedText = textParts.join(" ");
|
|
571
|
+
if (combinedText.length > MAX_COALESCED_TEXT_CHARS) combinedText = `${sliceUtf16Safe(combinedText, 0, MAX_COALESCED_TEXT_CHARS)}…[truncated]`;
|
|
572
|
+
const allAttachments = boundedPayloads.flatMap((p) => p.attachments ?? []).slice(0, MAX_COALESCED_ATTACHMENTS);
|
|
573
|
+
const createdAts = payloads.map((p) => p.created_at).filter((c) => typeof c === "string" && c.length > 0);
|
|
574
|
+
const latestCreatedAt = createdAts.length > 0 ? createdAts.reduce((a, b) => a > b ? a : b) : first.created_at;
|
|
575
|
+
let maxRowid = -Infinity;
|
|
576
|
+
let maxDateMs = -Infinity;
|
|
577
|
+
for (const payload of payloads) {
|
|
578
|
+
if (typeof payload.id === "number" && Number.isFinite(payload.id)) maxRowid = Math.max(maxRowid, payload.id);
|
|
579
|
+
const dateMs = typeof payload.created_at === "string" ? Date.parse(payload.created_at) : NaN;
|
|
580
|
+
if (Number.isFinite(dateMs)) maxDateMs = Math.max(maxDateMs, dateMs);
|
|
581
|
+
}
|
|
582
|
+
const seenGuids = /* @__PURE__ */ new Set();
|
|
583
|
+
const coalescedMessageGuids = [];
|
|
584
|
+
for (const payload of payloads) {
|
|
585
|
+
const guid = payload.guid?.trim();
|
|
586
|
+
if (!guid || seenGuids.has(guid)) continue;
|
|
587
|
+
seenGuids.add(guid);
|
|
588
|
+
coalescedMessageGuids.push(guid);
|
|
589
|
+
}
|
|
590
|
+
const entryWithReply = payloads.find((p) => p.reply_to_id != null);
|
|
591
|
+
return {
|
|
592
|
+
...first,
|
|
593
|
+
text: combinedText,
|
|
594
|
+
attachments: allAttachments.length > 0 ? allAttachments : null,
|
|
595
|
+
created_at: latestCreatedAt,
|
|
596
|
+
reply_to_id: entryWithReply?.reply_to_id ?? first.reply_to_id ?? null,
|
|
597
|
+
reply_to_text: entryWithReply?.reply_to_text ?? first.reply_to_text ?? null,
|
|
598
|
+
reply_to_sender: entryWithReply?.reply_to_sender ?? first.reply_to_sender ?? null,
|
|
599
|
+
coalescedMessageGuids: coalescedMessageGuids.length > 0 ? coalescedMessageGuids : void 0,
|
|
600
|
+
coalescedCatchupCursor: Number.isFinite(maxRowid) && Number.isFinite(maxDateMs) ? {
|
|
601
|
+
lastSeenMs: maxDateMs,
|
|
602
|
+
lastSeenRowid: maxRowid
|
|
603
|
+
} : void 0
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region extensions/imessage/src/monitor/conversation-repair.ts
|
|
608
|
+
const DEFAULT_CHATS_LIMIT = 20;
|
|
609
|
+
const DEFAULT_PER_CHAT_HISTORY_LIMIT = 50;
|
|
610
|
+
const DEFAULT_RPC_TIMEOUT_MS = 5e3;
|
|
611
|
+
function hasPositiveChatId(value) {
|
|
612
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
613
|
+
}
|
|
614
|
+
function isExplicitEmptyString(value) {
|
|
615
|
+
return typeof value === "string" && value.trim() === "";
|
|
616
|
+
}
|
|
617
|
+
function hasUsableConversationAnchor(projection) {
|
|
618
|
+
return hasPositiveChatId(projection.chat_id) || hasNonEmptyString(projection.chat_guid) || hasNonEmptyString(projection.chat_identifier);
|
|
619
|
+
}
|
|
620
|
+
function isIMessageAnchorless(message) {
|
|
621
|
+
if (hasPositiveChatId(message.chat_id) || hasNonEmptyString(message.chat_guid) || hasNonEmptyString(message.chat_identifier)) return false;
|
|
622
|
+
return message.chat_id === null || typeof message.chat_id === "number" && (!Number.isFinite(message.chat_id) || message.chat_id <= 0) || isExplicitEmptyString(message.chat_guid) || isExplicitEmptyString(message.chat_identifier);
|
|
623
|
+
}
|
|
624
|
+
function extractAuthoritativeRecoveryProjection(entry) {
|
|
625
|
+
if (typeof entry.is_group !== "boolean" || typeof entry.is_from_me !== "boolean") return null;
|
|
626
|
+
if (!hasNonEmptyString(entry.sender)) return null;
|
|
627
|
+
const projection = {
|
|
628
|
+
sender: entry.sender.trim(),
|
|
629
|
+
is_from_me: entry.is_from_me,
|
|
630
|
+
is_group: entry.is_group
|
|
631
|
+
};
|
|
632
|
+
if (hasNonEmptyString(entry.destination_caller_id)) projection.destination_caller_id = entry.destination_caller_id.trim();
|
|
633
|
+
if (hasPositiveChatId(entry.chat_id)) projection.chat_id = entry.chat_id;
|
|
634
|
+
if (hasNonEmptyString(entry.chat_guid)) projection.chat_guid = entry.chat_guid;
|
|
635
|
+
if (hasNonEmptyString(entry.chat_identifier)) projection.chat_identifier = entry.chat_identifier;
|
|
636
|
+
if (typeof entry.chat_name === "string") projection.chat_name = entry.chat_name;
|
|
637
|
+
if (Array.isArray(entry.participants) && entry.participants.every((participant) => typeof participant === "string")) projection.participants = entry.participants;
|
|
638
|
+
return hasUsableConversationAnchor(projection) ? projection : null;
|
|
639
|
+
}
|
|
640
|
+
function projectionConflictKey(projection) {
|
|
641
|
+
return JSON.stringify({
|
|
642
|
+
chat_id: projection.chat_id ?? null,
|
|
643
|
+
chat_guid: projection.chat_guid ?? null,
|
|
644
|
+
chat_identifier: projection.chat_identifier ?? null,
|
|
645
|
+
is_group: projection.is_group,
|
|
646
|
+
sender: projection.sender,
|
|
647
|
+
destination_caller_id: projection.destination_caller_id ?? null,
|
|
648
|
+
is_from_me: projection.is_from_me
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
function applyAuthoritativeRecoveryProjection(message, projection) {
|
|
652
|
+
return {
|
|
653
|
+
...message,
|
|
654
|
+
...projection.chat_id !== void 0 ? { chat_id: projection.chat_id } : {},
|
|
655
|
+
...projection.chat_guid !== void 0 ? { chat_guid: projection.chat_guid } : {},
|
|
656
|
+
...projection.chat_identifier !== void 0 ? { chat_identifier: projection.chat_identifier } : {},
|
|
657
|
+
...projection.chat_name !== void 0 ? { chat_name: projection.chat_name } : {},
|
|
658
|
+
...projection.participants !== void 0 ? { participants: projection.participants } : {},
|
|
659
|
+
is_group: projection.is_group,
|
|
660
|
+
sender: projection.sender,
|
|
661
|
+
destination_caller_id: projection.destination_caller_id ?? null,
|
|
662
|
+
is_from_me: projection.is_from_me
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
async function repairIMessageConversationAnchor(params) {
|
|
666
|
+
const { client, message, runtime } = params;
|
|
667
|
+
if (!isIMessageAnchorless(message)) return message;
|
|
668
|
+
const guid = message.guid?.trim();
|
|
669
|
+
if (!guid) {
|
|
670
|
+
runtime?.error?.("imessage: dropping anchorless message without GUID");
|
|
671
|
+
return null;
|
|
672
|
+
}
|
|
673
|
+
let chatsResult;
|
|
674
|
+
try {
|
|
675
|
+
chatsResult = await client.request("chats.list", { limit: params.chatsLimit ?? DEFAULT_CHATS_LIMIT }, { timeoutMs: params.rpcTimeoutMs ?? DEFAULT_RPC_TIMEOUT_MS });
|
|
676
|
+
} catch (err) {
|
|
677
|
+
runtime?.error?.(`imessage: anchorless message recovery failed listing chats: ${String(err)}`);
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
const matchedProjections = [];
|
|
681
|
+
const chats = chatsResult?.chats ?? [];
|
|
682
|
+
for (const chat of chats) {
|
|
683
|
+
const chatId = hasPositiveChatId(chat.id) ? chat.id : null;
|
|
684
|
+
if (chatId === null) continue;
|
|
685
|
+
let historyResult;
|
|
686
|
+
try {
|
|
687
|
+
historyResult = await client.request("messages.history", {
|
|
688
|
+
attachments: false,
|
|
689
|
+
chat_id: chatId,
|
|
690
|
+
limit: params.perChatHistoryLimit ?? DEFAULT_PER_CHAT_HISTORY_LIMIT
|
|
691
|
+
}, { timeoutMs: params.rpcTimeoutMs ?? DEFAULT_RPC_TIMEOUT_MS });
|
|
692
|
+
} catch {
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
const messages = Array.isArray(historyResult?.messages) ? historyResult.messages : [];
|
|
696
|
+
for (const raw of messages) {
|
|
697
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) continue;
|
|
698
|
+
const entry = raw;
|
|
699
|
+
if (entry.guid !== guid) continue;
|
|
700
|
+
const projection = extractAuthoritativeRecoveryProjection(entry);
|
|
701
|
+
if (!projection) {
|
|
702
|
+
runtime?.error?.(`imessage: dropping anchorless message GUID=${guid}; exact-GUID history row is incomplete`);
|
|
703
|
+
return null;
|
|
704
|
+
}
|
|
705
|
+
matchedProjections.push(projection);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
const [projection] = matchedProjections;
|
|
709
|
+
if (!projection) {
|
|
710
|
+
runtime?.error?.(`imessage: dropping anchorless message GUID=${guid}; no recent chat matched`);
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
if (new Set(matchedProjections.map(projectionConflictKey)).size > 1) {
|
|
714
|
+
runtime?.error?.(`imessage: dropping anchorless message GUID=${guid}; conflicting exact-GUID history projections`);
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
717
|
+
if (projection.is_from_me) {
|
|
718
|
+
runtime?.error?.(`imessage: dropping anchorless message GUID=${guid}; recovered authoritative row is from-me`);
|
|
719
|
+
return null;
|
|
720
|
+
}
|
|
721
|
+
const repaired = applyAuthoritativeRecoveryProjection(message, projection);
|
|
722
|
+
if (isIMessageAnchorless(repaired)) {
|
|
723
|
+
runtime?.error?.(`imessage: dropping anchorless message GUID=${guid} after recovery found no usable conversation anchor`);
|
|
724
|
+
return null;
|
|
725
|
+
}
|
|
726
|
+
runtime?.log?.(`imessage: recovered anchorless message GUID=${guid} chat_id=${repaired.chat_id ?? "unknown"} is_group=${repaired.is_group === true}`);
|
|
727
|
+
return repaired;
|
|
728
|
+
}
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region extensions/imessage/src/monitor/deliver.ts
|
|
731
|
+
async function deliverIMessageReply(params) {
|
|
732
|
+
const { payload, target, runtime, maxBytes, textLimit, accountId, sentMessageCache } = params;
|
|
733
|
+
const scope = `${accountId ?? ""}:${target}`;
|
|
734
|
+
const { cfg } = params;
|
|
735
|
+
const tableMode = resolveMarkdownTableMode$1({
|
|
736
|
+
cfg,
|
|
737
|
+
channel: "imessage",
|
|
738
|
+
accountId
|
|
739
|
+
});
|
|
740
|
+
const chunkMode = resolveChunkMode(cfg, "imessage", accountId);
|
|
741
|
+
const reply = resolveSendableOutboundReplyParts(payload, { text: convertMarkdownTables$1(sanitizeOutboundText(payload.text ?? ""), tableMode) });
|
|
742
|
+
const accepted = [];
|
|
743
|
+
const sendAccepted = async (text, mediaUrl) => {
|
|
744
|
+
const sent = await sendMessageIMessage(target, text, {
|
|
745
|
+
config: cfg,
|
|
746
|
+
...mediaUrl ? {
|
|
747
|
+
mediaUrl,
|
|
748
|
+
...payload.audioAsVoice ? { audioAsVoice: true } : {}
|
|
749
|
+
} : {},
|
|
750
|
+
maxBytes,
|
|
751
|
+
accountId,
|
|
752
|
+
replyToId: payload.replyToId
|
|
753
|
+
});
|
|
754
|
+
accepted.push(sent);
|
|
755
|
+
const echoText = sent.echoText ?? (sent.sentText || void 0);
|
|
756
|
+
sentMessageCache?.remember(scope, {
|
|
757
|
+
...echoText ? { text: echoText } : {},
|
|
758
|
+
...sent.echoMedia ? { media: sent.echoMedia } : {},
|
|
759
|
+
messageId: sent.messageId
|
|
760
|
+
});
|
|
761
|
+
};
|
|
762
|
+
let delivered;
|
|
763
|
+
try {
|
|
764
|
+
delivered = await deliverTextOrMediaReply({
|
|
765
|
+
payload,
|
|
766
|
+
text: reply.text,
|
|
767
|
+
chunkText: (value) => chunkTextWithMode(value, textLimit, chunkMode),
|
|
768
|
+
sendText: sendAccepted,
|
|
769
|
+
sendMedia: ({ mediaUrl, caption }) => sendAccepted(caption ?? "", mediaUrl)
|
|
770
|
+
});
|
|
771
|
+
} catch (error) {
|
|
772
|
+
const partial = isChannelPartialDeliveryError(error) ? error.deliveryResult : void 0;
|
|
773
|
+
if (accepted.length === 0 && partial?.visibleReplySent !== true) throw error;
|
|
774
|
+
const receipt = createMessageReceiptFromOutboundResults({
|
|
775
|
+
results: [...accepted.map((result) => ({ receipt: result.receipt })), ...partial?.receipt ? [{ receipt: partial.receipt }] : (partial?.messageIds ?? []).map((messageId) => ({ messageId }))],
|
|
776
|
+
kind: reply.mediaUrls.length > 0 ? "media" : "text"
|
|
777
|
+
});
|
|
778
|
+
throw createChannelPartialDeliveryError(error, {
|
|
779
|
+
messageIds: listMessageReceiptPlatformIds(receipt),
|
|
780
|
+
receipt,
|
|
781
|
+
visibleReplySent: true,
|
|
782
|
+
content: [...accepted.map((result) => result.sentText), partial?.content].filter(Boolean).join("\n")
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
if (delivered === "empty") return {
|
|
786
|
+
visibleReplySent: false,
|
|
787
|
+
suppression: { reason: "no_visible_result" }
|
|
788
|
+
};
|
|
789
|
+
const receipt = createMessageReceiptFromOutboundResults({
|
|
790
|
+
results: accepted.map((result) => ({ receipt: result.receipt })),
|
|
791
|
+
kind: delivered
|
|
792
|
+
});
|
|
793
|
+
runtime.log?.(`imessage: delivered reply to ${target}`);
|
|
794
|
+
return {
|
|
795
|
+
messageIds: listMessageReceiptPlatformIds(receipt),
|
|
796
|
+
receipt,
|
|
797
|
+
visibleReplySent: true,
|
|
798
|
+
content: accepted.map((result) => result.sentText).filter(Boolean).join("\n")
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function createIMessageEchoCachingSend(params) {
|
|
802
|
+
return async (target, text, opts) => {
|
|
803
|
+
const sent = await sendMessageIMessage(target, sanitizeOutboundText(text), opts);
|
|
804
|
+
const scope = `${params.accountId ?? opts.accountId ?? ""}:${target}`;
|
|
805
|
+
const echoText = sent.echoText ?? (sent.sentText || void 0);
|
|
806
|
+
params.sentMessageCache?.remember(scope, {
|
|
807
|
+
...echoText ? { text: echoText } : {},
|
|
808
|
+
...sent.echoMedia ? { media: sent.echoMedia } : {},
|
|
809
|
+
messageId: sent.messageId
|
|
810
|
+
});
|
|
811
|
+
return sent;
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
//#endregion
|
|
815
|
+
//#region extensions/imessage/src/monitor/dm-history.ts
|
|
816
|
+
const DM_HISTORY_RPC_TIMEOUT_MS = 1e4;
|
|
817
|
+
function resolveIMessageDmHistoryLimit(params) {
|
|
818
|
+
const senderCandidates = [
|
|
819
|
+
normalizeOptionalString(params.senderNormalized),
|
|
820
|
+
normalizeOptionalString(params.sender),
|
|
821
|
+
params.sender ? normalizeIMessageHandle(params.sender) : void 0
|
|
822
|
+
].filter((candidate) => Boolean(candidate));
|
|
823
|
+
for (const candidate of senderCandidates) {
|
|
824
|
+
const override = params.config.dms?.[candidate]?.historyLimit;
|
|
825
|
+
if (override !== void 0) return Math.max(0, override);
|
|
826
|
+
}
|
|
827
|
+
return Math.max(0, params.config.dmHistoryLimit ?? 0);
|
|
828
|
+
}
|
|
829
|
+
function historyRowSortValue(message) {
|
|
830
|
+
if (typeof message.id === "number" && Number.isFinite(message.id)) return message.id;
|
|
831
|
+
const createdAtMs = typeof message.created_at === "string" ? Date.parse(message.created_at) : NaN;
|
|
832
|
+
return Number.isFinite(createdAtMs) ? createdAtMs : 0;
|
|
833
|
+
}
|
|
834
|
+
function isBeforeCurrentMessage(params) {
|
|
835
|
+
const { message, currentMessage } = params;
|
|
836
|
+
if (typeof message.id === "number" && typeof currentMessage.id === "number" && Number.isFinite(message.id) && Number.isFinite(currentMessage.id)) return message.id < currentMessage.id;
|
|
837
|
+
const guid = normalizeOptionalString(message.guid);
|
|
838
|
+
const currentGuid = normalizeOptionalString(currentMessage.guid);
|
|
839
|
+
if (guid && currentGuid) return guid !== currentGuid;
|
|
840
|
+
return true;
|
|
841
|
+
}
|
|
842
|
+
function historyEntryFromMessage(message, fallbackSender) {
|
|
843
|
+
const body = normalizeOptionalString(message.text);
|
|
844
|
+
if (!body) return null;
|
|
845
|
+
const timestamp = parseDateStringTimestampMs(message.created_at);
|
|
846
|
+
return {
|
|
847
|
+
sender: message.is_from_me === true ? "Me" : normalizeIMessageHandle(normalizeOptionalString(message.sender) ?? fallbackSender) || fallbackSender,
|
|
848
|
+
body,
|
|
849
|
+
...timestamp !== void 0 ? { timestamp } : {}
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
async function resolveIMessageDmHistoryContext(params) {
|
|
853
|
+
const maxMessages = Math.max(0, Math.floor(params.limit));
|
|
854
|
+
const chatId = typeof params.message.chat_id === "number" && Number.isFinite(params.message.chat_id) ? params.message.chat_id : void 0;
|
|
855
|
+
if (maxMessages <= 0 || chatId === void 0) return {};
|
|
856
|
+
let result;
|
|
857
|
+
try {
|
|
858
|
+
result = await params.client.request("messages.history", {
|
|
859
|
+
chat_id: chatId,
|
|
860
|
+
limit: maxMessages + 1,
|
|
861
|
+
attachments: false
|
|
862
|
+
}, { timeoutMs: DM_HISTORY_RPC_TIMEOUT_MS });
|
|
863
|
+
} catch (err) {
|
|
864
|
+
params.logVerbose?.(`imessage: DM history fetch failed for chat_id=${chatId}: ${String(err)}`);
|
|
865
|
+
return {};
|
|
866
|
+
}
|
|
867
|
+
const history = (Array.isArray(result?.messages) ? result.messages : []).map((row) => parseIMessageNotification({ message: row })).filter((message) => Boolean(message)).filter((message) => message.is_group !== true).filter((message) => isBeforeCurrentMessage({
|
|
868
|
+
message,
|
|
869
|
+
currentMessage: params.message
|
|
870
|
+
})).toSorted((a, b) => historyRowSortValue(a) - historyRowSortValue(b)).map((message) => historyEntryFromMessage(message, params.senderNormalized)).filter((entry) => Boolean(entry)).slice(-maxMessages);
|
|
871
|
+
if (history.length === 0) return {};
|
|
872
|
+
return {
|
|
873
|
+
inboundHistory: history,
|
|
874
|
+
body: history.map((entry) => formatInboundEnvelope({
|
|
875
|
+
channel: "iMessage",
|
|
876
|
+
from: entry.sender,
|
|
877
|
+
timestamp: entry.timestamp,
|
|
878
|
+
body: entry.body,
|
|
879
|
+
chatType: "direct",
|
|
880
|
+
senderLabel: entry.sender,
|
|
881
|
+
envelope: params.envelopeOptions
|
|
882
|
+
})).join("\n\n")
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region extensions/imessage/src/monitor/drop-diagnostic-cache.ts
|
|
887
|
+
const THROTTLED_DROP_DIAGNOSTIC_CACHE_MAX_SIZE = 512;
|
|
888
|
+
function createIMessageThrottledDropDiagnosticCache() {
|
|
889
|
+
return createDedupeCache({
|
|
890
|
+
maxSize: THROTTLED_DROP_DIAGNOSTIC_CACHE_MAX_SIZE,
|
|
891
|
+
ttlMs: 0
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
//#endregion
|
|
895
|
+
//#region extensions/imessage/src/monitor/echo-cache.ts
|
|
896
|
+
const SENT_MESSAGE_TEXT_TTL_MS = 4e3;
|
|
897
|
+
const SENT_MESSAGE_ID_TTL_MS = 6e4;
|
|
898
|
+
function normalizeEchoTextKey(text) {
|
|
899
|
+
if (!text) return null;
|
|
900
|
+
const normalized = stripLeadingEchoTextCorruptionMarkers(text.replace(/\r\n?/g, "\n").trim()).trim();
|
|
901
|
+
return normalized ? normalized : null;
|
|
902
|
+
}
|
|
903
|
+
function normalizeEchoMessageIdKey(messageId) {
|
|
904
|
+
if (!messageId) return null;
|
|
905
|
+
const normalized = messageId.trim();
|
|
906
|
+
if (!normalized || normalized === "ok" || normalized === "unknown") return null;
|
|
907
|
+
return normalized;
|
|
908
|
+
}
|
|
909
|
+
var DefaultSentMessageCache = class {
|
|
910
|
+
constructor() {
|
|
911
|
+
this.textCache = /* @__PURE__ */ new Map();
|
|
912
|
+
this.textBackedByIdCache = /* @__PURE__ */ new Map();
|
|
913
|
+
this.mediaCache = /* @__PURE__ */ new Map();
|
|
914
|
+
this.mediaBackedByIdCache = /* @__PURE__ */ new Map();
|
|
915
|
+
this.messageIdCache = /* @__PURE__ */ new Map();
|
|
916
|
+
}
|
|
917
|
+
remember(scope, lookup) {
|
|
918
|
+
const textKey = normalizeEchoTextKey(lookup.text);
|
|
919
|
+
if (textKey) this.textCache.set(`${scope}:${textKey}`, Date.now());
|
|
920
|
+
const mediaKey = resolveIMessageEchoMediaKey(lookup.media);
|
|
921
|
+
if (mediaKey) this.mediaCache.set(`${scope}:${mediaKey}`, Date.now());
|
|
922
|
+
const messageIdKey = normalizeEchoMessageIdKey(lookup.messageId);
|
|
923
|
+
if (messageIdKey) {
|
|
924
|
+
this.messageIdCache.set(`${scope}:${messageIdKey}`, Date.now());
|
|
925
|
+
if (textKey) this.textBackedByIdCache.set(`${scope}:${textKey}`, Date.now());
|
|
926
|
+
if (mediaKey) this.mediaBackedByIdCache.set(`${scope}:${mediaKey}`, Date.now());
|
|
927
|
+
}
|
|
928
|
+
this.cleanup();
|
|
929
|
+
}
|
|
930
|
+
has(scope, lookup, options = false) {
|
|
931
|
+
this.cleanup();
|
|
932
|
+
const resolvedOptions = typeof options === "boolean" ? { skipIdShortCircuit: options } : options;
|
|
933
|
+
if (hasPersistedIMessageEcho({
|
|
934
|
+
scope,
|
|
935
|
+
text: lookup.text,
|
|
936
|
+
media: lookup.media,
|
|
937
|
+
messageId: lookup.messageId,
|
|
938
|
+
skipIdShortCircuit: resolvedOptions.skipIdShortCircuit,
|
|
939
|
+
includePendingText: resolvedOptions.includePendingText
|
|
940
|
+
})) return true;
|
|
941
|
+
const textKey = normalizeEchoTextKey(lookup.text);
|
|
942
|
+
const mediaKey = resolveIMessageEchoMediaKey(lookup.media);
|
|
943
|
+
const messageIdKey = normalizeEchoMessageIdKey(lookup.messageId);
|
|
944
|
+
let canUseMediaFallback = !messageIdKey;
|
|
945
|
+
if (messageIdKey) {
|
|
946
|
+
const idTimestamp = this.messageIdCache.get(`${scope}:${messageIdKey}`);
|
|
947
|
+
if (idTimestamp && Date.now() - idTimestamp <= SENT_MESSAGE_ID_TTL_MS) return true;
|
|
948
|
+
const textTimestamp = textKey ? this.textCache.get(`${scope}:${textKey}`) : void 0;
|
|
949
|
+
const textBackedByIdTimestamp = textKey ? this.textBackedByIdCache.get(`${scope}:${textKey}`) : void 0;
|
|
950
|
+
const hasTextOnlyMatch = typeof textTimestamp === "number" && (!textBackedByIdTimestamp || textTimestamp > textBackedByIdTimestamp);
|
|
951
|
+
const mediaTimestamp = mediaKey ? this.mediaCache.get(`${scope}:${mediaKey}`) : void 0;
|
|
952
|
+
const mediaBackedByIdTimestamp = mediaKey ? this.mediaBackedByIdCache.get(`${scope}:${mediaKey}`) : void 0;
|
|
953
|
+
const hasMediaOnlyMatch = typeof mediaTimestamp === "number" && (!mediaBackedByIdTimestamp || mediaTimestamp > mediaBackedByIdTimestamp);
|
|
954
|
+
canUseMediaFallback = hasMediaOnlyMatch;
|
|
955
|
+
if (!resolvedOptions.skipIdShortCircuit && !hasTextOnlyMatch && !hasMediaOnlyMatch) return false;
|
|
956
|
+
}
|
|
957
|
+
if (textKey) {
|
|
958
|
+
const textTimestamp = this.textCache.get(`${scope}:${textKey}`);
|
|
959
|
+
if (textTimestamp && Date.now() - textTimestamp <= SENT_MESSAGE_TEXT_TTL_MS) return true;
|
|
960
|
+
}
|
|
961
|
+
if (mediaKey && canUseMediaFallback) {
|
|
962
|
+
const mediaTimestamp = this.mediaCache.get(`${scope}:${mediaKey}`);
|
|
963
|
+
if (mediaTimestamp && Date.now() - mediaTimestamp <= SENT_MESSAGE_TEXT_TTL_MS) return true;
|
|
964
|
+
}
|
|
965
|
+
return false;
|
|
966
|
+
}
|
|
967
|
+
cleanup() {
|
|
968
|
+
const now = Date.now();
|
|
969
|
+
for (const [key, timestamp] of this.textCache.entries()) if (now - timestamp > SENT_MESSAGE_TEXT_TTL_MS) this.textCache.delete(key);
|
|
970
|
+
for (const [key, timestamp] of this.textBackedByIdCache.entries()) if (now - timestamp > SENT_MESSAGE_TEXT_TTL_MS) this.textBackedByIdCache.delete(key);
|
|
971
|
+
for (const [key, timestamp] of this.mediaCache.entries()) if (now - timestamp > SENT_MESSAGE_TEXT_TTL_MS) this.mediaCache.delete(key);
|
|
972
|
+
for (const [key, timestamp] of this.mediaBackedByIdCache.entries()) if (now - timestamp > SENT_MESSAGE_TEXT_TTL_MS) this.mediaBackedByIdCache.delete(key);
|
|
973
|
+
for (const [key, timestamp] of this.messageIdCache.entries()) if (now - timestamp > SENT_MESSAGE_ID_TTL_MS) this.messageIdCache.delete(key);
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
function createSentMessageCache() {
|
|
977
|
+
return new DefaultSentMessageCache();
|
|
978
|
+
}
|
|
979
|
+
//#endregion
|
|
980
|
+
//#region extensions/imessage/src/monitor/group-allowlist-warnings.ts
|
|
981
|
+
const PER_CHAT_WARNING_CACHE_MAX_SIZE = 512;
|
|
982
|
+
const startupWarned = /* @__PURE__ */ new Set();
|
|
983
|
+
const perChatWarned = createDedupeCache({
|
|
984
|
+
maxSize: PER_CHAT_WARNING_CACHE_MAX_SIZE,
|
|
985
|
+
ttlMs: 0
|
|
986
|
+
});
|
|
987
|
+
/**
|
|
988
|
+
* Fires once per `accountId` at monitor startup when `groupPolicy === "allowlist"`
|
|
989
|
+
* and the effective group sender allowlist is empty. The sender gate runs
|
|
990
|
+
* before the group registry, so `channels.imessage.groups` entries cannot admit
|
|
991
|
+
* traffic without a sender allowlist. A non-empty `groupAllowFrom` makes the
|
|
992
|
+
* configuration potentially valid and suppresses this drop-all warning.
|
|
993
|
+
*/
|
|
994
|
+
function warnGroupAllowlistMisconfigOnce(params) {
|
|
995
|
+
if (params.groupPolicy !== "allowlist") return false;
|
|
996
|
+
if (params.hasGroupAllowFrom) return false;
|
|
997
|
+
const key = `imessage:${params.accountId}`;
|
|
998
|
+
if (startupWarned.has(key)) return false;
|
|
999
|
+
startupWarned.add(key);
|
|
1000
|
+
params.log(`imessage: groupPolicy="allowlist" for account "${params.accountId}" but no group sender allowlist is configured (channels.imessage.groupAllowFrom, or its allowFrom fallback). Every inbound group message will be dropped. Set channels.imessage.groupAllowFrom (sender handles, chat targets like chat_id:<id>, or "*") to admit group senders, and optionally add channels.imessage.groups entries to scope which chats are allowed.`);
|
|
1001
|
+
return true;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Fires once per `accountId:chat_id` when the runtime allowlist gate drops a
|
|
1005
|
+
* group message because that chat_id is not in `channels.imessage.groups`.
|
|
1006
|
+
* Retains up to 512 recently active account/chat pairs; evicted chats may warn again.
|
|
1007
|
+
*/
|
|
1008
|
+
function warnGroupAllowlistDropPerChatOnce(params) {
|
|
1009
|
+
const chat = params.chatId == null ? "" : String(params.chatId).trim();
|
|
1010
|
+
if (!chat) return false;
|
|
1011
|
+
const key = `imessage:${params.accountId}:${chat}`;
|
|
1012
|
+
if (perChatWarned.check(key)) return false;
|
|
1013
|
+
params.log(`imessage: dropping group message from chat_id=${chat} (account "${params.accountId}") — not in channels.imessage.groups allowlist. Add channels.imessage.groups["${chat}"] or channels.imessage.groups["*"] to allow it.`);
|
|
1014
|
+
return true;
|
|
1015
|
+
}
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region extensions/imessage/src/monitor/inbound-dedupe.ts
|
|
1018
|
+
const IMESSAGE_STALE_INBOUND_THRESHOLD_MS = 900 * 1e3;
|
|
1019
|
+
const IMESSAGE_RECOVERY_MAX_AGE_MS = 7200 * 1e3;
|
|
1020
|
+
/**
|
|
1021
|
+
* Age fence: true when the message's own send date is materially older than
|
|
1022
|
+
* now, i.e. stale backlog rather than a live message. Fails open (returns
|
|
1023
|
+
* false) when the send date is missing or unparseable so an undateable message
|
|
1024
|
+
* is never suppressed on a timestamp we cannot read.
|
|
1025
|
+
*/
|
|
1026
|
+
function isStaleIMessageBacklog(message, nowMs, thresholdMs = IMESSAGE_STALE_INBOUND_THRESHOLD_MS) {
|
|
1027
|
+
const createdAt = message.created_at?.trim();
|
|
1028
|
+
if (!createdAt) return false;
|
|
1029
|
+
const sentMs = Date.parse(createdAt);
|
|
1030
|
+
if (!Number.isFinite(sentMs)) return false;
|
|
1031
|
+
return nowMs - sentMs > thresholdMs;
|
|
1032
|
+
}
|
|
1033
|
+
//#endregion
|
|
1034
|
+
//#region extensions/imessage/src/conversation-route.ts
|
|
1035
|
+
function resolveIMessageConversationRoute(params) {
|
|
1036
|
+
let route = resolveAgentRoute({
|
|
1037
|
+
cfg: params.cfg,
|
|
1038
|
+
channel: "imessage",
|
|
1039
|
+
accountId: params.accountId,
|
|
1040
|
+
peer: {
|
|
1041
|
+
kind: params.isGroup ? "group" : "direct",
|
|
1042
|
+
id: params.peerId
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
const conversationId = resolveIMessageInboundConversationId({
|
|
1046
|
+
isGroup: params.isGroup,
|
|
1047
|
+
sender: params.sender,
|
|
1048
|
+
chatId: params.chatId
|
|
1049
|
+
});
|
|
1050
|
+
if (!conversationId) return route;
|
|
1051
|
+
route = resolveConfiguredBindingRoute({
|
|
1052
|
+
cfg: params.cfg,
|
|
1053
|
+
route,
|
|
1054
|
+
conversation: {
|
|
1055
|
+
channel: "imessage",
|
|
1056
|
+
accountId: params.accountId,
|
|
1057
|
+
conversationId
|
|
1058
|
+
}
|
|
1059
|
+
}).route;
|
|
1060
|
+
const runtimeRoute = resolveRuntimeConversationBindingRoute({
|
|
1061
|
+
route,
|
|
1062
|
+
conversation: {
|
|
1063
|
+
channel: "imessage",
|
|
1064
|
+
accountId: params.accountId,
|
|
1065
|
+
conversationId
|
|
1066
|
+
}
|
|
1067
|
+
});
|
|
1068
|
+
route = runtimeRoute.route;
|
|
1069
|
+
if (runtimeRoute.bindingRecord && !runtimeRoute.boundSessionKey) logVerbose(`imessage: plugin-bound conversation ${conversationId}`);
|
|
1070
|
+
else if (runtimeRoute.boundSessionKey) logVerbose(`imessage: routed via bound conversation ${conversationId} -> ${runtimeRoute.boundSessionKey}`);
|
|
1071
|
+
return route;
|
|
1072
|
+
}
|
|
1073
|
+
//#endregion
|
|
1074
|
+
//#region extensions/imessage/src/monitor/reflection-guard.ts
|
|
1075
|
+
const REFLECTION_PATTERNS = [
|
|
1076
|
+
{
|
|
1077
|
+
re: /(?:#\+){2,}#?/,
|
|
1078
|
+
label: "internal-separator"
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
re: /\bassistant\s+to\s*=\s*\w+/i,
|
|
1082
|
+
label: "assistant-role-marker"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
re: /<\s*\/?\s*(?:(?:antml:|mm:)?(?:think(?:ing)?|thought)|antthinking)\b[^<>]*>/i,
|
|
1086
|
+
label: "thinking-tag"
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
re: /<\s*\/?\s*relevant[-_]memories\b[^<>]*>/i,
|
|
1090
|
+
label: "relevant-memories-tag"
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
re: /<\s*\/?\s*final\b[^<>]*>/i,
|
|
1094
|
+
label: "final-tag"
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
re: /\bACP error\s*\(\s*ACP_[A-Z0-9_]+\s*\):/i,
|
|
1098
|
+
label: "acp-error"
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
re: /\bMissing API key for\b.+\bon the gateway\b/i,
|
|
1102
|
+
label: "gateway-missing-api-key"
|
|
1103
|
+
}
|
|
1104
|
+
];
|
|
1105
|
+
function hasMatchOutsideCode(text, re) {
|
|
1106
|
+
const codeRegions = findCodeRegions(text);
|
|
1107
|
+
const globalRe = new RegExp(re.source, re.flags.includes("g") ? re.flags : `${re.flags}g`);
|
|
1108
|
+
for (const match of text.matchAll(globalRe)) {
|
|
1109
|
+
const start = match.index ?? -1;
|
|
1110
|
+
if (start >= 0 && !isInsideCode(start, codeRegions)) return true;
|
|
1111
|
+
}
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Check whether an inbound message appears to be a reflection of
|
|
1116
|
+
* assistant-originated content. Returns matched pattern labels for telemetry.
|
|
1117
|
+
*/
|
|
1118
|
+
function detectReflectedContent(text) {
|
|
1119
|
+
if (!text) return {
|
|
1120
|
+
isReflection: false,
|
|
1121
|
+
matchedLabels: []
|
|
1122
|
+
};
|
|
1123
|
+
const matchedLabels = [];
|
|
1124
|
+
for (const { re, label } of REFLECTION_PATTERNS) if (hasMatchOutsideCode(text, re)) matchedLabels.push(label);
|
|
1125
|
+
return {
|
|
1126
|
+
isReflection: matchedLabels.length > 0,
|
|
1127
|
+
matchedLabels
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
//#endregion
|
|
1131
|
+
//#region extensions/imessage/src/monitor/inbound-processing.ts
|
|
1132
|
+
const normalizeNonEmpty = (value) => value.trim() || null;
|
|
1133
|
+
const imessageConversationIdentityKinds = /* @__PURE__ */ new Set([
|
|
1134
|
+
"plugin:imessage-chat-id",
|
|
1135
|
+
"plugin:imessage-chat-guid",
|
|
1136
|
+
"plugin:imessage-chat-identifier"
|
|
1137
|
+
]);
|
|
1138
|
+
const matchIMessageIngressEntry = ({ entry, context }) => {
|
|
1139
|
+
if (imessageConversationIdentityKinds.has(entry.kind) && context !== "group") return false;
|
|
1140
|
+
};
|
|
1141
|
+
function isIMessageConversationAllowTarget(entry) {
|
|
1142
|
+
const parsed = parseIMessageAllowTarget(entry);
|
|
1143
|
+
return parsed.kind === "chat_id" || parsed.kind === "chat_guid" || parsed.kind === "chat_identifier";
|
|
1144
|
+
}
|
|
1145
|
+
function mergeIMessageGroupAllowFromWithLegacyChatTargets(params) {
|
|
1146
|
+
if (params.groupAllowFrom.length > 0 || !params.allowLegacyConversationTargets) return params.groupAllowFrom;
|
|
1147
|
+
const legacyChatTargets = params.allowFrom.filter((entry) => isIMessageConversationAllowTarget(entry));
|
|
1148
|
+
if (legacyChatTargets.length === 0) return params.groupAllowFrom;
|
|
1149
|
+
return uniqueStrings([...params.groupAllowFrom, ...legacyChatTargets]);
|
|
1150
|
+
}
|
|
1151
|
+
const imessageIngressIdentity = defineStableChannelIngressIdentity({
|
|
1152
|
+
key: "imessage-sender",
|
|
1153
|
+
normalizeEntry: normalizeIMessageHandleEntry,
|
|
1154
|
+
normalizeSubject: normalizeIMessageHandle,
|
|
1155
|
+
sensitivity: "pii",
|
|
1156
|
+
matchEntry: matchIMessageIngressEntry,
|
|
1157
|
+
aliases: [
|
|
1158
|
+
[
|
|
1159
|
+
"imessage-chat-id",
|
|
1160
|
+
"plugin:imessage-chat-id",
|
|
1161
|
+
normalizeIMessageChatIdEntry
|
|
1162
|
+
],
|
|
1163
|
+
[
|
|
1164
|
+
"imessage-chat-guid",
|
|
1165
|
+
"plugin:imessage-chat-guid",
|
|
1166
|
+
normalizeIMessageChatGuidEntry
|
|
1167
|
+
],
|
|
1168
|
+
[
|
|
1169
|
+
"imessage-chat-identifier",
|
|
1170
|
+
"plugin:imessage-chat-identifier",
|
|
1171
|
+
normalizeIMessageChatIdentifierEntry
|
|
1172
|
+
]
|
|
1173
|
+
].map(([key, kind, normalizeEntry]) => ({
|
|
1174
|
+
key,
|
|
1175
|
+
kind,
|
|
1176
|
+
normalizeEntry,
|
|
1177
|
+
normalizeSubject: normalizeNonEmpty,
|
|
1178
|
+
sensitivity: "pii"
|
|
1179
|
+
})),
|
|
1180
|
+
resolveEntryId: ({ entryIndex }) => `imessage-entry-${entryIndex + 1}`
|
|
1181
|
+
});
|
|
1182
|
+
function normalizeIMessageHandleEntry(entry) {
|
|
1183
|
+
const parsed = parseIMessageAllowTarget(entry.trim());
|
|
1184
|
+
return parsed.kind === "handle" ? normalizeIMessageHandle(parsed.handle) : null;
|
|
1185
|
+
}
|
|
1186
|
+
function normalizeIMessageChatIdEntry(entry) {
|
|
1187
|
+
const parsed = parseIMessageAllowTarget(entry.trim());
|
|
1188
|
+
return parsed.kind === "chat_id" ? String(parsed.chatId) : null;
|
|
1189
|
+
}
|
|
1190
|
+
function normalizeIMessageChatGuidEntry(entry) {
|
|
1191
|
+
const parsed = parseIMessageAllowTarget(entry.trim());
|
|
1192
|
+
return parsed.kind === "chat_guid" ? parsed.chatGuid.trim() || null : null;
|
|
1193
|
+
}
|
|
1194
|
+
function normalizeIMessageChatIdentifierEntry(entry) {
|
|
1195
|
+
const parsed = parseIMessageAllowTarget(entry.trim());
|
|
1196
|
+
return parsed.kind === "chat_identifier" ? parsed.chatIdentifier.trim() || null : null;
|
|
1197
|
+
}
|
|
1198
|
+
function normalizeDmPolicy(policy) {
|
|
1199
|
+
return policy === "open" || policy === "allowlist" || policy === "disabled" ? policy : "pairing";
|
|
1200
|
+
}
|
|
1201
|
+
function normalizeGroupPolicy(policy) {
|
|
1202
|
+
return policy === "open" || policy === "disabled" ? policy : "allowlist";
|
|
1203
|
+
}
|
|
1204
|
+
function normalizeReplyField(value) {
|
|
1205
|
+
if (typeof value === "string") {
|
|
1206
|
+
const trimmed = value.trim();
|
|
1207
|
+
return trimmed ? trimmed : void 0;
|
|
1208
|
+
}
|
|
1209
|
+
if (typeof value === "number") return String(value);
|
|
1210
|
+
}
|
|
1211
|
+
function describeReplyContext(message) {
|
|
1212
|
+
const body = normalizeReplyField(message.reply_to_text);
|
|
1213
|
+
if (!body) return null;
|
|
1214
|
+
return {
|
|
1215
|
+
body,
|
|
1216
|
+
id: normalizeReplyField(message.reply_to_id),
|
|
1217
|
+
sender: normalizeReplyField(message.reply_to_sender)
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
function resolveInboundEchoMessageIds(message) {
|
|
1221
|
+
const values = [message.id != null ? String(message.id) : void 0, normalizeReplyField(message.guid)];
|
|
1222
|
+
const ids = [];
|
|
1223
|
+
for (const value of values) {
|
|
1224
|
+
if (!value || ids.includes(value)) continue;
|
|
1225
|
+
ids.push(value);
|
|
1226
|
+
}
|
|
1227
|
+
return ids;
|
|
1228
|
+
}
|
|
1229
|
+
function rememberIMessageSkippedFromMeForSelfChatDedupe(params) {
|
|
1230
|
+
if (params.message.is_from_me !== true) return;
|
|
1231
|
+
const sender = params.message.sender?.trim();
|
|
1232
|
+
if (!sender) return;
|
|
1233
|
+
const chatId = params.message.chat_id ?? void 0;
|
|
1234
|
+
const isGroup = Boolean(params.message.is_group);
|
|
1235
|
+
const chatIdentifierNormalized = normalizeIMessageHandle(params.message.chat_identifier ?? "") || void 0;
|
|
1236
|
+
const destinationCallerIdNormalized = normalizeIMessageHandle(params.message.destination_caller_id ?? "") || void 0;
|
|
1237
|
+
const senderNormalized = normalizeIMessageHandle(sender);
|
|
1238
|
+
const createdAt = params.message.created_at ? Date.parse(params.message.created_at) : void 0;
|
|
1239
|
+
const lookup = {
|
|
1240
|
+
accountId: params.accountId,
|
|
1241
|
+
isGroup,
|
|
1242
|
+
chatId,
|
|
1243
|
+
sender,
|
|
1244
|
+
text: params.bodyText.trim(),
|
|
1245
|
+
createdAt
|
|
1246
|
+
};
|
|
1247
|
+
const isSelfChat = !isGroup && chatIdentifierNormalized != null && senderNormalized === chatIdentifierNormalized && destinationCallerIdNormalized != null && destinationCallerIdNormalized === senderNormalized;
|
|
1248
|
+
const isAmbiguousSelfThread = !isGroup && chatIdentifierNormalized != null && senderNormalized === chatIdentifierNormalized && destinationCallerIdNormalized == null;
|
|
1249
|
+
if (isSelfChat) params.selfChatCache?.remember({
|
|
1250
|
+
...lookup,
|
|
1251
|
+
allowCreatedAtSkew: true
|
|
1252
|
+
});
|
|
1253
|
+
else if (isAmbiguousSelfThread) params.selfChatCache?.remember(lookup);
|
|
1254
|
+
}
|
|
1255
|
+
function hasIMessageEchoMatch(params) {
|
|
1256
|
+
const scopes = typeof params.scope === "string" ? [params.scope] : params.scope;
|
|
1257
|
+
for (const scope of scopes) {
|
|
1258
|
+
if (!scope) continue;
|
|
1259
|
+
for (const messageId of params.messageIds) if (params.echoCache.has(scope, { messageId })) return true;
|
|
1260
|
+
const fallbackMessageId = params.messageIds[0];
|
|
1261
|
+
if (!params.text && !params.media && !fallbackMessageId) continue;
|
|
1262
|
+
if (params.echoCache.has(scope, {
|
|
1263
|
+
text: params.text,
|
|
1264
|
+
media: params.media,
|
|
1265
|
+
messageId: fallbackMessageId
|
|
1266
|
+
}, {
|
|
1267
|
+
skipIdShortCircuit: params.skipIdShortCircuit,
|
|
1268
|
+
includePendingText: params.includePendingText
|
|
1269
|
+
})) return true;
|
|
1270
|
+
}
|
|
1271
|
+
return false;
|
|
1272
|
+
}
|
|
1273
|
+
function isKnownFromMeIMessageReactionTarget(params) {
|
|
1274
|
+
const { messageId, accountId, chatId, chatGuid, chatIdentifier } = params;
|
|
1275
|
+
const ctx = {
|
|
1276
|
+
accountId,
|
|
1277
|
+
chatId,
|
|
1278
|
+
chatGuid,
|
|
1279
|
+
chatIdentifier
|
|
1280
|
+
};
|
|
1281
|
+
if (params.isKnownFromMeMessageId) return params.isKnownFromMeMessageId(messageId, ctx);
|
|
1282
|
+
return isKnownFromMeIMessageMessageId(messageId, ctx);
|
|
1283
|
+
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Per-group `systemPrompt` resolution. Mirrors `resolveWhatsAppGroupSystemPrompt`
|
|
1286
|
+
* in `extensions/whatsapp/src/system-prompt.ts`:
|
|
1287
|
+
*
|
|
1288
|
+
* 1. If the matched per-`chat_id` entry exists AND defines `systemPrompt` (key
|
|
1289
|
+
* is present, value is non-null), use it. Trim whitespace; if the trim
|
|
1290
|
+
* leaves an empty string, return `undefined` and DO NOT fall through to the
|
|
1291
|
+
* wildcard. This is how operators say "this specific group has no prompt"
|
|
1292
|
+
* without inheriting from `groups["*"]`.
|
|
1293
|
+
* 2. Otherwise, return the wildcard `groups["*"].systemPrompt` (trimmed; empty
|
|
1294
|
+
* after trim → `undefined`).
|
|
1295
|
+
*/
|
|
1296
|
+
function resolveIMessageGroupSystemPrompt(params) {
|
|
1297
|
+
const specific = params.groupConfig;
|
|
1298
|
+
if (specific != null && specific.systemPrompt != null) return specific.systemPrompt.trim() || void 0;
|
|
1299
|
+
const wildcard = params.defaultConfig?.systemPrompt;
|
|
1300
|
+
return wildcard != null ? wildcard.trim() || void 0 : void 0;
|
|
1301
|
+
}
|
|
1302
|
+
async function resolveIMessageInboundDecision(params) {
|
|
1303
|
+
const sender = (params.message.sender ?? "").trim();
|
|
1304
|
+
if (!sender) return {
|
|
1305
|
+
kind: "drop",
|
|
1306
|
+
reason: "missing sender"
|
|
1307
|
+
};
|
|
1308
|
+
const senderNormalized = normalizeIMessageHandle(sender);
|
|
1309
|
+
const chatId = params.message.chat_id ?? void 0;
|
|
1310
|
+
const chatGuid = params.message.chat_guid ?? void 0;
|
|
1311
|
+
const chatIdentifier = params.message.chat_identifier ?? void 0;
|
|
1312
|
+
const destinationCallerId = params.message.destination_caller_id ?? void 0;
|
|
1313
|
+
const createdAt = params.message.created_at ? Date.parse(params.message.created_at) : void 0;
|
|
1314
|
+
const messageText = params.messageText.trim();
|
|
1315
|
+
const bodyText = params.bodyText.trim();
|
|
1316
|
+
const mediaFacts = params.mediaFacts ?? [];
|
|
1317
|
+
const reactionContext = resolveIMessageReactionContext(params.message, bodyText || messageText);
|
|
1318
|
+
const groupIdCandidate = chatId !== void 0 ? String(chatId) : void 0;
|
|
1319
|
+
const groupAllowFromWithLegacyChatTargets = mergeIMessageGroupAllowFromWithLegacyChatTargets({
|
|
1320
|
+
groupAllowFrom: params.groupAllowFrom,
|
|
1321
|
+
allowFrom: params.allowFrom,
|
|
1322
|
+
allowLegacyConversationTargets: params.allowLegacyConversationAllowFromForGroup
|
|
1323
|
+
});
|
|
1324
|
+
const groupListPolicy = groupIdCandidate ? resolveChannelGroupPolicy({
|
|
1325
|
+
cfg: params.cfg,
|
|
1326
|
+
channel: "imessage",
|
|
1327
|
+
accountId: params.accountId,
|
|
1328
|
+
groupId: groupIdCandidate,
|
|
1329
|
+
hasGroupAllowFrom: groupAllowFromWithLegacyChatTargets.length > 0
|
|
1330
|
+
}) : {
|
|
1331
|
+
allowlistEnabled: false,
|
|
1332
|
+
allowed: true,
|
|
1333
|
+
groupConfig: void 0,
|
|
1334
|
+
defaultConfig: void 0
|
|
1335
|
+
};
|
|
1336
|
+
const treatAsGroupByConfig = Boolean(groupIdCandidate && groupListPolicy.allowlistEnabled && groupListPolicy.groupConfig);
|
|
1337
|
+
const isGroup = Boolean(params.message.is_group) || treatAsGroupByConfig;
|
|
1338
|
+
const selfChatLookup = {
|
|
1339
|
+
accountId: params.accountId,
|
|
1340
|
+
isGroup,
|
|
1341
|
+
chatId,
|
|
1342
|
+
sender,
|
|
1343
|
+
text: bodyText,
|
|
1344
|
+
createdAt
|
|
1345
|
+
};
|
|
1346
|
+
const chatIdentifierNormalized = normalizeIMessageHandle(chatIdentifier ?? "") || void 0;
|
|
1347
|
+
const destinationCallerIdNormalized = normalizeIMessageHandle(destinationCallerId ?? "") || void 0;
|
|
1348
|
+
const isSelfChat = !isGroup && chatIdentifierNormalized != null && senderNormalized === chatIdentifierNormalized && destinationCallerIdNormalized != null && destinationCallerIdNormalized === senderNormalized;
|
|
1349
|
+
const isAmbiguousSelfThread = !isGroup && chatIdentifierNormalized != null && senderNormalized === chatIdentifierNormalized && destinationCallerIdNormalized == null;
|
|
1350
|
+
let skipSelfChatHasCheck = false;
|
|
1351
|
+
const inboundMessageIds = resolveInboundEchoMessageIds(params.message);
|
|
1352
|
+
const inboundMessageId = inboundMessageIds[0];
|
|
1353
|
+
const hasInboundGuid = Boolean(normalizeReplyField(params.message.guid));
|
|
1354
|
+
if (params.message.is_from_me) {
|
|
1355
|
+
if (isAmbiguousSelfThread) params.selfChatCache?.remember(selfChatLookup);
|
|
1356
|
+
if (isSelfChat) {
|
|
1357
|
+
params.selfChatCache?.remember({
|
|
1358
|
+
...selfChatLookup,
|
|
1359
|
+
allowCreatedAtSkew: true
|
|
1360
|
+
});
|
|
1361
|
+
const echoScope = buildIMessageEchoScope({
|
|
1362
|
+
accountId: params.accountId,
|
|
1363
|
+
isGroup,
|
|
1364
|
+
chatId,
|
|
1365
|
+
chatGuid,
|
|
1366
|
+
chatIdentifier,
|
|
1367
|
+
sender
|
|
1368
|
+
});
|
|
1369
|
+
if (params.echoCache && (bodyText || inboundMessageId || mediaFacts.length > 0) && hasIMessageEchoMatch({
|
|
1370
|
+
echoCache: params.echoCache,
|
|
1371
|
+
scope: echoScope,
|
|
1372
|
+
text: bodyText || void 0,
|
|
1373
|
+
media: mediaFacts[0],
|
|
1374
|
+
messageIds: inboundMessageIds,
|
|
1375
|
+
skipIdShortCircuit: !hasInboundGuid,
|
|
1376
|
+
includePendingText: true
|
|
1377
|
+
})) return {
|
|
1378
|
+
kind: "drop",
|
|
1379
|
+
reason: "agent echo in self-chat"
|
|
1380
|
+
};
|
|
1381
|
+
skipSelfChatHasCheck = true;
|
|
1382
|
+
} else return {
|
|
1383
|
+
kind: "drop",
|
|
1384
|
+
reason: "from me"
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
if (isGroup && !chatId) return {
|
|
1388
|
+
kind: "drop",
|
|
1389
|
+
reason: "group without chat_id"
|
|
1390
|
+
};
|
|
1391
|
+
const groupId = isGroup ? groupIdCandidate : void 0;
|
|
1392
|
+
const hasControlCommandInMessage = hasControlCommand(messageText, params.cfg);
|
|
1393
|
+
const groupAllowFromForAccess = isGroup ? groupAllowFromWithLegacyChatTargets : params.groupAllowFrom;
|
|
1394
|
+
const route = resolveIMessageConversationRoute({
|
|
1395
|
+
cfg: params.cfg,
|
|
1396
|
+
accountId: params.accountId,
|
|
1397
|
+
isGroup,
|
|
1398
|
+
peerId: isGroup ? String(chatId ?? "unknown") : senderNormalized,
|
|
1399
|
+
sender,
|
|
1400
|
+
chatId
|
|
1401
|
+
});
|
|
1402
|
+
const accessDecision = await createChannelIngressResolver({
|
|
1403
|
+
channelId: "imessage",
|
|
1404
|
+
accountId: params.accountId,
|
|
1405
|
+
identity: imessageIngressIdentity,
|
|
1406
|
+
cfg: params.cfg,
|
|
1407
|
+
readStoreAllowFrom: async () => params.storeAllowFrom
|
|
1408
|
+
}).message({
|
|
1409
|
+
subject: {
|
|
1410
|
+
stableId: sender,
|
|
1411
|
+
aliases: {
|
|
1412
|
+
...chatId != null ? { "imessage-chat-id": String(chatId) } : {},
|
|
1413
|
+
...chatGuid ? { "imessage-chat-guid": chatGuid } : {},
|
|
1414
|
+
...chatIdentifier ? { "imessage-chat-identifier": chatIdentifier } : {}
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
conversation: {
|
|
1418
|
+
kind: isGroup ? "group" : "direct",
|
|
1419
|
+
id: isGroup ? String(chatId ?? chatGuid ?? chatIdentifier ?? "unknown") : normalizeIMessageHandle(sender)
|
|
1420
|
+
},
|
|
1421
|
+
...reactionContext ? {} : { contextBinding: {
|
|
1422
|
+
agentId: route.agentId,
|
|
1423
|
+
sessionKey: route.sessionKey,
|
|
1424
|
+
inboundEventKind: "user_request"
|
|
1425
|
+
} },
|
|
1426
|
+
dmPolicy: normalizeDmPolicy(params.dmPolicy),
|
|
1427
|
+
groupPolicy: normalizeGroupPolicy(params.groupPolicy),
|
|
1428
|
+
policy: { groupAllowFromFallbackToAllowFrom: false },
|
|
1429
|
+
allowFrom: params.allowFrom,
|
|
1430
|
+
groupAllowFrom: groupAllowFromForAccess,
|
|
1431
|
+
command: {
|
|
1432
|
+
allowTextCommands: isGroup,
|
|
1433
|
+
hasControlCommand: hasControlCommandInMessage,
|
|
1434
|
+
directGroupAllowFrom: "effective"
|
|
1435
|
+
}
|
|
1436
|
+
});
|
|
1437
|
+
const { commandAccess, senderAccess } = accessDecision;
|
|
1438
|
+
const effectiveGroupAllowFrom = senderAccess.effectiveGroupAllowFrom;
|
|
1439
|
+
if (senderAccess.decision !== "allow") {
|
|
1440
|
+
if (isGroup) {
|
|
1441
|
+
if (senderAccess.reasonCode === "group_policy_disabled") {
|
|
1442
|
+
params.logVerbose?.("Blocked iMessage group message (groupPolicy: disabled)");
|
|
1443
|
+
return {
|
|
1444
|
+
kind: "drop",
|
|
1445
|
+
reason: "groupPolicy disabled"
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
if (senderAccess.reasonCode === "group_policy_empty_allowlist") {
|
|
1449
|
+
params.logVerbose?.("Blocked iMessage group message (groupPolicy: allowlist, no groupAllowFrom)");
|
|
1450
|
+
return {
|
|
1451
|
+
kind: "drop",
|
|
1452
|
+
reason: "groupPolicy allowlist (empty groupAllowFrom)"
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
if (senderAccess.reasonCode === "group_policy_not_allowlisted") {
|
|
1456
|
+
params.logVerbose?.(`Blocked iMessage sender ${sender} (not in groupAllowFrom)`);
|
|
1457
|
+
return {
|
|
1458
|
+
kind: "drop",
|
|
1459
|
+
reason: "not in groupAllowFrom"
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
params.logVerbose?.(`Blocked iMessage group message (${senderAccess.reasonCode})`);
|
|
1463
|
+
return {
|
|
1464
|
+
kind: "drop",
|
|
1465
|
+
reason: senderAccess.reasonCode
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
if (senderAccess.reasonCode === "dm_policy_disabled") return {
|
|
1469
|
+
kind: "drop",
|
|
1470
|
+
reason: "dmPolicy disabled"
|
|
1471
|
+
};
|
|
1472
|
+
if (senderAccess.decision === "pairing") return {
|
|
1473
|
+
kind: "pairing",
|
|
1474
|
+
senderId: senderNormalized
|
|
1475
|
+
};
|
|
1476
|
+
params.logVerbose?.(`Blocked iMessage sender ${sender} (dmPolicy=${params.dmPolicy})`);
|
|
1477
|
+
return {
|
|
1478
|
+
kind: "drop",
|
|
1479
|
+
reason: "dmPolicy blocked"
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
if (isGroup && groupListPolicy.allowlistEnabled && !groupListPolicy.allowed) {
|
|
1483
|
+
params.logVerbose?.(`imessage: skipping group message (${groupId ?? "unknown"}) not in allowlist`);
|
|
1484
|
+
return {
|
|
1485
|
+
kind: "drop",
|
|
1486
|
+
reason: "group id not in allowlist"
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1489
|
+
if (reactionContext) {
|
|
1490
|
+
const notificationMode = params.reactionNotifications ?? "own";
|
|
1491
|
+
if (notificationMode === "off") return {
|
|
1492
|
+
kind: "drop",
|
|
1493
|
+
reason: "reaction notifications disabled"
|
|
1494
|
+
};
|
|
1495
|
+
const targetGuid = reactionContext.targetGuid;
|
|
1496
|
+
const targetGuids = reactionContext.targetGuids ?? (targetGuid ? [targetGuid] : []);
|
|
1497
|
+
const targetIsOwn = Boolean(targetGuid && (params.echoCache && hasIMessageEchoMatch({
|
|
1498
|
+
echoCache: params.echoCache,
|
|
1499
|
+
scope: buildIMessageEchoScope({
|
|
1500
|
+
accountId: params.accountId,
|
|
1501
|
+
isGroup,
|
|
1502
|
+
chatId,
|
|
1503
|
+
chatGuid,
|
|
1504
|
+
chatIdentifier,
|
|
1505
|
+
sender
|
|
1506
|
+
}),
|
|
1507
|
+
messageIds: targetGuids
|
|
1508
|
+
}) || targetGuids.some((messageId) => isKnownFromMeIMessageReactionTarget({
|
|
1509
|
+
messageId,
|
|
1510
|
+
accountId: params.accountId,
|
|
1511
|
+
chatId,
|
|
1512
|
+
chatGuid,
|
|
1513
|
+
chatIdentifier,
|
|
1514
|
+
isKnownFromMeMessageId: params.isKnownFromMeMessageId
|
|
1515
|
+
}))));
|
|
1516
|
+
if (notificationMode === "own" && !targetIsOwn) return {
|
|
1517
|
+
kind: "drop",
|
|
1518
|
+
reason: "reaction target not sent by agent"
|
|
1519
|
+
};
|
|
1520
|
+
const target = targetGuid ? `msg ${targetGuid}` : reactionContext.targetText ? `message "${truncateUtf16Safe(reactionContext.targetText, 80)}"` : "a message";
|
|
1521
|
+
return {
|
|
1522
|
+
kind: "reaction",
|
|
1523
|
+
isGroup,
|
|
1524
|
+
chatId,
|
|
1525
|
+
chatGuid,
|
|
1526
|
+
chatIdentifier,
|
|
1527
|
+
sender,
|
|
1528
|
+
senderNormalized,
|
|
1529
|
+
route,
|
|
1530
|
+
reaction: reactionContext,
|
|
1531
|
+
text: `iMessage reaction ${reactionContext.action}: ${reactionContext.emoji} by ${senderNormalized} on ${target}`,
|
|
1532
|
+
contextKey: [
|
|
1533
|
+
"imessage",
|
|
1534
|
+
"reaction",
|
|
1535
|
+
reactionContext.action,
|
|
1536
|
+
chatId ?? chatGuid ?? chatIdentifier ?? senderNormalized,
|
|
1537
|
+
targetGuid ?? reactionContext.targetText ?? "unknown",
|
|
1538
|
+
senderNormalized,
|
|
1539
|
+
reactionContext.emoji
|
|
1540
|
+
].join(":")
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
const mentionRegexes = buildMentionRegexes(params.cfg, route.agentId);
|
|
1544
|
+
if (!bodyText && mediaFacts.length === 0) return {
|
|
1545
|
+
kind: "drop",
|
|
1546
|
+
reason: "empty body"
|
|
1547
|
+
};
|
|
1548
|
+
if (skipSelfChatHasCheck ? false : params.selfChatCache?.has({
|
|
1549
|
+
...selfChatLookup,
|
|
1550
|
+
text: bodyText
|
|
1551
|
+
})) {
|
|
1552
|
+
const preview = sanitizeTerminalText(truncateUtf16Safe(bodyText, 50));
|
|
1553
|
+
params.logVerbose?.(`imessage: dropping self-chat reflected duplicate: "${preview}"`);
|
|
1554
|
+
return {
|
|
1555
|
+
kind: "drop",
|
|
1556
|
+
reason: "self-chat echo"
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
if (params.echoCache && (messageText || inboundMessageId || mediaFacts.length > 0)) {
|
|
1560
|
+
const echoScope = buildIMessageEchoScope({
|
|
1561
|
+
accountId: params.accountId,
|
|
1562
|
+
isGroup,
|
|
1563
|
+
chatId,
|
|
1564
|
+
chatGuid,
|
|
1565
|
+
chatIdentifier,
|
|
1566
|
+
sender
|
|
1567
|
+
});
|
|
1568
|
+
if (hasIMessageEchoMatch({
|
|
1569
|
+
echoCache: params.echoCache,
|
|
1570
|
+
scope: echoScope,
|
|
1571
|
+
text: bodyText || void 0,
|
|
1572
|
+
media: mediaFacts[0],
|
|
1573
|
+
messageIds: inboundMessageIds,
|
|
1574
|
+
includePendingText: isSelfChat
|
|
1575
|
+
})) {
|
|
1576
|
+
params.logVerbose?.(describeIMessageEchoDropLog({
|
|
1577
|
+
messageText: bodyText,
|
|
1578
|
+
messageId: inboundMessageId
|
|
1579
|
+
}));
|
|
1580
|
+
return {
|
|
1581
|
+
kind: "drop",
|
|
1582
|
+
reason: "echo"
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
const reflection = detectReflectedContent(messageText);
|
|
1587
|
+
if (reflection.isReflection) {
|
|
1588
|
+
params.logVerbose?.(`imessage: dropping reflected assistant content (markers: ${reflection.matchedLabels.join(", ")})`);
|
|
1589
|
+
return {
|
|
1590
|
+
kind: "drop",
|
|
1591
|
+
reason: "reflected assistant content"
|
|
1592
|
+
};
|
|
1593
|
+
}
|
|
1594
|
+
const replyContext = describeReplyContext(params.message);
|
|
1595
|
+
const contextVisibilityMode = resolveChannelContextVisibilityMode({
|
|
1596
|
+
cfg: params.cfg,
|
|
1597
|
+
channel: "imessage",
|
|
1598
|
+
accountId: params.accountId
|
|
1599
|
+
});
|
|
1600
|
+
const replyContextAllowFrom = Array.from(/* @__PURE__ */ new Set([...groupAllowFromForAccess, ...effectiveGroupAllowFrom]));
|
|
1601
|
+
const replySenderAllowed = resolveInboundSupplementalSenderAllowed({
|
|
1602
|
+
isGroup,
|
|
1603
|
+
groupPolicy: replyContextAllowFrom.length === 0 ? "open" : "allowlist",
|
|
1604
|
+
allowFrom: replyContextAllowFrom,
|
|
1605
|
+
isSenderAllowed: (allowFrom) => replyContext?.sender ? isAllowedIMessageReplyContextSender({
|
|
1606
|
+
allowFrom: [...allowFrom],
|
|
1607
|
+
sender: replyContext.sender,
|
|
1608
|
+
chatId,
|
|
1609
|
+
chatGuid,
|
|
1610
|
+
chatIdentifier
|
|
1611
|
+
}) : false
|
|
1612
|
+
});
|
|
1613
|
+
const visibleReply = filterChannelInboundQuoteContext(contextVisibilityMode, replyContext ? {
|
|
1614
|
+
id: replyContext.id,
|
|
1615
|
+
body: replyContext.body,
|
|
1616
|
+
sender: replyContext.sender,
|
|
1617
|
+
senderAllowed: replySenderAllowed
|
|
1618
|
+
} : void 0);
|
|
1619
|
+
const filteredReplyContext = visibleReply ? {
|
|
1620
|
+
id: visibleReply.id,
|
|
1621
|
+
body: visibleReply.body ?? "",
|
|
1622
|
+
sender: visibleReply.sender
|
|
1623
|
+
} : null;
|
|
1624
|
+
if (replyContext && !filteredReplyContext && isGroup) params.logVerbose?.(`imessage: drop reply context (mode=${contextVisibilityMode}, sender_allowed=${replySenderAllowed ? "yes" : "no"})`);
|
|
1625
|
+
const historyKey = isGroup ? String(chatId ?? chatGuid ?? chatIdentifier ?? "unknown") : void 0;
|
|
1626
|
+
const mentioned = isGroup ? matchesMentionPatterns(messageText, mentionRegexes) : true;
|
|
1627
|
+
const requireMention = resolveScopeRequireMention({
|
|
1628
|
+
tree: buildChannelGroupsScopeTree(params.cfg, "imessage", params.accountId),
|
|
1629
|
+
path: groupId ? [groupId] : [],
|
|
1630
|
+
requireMentionOverride: params.opts?.requireMention,
|
|
1631
|
+
overrideOrder: "before-config"
|
|
1632
|
+
});
|
|
1633
|
+
const canDetectMention = mentionRegexes.length > 0;
|
|
1634
|
+
const commandAuthorized = commandAccess.authorized;
|
|
1635
|
+
if (commandAccess.shouldBlockControlCommand) {
|
|
1636
|
+
if (params.logVerbose) logInboundDrop({
|
|
1637
|
+
log: params.logVerbose,
|
|
1638
|
+
channel: "imessage",
|
|
1639
|
+
reason: "control command (unauthorized)",
|
|
1640
|
+
target: sender
|
|
1641
|
+
});
|
|
1642
|
+
return {
|
|
1643
|
+
kind: "drop",
|
|
1644
|
+
reason: "control command (unauthorized)"
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
const mentionDecision = resolveInboundMentionDecision({
|
|
1648
|
+
facts: {
|
|
1649
|
+
canDetectMention,
|
|
1650
|
+
wasMentioned: mentioned,
|
|
1651
|
+
hasAnyMention: false,
|
|
1652
|
+
implicitMentionKinds: []
|
|
1653
|
+
},
|
|
1654
|
+
policy: {
|
|
1655
|
+
isGroup,
|
|
1656
|
+
requireMention,
|
|
1657
|
+
allowTextCommands: true,
|
|
1658
|
+
hasControlCommand: hasControlCommandInMessage,
|
|
1659
|
+
commandAuthorized
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1662
|
+
const effectiveWasMentioned = mentionDecision.effectiveWasMentioned;
|
|
1663
|
+
if (isGroup && requireMention && canDetectMention && mentionDecision.shouldSkip) {
|
|
1664
|
+
params.logVerbose?.(`imessage: skipping group message (no mention)`);
|
|
1665
|
+
createChannelHistoryWindow({ historyMap: params.groupHistories }).record({
|
|
1666
|
+
historyKey: historyKey ?? "",
|
|
1667
|
+
limit: params.historyLimit,
|
|
1668
|
+
entry: historyKey ? {
|
|
1669
|
+
sender: senderNormalized,
|
|
1670
|
+
body: [bodyText, formatMediaPlaceholderText(mediaFacts)].filter(Boolean).join("\n"),
|
|
1671
|
+
timestamp: createdAt,
|
|
1672
|
+
messageId: params.message.id ? String(params.message.id) : void 0
|
|
1673
|
+
} : null
|
|
1674
|
+
});
|
|
1675
|
+
return {
|
|
1676
|
+
kind: "drop",
|
|
1677
|
+
reason: "no mention"
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
return {
|
|
1681
|
+
kind: "dispatch",
|
|
1682
|
+
channelIngress: accessDecision,
|
|
1683
|
+
isGroup,
|
|
1684
|
+
chatId,
|
|
1685
|
+
chatGuid,
|
|
1686
|
+
chatIdentifier,
|
|
1687
|
+
groupId,
|
|
1688
|
+
historyKey,
|
|
1689
|
+
sender,
|
|
1690
|
+
senderNormalized,
|
|
1691
|
+
route,
|
|
1692
|
+
bodyText,
|
|
1693
|
+
createdAt,
|
|
1694
|
+
replyContext: filteredReplyContext,
|
|
1695
|
+
effectiveWasMentioned,
|
|
1696
|
+
groupRequireMention: requireMention,
|
|
1697
|
+
commandAuthorized,
|
|
1698
|
+
hasControlCommand: hasControlCommandInMessage,
|
|
1699
|
+
groupSystemPrompt: isGroup ? resolveIMessageGroupSystemPrompt({
|
|
1700
|
+
groupConfig: groupListPolicy.groupConfig,
|
|
1701
|
+
defaultConfig: groupListPolicy.defaultConfig
|
|
1702
|
+
}) : void 0
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
async function buildIMessageInboundContext(params) {
|
|
1706
|
+
const envelopeOptions = params.envelopeOptions ?? resolveEnvelopeFormatOptions(params.cfg);
|
|
1707
|
+
const { decision } = params;
|
|
1708
|
+
const chatId = decision.chatId;
|
|
1709
|
+
const chatTarget = decision.isGroup && chatId != null ? formatIMessageChatTarget(chatId) : void 0;
|
|
1710
|
+
const messageGuid = normalizeReplyField(params.message.guid);
|
|
1711
|
+
const messageSid = (messageGuid ? rememberIMessageReplyCache({
|
|
1712
|
+
accountId: decision.route.accountId,
|
|
1713
|
+
messageId: messageGuid,
|
|
1714
|
+
chatGuid: decision.chatGuid,
|
|
1715
|
+
chatIdentifier: decision.chatIdentifier,
|
|
1716
|
+
chatId: decision.chatId,
|
|
1717
|
+
timestamp: Date.now(),
|
|
1718
|
+
isFromMe: false
|
|
1719
|
+
}) : null)?.shortId || void 0;
|
|
1720
|
+
const replySuffix = decision.replyContext ? `\n\n[Replying to ${decision.replyContext.sender ?? "unknown sender"}${decision.replyContext.id ? ` id:${decision.replyContext.id}` : ""}]\n${decision.replyContext.body}\n[/Replying]` : "";
|
|
1721
|
+
const fromLabel = formatInboundFromLabel({
|
|
1722
|
+
isGroup: decision.isGroup,
|
|
1723
|
+
groupLabel: params.message.chat_name ?? void 0,
|
|
1724
|
+
groupId: chatId !== void 0 ? String(chatId) : "unknown",
|
|
1725
|
+
groupFallback: "Group",
|
|
1726
|
+
directLabel: decision.senderNormalized,
|
|
1727
|
+
directId: decision.sender
|
|
1728
|
+
});
|
|
1729
|
+
let combinedBody = formatInboundEnvelope({
|
|
1730
|
+
channel: "iMessage",
|
|
1731
|
+
from: fromLabel,
|
|
1732
|
+
timestamp: decision.createdAt,
|
|
1733
|
+
body: `${decision.agentBodyText ?? decision.bodyText}${replySuffix}`,
|
|
1734
|
+
chatType: decision.isGroup ? "group" : "direct",
|
|
1735
|
+
sender: {
|
|
1736
|
+
name: decision.senderNormalized,
|
|
1737
|
+
id: decision.sender
|
|
1738
|
+
},
|
|
1739
|
+
previousTimestamp: params.previousTimestamp,
|
|
1740
|
+
envelope: envelopeOptions
|
|
1741
|
+
});
|
|
1742
|
+
if (!decision.isGroup && params.dmHistory?.body) combinedBody = `${params.dmHistory.body}\n\n${combinedBody}`;
|
|
1743
|
+
if (decision.isGroup && decision.historyKey) combinedBody = createChannelHistoryWindow({ historyMap: params.groupHistories }).buildPendingContext({
|
|
1744
|
+
historyKey: decision.historyKey,
|
|
1745
|
+
limit: params.historyLimit,
|
|
1746
|
+
currentMessage: combinedBody,
|
|
1747
|
+
formatEntry: (entry) => formatInboundEnvelope({
|
|
1748
|
+
channel: "iMessage",
|
|
1749
|
+
from: fromLabel,
|
|
1750
|
+
timestamp: entry.timestamp,
|
|
1751
|
+
body: `${entry.body}${entry.messageId ? ` [id:${entry.messageId}]` : ""}`,
|
|
1752
|
+
chatType: "group",
|
|
1753
|
+
senderLabel: entry.sender,
|
|
1754
|
+
envelope: envelopeOptions
|
|
1755
|
+
})
|
|
1756
|
+
});
|
|
1757
|
+
const imessageTo = decision.isGroup ? chatTarget || `imessage:${decision.sender}` : buildDirectIMessageReplyTarget({
|
|
1758
|
+
cfg: params.cfg,
|
|
1759
|
+
accountId: decision.route.accountId,
|
|
1760
|
+
sender: decision.sender
|
|
1761
|
+
});
|
|
1762
|
+
const imessageFrom = decision.isGroup ? `imessage:group:${chatId ?? "unknown"}` : imessageTo;
|
|
1763
|
+
const inboundHistory = !decision.isGroup && params.dmHistory?.inboundHistory ? params.dmHistory.inboundHistory : decision.isGroup && decision.historyKey && params.historyLimit > 0 ? createChannelHistoryWindow({ historyMap: params.groupHistories }).buildInboundHistory({
|
|
1764
|
+
historyKey: decision.historyKey,
|
|
1765
|
+
limit: params.historyLimit
|
|
1766
|
+
}) : void 0;
|
|
1767
|
+
const media = await toInboundMediaFactsWithMetadata(params.media?.facts?.map((entry) => ({
|
|
1768
|
+
...entry,
|
|
1769
|
+
url: entry.url ?? entry.path
|
|
1770
|
+
})));
|
|
1771
|
+
return {
|
|
1772
|
+
ctxPayload: (params.buildContext ?? buildChannelInboundEventContext)({
|
|
1773
|
+
channelIngress: decision.channelIngress,
|
|
1774
|
+
channel: "imessage",
|
|
1775
|
+
supplemental: {
|
|
1776
|
+
quote: decision.replyContext ? {
|
|
1777
|
+
id: decision.replyContext.id,
|
|
1778
|
+
body: decision.replyContext.body,
|
|
1779
|
+
sender: decision.replyContext.sender
|
|
1780
|
+
} : void 0,
|
|
1781
|
+
groupSystemPrompt: decision.isGroup ? decision.groupSystemPrompt : void 0
|
|
1782
|
+
},
|
|
1783
|
+
media,
|
|
1784
|
+
messageId: messageSid,
|
|
1785
|
+
messageIdFull: messageGuid,
|
|
1786
|
+
timestamp: decision.createdAt,
|
|
1787
|
+
from: imessageFrom,
|
|
1788
|
+
sender: {
|
|
1789
|
+
id: decision.sender,
|
|
1790
|
+
name: decision.senderNormalized
|
|
1791
|
+
},
|
|
1792
|
+
conversation: {
|
|
1793
|
+
kind: decision.isGroup ? "group" : "direct",
|
|
1794
|
+
id: chatId != null ? String(chatId) : decision.sender,
|
|
1795
|
+
label: fromLabel
|
|
1796
|
+
},
|
|
1797
|
+
route: {
|
|
1798
|
+
agentId: decision.route.agentId,
|
|
1799
|
+
dmScope: decision.route.dmScope,
|
|
1800
|
+
accountId: decision.route.accountId,
|
|
1801
|
+
routeSessionKey: decision.route.sessionKey
|
|
1802
|
+
},
|
|
1803
|
+
reply: { to: imessageTo },
|
|
1804
|
+
message: {
|
|
1805
|
+
body: combinedBody,
|
|
1806
|
+
bodyForAgent: decision.agentBodyText ?? decision.bodyText,
|
|
1807
|
+
inboundHistory,
|
|
1808
|
+
rawBody: decision.bodyText,
|
|
1809
|
+
commandBody: decision.bodyText
|
|
1810
|
+
},
|
|
1811
|
+
sessionTranscript: { historyLimit: decision.isGroup ? params.historyLimit : 0 },
|
|
1812
|
+
access: {
|
|
1813
|
+
mentions: {
|
|
1814
|
+
canDetectMention: decision.isGroup,
|
|
1815
|
+
wasMentioned: decision.effectiveWasMentioned
|
|
1816
|
+
},
|
|
1817
|
+
commands: { authorized: decision.commandAuthorized }
|
|
1818
|
+
},
|
|
1819
|
+
extra: {
|
|
1820
|
+
GroupSubject: decision.isGroup ? params.message.chat_name ?? void 0 : void 0,
|
|
1821
|
+
GroupRequireMention: decision.isGroup ? decision.groupRequireMention : void 0,
|
|
1822
|
+
GroupMembers: decision.isGroup ? (params.message.participants ?? []).filter(Boolean).join(", ") : void 0,
|
|
1823
|
+
MediaRemoteHost: params.remoteHost,
|
|
1824
|
+
CommandSource: decision.commandAuthorized && decision.hasControlCommand ? "text" : void 0
|
|
1825
|
+
}
|
|
1826
|
+
}),
|
|
1827
|
+
fromLabel,
|
|
1828
|
+
chatTarget,
|
|
1829
|
+
imessageTo,
|
|
1830
|
+
inboundHistory
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
function buildIMessageEchoScope(params) {
|
|
1834
|
+
const scopes = [];
|
|
1835
|
+
if (params.isGroup) {
|
|
1836
|
+
const chatIdScope = formatIMessageChatTarget(params.chatId);
|
|
1837
|
+
if (chatIdScope) scopes.push(`${params.accountId}:${chatIdScope}`);
|
|
1838
|
+
} else scopes.push(`${params.accountId}:imessage:${params.sender}`);
|
|
1839
|
+
if (params.chatGuid) scopes.push(`${params.accountId}:chat_guid:${params.chatGuid}`);
|
|
1840
|
+
if (params.chatIdentifier) scopes.push(`${params.accountId}:chat_identifier:${params.chatIdentifier}`);
|
|
1841
|
+
return scopes;
|
|
1842
|
+
}
|
|
1843
|
+
function buildDirectIMessageReplyTarget(params) {
|
|
1844
|
+
if (resolveIMessageAccount({
|
|
1845
|
+
cfg: params.cfg,
|
|
1846
|
+
accountId: params.accountId
|
|
1847
|
+
}).config.service === "sms") return `sms:${params.sender}`;
|
|
1848
|
+
return `imessage:${params.sender}`;
|
|
1849
|
+
}
|
|
1850
|
+
function describeIMessageEchoDropLog(params) {
|
|
1851
|
+
const preview = truncateUtf16Safe(params.messageText, 50);
|
|
1852
|
+
return `imessage: skipping echo message${params.messageId ? ` id=${params.messageId}` : ""}: "${preview}"`;
|
|
1853
|
+
}
|
|
1854
|
+
//#endregion
|
|
1855
|
+
//#region extensions/imessage/src/monitor/ingress.ts
|
|
1856
|
+
const IMESSAGE_INGRESS_PAYLOAD_VERSION = 1;
|
|
1857
|
+
const IMESSAGE_INGRESS_DRAIN_INTERVAL_MS = 1e3;
|
|
1858
|
+
const IMessageIngressPayloadError = createChannelIngressError("IMessageIngressPayloadError");
|
|
1859
|
+
function rawMessageRecord(raw) {
|
|
1860
|
+
if (!isRecord$1(raw)) return null;
|
|
1861
|
+
return isRecord$1(raw.message) ? raw.message : null;
|
|
1862
|
+
}
|
|
1863
|
+
function rawRowid(raw) {
|
|
1864
|
+
return asSafeIntegerInRange(rawMessageRecord(raw)?.id, { min: 0 }) ?? null;
|
|
1865
|
+
}
|
|
1866
|
+
/** Read only stable transport metadata; payload normalization waits for dispatch. */
|
|
1867
|
+
function inspectIMessageIngress(raw) {
|
|
1868
|
+
const message = rawMessageRecord(raw);
|
|
1869
|
+
const guid = typeof message?.guid === "string" ? message.guid.trim() : "";
|
|
1870
|
+
if (!guid) throw new IMessageIngressPayloadError("iMessage ingress row is missing its stable GUID.");
|
|
1871
|
+
const rowid = rawRowid(raw);
|
|
1872
|
+
if (rowid === null) throw new IMessageIngressPayloadError("iMessage ingress row is missing its ROWID.");
|
|
1873
|
+
const chatId = message?.chat_id;
|
|
1874
|
+
if (typeof chatId !== "number" || !Number.isSafeInteger(chatId)) throw new IMessageIngressPayloadError("iMessage ingress row is missing its chat id.");
|
|
1875
|
+
const createdAt = message?.created_at;
|
|
1876
|
+
return {
|
|
1877
|
+
eventId: guid,
|
|
1878
|
+
laneKey: `chat:${chatId}`,
|
|
1879
|
+
rowid,
|
|
1880
|
+
...typeof createdAt === "string" ? { createdAt } : {}
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
function decodeIMessageIngressPayload(payload, eventId) {
|
|
1884
|
+
if (typeof payload.receivedAt !== "number" || !Number.isFinite(payload.receivedAt)) throw new IMessageIngressPayloadError(`iMessage ingress payload ${eventId} is invalid.`);
|
|
1885
|
+
return {
|
|
1886
|
+
version: payload.version,
|
|
1887
|
+
body: {
|
|
1888
|
+
receivedAt: payload.receivedAt,
|
|
1889
|
+
raw: payload.raw,
|
|
1890
|
+
...payload.catchup ? { catchup: true } : {}
|
|
1891
|
+
}
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
function deserializeIMessageIngress(body, eventId) {
|
|
1895
|
+
const message = parseIMessageNotification(body.raw);
|
|
1896
|
+
if (!message) throw new IMessageIngressPayloadError(`iMessage ingress payload ${eventId} is invalid.`);
|
|
1897
|
+
return {
|
|
1898
|
+
raw: body.raw,
|
|
1899
|
+
receivedAt: body.receivedAt,
|
|
1900
|
+
message,
|
|
1901
|
+
...body.catchup ? { catchup: true } : {}
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
function isIMessageAuthenticationFailure(error) {
|
|
1905
|
+
return collectErrorGraphCandidates(error, (current) => [
|
|
1906
|
+
current.cause,
|
|
1907
|
+
current.error,
|
|
1908
|
+
current.original
|
|
1909
|
+
]).some((candidate) => {
|
|
1910
|
+
const message = formatErrorMessage(candidate).toLowerCase();
|
|
1911
|
+
return message.includes("full disk access") && message.includes("chat.db") || message.includes("authorization denied") && message.includes("messages");
|
|
1912
|
+
});
|
|
1913
|
+
}
|
|
1914
|
+
function resolveIMessageIngressNonRetryableFailure(error) {
|
|
1915
|
+
if (error instanceof IMessageIngressPayloadError) return {
|
|
1916
|
+
reason: "invalid-event",
|
|
1917
|
+
message: error.message
|
|
1918
|
+
};
|
|
1919
|
+
if (isIMessageAuthenticationFailure(error)) return {
|
|
1920
|
+
reason: "authentication-failed",
|
|
1921
|
+
message: formatErrorMessage(error)
|
|
1922
|
+
};
|
|
1923
|
+
return null;
|
|
1924
|
+
}
|
|
1925
|
+
function createIMessageDurableIngress(options) {
|
|
1926
|
+
const queue = options.queue ?? getIMessageRuntime().state.openChannelIngressQueue({ accountId: options.accountId });
|
|
1927
|
+
const now = options.now ?? Date.now;
|
|
1928
|
+
const dispatchAdmissionQueue = new KeyedAsyncQueue();
|
|
1929
|
+
const priorityDispatchQueue = new KeyedAsyncQueue();
|
|
1930
|
+
const monitor = createChannelIngressMonitor({
|
|
1931
|
+
queue,
|
|
1932
|
+
inspect: (event, context) => {
|
|
1933
|
+
try {
|
|
1934
|
+
return inspectIMessageIngress(event.raw);
|
|
1935
|
+
} catch (error) {
|
|
1936
|
+
if (context.phase === "claim") throw new IMessageIngressPayloadError(`iMessage ingress payload ${context.claimedId} is invalid.`, { cause: error });
|
|
1937
|
+
throw error;
|
|
1938
|
+
}
|
|
1939
|
+
},
|
|
1940
|
+
payload: {
|
|
1941
|
+
version: IMESSAGE_INGRESS_PAYLOAD_VERSION,
|
|
1942
|
+
serialize: (event, { receivedAt }) => ({
|
|
1943
|
+
receivedAt,
|
|
1944
|
+
raw: event.raw,
|
|
1945
|
+
...event.catchup ? { catchup: true } : {}
|
|
1946
|
+
}),
|
|
1947
|
+
deserialize: (body, { claim }) => deserializeIMessageIngress(body, claim.id),
|
|
1948
|
+
encode: ({ body }) => ({
|
|
1949
|
+
version: IMESSAGE_INGRESS_PAYLOAD_VERSION,
|
|
1950
|
+
...body
|
|
1951
|
+
}),
|
|
1952
|
+
decode: (payload, { claim }) => decodeIMessageIngressPayload(payload, claim.id),
|
|
1953
|
+
createClaimError: (_kind, claim) => new IMessageIngressPayloadError(`iMessage ingress payload ${claim.id} is invalid.`)
|
|
1954
|
+
},
|
|
1955
|
+
deliver: async (event, lifecycle, record) => {
|
|
1956
|
+
if (!event.message || event.receivedAt === void 0) throw new IMessageIngressPayloadError(`iMessage ingress payload ${record.id} is invalid.`);
|
|
1957
|
+
const message = event.message;
|
|
1958
|
+
const receivedAt = event.receivedAt;
|
|
1959
|
+
if (lifecycle.abortSignal.aborted) throw lifecycle.abortSignal.reason;
|
|
1960
|
+
const priorityResult = await priorityDispatchQueue.enqueue(record.laneKey ?? record.id, async () => await options.dispatchPriority?.(message, lifecycle, receivedAt, event.catchup ? { catchup: true } : {}));
|
|
1961
|
+
if (priorityResult) return priorityResult;
|
|
1962
|
+
return await dispatchAdmissionQueue.enqueue(record.laneKey ?? record.id, async () => {
|
|
1963
|
+
return await options.dispatch(message, lifecycle, receivedAt, event.catchup ? { catchup: true } : {});
|
|
1964
|
+
});
|
|
1965
|
+
},
|
|
1966
|
+
pollIntervalMs: IMESSAGE_INGRESS_DRAIN_INTERVAL_MS,
|
|
1967
|
+
retention: {
|
|
1968
|
+
completedTtlMs: 14400 * 1e3,
|
|
1969
|
+
completedMaxEntries: 1e4,
|
|
1970
|
+
failedMaxEntries: 1e3
|
|
1971
|
+
},
|
|
1972
|
+
appendRetryDelaysMs: [0],
|
|
1973
|
+
onDurableAdmission: async (event) => {
|
|
1974
|
+
await options.onDurableEnqueue?.(inspectIMessageIngress(event.raw));
|
|
1975
|
+
},
|
|
1976
|
+
onAdmissionFailure: async (event, error) => {
|
|
1977
|
+
await options.onDurableEnqueueFailure?.(rawRowid(event.raw), error);
|
|
1978
|
+
},
|
|
1979
|
+
drain: {
|
|
1980
|
+
deriveLaneKey: (record) => `${record.laneKey ?? "event"}:${record.id}`,
|
|
1981
|
+
resolveNonRetryableFailure: resolveIMessageIngressNonRetryableFailure,
|
|
1982
|
+
onLog: (message) => options.runtime.log?.(`imessage ${message}`)
|
|
1983
|
+
},
|
|
1984
|
+
now,
|
|
1985
|
+
onError: (error) => options.runtime.error?.(`imessage: ingress drain failed: ${formatErrorMessage(error)}`)
|
|
1986
|
+
});
|
|
1987
|
+
let stopTask;
|
|
1988
|
+
return {
|
|
1989
|
+
receive: async (raw, receiveOpts) => {
|
|
1990
|
+
await monitor.admit({
|
|
1991
|
+
raw,
|
|
1992
|
+
...receiveOpts?.catchup ? { catchup: true } : {}
|
|
1993
|
+
});
|
|
1994
|
+
},
|
|
1995
|
+
start: monitor.start,
|
|
1996
|
+
stop: () => {
|
|
1997
|
+
stopTask ??= (async () => {
|
|
1998
|
+
await monitor.waitForIdle();
|
|
1999
|
+
await monitor.stop();
|
|
2000
|
+
})();
|
|
2001
|
+
return stopTask;
|
|
2002
|
+
},
|
|
2003
|
+
waitForIdle: monitor.waitForIdle
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
//#endregion
|
|
2007
|
+
//#region extensions/imessage/src/monitor/loop-rate-limiter.ts
|
|
2008
|
+
/**
|
|
2009
|
+
* Per-conversation rate limiter that detects rapid-fire identical echo
|
|
2010
|
+
* patterns and suppresses them before they amplify into queue overflow.
|
|
2011
|
+
*/
|
|
2012
|
+
const DEFAULT_WINDOW_MS = 6e4;
|
|
2013
|
+
const DEFAULT_MAX_HITS = 5;
|
|
2014
|
+
const CLEANUP_INTERVAL_MS = 12e4;
|
|
2015
|
+
function createLoopRateLimiter(opts) {
|
|
2016
|
+
const windowMs = opts?.windowMs ?? DEFAULT_WINDOW_MS;
|
|
2017
|
+
const maxHits = opts?.maxHits ?? DEFAULT_MAX_HITS;
|
|
2018
|
+
const conversations = /* @__PURE__ */ new Map();
|
|
2019
|
+
let lastCleanup = Date.now();
|
|
2020
|
+
function cleanup() {
|
|
2021
|
+
const now = Date.now();
|
|
2022
|
+
if (now - lastCleanup < CLEANUP_INTERVAL_MS) return;
|
|
2023
|
+
lastCleanup = now;
|
|
2024
|
+
for (const [key, win] of conversations.entries()) {
|
|
2025
|
+
const recent = win.timestamps.filter((ts) => now - ts <= windowMs);
|
|
2026
|
+
if (recent.length === 0) conversations.delete(key);
|
|
2027
|
+
else win.timestamps = recent;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
return {
|
|
2031
|
+
record(conversationKey) {
|
|
2032
|
+
cleanup();
|
|
2033
|
+
let win = conversations.get(conversationKey);
|
|
2034
|
+
if (!win) {
|
|
2035
|
+
win = { timestamps: [] };
|
|
2036
|
+
conversations.set(conversationKey, win);
|
|
2037
|
+
}
|
|
2038
|
+
win.timestamps.push(Date.now());
|
|
2039
|
+
},
|
|
2040
|
+
isRateLimited(conversationKey) {
|
|
2041
|
+
cleanup();
|
|
2042
|
+
const win = conversations.get(conversationKey);
|
|
2043
|
+
if (!win) return false;
|
|
2044
|
+
const now = Date.now();
|
|
2045
|
+
const recent = win.timestamps.filter((ts) => now - ts <= windowMs);
|
|
2046
|
+
win.timestamps = recent;
|
|
2047
|
+
return recent.length >= maxHits;
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
}
|
|
2051
|
+
//#endregion
|
|
2052
|
+
//#region extensions/imessage/src/monitor/media-staging.ts
|
|
2053
|
+
function createTypeOnlyIMessageAttachment(attachment) {
|
|
2054
|
+
const contentType = attachment.mime_type?.trim() || void 0;
|
|
2055
|
+
return {
|
|
2056
|
+
contentType,
|
|
2057
|
+
kind: kindFromMime(contentType) ?? "unknown"
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
function isHeicAttachment(attachmentPath, mimeType) {
|
|
2061
|
+
const normalizedMime = mimeType?.toLowerCase();
|
|
2062
|
+
if (normalizedMime === "image/heic" || normalizedMime === "image/heif") return true;
|
|
2063
|
+
const ext = path.extname(attachmentPath).toLowerCase();
|
|
2064
|
+
return ext === ".heic" || ext === ".heif";
|
|
2065
|
+
}
|
|
2066
|
+
function jpegFilenameForAttachment(attachmentPath) {
|
|
2067
|
+
return `${path.parse(attachmentPath).name || "imessage-attachment"}.jpg`;
|
|
2068
|
+
}
|
|
2069
|
+
function hasWildcardSegment(root) {
|
|
2070
|
+
return root.replaceAll("\\", "/").split("/").includes("*");
|
|
2071
|
+
}
|
|
2072
|
+
async function canonicalizeAllowedRoots(roots) {
|
|
2073
|
+
const canonicalRoots = [];
|
|
2074
|
+
for (const root of roots) {
|
|
2075
|
+
canonicalRoots.push(root);
|
|
2076
|
+
if (hasWildcardSegment(root)) continue;
|
|
2077
|
+
const canonicalRoot = await fs.realpath(root).catch(() => void 0);
|
|
2078
|
+
if (canonicalRoot && canonicalRoot !== root) canonicalRoots.push(canonicalRoot);
|
|
2079
|
+
}
|
|
2080
|
+
return canonicalRoots;
|
|
2081
|
+
}
|
|
2082
|
+
async function assertAllowedCanonicalAttachmentPath(params) {
|
|
2083
|
+
if (!params.allowedRoots) return;
|
|
2084
|
+
const canonicalRoots = await canonicalizeAllowedRoots(params.allowedRoots);
|
|
2085
|
+
if (!isInboundPathAllowed({
|
|
2086
|
+
filePath: params.canonicalPath,
|
|
2087
|
+
roots: canonicalRoots
|
|
2088
|
+
})) throw new Error("attachment path resolves outside allowed roots");
|
|
2089
|
+
}
|
|
2090
|
+
async function readPinnedAttachmentBytes(handle, maxBytes) {
|
|
2091
|
+
const chunks = [];
|
|
2092
|
+
let totalBytes = 0;
|
|
2093
|
+
while (totalBytes <= maxBytes) {
|
|
2094
|
+
const remaining = maxBytes + 1 - totalBytes;
|
|
2095
|
+
const chunk = Buffer.allocUnsafe(Math.min(64 * 1024, remaining));
|
|
2096
|
+
const { bytesRead } = await handle.read(chunk, 0, chunk.length, null);
|
|
2097
|
+
if (bytesRead === 0) return Buffer.concat(chunks, totalBytes);
|
|
2098
|
+
chunks.push(chunk.subarray(0, bytesRead));
|
|
2099
|
+
totalBytes += bytesRead;
|
|
2100
|
+
}
|
|
2101
|
+
throw new Error(`attachment exceeds ${Math.round(maxBytes / (1024 * 1024))}MB limit`);
|
|
2102
|
+
}
|
|
2103
|
+
async function readAttachmentBuffer(params) {
|
|
2104
|
+
const opened = await (params.deps.openLocalFileSafely ?? openLocalFileSafely)({ filePath: params.attachmentPath });
|
|
2105
|
+
try {
|
|
2106
|
+
if (opened.stat.size > params.maxBytes) throw new Error(`attachment exceeds ${Math.round(params.maxBytes / (1024 * 1024))}MB limit`);
|
|
2107
|
+
await assertAllowedCanonicalAttachmentPath({
|
|
2108
|
+
canonicalPath: opened.realPath,
|
|
2109
|
+
allowedRoots: params.allowedRoots
|
|
2110
|
+
});
|
|
2111
|
+
const buffer = await readPinnedAttachmentBytes(opened.handle, params.maxBytes);
|
|
2112
|
+
if (isHeicAttachment(params.attachmentPath, params.mimeType)) try {
|
|
2113
|
+
const convert = params.deps.convertHeicToJpeg;
|
|
2114
|
+
return {
|
|
2115
|
+
buffer: (await withTempWorkspace({
|
|
2116
|
+
rootDir: resolvePreferredOpenClawTmpDir(),
|
|
2117
|
+
prefix: "openclaw-imessage-heic-"
|
|
2118
|
+
}, async (workspace) => {
|
|
2119
|
+
const pinnedPath = await workspace.write("attachment.heic", buffer);
|
|
2120
|
+
return convert ? { buffer: await convert(pinnedPath, params.maxBytes) } : await loadWebMedia(pinnedPath, {
|
|
2121
|
+
maxBytes: params.maxBytes,
|
|
2122
|
+
localRoots: [workspace.dir]
|
|
2123
|
+
});
|
|
2124
|
+
})).buffer,
|
|
2125
|
+
contentType: "image/jpeg",
|
|
2126
|
+
originalFilename: jpegFilenameForAttachment(params.attachmentPath)
|
|
2127
|
+
};
|
|
2128
|
+
} catch (err) {
|
|
2129
|
+
params.deps.logVerbose?.(`imessage: HEIC attachment conversion failed; staging original instead: ${String(err)}`);
|
|
2130
|
+
}
|
|
2131
|
+
return {
|
|
2132
|
+
buffer,
|
|
2133
|
+
contentType: params.mimeType ?? void 0,
|
|
2134
|
+
originalFilename: path.basename(params.attachmentPath)
|
|
2135
|
+
};
|
|
2136
|
+
} finally {
|
|
2137
|
+
await opened.handle.close().catch(() => void 0);
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
async function stageIMessageAttachments(attachments, params) {
|
|
2141
|
+
const deps = params.deps ?? {};
|
|
2142
|
+
const save = deps.saveMediaBuffer ?? saveMediaBuffer;
|
|
2143
|
+
const staged = [];
|
|
2144
|
+
let unavailableCount = 0;
|
|
2145
|
+
for (const attachment of attachments) {
|
|
2146
|
+
const attachmentPath = attachment.original_path?.trim();
|
|
2147
|
+
if (!attachmentPath || attachment.missing) {
|
|
2148
|
+
unavailableCount += 1;
|
|
2149
|
+
staged.push(createTypeOnlyIMessageAttachment(attachment));
|
|
2150
|
+
continue;
|
|
2151
|
+
}
|
|
2152
|
+
try {
|
|
2153
|
+
const media = await readAttachmentBuffer({
|
|
2154
|
+
attachmentPath,
|
|
2155
|
+
mimeType: attachment.mime_type,
|
|
2156
|
+
maxBytes: params.maxBytes,
|
|
2157
|
+
allowedRoots: params.allowedRoots,
|
|
2158
|
+
deps
|
|
2159
|
+
});
|
|
2160
|
+
const saved = await save(media.buffer, media.contentType, "inbound", params.maxBytes, media.originalFilename);
|
|
2161
|
+
const contentType = saved.contentType ?? media.contentType;
|
|
2162
|
+
staged.push({
|
|
2163
|
+
path: saved.path,
|
|
2164
|
+
contentType,
|
|
2165
|
+
kind: kindFromMime(contentType) ?? "unknown"
|
|
2166
|
+
});
|
|
2167
|
+
} catch (err) {
|
|
2168
|
+
unavailableCount += 1;
|
|
2169
|
+
staged.push(createTypeOnlyIMessageAttachment(attachment));
|
|
2170
|
+
deps.logVerbose?.(`imessage: failed to stage inbound attachment: ${String(err)}`);
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
return {
|
|
2174
|
+
attachments: staged,
|
|
2175
|
+
unavailableCount
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
//#endregion
|
|
2179
|
+
//#region extensions/imessage/src/monitor/poll-comment.ts
|
|
2180
|
+
const DEFAULT_COMMENT_WINDOW_MS = 15e3;
|
|
2181
|
+
function normalizeGuid(guid) {
|
|
2182
|
+
return guid?.trim() ?? "";
|
|
2183
|
+
}
|
|
2184
|
+
function normalizeSender(sender) {
|
|
2185
|
+
return sender?.trim().toLowerCase() ?? "";
|
|
2186
|
+
}
|
|
2187
|
+
function createPollCommentFolder(options) {
|
|
2188
|
+
const windowMs = options?.windowMs ?? DEFAULT_COMMENT_WINDOW_MS;
|
|
2189
|
+
const seenPolls = /* @__PURE__ */ new Map();
|
|
2190
|
+
function prune(referenceMs) {
|
|
2191
|
+
for (const [key, seen] of seenPolls) if (referenceMs - seen.atMs > windowMs) seenPolls.delete(key);
|
|
2192
|
+
}
|
|
2193
|
+
return {
|
|
2194
|
+
rememberPoll(guid, atMs, sender) {
|
|
2195
|
+
const key = normalizeGuid(guid);
|
|
2196
|
+
if (!key || !Number.isFinite(atMs)) return;
|
|
2197
|
+
prune(atMs);
|
|
2198
|
+
seenPolls.set(key, {
|
|
2199
|
+
atMs,
|
|
2200
|
+
sender: normalizeSender(sender)
|
|
2201
|
+
});
|
|
2202
|
+
},
|
|
2203
|
+
isPollComment(replyToGuid, atMs, sender) {
|
|
2204
|
+
const key = normalizeGuid(replyToGuid);
|
|
2205
|
+
if (!key || !Number.isFinite(atMs)) return false;
|
|
2206
|
+
const seen = seenPolls.get(key);
|
|
2207
|
+
if (!seen || atMs < seen.atMs || atMs - seen.atMs > windowMs) return false;
|
|
2208
|
+
const replySender = normalizeSender(sender);
|
|
2209
|
+
return seen.sender.length > 0 && replySender.length > 0 && seen.sender === replySender;
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2212
|
+
}
|
|
2213
|
+
//#endregion
|
|
2214
|
+
//#region extensions/imessage/src/monitor/poll-render.ts
|
|
2215
|
+
function renderIMessagePollBody(poll, sender, renderOptions) {
|
|
2216
|
+
const options = poll.options ?? [];
|
|
2217
|
+
if (poll.kind === "vote" || poll.vote && options.length === 0) {
|
|
2218
|
+
if (poll.votes) {
|
|
2219
|
+
const snapshotParticipant = poll.votes.find((vote) => vote.participant?.trim())?.participant?.trim() || sender?.trim() || "someone";
|
|
2220
|
+
const selectionsByParticipant = /* @__PURE__ */ new Map();
|
|
2221
|
+
for (const vote of poll.votes) {
|
|
2222
|
+
if (vote.event_type === "removed") continue;
|
|
2223
|
+
const who = vote.participant?.trim() || snapshotParticipant;
|
|
2224
|
+
const what = vote.option_text?.trim() || vote.option_id || "an option";
|
|
2225
|
+
const selections = selectionsByParticipant.get(who) ?? [];
|
|
2226
|
+
if (!selections.includes(what)) selections.push(what);
|
|
2227
|
+
selectionsByParticipant.set(who, selections);
|
|
2228
|
+
}
|
|
2229
|
+
if (selectionsByParticipant.size === 0) return `\u{1F4CA} Poll selections: ${snapshotParticipant} currently selected no options`;
|
|
2230
|
+
return `\u{1F4CA} Poll selections: ${Array.from(selectionsByParticipant, ([who, selections]) => {
|
|
2231
|
+
return `${who} currently selected ${selections.map((selection) => `"${selection}"`).join(", ")}`;
|
|
2232
|
+
}).join("; ")}`;
|
|
2233
|
+
}
|
|
2234
|
+
const vote = poll.vote;
|
|
2235
|
+
if (!vote) return "📊 Poll vote received";
|
|
2236
|
+
const who = vote.participant?.trim() || sender?.trim() || "someone";
|
|
2237
|
+
const what = vote.option_text?.trim() || vote.option_id || "an option";
|
|
2238
|
+
return `\u{1F4CA} Poll vote: ${who} ${vote.event_type === "removed" ? "removed their vote for" : "voted for"} "${what}"`;
|
|
2239
|
+
}
|
|
2240
|
+
if (options.length === 0) return null;
|
|
2241
|
+
const tally = /* @__PURE__ */ new Map();
|
|
2242
|
+
for (const vote of poll.votes ?? []) {
|
|
2243
|
+
if (vote.event_type === "removed" || !vote.option_id) continue;
|
|
2244
|
+
tally.set(vote.option_id, (tally.get(vote.option_id) ?? 0) + 1);
|
|
2245
|
+
}
|
|
2246
|
+
const optionList = options.map((option, index) => {
|
|
2247
|
+
const count = tally.get(option.id) ?? 0;
|
|
2248
|
+
const id = renderOptions?.preferOptionId ? ` (id: ${option.id})` : "";
|
|
2249
|
+
return `${index + 1}) ${option.text}${id}${count > 0 ? ` [${count}]` : ""}`;
|
|
2250
|
+
}).join(" ");
|
|
2251
|
+
const question = poll.question?.trim();
|
|
2252
|
+
const selector = renderOptions?.preferOptionId ? "pollOptionId = the stable option id shown above" : "pollOptionIndex = the option number";
|
|
2253
|
+
return `\u{1F4CA} Poll${question ? `: ${question}` : ""} — options: ${optionList}. Cast your vote on this poll with the poll-vote action (${selector}); do not answer in a text reply.`;
|
|
2254
|
+
}
|
|
2255
|
+
//#endregion
|
|
2256
|
+
//#region extensions/imessage/src/monitor/reaction-system-event.ts
|
|
2257
|
+
function enqueueIMessageReactionSystemEvent(params) {
|
|
2258
|
+
const { decision, runtime } = params;
|
|
2259
|
+
const queued = enqueueSystemEvent(decision.text, {
|
|
2260
|
+
sessionKey: decision.route.sessionKey,
|
|
2261
|
+
contextKey: decision.contextKey
|
|
2262
|
+
});
|
|
2263
|
+
runtime.log?.(`imessage: reaction system event ${queued ? "queued" : "deduped"} session=${decision.route.sessionKey} target=${decision.reaction.targetGuid ?? "unknown"} action=${decision.reaction.action} emoji=${decision.reaction.emoji}`);
|
|
2264
|
+
params.logVerbose?.(`imessage: reaction event enqueued: ${decision.text}`);
|
|
2265
|
+
return queued;
|
|
2266
|
+
}
|
|
2267
|
+
//#endregion
|
|
2268
|
+
//#region extensions/imessage/src/monitor/recovery-cursor.ts
|
|
2269
|
+
const IMESSAGE_RECOVERY_CURSOR_NAMESPACE = "imessage.recovery-cursor";
|
|
2270
|
+
const IMESSAGE_RECOVERY_CURSOR_MAX_ENTRIES = 64;
|
|
2271
|
+
const LEGACY_CATCHUP_CURSOR_NAMESPACE = "imessage.catchup-cursors";
|
|
2272
|
+
const LEGACY_CATCHUP_CURSOR_MAX_ENTRIES = 256;
|
|
2273
|
+
function openRecoveryCursorStore() {
|
|
2274
|
+
return getIMessageRuntime().state.openSyncKeyedStore({
|
|
2275
|
+
namespace: IMESSAGE_RECOVERY_CURSOR_NAMESPACE,
|
|
2276
|
+
maxEntries: IMESSAGE_RECOVERY_CURSOR_MAX_ENTRIES
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
function normalizeLocalDbPath(dbPath) {
|
|
2280
|
+
let resolved = dbPath.trim();
|
|
2281
|
+
if (resolved.startsWith("~")) {
|
|
2282
|
+
const home = resolveIMessageHomeDir();
|
|
2283
|
+
if (home) resolved = path.join(home, resolved.slice(1).replace(/^\/+/, ""));
|
|
2284
|
+
}
|
|
2285
|
+
return path.resolve(resolved);
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2288
|
+
* Stable identity for the watched Messages database. A changed identity means a
|
|
2289
|
+
* different chat.db (different `dbPath`, custom `cliPath`, or a remote host),
|
|
2290
|
+
* whose rowids share no ordering with the previous one, so the cursor must not
|
|
2291
|
+
* carry across. Local paths are canonicalized so the implicit default and an
|
|
2292
|
+
* explicit path to the same chat.db resolve to one identity.
|
|
2293
|
+
*/
|
|
2294
|
+
function resolveIMessageRecoveryCursorDbIdentity(params) {
|
|
2295
|
+
const remoteHost = params.remoteHost?.trim();
|
|
2296
|
+
if (remoteHost) return `remote:${remoteHost}:${params.dbPath?.trim() || "default"}`;
|
|
2297
|
+
const dbPath = params.dbPath?.trim();
|
|
2298
|
+
if (dbPath) return `local:${normalizeLocalDbPath(dbPath)}`;
|
|
2299
|
+
const cliPath = params.cliPath?.trim();
|
|
2300
|
+
if (!cliPath || cliPath === "imsg" || path.basename(cliPath) === "imsg") {
|
|
2301
|
+
const home = resolveIMessageHomeDir();
|
|
2302
|
+
return home ? `local:${normalizeLocalDbPath(path.join(home, "Library", "Messages", "chat.db"))}` : "local:default";
|
|
2303
|
+
}
|
|
2304
|
+
return `local:cli:${cliPath}`;
|
|
2305
|
+
}
|
|
2306
|
+
function recoveryCursorStoreKey(accountId, dbIdentity) {
|
|
2307
|
+
return `${accountId}\u0000${dbIdentity}`;
|
|
2308
|
+
}
|
|
2309
|
+
function readRecoveryCursor(accountId, dbIdentity) {
|
|
2310
|
+
try {
|
|
2311
|
+
const store = openRecoveryCursorStore();
|
|
2312
|
+
const key = recoveryCursorStoreKey(accountId, dbIdentity);
|
|
2313
|
+
const value = store.lookup(key);
|
|
2314
|
+
if (value) return Number.isFinite(value.lastRowid) ? value.lastRowid : null;
|
|
2315
|
+
const legacy = store.consume(accountId);
|
|
2316
|
+
if (legacy && Number.isFinite(legacy.lastRowid)) {
|
|
2317
|
+
store.register(key, { lastRowid: legacy.lastRowid });
|
|
2318
|
+
return legacy.lastRowid;
|
|
2319
|
+
}
|
|
2320
|
+
return null;
|
|
2321
|
+
} catch {
|
|
2322
|
+
return null;
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
function migrateLegacyCatchupCursor(accountId, dbIdentity) {
|
|
2326
|
+
try {
|
|
2327
|
+
const legacy = getIMessageRuntime().state.openSyncKeyedStore({
|
|
2328
|
+
namespace: LEGACY_CATCHUP_CURSOR_NAMESPACE,
|
|
2329
|
+
maxEntries: LEGACY_CATCHUP_CURSOR_MAX_ENTRIES
|
|
2330
|
+
});
|
|
2331
|
+
const key = createHash("sha256").update(accountId, "utf8").digest("hex").slice(0, 32);
|
|
2332
|
+
const value = legacy.consume(key);
|
|
2333
|
+
const rowid = typeof value?.lastSeenRowid === "number" && Number.isFinite(value.lastSeenRowid) ? value.lastSeenRowid : null;
|
|
2334
|
+
if (rowid !== null) advanceIMessageRecoveryCursor(accountId, dbIdentity, rowid);
|
|
2335
|
+
return rowid;
|
|
2336
|
+
} catch {
|
|
2337
|
+
return null;
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
function reconcileRecoveryCursorToWatermark(accountId, dbIdentity, cursorRowid, watermarkRowid) {
|
|
2341
|
+
if (cursorRowid === null || watermarkRowid === null || cursorRowid <= watermarkRowid) return cursorRowid;
|
|
2342
|
+
try {
|
|
2343
|
+
openRecoveryCursorStore().register(recoveryCursorStoreKey(accountId, dbIdentity), { lastRowid: watermarkRowid });
|
|
2344
|
+
} catch {
|
|
2345
|
+
return watermarkRowid;
|
|
2346
|
+
}
|
|
2347
|
+
return watermarkRowid;
|
|
2348
|
+
}
|
|
2349
|
+
/**
|
|
2350
|
+
* Last durably admitted rowid for this account on `dbIdentity`, or null when
|
|
2351
|
+
* none is recorded yet (including when the only stored cursor belongs to a
|
|
2352
|
+
* different database).
|
|
2353
|
+
*/
|
|
2354
|
+
function loadIMessageRecoveryCursor(accountId, dbIdentity, options = {}) {
|
|
2355
|
+
const watermarkRowid = typeof options.watermarkRowid === "number" && Number.isFinite(options.watermarkRowid) ? options.watermarkRowid : null;
|
|
2356
|
+
const current = readRecoveryCursor(accountId, dbIdentity);
|
|
2357
|
+
if (current !== null) return reconcileRecoveryCursorToWatermark(accountId, dbIdentity, current, watermarkRowid);
|
|
2358
|
+
if (options.migrateLegacyCatchup === false) return null;
|
|
2359
|
+
return reconcileRecoveryCursorToWatermark(accountId, dbIdentity, migrateLegacyCatchupCursor(accountId, dbIdentity), watermarkRowid);
|
|
2360
|
+
}
|
|
2361
|
+
/** Advance the cursor forward to `rowid` (monotonic per database; never rewinds). */
|
|
2362
|
+
function advanceIMessageRecoveryCursor(accountId, dbIdentity, rowid) {
|
|
2363
|
+
if (!Number.isFinite(rowid)) return;
|
|
2364
|
+
try {
|
|
2365
|
+
const store = openRecoveryCursorStore();
|
|
2366
|
+
const key = recoveryCursorStoreKey(accountId, dbIdentity);
|
|
2367
|
+
const current = store.lookup(key);
|
|
2368
|
+
if (current && current.lastRowid >= rowid) return;
|
|
2369
|
+
store.register(key, { lastRowid: rowid });
|
|
2370
|
+
} catch {}
|
|
2371
|
+
}
|
|
2372
|
+
//#endregion
|
|
2373
|
+
//#region extensions/imessage/src/monitor/runtime.ts
|
|
2374
|
+
function resolveRuntime(opts) {
|
|
2375
|
+
return opts.runtime ?? createNonExitingRuntime();
|
|
2376
|
+
}
|
|
2377
|
+
//#endregion
|
|
2378
|
+
//#region extensions/imessage/src/monitor/self-chat-cache.ts
|
|
2379
|
+
const SELF_CHAT_TTL_MS = 1e4;
|
|
2380
|
+
const SELF_CHAT_CREATED_AT_TOLERANCE_MS = 1e3;
|
|
2381
|
+
const MAX_SELF_CHAT_CACHE_ENTRIES = 512;
|
|
2382
|
+
const CLEANUP_MIN_INTERVAL_MS = 1e3;
|
|
2383
|
+
function normalizeText(text) {
|
|
2384
|
+
if (!text) return null;
|
|
2385
|
+
const normalized = text.replace(/\r\n?/g, "\n").trim();
|
|
2386
|
+
return normalized ? normalized : null;
|
|
2387
|
+
}
|
|
2388
|
+
function isUsableTimestamp(createdAt) {
|
|
2389
|
+
return typeof createdAt === "number" && Number.isFinite(createdAt);
|
|
2390
|
+
}
|
|
2391
|
+
function digestText(text) {
|
|
2392
|
+
return createHash("sha256").update(text).digest("hex");
|
|
2393
|
+
}
|
|
2394
|
+
function buildScope(parts) {
|
|
2395
|
+
if (!parts.isGroup) return `${parts.accountId}:imessage:${parts.sender}`;
|
|
2396
|
+
const chatTarget = formatIMessageChatTarget(parts.chatId) || "chat_id:unknown";
|
|
2397
|
+
return `${parts.accountId}:${chatTarget}:imessage:${parts.sender}`;
|
|
2398
|
+
}
|
|
2399
|
+
var DefaultSelfChatCache = class {
|
|
2400
|
+
constructor() {
|
|
2401
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
2402
|
+
this.insertionOrder = [];
|
|
2403
|
+
this.insertionOrderOffset = 0;
|
|
2404
|
+
this.entryCount = 0;
|
|
2405
|
+
this.lastCleanupAt = 0;
|
|
2406
|
+
this.nextEntryId = 1;
|
|
2407
|
+
}
|
|
2408
|
+
buildBucketKey(lookup) {
|
|
2409
|
+
const text = normalizeText(lookup.text);
|
|
2410
|
+
if (!text) return null;
|
|
2411
|
+
return `${buildScope(lookup)}:${digestText(text)}`;
|
|
2412
|
+
}
|
|
2413
|
+
remember(lookup) {
|
|
2414
|
+
const key = this.buildBucketKey(lookup);
|
|
2415
|
+
if (!key || !isUsableTimestamp(lookup.createdAt)) return;
|
|
2416
|
+
const entries = this.cache.get(key) ?? /* @__PURE__ */ new Map();
|
|
2417
|
+
const entry = {
|
|
2418
|
+
id: this.nextEntryId,
|
|
2419
|
+
createdAt: lookup.createdAt,
|
|
2420
|
+
createdAtSkewToleranceMs: lookup.allowCreatedAtSkew ? SELF_CHAT_CREATED_AT_TOLERANCE_MS : 0,
|
|
2421
|
+
rememberedAt: Date.now()
|
|
2422
|
+
};
|
|
2423
|
+
this.nextEntryId += 1;
|
|
2424
|
+
entries.set(entry.id, entry);
|
|
2425
|
+
this.cache.set(key, entries);
|
|
2426
|
+
this.insertionOrder.push({
|
|
2427
|
+
key,
|
|
2428
|
+
id: entry.id
|
|
2429
|
+
});
|
|
2430
|
+
this.entryCount += 1;
|
|
2431
|
+
this.maybeCleanup();
|
|
2432
|
+
}
|
|
2433
|
+
has(lookup) {
|
|
2434
|
+
this.maybeCleanup();
|
|
2435
|
+
const key = this.buildBucketKey(lookup);
|
|
2436
|
+
if (!key || !isUsableTimestamp(lookup.createdAt)) return false;
|
|
2437
|
+
const entries = this.cache.get(key);
|
|
2438
|
+
if (!entries) return false;
|
|
2439
|
+
const now = Date.now();
|
|
2440
|
+
const createdAt = lookup.createdAt;
|
|
2441
|
+
return [...entries.values()].some((entry) => {
|
|
2442
|
+
const createdAtDelta = Math.abs(entry.createdAt - createdAt);
|
|
2443
|
+
return now - entry.rememberedAt <= SELF_CHAT_TTL_MS && (createdAtDelta === 0 || createdAtDelta < entry.createdAtSkewToleranceMs);
|
|
2444
|
+
});
|
|
2445
|
+
}
|
|
2446
|
+
maybeCleanup() {
|
|
2447
|
+
const now = Date.now();
|
|
2448
|
+
if (now - this.lastCleanupAt < CLEANUP_MIN_INTERVAL_MS) return;
|
|
2449
|
+
this.lastCleanupAt = now;
|
|
2450
|
+
for (const [key, entries] of this.cache.entries()) {
|
|
2451
|
+
for (const [id, entry] of entries.entries()) if (now - entry.rememberedAt > SELF_CHAT_TTL_MS) {
|
|
2452
|
+
entries.delete(id);
|
|
2453
|
+
this.entryCount -= 1;
|
|
2454
|
+
}
|
|
2455
|
+
if (entries.size === 0) this.cache.delete(key);
|
|
2456
|
+
}
|
|
2457
|
+
while (this.entryCount > MAX_SELF_CHAT_CACHE_ENTRIES && this.insertionOrderOffset < this.insertionOrder.length) {
|
|
2458
|
+
const oldest = expectDefined(this.insertionOrder[this.insertionOrderOffset], "oldest iMessage self-chat cache entry");
|
|
2459
|
+
this.insertionOrderOffset += 1;
|
|
2460
|
+
const entries = this.cache.get(oldest.key);
|
|
2461
|
+
if (!entries) continue;
|
|
2462
|
+
if (!entries.delete(oldest.id)) continue;
|
|
2463
|
+
this.entryCount -= 1;
|
|
2464
|
+
if (entries.size === 0) this.cache.delete(oldest.key);
|
|
2465
|
+
}
|
|
2466
|
+
this.compactInsertionOrder();
|
|
2467
|
+
}
|
|
2468
|
+
compactInsertionOrder() {
|
|
2469
|
+
if (this.insertionOrderOffset <= 1024 && this.insertionOrder.length <= this.entryCount + 1024) return;
|
|
2470
|
+
this.insertionOrder = this.insertionOrder.slice(this.insertionOrderOffset).filter((entry) => this.cache.get(entry.key)?.has(entry.id));
|
|
2471
|
+
this.insertionOrderOffset = 0;
|
|
2472
|
+
}
|
|
2473
|
+
};
|
|
2474
|
+
function createSelfChatCache() {
|
|
2475
|
+
return new DefaultSelfChatCache();
|
|
2476
|
+
}
|
|
2477
|
+
//#endregion
|
|
2478
|
+
//#region extensions/imessage/src/monitor/watch-error-log.ts
|
|
2479
|
+
const MAX_WATCH_ERROR_MESSAGE_CHARS = 200;
|
|
2480
|
+
function sanitizeIMessageWatchErrorPayload(payload) {
|
|
2481
|
+
if (!isRecord(payload)) return {};
|
|
2482
|
+
const safe = {};
|
|
2483
|
+
if (typeof payload.code === "number" && Number.isFinite(payload.code)) safe.code = payload.code;
|
|
2484
|
+
if (typeof payload.message === "string") {
|
|
2485
|
+
const sanitizedMessage = sanitizeTerminalText(payload.message);
|
|
2486
|
+
if (sanitizedMessage) safe.message = sanitizedMessage.length > MAX_WATCH_ERROR_MESSAGE_CHARS ? `${truncateUtf16Safe(sanitizedMessage, MAX_WATCH_ERROR_MESSAGE_CHARS - 1)}…` : sanitizedMessage;
|
|
2487
|
+
}
|
|
2488
|
+
return safe;
|
|
2489
|
+
}
|
|
2490
|
+
//#endregion
|
|
2491
|
+
//#region extensions/imessage/src/monitor/monitor-provider.ts
|
|
2492
|
+
const WATCH_SUBSCRIBE_MAX_ATTEMPTS = 3;
|
|
2493
|
+
const WATCH_SUBSCRIBE_RETRY_DELAY_MS = 1e3;
|
|
2494
|
+
const CHANNEL_APPROVAL_GATEWAY_RUNTIME_CONTEXT_CAPABILITY = "approval.gateway";
|
|
2495
|
+
const APPROVAL_REACTION_POLL_INTERVAL_MS = 2e3;
|
|
2496
|
+
const APPROVAL_REACTION_DISCOVERY_INTERVAL_MS = 6e4;
|
|
2497
|
+
const IMESSAGE_TYPING_KEEPALIVE_INTERVAL_MS = 8e3;
|
|
2498
|
+
const IMESSAGE_TYPING_KEEPALIVE_MAX_DURATION_MS = 10 * 6e4;
|
|
2499
|
+
function resolveConfiguredIMessageTypingMode(cfg, agentId) {
|
|
2500
|
+
return resolveAgentConfig(cfg, agentId)?.typingMode ?? cfg.agents?.defaults?.typingMode;
|
|
2501
|
+
}
|
|
2502
|
+
function isIMessagePluginPayloadAttachment(attachment) {
|
|
2503
|
+
const attachmentPath = attachment.original_path?.trim().toLowerCase() ?? "";
|
|
2504
|
+
const transferName = attachment.transfer_name?.trim().toLowerCase() ?? "";
|
|
2505
|
+
const uti = attachment.uti?.trim().toLowerCase() ?? "";
|
|
2506
|
+
return attachmentPath.endsWith(".pluginpayloadattachment") || transferName.endsWith(".pluginpayloadattachment") || uti === "com.apple.messages.pluginpayloadattachment";
|
|
2507
|
+
}
|
|
2508
|
+
function resolveIMessageInboundMediaInput(params) {
|
|
2509
|
+
const mediaCandidates = params.attachments.filter((entry) => !isIMessagePluginPayloadAttachment(entry));
|
|
2510
|
+
const mediaFacts = mediaCandidates.map((attachment) => {
|
|
2511
|
+
const contentType = attachment.mime_type?.trim() || void 0;
|
|
2512
|
+
return {
|
|
2513
|
+
contentType,
|
|
2514
|
+
kind: kindFromMime(contentType) ?? "unknown"
|
|
2515
|
+
};
|
|
2516
|
+
});
|
|
2517
|
+
const rawMediaAttachments = mediaCandidates.map((attachment, index) => {
|
|
2518
|
+
const fact = mediaFacts[index] ?? { kind: "unknown" };
|
|
2519
|
+
const attachmentPath = attachment.original_path?.trim();
|
|
2520
|
+
if (!attachmentPath || attachment.missing) return fact;
|
|
2521
|
+
if (!isInboundPathAllowed({
|
|
2522
|
+
filePath: attachmentPath,
|
|
2523
|
+
roots: params.effectiveAttachmentRoots
|
|
2524
|
+
})) {
|
|
2525
|
+
params.logVerbose?.(`imessage: dropping inbound attachment outside allowed roots: ${attachmentPath}`);
|
|
2526
|
+
return fact;
|
|
2527
|
+
}
|
|
2528
|
+
return {
|
|
2529
|
+
...fact,
|
|
2530
|
+
path: attachmentPath
|
|
2531
|
+
};
|
|
2532
|
+
});
|
|
2533
|
+
return {
|
|
2534
|
+
bodyText: params.messageText,
|
|
2535
|
+
mediaFacts,
|
|
2536
|
+
mediaCandidates,
|
|
2537
|
+
rawMediaAttachments
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2540
|
+
function formatIMessageInboundMediaBody(params) {
|
|
2541
|
+
return formatInboundMediaUnavailableText({
|
|
2542
|
+
body: params.messageText,
|
|
2543
|
+
notice: `[imessage ${params.unavailableCount > 1 ? `${params.unavailableCount} attachments` : "attachment"} unavailable]`
|
|
2544
|
+
});
|
|
2545
|
+
}
|
|
2546
|
+
function resolveIMessageWatchSourceDbPath(params) {
|
|
2547
|
+
return resolveIMessageChatDbLookupPath(params);
|
|
2548
|
+
}
|
|
2549
|
+
async function resolveIMessageStartupRowidWatermark(dbPath) {
|
|
2550
|
+
let database;
|
|
2551
|
+
try {
|
|
2552
|
+
database = openNodeSqliteDatabase(dbPath, { readOnly: true });
|
|
2553
|
+
const row = database.prepare("SELECT MAX(ROWID) AS maxRowid FROM message").get();
|
|
2554
|
+
if (typeof row?.maxRowid === "number" && Number.isFinite(row.maxRowid)) return row.maxRowid;
|
|
2555
|
+
return row?.maxRowid === null ? 0 : null;
|
|
2556
|
+
} catch (err) {
|
|
2557
|
+
logVerbose(`imessage: startup rowid watermark unavailable for db=${dbPath}: ${String(err)}`);
|
|
2558
|
+
return null;
|
|
2559
|
+
} finally {
|
|
2560
|
+
database?.close();
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
const warnIfImsgUpgradeNeeded = (() => {
|
|
2564
|
+
let fired = false;
|
|
2565
|
+
return { fireOnce: (rpcMethods, runtime) => {
|
|
2566
|
+
if (fired) return;
|
|
2567
|
+
fired = true;
|
|
2568
|
+
const detail = rpcMethods.length === 0 ? "imsg build pre-dates the rpc_methods capability list" : `imsg rpc_methods=[${rpcMethods.join(", ")}] does not include typing/read`;
|
|
2569
|
+
runtime.log?.(warn(`imessage: typing indicators / read receipts gated off (${detail}). Upgrade imsg (current bridge needs typing+read in rpc_methods).`));
|
|
2570
|
+
} };
|
|
2571
|
+
})();
|
|
2572
|
+
function isRetriableWatchSubscribeStartupError(error) {
|
|
2573
|
+
return /imsg rpc timeout \(watch\.subscribe\)|imsg rpc (closed|exited|not running)/i.test(String(error));
|
|
2574
|
+
}
|
|
2575
|
+
const IMESSAGE_DIAGNOSTIC_DROP_REASONS = /* @__PURE__ */ new Set([
|
|
2576
|
+
"agent echo in self-chat",
|
|
2577
|
+
"echo",
|
|
2578
|
+
"from me",
|
|
2579
|
+
"reflected assistant content",
|
|
2580
|
+
"self-chat echo"
|
|
2581
|
+
]);
|
|
2582
|
+
const IMESSAGE_THROTTLED_DIAGNOSTIC_DROP_REASONS = /* @__PURE__ */ new Set(["from me"]);
|
|
2583
|
+
function shouldThrottleIMessageInboundDropDiagnostic(reason) {
|
|
2584
|
+
return IMESSAGE_THROTTLED_DIAGNOSTIC_DROP_REASONS.has(reason);
|
|
2585
|
+
}
|
|
2586
|
+
function describeIMessageInboundDropDiagnostic(params) {
|
|
2587
|
+
if (!IMESSAGE_DIAGNOSTIC_DROP_REASONS.has(params.reason)) return null;
|
|
2588
|
+
const messageId = typeof params.message.id === "number" || typeof params.message.id === "string" ? String(params.message.id) : "unknown";
|
|
2589
|
+
return `imessage: dropped inbound message account=${params.accountId} reason=${JSON.stringify(params.reason)} chat_id=${params.message.chat_id ?? "unknown"} group=${params.message.is_group === true} message_id=${messageId} guid=${params.message.guid ? "present" : "missing"} created_at=${params.message.created_at ?? "unknown"}`;
|
|
2590
|
+
}
|
|
2591
|
+
function describeIMessageWatchSubscribeStartupFailure(params) {
|
|
2592
|
+
const retry = params.retryDelayMs !== void 0 ? ` retry_in_ms=${params.retryDelayMs}` : "";
|
|
2593
|
+
return `imessage: watch.subscribe startup failed attempt=${params.attempt}/${params.maxAttempts} account=${params.accountId} cliPath=${params.cliPath} dbPath=${params.dbPath ? "configured" : "default"} remoteHost=${params.remoteHost ? "configured" : "none"} timeoutMs=${params.probeTimeoutMs} since_rowid=${params.watchSinceRowid ?? "none"} attachments=${params.includeAttachments} include_reactions=true${retry}: ${String(params.error)}`;
|
|
2594
|
+
}
|
|
2595
|
+
async function waitForWatchSubscribeRetryDelay(params) {
|
|
2596
|
+
if (params.ms <= 0) return;
|
|
2597
|
+
await new Promise((resolve) => {
|
|
2598
|
+
const timer = setTimeout(() => {
|
|
2599
|
+
params.abortSignal?.removeEventListener("abort", onAbort);
|
|
2600
|
+
resolve();
|
|
2601
|
+
}, params.ms);
|
|
2602
|
+
const onAbort = () => {
|
|
2603
|
+
clearTimeout(timer);
|
|
2604
|
+
params.abortSignal?.removeEventListener("abort", onAbort);
|
|
2605
|
+
resolve();
|
|
2606
|
+
};
|
|
2607
|
+
params.abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
2608
|
+
});
|
|
2609
|
+
}
|
|
2610
|
+
async function monitorIMessageProvider(opts = {}) {
|
|
2611
|
+
const runtime = resolveRuntime(opts);
|
|
2612
|
+
const cfg = opts.config ?? getRuntimeConfig();
|
|
2613
|
+
const accountInfo = resolveIMessageAccount({
|
|
2614
|
+
cfg,
|
|
2615
|
+
accountId: opts.accountId
|
|
2616
|
+
});
|
|
2617
|
+
const approvalGatewayRuntime = opts.channelRuntime?.runtimeContexts.get({
|
|
2618
|
+
channelId: "imessage",
|
|
2619
|
+
accountId: accountInfo.accountId,
|
|
2620
|
+
capability: CHANNEL_APPROVAL_GATEWAY_RUNTIME_CONTEXT_CAPABILITY
|
|
2621
|
+
});
|
|
2622
|
+
const imessageCfg = accountInfo.config;
|
|
2623
|
+
const historyLimit = Math.max(0, imessageCfg.historyLimit ?? cfg.messages?.groupChat?.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT);
|
|
2624
|
+
const groupHistories = /* @__PURE__ */ new Map();
|
|
2625
|
+
const sentMessageCache = createSentMessageCache();
|
|
2626
|
+
const selfChatCache = createSelfChatCache();
|
|
2627
|
+
const loopRateLimiter = createLoopRateLimiter();
|
|
2628
|
+
const textLimit = resolveTextChunkLimit(cfg, "imessage", accountInfo.accountId);
|
|
2629
|
+
const allowFrom = normalizeStringEntries(opts.allowFrom ?? imessageCfg.allowFrom);
|
|
2630
|
+
const configuredGroupAllowFrom = opts.groupAllowFrom ?? imessageCfg.groupAllowFrom;
|
|
2631
|
+
const groupAllowFrom = normalizeStringEntries(configuredGroupAllowFrom ?? (imessageCfg.allowFrom && imessageCfg.allowFrom.length > 0 ? imessageCfg.allowFrom : []));
|
|
2632
|
+
const allowLegacyConversationAllowFromForGroup = configuredGroupAllowFrom == null;
|
|
2633
|
+
const defaultGroupPolicy = resolveDefaultGroupPolicy(cfg);
|
|
2634
|
+
const { groupPolicy, providerMissingFallbackApplied } = resolveOpenProviderRuntimeGroupPolicy({
|
|
2635
|
+
providerConfigPresent: cfg.channels?.imessage !== void 0,
|
|
2636
|
+
groupPolicy: imessageCfg.groupPolicy,
|
|
2637
|
+
defaultGroupPolicy
|
|
2638
|
+
});
|
|
2639
|
+
warnMissingProviderGroupPolicyFallbackOnce({
|
|
2640
|
+
providerMissingFallbackApplied,
|
|
2641
|
+
providerKey: "imessage",
|
|
2642
|
+
accountId: accountInfo.accountId,
|
|
2643
|
+
log: (message) => runtime.log?.(warn(message))
|
|
2644
|
+
});
|
|
2645
|
+
warnGroupAllowlistMisconfigOnce({
|
|
2646
|
+
groupPolicy,
|
|
2647
|
+
hasGroupAllowFrom: mergeIMessageGroupAllowFromWithLegacyChatTargets({
|
|
2648
|
+
groupAllowFrom,
|
|
2649
|
+
allowFrom,
|
|
2650
|
+
allowLegacyConversationTargets: allowLegacyConversationAllowFromForGroup
|
|
2651
|
+
}).length > 0,
|
|
2652
|
+
accountId: accountInfo.accountId,
|
|
2653
|
+
log: (message) => runtime.log?.(warn(message))
|
|
2654
|
+
});
|
|
2655
|
+
const dmPolicy = imessageCfg.dmPolicy ?? "pairing";
|
|
2656
|
+
const catchupCfg = resolveCatchupConfig(imessageCfg.catchup);
|
|
2657
|
+
const includeAttachments = opts.includeAttachments ?? imessageCfg.includeAttachments ?? false;
|
|
2658
|
+
const mediaMaxBytes = (opts.mediaMaxMb ?? imessageCfg.mediaMaxMb ?? 16) * 1024 * 1024;
|
|
2659
|
+
const cliPath = opts.cliPath ?? imessageCfg.cliPath ?? "imsg";
|
|
2660
|
+
const dbPath = opts.dbPath ?? imessageCfg.dbPath;
|
|
2661
|
+
const probeTimeoutMs = imessageCfg.probeTimeoutMs ?? 1e4;
|
|
2662
|
+
const attachmentRoots = resolveIMessageAttachmentRoots({
|
|
2663
|
+
cfg,
|
|
2664
|
+
accountId: accountInfo.accountId
|
|
2665
|
+
});
|
|
2666
|
+
const remoteAttachmentRoots = resolveIMessageRemoteAttachmentRoots({
|
|
2667
|
+
cfg,
|
|
2668
|
+
accountId: accountInfo.accountId
|
|
2669
|
+
});
|
|
2670
|
+
const remoteHost = await resolveIMessageRemoteHost({
|
|
2671
|
+
cliPath,
|
|
2672
|
+
remoteHost: imessageCfg.remoteHost
|
|
2673
|
+
});
|
|
2674
|
+
let staleBacklogSuppressed = 0;
|
|
2675
|
+
const loggedThrottledDropDiagnostics = createIMessageThrottledDropDiagnosticCache();
|
|
2676
|
+
const watchSourceDbPath = resolveIMessageWatchSourceDbPath({
|
|
2677
|
+
cliPath,
|
|
2678
|
+
dbPath,
|
|
2679
|
+
remoteHost
|
|
2680
|
+
});
|
|
2681
|
+
const recoveryBoundaryRowid = watchSourceDbPath ? await resolveIMessageStartupRowidWatermark(watchSourceDbPath) : null;
|
|
2682
|
+
const recoveryCursorDbIdentity = resolveIMessageRecoveryCursorDbIdentity({
|
|
2683
|
+
cliPath,
|
|
2684
|
+
dbPath,
|
|
2685
|
+
remoteHost
|
|
2686
|
+
});
|
|
2687
|
+
const recoveryCursorRowid = loadIMessageRecoveryCursor(accountInfo.accountId, recoveryCursorDbIdentity, {
|
|
2688
|
+
migrateLegacyCatchup: !catchupCfg.enabled,
|
|
2689
|
+
watermarkRowid: recoveryBoundaryRowid
|
|
2690
|
+
});
|
|
2691
|
+
const reconciledWatchSinceRowid = catchupCfg.enabled ? null : recoveryCursorRowid !== null ? recoveryBoundaryRowid !== null ? Math.max(recoveryCursorRowid, recoveryBoundaryRowid - 500) : recoveryCursorRowid : recoveryBoundaryRowid;
|
|
2692
|
+
const watchSinceRowid = reconciledWatchSinceRowid === 0 ? -1 : reconciledWatchSinceRowid;
|
|
2693
|
+
let latestAdvancedRecoveryCursorRowid = recoveryCursorRowid ?? -1;
|
|
2694
|
+
const durableRecoveryCursorRowids = /* @__PURE__ */ new Set();
|
|
2695
|
+
const failedRecoveryCursorRowids = /* @__PURE__ */ new Set();
|
|
2696
|
+
function minSetValue(values) {
|
|
2697
|
+
let min = null;
|
|
2698
|
+
for (const value of values) min = min === null ? value : Math.min(min, value);
|
|
2699
|
+
return min;
|
|
2700
|
+
}
|
|
2701
|
+
function advanceRecoveryCursorAfterDurableEnqueue(rowid) {
|
|
2702
|
+
if (catchupCfg.enabled) return;
|
|
2703
|
+
failedRecoveryCursorRowids.delete(rowid);
|
|
2704
|
+
durableRecoveryCursorRowids.add(rowid);
|
|
2705
|
+
const maxDurableRowid = Math.max(...durableRecoveryCursorRowids);
|
|
2706
|
+
const holdFloor = minSetValue(failedRecoveryCursorRowids);
|
|
2707
|
+
const nextCursorRowid = holdFloor !== null && maxDurableRowid >= holdFloor ? holdFloor - 1 : maxDurableRowid;
|
|
2708
|
+
if (nextCursorRowid >= 0 && nextCursorRowid > latestAdvancedRecoveryCursorRowid) {
|
|
2709
|
+
advanceIMessageRecoveryCursor(accountInfo.accountId, recoveryCursorDbIdentity, nextCursorRowid);
|
|
2710
|
+
latestAdvancedRecoveryCursorRowid = nextCursorRowid;
|
|
2711
|
+
for (const durableRowid of durableRecoveryCursorRowids) if (durableRowid <= nextCursorRowid) durableRecoveryCursorRowids.delete(durableRowid);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
function holdRecoveryCursorBeforeFailedEnqueue(rowid) {
|
|
2715
|
+
if (catchupCfg.enabled || rowid === null || rowid <= latestAdvancedRecoveryCursorRowid) return;
|
|
2716
|
+
failedRecoveryCursorRowids.add(rowid);
|
|
2717
|
+
}
|
|
2718
|
+
const { debouncer: inboundDebouncer } = createChannelInboundDebouncer({
|
|
2719
|
+
cfg,
|
|
2720
|
+
channel: "imessage",
|
|
2721
|
+
buildKey: (entry) => {
|
|
2722
|
+
const msg = entry.message;
|
|
2723
|
+
const sender = msg.sender?.trim();
|
|
2724
|
+
if (!sender) return null;
|
|
2725
|
+
const conversationId = msg.chat_id != null ? `chat:${msg.chat_id}` : msg.chat_guid ?? msg.chat_identifier ?? "unknown";
|
|
2726
|
+
return `imessage:${accountInfo.accountId}:${conversationId}:${sender}`;
|
|
2727
|
+
},
|
|
2728
|
+
shouldDebounce: (entry) => {
|
|
2729
|
+
const msg = entry.message;
|
|
2730
|
+
if (resolveIMessageReactionContext(msg, (msg.text ?? "").trim())) return false;
|
|
2731
|
+
if (msg.is_from_me === true) return false;
|
|
2732
|
+
return shouldDebounceTextInbound({
|
|
2733
|
+
text: msg.text,
|
|
2734
|
+
cfg,
|
|
2735
|
+
hasMedia: Boolean(msg.attachments?.some((attachment) => !isIMessagePluginPayloadAttachment(attachment)))
|
|
2736
|
+
});
|
|
2737
|
+
},
|
|
2738
|
+
onFlush: (entries, createFlush) => {
|
|
2739
|
+
const { lifecycle, settle, abandon } = fanInChannelIngressLifecycles(entries.flatMap((entry) => entry.ingressLifecycle ? [entry.ingressLifecycle] : []));
|
|
2740
|
+
return createFlush({
|
|
2741
|
+
lifecycle,
|
|
2742
|
+
dispatch: async (admissionLifecycle) => {
|
|
2743
|
+
if (entries.length === 0) return;
|
|
2744
|
+
try {
|
|
2745
|
+
if (admissionLifecycle.abortSignal.aborted) {
|
|
2746
|
+
await abandon();
|
|
2747
|
+
return;
|
|
2748
|
+
}
|
|
2749
|
+
if (entries.length === 1) {
|
|
2750
|
+
await handleMessageNow(expectDefined(entries[0], "single iMessage dispatch entry").message, admissionLifecycle);
|
|
2751
|
+
await settle();
|
|
2752
|
+
return;
|
|
2753
|
+
}
|
|
2754
|
+
const combined = combineIMessagePayloads(entries.map((entry) => entry.message));
|
|
2755
|
+
if (shouldLogVerbose()) {
|
|
2756
|
+
const text = combined.text ?? "";
|
|
2757
|
+
const preview = sliceUtf16Safe(text, 0, 50);
|
|
2758
|
+
const ellipsis = text.length > 50 ? "..." : "";
|
|
2759
|
+
logVerbose(`[imessage] merged ${entries.length} debounced messages: "${preview}${ellipsis}"`);
|
|
2760
|
+
}
|
|
2761
|
+
await handleMessageNow(combined, admissionLifecycle);
|
|
2762
|
+
await settle();
|
|
2763
|
+
} catch (err) {
|
|
2764
|
+
await abandon();
|
|
2765
|
+
runtime.error?.(`imessage: inbound dispatch failed: ${String(err)}`);
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
});
|
|
2769
|
+
},
|
|
2770
|
+
onError: (err) => {
|
|
2771
|
+
runtime.error?.(`imessage debounce flush failed: ${String(err)}`);
|
|
2772
|
+
}
|
|
2773
|
+
});
|
|
2774
|
+
let client;
|
|
2775
|
+
let detachAbortHandler = () => {};
|
|
2776
|
+
let liveCatchupCursorAdvanceEnabled = false;
|
|
2777
|
+
let startupCatchupInProgress = false;
|
|
2778
|
+
const pendingLiveCatchupCursorAdvances = [];
|
|
2779
|
+
const getActiveClient = () => {
|
|
2780
|
+
if (!client) throw new Error("imessage monitor client not initialized");
|
|
2781
|
+
return client;
|
|
2782
|
+
};
|
|
2783
|
+
async function repairMessageConversationAnchor(message) {
|
|
2784
|
+
return await repairIMessageConversationAnchor({
|
|
2785
|
+
client: getActiveClient(),
|
|
2786
|
+
message,
|
|
2787
|
+
runtime
|
|
2788
|
+
});
|
|
2789
|
+
}
|
|
2790
|
+
function resolveLiveCatchupCursor(message) {
|
|
2791
|
+
const coalescedCursor = message.coalescedCatchupCursor;
|
|
2792
|
+
const rowid = typeof coalescedCursor?.lastSeenRowid === "number" && Number.isFinite(coalescedCursor.lastSeenRowid) ? coalescedCursor.lastSeenRowid : typeof message.id === "number" && Number.isFinite(message.id) ? message.id : null;
|
|
2793
|
+
const dateMs = typeof coalescedCursor?.lastSeenMs === "number" && Number.isFinite(coalescedCursor.lastSeenMs) ? coalescedCursor.lastSeenMs : typeof message.created_at === "string" ? Date.parse(message.created_at) : NaN;
|
|
2794
|
+
if (rowid === null || !Number.isFinite(dateMs)) return null;
|
|
2795
|
+
return {
|
|
2796
|
+
lastSeenMs: dateMs,
|
|
2797
|
+
lastSeenRowid: rowid
|
|
2798
|
+
};
|
|
2799
|
+
}
|
|
2800
|
+
async function maybeAdvanceLiveCatchupCursor(message) {
|
|
2801
|
+
if (!catchupCfg.enabled) return;
|
|
2802
|
+
const cursor = resolveLiveCatchupCursor(message);
|
|
2803
|
+
if (!cursor) return;
|
|
2804
|
+
if (!liveCatchupCursorAdvanceEnabled) {
|
|
2805
|
+
if (startupCatchupInProgress) pendingLiveCatchupCursorAdvances.push(cursor);
|
|
2806
|
+
return;
|
|
2807
|
+
}
|
|
2808
|
+
try {
|
|
2809
|
+
await advanceIMessageCatchupCursor(accountInfo.accountId, cursor, catchupCfg);
|
|
2810
|
+
} catch (err) {
|
|
2811
|
+
runtime.error?.(`imessage catchup: failed to advance live cursor: ${String(err)}`);
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
async function flushPendingLiveCatchupCursorAdvances() {
|
|
2815
|
+
for (const cursor of pendingLiveCatchupCursorAdvances.splice(0)) try {
|
|
2816
|
+
await advanceIMessageCatchupCursor(accountInfo.accountId, cursor, catchupCfg);
|
|
2817
|
+
} catch (err) {
|
|
2818
|
+
runtime.error?.(`imessage catchup: failed to advance pending live cursor: ${String(err)}`);
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
async function handleMessageNow(message, ingressLifecycle) {
|
|
2822
|
+
await handleMessageNowInner(message, ingressLifecycle);
|
|
2823
|
+
}
|
|
2824
|
+
const pollCommentFolder = createPollCommentFolder();
|
|
2825
|
+
function resolveIMessageInboundBodyText(message) {
|
|
2826
|
+
const messageText = ((message.poll ? renderIMessagePollBody(message.poll, message.sender, { preferOptionId: Boolean(remoteHost) }) : null) ?? message.text ?? "").trim();
|
|
2827
|
+
const attachments = includeAttachments ? message.attachments ?? [] : [];
|
|
2828
|
+
const effectiveAttachmentRoots = remoteHost ? remoteAttachmentRoots : attachmentRoots;
|
|
2829
|
+
return {
|
|
2830
|
+
messageText,
|
|
2831
|
+
...resolveIMessageInboundMediaInput({
|
|
2832
|
+
messageText,
|
|
2833
|
+
attachments,
|
|
2834
|
+
effectiveAttachmentRoots,
|
|
2835
|
+
logVerbose
|
|
2836
|
+
}),
|
|
2837
|
+
effectiveAttachmentRoots
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2840
|
+
async function handleMessageNowInner(rawMessage, ingressLifecycle) {
|
|
2841
|
+
const message = await repairMessageConversationAnchor(rawMessage);
|
|
2842
|
+
if (!message) return;
|
|
2843
|
+
const pollFoldAtMs = message.created_at ? Date.parse(message.created_at) : NaN;
|
|
2844
|
+
if (message.poll) pollCommentFolder.rememberPoll(message.guid, pollFoldAtMs, message.sender);
|
|
2845
|
+
else if (message.reply_to_guid != null && pollCommentFolder.isPollComment(message.reply_to_guid, pollFoldAtMs, message.sender)) {
|
|
2846
|
+
logVerbose("imessage: folding poll comment (inline reply sent with a poll) into the poll; not delivering standalone");
|
|
2847
|
+
return;
|
|
2848
|
+
}
|
|
2849
|
+
const { messageText, bodyText, mediaFacts, mediaCandidates, rawMediaAttachments, effectiveAttachmentRoots } = resolveIMessageInboundBodyText(message);
|
|
2850
|
+
const storeAllowFrom = await readChannelAllowFromStore("imessage", process.env, accountInfo.accountId).catch(() => []);
|
|
2851
|
+
const isQuestionReaction = hasIMessageQuestionReactionTarget({
|
|
2852
|
+
accountId: accountInfo.accountId,
|
|
2853
|
+
message,
|
|
2854
|
+
bodyText
|
|
2855
|
+
});
|
|
2856
|
+
const decision = await resolveIMessageInboundDecision({
|
|
2857
|
+
cfg,
|
|
2858
|
+
accountId: accountInfo.accountId,
|
|
2859
|
+
message,
|
|
2860
|
+
opts,
|
|
2861
|
+
messageText,
|
|
2862
|
+
bodyText,
|
|
2863
|
+
mediaFacts,
|
|
2864
|
+
allowFrom,
|
|
2865
|
+
groupAllowFrom,
|
|
2866
|
+
allowLegacyConversationAllowFromForGroup,
|
|
2867
|
+
groupPolicy,
|
|
2868
|
+
dmPolicy,
|
|
2869
|
+
storeAllowFrom,
|
|
2870
|
+
historyLimit,
|
|
2871
|
+
groupHistories,
|
|
2872
|
+
echoCache: sentMessageCache,
|
|
2873
|
+
selfChatCache,
|
|
2874
|
+
reactionNotifications: isQuestionReaction ? "all" : imessageCfg.reactionNotifications,
|
|
2875
|
+
logVerbose
|
|
2876
|
+
});
|
|
2877
|
+
const chatId = message.chat_id ?? void 0;
|
|
2878
|
+
const senderForKey = (message.sender ?? "").trim();
|
|
2879
|
+
const conversationKey = chatId != null ? `group:${chatId}` : `dm:${senderForKey}`;
|
|
2880
|
+
const rateLimitKey = `${accountInfo.accountId}:${conversationKey}`;
|
|
2881
|
+
if (decision.kind === "drop") {
|
|
2882
|
+
if (decision.reason === "echo" || decision.reason === "self-chat echo" || decision.reason === "reflected assistant content") loopRateLimiter.record(rateLimitKey);
|
|
2883
|
+
const diagnostic = describeIMessageInboundDropDiagnostic({
|
|
2884
|
+
accountId: accountInfo.accountId,
|
|
2885
|
+
reason: decision.reason,
|
|
2886
|
+
message
|
|
2887
|
+
});
|
|
2888
|
+
if (diagnostic) {
|
|
2889
|
+
const throttleKey = `${rateLimitKey}:${decision.reason}`;
|
|
2890
|
+
if (!shouldThrottleIMessageInboundDropDiagnostic(decision.reason) || !loggedThrottledDropDiagnostics.check(throttleKey)) runtime.log?.(warn(diagnostic));
|
|
2891
|
+
}
|
|
2892
|
+
if (decision.reason === "group id not in allowlist") warnGroupAllowlistDropPerChatOnce({
|
|
2893
|
+
accountId: accountInfo.accountId,
|
|
2894
|
+
chatId: message.chat_id ?? void 0,
|
|
2895
|
+
log: (msg) => runtime.log?.(warn(msg))
|
|
2896
|
+
});
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2899
|
+
if (decision.kind === "dispatch" && loopRateLimiter.isRateLimited(rateLimitKey)) {
|
|
2900
|
+
if (!loggedThrottledDropDiagnostics.check(`${rateLimitKey}:rate-limited`)) {
|
|
2901
|
+
const diagnosticConversationKey = `${chatId != null ? "group" : "dm"}:${redactIdentifier(conversationKey)}`;
|
|
2902
|
+
runtime.log?.(warn(`[imessage:${accountInfo.accountId}] Suppressing inbound from ${diagnosticConversationKey}: echo loop detected (rate limiter tripped)`));
|
|
2903
|
+
}
|
|
2904
|
+
return;
|
|
2905
|
+
}
|
|
2906
|
+
if (decision.kind === "pairing") {
|
|
2907
|
+
const sender = (message.sender ?? "").trim();
|
|
2908
|
+
if (!sender) return;
|
|
2909
|
+
await createChannelPairingChallengeIssuer({
|
|
2910
|
+
channel: "imessage",
|
|
2911
|
+
accountId: accountInfo.accountId,
|
|
2912
|
+
upsertPairingRequest: async ({ id, meta }) => await upsertChannelPairingRequest({
|
|
2913
|
+
channel: "imessage",
|
|
2914
|
+
id,
|
|
2915
|
+
accountId: accountInfo.accountId,
|
|
2916
|
+
meta
|
|
2917
|
+
})
|
|
2918
|
+
})({
|
|
2919
|
+
senderId: decision.senderId,
|
|
2920
|
+
senderIdLine: `Your iMessage sender id: ${decision.senderId}`,
|
|
2921
|
+
meta: {
|
|
2922
|
+
sender: decision.senderId,
|
|
2923
|
+
chatId: chatId ? String(chatId) : void 0
|
|
2924
|
+
},
|
|
2925
|
+
onCreated: () => {
|
|
2926
|
+
logVerbose(`imessage pairing request sender=${decision.senderId}`);
|
|
2927
|
+
},
|
|
2928
|
+
sendPairingReply: async (text) => {
|
|
2929
|
+
await sendMessageIMessage(sender, text, {
|
|
2930
|
+
config: cfg,
|
|
2931
|
+
client: getActiveClient(),
|
|
2932
|
+
maxBytes: mediaMaxBytes,
|
|
2933
|
+
accountId: accountInfo.accountId,
|
|
2934
|
+
...chatId ? { chatId } : {}
|
|
2935
|
+
});
|
|
2936
|
+
},
|
|
2937
|
+
onReplyError: (err) => {
|
|
2938
|
+
runtime.error?.(`imessage pairing reply failed for ${decision.senderId}: ${String(err)}`);
|
|
2939
|
+
}
|
|
2940
|
+
});
|
|
2941
|
+
return;
|
|
2942
|
+
}
|
|
2943
|
+
if (decision.kind === "reaction") {
|
|
2944
|
+
if (await maybeResolveIMessageQuestionReaction({
|
|
2945
|
+
cfg,
|
|
2946
|
+
accountId: accountInfo.accountId,
|
|
2947
|
+
message,
|
|
2948
|
+
bodyText,
|
|
2949
|
+
senderId: decision.senderNormalized,
|
|
2950
|
+
logDebug: logVerbose
|
|
2951
|
+
})) return;
|
|
2952
|
+
enqueueIMessageReactionSystemEvent({
|
|
2953
|
+
decision,
|
|
2954
|
+
runtime,
|
|
2955
|
+
logVerbose
|
|
2956
|
+
});
|
|
2957
|
+
return;
|
|
2958
|
+
}
|
|
2959
|
+
const storePath = resolveStorePath(cfg.session?.store, { agentId: decision.route.agentId });
|
|
2960
|
+
const privateApiStatus = getCachedIMessagePrivateApiStatus(cliPath);
|
|
2961
|
+
const supportsTyping = imessageRpcSupportsMethod(privateApiStatus, "typing");
|
|
2962
|
+
const supportsRead = imessageRpcSupportsMethod(privateApiStatus, "read");
|
|
2963
|
+
if (privateApiStatus?.available === true) {
|
|
2964
|
+
if (!supportsTyping || !supportsRead) warnIfImsgUpgradeNeeded.fireOnce(privateApiStatus.rpcMethods, runtime);
|
|
2965
|
+
}
|
|
2966
|
+
const configuredTypingMode = resolveConfiguredIMessageTypingMode(cfg, decision.route.agentId);
|
|
2967
|
+
const sendPolicy = resolveSendPolicy({
|
|
2968
|
+
cfg,
|
|
2969
|
+
entry: getSessionEntry({
|
|
2970
|
+
storePath,
|
|
2971
|
+
sessionKey: decision.route.sessionKey
|
|
2972
|
+
}),
|
|
2973
|
+
sessionKey: decision.route.sessionKey,
|
|
2974
|
+
channel: "imessage",
|
|
2975
|
+
chatType: decision.isGroup ? "group" : "direct"
|
|
2976
|
+
});
|
|
2977
|
+
const shouldUseDirectToolTypingOptions = !decision.isGroup && sendPolicy !== "deny" && (configuredTypingMode === void 0 || configuredTypingMode === "instant");
|
|
2978
|
+
const earlyDirectTypingTarget = supportsTyping && shouldUseDirectToolTypingOptions ? buildDirectIMessageReplyTarget({
|
|
2979
|
+
cfg,
|
|
2980
|
+
accountId: decision.route.accountId,
|
|
2981
|
+
sender: decision.sender
|
|
2982
|
+
}) : void 0;
|
|
2983
|
+
let stopEarlyDirectTyping;
|
|
2984
|
+
if (earlyDirectTypingTarget) {
|
|
2985
|
+
const earlyDirectTypingStarted = sendIMessageTyping(earlyDirectTypingTarget, true, {
|
|
2986
|
+
cfg,
|
|
2987
|
+
accountId: accountInfo.accountId,
|
|
2988
|
+
cliPath,
|
|
2989
|
+
dbPath,
|
|
2990
|
+
remoteHost
|
|
2991
|
+
}).then(() => true, (err) => {
|
|
2992
|
+
logTypingFailure({
|
|
2993
|
+
log: (msg) => logVerbose(msg),
|
|
2994
|
+
channel: "imessage",
|
|
2995
|
+
action: "start",
|
|
2996
|
+
target: earlyDirectTypingTarget,
|
|
2997
|
+
error: err
|
|
2998
|
+
});
|
|
2999
|
+
return false;
|
|
3000
|
+
});
|
|
3001
|
+
let earlyTypingStopQueued = false;
|
|
3002
|
+
stopEarlyDirectTyping = () => {
|
|
3003
|
+
if (earlyTypingStopQueued) return;
|
|
3004
|
+
earlyTypingStopQueued = true;
|
|
3005
|
+
earlyDirectTypingStarted.then(async (started) => {
|
|
3006
|
+
if (!started) return;
|
|
3007
|
+
await sendIMessageTyping(earlyDirectTypingTarget, false, {
|
|
3008
|
+
cfg,
|
|
3009
|
+
accountId: accountInfo.accountId,
|
|
3010
|
+
cliPath,
|
|
3011
|
+
dbPath,
|
|
3012
|
+
remoteHost
|
|
3013
|
+
});
|
|
3014
|
+
}).catch((err) => {
|
|
3015
|
+
logTypingFailure({
|
|
3016
|
+
log: (msg) => logVerbose(msg),
|
|
3017
|
+
channel: "imessage",
|
|
3018
|
+
action: "stop",
|
|
3019
|
+
target: earlyDirectTypingTarget,
|
|
3020
|
+
error: err
|
|
3021
|
+
});
|
|
3022
|
+
});
|
|
3023
|
+
};
|
|
3024
|
+
}
|
|
3025
|
+
const staged = remoteHost ? {
|
|
3026
|
+
attachments: rawMediaAttachments,
|
|
3027
|
+
unavailableCount: rawMediaAttachments.filter((attachment) => !attachment.path).length
|
|
3028
|
+
} : await stageIMessageAttachments(mediaCandidates, {
|
|
3029
|
+
maxBytes: mediaMaxBytes,
|
|
3030
|
+
allowedRoots: effectiveAttachmentRoots,
|
|
3031
|
+
deps: { logVerbose }
|
|
3032
|
+
});
|
|
3033
|
+
const mediaAttachments = staged.attachments;
|
|
3034
|
+
const unavailableCount = staged.unavailableCount;
|
|
3035
|
+
const contextDecision = unavailableCount > 0 ? {
|
|
3036
|
+
...decision,
|
|
3037
|
+
agentBodyText: formatIMessageInboundMediaBody({
|
|
3038
|
+
messageText,
|
|
3039
|
+
unavailableCount
|
|
3040
|
+
})
|
|
3041
|
+
} : decision;
|
|
3042
|
+
const previousTimestamp = readSessionUpdatedAt({
|
|
3043
|
+
storePath,
|
|
3044
|
+
sessionKey: decision.route.sessionKey
|
|
3045
|
+
});
|
|
3046
|
+
const dmHistoryLimit = !decision.isGroup ? resolveIMessageDmHistoryLimit({
|
|
3047
|
+
config: imessageCfg,
|
|
3048
|
+
sender: decision.sender,
|
|
3049
|
+
senderNormalized: decision.senderNormalized
|
|
3050
|
+
}) : 0;
|
|
3051
|
+
const dmHistory = !decision.isGroup && dmHistoryLimit > 0 && !previousTimestamp ? await resolveIMessageDmHistoryContext({
|
|
3052
|
+
client: getActiveClient(),
|
|
3053
|
+
message,
|
|
3054
|
+
senderNormalized: decision.senderNormalized,
|
|
3055
|
+
limit: dmHistoryLimit,
|
|
3056
|
+
envelopeOptions: resolveEnvelopeFormatOptions(cfg),
|
|
3057
|
+
logVerbose
|
|
3058
|
+
}) : void 0;
|
|
3059
|
+
const { ctxPayload, chatTarget, imessageTo } = await buildIMessageInboundContext({
|
|
3060
|
+
cfg,
|
|
3061
|
+
decision: contextDecision,
|
|
3062
|
+
message,
|
|
3063
|
+
previousTimestamp,
|
|
3064
|
+
remoteHost,
|
|
3065
|
+
historyLimit,
|
|
3066
|
+
groupHistories,
|
|
3067
|
+
dmHistory,
|
|
3068
|
+
buildContext: opts.channelRuntime?.inbound.buildContext,
|
|
3069
|
+
media: { facts: mediaAttachments }
|
|
3070
|
+
});
|
|
3071
|
+
const updateTarget = chatTarget || imessageTo;
|
|
3072
|
+
const pinnedMainDmOwner = resolvePinnedMainDmOwnerFromAllowlist({
|
|
3073
|
+
dmScope: cfg.session?.dmScope,
|
|
3074
|
+
allowFrom,
|
|
3075
|
+
normalizeEntry: normalizeIMessageHandle
|
|
3076
|
+
});
|
|
3077
|
+
if (shouldLogVerbose()) {
|
|
3078
|
+
const preview = truncateUtf16Safe(ctxPayload.Body ?? "", 200).replace(/\n/g, "\\n");
|
|
3079
|
+
logVerbose(`imessage inbound: chatId=${chatId ?? "unknown"} from=${ctxPayload.From} len=${(ctxPayload.Body ?? "").length} preview="${preview}"`);
|
|
3080
|
+
}
|
|
3081
|
+
const sendReadReceipts = imessageCfg.sendReadReceipts !== false;
|
|
3082
|
+
const typingTarget = ctxPayload.To;
|
|
3083
|
+
if (supportsRead && sendReadReceipts && typingTarget) markIMessageChatRead(typingTarget, {
|
|
3084
|
+
cfg,
|
|
3085
|
+
accountId: accountInfo.accountId,
|
|
3086
|
+
cliPath,
|
|
3087
|
+
dbPath,
|
|
3088
|
+
remoteHost
|
|
3089
|
+
}).catch((err) => {
|
|
3090
|
+
runtime.error?.(`imessage: mark read failed: ${String(err)}`);
|
|
3091
|
+
});
|
|
3092
|
+
const { onModelSelected, ...replyPipeline } = createChannelMessageReplyPipeline({
|
|
3093
|
+
cfg,
|
|
3094
|
+
agentId: decision.route.agentId,
|
|
3095
|
+
channel: "imessage",
|
|
3096
|
+
accountId: decision.route.accountId,
|
|
3097
|
+
typing: supportsTyping && typingTarget ? {
|
|
3098
|
+
start: async () => {
|
|
3099
|
+
await sendIMessageTyping(typingTarget, true, {
|
|
3100
|
+
cfg,
|
|
3101
|
+
accountId: accountInfo.accountId,
|
|
3102
|
+
client: getActiveClient(),
|
|
3103
|
+
cliPath,
|
|
3104
|
+
dbPath,
|
|
3105
|
+
remoteHost
|
|
3106
|
+
});
|
|
3107
|
+
},
|
|
3108
|
+
stop: async () => {
|
|
3109
|
+
await sendIMessageTyping(typingTarget, false, {
|
|
3110
|
+
cfg,
|
|
3111
|
+
accountId: accountInfo.accountId,
|
|
3112
|
+
client: getActiveClient(),
|
|
3113
|
+
cliPath,
|
|
3114
|
+
dbPath,
|
|
3115
|
+
remoteHost
|
|
3116
|
+
});
|
|
3117
|
+
},
|
|
3118
|
+
keepaliveIntervalMs: IMESSAGE_TYPING_KEEPALIVE_INTERVAL_MS,
|
|
3119
|
+
maxDurationMs: IMESSAGE_TYPING_KEEPALIVE_MAX_DURATION_MS,
|
|
3120
|
+
onStartError: (err) => {
|
|
3121
|
+
logTypingFailure({
|
|
3122
|
+
log: (msg) => logVerbose(msg),
|
|
3123
|
+
channel: "imessage",
|
|
3124
|
+
action: "start",
|
|
3125
|
+
target: typingTarget,
|
|
3126
|
+
error: err
|
|
3127
|
+
});
|
|
3128
|
+
},
|
|
3129
|
+
onStopError: (err) => {
|
|
3130
|
+
logTypingFailure({
|
|
3131
|
+
log: (msg) => logVerbose(msg),
|
|
3132
|
+
channel: "imessage",
|
|
3133
|
+
action: "stop",
|
|
3134
|
+
target: typingTarget,
|
|
3135
|
+
error: err
|
|
3136
|
+
});
|
|
3137
|
+
}
|
|
3138
|
+
} : void 0
|
|
3139
|
+
});
|
|
3140
|
+
const dispatcherOptions = {
|
|
3141
|
+
...replyPipeline,
|
|
3142
|
+
humanDelay: resolveHumanDelayConfig(cfg, decision.route.agentId)
|
|
3143
|
+
};
|
|
3144
|
+
const delivery = {
|
|
3145
|
+
durable: ctxPayload.To ? {
|
|
3146
|
+
to: ctxPayload.To,
|
|
3147
|
+
deps: { imessage: createIMessageEchoCachingSend({
|
|
3148
|
+
accountId: accountInfo.accountId,
|
|
3149
|
+
sentMessageCache
|
|
3150
|
+
}) }
|
|
3151
|
+
} : false,
|
|
3152
|
+
observeMessageSent: true,
|
|
3153
|
+
deliver: async (payload) => {
|
|
3154
|
+
const target = ctxPayload.To;
|
|
3155
|
+
if (!target) {
|
|
3156
|
+
runtime.error?.(danger("imessage: missing delivery target"));
|
|
3157
|
+
return {
|
|
3158
|
+
visibleReplySent: false,
|
|
3159
|
+
suppression: { reason: "no_visible_result" }
|
|
3160
|
+
};
|
|
3161
|
+
}
|
|
3162
|
+
return await deliverIMessageReply({
|
|
3163
|
+
cfg,
|
|
3164
|
+
payload,
|
|
3165
|
+
target,
|
|
3166
|
+
accountId: accountInfo.accountId,
|
|
3167
|
+
runtime,
|
|
3168
|
+
maxBytes: mediaMaxBytes,
|
|
3169
|
+
textLimit,
|
|
3170
|
+
sentMessageCache
|
|
3171
|
+
});
|
|
3172
|
+
},
|
|
3173
|
+
onError: (err, info) => {
|
|
3174
|
+
runtime.error?.(danger(`imessage ${info.kind} reply failed: ${String(err)}`));
|
|
3175
|
+
}
|
|
3176
|
+
};
|
|
3177
|
+
let directTypingController;
|
|
3178
|
+
const directToolTypingOptions = shouldUseDirectToolTypingOptions ? {
|
|
3179
|
+
suppressDefaultToolProgressMessages: true,
|
|
3180
|
+
allowProgressCallbacksWhenSourceDeliverySuppressed: true,
|
|
3181
|
+
onTypingController: (typing) => {
|
|
3182
|
+
directTypingController = typing;
|
|
3183
|
+
},
|
|
3184
|
+
onToolResult: async () => {
|
|
3185
|
+
await directTypingController?.startTypingLoop();
|
|
3186
|
+
return false;
|
|
3187
|
+
},
|
|
3188
|
+
...supportsTyping ? { onToolStart: async () => {
|
|
3189
|
+
await directTypingController?.startTypingLoop();
|
|
3190
|
+
return false;
|
|
3191
|
+
} } : {}
|
|
3192
|
+
} : {};
|
|
3193
|
+
const configuredBlockStreaming = resolveChannelStreamingBlockEnabled(accountInfo.config);
|
|
3194
|
+
const inboundLastRouteSessionKey = resolveInboundLastRouteSessionKey({
|
|
3195
|
+
route: decision.route,
|
|
3196
|
+
sessionKey: decision.route.sessionKey
|
|
3197
|
+
});
|
|
3198
|
+
await runChannelInboundEvent({
|
|
3199
|
+
channel: "imessage",
|
|
3200
|
+
accountId: decision.route.accountId,
|
|
3201
|
+
raw: decision,
|
|
3202
|
+
adapter: {
|
|
3203
|
+
ingest: () => ({
|
|
3204
|
+
id: ctxPayload.MessageSid ?? `${ctxPayload.From}:${Date.now()}`,
|
|
3205
|
+
timestamp: typeof ctxPayload.Timestamp === "number" ? ctxPayload.Timestamp : void 0,
|
|
3206
|
+
rawText: ctxPayload.RawBody ?? "",
|
|
3207
|
+
textForAgent: ctxPayload.BodyForAgent,
|
|
3208
|
+
textForCommands: ctxPayload.CommandBody,
|
|
3209
|
+
raw: decision
|
|
3210
|
+
}),
|
|
3211
|
+
resolveTurn: () => ({
|
|
3212
|
+
cfg,
|
|
3213
|
+
channel: "imessage",
|
|
3214
|
+
accountId: decision.route.accountId,
|
|
3215
|
+
route: {
|
|
3216
|
+
agentId: decision.route.agentId,
|
|
3217
|
+
sessionKey: decision.route.sessionKey
|
|
3218
|
+
},
|
|
3219
|
+
ctxPayload,
|
|
3220
|
+
record: {
|
|
3221
|
+
updateLastRoute: !decision.isGroup && updateTarget ? {
|
|
3222
|
+
sessionKey: inboundLastRouteSessionKey,
|
|
3223
|
+
channel: "imessage",
|
|
3224
|
+
to: updateTarget,
|
|
3225
|
+
accountId: decision.route.accountId,
|
|
3226
|
+
mainDmOwnerPin: inboundLastRouteSessionKey === decision.route.mainSessionKey && pinnedMainDmOwner && decision.senderNormalized ? {
|
|
3227
|
+
ownerRecipient: pinnedMainDmOwner,
|
|
3228
|
+
senderRecipient: decision.senderNormalized,
|
|
3229
|
+
onSkip: ({ ownerRecipient, senderRecipient }) => {
|
|
3230
|
+
logVerbose(`imessage: skip main-session last route for ${senderRecipient} (pinned owner ${ownerRecipient})`);
|
|
3231
|
+
}
|
|
3232
|
+
} : void 0
|
|
3233
|
+
} : void 0,
|
|
3234
|
+
onRecordError: (err) => {
|
|
3235
|
+
logVerbose(`imessage: failed updating session meta: ${String(err)}`);
|
|
3236
|
+
}
|
|
3237
|
+
},
|
|
3238
|
+
history: {
|
|
3239
|
+
isGroup: decision.isGroup,
|
|
3240
|
+
historyKey: decision.historyKey,
|
|
3241
|
+
historyMap: groupHistories,
|
|
3242
|
+
limit: historyLimit
|
|
3243
|
+
},
|
|
3244
|
+
delivery,
|
|
3245
|
+
dispatcherOptions: {
|
|
3246
|
+
...dispatcherOptions,
|
|
3247
|
+
onSettled: () => stopEarlyDirectTyping?.()
|
|
3248
|
+
},
|
|
3249
|
+
replyOptions: {
|
|
3250
|
+
...ingressLifecycle ? bindIngressLifecycleToReplyOptions(ingressLifecycle) : {},
|
|
3251
|
+
disableBlockStreaming: typeof configuredBlockStreaming === "boolean" ? !configuredBlockStreaming : void 0,
|
|
3252
|
+
onModelSelected,
|
|
3253
|
+
...directToolTypingOptions
|
|
3254
|
+
}
|
|
3255
|
+
}),
|
|
3256
|
+
onFinalize: () => stopEarlyDirectTyping?.()
|
|
3257
|
+
}
|
|
3258
|
+
});
|
|
3259
|
+
}
|
|
3260
|
+
const suppressStaleIngress = (message, receivedAt, provenance) => {
|
|
3261
|
+
const isRecoveryReplay = recoveryCursorRowid !== null && recoveryBoundaryRowid !== null && typeof message.id === "number" && message.id <= recoveryBoundaryRowid;
|
|
3262
|
+
const staleThresholdMs = isRecoveryReplay ? IMESSAGE_RECOVERY_MAX_AGE_MS : IMESSAGE_STALE_INBOUND_THRESHOLD_MS;
|
|
3263
|
+
if (provenance?.catchup || !isStaleIMessageBacklog(message, receivedAt, staleThresholdMs)) return false;
|
|
3264
|
+
staleBacklogSuppressed += 1;
|
|
3265
|
+
runtime.log?.(warn(`imessage: suppressed stale inbound backlog account=${accountInfo.accountId} sent=${message.created_at ?? "unknown"} recovery=${isRecoveryReplay} (${staleBacklogSuppressed} suppressed since start)`));
|
|
3266
|
+
return true;
|
|
3267
|
+
};
|
|
3268
|
+
const maybeHandleApprovalControl = async (message) => {
|
|
3269
|
+
if (await maybeResolveIMessageApprovalPollVote({
|
|
3270
|
+
cfg,
|
|
3271
|
+
accountId: accountInfo.accountId,
|
|
3272
|
+
message,
|
|
3273
|
+
gatewayRuntime: approvalGatewayRuntime
|
|
3274
|
+
})) return true;
|
|
3275
|
+
return await maybeResolveIMessageApprovalReaction({
|
|
3276
|
+
cfg,
|
|
3277
|
+
accountId: accountInfo.accountId,
|
|
3278
|
+
message,
|
|
3279
|
+
bodyText: resolveIMessageInboundBodyText(message).bodyText,
|
|
3280
|
+
gatewayRuntime: approvalGatewayRuntime,
|
|
3281
|
+
logVerboseMessage: logVerbose
|
|
3282
|
+
});
|
|
3283
|
+
};
|
|
3284
|
+
const resolveApprovalControlConversation = (message) => {
|
|
3285
|
+
const sender = normalizeIMessageHandle((message.sender ?? "").trim());
|
|
3286
|
+
const destination = normalizeIMessageHandle((message.destination_caller_id ?? "").trim());
|
|
3287
|
+
const actorHandle = (message.is_from_me !== true && Boolean(sender) && sender === destination ? "" : sender) || (message.is_from_me === true ? destination : "");
|
|
3288
|
+
return actorHandle ? buildIMessageApprovalConversationKeyForInbound({
|
|
3289
|
+
chatGuid: message.chat_guid,
|
|
3290
|
+
chatIdentifier: message.chat_identifier,
|
|
3291
|
+
chatId: message.chat_id,
|
|
3292
|
+
isGroup: message.is_group,
|
|
3293
|
+
actorHandle
|
|
3294
|
+
}) : null;
|
|
3295
|
+
};
|
|
3296
|
+
const ingress = createIMessageDurableIngress({
|
|
3297
|
+
accountId: accountInfo.accountId,
|
|
3298
|
+
runtime,
|
|
3299
|
+
dispatchPriority: async (message, lifecycle, receivedAt, provenance) => {
|
|
3300
|
+
const bodyText = (message.text ?? "").trim();
|
|
3301
|
+
const isApprovalCommand = /^\/approve(?:@[^\s]+)?(?:\s|$)/i.test(bodyText);
|
|
3302
|
+
if (!(isApprovalCommand || message.poll?.kind === "vote" || Boolean(resolveIMessageReactionContext(message, bodyText)))) return;
|
|
3303
|
+
if (suppressStaleIngress(message, receivedAt, provenance)) return { kind: "completed" };
|
|
3304
|
+
const repairedMessage = await repairMessageConversationAnchor(message);
|
|
3305
|
+
if (!repairedMessage) return { kind: "completed" };
|
|
3306
|
+
if (isApprovalCommand) {
|
|
3307
|
+
await handleMessageNowInner(repairedMessage);
|
|
3308
|
+
return { kind: "completed" };
|
|
3309
|
+
}
|
|
3310
|
+
const conversation = resolveApprovalControlConversation(repairedMessage);
|
|
3311
|
+
while (true) {
|
|
3312
|
+
if (await maybeHandleApprovalControl(repairedMessage)) return { kind: "completed" };
|
|
3313
|
+
if (!conversation) return;
|
|
3314
|
+
if (!await iMessageApprovalControlBindings.wait({
|
|
3315
|
+
accountId: accountInfo.accountId,
|
|
3316
|
+
conversation,
|
|
3317
|
+
abortSignal: lifecycle.abortSignal
|
|
3318
|
+
})) return await maybeHandleApprovalControl(repairedMessage) ? { kind: "completed" } : void 0;
|
|
3319
|
+
}
|
|
3320
|
+
},
|
|
3321
|
+
dispatch: async (message, ingressLifecycle, receivedAt, provenance) => {
|
|
3322
|
+
if (suppressStaleIngress(message, receivedAt, provenance)) return { kind: "completed" };
|
|
3323
|
+
const repairedMessage = await repairMessageConversationAnchor(message);
|
|
3324
|
+
if (!repairedMessage) return { kind: "completed" };
|
|
3325
|
+
if (await maybeHandleApprovalControl(repairedMessage)) return { kind: "completed" };
|
|
3326
|
+
await inboundDebouncer.enqueue({
|
|
3327
|
+
message: repairedMessage,
|
|
3328
|
+
ingressLifecycle
|
|
3329
|
+
});
|
|
3330
|
+
return { kind: "deferred" };
|
|
3331
|
+
},
|
|
3332
|
+
onDurableEnqueue: async (facts) => {
|
|
3333
|
+
advanceRecoveryCursorAfterDurableEnqueue(facts.rowid);
|
|
3334
|
+
await maybeAdvanceLiveCatchupCursor({
|
|
3335
|
+
id: facts.rowid,
|
|
3336
|
+
created_at: facts.createdAt
|
|
3337
|
+
});
|
|
3338
|
+
},
|
|
3339
|
+
onDurableEnqueueFailure: (rowid) => {
|
|
3340
|
+
holdRecoveryCursorBeforeFailedEnqueue(rowid);
|
|
3341
|
+
}
|
|
3342
|
+
});
|
|
3343
|
+
await waitForTransportReady({
|
|
3344
|
+
label: "imsg rpc",
|
|
3345
|
+
timeoutMs: 3e4,
|
|
3346
|
+
logAfterMs: 1e4,
|
|
3347
|
+
logIntervalMs: 1e4,
|
|
3348
|
+
pollIntervalMs: 500,
|
|
3349
|
+
abortSignal: opts.abortSignal,
|
|
3350
|
+
runtime,
|
|
3351
|
+
check: async () => {
|
|
3352
|
+
const probe = await probeIMessage(probeTimeoutMs, {
|
|
3353
|
+
cliPath,
|
|
3354
|
+
dbPath,
|
|
3355
|
+
remoteHost,
|
|
3356
|
+
runtime
|
|
3357
|
+
});
|
|
3358
|
+
if (probe.ok) return { ok: true };
|
|
3359
|
+
if (probe.fatal) throw new Error(probe.error ?? "imsg rpc unavailable");
|
|
3360
|
+
return {
|
|
3361
|
+
ok: false,
|
|
3362
|
+
error: probe.error ?? "unreachable"
|
|
3363
|
+
};
|
|
3364
|
+
}
|
|
3365
|
+
});
|
|
3366
|
+
if (opts.abortSignal?.aborted) return;
|
|
3367
|
+
const abort = opts.abortSignal;
|
|
3368
|
+
const createWatchClient = async () => await createIMessageRpcClient({
|
|
3369
|
+
cliPath,
|
|
3370
|
+
dbPath,
|
|
3371
|
+
remoteHost,
|
|
3372
|
+
runtime,
|
|
3373
|
+
onNotification: (msg) => {
|
|
3374
|
+
if (msg.method === "message") ingress.receive(msg.params).catch((err) => {
|
|
3375
|
+
runtime.error?.(`imessage: durable admission failed: ${String(err)}`);
|
|
3376
|
+
});
|
|
3377
|
+
else if (msg.method === "error") runtime.error?.(`imessage: watch error ${JSON.stringify(sanitizeIMessageWatchErrorPayload(msg.params))}`);
|
|
3378
|
+
}
|
|
3379
|
+
});
|
|
3380
|
+
const requireWatchClient = (watchClient) => {
|
|
3381
|
+
if (!watchClient) throw new Error("imessage monitor client not initialized");
|
|
3382
|
+
return watchClient;
|
|
3383
|
+
};
|
|
3384
|
+
for (let attempt = 1; attempt <= WATCH_SUBSCRIBE_MAX_ATTEMPTS; attempt++) {
|
|
3385
|
+
if (abort?.aborted) return;
|
|
3386
|
+
let attemptClient;
|
|
3387
|
+
let attemptDetachAbortHandler = () => {};
|
|
3388
|
+
let keepAttemptClient = false;
|
|
3389
|
+
try {
|
|
3390
|
+
attemptClient = requireWatchClient(await createWatchClient());
|
|
3391
|
+
let attemptSubscriptionId = null;
|
|
3392
|
+
attemptDetachAbortHandler = attachIMessageMonitorAbortHandler({
|
|
3393
|
+
abortSignal: abort,
|
|
3394
|
+
client: attemptClient,
|
|
3395
|
+
getSubscriptionId: () => attemptSubscriptionId
|
|
3396
|
+
});
|
|
3397
|
+
attemptSubscriptionId = (await attemptClient.request("watch.subscribe", {
|
|
3398
|
+
attachments: includeAttachments,
|
|
3399
|
+
include_reactions: true,
|
|
3400
|
+
...watchSinceRowid !== null ? { since_rowid: watchSinceRowid } : {}
|
|
3401
|
+
}, { timeoutMs: probeTimeoutMs }))?.subscription ?? null;
|
|
3402
|
+
opts.statusSink?.(channelReadyPatch());
|
|
3403
|
+
client = attemptClient;
|
|
3404
|
+
detachAbortHandler = attemptDetachAbortHandler;
|
|
3405
|
+
keepAttemptClient = true;
|
|
3406
|
+
break;
|
|
3407
|
+
} catch (err) {
|
|
3408
|
+
if (abort?.aborted) return;
|
|
3409
|
+
const retriable = isRetriableWatchSubscribeStartupError(err);
|
|
3410
|
+
if (!(attempt < WATCH_SUBSCRIBE_MAX_ATTEMPTS && retriable)) {
|
|
3411
|
+
opts.statusSink?.({
|
|
3412
|
+
connected: false,
|
|
3413
|
+
lifecycle: retriable ? "recovering" : "blocked",
|
|
3414
|
+
terminalDisconnect: retriable ? void 0 : true,
|
|
3415
|
+
lastError: String(err)
|
|
3416
|
+
});
|
|
3417
|
+
runtime.error?.(danger(`imessage: monitor failed: ${describeIMessageWatchSubscribeStartupFailure({
|
|
3418
|
+
accountId: accountInfo.accountId,
|
|
3419
|
+
attempt,
|
|
3420
|
+
maxAttempts: WATCH_SUBSCRIBE_MAX_ATTEMPTS,
|
|
3421
|
+
cliPath,
|
|
3422
|
+
dbPath,
|
|
3423
|
+
remoteHost,
|
|
3424
|
+
includeAttachments,
|
|
3425
|
+
probeTimeoutMs,
|
|
3426
|
+
watchSinceRowid,
|
|
3427
|
+
error: err
|
|
3428
|
+
})}`));
|
|
3429
|
+
throw err;
|
|
3430
|
+
}
|
|
3431
|
+
opts.statusSink?.({
|
|
3432
|
+
connected: false,
|
|
3433
|
+
lifecycle: "recovering",
|
|
3434
|
+
lastError: String(err)
|
|
3435
|
+
});
|
|
3436
|
+
runtime.log?.(warn(describeIMessageWatchSubscribeStartupFailure({
|
|
3437
|
+
accountId: accountInfo.accountId,
|
|
3438
|
+
attempt,
|
|
3439
|
+
maxAttempts: WATCH_SUBSCRIBE_MAX_ATTEMPTS,
|
|
3440
|
+
cliPath,
|
|
3441
|
+
dbPath,
|
|
3442
|
+
remoteHost,
|
|
3443
|
+
includeAttachments,
|
|
3444
|
+
probeTimeoutMs,
|
|
3445
|
+
watchSinceRowid,
|
|
3446
|
+
error: err,
|
|
3447
|
+
retryDelayMs: WATCH_SUBSCRIBE_RETRY_DELAY_MS
|
|
3448
|
+
})));
|
|
3449
|
+
attemptDetachAbortHandler();
|
|
3450
|
+
attemptDetachAbortHandler = () => {};
|
|
3451
|
+
await attemptClient?.stop();
|
|
3452
|
+
attemptClient = void 0;
|
|
3453
|
+
await waitForWatchSubscribeRetryDelay({
|
|
3454
|
+
ms: WATCH_SUBSCRIBE_RETRY_DELAY_MS,
|
|
3455
|
+
abortSignal: abort
|
|
3456
|
+
});
|
|
3457
|
+
if (abort?.aborted) return;
|
|
3458
|
+
} finally {
|
|
3459
|
+
if (!keepAttemptClient) {
|
|
3460
|
+
attemptDetachAbortHandler();
|
|
3461
|
+
await attemptClient?.stop();
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
}
|
|
3465
|
+
const activeClient = client;
|
|
3466
|
+
if (!activeClient) return;
|
|
3467
|
+
ingress.start();
|
|
3468
|
+
const approvalContextLease = opts.channelRuntime ? registerChannelRuntimeContext({
|
|
3469
|
+
channelRuntime: opts.channelRuntime,
|
|
3470
|
+
channelId: "imessage",
|
|
3471
|
+
accountId: accountInfo.accountId,
|
|
3472
|
+
capability: CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY,
|
|
3473
|
+
context: { accountId: accountInfo.accountId },
|
|
3474
|
+
abortSignal: abort
|
|
3475
|
+
}) : void 0;
|
|
3476
|
+
let approvalReactionPollInFlight = false;
|
|
3477
|
+
const pollApprovalReactions = async (allowRecentChatDiscovery = false) => {
|
|
3478
|
+
if (approvalReactionPollInFlight) return;
|
|
3479
|
+
approvalReactionPollInFlight = true;
|
|
3480
|
+
try {
|
|
3481
|
+
await pollPendingIMessageApprovalReactions({
|
|
3482
|
+
client: activeClient,
|
|
3483
|
+
cfg,
|
|
3484
|
+
accountId: accountInfo.accountId,
|
|
3485
|
+
allowRecentChatDiscovery,
|
|
3486
|
+
gatewayRuntime: approvalGatewayRuntime,
|
|
3487
|
+
logVerboseMessage: logVerbose
|
|
3488
|
+
});
|
|
3489
|
+
} catch (err) {
|
|
3490
|
+
logVerbose(`imessage: approval reaction poll failed: ${String(err)}`);
|
|
3491
|
+
} finally {
|
|
3492
|
+
approvalReactionPollInFlight = false;
|
|
3493
|
+
}
|
|
3494
|
+
};
|
|
3495
|
+
const approvalReactionPollTimer = setInterval(() => {
|
|
3496
|
+
pollApprovalReactions();
|
|
3497
|
+
}, APPROVAL_REACTION_POLL_INTERVAL_MS);
|
|
3498
|
+
const approvalReactionDiscoveryTimer = setInterval(() => {
|
|
3499
|
+
pollApprovalReactions(true);
|
|
3500
|
+
}, APPROVAL_REACTION_DISCOVERY_INTERVAL_MS);
|
|
3501
|
+
pollApprovalReactions(true);
|
|
3502
|
+
if (catchupCfg.enabled && !abort?.aborted) {
|
|
3503
|
+
startupCatchupInProgress = true;
|
|
3504
|
+
try {
|
|
3505
|
+
const catchupSummary = await runIMessageCatchup({
|
|
3506
|
+
client: activeClient,
|
|
3507
|
+
accountId: accountInfo.accountId,
|
|
3508
|
+
config: catchupCfg,
|
|
3509
|
+
includeAttachments,
|
|
3510
|
+
dispatchPayload: async (_message, rawEnvelope) => {
|
|
3511
|
+
await ingress.receive(rawEnvelope, { catchup: true });
|
|
3512
|
+
},
|
|
3513
|
+
observeSkippedFromMePayload: (message) => {
|
|
3514
|
+
const { bodyText } = resolveIMessageInboundBodyText(message);
|
|
3515
|
+
rememberIMessageSkippedFromMeForSelfChatDedupe({
|
|
3516
|
+
accountId: accountInfo.accountId,
|
|
3517
|
+
message,
|
|
3518
|
+
bodyText,
|
|
3519
|
+
selfChatCache
|
|
3520
|
+
});
|
|
3521
|
+
},
|
|
3522
|
+
runtime
|
|
3523
|
+
});
|
|
3524
|
+
liveCatchupCursorAdvanceEnabled = catchupSummary.querySucceeded && catchupSummary.fullyCaughtUp;
|
|
3525
|
+
if (liveCatchupCursorAdvanceEnabled) await flushPendingLiveCatchupCursorAdvances();
|
|
3526
|
+
else pendingLiveCatchupCursorAdvances.length = 0;
|
|
3527
|
+
} catch (err) {
|
|
3528
|
+
pendingLiveCatchupCursorAdvances.length = 0;
|
|
3529
|
+
runtime.error?.(`imessage catchup: pass failed: ${String(err)}`);
|
|
3530
|
+
} finally {
|
|
3531
|
+
startupCatchupInProgress = false;
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
try {
|
|
3535
|
+
await activeClient.waitForClose();
|
|
3536
|
+
} catch (err) {
|
|
3537
|
+
if (abort?.aborted) return;
|
|
3538
|
+
runtime.error?.(danger(`imessage: monitor failed: ${String(err)}`));
|
|
3539
|
+
throw err;
|
|
3540
|
+
} finally {
|
|
3541
|
+
clearInterval(approvalReactionPollTimer);
|
|
3542
|
+
clearInterval(approvalReactionDiscoveryTimer);
|
|
3543
|
+
approvalContextLease?.dispose();
|
|
3544
|
+
detachAbortHandler();
|
|
3545
|
+
await activeClient.stop();
|
|
3546
|
+
await ingress.stop();
|
|
3547
|
+
}
|
|
3548
|
+
}
|
|
3549
|
+
//#endregion
|
|
3550
|
+
export { monitorIMessageProvider as t };
|