@openclaw/feishu 2026.10.2 → 2026.10.5-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/dist/.setup/{app-registration-BB6TubaW.mjs → app-registration-DQOq5urV.mjs} +13 -32
- package/dist/.setup/{channel-DZakdZ3r.mjs → channel-CjGGyrdx.mjs} +87 -174
- package/dist/.setup/{channel.runtime-rXFuQXLL.mjs → channel.runtime-SaC_uTPM.mjs} +57 -74
- package/dist/.setup/{chat-mTBvMMvx.mjs → chat-fC3dvxFs.mjs} +16 -28
- package/dist/.setup/{client-CcxmEkoy.mjs → client-wwr8PGPH.mjs} +24 -30
- package/dist/.setup/{conversation-id-C1ofUfU8.mjs → conversation-id-D00i9uy5.mjs} +5 -10
- package/dist/.setup/{doctor-contract-DyOo8NvC.mjs → doctor-contract-oIpUWtNO.mjs} +8 -15
- package/dist/.setup/{monitor-CXaFHMmi.mjs → monitor-Yt__BUki.mjs} +33 -54
- package/dist/.setup/{monitor.account-cJ8gavqv.mjs → monitor.account-CVz16781.mjs} +359 -658
- package/dist/.setup/{probe-BjSykXB8.mjs → probe-DXnFxq5j.mjs} +14 -17
- package/dist/.setup/{reply-delivery-result-laBNOmBu.mjs → reply-delivery-result-iCCrdxE1.mjs} +153 -181
- package/dist/.setup/{session-conversation-C53IEUWt.mjs → session-conversation-BSBNK5Mq.mjs} +1 -1
- package/dist/.setup/{setup-api-fZcYXGxe.mjs → setup-api-B_LFQQ-Q.mjs} +1 -1
- package/dist/.setup/{subagent-hooks-C8Z_x3KJ.mjs → subagent-hooks-9Pc1-k37.mjs} +7 -17
- package/dist/.setup/{thread-bindings-jW2x5VuN.mjs → thread-bindings-DdNLxoL3.mjs} +21 -44
- package/dist/api.js +218 -326
- package/dist/channel-plugin-api.js +1 -1
- package/dist/contract-api.js +1 -1
- package/dist/doctor-contract-api.js +1 -1
- package/dist/session-binding-contract-api.js +1 -1
- package/dist/session-key-api.js +1 -1
- package/dist/setup-api.js +1 -1
- package/dist/setup-entry.js +1 -1
- package/dist/subagent-hooks-api.js +1 -1
- package/node_modules/@openclaw/fs-safe/CHANGELOG.md +35 -0
- package/node_modules/@openclaw/fs-safe/README.md +1 -1
- package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/archive-durability.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +4 -4
- package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
- package/node_modules/@openclaw/fs-safe/dist/archive-read.js +5 -4
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.d.ts +1 -1
- package/node_modules/@openclaw/fs-safe/dist/archive-staging.js +22 -38
- package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.d.ts +17 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +117 -0
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.d.ts +8 -5
- package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +27 -50
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.d.ts +3 -0
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.js +57 -11
- package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.js +5 -5
- package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +52 -5
- package/node_modules/@openclaw/fs-safe/dist/guest.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +1 -0
- package/node_modules/@openclaw/fs-safe/dist/native-operations.d.ts +0 -1
- package/node_modules/@openclaw/fs-safe/dist/native-operations.js +22 -26
- package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +5 -1
- package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +4 -1
- package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +2 -1
- package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +6 -1
- package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +2 -2
- package/node_modules/@openclaw/fs-safe/dist/publish-file.js +34 -7
- package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.js +1 -4
- package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +6 -0
- package/node_modules/@openclaw/fs-safe/dist/root-create-input.d.ts +15 -1
- package/node_modules/@openclaw/fs-safe/dist/root-create-input.js +4 -0
- package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list.d.ts +0 -1
- package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +6 -12
- package/node_modules/@openclaw/fs-safe/dist/root-impl.js +15 -15
- package/node_modules/@openclaw/fs-safe/dist/root-paths.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/root-walk.js +4 -4
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.d.ts +10 -1
- package/node_modules/@openclaw/fs-safe/dist/root-write-verification.js +20 -0
- package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.js +19 -7
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.js +25 -3
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-admission.d.ts +2 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.d.ts +14 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +187 -0
- package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.js +15 -1
- package/node_modules/@openclaw/fs-safe/dist/temp-directory-diagnostics.d.ts +10 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-directory-diagnostics.js +29 -0
- package/node_modules/@openclaw/fs-safe/dist/temp-target.js +1 -1
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-admission.js +6 -6
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.d.ts +4 -4
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +17 -16
- package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.js +20 -28
- package/node_modules/@openclaw/fs-safe/dist/walk.js +2 -13
- package/node_modules/@openclaw/fs-safe/dist/watch-native.d.ts +2 -2
- package/node_modules/@openclaw/fs-safe/dist/watch-native.js +3 -1
- package/node_modules/@openclaw/fs-safe/dist/watch-rescan.js +3 -9
- package/node_modules/@openclaw/fs-safe/dist/watch.js +2 -3
- package/node_modules/@openclaw/fs-safe/docs/advanced.md +1 -1
- package/node_modules/@openclaw/fs-safe/docs/archive.md +3 -0
- package/node_modules/@openclaw/fs-safe/docs/atomic.md +11 -3
- package/node_modules/@openclaw/fs-safe/docs/contributing.md +1 -1
- package/node_modules/@openclaw/fs-safe/docs/copy.md +48 -0
- package/node_modules/@openclaw/fs-safe/docs/guest.md +21 -4
- package/node_modules/@openclaw/fs-safe/docs/path-scope.md +4 -0
- package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +46 -8
- package/node_modules/@openclaw/fs-safe/docs/temp.md +12 -0
- package/node_modules/@openclaw/fs-safe/docs/watch.md +3 -2
- package/node_modules/@openclaw/fs-safe/package.json +15 -15
- package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
- package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
- package/node_modules/follow-redirects/index.js +10 -1
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/mdast-util-to-markdown/index.d.ts +2 -0
- package/node_modules/mdast-util-to-markdown/lib/configure.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/configure.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/configure.js +19 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/blockquote.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/blockquote.js +12 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/break.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/break.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/break.js +16 -5
- package/node_modules/mdast-util-to-markdown/lib/handle/code.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/code.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/code.js +13 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/definition.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/definition.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/definition.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/emphasis.d.ts +30 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/emphasis.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/emphasis.js +39 -41
- package/node_modules/mdast-util-to-markdown/lib/handle/heading.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/heading.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/heading.js +11 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/html.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/html.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/html.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/image-reference.d.ts +10 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/image-reference.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/image-reference.js +17 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/image.d.ts +10 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/image.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/image.js +10 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts +9 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/inline-code.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/inline-code.js +14 -4
- package/node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts +10 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/link-reference.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/link-reference.js +17 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/link.d.ts +13 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/link.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/link.js +24 -9
- package/node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/list-item.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/list-item.js +12 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/list.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/list.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/list.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/paragraph.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/paragraph.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/root.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/root.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/root.js +13 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts +30 -2
- package/node_modules/mdast-util-to-markdown/lib/handle/strong.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/strong.js +39 -41
- package/node_modules/mdast-util-to-markdown/lib/handle/text.d.ts +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/text.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/text.js +7 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts +6 -0
- package/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js +6 -0
- package/node_modules/mdast-util-to-markdown/lib/index.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/index.js +34 -8
- package/node_modules/mdast-util-to-markdown/lib/join.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/join.js +18 -1
- package/node_modules/mdast-util-to-markdown/lib/types.d.ts +50 -30
- package/node_modules/mdast-util-to-markdown/lib/unsafe.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/unsafe.js +15 -1
- package/node_modules/mdast-util-to-markdown/lib/util/character.d.ts +23 -0
- package/node_modules/mdast-util-to-markdown/lib/util/character.d.ts.map +1 -0
- package/node_modules/mdast-util-to-markdown/lib/util/character.js +32 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-bullet.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-emphasis.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-emphasis.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-emphasis.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-fence.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-fence.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-fence.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-quote.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-quote.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-quote.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-rule.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-strong.d.ts +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/check-strong.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/check-strong.js +4 -0
- package/node_modules/mdast-util-to-markdown/lib/util/compile-pattern.js +3 -1
- package/node_modules/mdast-util-to-markdown/lib/util/container-flow.d.ts +2 -0
- package/node_modules/mdast-util-to-markdown/lib/util/container-flow.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/container-flow.js +9 -0
- package/node_modules/mdast-util-to-markdown/lib/util/container-phrasing.d.ts +95 -4
- package/node_modules/mdast-util-to-markdown/lib/util/container-phrasing.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/container-phrasing.js +636 -57
- package/node_modules/mdast-util-to-markdown/lib/util/encode-info.d.ts +2 -2
- package/node_modules/mdast-util-to-markdown/lib/util/encode-info.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/encode-info.js +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.js +12 -7
- package/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js +7 -2
- package/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js +20 -15
- package/node_modules/mdast-util-to-markdown/lib/util/html-kind.d.ts +31 -0
- package/node_modules/mdast-util-to-markdown/lib/util/html-kind.d.ts.map +1 -0
- package/node_modules/mdast-util-to-markdown/lib/util/html-kind.js +63 -0
- package/node_modules/mdast-util-to-markdown/lib/util/indent-lines.js +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.d.ts +5 -0
- package/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.js +11 -0
- package/node_modules/mdast-util-to-markdown/lib/util/safe.d.ts +2 -2
- package/node_modules/mdast-util-to-markdown/lib/util/safe.d.ts.map +1 -1
- package/node_modules/mdast-util-to-markdown/lib/util/safe.js +71 -7
- package/node_modules/mdast-util-to-markdown/package.json +13 -57
- package/node_modules/mdast-util-to-markdown/readme.md +139 -84
- package/node_modules/micromark/dev/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/compile.js +14 -4
- package/node_modules/micromark/dev/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/create-tokenizer.js +7 -6
- package/node_modules/micromark/dev/lib/initialize/document.js +25 -21
- package/node_modules/micromark/dev/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/initialize/text.js +10 -6
- package/node_modules/micromark/dev/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/dev/lib/preprocess.js +19 -21
- package/node_modules/micromark/lib/compile.d.ts.map +1 -1
- package/node_modules/micromark/lib/compile.js +37 -29
- package/node_modules/micromark/lib/create-tokenizer.d.ts.map +1 -1
- package/node_modules/micromark/lib/create-tokenizer.js +37 -35
- package/node_modules/micromark/lib/initialize/document.js +21 -13
- package/node_modules/micromark/lib/initialize/text.d.ts.map +1 -1
- package/node_modules/micromark/lib/initialize/text.js +7 -3
- package/node_modules/micromark/lib/preprocess.d.ts.map +1 -1
- package/node_modules/micromark/lib/preprocess.js +16 -19
- package/node_modules/micromark/package.json +2 -15
- package/node_modules/micromark-core-commonmark/dev/lib/attention.js +18 -24
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/code-fenced.js +1 -43
- package/node_modules/micromark-core-commonmark/dev/lib/code-indented.js +19 -43
- package/node_modules/micromark-core-commonmark/dev/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/html-flow.js +2 -53
- package/node_modules/micromark-core-commonmark/dev/lib/label-end.js +14 -12
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-image.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/label-start-link.js +14 -5
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/dev/lib/partial-non-lazy-continuation.js +67 -0
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/dev/lib/setext-underline.js +8 -5
- package/node_modules/micromark-core-commonmark/lib/attention.js +14 -24
- package/node_modules/micromark-core-commonmark/lib/code-fenced.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/code-fenced.js +1 -39
- package/node_modules/micromark-core-commonmark/lib/code-indented.js +11 -29
- package/node_modules/micromark-core-commonmark/lib/heading-atx.js +2 -6
- package/node_modules/micromark-core-commonmark/lib/html-flow.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/html-flow.js +2 -51
- package/node_modules/micromark-core-commonmark/lib/label-end.js +11 -10
- package/node_modules/micromark-core-commonmark/lib/label-start-image.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-image.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/label-start-link.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/label-start-link.js +11 -3
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts +4 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.d.ts.map +1 -0
- package/node_modules/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
- package/node_modules/micromark-core-commonmark/lib/setext-underline.d.ts.map +1 -1
- package/node_modules/micromark-core-commonmark/lib/setext-underline.js +7 -5
- package/node_modules/micromark-core-commonmark/package.json +4 -16
- package/node_modules/micromark-factory-space/dev/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/dev/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/dev/index.js +58 -3
- package/node_modules/micromark-factory-space/index.d.ts +24 -1
- package/node_modules/micromark-factory-space/index.d.ts.map +1 -1
- package/node_modules/micromark-factory-space/index.js +55 -3
- package/node_modules/micromark-factory-space/package.json +1 -10
- package/node_modules/micromark-factory-space/readme.md +25 -25
- package/node_modules/micromark-util-edit-map/dev/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/dev/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/dev/index.js +237 -0
- package/node_modules/micromark-util-edit-map/index.d.ts +78 -0
- package/node_modules/micromark-util-edit-map/index.d.ts.map +1 -0
- package/node_modules/micromark-util-edit-map/index.js +225 -0
- package/node_modules/micromark-util-edit-map/license +22 -0
- package/node_modules/micromark-util-edit-map/package.json +48 -0
- package/node_modules/micromark-util-edit-map/readme.md +234 -0
- package/node_modules/micromark-util-types/index.d.ts +6 -3
- package/node_modules/micromark-util-types/package.json +2 -36
- package/node_modules/ws/lib/websocket.js +17 -3
- package/node_modules/ws/package.json +1 -1
- package/package.json +5 -5
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-arbitration.d.ts +0 -17
- package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-arbitration.js +0 -66
- package/node_modules/@openclaw/fs-safe/dist/publish-file-native.d.ts +0 -4
- package/node_modules/@openclaw/fs-safe/dist/publish-file-native.js +0 -35
- package/node_modules/@openclaw/fs-safe/dist/root-move-preflight.d.ts +0 -7
- package/node_modules/@openclaw/fs-safe/dist/root-move-preflight.js +0 -16
- package/node_modules/mdast-util-to-markdown/lib/util/emphasis-strong-marker.d.ts +0 -7
- package/node_modules/mdast-util-to-markdown/lib/util/emphasis-strong-marker.d.ts.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { c as normalizeFeishuExternalKey, g as resolveFeishuRuntimeAccount, h as resolveFeishuAccount, s as normalizeFeishuWebhookPath } from "./doctor-contract-
|
|
2
|
-
import { o as resolveConfiguredFeishuGroupSessionScope, t as buildFeishuConversationId, u as resolveReceiveIdType } from "./conversation-id-
|
|
3
|
-
import { c as resolveFeishuLegacyWebhookListener, l as gateway_config_runtime_exports, s as describeFeishuWebhookPathConflict } from "./channel-
|
|
4
|
-
import { A as sendMessageFeishu, At as
|
|
1
|
+
import { c as normalizeFeishuExternalKey, g as resolveFeishuRuntimeAccount, h as resolveFeishuAccount, s as normalizeFeishuWebhookPath } from "./doctor-contract-oIpUWtNO.mjs";
|
|
2
|
+
import { o as resolveConfiguredFeishuGroupSessionScope, t as buildFeishuConversationId, u as resolveReceiveIdType } from "./conversation-id-D00i9uy5.mjs";
|
|
3
|
+
import { c as resolveFeishuLegacyWebhookListener, l as gateway_config_runtime_exports, s as describeFeishuWebhookPathConflict } from "./channel-CjGGyrdx.mjs";
|
|
4
|
+
import { A as sendMessageFeishu, At as resolveFeishuGroupConversationIngressAccess, B as parseInteractiveCardContent, D as getMessageFeishu, Dt as normalizeFeishuAllowEntry, Et as hasExplicitFeishuGroupConfig, F as isFeishuBroadcastMention, Ft as resolveFeishuChatType, I as isMentionForwardRequest, K as deliverCommentThreadText, L as normalizeMentions, Lt as createFeishuCardInteractionEnvelope, N as formatFeishuMediaContent, Nt as resolveFeishuReplyPolicy, O as listFeishuThreadMessages, Ot as resolveFeishuDmIngressAccess, P as extractMentionTargets, Pt as normalizeFeishuChatType, R as isFeishuGroupChatType, Rt as decodeFeishuCardAction, S as sendMediaFeishu, T as chunkFeishuCardMarkdown, U as buildFeishuMediaFallbackText, V as parsePostContent, W as resolveFeishuIdentityEmoji, a as shouldSendNoVisibleReplyFallback, at as parseCommentContentElements, b as withinCardTableLimit, ct as normalizeCommentFileType, d as consumeFeishuPresentationFallbackMarker, dt as resolveFeishuCardTemplate, gt as shouldUseFeishuCard, i as noVisibleFeishuReplyDelivery, j as sendStructuredCardFeishu, jt as resolveFeishuGroupSenderActivationIngressAccess, k as sendCardFeishu, kt as resolveFeishuGroupConfig, mt as materializeFeishuPostMarkdownSoftBreaks, n as createFeishuReplyDeliveryResult, nt as encodeQuery, ot as requestFeishuApi, pt as chunkFeishuPostMarkdown, r as mergeFeishuReplyDeliveryResults, rt as extractReplyText, st as buildFeishuCommentTarget, t as createFeishuPartialReplyDeliveryError, tt as createCommentTypingReactionLifecycle, u as buildFeishuPresentationFallback, v as renderFeishuReplyPayload, w as shouldSuppressFeishuTextForVoiceMedia, x as saveMessageResourceFeishu, y as resolveFeishuRichReply, z as normalizeFeishuEventChatType } from "./reply-delivery-result-iCCrdxE1.mjs";
|
|
5
5
|
import { t as getFeishuRuntime } from "./runtime-C5JxBWZp.mjs";
|
|
6
|
-
import { a as getFeishuUserAgent, f as resolveConfiguredHttpTimeoutMs, i as createFeishuWSClient, n as createEventDispatcher, r as createFeishuClient } from "./client-
|
|
7
|
-
import { r as getChatInfo } from "./chat-
|
|
8
|
-
import { t as createFeishuThreadBindingManager } from "./thread-bindings-
|
|
6
|
+
import { a as getFeishuUserAgent, f as resolveConfiguredHttpTimeoutMs, i as createFeishuWSClient, n as createEventDispatcher, r as createFeishuClient } from "./client-wwr8PGPH.mjs";
|
|
7
|
+
import { r as getChatInfo } from "./chat-fC3dvxFs.mjs";
|
|
8
|
+
import { t as createFeishuThreadBindingManager } from "./thread-bindings-DdNLxoL3.mjs";
|
|
9
9
|
import { evaluateSupplementalContextVisibility, normalizeAgentId as normalizeAgentId$1, resolveChannelContextVisibilityMode } from "../runtime-api.js";
|
|
10
10
|
import { t as readFeishuJsonResponse } from "./json-response-DXajw_FU.mjs";
|
|
11
|
-
import { a as waitForAbortableDelay, i as raceWithTimeoutAndAbort } from "./probe-
|
|
12
|
-
import { t as fetchBotIdentityForMonitor } from "./monitor-
|
|
11
|
+
import { a as waitForAbortableDelay, i as raceWithTimeoutAndAbort } from "./probe-DXnFxq5j.mjs";
|
|
12
|
+
import { t as fetchBotIdentityForMonitor } from "./monitor-Yt__BUki.mjs";
|
|
13
13
|
import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
14
14
|
import { DEFAULT_INGRESS_ADOPTION_STALL_MS, bindIngressLifecycleToReplyOptions, createChannelIngressError, createChannelIngressMonitor, createChannelMessageReplyPipeline, createReplyPrefixContext, formatChannelProgressDraftLineForEntry, resolveAgentOutboundIdentity, resolveChannelPreviewStreamMode, resolveChannelStreamingBlockEnabled, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
|
|
15
15
|
import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
|
|
@@ -33,7 +33,7 @@ import * as Lark from "@larksuiteoapi/node-sdk";
|
|
|
33
33
|
import { isRecord as isRecord$1 } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
|
|
34
34
|
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
35
35
|
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
|
|
36
|
-
import {
|
|
36
|
+
import { safeParseJson, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
37
37
|
import * as crypto$1 from "node:crypto";
|
|
38
38
|
import crypto, { createHash } from "node:crypto";
|
|
39
39
|
import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
|
|
@@ -285,38 +285,13 @@ function resolveFeishuGroupSession(params) {
|
|
|
285
285
|
feishuCfg
|
|
286
286
|
});
|
|
287
287
|
const topicScope = groupSessionScope === "group_topic" || groupSessionScope === "group_topic_sender" ? (chatType === "topic_group" ? normalizedThreadId ?? normalizedRootId : void 0) ?? normalizedRootId ?? normalizedThreadId ?? (replyInThread ? messageId : null) : null;
|
|
288
|
-
let peerId;
|
|
289
|
-
switch (groupSessionScope) {
|
|
290
|
-
case "group_sender":
|
|
291
|
-
peerId = buildFeishuConversationId({
|
|
292
|
-
chatId,
|
|
293
|
-
scope: "group_sender",
|
|
294
|
-
senderOpenId
|
|
295
|
-
});
|
|
296
|
-
break;
|
|
297
|
-
case "group_topic":
|
|
298
|
-
peerId = topicScope ? buildFeishuConversationId({
|
|
299
|
-
chatId,
|
|
300
|
-
scope: "group_topic",
|
|
301
|
-
topicId: topicScope
|
|
302
|
-
}) : chatId;
|
|
303
|
-
break;
|
|
304
|
-
case "group_topic_sender":
|
|
305
|
-
peerId = topicScope ? buildFeishuConversationId({
|
|
306
|
-
chatId,
|
|
307
|
-
scope: "group_topic_sender",
|
|
308
|
-
topicId: topicScope,
|
|
309
|
-
senderOpenId
|
|
310
|
-
}) : buildFeishuConversationId({
|
|
311
|
-
chatId,
|
|
312
|
-
scope: "group_sender",
|
|
313
|
-
senderOpenId
|
|
314
|
-
});
|
|
315
|
-
break;
|
|
316
|
-
default: peerId = chatId;
|
|
317
|
-
}
|
|
318
288
|
return {
|
|
319
|
-
peerId
|
|
289
|
+
peerId: groupSessionScope === "group_sender" || groupSessionScope === "group_topic_sender" || topicScope ? buildFeishuConversationId({
|
|
290
|
+
chatId,
|
|
291
|
+
scope: groupSessionScope,
|
|
292
|
+
senderOpenId,
|
|
293
|
+
topicId: topicScope ?? void 0
|
|
294
|
+
}) : chatId,
|
|
320
295
|
parentPeer: topicScope ? {
|
|
321
296
|
kind: "group",
|
|
322
297
|
id: chatId
|
|
@@ -367,44 +342,18 @@ function checkBotMentioned(event, botOpenId) {
|
|
|
367
342
|
if (event.message.message_type === "post") return parsePostContent(event.message.content).mentionedOpenIds.some((id) => id.trim().toLowerCase() !== "all" && id === botOpenId);
|
|
368
343
|
return false;
|
|
369
344
|
}
|
|
370
|
-
function normalizeMentions(text, mentions, botStripId) {
|
|
371
|
-
if (!mentions || mentions.length === 0) return text;
|
|
372
|
-
const escapeName = (value) => value.replace(/</g, "<").replace(/>/g, ">");
|
|
373
|
-
const replacements = /* @__PURE__ */ new Map();
|
|
374
|
-
for (const mention of mentions) {
|
|
375
|
-
const mentionId = mention.id.open_id;
|
|
376
|
-
const replacement = botStripId && mentionId === botStripId ? "" : mentionId ? `<at user_id="${mentionId}">${escapeName(mention.name)}</at>` : `@${mention.name}`;
|
|
377
|
-
replacements.set(mention.key, replacement);
|
|
378
|
-
}
|
|
379
|
-
const keys = [...replacements.keys()].toSorted((a, b) => b.length - a.length).map(escapeRegExp);
|
|
380
|
-
return text.replace(new RegExp(keys.join("|"), "g"), (key) => replacements.get(key)).trim();
|
|
381
|
-
}
|
|
382
345
|
function normalizeFeishuCommandProbeBody(text) {
|
|
383
346
|
return text.replace(/<at\b[^>]*>[^<]*<\/at>/giu, " ").replace(/(^|\s)@[^/\s]+(?=\s|$|\/)/gu, "$1").replace(/\s+/g, " ").trim();
|
|
384
347
|
}
|
|
385
|
-
function
|
|
348
|
+
function parseMediaResource(content, messageType) {
|
|
386
349
|
try {
|
|
387
350
|
const parsed = JSON.parse(content);
|
|
388
351
|
const imageKey = normalizeFeishuExternalKey(parsed.image_key);
|
|
389
352
|
const fileKey = normalizeFeishuExternalKey(parsed.file_key);
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
};
|
|
395
|
-
case "file":
|
|
396
|
-
case "audio": return {
|
|
397
|
-
fileKey,
|
|
398
|
-
fileName: parsed.file_name
|
|
399
|
-
};
|
|
400
|
-
case "video":
|
|
401
|
-
case "media": return {
|
|
402
|
-
fileKey,
|
|
403
|
-
imageKey,
|
|
404
|
-
fileName: parsed.file_name
|
|
405
|
-
};
|
|
406
|
-
default: return {};
|
|
407
|
-
}
|
|
353
|
+
return {
|
|
354
|
+
key: messageType === "image" ? imageKey : messageType === "video" || messageType === "media" ? fileKey || imageKey : fileKey,
|
|
355
|
+
fileName: parsed.file_name
|
|
356
|
+
};
|
|
408
357
|
} catch {
|
|
409
358
|
return {};
|
|
410
359
|
}
|
|
@@ -448,13 +397,12 @@ async function resolveFeishuMediaList(params) {
|
|
|
448
397
|
});
|
|
449
398
|
}
|
|
450
399
|
} else {
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
if (!fileKey) return [{ kind: resolveFeishuMediaKind(messageType) }];
|
|
400
|
+
const resource = parseMediaResource(content, messageType);
|
|
401
|
+
if (!resource.key) return [{ kind: resolveFeishuMediaKind(messageType) }];
|
|
454
402
|
resources.push({
|
|
455
|
-
key:
|
|
403
|
+
key: resource.key,
|
|
456
404
|
type: messageType === "image" ? "image" : "file",
|
|
457
|
-
fileName:
|
|
405
|
+
fileName: resource.fileName,
|
|
458
406
|
kind: resolveFeishuMediaKind(messageType),
|
|
459
407
|
label: `${messageType} media`
|
|
460
408
|
});
|
|
@@ -670,25 +618,12 @@ async function resolveFeishuBotName(params) {
|
|
|
670
618
|
}
|
|
671
619
|
//#endregion
|
|
672
620
|
//#region extensions/feishu/src/bot-sender-name.ts
|
|
673
|
-
const
|
|
674
|
-
const FEISHU_SCOPE_CORRECTIONS = { "contact:contact.base:readonly": "contact:user.base:readonly" };
|
|
621
|
+
const STALE_CONTACT_SCOPE = "contact:contact.base:readonly";
|
|
675
622
|
const FEISHU_USER_LOOKUP_UNAUTHORIZED_CODE = 41050;
|
|
676
623
|
const SENDER_NAME_TTL_MS = 6e5;
|
|
677
624
|
const SENDER_NAME_NEGATIVE_TTL_MS = 18e5;
|
|
678
625
|
const SENDER_NAME_CACHE_MAX_SIZE = 500;
|
|
679
626
|
const senderNameCache = /* @__PURE__ */ new Map();
|
|
680
|
-
function correctFeishuScopeInUrl(url) {
|
|
681
|
-
let corrected = url;
|
|
682
|
-
for (const [wrong, right] of Object.entries(FEISHU_SCOPE_CORRECTIONS)) {
|
|
683
|
-
corrected = corrected.replaceAll(encodeURIComponent(wrong), encodeURIComponent(right));
|
|
684
|
-
corrected = corrected.replaceAll(wrong, right);
|
|
685
|
-
}
|
|
686
|
-
return corrected;
|
|
687
|
-
}
|
|
688
|
-
function shouldSuppressPermissionErrorNotice(permissionError) {
|
|
689
|
-
const message = normalizeLowercaseStringOrEmpty(permissionError.message);
|
|
690
|
-
return IGNORED_PERMISSION_SCOPE_TOKENS.some((token) => message.includes(token));
|
|
691
|
-
}
|
|
692
627
|
function extractFeishuApiError(err) {
|
|
693
628
|
if (!err || typeof err !== "object") return null;
|
|
694
629
|
const data = err.response?.data;
|
|
@@ -706,7 +641,7 @@ function extractPermissionError(feishuErr) {
|
|
|
706
641
|
return {
|
|
707
642
|
code: feishuErr.code,
|
|
708
643
|
message: feishuErr.message,
|
|
709
|
-
grantUrl: urlMatch?.[0]
|
|
644
|
+
grantUrl: urlMatch?.[0]?.replaceAll(encodeURIComponent(STALE_CONTACT_SCOPE), encodeURIComponent("contact:user.base:readonly")).replaceAll(STALE_CONTACT_SCOPE, "contact:user.base:readonly")
|
|
710
645
|
};
|
|
711
646
|
}
|
|
712
647
|
function writeSenderNameCache(key, entry) {
|
|
@@ -715,9 +650,8 @@ function writeSenderNameCache(key, entry) {
|
|
|
715
650
|
pruneMapToMaxSize(senderNameCache, SENDER_NAME_CACHE_MAX_SIZE);
|
|
716
651
|
}
|
|
717
652
|
function resolveSenderLookupIdType(senderId) {
|
|
718
|
-
|
|
719
|
-
if (
|
|
720
|
-
if (trimmed.startsWith("on_")) return "union_id";
|
|
653
|
+
if (senderId.startsWith("ou_")) return "open_id";
|
|
654
|
+
if (senderId.startsWith("on_")) return "union_id";
|
|
721
655
|
return "user_id";
|
|
722
656
|
}
|
|
723
657
|
async function resolveFeishuSenderName(params) {
|
|
@@ -753,7 +687,7 @@ async function resolveFeishuSenderName(params) {
|
|
|
753
687
|
const feishuErr = extractFeishuApiError(err);
|
|
754
688
|
const permErr = extractPermissionError(feishuErr);
|
|
755
689
|
if (permErr) {
|
|
756
|
-
if (
|
|
690
|
+
if (normalizeLowercaseStringOrEmpty(permErr.message).includes(STALE_CONTACT_SCOPE)) {
|
|
757
691
|
log(`feishu: ignoring stale permission scope error: ${permErr.message}`);
|
|
758
692
|
return {};
|
|
759
693
|
}
|
|
@@ -885,20 +819,13 @@ async function warmupDedupFromPluginState(namespace, log) {
|
|
|
885
819
|
}
|
|
886
820
|
//#endregion
|
|
887
821
|
//#region extensions/feishu/src/dedupe-key.ts
|
|
888
|
-
function parseContentRecord(content) {
|
|
889
|
-
try {
|
|
890
|
-
return asNullableRecord(JSON.parse(content));
|
|
891
|
-
} catch {
|
|
892
|
-
return null;
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
822
|
function resolvePostMediaParts(content) {
|
|
896
823
|
const { attachments } = parsePostContent(content, { includeTopLevelFiles: false });
|
|
897
824
|
return ["image", "file"].flatMap((kind) => attachments.filter((attachment) => attachment.kind === kind).map((attachment) => `${kind}_key:${attachment.key}`));
|
|
898
825
|
}
|
|
899
826
|
function resolveMessageMediaParts(messageType, content) {
|
|
900
827
|
if (messageType === "post") return resolvePostMediaParts(content);
|
|
901
|
-
const parsed =
|
|
828
|
+
const parsed = asNullableRecord(safeParseJson(content));
|
|
902
829
|
if (!parsed) return [];
|
|
903
830
|
const imageKey = normalizeFeishuExternalKey(parsed.image_key);
|
|
904
831
|
const fileKey = normalizeFeishuExternalKey(parsed.file_key);
|
|
@@ -1161,7 +1088,7 @@ async function assertSuccessfulCardKitResponse(response, auditContext, action) {
|
|
|
1161
1088
|
const data = await readFeishuJsonResponse(response, auditContext);
|
|
1162
1089
|
if (data.code !== 0) throw new Error(`${action} failed: ${data.msg ?? "unknown error"} (code=${String(data.code)})`);
|
|
1163
1090
|
}
|
|
1164
|
-
async function getToken(creds
|
|
1091
|
+
async function getToken(creds) {
|
|
1165
1092
|
const key = `${creds.domain ?? "feishu"}|${creds.appId}`;
|
|
1166
1093
|
const cached = tokenCache.get(key);
|
|
1167
1094
|
const rawNow = Date.now();
|
|
@@ -1182,8 +1109,6 @@ async function getToken(creds, deps) {
|
|
|
1182
1109
|
app_secret: creds.appSecret
|
|
1183
1110
|
})
|
|
1184
1111
|
},
|
|
1185
|
-
fetchImpl: deps?.fetchImpl,
|
|
1186
|
-
lookupFn: deps?.lookupFn,
|
|
1187
1112
|
policy: { allowedHostnames: resolveAllowedHostnames(creds.domain) },
|
|
1188
1113
|
auditContext: "feishu.streaming-card.token",
|
|
1189
1114
|
timeoutMs: creds.httpTimeoutMs ?? 3e4
|
|
@@ -1225,7 +1150,7 @@ function mergeStreamingText(previousText, nextText) {
|
|
|
1225
1150
|
return `${previous}${next}`;
|
|
1226
1151
|
}
|
|
1227
1152
|
var FeishuStreamingSession = class {
|
|
1228
|
-
constructor(client, creds, log
|
|
1153
|
+
constructor(client, creds, log) {
|
|
1229
1154
|
this.state = null;
|
|
1230
1155
|
this.queue = Promise.resolve();
|
|
1231
1156
|
this.closed = false;
|
|
@@ -1236,8 +1161,6 @@ var FeishuStreamingSession = class {
|
|
|
1236
1161
|
this.client = client;
|
|
1237
1162
|
this.creds = creds;
|
|
1238
1163
|
this.log = log;
|
|
1239
|
-
this.fetchImpl = deps?.fetchImpl;
|
|
1240
|
-
this.lookupFn = deps?.lookupFn;
|
|
1241
1164
|
}
|
|
1242
1165
|
async requestCardKit(path, operation, method, body, readResponse, token) {
|
|
1243
1166
|
const auditContext = `feishu.streaming-card.${operation}`;
|
|
@@ -1246,17 +1169,12 @@ var FeishuStreamingSession = class {
|
|
|
1246
1169
|
init: {
|
|
1247
1170
|
method,
|
|
1248
1171
|
headers: {
|
|
1249
|
-
Authorization: `Bearer ${token ?? await getToken(this.creds
|
|
1250
|
-
fetchImpl: this.fetchImpl,
|
|
1251
|
-
lookupFn: this.lookupFn
|
|
1252
|
-
})}`,
|
|
1172
|
+
Authorization: `Bearer ${token ?? await getToken(this.creds)}`,
|
|
1253
1173
|
"Content-Type": method === "PATCH" ? "application/json; charset=utf-8" : "application/json",
|
|
1254
1174
|
"User-Agent": getFeishuUserAgent()
|
|
1255
1175
|
},
|
|
1256
1176
|
body: JSON.stringify(body())
|
|
1257
1177
|
},
|
|
1258
|
-
fetchImpl: this.fetchImpl,
|
|
1259
|
-
lookupFn: this.lookupFn,
|
|
1260
1178
|
policy: { allowedHostnames: resolveAllowedHostnames(this.creds.domain) },
|
|
1261
1179
|
auditContext,
|
|
1262
1180
|
timeoutMs: this.creds.httpTimeoutMs ?? 3e4
|
|
@@ -1410,10 +1328,7 @@ var FeishuStreamingSession = class {
|
|
|
1410
1328
|
if (!this.state || !this.state.hasNote) return;
|
|
1411
1329
|
this.state.sequence += 1;
|
|
1412
1330
|
const path = `/${this.state.cardId}/elements/note/content`;
|
|
1413
|
-
const token = await getToken(this.creds
|
|
1414
|
-
fetchImpl: this.fetchImpl,
|
|
1415
|
-
lookupFn: this.lookupFn
|
|
1416
|
-
});
|
|
1331
|
+
const token = await getToken(this.creds);
|
|
1417
1332
|
await this.requestCardKit(path, "note-update", "PUT", () => ({
|
|
1418
1333
|
content: `<font color='grey'>${note}</font>`,
|
|
1419
1334
|
sequence: this.state.sequence,
|
|
@@ -1535,6 +1450,25 @@ function getBackoffCodeFromResponse(response) {
|
|
|
1535
1450
|
//#endregion
|
|
1536
1451
|
//#region extensions/feishu/src/typing.ts
|
|
1537
1452
|
const TYPING_EMOJI = "Typing";
|
|
1453
|
+
async function requestTypingReaction(request, operation, readResponse, runtime) {
|
|
1454
|
+
const indicator = `typing indicator${operation === "remove" ? " removal" : ""}`;
|
|
1455
|
+
try {
|
|
1456
|
+
const response = await request();
|
|
1457
|
+
const backoffCode = getBackoffCodeFromResponse(response);
|
|
1458
|
+
if (backoffCode !== void 0) {
|
|
1459
|
+
if (getFeishuRuntime().logging.shouldLogVerbose()) runtime?.log?.(`[feishu] ${indicator} response contains backoff code ${backoffCode}, stopping keepalive`);
|
|
1460
|
+
throw new FeishuBackoffError(backoffCode);
|
|
1461
|
+
}
|
|
1462
|
+
return readResponse(response);
|
|
1463
|
+
} catch (err) {
|
|
1464
|
+
if (isFeishuBackoffError(err)) {
|
|
1465
|
+
if (getFeishuRuntime().logging.shouldLogVerbose()) runtime?.log?.(`[feishu] ${indicator} hit rate-limit/quota, stopping keepalive`);
|
|
1466
|
+
throw err;
|
|
1467
|
+
}
|
|
1468
|
+
if (getFeishuRuntime().logging.shouldLogVerbose()) runtime?.log?.(`[feishu] failed to ${operation} typing indicator: ${String(err)}`);
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1538
1472
|
/**
|
|
1539
1473
|
* Add a typing indicator (reaction) to a message.
|
|
1540
1474
|
*
|
|
@@ -1555,31 +1489,13 @@ async function addTypingIndicator(params) {
|
|
|
1555
1489
|
reactionId: null
|
|
1556
1490
|
};
|
|
1557
1491
|
const client = createFeishuClient(account);
|
|
1558
|
-
|
|
1559
|
-
|
|
1492
|
+
return {
|
|
1493
|
+
messageId,
|
|
1494
|
+
reactionId: await requestTypingReaction(() => client.im.messageReaction.create({
|
|
1560
1495
|
path: { message_id: messageId },
|
|
1561
1496
|
data: { reaction_type: { emoji_type: TYPING_EMOJI } }
|
|
1562
|
-
})
|
|
1563
|
-
|
|
1564
|
-
if (backoffCode !== void 0) {
|
|
1565
|
-
if (getFeishuRuntime().logging.shouldLogVerbose()) runtime?.log?.(`[feishu] typing indicator response contains backoff code ${backoffCode}, stopping keepalive`);
|
|
1566
|
-
throw new FeishuBackoffError(backoffCode);
|
|
1567
|
-
}
|
|
1568
|
-
return {
|
|
1569
|
-
messageId,
|
|
1570
|
-
reactionId: response.data?.reaction_id ?? null
|
|
1571
|
-
};
|
|
1572
|
-
} catch (err) {
|
|
1573
|
-
if (isFeishuBackoffError(err)) {
|
|
1574
|
-
if (getFeishuRuntime().logging.shouldLogVerbose()) runtime?.log?.("[feishu] typing indicator hit rate-limit/quota, stopping keepalive");
|
|
1575
|
-
throw err;
|
|
1576
|
-
}
|
|
1577
|
-
if (getFeishuRuntime().logging.shouldLogVerbose()) runtime?.log?.(`[feishu] failed to add typing indicator: ${String(err)}`);
|
|
1578
|
-
return {
|
|
1579
|
-
messageId,
|
|
1580
|
-
reactionId: null
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1497
|
+
}), "add", (response) => response.data?.reaction_id ?? null, runtime) ?? null
|
|
1498
|
+
};
|
|
1583
1499
|
}
|
|
1584
1500
|
/**
|
|
1585
1501
|
* Remove a typing indicator (reaction) from a message.
|
|
@@ -1595,22 +1511,10 @@ async function removeTypingIndicator(params) {
|
|
|
1595
1511
|
});
|
|
1596
1512
|
if (!account.configured) return;
|
|
1597
1513
|
const client = createFeishuClient(account);
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
} }));
|
|
1603
|
-
if (backoffCode !== void 0) {
|
|
1604
|
-
if (getFeishuRuntime().logging.shouldLogVerbose()) runtime?.log?.(`[feishu] typing indicator removal response contains backoff code ${backoffCode}, stopping keepalive`);
|
|
1605
|
-
throw new FeishuBackoffError(backoffCode);
|
|
1606
|
-
}
|
|
1607
|
-
} catch (err) {
|
|
1608
|
-
if (isFeishuBackoffError(err)) {
|
|
1609
|
-
if (getFeishuRuntime().logging.shouldLogVerbose()) runtime?.log?.("[feishu] typing indicator removal hit rate-limit/quota, stopping keepalive");
|
|
1610
|
-
throw err;
|
|
1611
|
-
}
|
|
1612
|
-
if (getFeishuRuntime().logging.shouldLogVerbose()) runtime?.log?.(`[feishu] failed to remove typing indicator: ${String(err)}`);
|
|
1613
|
-
}
|
|
1514
|
+
await requestTypingReaction(() => client.im.messageReaction.delete({ path: {
|
|
1515
|
+
message_id: state.messageId,
|
|
1516
|
+
reaction_id: state.reactionId
|
|
1517
|
+
} }), "remove", () => void 0, runtime);
|
|
1614
1518
|
}
|
|
1615
1519
|
//#endregion
|
|
1616
1520
|
//#region extensions/feishu/src/reply-dispatcher.ts
|
|
@@ -1634,10 +1538,6 @@ function isStreamingStartBackedOff(accountId, now = Date.now()) {
|
|
|
1634
1538
|
}
|
|
1635
1539
|
return true;
|
|
1636
1540
|
}
|
|
1637
|
-
function rememberStreamingStartFailure(accountId, now = Date.now()) {
|
|
1638
|
-
const backoffUntil = now + STREAMING_START_FAILURE_BACKOFF_MS;
|
|
1639
|
-
streamingStartBackoffUntilByAccount.set(accountId, backoffUntil);
|
|
1640
|
-
}
|
|
1641
1541
|
function normalizeEpochMs(timestamp) {
|
|
1642
1542
|
if (!Number.isFinite(timestamp) || timestamp === void 0 || timestamp <= 0) return;
|
|
1643
1543
|
return timestamp < MS_EPOCH_MIN ? timestamp * 1e3 : timestamp;
|
|
@@ -1670,7 +1570,7 @@ function createFeishuReplyDispatcher(params) {
|
|
|
1670
1570
|
to: sendTarget,
|
|
1671
1571
|
replyToMessageId: sendReplyToMessageId,
|
|
1672
1572
|
replyInThread: effectiveReplyInThread,
|
|
1673
|
-
allowTopLevelReplyFallback:
|
|
1573
|
+
allowTopLevelReplyFallback: threadReplyMode && rootId !== void 0 && sendReplyToMessageId !== void 0 && sendReplyToMessageId !== rootId,
|
|
1674
1574
|
accountId
|
|
1675
1575
|
};
|
|
1676
1576
|
const account = resolveFeishuRuntimeAccount({
|
|
@@ -1732,8 +1632,7 @@ function createFeishuReplyDispatcher(params) {
|
|
|
1732
1632
|
const hookRunner = getGlobalHookRunner();
|
|
1733
1633
|
const modifyingHooksRegistered = (hookRunner?.hasHooks("reply_payload_sending") ?? false) || (hookRunner?.hasHooks("message_sending") ?? false);
|
|
1734
1634
|
const previewStreamingEnabled = streamingEnabled && !modifyingHooksRegistered;
|
|
1735
|
-
const
|
|
1736
|
-
const coreBlockStreamingEnabled = blockStreamingEnabled === true;
|
|
1635
|
+
const coreBlockStreamingEnabled = resolveChannelStreamingBlockEnabled(account.config) === true;
|
|
1737
1636
|
const reasoningPreviewEnabled = previewStreamingEnabled && params.allowReasoningPreview === true;
|
|
1738
1637
|
let streaming = null;
|
|
1739
1638
|
let streamText = "";
|
|
@@ -1791,11 +1690,6 @@ function createFeishuReplyDispatcher(params) {
|
|
|
1791
1690
|
}
|
|
1792
1691
|
flushStreamingCardUpdate(buildCombinedStreamText(reasoningText, streamText));
|
|
1793
1692
|
};
|
|
1794
|
-
const queueReasoningUpdate = (nextThinking) => {
|
|
1795
|
-
if (!nextThinking) return;
|
|
1796
|
-
reasoningText = nextThinking;
|
|
1797
|
-
flushStreamingCardUpdate(buildCombinedStreamText(reasoningText, streamText));
|
|
1798
|
-
};
|
|
1799
1693
|
const startStreaming = () => {
|
|
1800
1694
|
if (!streamingEnabled || streamingStartPromise || streaming || isStreamingStartBackedOff(account.accountId)) return;
|
|
1801
1695
|
streamingStartPromise = (async () => {
|
|
@@ -1823,7 +1717,7 @@ function createFeishuReplyDispatcher(params) {
|
|
|
1823
1717
|
});
|
|
1824
1718
|
streamingStartBackoffUntilByAccount.delete(account.accountId);
|
|
1825
1719
|
} catch (error) {
|
|
1826
|
-
|
|
1720
|
+
streamingStartBackoffUntilByAccount.set(account.accountId, Date.now() + STREAMING_START_FAILURE_BACKOFF_MS);
|
|
1827
1721
|
params.runtime.error?.(`feishu[${account.accountId}]: streaming start failed; using non-streaming card fallback for ${STREAMING_START_FAILURE_BACKOFF_MS / 1e3}s: ${String(error)}`);
|
|
1828
1722
|
if (streaming === session) {
|
|
1829
1723
|
streaming = null;
|
|
@@ -1959,9 +1853,9 @@ function createFeishuReplyDispatcher(params) {
|
|
|
1959
1853
|
const outcome = await closeStreaming("discarded");
|
|
1960
1854
|
if (outcome.error !== void 0) throw toStringifiedError(outcome.error);
|
|
1961
1855
|
};
|
|
1962
|
-
const updateStreamingStatusLine = (nextStatusLine,
|
|
1856
|
+
const updateStreamingStatusLine = (nextStatusLine, startIfNeeded = true) => {
|
|
1963
1857
|
statusLine = nextStatusLine;
|
|
1964
|
-
if (!Boolean(streaming?.isActive() || streamingStartPromise) && (
|
|
1858
|
+
if (!Boolean(streaming?.isActive() || streamingStartPromise) && (!startIfNeeded || renderMode !== "card")) return false;
|
|
1965
1859
|
startStreaming();
|
|
1966
1860
|
flushStreamingCardUpdate(buildCombinedStreamText(reasoningText, streamText));
|
|
1967
1861
|
return false;
|
|
@@ -2102,10 +1996,8 @@ function createFeishuReplyDispatcher(params) {
|
|
|
2102
1996
|
if (settlement) settlement.contentClaimed = true;
|
|
2103
1997
|
return settlement;
|
|
2104
1998
|
}
|
|
2105
|
-
let
|
|
2106
|
-
for (const
|
|
2107
|
-
if (latestKey === void 0) return;
|
|
2108
|
-
const result = closedStreamingSettlements.get(latestKey);
|
|
1999
|
+
let result;
|
|
2000
|
+
for (const settlement of closedStreamingSettlements.values()) if (settlement.contentClaimed !== true && (content === void 0 || settlement.content === content)) result = settlement;
|
|
2109
2001
|
if (result) result.contentClaimed = true;
|
|
2110
2002
|
return result;
|
|
2111
2003
|
};
|
|
@@ -2128,7 +2020,7 @@ function createFeishuReplyDispatcher(params) {
|
|
|
2128
2020
|
const closeOutcome = await closeStreaming();
|
|
2129
2021
|
const finalized = closeOutcome.result;
|
|
2130
2022
|
const ownsCurrentClose = (completion) => closeOutcome.generation !== void 0 && completion.streamingGeneration === closeOutcome.generation;
|
|
2131
|
-
if (completions.some(
|
|
2023
|
+
if (completions.some(ownsCurrentClose)) claimClosedStreamingResult(closeOutcome.generation, void 0);
|
|
2132
2024
|
for (const completion of completions) {
|
|
2133
2025
|
const claimedSettlement = ownsCurrentClose(completion) ? {
|
|
2134
2026
|
disposition: closeOutcome.disposition,
|
|
@@ -2235,9 +2127,9 @@ function createFeishuReplyDispatcher(params) {
|
|
|
2235
2127
|
replyOutcome = void 0;
|
|
2236
2128
|
}
|
|
2237
2129
|
if (previewStreamingEnabled && renderMode === "card") startStreaming();
|
|
2238
|
-
await
|
|
2130
|
+
await typingCallbacks?.onReplyStart?.();
|
|
2239
2131
|
},
|
|
2240
|
-
onIdle:
|
|
2132
|
+
onIdle: queueIdleSideEffects,
|
|
2241
2133
|
onCleanup: () => {
|
|
2242
2134
|
typingCallbacks?.onCleanup?.();
|
|
2243
2135
|
}
|
|
@@ -2397,7 +2289,7 @@ function createFeishuReplyDispatcher(params) {
|
|
|
2397
2289
|
},
|
|
2398
2290
|
replyOptions: {
|
|
2399
2291
|
onModelSelected,
|
|
2400
|
-
disableBlockStreaming:
|
|
2292
|
+
disableBlockStreaming: !coreBlockStreamingEnabled,
|
|
2401
2293
|
onPartialReply: previewStreamingEnabled ? (payload) => {
|
|
2402
2294
|
if (!payload.text) return false;
|
|
2403
2295
|
const cleaned = stripReasoningTagsFromText(payload.text, {
|
|
@@ -2415,7 +2307,11 @@ function createFeishuReplyDispatcher(params) {
|
|
|
2415
2307
|
onReasoningStream: reasoningPreviewEnabled ? (payload) => {
|
|
2416
2308
|
if (!payload.text) return false;
|
|
2417
2309
|
startStreaming();
|
|
2418
|
-
|
|
2310
|
+
const nextThinking = formatReasoningMessage(payload.text);
|
|
2311
|
+
if (nextThinking) {
|
|
2312
|
+
reasoningText = nextThinking;
|
|
2313
|
+
flushStreamingCardUpdate(buildCombinedStreamText(reasoningText, streamText));
|
|
2314
|
+
}
|
|
2419
2315
|
return false;
|
|
2420
2316
|
} : void 0,
|
|
2421
2317
|
onReasoningEnd: reasoningPreviewEnabled ? () => false : void 0,
|
|
@@ -2430,7 +2326,7 @@ function createFeishuReplyDispatcher(params) {
|
|
|
2430
2326
|
if (statusLineLocal) return updateStreamingStatusLine(statusLineLocal);
|
|
2431
2327
|
return false;
|
|
2432
2328
|
} : void 0,
|
|
2433
|
-
onAssistantMessageStart: previewStreamingEnabled ? () => updateStreamingStatusLine("",
|
|
2329
|
+
onAssistantMessageStart: previewStreamingEnabled ? () => updateStreamingStatusLine("", false) : void 0,
|
|
2434
2330
|
onCompactionStart: previewStreamingEnabled ? () => updateStreamingStatusLine("📦 **Compacting context...**") : void 0,
|
|
2435
2331
|
onCompactionEnd: previewStreamingEnabled ? () => updateStreamingStatusLine("") : void 0
|
|
2436
2332
|
},
|
|
@@ -2733,7 +2629,7 @@ async function handleFeishuMessage(params) {
|
|
|
2733
2629
|
const dmPolicy = feishuCfg?.dmPolicy ?? "pairing";
|
|
2734
2630
|
const configAllowFrom = feishuCfg?.allowFrom ?? [];
|
|
2735
2631
|
const rawBroadcastAgents = isGroup ? resolveBroadcastAgents(cfg, ctx.chatId) : null;
|
|
2736
|
-
const broadcastAgents = rawBroadcastAgents ? uniqueStrings(rawBroadcastAgents.map(
|
|
2632
|
+
const broadcastAgents = rawBroadcastAgents ? uniqueStrings(rawBroadcastAgents.map(normalizeAgentId$1)) : null;
|
|
2737
2633
|
const messageCreateTimeMs = parseStrictNonNegativeInteger(event.message.create_time) ?? Date.now();
|
|
2738
2634
|
let requireMention = false;
|
|
2739
2635
|
if (isGroup) {
|
|
@@ -3021,6 +2917,14 @@ async function handleFeishuMessage(params) {
|
|
|
3021
2917
|
channel: "feishu",
|
|
3022
2918
|
accountId: account.accountId
|
|
3023
2919
|
});
|
|
2920
|
+
const fetchedContextPolicy = {
|
|
2921
|
+
cfg,
|
|
2922
|
+
accountId: account.accountId,
|
|
2923
|
+
chatId: ctx.chatId,
|
|
2924
|
+
isGroup,
|
|
2925
|
+
allowFrom: effectiveGroupSenderAllowFrom,
|
|
2926
|
+
mode: contextVisibilityMode
|
|
2927
|
+
};
|
|
3024
2928
|
log(`feishu[${account.accountId}]: ${inboundLabel}: ${preview}`);
|
|
3025
2929
|
const mediaMaxBytes = (feishuCfg?.mediaMaxMb ?? 30) * 1024 * 1024;
|
|
3026
2930
|
const mediaList = await resolveFeishuMediaList({
|
|
@@ -3045,12 +2949,7 @@ async function handleFeishuMessage(params) {
|
|
|
3045
2949
|
accountId: account.accountId
|
|
3046
2950
|
});
|
|
3047
2951
|
if (quotedMessageInfo && await shouldIncludeFetchedGroupContextMessage({
|
|
3048
|
-
|
|
3049
|
-
accountId: account.accountId,
|
|
3050
|
-
chatId: ctx.chatId,
|
|
3051
|
-
isGroup,
|
|
3052
|
-
allowFrom: effectiveGroupSenderAllowFrom,
|
|
3053
|
-
mode: contextVisibilityMode,
|
|
2952
|
+
...fetchedContextPolicy,
|
|
3054
2953
|
kind: "quote",
|
|
3055
2954
|
senderId: quotedMessageInfo.senderId,
|
|
3056
2955
|
senderType: quotedMessageInfo.senderType
|
|
@@ -3162,7 +3061,7 @@ async function handleFeishuMessage(params) {
|
|
|
3162
3061
|
return threadContext;
|
|
3163
3062
|
}
|
|
3164
3063
|
const storePath = resolveStorePath(cfg.session?.store, { agentId });
|
|
3165
|
-
if (core.channel.session.
|
|
3064
|
+
if (await core.channel.session.readSessionUpdatedAtAsync({
|
|
3166
3065
|
storePath,
|
|
3167
3066
|
sessionKey: agentSessionKey
|
|
3168
3067
|
})) {
|
|
@@ -3173,12 +3072,7 @@ async function handleFeishuMessage(params) {
|
|
|
3173
3072
|
let rootMsg = await getRootMessageInfo();
|
|
3174
3073
|
const feishuThreadId = ctx.threadId ?? rootMsg?.threadId;
|
|
3175
3074
|
if (rootMsg && !await shouldIncludeFetchedGroupContextMessage({
|
|
3176
|
-
|
|
3177
|
-
accountId: account.accountId,
|
|
3178
|
-
chatId: ctx.chatId,
|
|
3179
|
-
isGroup,
|
|
3180
|
-
allowFrom: effectiveGroupSenderAllowFrom,
|
|
3181
|
-
mode: contextVisibilityMode,
|
|
3075
|
+
...fetchedContextPolicy,
|
|
3182
3076
|
kind: "thread",
|
|
3183
3077
|
senderId: rootMsg.senderId,
|
|
3184
3078
|
senderType: rootMsg.senderType
|
|
@@ -3202,14 +3096,9 @@ async function handleFeishuMessage(params) {
|
|
|
3202
3096
|
accountId: account.accountId
|
|
3203
3097
|
});
|
|
3204
3098
|
const senderScoped = groupSession?.groupSessionScope === "group_topic_sender";
|
|
3205
|
-
const senderIds = new Set([ctx.senderOpenId, senderUserId].
|
|
3099
|
+
const senderIds = new Set([ctx.senderOpenId, senderUserId].filter((id) => Boolean(id)));
|
|
3206
3100
|
const allowlistedMessages = await filterFetchedGroupContextMessages(threadMessages, {
|
|
3207
|
-
|
|
3208
|
-
accountId: account.accountId,
|
|
3209
|
-
chatId: ctx.chatId,
|
|
3210
|
-
isGroup,
|
|
3211
|
-
allowFrom: effectiveGroupSenderAllowFrom,
|
|
3212
|
-
mode: contextVisibilityMode,
|
|
3101
|
+
...fetchedContextPolicy,
|
|
3213
3102
|
kind: "history"
|
|
3214
3103
|
});
|
|
3215
3104
|
const relevantMessages = senderScoped ? allowlistedMessages.filter((msg) => msg.senderType === "app" || msg.senderId !== void 0 && senderIds.has(msg.senderId.trim())) : allowlistedMessages;
|
|
@@ -3385,6 +3274,22 @@ async function handleFeishuMessage(params) {
|
|
|
3385
3274
|
requiredMentionTargets,
|
|
3386
3275
|
messageCreateTimeMs
|
|
3387
3276
|
});
|
|
3277
|
+
const runAgentTurn = (ctxPayload, resolveTurn) => core.channel.inbound.run({
|
|
3278
|
+
channel: "feishu",
|
|
3279
|
+
accountId: route.accountId,
|
|
3280
|
+
raw: ctx,
|
|
3281
|
+
adapter: {
|
|
3282
|
+
ingest: () => ({
|
|
3283
|
+
id: ctx.messageId,
|
|
3284
|
+
timestamp: messageCreateTimeMs,
|
|
3285
|
+
rawText: ctx.content,
|
|
3286
|
+
textForAgent: ctxPayload.BodyForAgent,
|
|
3287
|
+
textForCommands: ctxPayload.CommandBody,
|
|
3288
|
+
raw: ctx
|
|
3289
|
+
}),
|
|
3290
|
+
resolveTurn
|
|
3291
|
+
}
|
|
3292
|
+
});
|
|
3388
3293
|
if (broadcastAgents) {
|
|
3389
3294
|
const broadcastDedupeKey = messageDedupeKey ?? ctx.messageId;
|
|
3390
3295
|
const broadcastClaim = await claimUnprocessedFeishuMessage({
|
|
@@ -3417,12 +3322,11 @@ async function handleFeishuMessage(params) {
|
|
|
3417
3322
|
};
|
|
3418
3323
|
const strategy = cfg.broadcast?.strategy === "sequential" ? "sequential" : "parallel";
|
|
3419
3324
|
const activeAgentId = ctx.mentionedBot || !requireMention ? normalizeAgentId$1(route.agentId) : null;
|
|
3420
|
-
const agentIds = Object.keys(cfg.agents?.entries ?? {}).map(
|
|
3325
|
+
const agentIds = Object.keys(cfg.agents?.entries ?? {}).map(normalizeAgentId$1);
|
|
3421
3326
|
const hasKnownAgents = agentIds.length > 0;
|
|
3422
3327
|
log(`feishu[${account.accountId}]: broadcasting to ${broadcastAgents.length} agents (strategy=${strategy}, active=${activeAgentId ?? "none"})`);
|
|
3423
3328
|
const dispatchForAgent = async (agentId) => {
|
|
3424
|
-
|
|
3425
|
-
if (hasKnownAgents && !agentIds.includes(normalizedAgentId)) {
|
|
3329
|
+
if (hasKnownAgents && !agentIds.includes(agentId)) {
|
|
3426
3330
|
log(`feishu[${account.accountId}]: broadcast agent ${agentId} not found in agents.entries; skipping`);
|
|
3427
3331
|
return;
|
|
3428
3332
|
}
|
|
@@ -3430,7 +3334,7 @@ async function handleFeishuMessage(params) {
|
|
|
3430
3334
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
3431
3335
|
agentClaim = await claimUnprocessedFeishuMessage({
|
|
3432
3336
|
messageId: broadcastDedupeKey,
|
|
3433
|
-
namespace: `broadcast:${
|
|
3337
|
+
namespace: `broadcast:${agentId}`,
|
|
3434
3338
|
log
|
|
3435
3339
|
});
|
|
3436
3340
|
if (agentClaim.kind === "duplicate") return;
|
|
@@ -3463,67 +3367,42 @@ async function handleFeishuMessage(params) {
|
|
|
3463
3367
|
sessionKey: agentSessionKey
|
|
3464
3368
|
});
|
|
3465
3369
|
const agentCtx = await buildCtxPayloadForAgent(agentId, agentSessionKey, route.accountId, ctx.mentionedBot && agentId === activeAgentId);
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
})
|
|
3478
|
-
};
|
|
3479
|
-
log(`feishu[${account.accountId}]: broadcast active dispatch agent=${agentId} (session=${agentSessionKey})`);
|
|
3480
|
-
} else {
|
|
3481
|
-
delete agentCtx.CommandAuthorized;
|
|
3482
|
-
variant = { kind: "observeOnly" };
|
|
3483
|
-
log(`feishu[${account.accountId}]: broadcast observer dispatch agent=${agentId} (session=${agentSessionKey})`);
|
|
3484
|
-
}
|
|
3485
|
-
const turnResult = await core.channel.inbound.run({
|
|
3370
|
+
const dispatcher = agentId === activeAgentId ? createAgentReplyDispatcher({
|
|
3371
|
+
cfg,
|
|
3372
|
+
agentId,
|
|
3373
|
+
allowReasoningPreview,
|
|
3374
|
+
identity: resolveAgentOutboundIdentity(cfg, agentId),
|
|
3375
|
+
sessionKey: agentSessionKey
|
|
3376
|
+
}) : void 0;
|
|
3377
|
+
if (!dispatcher) delete agentCtx.CommandAuthorized;
|
|
3378
|
+
log(`feishu[${account.accountId}]: broadcast ${dispatcher ? "active" : "observer"} dispatch agent=${agentId} (session=${agentSessionKey})`);
|
|
3379
|
+
const turnResult = await runAgentTurn(agentCtx, () => ({
|
|
3380
|
+
cfg,
|
|
3486
3381
|
channel: "feishu",
|
|
3487
3382
|
accountId: route.accountId,
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
...variant.kind === "observeOnly" ? {
|
|
3509
|
-
admission: {
|
|
3510
|
-
kind: "observeOnly",
|
|
3511
|
-
reason: "broadcast-observer"
|
|
3512
|
-
},
|
|
3513
|
-
delivery: { deliver: async () => ({ visibleReplySent: false }) },
|
|
3514
|
-
replyOptions: bindIngressLifecycleToReplyOptions(lane.lifecycle)
|
|
3515
|
-
} : {
|
|
3516
|
-
dispatcherOptions: variant.dispatcher.dispatcherOptions,
|
|
3517
|
-
delivery: variant.dispatcher.delivery,
|
|
3518
|
-
replyOptions: {
|
|
3519
|
-
...variant.dispatcher.replyOptions,
|
|
3520
|
-
...bindIngressLifecycleToReplyOptions(lane.lifecycle)
|
|
3521
|
-
}
|
|
3522
|
-
}
|
|
3523
|
-
})
|
|
3383
|
+
route: {
|
|
3384
|
+
agentId,
|
|
3385
|
+
sessionKey: agentSessionKey
|
|
3386
|
+
},
|
|
3387
|
+
ctxPayload: agentCtx,
|
|
3388
|
+
record: agentRecord,
|
|
3389
|
+
...!dispatcher ? {
|
|
3390
|
+
admission: {
|
|
3391
|
+
kind: "observeOnly",
|
|
3392
|
+
reason: "broadcast-observer"
|
|
3393
|
+
},
|
|
3394
|
+
delivery: { deliver: async () => ({ visibleReplySent: false }) },
|
|
3395
|
+
replyOptions: bindIngressLifecycleToReplyOptions(lane.lifecycle)
|
|
3396
|
+
} : {
|
|
3397
|
+
dispatcherOptions: dispatcher.dispatcherOptions,
|
|
3398
|
+
delivery: dispatcher.delivery,
|
|
3399
|
+
replyOptions: {
|
|
3400
|
+
...dispatcher.replyOptions,
|
|
3401
|
+
...bindIngressLifecycleToReplyOptions(lane.lifecycle)
|
|
3402
|
+
}
|
|
3524
3403
|
}
|
|
3525
|
-
});
|
|
3526
|
-
if (
|
|
3404
|
+
}));
|
|
3405
|
+
if (dispatcher && turnResult.dispatched && shouldSendNoVisibleReplyFallback(turnResult.dispatchResult)) await dispatcher.ensureNoVisibleReplyFallback("broadcast-dispatch-complete-no-visible-reply");
|
|
3527
3406
|
await lane.onDispatchComplete(turnResult.dispatched);
|
|
3528
3407
|
} catch (err) {
|
|
3529
3408
|
await lane.onDispatchFailed(err);
|
|
@@ -3581,52 +3460,37 @@ async function handleFeishuMessage(params) {
|
|
|
3581
3460
|
sessionKey: route.sessionKey
|
|
3582
3461
|
});
|
|
3583
3462
|
log(`feishu[${account.accountId}]: dispatching to agent (session=${route.sessionKey})`);
|
|
3584
|
-
const turnResult = await
|
|
3463
|
+
const turnResult = await runAgentTurn(ctxPayload, () => ({
|
|
3464
|
+
cfg: effectiveCfg,
|
|
3585
3465
|
channel: "feishu",
|
|
3586
3466
|
accountId: route.accountId,
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3467
|
+
route: {
|
|
3468
|
+
agentId: route.agentId,
|
|
3469
|
+
sessionKey: route.sessionKey
|
|
3470
|
+
},
|
|
3471
|
+
ctxPayload,
|
|
3472
|
+
record: {
|
|
3473
|
+
updateLastRoute: buildFeishuInboundLastRouteUpdate({
|
|
3474
|
+
sessionKey: route.sessionKey,
|
|
3475
|
+
accountId: route.accountId
|
|
3596
3476
|
}),
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
log(`feishu[${account.accountId}]: failed to record inbound session ${route.sessionKey}: ${String(err)}`);
|
|
3613
|
-
}
|
|
3614
|
-
},
|
|
3615
|
-
history: {
|
|
3616
|
-
isGroup,
|
|
3617
|
-
historyKey,
|
|
3618
|
-
historyMap: chatHistories,
|
|
3619
|
-
limit: historyLimit
|
|
3620
|
-
},
|
|
3621
|
-
dispatcherOptions,
|
|
3622
|
-
delivery,
|
|
3623
|
-
replyOptions: {
|
|
3624
|
-
...replyOptions,
|
|
3625
|
-
...turnAdoptionLifecycle ? bindIngressLifecycleToReplyOptions(turnAdoptionLifecycle) : {}
|
|
3626
|
-
}
|
|
3627
|
-
})
|
|
3477
|
+
onRecordError: (err) => {
|
|
3478
|
+
log(`feishu[${account.accountId}]: failed to record inbound session ${route.sessionKey}: ${String(err)}`);
|
|
3479
|
+
}
|
|
3480
|
+
},
|
|
3481
|
+
history: {
|
|
3482
|
+
isGroup,
|
|
3483
|
+
historyKey,
|
|
3484
|
+
historyMap: chatHistories,
|
|
3485
|
+
limit: historyLimit
|
|
3486
|
+
},
|
|
3487
|
+
dispatcherOptions,
|
|
3488
|
+
delivery,
|
|
3489
|
+
replyOptions: {
|
|
3490
|
+
...replyOptions,
|
|
3491
|
+
...turnAdoptionLifecycle ? bindIngressLifecycleToReplyOptions(turnAdoptionLifecycle) : {}
|
|
3628
3492
|
}
|
|
3629
|
-
});
|
|
3493
|
+
}));
|
|
3630
3494
|
if (!turnResult.dispatched) return;
|
|
3631
3495
|
const { dispatchResult } = turnResult;
|
|
3632
3496
|
const { queuedFinal, counts } = dispatchResult;
|
|
@@ -3732,17 +3596,11 @@ function beginFeishuCardActionToken(params) {
|
|
|
3732
3596
|
const normalizedToken = params.token.trim();
|
|
3733
3597
|
if (!normalizedToken) return false;
|
|
3734
3598
|
const key = `${params.accountId}:${normalizedToken}`;
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
processedCardActions.delete(key);
|
|
3738
|
-
const expiresAt = resolveExpiresAtMsFromDurationMs(FEISHU_CARD_ACTION_TOKEN_TTL_MS, { nowMs: now });
|
|
3739
|
-
if (expiresAt !== void 0) processedCardActions.set(key, {
|
|
3740
|
-
status: "inflight",
|
|
3741
|
-
expiresAt
|
|
3742
|
-
});
|
|
3599
|
+
if (processedCardActions.has(key)) return false;
|
|
3600
|
+
refreshFeishuCardActionToken(normalizedToken, params.accountId, now);
|
|
3743
3601
|
return true;
|
|
3744
3602
|
}
|
|
3745
|
-
function
|
|
3603
|
+
function refreshFeishuCardActionToken(actionId, accountId, now = Date.now()) {
|
|
3746
3604
|
const normalizedActionId = actionId.trim();
|
|
3747
3605
|
if (!normalizedActionId) return;
|
|
3748
3606
|
const key = `${accountId}:${normalizedActionId}`;
|
|
@@ -3751,12 +3609,9 @@ function completeFeishuCardAction(actionId, accountId, now = Date.now()) {
|
|
|
3751
3609
|
processedCardActions.delete(key);
|
|
3752
3610
|
return;
|
|
3753
3611
|
}
|
|
3754
|
-
processedCardActions.set(key, {
|
|
3755
|
-
status: "completed",
|
|
3756
|
-
expiresAt
|
|
3757
|
-
});
|
|
3612
|
+
processedCardActions.set(key, { expiresAt });
|
|
3758
3613
|
}
|
|
3759
|
-
function buildSyntheticMessageEvent
|
|
3614
|
+
function buildSyntheticMessageEvent(event, content, chatType, botOpenId) {
|
|
3760
3615
|
const replyTargetMessageId = event.context.open_message_id ?? event.open_message_id;
|
|
3761
3616
|
const isTemporaryCardActionId = replyTargetMessageId?.startsWith("card-action-c-");
|
|
3762
3617
|
const validReplyTargetId = replyTargetMessageId && !isTemporaryCardActionId ? replyTargetMessageId : void 0;
|
|
@@ -3799,7 +3654,7 @@ async function dispatchSyntheticCommand(params) {
|
|
|
3799
3654
|
await handleFeishuMessage({
|
|
3800
3655
|
trackTask: params.trackTask,
|
|
3801
3656
|
cfg: params.cfg,
|
|
3802
|
-
event: buildSyntheticMessageEvent
|
|
3657
|
+
event: buildSyntheticMessageEvent(params.event, params.command, resolvedChatType, params.botOpenId),
|
|
3803
3658
|
botOpenId: params.botOpenId,
|
|
3804
3659
|
runtime: params.runtime,
|
|
3805
3660
|
channelRuntime: params.channelRuntime,
|
|
@@ -3951,7 +3806,7 @@ async function handleFeishuCardAction(params) {
|
|
|
3951
3806
|
account
|
|
3952
3807
|
});
|
|
3953
3808
|
} finally {
|
|
3954
|
-
|
|
3809
|
+
refreshFeishuCardActionToken(event.token, account.accountId);
|
|
3955
3810
|
}
|
|
3956
3811
|
}
|
|
3957
3812
|
//#endregion
|
|
@@ -4429,26 +4284,6 @@ function isFeishuRetryableSyntheticEventError(error) {
|
|
|
4429
4284
|
}
|
|
4430
4285
|
//#endregion
|
|
4431
4286
|
//#region extensions/feishu/src/monitor.bot-menu-handler.ts
|
|
4432
|
-
function readStringOrNumber(value) {
|
|
4433
|
-
return typeof value === "string" || typeof value === "number" ? value : void 0;
|
|
4434
|
-
}
|
|
4435
|
-
function parseFeishuBotMenuEvent(value) {
|
|
4436
|
-
if (!isRecord(value)) return null;
|
|
4437
|
-
const operator = value.operator;
|
|
4438
|
-
if (operator !== void 0 && !isRecord(operator)) return null;
|
|
4439
|
-
return {
|
|
4440
|
-
event_key: readStringValue(value.event_key),
|
|
4441
|
-
timestamp: readStringOrNumber(value.timestamp),
|
|
4442
|
-
operator: operator ? {
|
|
4443
|
-
operator_name: readStringValue(operator.operator_name),
|
|
4444
|
-
operator_id: isRecord(operator.operator_id) ? {
|
|
4445
|
-
open_id: readStringValue(operator.operator_id.open_id),
|
|
4446
|
-
user_id: readStringValue(operator.operator_id.user_id),
|
|
4447
|
-
union_id: readStringValue(operator.operator_id.union_id)
|
|
4448
|
-
} : void 0
|
|
4449
|
-
} : void 0
|
|
4450
|
-
};
|
|
4451
|
-
}
|
|
4452
4287
|
function createFeishuBotMenuHandler(params) {
|
|
4453
4288
|
const { cfg, accountId, runtime, chatHistories, fireAndForget } = params;
|
|
4454
4289
|
const log = runtime?.log ?? console.log;
|
|
@@ -4458,22 +4293,22 @@ function createFeishuBotMenuHandler(params) {
|
|
|
4458
4293
|
const handle = async (data) => {
|
|
4459
4294
|
try {
|
|
4460
4295
|
if (!isActive()) return;
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
const operatorOpenId =
|
|
4464
|
-
const eventKey =
|
|
4296
|
+
if (!isRecord(data) || !isRecord(data.operator) || !isRecord(data.operator.operator_id)) return;
|
|
4297
|
+
const operatorId = data.operator.operator_id;
|
|
4298
|
+
const operatorOpenId = readStringValue(operatorId.open_id)?.trim();
|
|
4299
|
+
const eventKey = readStringValue(data.event_key)?.trim();
|
|
4465
4300
|
if (!operatorOpenId || !eventKey) return;
|
|
4466
4301
|
const syntheticEvent = {
|
|
4467
4302
|
sender: {
|
|
4468
4303
|
sender_id: {
|
|
4469
4304
|
open_id: operatorOpenId,
|
|
4470
|
-
user_id:
|
|
4471
|
-
union_id:
|
|
4305
|
+
user_id: readStringValue(operatorId.user_id),
|
|
4306
|
+
union_id: readStringValue(operatorId.union_id)
|
|
4472
4307
|
},
|
|
4473
4308
|
sender_type: "user"
|
|
4474
4309
|
},
|
|
4475
4310
|
message: {
|
|
4476
|
-
message_id: `bot-menu:${eventKey}:${
|
|
4311
|
+
message_id: `bot-menu:${eventKey}:${typeof data.timestamp === "string" || typeof data.timestamp === "number" ? data.timestamp : Date.now()}`,
|
|
4477
4312
|
suppress_reply_target: true,
|
|
4478
4313
|
chat_id: `p2p:${operatorOpenId}`,
|
|
4479
4314
|
chat_type: "p2p",
|
|
@@ -4525,7 +4360,7 @@ function createFeishuBotMenuHandler(params) {
|
|
|
4525
4360
|
if (claim.kind === "claimed") claim.handle.release({ error: /* @__PURE__ */ new Error("feishu account stopped before menu dispatch") });
|
|
4526
4361
|
return;
|
|
4527
4362
|
}
|
|
4528
|
-
return
|
|
4363
|
+
return handleLegacyMenu();
|
|
4529
4364
|
}).catch(async (err) => {
|
|
4530
4365
|
if (isFeishuRetryableSyntheticEventError(err)) {
|
|
4531
4366
|
await forgetProcessedFeishuMessage(syntheticMessageId, accountId, log);
|
|
@@ -4640,13 +4475,6 @@ const FEISHU_COMMENT_REPLY_MISS_RETRY_LIMIT = 6;
|
|
|
4640
4475
|
const FEISHU_COMMENT_THREAD_PROMPT_LIMIT = 20;
|
|
4641
4476
|
const FEISHU_WHOLE_COMMENT_PROMPT_LIMIT = 12;
|
|
4642
4477
|
const FEISHU_PROMPT_TEXT_LIMIT = 220;
|
|
4643
|
-
function safeJsonStringify(value) {
|
|
4644
|
-
try {
|
|
4645
|
-
return JSON.stringify(value);
|
|
4646
|
-
} catch (error) {
|
|
4647
|
-
return JSON.stringify({ error: formatErrorMessage(error) });
|
|
4648
|
-
}
|
|
4649
|
-
}
|
|
4650
4478
|
function truncatePromptText(text, maxLength = FEISHU_PROMPT_TEXT_LIMIT) {
|
|
4651
4479
|
const normalized = normalizeOptionalString(text);
|
|
4652
4480
|
if (!normalized) return "";
|
|
@@ -4655,11 +4483,11 @@ function truncatePromptText(text, maxLength = FEISHU_PROMPT_TEXT_LIMIT) {
|
|
|
4655
4483
|
function formatPromptTextValue(text) {
|
|
4656
4484
|
return JSON.stringify(truncatePromptText(text));
|
|
4657
4485
|
}
|
|
4658
|
-
function compareCommentTimelineEntries(left, right) {
|
|
4486
|
+
function compareCommentTimelineEntries(left, right, stableId) {
|
|
4659
4487
|
const leftTime = left.createTime ?? Number.MAX_SAFE_INTEGER;
|
|
4660
4488
|
const rightTime = right.createTime ?? Number.MAX_SAFE_INTEGER;
|
|
4661
4489
|
if (leftTime !== rightTime) return leftTime - rightTime;
|
|
4662
|
-
return (left
|
|
4490
|
+
return (stableId(left) ?? "").localeCompare(stableId(right) ?? "");
|
|
4663
4491
|
}
|
|
4664
4492
|
function formatLinkedDocumentInline(link) {
|
|
4665
4493
|
return [
|
|
@@ -4680,7 +4508,7 @@ function formatLinkedDocumentsInlineSummary(linkedDocuments) {
|
|
|
4680
4508
|
return linkedDocuments.map((link) => `${link.resolvedObjType ?? link.urlKind}:${link.resolvedObjToken ?? link.wikiNodeToken ?? "UNKNOWN"}`).join(",");
|
|
4681
4509
|
}
|
|
4682
4510
|
function summarizeCommentRepliesForLog(replies) {
|
|
4683
|
-
return
|
|
4511
|
+
return JSON.stringify(replies.map((reply) => ({
|
|
4684
4512
|
reply_id: reply.reply_id,
|
|
4685
4513
|
text_len: extractReplyText(reply)?.length ?? 0
|
|
4686
4514
|
})));
|
|
@@ -4728,56 +4556,35 @@ async function resolveParsedCommentContent(params) {
|
|
|
4728
4556
|
linkedDocuments: resolvedLinkedDocuments
|
|
4729
4557
|
};
|
|
4730
4558
|
}
|
|
4731
|
-
function fetchDriveComments(params) {
|
|
4732
|
-
const errorLabel = `feishu[${params.accountId}]: failed to list drive comments for ${params.fileToken}`;
|
|
4733
|
-
return fetchDriveCommentPages({
|
|
4734
|
-
logger: params.logger,
|
|
4735
|
-
errorLabel,
|
|
4736
|
-
fetchPage: (pageToken) => requestFeishuOpenApi({
|
|
4737
|
-
client: params.client,
|
|
4738
|
-
method: "GET",
|
|
4739
|
-
url: `/open-apis/drive/v1/files/${encodeURIComponent(params.fileToken)}/comments` + encodeQuery({
|
|
4740
|
-
file_type: params.fileType,
|
|
4741
|
-
is_whole: params.isWholeOnly === true ? "true" : void 0,
|
|
4742
|
-
page_size: String(FEISHU_COMMENT_PAGE_SIZE),
|
|
4743
|
-
page_token: pageToken,
|
|
4744
|
-
user_id_type: "open_id"
|
|
4745
|
-
}),
|
|
4746
|
-
timeoutMs: params.timeoutMs,
|
|
4747
|
-
logger: params.logger,
|
|
4748
|
-
errorLabel
|
|
4749
|
-
})
|
|
4750
|
-
});
|
|
4751
|
-
}
|
|
4752
|
-
function fetchDriveCommentReplies(params) {
|
|
4753
|
-
const errorLabel = `feishu[${params.accountId}]: failed to fetch comment replies for ${params.commentId}`;
|
|
4754
|
-
return fetchDriveCommentPages({
|
|
4755
|
-
logger: params.logger,
|
|
4756
|
-
errorLabel,
|
|
4757
|
-
fetchPage: (pageToken) => requestFeishuOpenApi({
|
|
4758
|
-
client: params.client,
|
|
4759
|
-
method: "GET",
|
|
4760
|
-
url: `/open-apis/drive/v1/files/${encodeURIComponent(params.fileToken)}/comments/${encodeURIComponent(params.commentId)}/replies` + encodeQuery({
|
|
4761
|
-
file_type: params.fileType,
|
|
4762
|
-
page_token: pageToken,
|
|
4763
|
-
page_size: String(FEISHU_COMMENT_PAGE_SIZE),
|
|
4764
|
-
user_id_type: "open_id"
|
|
4765
|
-
}),
|
|
4766
|
-
timeoutMs: params.timeoutMs,
|
|
4767
|
-
logger: params.logger,
|
|
4768
|
-
errorLabel
|
|
4769
|
-
})
|
|
4770
|
-
});
|
|
4771
|
-
}
|
|
4772
4559
|
async function fetchDriveCommentPages(params) {
|
|
4560
|
+
const errorLabel = params.kind === "whole-comments" ? `feishu[${params.accountId}]: failed to list drive comments for ${params.fileToken}` : `feishu[${params.accountId}]: failed to fetch comment replies for ${params.commentId}`;
|
|
4773
4561
|
const items = [];
|
|
4774
4562
|
const logIds = [];
|
|
4775
4563
|
let pageToken;
|
|
4776
4564
|
for (let page = 0; page < FEISHU_COMMENT_PAGE_LIMIT; page += 1) {
|
|
4777
|
-
const
|
|
4565
|
+
const commentsUrl = `/open-apis/drive/v1/files/${encodeURIComponent(params.fileToken)}/comments`;
|
|
4566
|
+
const url = params.kind === "whole-comments" ? commentsUrl : `${commentsUrl}/${encodeURIComponent(params.commentId)}/replies`;
|
|
4567
|
+
const query = {
|
|
4568
|
+
file_type: params.fileType,
|
|
4569
|
+
...params.kind === "whole-comments" ? {
|
|
4570
|
+
is_whole: "true",
|
|
4571
|
+
page_size: String(FEISHU_COMMENT_PAGE_SIZE),
|
|
4572
|
+
page_token: pageToken
|
|
4573
|
+
} : {
|
|
4574
|
+
page_token: pageToken,
|
|
4575
|
+
page_size: String(FEISHU_COMMENT_PAGE_SIZE)
|
|
4576
|
+
},
|
|
4577
|
+
user_id_type: "open_id"
|
|
4578
|
+
};
|
|
4579
|
+
const response = await requestFeishuOpenApi({
|
|
4580
|
+
...params,
|
|
4581
|
+
method: "GET",
|
|
4582
|
+
url: url + encodeQuery(query),
|
|
4583
|
+
errorLabel
|
|
4584
|
+
});
|
|
4778
4585
|
if (response?.log_id?.trim()) logIds.push(response.log_id.trim());
|
|
4779
4586
|
if (response?.code !== 0) {
|
|
4780
|
-
if (response) params.logger?.(`${
|
|
4587
|
+
if (response) params.logger?.(`${errorLabel}: ${response.msg ?? "unknown error"} log_id=${response.log_id?.trim() || "unknown"}`);
|
|
4781
4588
|
break;
|
|
4782
4589
|
}
|
|
4783
4590
|
items.push(...response.data?.items ?? []);
|
|
@@ -4794,7 +4601,7 @@ async function requestFeishuOpenApi(params) {
|
|
|
4794
4601
|
if (!isRecord(error)) return typeof error === "string" ? error : JSON.stringify(error);
|
|
4795
4602
|
const response = isRecord(error.response) ? error.response : void 0;
|
|
4796
4603
|
const responseData = isRecord(response?.data) ? response?.data : void 0;
|
|
4797
|
-
|
|
4604
|
+
const details = {
|
|
4798
4605
|
message: typeof error.message === "string" ? error.message : JSON.stringify(error),
|
|
4799
4606
|
code: readStringValue(error.code),
|
|
4800
4607
|
method: readStringValue(isRecord(error.config) ? error.config.method : void 0),
|
|
@@ -4803,7 +4610,8 @@ async function requestFeishuOpenApi(params) {
|
|
|
4803
4610
|
feishu_code: typeof responseData?.code === "number" ? responseData.code : readStringValue(responseData?.code),
|
|
4804
4611
|
feishu_msg: readStringValue(responseData?.msg),
|
|
4805
4612
|
feishu_log_id: readStringValue(responseData?.log_id)
|
|
4806
|
-
}
|
|
4613
|
+
};
|
|
4614
|
+
return JSON.stringify(details);
|
|
4807
4615
|
};
|
|
4808
4616
|
const result = await raceWithTimeoutAndAbort(params.client.request({
|
|
4809
4617
|
method: params.method,
|
|
@@ -4817,20 +4625,6 @@ async function requestFeishuOpenApi(params) {
|
|
|
4817
4625
|
if (!result) params.logger?.(`${params.errorLabel}: request timed out or returned no data`);
|
|
4818
4626
|
return result;
|
|
4819
4627
|
}
|
|
4820
|
-
async function resolveCommentReplyContext(params) {
|
|
4821
|
-
const userId = normalizeOptionalString(params.reply.user_id);
|
|
4822
|
-
const normalizedBotOpenIds = new Set(normalizeTrimmedStringList(Array.from(params.botOpenIds ?? [])));
|
|
4823
|
-
return {
|
|
4824
|
-
replyId: normalizeOptionalString(params.reply.reply_id),
|
|
4825
|
-
userId,
|
|
4826
|
-
createTime: typeof params.reply.create_time === "number" ? params.reply.create_time : void 0,
|
|
4827
|
-
isBotAuthored: typeof userId === "string" && normalizedBotOpenIds.has(userId),
|
|
4828
|
-
content: await resolveParsedCommentContent({
|
|
4829
|
-
...params,
|
|
4830
|
-
elements: isRecord(params.reply.content) ? params.reply.content.elements : void 0
|
|
4831
|
-
})
|
|
4832
|
-
};
|
|
4833
|
-
}
|
|
4834
4628
|
function selectCommentThreadPromptReplies(replies, targetReplyId) {
|
|
4835
4629
|
if (replies.length <= FEISHU_COMMENT_THREAD_PROMPT_LIMIT) return replies;
|
|
4836
4630
|
const targetIndex = replies.findIndex((reply) => reply.replyId === targetReplyId);
|
|
@@ -4915,24 +4709,30 @@ async function fetchDriveCommentContext(params) {
|
|
|
4915
4709
|
const commentCard = commentResponse?.code === 0 ? (commentResponse.data?.items ?? []).find((item) => item.comment_id?.trim() === params.commentId) : void 0;
|
|
4916
4710
|
const embeddedReplies = commentCard?.reply_list?.replies ?? [];
|
|
4917
4711
|
params.logger?.(`feishu[${params.accountId}]: embedded comment replies comment=${params.commentId} count=${embeddedReplies.length} summary=${summarizeCommentRepliesForLog(embeddedReplies)}`);
|
|
4918
|
-
const embeddedTargetReply = params.replyId ? embeddedReplies.find((reply) => reply.reply_id?.trim() === params.replyId
|
|
4712
|
+
const embeddedTargetReply = params.replyId ? embeddedReplies.find((reply) => reply.reply_id?.trim() === params.replyId) : embeddedReplies.at(-1);
|
|
4919
4713
|
let replies = embeddedReplies;
|
|
4920
|
-
let fetchedMatchedReply = params.replyId ?
|
|
4921
|
-
if (!embeddedTargetReply ||
|
|
4714
|
+
let fetchedMatchedReply = params.replyId ? embeddedTargetReply : void 0;
|
|
4715
|
+
if (!embeddedTargetReply || commentCard?.has_more === true) {
|
|
4922
4716
|
params.logger?.(`feishu[${params.accountId}]: fetching extra comment replies comment=${params.commentId} requested_reply=${params.replyId ?? "none"} embedded_count=${embeddedReplies.length} embedded_hit=${embeddedTargetReply ? "yes" : "no"} embedded_has_more=${commentCard?.has_more === true ? "yes" : "no"}`);
|
|
4923
|
-
const fetched = await
|
|
4717
|
+
const fetched = await fetchDriveCommentPages({
|
|
4718
|
+
...params,
|
|
4719
|
+
kind: "replies"
|
|
4720
|
+
});
|
|
4924
4721
|
if (fetched.items.length > 0) {
|
|
4925
|
-
params.logger?.(`feishu[${params.accountId}]: fetched extra comment replies comment=${params.commentId} count=${fetched.items.length} log_ids=${
|
|
4722
|
+
params.logger?.(`feishu[${params.accountId}]: fetched extra comment replies comment=${params.commentId} count=${fetched.items.length} log_ids=${JSON.stringify(fetched.logIds)} summary=${summarizeCommentRepliesForLog(fetched.items)}`);
|
|
4926
4723
|
replies = fetched.items;
|
|
4927
|
-
fetchedMatchedReply = params.replyId ? replies.find((reply) => reply.reply_id?.trim() === params.replyId
|
|
4724
|
+
fetchedMatchedReply = params.replyId ? replies.find((reply) => reply.reply_id?.trim() === params.replyId) : void 0;
|
|
4928
4725
|
}
|
|
4929
4726
|
if (params.replyId && !embeddedTargetReply && !fetchedMatchedReply) for (let attempt = 1; attempt <= FEISHU_COMMENT_REPLY_MISS_RETRY_LIMIT; attempt += 1) {
|
|
4930
4727
|
if (params.abortSignal?.aborted) break;
|
|
4931
4728
|
params.logger?.(`feishu[${params.accountId}]: retrying comment reply lookup comment=${params.commentId} requested_reply=${params.replyId} attempt=${attempt}/${FEISHU_COMMENT_REPLY_MISS_RETRY_LIMIT} delay_ms=${FEISHU_COMMENT_REPLY_MISS_RETRY_DELAY_MS}`);
|
|
4932
4729
|
if (!await waitForAbortableDelay(FEISHU_COMMENT_REPLY_MISS_RETRY_DELAY_MS, params.abortSignal)) break;
|
|
4933
|
-
const retried = await
|
|
4730
|
+
const retried = await fetchDriveCommentPages({
|
|
4731
|
+
...params,
|
|
4732
|
+
kind: "replies"
|
|
4733
|
+
});
|
|
4934
4734
|
if (retried.items.length > 0) {
|
|
4935
|
-
params.logger?.(`feishu[${params.accountId}]: fetched retried comment replies comment=${params.commentId} attempt=${attempt} count=${retried.items.length} log_ids=${
|
|
4735
|
+
params.logger?.(`feishu[${params.accountId}]: fetched retried comment replies comment=${params.commentId} attempt=${attempt} count=${retried.items.length} log_ids=${JSON.stringify(retried.logIds)} summary=${summarizeCommentRepliesForLog(retried.items)}`);
|
|
4936
4736
|
replies = retried.items;
|
|
4937
4737
|
}
|
|
4938
4738
|
fetchedMatchedReply = replies.find((reply) => reply.reply_id?.trim() === params.replyId);
|
|
@@ -4940,12 +4740,12 @@ async function fetchDriveCommentContext(params) {
|
|
|
4940
4740
|
}
|
|
4941
4741
|
}
|
|
4942
4742
|
const rootReply = replies[0] ?? embeddedReplies[0];
|
|
4943
|
-
const targetReply = params.replyId ? embeddedTargetReply ?? fetchedMatchedReply
|
|
4743
|
+
const targetReply = params.replyId ? embeddedTargetReply ?? fetchedMatchedReply : replies.at(-1) ?? embeddedTargetReply ?? rootReply;
|
|
4944
4744
|
const matchSource = params.replyId ? embeddedTargetReply ? "embedded" : fetchedMatchedReply ? "fetched" : "miss" : targetReply === rootReply ? "fallback_root" : targetReply === embeddedTargetReply ? "embedded_latest" : "fetched_latest";
|
|
4945
|
-
params.logger?.(`feishu[${params.accountId}]: comment reply resolution comment=${params.commentId} requested_reply=${params.replyId ?? "none"} match_source=${matchSource} root=${
|
|
4745
|
+
params.logger?.(`feishu[${params.accountId}]: comment reply resolution comment=${params.commentId} requested_reply=${params.replyId ?? "none"} match_source=${matchSource} root=${JSON.stringify({
|
|
4946
4746
|
reply_id: rootReply?.reply_id,
|
|
4947
4747
|
text_len: extractReplyText(rootReply)?.length ?? 0
|
|
4948
|
-
})} target=${
|
|
4748
|
+
})} target=${JSON.stringify({
|
|
4949
4749
|
reply_id: targetReply?.reply_id,
|
|
4950
4750
|
text_len: extractReplyText(targetReply)?.length ?? 0
|
|
4951
4751
|
})}`);
|
|
@@ -4962,28 +4762,31 @@ async function fetchDriveCommentContext(params) {
|
|
|
4962
4762
|
logger: params.logger,
|
|
4963
4763
|
accountId: params.accountId
|
|
4964
4764
|
};
|
|
4965
|
-
const
|
|
4966
|
-
|
|
4967
|
-
reply
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4765
|
+
const normalizedBotOpenIds = new Set(normalizeTrimmedStringList(Array.from(params.botOpenIds ?? [])));
|
|
4766
|
+
const resolvedReplies = await Promise.all(replies.map(async (reply) => {
|
|
4767
|
+
const userId = normalizeOptionalString(reply.user_id);
|
|
4768
|
+
return {
|
|
4769
|
+
replyId: normalizeOptionalString(reply.reply_id),
|
|
4770
|
+
userId,
|
|
4771
|
+
createTime: typeof reply.create_time === "number" ? reply.create_time : void 0,
|
|
4772
|
+
isBotAuthored: userId !== void 0 && normalizedBotOpenIds.has(userId),
|
|
4773
|
+
content: await resolveParsedCommentContent({
|
|
4774
|
+
...contentContext,
|
|
4775
|
+
elements: isRecord(reply.content) ? reply.content.elements : void 0
|
|
4776
|
+
})
|
|
4777
|
+
};
|
|
4975
4778
|
}));
|
|
4779
|
+
resolvedReplies.sort((left, right) => compareCommentTimelineEntries(left, right, (reply) => reply.replyId));
|
|
4976
4780
|
const rootReplyContext = resolvedReplies.find((reply) => reply.replyId === normalizeOptionalString(rootReply?.reply_id)) ?? resolvedReplies[0];
|
|
4977
4781
|
const targetReplyContext = resolvedReplies.find((reply) => reply.replyId === normalizeOptionalString(targetReply?.reply_id)) ?? (params.replyId ? void 0 : resolvedReplies.at(-1) ?? rootReplyContext);
|
|
4978
4782
|
let wholeCommentTimeline = [];
|
|
4979
4783
|
if (commentCard?.is_whole === true) {
|
|
4980
|
-
const wholeComments = (await
|
|
4784
|
+
const wholeComments = (await fetchDriveCommentPages({
|
|
4981
4785
|
...params,
|
|
4982
|
-
|
|
4786
|
+
kind: "whole-comments"
|
|
4983
4787
|
})).items.filter((comment) => comment.is_whole === true);
|
|
4984
4788
|
wholeCommentTimeline = await Promise.all(wholeComments.map(async (comment) => {
|
|
4985
4789
|
const rootWholeReply = comment.reply_list?.replies?.[0];
|
|
4986
|
-
const normalizedBotOpenIds = new Set(normalizeTrimmedStringList(Array.from(params.botOpenIds ?? [])));
|
|
4987
4790
|
const content = await resolveParsedCommentContent({
|
|
4988
4791
|
...contentContext,
|
|
4989
4792
|
elements: isRecord(rootWholeReply?.content) ? rootWholeReply.content.elements : void 0
|
|
@@ -4993,17 +4796,11 @@ async function fetchDriveCommentContext(params) {
|
|
|
4993
4796
|
commentId: normalizeOptionalString(comment.comment_id) ?? "",
|
|
4994
4797
|
userId: commentUserId,
|
|
4995
4798
|
createTime: typeof comment.create_time === "number" ? comment.create_time : typeof rootWholeReply?.create_time === "number" ? rootWholeReply.create_time : void 0,
|
|
4996
|
-
isBotAuthored:
|
|
4799
|
+
isBotAuthored: commentUserId !== void 0 && normalizedBotOpenIds.has(commentUserId),
|
|
4997
4800
|
content
|
|
4998
4801
|
};
|
|
4999
4802
|
}));
|
|
5000
|
-
wholeCommentTimeline = wholeCommentTimeline.filter((entry) => Boolean(entry.commentId)).toSorted((left, right) => compareCommentTimelineEntries(
|
|
5001
|
-
createTime: left.createTime,
|
|
5002
|
-
stableId: left.commentId
|
|
5003
|
-
}, {
|
|
5004
|
-
createTime: right.createTime,
|
|
5005
|
-
stableId: right.commentId
|
|
5006
|
-
}));
|
|
4803
|
+
wholeCommentTimeline = wholeCommentTimeline.filter((entry) => Boolean(entry.commentId)).toSorted((left, right) => compareCommentTimelineEntries(left, right, (entry) => entry.commentId));
|
|
5007
4804
|
}
|
|
5008
4805
|
const currentWholeCommentIndex = wholeCommentTimeline.findIndex((entry) => entry.commentId === params.commentId);
|
|
5009
4806
|
return {
|
|
@@ -5042,7 +4839,7 @@ function buildDriveCommentSurfacePrompt(params) {
|
|
|
5042
4839
|
if (params.documentUrl) lines.push(`- url=${params.documentUrl}`);
|
|
5043
4840
|
lines.push(`Event type: ${params.noticeType}`, `file_token: ${params.fileToken}`, `file_type: ${params.fileType}`, `comment_id: ${params.commentId}`);
|
|
5044
4841
|
if (params.isWholeComment === true) lines.push("This is a whole-document comment.");
|
|
5045
|
-
if (params.replyId
|
|
4842
|
+
if (params.replyId) lines.push(`reply_id: ${params.replyId}`);
|
|
5046
4843
|
if (params.targetReplyContent?.semanticText) lines.push(`Current user comment semantic text: ${formatPromptTextValue(params.targetReplyContent.semanticText)}`);
|
|
5047
4844
|
if (params.targetReplyContent?.botMentioned) lines.push("Bot routing mention detected in the current user comment. Treat that mention as routing only, not task content.");
|
|
5048
4845
|
const nonBotMentions = (params.targetReplyContent?.mentions ?? []).filter((mention) => !mention.isBotMention).map((mention) => mention.displayText);
|
|
@@ -5060,8 +4857,7 @@ function buildDriveCommentSurfacePrompt(params) {
|
|
|
5060
4857
|
entries: params.wholeCommentTimeline,
|
|
5061
4858
|
currentCommentId: params.commentId
|
|
5062
4859
|
}));
|
|
5063
|
-
|
|
5064
|
-
if (params.nearestBotWholeCommentBefore) lines.push(`Nearest bot-authored whole-comment before the current comment: comment_id=${params.nearestBotWholeCommentBefore.commentId} text=${formatPromptTextValue(params.nearestBotWholeCommentBefore.content.semanticText ?? params.nearestBotWholeCommentBefore.content.plainText)}`);
|
|
4860
|
+
for (const [direction, entry] of [["after", params.nearestBotWholeCommentAfter], ["before", params.nearestBotWholeCommentBefore]]) if (entry) lines.push(`Nearest bot-authored whole-comment ${direction} the current comment: comment_id=${entry.commentId} text=${formatPromptTextValue(entry.content.semanticText ?? entry.content.plainText)}`);
|
|
5065
4861
|
lines.push("For this whole-document comment, use the whole-comment timeline above as the primary source for phrases like 'just now', 'previous result', 'that summary', or 'write it back'.", "Document-level session history is auxiliary background only. Do not resolve whole-comment follow-ups by blindly using the most recent document-session output.");
|
|
5066
4862
|
}
|
|
5067
4863
|
lines.push("This is a Feishu document comment thread.", "It is not a Feishu IM chat.", "Your final text reply will be posted to the current comment thread automatically.", "Use the thread timeline above as the main context for follow-up requests.", "Do not use another comment card or document-session output as the main reference.", "If you need comment thread context, use the available Feishu drive comment-list actions.", "If you modify the document, post a user-visible follow-up in the comment thread.", "Use an available Feishu drive reply-comment or add-comment action for that follow-up.", "Whole-document comments do not support direct replies.", "For whole-document comments, use the Feishu drive add-comment action when available.", "Only treat URLs listed under \"Referenced documents from current user comment\" as structured Feishu document references.", "URLs that appear only in comment text are plain links unless you verify them.", "If the user asks about a linked Feishu document or wiki page, treat that linked document as the read target.", "If the user asks you to use a linked document as guidance, treat the linked document as the reference source and the current commented document as the edit target.", "If a referenced document resolves to the same file_token and file_type as the current commented document, treat it as the current document.", "If the user asks you to modify document content, you must use an available Feishu document tool to make the change.", "Do not reply with only \"done\", \"I'll handle it\", or a restated plan without calling tools.", "If the comment quotes document content, treat the quoted content as the main anchor.", "For requests like \"insert xxx below this content\", locate the quoted content first, then edit the document.", "For requests like \"summarize the content below\", \"explain this section\", or \"continue writing from here\", use the quoted content as the main target.", "If the quote is not enough, use available Feishu document read or list-blocks actions to read nearby context.", "Do not guess document content from the comment alone.", "Do not give a vague answer before reading enough context.", "Unless the user asks for the whole document, handle only the local content around the quoted anchor.", "If document edits are involved, read the anchor first, then edit.", "If the edit fails or the anchor cannot be found, say so clearly.", "If this is a reading task, such as summarization, explanation, or extraction, you may output the final answer directly after confirming the context.", "Use the same language as the user's comment or reply, unless the user asks for another language.", "Use plain text only.", "Do not use Markdown.", "Do not use headings.", "Do not use bullet lists.", "Do not use numbered lists.", "Do not use tables.", "Do not use blockquotes.", "Do not use code blocks.", "Do not show reasoning.", "Do not show analysis.", "Do not show chain-of-thought.", "Do not show scratch work.", "Do not describe your plan.", "Do not describe your steps.", "Do not describe tool use.", "Do not start with phrases like \"I will\", \"I’ll first\", \"I need to\", \"The user wants\", or \"I have updated\".", "Output only the final user-facing reply.", "If you already sent the user-visible reply with a Feishu drive comment action, output exactly NO_REPLY.", "If no user-visible reply is needed, output exactly NO_REPLY.", "Be concise.", "Do not omit requested content.");
|
|
@@ -5098,7 +4894,7 @@ async function resolveDriveCommentEventTurn(params) {
|
|
|
5098
4894
|
return null;
|
|
5099
4895
|
}
|
|
5100
4896
|
const context = await fetchDriveCommentContext({
|
|
5101
|
-
client: createClient ? createClient(account ?? { accountId }) : createFeishuClient((await import("./doctor-contract-
|
|
4897
|
+
client: createClient ? createClient(account ?? { accountId }) : createFeishuClient((await import("./doctor-contract-oIpUWtNO.mjs").then((n) => n.l)).resolveFeishuAccount({
|
|
5102
4898
|
cfg,
|
|
5103
4899
|
accountId
|
|
5104
4900
|
})),
|
|
@@ -5146,8 +4942,11 @@ async function resolveDriveCommentEventTurn(params) {
|
|
|
5146
4942
|
function parseFeishuDriveCommentNoticeEventPayload(value) {
|
|
5147
4943
|
if (!isRecord(value) || !isRecord(value.notice_meta)) return null;
|
|
5148
4944
|
const noticeMeta = value.notice_meta;
|
|
5149
|
-
const
|
|
5150
|
-
|
|
4945
|
+
const readUserId = (userIdValue) => isRecord(userIdValue) ? {
|
|
4946
|
+
open_id: readStringValue(userIdValue.open_id),
|
|
4947
|
+
user_id: readStringValue(userIdValue.user_id),
|
|
4948
|
+
union_id: readStringValue(userIdValue.union_id)
|
|
4949
|
+
} : void 0;
|
|
5151
4950
|
return {
|
|
5152
4951
|
comment_id: readStringValue(value.comment_id),
|
|
5153
4952
|
event_id: readStringValue(value.event_id),
|
|
@@ -5155,17 +4954,9 @@ function parseFeishuDriveCommentNoticeEventPayload(value) {
|
|
|
5155
4954
|
notice_meta: {
|
|
5156
4955
|
file_token: readStringValue(noticeMeta.file_token),
|
|
5157
4956
|
file_type: readStringValue(noticeMeta.file_type),
|
|
5158
|
-
from_user_id:
|
|
5159
|
-
open_id: readStringValue(fromUserId.open_id),
|
|
5160
|
-
user_id: readStringValue(fromUserId.user_id),
|
|
5161
|
-
union_id: readStringValue(fromUserId.union_id)
|
|
5162
|
-
} : void 0,
|
|
4957
|
+
from_user_id: readUserId(noticeMeta.from_user_id),
|
|
5163
4958
|
notice_type: readStringValue(noticeMeta.notice_type),
|
|
5164
|
-
to_user_id:
|
|
5165
|
-
open_id: readStringValue(toUserId.open_id),
|
|
5166
|
-
user_id: readStringValue(toUserId.user_id),
|
|
5167
|
-
union_id: readStringValue(toUserId.union_id)
|
|
5168
|
-
} : void 0
|
|
4959
|
+
to_user_id: readUserId(noticeMeta.to_user_id)
|
|
5169
4960
|
},
|
|
5170
4961
|
reply_id: readStringValue(value.reply_id),
|
|
5171
4962
|
timestamp: readStringValue(value.timestamp),
|
|
@@ -5492,7 +5283,7 @@ function createFeishuDriveCommentNoticeHandler(params) {
|
|
|
5492
5283
|
return async (data) => {
|
|
5493
5284
|
const ingressLifecycle = params.resolveIngressLifecycle?.(data);
|
|
5494
5285
|
if (!ingressLifecycle) {
|
|
5495
|
-
await runFeishuHandler(
|
|
5286
|
+
await runFeishuHandler(() => handleNotice(data));
|
|
5496
5287
|
return;
|
|
5497
5288
|
}
|
|
5498
5289
|
const { lifecycle, settle } = buildFeishuFlushIngressLifecycle([{ lifecycle: ingressLifecycle }]);
|
|
@@ -5531,18 +5322,12 @@ function mergeFeishuDebounceMentions(entries) {
|
|
|
5531
5322
|
}
|
|
5532
5323
|
function dedupeFeishuDebounceEntriesByDedupeKey(entries) {
|
|
5533
5324
|
const seen = /* @__PURE__ */ new Set();
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
}
|
|
5541
|
-
if (seen.has(dedupeKey)) continue;
|
|
5542
|
-
seen.add(dedupeKey);
|
|
5543
|
-
deduped.push(entry);
|
|
5544
|
-
}
|
|
5545
|
-
return deduped;
|
|
5325
|
+
return entries.filter(({ messageDedupeKey }) => {
|
|
5326
|
+
if (!messageDedupeKey) return true;
|
|
5327
|
+
if (seen.has(messageDedupeKey)) return false;
|
|
5328
|
+
seen.add(messageDedupeKey);
|
|
5329
|
+
return true;
|
|
5330
|
+
});
|
|
5546
5331
|
}
|
|
5547
5332
|
function resolveFeishuDebounceMentions(params) {
|
|
5548
5333
|
const { entries, botOpenId } = params;
|
|
@@ -5566,7 +5351,7 @@ function createFeishuMessageReceiveHandler({ cfg, channelRuntime, accountId, run
|
|
|
5566
5351
|
const enqueue = createSequentialQueue({ onTaskTimeout: (key, timeoutMs) => {
|
|
5567
5352
|
log(`feishu[${accountId}]: per-chat task exceeded ${timeoutMs}ms cap (key=${key}); evicting from queue so later same-key messages can proceed (#70133)`);
|
|
5568
5353
|
} });
|
|
5569
|
-
const dispatchFeishuMessage = async (event, messageDedupeKey, processingClaim, turnAdoptionLifecycle, preparedContent) => {
|
|
5354
|
+
const dispatchFeishuMessage = async ({ event, messageDedupeKey, processingClaim }, turnAdoptionLifecycle, preparedContent) => {
|
|
5570
5355
|
const sequentialKey = resolveSequentialKey({
|
|
5571
5356
|
accountId,
|
|
5572
5357
|
event,
|
|
@@ -5649,7 +5434,7 @@ function createFeishuMessageReceiveHandler({ cfg, channelRuntime, accountId, run
|
|
|
5649
5434
|
}
|
|
5650
5435
|
try {
|
|
5651
5436
|
if (activeEntries.length === 1) {
|
|
5652
|
-
await dispatchFeishuMessage(last
|
|
5437
|
+
await dispatchFeishuMessage(last, admissionLifecycle);
|
|
5653
5438
|
await settle();
|
|
5654
5439
|
return;
|
|
5655
5440
|
}
|
|
@@ -5669,12 +5454,15 @@ function createFeishuMessageReceiveHandler({ cfg, channelRuntime, accountId, run
|
|
|
5669
5454
|
botOpenId: getBotOpenId(accountId)
|
|
5670
5455
|
});
|
|
5671
5456
|
await dispatchFeishuMessage({
|
|
5672
|
-
...dispatchEntry
|
|
5673
|
-
|
|
5674
|
-
...dispatchEntry.event
|
|
5675
|
-
|
|
5457
|
+
...dispatchEntry,
|
|
5458
|
+
event: {
|
|
5459
|
+
...dispatchEntry.event,
|
|
5460
|
+
message: {
|
|
5461
|
+
...dispatchEntry.event.message,
|
|
5462
|
+
mentions: mergedMentions ?? dispatchEntry.event.message.mentions
|
|
5463
|
+
}
|
|
5676
5464
|
}
|
|
5677
|
-
},
|
|
5465
|
+
}, admissionLifecycle, combinedText);
|
|
5678
5466
|
await settle();
|
|
5679
5467
|
} catch (err) {
|
|
5680
5468
|
await admissionLifecycle.onAbandoned();
|
|
@@ -5808,14 +5596,6 @@ function buildFeishuWebhookEnvelope(req, payload) {
|
|
|
5808
5596
|
for (const [key, value] of Object.entries(payload)) if (!BLOCKED_FEISHU_WEBHOOK_PAYLOAD_KEYS.has(key)) envelope[key] = value;
|
|
5809
5597
|
return envelope;
|
|
5810
5598
|
}
|
|
5811
|
-
function parseFeishuWebhookPayload(rawBody) {
|
|
5812
|
-
try {
|
|
5813
|
-
const parsed = JSON.parse(rawBody);
|
|
5814
|
-
return isRecord(parsed) ? parsed : null;
|
|
5815
|
-
} catch {
|
|
5816
|
-
return null;
|
|
5817
|
-
}
|
|
5818
|
-
}
|
|
5819
5599
|
function isFeishuWebhookTimestampFresh(timestamp) {
|
|
5820
5600
|
const parsed = Number.parseInt(timestamp, 10);
|
|
5821
5601
|
if (!Number.isFinite(parsed)) return false;
|
|
@@ -6077,8 +5857,8 @@ async function handleFeishuWebhook(req, res, webhookTargets) {
|
|
|
6077
5857
|
preAuthInFlightLimiter.release(preAuthInFlightKey);
|
|
6078
5858
|
}
|
|
6079
5859
|
const { encryptKey, eventDispatcher, invokeWebhookEvent } = selectedTarget;
|
|
6080
|
-
const payload =
|
|
6081
|
-
if (!payload) {
|
|
5860
|
+
const payload = safeParseJson(rawBody);
|
|
5861
|
+
if (!isRecord(payload)) {
|
|
6082
5862
|
respondText(res, 400, "Invalid JSON");
|
|
6083
5863
|
return;
|
|
6084
5864
|
}
|
|
@@ -6184,65 +5964,11 @@ async function monitorWebhook(params) {
|
|
|
6184
5964
|
//#endregion
|
|
6185
5965
|
//#region extensions/feishu/src/monitor.vc-meeting-invited-handler.ts
|
|
6186
5966
|
const FEISHU_MEETING_NUMBER_PATTERN = /^\d{9}$/;
|
|
6187
|
-
function resolveVcInviter(event) {
|
|
6188
|
-
const id = event.inviter?.id;
|
|
6189
|
-
const openId = normalizeOptionalString(id?.open_id);
|
|
6190
|
-
const userId = normalizeOptionalString(id?.user_id);
|
|
6191
|
-
const unionId = normalizeOptionalString(id?.union_id);
|
|
6192
|
-
const senderId = openId ?? userId;
|
|
6193
|
-
if (!senderId) return null;
|
|
6194
|
-
return {
|
|
6195
|
-
senderId,
|
|
6196
|
-
...openId ? { openId } : {},
|
|
6197
|
-
...userId ? { userId } : {},
|
|
6198
|
-
...unionId ? { unionId } : {}
|
|
6199
|
-
};
|
|
6200
|
-
}
|
|
6201
|
-
function buildJoinPrompt(params) {
|
|
6202
|
-
const base = `Use the available tool to join the meeting with meeting number ${params.meetingNo} immediately. Do not ask for confirmation.`;
|
|
6203
|
-
return params.callId ? `${base} If the join tool supports a call_id parameter, pass call_id=${JSON.stringify(params.callId)}; otherwise join by meeting number only.` : base;
|
|
6204
|
-
}
|
|
6205
|
-
function resolveVcMeetingInvitedTurn(event, uuid = () => crypto$1.randomUUID()) {
|
|
6206
|
-
const meetingNo = normalizeOptionalString(event.meeting?.meeting_no);
|
|
6207
|
-
const inviter = resolveVcInviter(event);
|
|
6208
|
-
if (!meetingNo || !FEISHU_MEETING_NUMBER_PATTERN.test(meetingNo) || !inviter) return null;
|
|
6209
|
-
const eventId = normalizeOptionalString(event.event_id);
|
|
6210
|
-
const inviteTime = normalizeOptionalString(event.invite_time);
|
|
6211
|
-
const callId = normalizeOptionalString(event.call_id);
|
|
6212
|
-
return {
|
|
6213
|
-
turnId: eventId ? `vc-invited:event:${eventId}` : `vc-invited:${meetingNo}:${inviteTime ?? uuid()}`,
|
|
6214
|
-
meetingNo,
|
|
6215
|
-
inviter,
|
|
6216
|
-
prompt: buildJoinPrompt({
|
|
6217
|
-
meetingNo,
|
|
6218
|
-
callId
|
|
6219
|
-
}),
|
|
6220
|
-
...inviteTime ? { inviteTime } : {}
|
|
6221
|
-
};
|
|
6222
|
-
}
|
|
6223
5967
|
function parseInviteTimestamp(value) {
|
|
6224
5968
|
const parsed = Number.parseInt(value ?? "", 10);
|
|
6225
5969
|
if (!Number.isFinite(parsed) || parsed <= 0) return Date.now();
|
|
6226
5970
|
return parsed < 1e10 ? parsed * 1e3 : parsed;
|
|
6227
5971
|
}
|
|
6228
|
-
function buildSyntheticMessageEvent(turn) {
|
|
6229
|
-
return {
|
|
6230
|
-
sender: { sender_id: {
|
|
6231
|
-
...turn.inviter.openId ? { open_id: turn.inviter.openId } : {},
|
|
6232
|
-
...turn.inviter.userId ? { user_id: turn.inviter.userId } : {},
|
|
6233
|
-
...turn.inviter.unionId ? { union_id: turn.inviter.unionId } : {}
|
|
6234
|
-
} },
|
|
6235
|
-
message: {
|
|
6236
|
-
message_id: turn.turnId,
|
|
6237
|
-
chat_id: turn.inviter.senderId,
|
|
6238
|
-
chat_type: "p2p",
|
|
6239
|
-
message_type: "text",
|
|
6240
|
-
content: JSON.stringify({ text: turn.prompt }),
|
|
6241
|
-
create_time: String(parseInviteTimestamp(turn.inviteTime)),
|
|
6242
|
-
suppress_reply_target: true
|
|
6243
|
-
}
|
|
6244
|
-
};
|
|
6245
|
-
}
|
|
6246
5972
|
function createVcInviteAdoption(params) {
|
|
6247
5973
|
const cancellation = new AbortController();
|
|
6248
5974
|
const settled = createDeferred();
|
|
@@ -6289,42 +6015,6 @@ function createVcInviteAdoption(params) {
|
|
|
6289
6015
|
}
|
|
6290
6016
|
};
|
|
6291
6017
|
}
|
|
6292
|
-
async function dispatchVcMeetingInvitedTurn(params) {
|
|
6293
|
-
params.runtime?.log?.(`feishu[${params.accountId}]: vc meeting invited, dispatching synthetic p2p message sender=${params.turn.inviter.senderId} meeting_no=${params.turn.meetingNo}`);
|
|
6294
|
-
const event = setFeishuSyntheticDirectPreDispatchTarget(buildSyntheticMessageEvent(params.turn), `user:${params.turn.inviter.senderId}`);
|
|
6295
|
-
const claim = await claimUnprocessedFeishuMessage({
|
|
6296
|
-
messageId: resolveFeishuMessageDedupeKey(event),
|
|
6297
|
-
namespace: params.accountId,
|
|
6298
|
-
log: params.runtime?.log ?? console.log
|
|
6299
|
-
});
|
|
6300
|
-
if (claim.kind !== "claimed") return;
|
|
6301
|
-
if (params.abortSignal?.aborted || params.isAccountActive?.() === false) {
|
|
6302
|
-
claim.handle.release({ error: /* @__PURE__ */ new Error("Feishu account stopped before VC dispatch") });
|
|
6303
|
-
return;
|
|
6304
|
-
}
|
|
6305
|
-
const adoption = createVcInviteAdoption({
|
|
6306
|
-
claim: claim.handle,
|
|
6307
|
-
abortSignal: params.abortSignal,
|
|
6308
|
-
isAccountActive: params.isAccountActive,
|
|
6309
|
-
trackTask: params.trackTask
|
|
6310
|
-
});
|
|
6311
|
-
try {
|
|
6312
|
-
await handleFeishuMessage({
|
|
6313
|
-
trackTask: params.trackTask,
|
|
6314
|
-
cfg: params.cfg,
|
|
6315
|
-
accountId: params.accountId,
|
|
6316
|
-
event,
|
|
6317
|
-
runtime: params.runtime,
|
|
6318
|
-
channelRuntime: params.channelRuntime,
|
|
6319
|
-
turnAdoptionLifecycle: adoption.lifecycle
|
|
6320
|
-
});
|
|
6321
|
-
} catch (error) {
|
|
6322
|
-
await adoption.lifecycle.onAbandoned();
|
|
6323
|
-
throw error;
|
|
6324
|
-
} finally {
|
|
6325
|
-
await adoption.finish();
|
|
6326
|
-
}
|
|
6327
|
-
}
|
|
6328
6018
|
function createFeishuVcMeetingInvitedHandler(params) {
|
|
6329
6019
|
const { cfg, accountId, runtime, fireAndForget, autoJoin } = params;
|
|
6330
6020
|
const log = runtime?.log ?? console.log;
|
|
@@ -6336,21 +6026,72 @@ function createFeishuVcMeetingInvitedHandler(params) {
|
|
|
6336
6026
|
return;
|
|
6337
6027
|
}
|
|
6338
6028
|
try {
|
|
6339
|
-
const
|
|
6340
|
-
|
|
6029
|
+
const invite = data;
|
|
6030
|
+
const meetingNo = normalizeOptionalString(invite.meeting?.meeting_no);
|
|
6031
|
+
const id = invite.inviter?.id;
|
|
6032
|
+
const openId = normalizeOptionalString(id?.open_id);
|
|
6033
|
+
const userId = normalizeOptionalString(id?.user_id);
|
|
6034
|
+
const unionId = normalizeOptionalString(id?.union_id);
|
|
6035
|
+
const senderId = openId ?? userId;
|
|
6036
|
+
if (!meetingNo || !FEISHU_MEETING_NUMBER_PATTERN.test(meetingNo) || !senderId) {
|
|
6341
6037
|
log(`feishu[${accountId}]: vc meeting invited event has invalid meeting_no or inviter identity, skipping`);
|
|
6342
6038
|
return;
|
|
6343
6039
|
}
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6040
|
+
const eventId = normalizeOptionalString(invite.event_id);
|
|
6041
|
+
const inviteTime = normalizeOptionalString(invite.invite_time);
|
|
6042
|
+
const callId = normalizeOptionalString(invite.call_id);
|
|
6043
|
+
const turnId = eventId ? `vc-invited:event:${eventId}` : `vc-invited:${meetingNo}:${inviteTime ?? crypto$1.randomUUID()}`;
|
|
6044
|
+
const basePrompt = `Use the available tool to join the meeting with meeting number ${meetingNo} immediately. Do not ask for confirmation.`;
|
|
6045
|
+
const prompt = callId ? `${basePrompt} If the join tool supports a call_id parameter, pass call_id=${JSON.stringify(callId)}; otherwise join by meeting number only.` : basePrompt;
|
|
6046
|
+
runtime?.log?.(`feishu[${accountId}]: vc meeting invited, dispatching synthetic p2p message sender=${senderId} meeting_no=${meetingNo}`);
|
|
6047
|
+
const event = setFeishuSyntheticDirectPreDispatchTarget({
|
|
6048
|
+
sender: { sender_id: {
|
|
6049
|
+
...openId ? { open_id: openId } : {},
|
|
6050
|
+
...userId ? { user_id: userId } : {},
|
|
6051
|
+
...unionId ? { union_id: unionId } : {}
|
|
6052
|
+
} },
|
|
6053
|
+
message: {
|
|
6054
|
+
message_id: turnId,
|
|
6055
|
+
chat_id: senderId,
|
|
6056
|
+
chat_type: "p2p",
|
|
6057
|
+
message_type: "text",
|
|
6058
|
+
content: JSON.stringify({ text: prompt }),
|
|
6059
|
+
create_time: String(parseInviteTimestamp(inviteTime)),
|
|
6060
|
+
suppress_reply_target: true
|
|
6061
|
+
}
|
|
6062
|
+
}, `user:${senderId}`);
|
|
6063
|
+
const claim = await claimUnprocessedFeishuMessage({
|
|
6064
|
+
messageId: resolveFeishuMessageDedupeKey(event),
|
|
6065
|
+
namespace: accountId,
|
|
6066
|
+
log
|
|
6067
|
+
});
|
|
6068
|
+
if (claim.kind !== "claimed") return;
|
|
6069
|
+
if (params.abortSignal?.aborted || params.isAccountActive?.() === false) {
|
|
6070
|
+
claim.handle.release({ error: /* @__PURE__ */ new Error("Feishu account stopped before VC dispatch") });
|
|
6071
|
+
return;
|
|
6072
|
+
}
|
|
6073
|
+
const adoption = createVcInviteAdoption({
|
|
6074
|
+
claim: claim.handle,
|
|
6351
6075
|
abortSignal: params.abortSignal,
|
|
6352
|
-
isAccountActive: params.isAccountActive
|
|
6076
|
+
isAccountActive: params.isAccountActive,
|
|
6077
|
+
trackTask: params.trackTask
|
|
6353
6078
|
});
|
|
6079
|
+
try {
|
|
6080
|
+
await handleFeishuMessage({
|
|
6081
|
+
trackTask: params.trackTask,
|
|
6082
|
+
cfg,
|
|
6083
|
+
accountId,
|
|
6084
|
+
event,
|
|
6085
|
+
runtime,
|
|
6086
|
+
channelRuntime: params.channelRuntime,
|
|
6087
|
+
turnAdoptionLifecycle: adoption.lifecycle
|
|
6088
|
+
});
|
|
6089
|
+
} catch (dispatchError) {
|
|
6090
|
+
await adoption.lifecycle.onAbandoned();
|
|
6091
|
+
throw dispatchError;
|
|
6092
|
+
} finally {
|
|
6093
|
+
await adoption.finish();
|
|
6094
|
+
}
|
|
6354
6095
|
} catch (err) {
|
|
6355
6096
|
error(`feishu[${accountId}]: error handling vc meeting invited event: ${String(err)}`);
|
|
6356
6097
|
}
|
|
@@ -6382,7 +6123,7 @@ async function resolveReactionSyntheticEvent(params) {
|
|
|
6382
6123
|
const senderUserId = event.user_id?.user_id?.trim();
|
|
6383
6124
|
const senderId = senderOpenId || senderUserId;
|
|
6384
6125
|
if (!emoji || !messageId || !senderId) return null;
|
|
6385
|
-
const { resolveFeishuAccount } = await import("./doctor-contract-
|
|
6126
|
+
const { resolveFeishuAccount } = await import("./doctor-contract-oIpUWtNO.mjs").then((n) => n.l);
|
|
6386
6127
|
const reactionNotifications = resolveFeishuAccount({
|
|
6387
6128
|
cfg,
|
|
6388
6129
|
accountId
|
|
@@ -6485,7 +6226,7 @@ function parseFeishuCardActionEventPayload(value) {
|
|
|
6485
6226
|
};
|
|
6486
6227
|
}
|
|
6487
6228
|
function registerEventHandlers(eventDispatcher, context) {
|
|
6488
|
-
const { cfg, accountId, channelRuntime, runtime, chatHistories, fireAndForget
|
|
6229
|
+
const { cfg, accountId, channelRuntime, runtime, chatHistories, fireAndForget } = context;
|
|
6489
6230
|
const log = runtime?.log ?? console.log;
|
|
6490
6231
|
const error = runtime?.error ?? console.error;
|
|
6491
6232
|
const runFeishuHandler = async (params) => {
|
|
@@ -6522,75 +6263,35 @@ function registerEventHandlers(eventDispatcher, context) {
|
|
|
6522
6263
|
});
|
|
6523
6264
|
}
|
|
6524
6265
|
});
|
|
6266
|
+
const handleBotMembership = async (data, action) => {
|
|
6267
|
+
try {
|
|
6268
|
+
const chatId = action === "added" ? parseFeishuBotAddedEventPayload(data)?.chat_id : parseFeishuBotRemovedChatId(data);
|
|
6269
|
+
if (chatId) log(`feishu[${accountId}]: bot ${action === "added" ? "added to" : "removed from"} chat ${chatId}`);
|
|
6270
|
+
} catch (err) {
|
|
6271
|
+
error(`feishu[${accountId}]: error handling bot ${action} event: ${String(err)}`);
|
|
6272
|
+
}
|
|
6273
|
+
};
|
|
6525
6274
|
eventDispatcher.register({
|
|
6526
6275
|
"im.message.receive_v1": createFeishuMessageReceiveHandler({
|
|
6527
|
-
|
|
6528
|
-
channelRuntime,
|
|
6529
|
-
accountId,
|
|
6530
|
-
runtime,
|
|
6531
|
-
chatHistories,
|
|
6532
|
-
fireAndForget,
|
|
6533
|
-
isAccountActive: context.isAccountActive,
|
|
6534
|
-
trackTask: context.trackTask,
|
|
6276
|
+
...context,
|
|
6535
6277
|
handleMessage: handleFeishuMessage,
|
|
6536
6278
|
resolveDebounceText: ({ event, botOpenId }) => parseFeishuMessageEvent(event, botOpenId).content,
|
|
6537
6279
|
hasProcessedMessage: hasProcessedFeishuMessage,
|
|
6538
6280
|
getBotOpenId: (id) => botOpenIds.get(id),
|
|
6539
|
-
resolveSequentialKey: getFeishuSequentialKey
|
|
6540
|
-
resolveIngressLifecycle: context.resolveIngressLifecycle,
|
|
6541
|
-
...context.statusSink ? { statusSink: context.statusSink } : {}
|
|
6281
|
+
resolveSequentialKey: getFeishuSequentialKey
|
|
6542
6282
|
}),
|
|
6543
6283
|
"im.message.message_read_v1": async () => {},
|
|
6544
6284
|
"im.chat.access_event.bot_p2p_chat_entered_v1": async () => {},
|
|
6545
|
-
"im.chat.member.bot.added_v1":
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
if (!event) return;
|
|
6549
|
-
log(`feishu[${accountId}]: bot added to chat ${event.chat_id}`);
|
|
6550
|
-
} catch (err) {
|
|
6551
|
-
error(`feishu[${accountId}]: error handling bot added event: ${String(err)}`);
|
|
6552
|
-
}
|
|
6553
|
-
},
|
|
6554
|
-
"im.chat.member.bot.deleted_v1": async (data) => {
|
|
6555
|
-
try {
|
|
6556
|
-
const chatId = parseFeishuBotRemovedChatId(data);
|
|
6557
|
-
if (!chatId) return;
|
|
6558
|
-
log(`feishu[${accountId}]: bot removed from chat ${chatId}`);
|
|
6559
|
-
} catch (err) {
|
|
6560
|
-
error(`feishu[${accountId}]: error handling bot removed event: ${String(err)}`);
|
|
6561
|
-
}
|
|
6562
|
-
},
|
|
6563
|
-
"drive.notice.comment_add_v1": createFeishuDriveCommentNoticeHandler({
|
|
6564
|
-
cfg,
|
|
6565
|
-
accountId,
|
|
6566
|
-
runtime,
|
|
6567
|
-
fireAndForget,
|
|
6568
|
-
abortSignal,
|
|
6569
|
-
resolveIngressLifecycle: context.resolveIngressLifecycle
|
|
6570
|
-
}),
|
|
6285
|
+
"im.chat.member.bot.added_v1": (data) => handleBotMembership(data, "added"),
|
|
6286
|
+
"im.chat.member.bot.deleted_v1": (data) => handleBotMembership(data, "removed"),
|
|
6287
|
+
"drive.notice.comment_add_v1": createFeishuDriveCommentNoticeHandler(context),
|
|
6571
6288
|
"vc.bot.meeting_invited_v1": createFeishuVcMeetingInvitedHandler({
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
runtime,
|
|
6575
|
-
fireAndForget,
|
|
6576
|
-
channelRuntime,
|
|
6577
|
-
autoJoin: context.vcAutoJoin,
|
|
6578
|
-
abortSignal: context.abortSignal,
|
|
6579
|
-
isAccountActive: context.isAccountActive,
|
|
6580
|
-
trackTask: context.trackTask
|
|
6289
|
+
...context,
|
|
6290
|
+
autoJoin: context.vcAutoJoin
|
|
6581
6291
|
}),
|
|
6582
6292
|
"im.message.reaction.created_v1": (data) => handleReaction(data, "created"),
|
|
6583
6293
|
"im.message.reaction.deleted_v1": (data) => handleReaction(data, "deleted"),
|
|
6584
|
-
"application.bot.menu_v6": createFeishuBotMenuHandler(
|
|
6585
|
-
cfg,
|
|
6586
|
-
accountId,
|
|
6587
|
-
runtime,
|
|
6588
|
-
chatHistories,
|
|
6589
|
-
fireAndForget,
|
|
6590
|
-
isAccountActive: context.isAccountActive,
|
|
6591
|
-
trackTask: context.trackTask,
|
|
6592
|
-
channelRuntime
|
|
6593
|
-
}),
|
|
6294
|
+
"application.bot.menu_v6": createFeishuBotMenuHandler(context),
|
|
6594
6295
|
"card.action.trigger": async (data) => {
|
|
6595
6296
|
await runFeishuHandler({
|
|
6596
6297
|
errorMessage: `feishu[${accountId}]: error handling card action`,
|