loudmouth-ai 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -77
- package/dist/build-info.json +3 -3
- package/extensions/package.json +6 -0
- package/package.json +1 -1
- package/skills/autopilot/SKILL.md +179 -0
- package/skills/goals/SKILL.md +189 -0
- package/skills/wordpress/SKILL.md +232 -0
- package/extensions/bluebubbles/clawdbot.plugin.json +0 -11
- package/extensions/bluebubbles/index.ts +0 -20
- package/extensions/bluebubbles/package.json +0 -33
- package/extensions/bluebubbles/src/accounts.ts +0 -80
- package/extensions/bluebubbles/src/actions.test.ts +0 -651
- package/extensions/bluebubbles/src/actions.ts +0 -403
- package/extensions/bluebubbles/src/attachments.test.ts +0 -346
- package/extensions/bluebubbles/src/attachments.ts +0 -282
- package/extensions/bluebubbles/src/channel.ts +0 -399
- package/extensions/bluebubbles/src/chat.test.ts +0 -462
- package/extensions/bluebubbles/src/chat.ts +0 -354
- package/extensions/bluebubbles/src/config-schema.ts +0 -51
- package/extensions/bluebubbles/src/media-send.ts +0 -168
- package/extensions/bluebubbles/src/monitor.test.ts +0 -2140
- package/extensions/bluebubbles/src/monitor.ts +0 -2101
- package/extensions/bluebubbles/src/onboarding.ts +0 -340
- package/extensions/bluebubbles/src/probe.ts +0 -127
- package/extensions/bluebubbles/src/reactions.test.ts +0 -393
- package/extensions/bluebubbles/src/reactions.ts +0 -183
- package/extensions/bluebubbles/src/runtime.ts +0 -14
- package/extensions/bluebubbles/src/send.test.ts +0 -809
- package/extensions/bluebubbles/src/send.ts +0 -418
- package/extensions/bluebubbles/src/targets.test.ts +0 -184
- package/extensions/bluebubbles/src/targets.ts +0 -323
- package/extensions/bluebubbles/src/types.ts +0 -127
- package/extensions/copilot-proxy/README.md +0 -24
- package/extensions/copilot-proxy/clawdbot.plugin.json +0 -11
- package/extensions/copilot-proxy/index.ts +0 -142
- package/extensions/copilot-proxy/package.json +0 -11
- package/extensions/google-antigravity-auth/README.md +0 -24
- package/extensions/google-antigravity-auth/clawdbot.plugin.json +0 -11
- package/extensions/google-antigravity-auth/index.ts +0 -437
- package/extensions/google-antigravity-auth/package.json +0 -11
- package/extensions/google-gemini-cli-auth/README.md +0 -35
- package/extensions/google-gemini-cli-auth/clawdbot.plugin.json +0 -11
- package/extensions/google-gemini-cli-auth/index.ts +0 -91
- package/extensions/google-gemini-cli-auth/oauth.test.ts +0 -228
- package/extensions/google-gemini-cli-auth/oauth.ts +0 -580
- package/extensions/google-gemini-cli-auth/package.json +0 -11
- package/extensions/googlechat/clawdbot.plugin.json +0 -11
- package/extensions/googlechat/index.ts +0 -20
- package/extensions/googlechat/package.json +0 -39
- package/extensions/googlechat/src/accounts.ts +0 -133
- package/extensions/googlechat/src/actions.ts +0 -162
- package/extensions/googlechat/src/api.test.ts +0 -62
- package/extensions/googlechat/src/api.ts +0 -259
- package/extensions/googlechat/src/auth.ts +0 -113
- package/extensions/googlechat/src/channel.ts +0 -580
- package/extensions/googlechat/src/monitor.test.ts +0 -27
- package/extensions/googlechat/src/monitor.ts +0 -900
- package/extensions/googlechat/src/onboarding.ts +0 -278
- package/extensions/googlechat/src/runtime.ts +0 -14
- package/extensions/googlechat/src/targets.test.ts +0 -35
- package/extensions/googlechat/src/targets.ts +0 -55
- package/extensions/googlechat/src/types.config.ts +0 -3
- package/extensions/googlechat/src/types.ts +0 -73
- package/extensions/imessage/clawdbot.plugin.json +0 -11
- package/extensions/imessage/index.ts +0 -18
- package/extensions/imessage/package.json +0 -11
- package/extensions/imessage/src/channel.ts +0 -294
- package/extensions/imessage/src/runtime.ts +0 -14
- package/extensions/line/clawdbot.plugin.json +0 -11
- package/extensions/line/index.ts +0 -20
- package/extensions/line/package.json +0 -29
- package/extensions/line/src/card-command.ts +0 -338
- package/extensions/line/src/channel.logout.test.ts +0 -96
- package/extensions/line/src/channel.sendPayload.test.ts +0 -308
- package/extensions/line/src/channel.ts +0 -773
- package/extensions/line/src/runtime.ts +0 -14
- package/extensions/matrix/CHANGELOG.md +0 -54
- package/extensions/matrix/clawdbot.plugin.json +0 -11
- package/extensions/matrix/index.ts +0 -18
- package/extensions/matrix/package.json +0 -36
- package/extensions/matrix/src/actions.ts +0 -185
- package/extensions/matrix/src/channel.directory.test.ts +0 -56
- package/extensions/matrix/src/channel.ts +0 -417
- package/extensions/matrix/src/config-schema.ts +0 -62
- package/extensions/matrix/src/directory-live.ts +0 -175
- package/extensions/matrix/src/group-mentions.ts +0 -61
- package/extensions/matrix/src/matrix/accounts.test.ts +0 -83
- package/extensions/matrix/src/matrix/accounts.ts +0 -63
- package/extensions/matrix/src/matrix/actions/client.ts +0 -53
- package/extensions/matrix/src/matrix/actions/messages.ts +0 -120
- package/extensions/matrix/src/matrix/actions/pins.ts +0 -70
- package/extensions/matrix/src/matrix/actions/reactions.ts +0 -84
- package/extensions/matrix/src/matrix/actions/room.ts +0 -88
- package/extensions/matrix/src/matrix/actions/summary.ts +0 -77
- package/extensions/matrix/src/matrix/actions/types.ts +0 -84
- package/extensions/matrix/src/matrix/actions.ts +0 -15
- package/extensions/matrix/src/matrix/active-client.ts +0 -11
- package/extensions/matrix/src/matrix/client/config.ts +0 -165
- package/extensions/matrix/src/matrix/client/create-client.ts +0 -127
- package/extensions/matrix/src/matrix/client/logging.ts +0 -35
- package/extensions/matrix/src/matrix/client/runtime.ts +0 -4
- package/extensions/matrix/src/matrix/client/shared.ts +0 -169
- package/extensions/matrix/src/matrix/client/storage.ts +0 -131
- package/extensions/matrix/src/matrix/client/types.ts +0 -34
- package/extensions/matrix/src/matrix/client.test.ts +0 -57
- package/extensions/matrix/src/matrix/client.ts +0 -9
- package/extensions/matrix/src/matrix/credentials.ts +0 -103
- package/extensions/matrix/src/matrix/deps.ts +0 -57
- package/extensions/matrix/src/matrix/format.test.ts +0 -34
- package/extensions/matrix/src/matrix/format.ts +0 -22
- package/extensions/matrix/src/matrix/index.ts +0 -11
- package/extensions/matrix/src/matrix/monitor/allowlist.ts +0 -58
- package/extensions/matrix/src/matrix/monitor/auto-join.ts +0 -68
- package/extensions/matrix/src/matrix/monitor/direct.ts +0 -105
- package/extensions/matrix/src/matrix/monitor/events.ts +0 -103
- package/extensions/matrix/src/matrix/monitor/handler.ts +0 -645
- package/extensions/matrix/src/matrix/monitor/index.ts +0 -279
- package/extensions/matrix/src/matrix/monitor/location.ts +0 -83
- package/extensions/matrix/src/matrix/monitor/media.test.ts +0 -103
- package/extensions/matrix/src/matrix/monitor/media.ts +0 -113
- package/extensions/matrix/src/matrix/monitor/mentions.ts +0 -31
- package/extensions/matrix/src/matrix/monitor/replies.ts +0 -96
- package/extensions/matrix/src/matrix/monitor/room-info.ts +0 -58
- package/extensions/matrix/src/matrix/monitor/rooms.ts +0 -43
- package/extensions/matrix/src/matrix/monitor/threads.ts +0 -64
- package/extensions/matrix/src/matrix/monitor/types.ts +0 -39
- package/extensions/matrix/src/matrix/poll-types.test.ts +0 -22
- package/extensions/matrix/src/matrix/poll-types.ts +0 -157
- package/extensions/matrix/src/matrix/probe.ts +0 -70
- package/extensions/matrix/src/matrix/send/client.ts +0 -63
- package/extensions/matrix/src/matrix/send/formatting.ts +0 -92
- package/extensions/matrix/src/matrix/send/media.ts +0 -220
- package/extensions/matrix/src/matrix/send/targets.test.ts +0 -102
- package/extensions/matrix/src/matrix/send/targets.ts +0 -144
- package/extensions/matrix/src/matrix/send/types.ts +0 -109
- package/extensions/matrix/src/matrix/send.test.ts +0 -172
- package/extensions/matrix/src/matrix/send.ts +0 -255
- package/extensions/matrix/src/onboarding.ts +0 -432
- package/extensions/matrix/src/outbound.ts +0 -53
- package/extensions/matrix/src/resolve-targets.ts +0 -89
- package/extensions/matrix/src/runtime.ts +0 -14
- package/extensions/matrix/src/tool-actions.ts +0 -160
- package/extensions/matrix/src/types.ts +0 -95
- package/extensions/mattermost/clawdbot.plugin.json +0 -11
- package/extensions/mattermost/index.ts +0 -18
- package/extensions/mattermost/package.json +0 -25
- package/extensions/mattermost/src/channel.test.ts +0 -43
- package/extensions/mattermost/src/channel.ts +0 -339
- package/extensions/mattermost/src/config-schema.ts +0 -56
- package/extensions/mattermost/src/group-mentions.ts +0 -14
- package/extensions/mattermost/src/mattermost/accounts.ts +0 -115
- package/extensions/mattermost/src/mattermost/client.ts +0 -208
- package/extensions/mattermost/src/mattermost/index.ts +0 -9
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +0 -150
- package/extensions/mattermost/src/mattermost/monitor.ts +0 -921
- package/extensions/mattermost/src/mattermost/probe.ts +0 -70
- package/extensions/mattermost/src/mattermost/send.ts +0 -217
- package/extensions/mattermost/src/normalize.ts +0 -38
- package/extensions/mattermost/src/onboarding-helpers.ts +0 -42
- package/extensions/mattermost/src/onboarding.ts +0 -187
- package/extensions/mattermost/src/runtime.ts +0 -14
- package/extensions/mattermost/src/types.ts +0 -50
- package/extensions/msteams/CHANGELOG.md +0 -51
- package/extensions/msteams/clawdbot.plugin.json +0 -11
- package/extensions/msteams/index.ts +0 -18
- package/extensions/msteams/package.json +0 -36
- package/extensions/msteams/src/attachments/download.ts +0 -206
- package/extensions/msteams/src/attachments/graph.ts +0 -319
- package/extensions/msteams/src/attachments/html.ts +0 -76
- package/extensions/msteams/src/attachments/payload.ts +0 -22
- package/extensions/msteams/src/attachments/shared.ts +0 -235
- package/extensions/msteams/src/attachments/types.ts +0 -37
- package/extensions/msteams/src/attachments.test.ts +0 -424
- package/extensions/msteams/src/attachments.ts +0 -18
- package/extensions/msteams/src/channel.directory.test.ts +0 -46
- package/extensions/msteams/src/channel.ts +0 -436
- package/extensions/msteams/src/conversation-store-fs.test.ts +0 -88
- package/extensions/msteams/src/conversation-store-fs.ts +0 -155
- package/extensions/msteams/src/conversation-store-memory.ts +0 -45
- package/extensions/msteams/src/conversation-store.ts +0 -41
- package/extensions/msteams/src/directory-live.ts +0 -179
- package/extensions/msteams/src/errors.test.ts +0 -46
- package/extensions/msteams/src/errors.ts +0 -158
- package/extensions/msteams/src/file-consent-helpers.test.ts +0 -234
- package/extensions/msteams/src/file-consent-helpers.ts +0 -73
- package/extensions/msteams/src/file-consent.ts +0 -122
- package/extensions/msteams/src/graph-chat.ts +0 -52
- package/extensions/msteams/src/graph-upload.ts +0 -445
- package/extensions/msteams/src/inbound.test.ts +0 -67
- package/extensions/msteams/src/inbound.ts +0 -38
- package/extensions/msteams/src/index.ts +0 -4
- package/extensions/msteams/src/media-helpers.test.ts +0 -186
- package/extensions/msteams/src/media-helpers.ts +0 -77
- package/extensions/msteams/src/messenger.test.ts +0 -245
- package/extensions/msteams/src/messenger.ts +0 -460
- package/extensions/msteams/src/monitor-handler/inbound-media.ts +0 -123
- package/extensions/msteams/src/monitor-handler/message-handler.ts +0 -629
- package/extensions/msteams/src/monitor-handler.ts +0 -166
- package/extensions/msteams/src/monitor-types.ts +0 -5
- package/extensions/msteams/src/monitor.ts +0 -290
- package/extensions/msteams/src/onboarding.ts +0 -432
- package/extensions/msteams/src/outbound.ts +0 -47
- package/extensions/msteams/src/pending-uploads.ts +0 -87
- package/extensions/msteams/src/policy.test.ts +0 -210
- package/extensions/msteams/src/policy.ts +0 -202
- package/extensions/msteams/src/polls-store-memory.ts +0 -30
- package/extensions/msteams/src/polls-store.test.ts +0 -40
- package/extensions/msteams/src/polls.test.ts +0 -72
- package/extensions/msteams/src/polls.ts +0 -299
- package/extensions/msteams/src/probe.test.ts +0 -57
- package/extensions/msteams/src/probe.ts +0 -99
- package/extensions/msteams/src/reply-dispatcher.ts +0 -128
- package/extensions/msteams/src/resolve-allowlist.ts +0 -277
- package/extensions/msteams/src/runtime.ts +0 -14
- package/extensions/msteams/src/sdk-types.ts +0 -19
- package/extensions/msteams/src/sdk.ts +0 -33
- package/extensions/msteams/src/send-context.ts +0 -156
- package/extensions/msteams/src/send.ts +0 -489
- package/extensions/msteams/src/sent-message-cache.test.ts +0 -16
- package/extensions/msteams/src/sent-message-cache.ts +0 -41
- package/extensions/msteams/src/storage.ts +0 -22
- package/extensions/msteams/src/store-fs.ts +0 -80
- package/extensions/msteams/src/token.ts +0 -19
- package/extensions/nextcloud-talk/clawdbot.plugin.json +0 -11
- package/extensions/nextcloud-talk/index.ts +0 -18
- package/extensions/nextcloud-talk/package.json +0 -30
- package/extensions/nextcloud-talk/src/accounts.ts +0 -154
- package/extensions/nextcloud-talk/src/channel.ts +0 -404
- package/extensions/nextcloud-talk/src/config-schema.ts +0 -78
- package/extensions/nextcloud-talk/src/format.ts +0 -79
- package/extensions/nextcloud-talk/src/inbound.ts +0 -336
- package/extensions/nextcloud-talk/src/monitor.ts +0 -246
- package/extensions/nextcloud-talk/src/normalize.ts +0 -31
- package/extensions/nextcloud-talk/src/onboarding.ts +0 -341
- package/extensions/nextcloud-talk/src/policy.ts +0 -175
- package/extensions/nextcloud-talk/src/room-info.ts +0 -111
- package/extensions/nextcloud-talk/src/runtime.ts +0 -14
- package/extensions/nextcloud-talk/src/send.ts +0 -206
- package/extensions/nextcloud-talk/src/signature.ts +0 -67
- package/extensions/nextcloud-talk/src/types.ts +0 -179
- package/extensions/nostr/CHANGELOG.md +0 -46
- package/extensions/nostr/README.md +0 -136
- package/extensions/nostr/clawdbot.plugin.json +0 -11
- package/extensions/nostr/index.ts +0 -69
- package/extensions/nostr/package.json +0 -31
- package/extensions/nostr/src/channel.test.ts +0 -141
- package/extensions/nostr/src/channel.ts +0 -342
- package/extensions/nostr/src/config-schema.ts +0 -90
- package/extensions/nostr/src/metrics.ts +0 -464
- package/extensions/nostr/src/nostr-bus.fuzz.test.ts +0 -544
- package/extensions/nostr/src/nostr-bus.integration.test.ts +0 -452
- package/extensions/nostr/src/nostr-bus.test.ts +0 -199
- package/extensions/nostr/src/nostr-bus.ts +0 -741
- package/extensions/nostr/src/nostr-profile-http.test.ts +0 -378
- package/extensions/nostr/src/nostr-profile-http.ts +0 -500
- package/extensions/nostr/src/nostr-profile-import.test.ts +0 -120
- package/extensions/nostr/src/nostr-profile-import.ts +0 -259
- package/extensions/nostr/src/nostr-profile.fuzz.test.ts +0 -479
- package/extensions/nostr/src/nostr-profile.test.ts +0 -410
- package/extensions/nostr/src/nostr-profile.ts +0 -242
- package/extensions/nostr/src/nostr-state-store.test.ts +0 -128
- package/extensions/nostr/src/nostr-state-store.ts +0 -226
- package/extensions/nostr/src/runtime.ts +0 -14
- package/extensions/nostr/src/seen-tracker.ts +0 -271
- package/extensions/nostr/src/types.test.ts +0 -161
- package/extensions/nostr/src/types.ts +0 -99
- package/extensions/nostr/test/setup.ts +0 -5
- package/extensions/open-prose/README.md +0 -25
- package/extensions/open-prose/clawdbot.plugin.json +0 -11
- package/extensions/open-prose/index.ts +0 -5
- package/extensions/open-prose/package.json +0 -11
- package/extensions/open-prose/skills/prose/LICENSE +0 -21
- package/extensions/open-prose/skills/prose/SKILL.md +0 -318
- package/extensions/open-prose/skills/prose/alt-borges.md +0 -141
- package/extensions/open-prose/skills/prose/alts/arabian-nights.md +0 -358
- package/extensions/open-prose/skills/prose/alts/borges.md +0 -360
- package/extensions/open-prose/skills/prose/alts/folk.md +0 -322
- package/extensions/open-prose/skills/prose/alts/homer.md +0 -346
- package/extensions/open-prose/skills/prose/alts/kafka.md +0 -373
- package/extensions/open-prose/skills/prose/compiler.md +0 -2967
- package/extensions/open-prose/skills/prose/examples/01-hello-world.prose +0 -4
- package/extensions/open-prose/skills/prose/examples/02-research-and-summarize.prose +0 -6
- package/extensions/open-prose/skills/prose/examples/03-code-review.prose +0 -17
- package/extensions/open-prose/skills/prose/examples/04-write-and-refine.prose +0 -14
- package/extensions/open-prose/skills/prose/examples/05-debug-issue.prose +0 -20
- package/extensions/open-prose/skills/prose/examples/06-explain-codebase.prose +0 -17
- package/extensions/open-prose/skills/prose/examples/07-refactor.prose +0 -20
- package/extensions/open-prose/skills/prose/examples/08-blog-post.prose +0 -20
- package/extensions/open-prose/skills/prose/examples/09-research-with-agents.prose +0 -25
- package/extensions/open-prose/skills/prose/examples/10-code-review-agents.prose +0 -32
- package/extensions/open-prose/skills/prose/examples/11-skills-and-imports.prose +0 -27
- package/extensions/open-prose/skills/prose/examples/12-secure-agent-permissions.prose +0 -43
- package/extensions/open-prose/skills/prose/examples/13-variables-and-context.prose +0 -51
- package/extensions/open-prose/skills/prose/examples/14-composition-blocks.prose +0 -48
- package/extensions/open-prose/skills/prose/examples/15-inline-sequences.prose +0 -23
- package/extensions/open-prose/skills/prose/examples/16-parallel-reviews.prose +0 -19
- package/extensions/open-prose/skills/prose/examples/17-parallel-research.prose +0 -19
- package/extensions/open-prose/skills/prose/examples/18-mixed-parallel-sequential.prose +0 -36
- package/extensions/open-prose/skills/prose/examples/19-advanced-parallel.prose +0 -71
- package/extensions/open-prose/skills/prose/examples/20-fixed-loops.prose +0 -20
- package/extensions/open-prose/skills/prose/examples/21-pipeline-operations.prose +0 -35
- package/extensions/open-prose/skills/prose/examples/22-error-handling.prose +0 -51
- package/extensions/open-prose/skills/prose/examples/23-retry-with-backoff.prose +0 -63
- package/extensions/open-prose/skills/prose/examples/24-choice-blocks.prose +0 -86
- package/extensions/open-prose/skills/prose/examples/25-conditionals.prose +0 -114
- package/extensions/open-prose/skills/prose/examples/26-parameterized-blocks.prose +0 -100
- package/extensions/open-prose/skills/prose/examples/27-string-interpolation.prose +0 -105
- package/extensions/open-prose/skills/prose/examples/28-automated-pr-review.prose +0 -37
- package/extensions/open-prose/skills/prose/examples/28-gas-town.prose +0 -1572
- package/extensions/open-prose/skills/prose/examples/29-captains-chair.prose +0 -218
- package/extensions/open-prose/skills/prose/examples/30-captains-chair-simple.prose +0 -42
- package/extensions/open-prose/skills/prose/examples/31-captains-chair-with-memory.prose +0 -145
- package/extensions/open-prose/skills/prose/examples/33-pr-review-autofix.prose +0 -168
- package/extensions/open-prose/skills/prose/examples/34-content-pipeline.prose +0 -204
- package/extensions/open-prose/skills/prose/examples/35-feature-factory.prose +0 -296
- package/extensions/open-prose/skills/prose/examples/36-bug-hunter.prose +0 -237
- package/extensions/open-prose/skills/prose/examples/37-the-forge.prose +0 -1474
- package/extensions/open-prose/skills/prose/examples/38-skill-scan.prose +0 -455
- package/extensions/open-prose/skills/prose/examples/39-architect-by-simulation.prose +0 -277
- package/extensions/open-prose/skills/prose/examples/40-rlm-self-refine.prose +0 -32
- package/extensions/open-prose/skills/prose/examples/41-rlm-divide-conquer.prose +0 -38
- package/extensions/open-prose/skills/prose/examples/42-rlm-filter-recurse.prose +0 -46
- package/extensions/open-prose/skills/prose/examples/43-rlm-pairwise.prose +0 -50
- package/extensions/open-prose/skills/prose/examples/44-run-endpoint-ux-test.prose +0 -261
- package/extensions/open-prose/skills/prose/examples/45-plugin-release.prose +0 -159
- package/extensions/open-prose/skills/prose/examples/45-run-endpoint-ux-test-with-remediation.prose +0 -637
- package/extensions/open-prose/skills/prose/examples/46-run-endpoint-ux-test-fast.prose +0 -148
- package/extensions/open-prose/skills/prose/examples/46-workflow-crystallizer.prose +0 -225
- package/extensions/open-prose/skills/prose/examples/47-language-self-improvement.prose +0 -356
- package/extensions/open-prose/skills/prose/examples/48-habit-miner.prose +0 -445
- package/extensions/open-prose/skills/prose/examples/49-prose-run-retrospective.prose +0 -210
- package/extensions/open-prose/skills/prose/examples/README.md +0 -391
- package/extensions/open-prose/skills/prose/examples/roadmap/README.md +0 -22
- package/extensions/open-prose/skills/prose/examples/roadmap/iterative-refinement.prose +0 -20
- package/extensions/open-prose/skills/prose/examples/roadmap/parallel-review.prose +0 -18
- package/extensions/open-prose/skills/prose/examples/roadmap/simple-pipeline.prose +0 -17
- package/extensions/open-prose/skills/prose/examples/roadmap/syntax/open-prose-syntax.prose +0 -223
- package/extensions/open-prose/skills/prose/guidance/antipatterns.md +0 -951
- package/extensions/open-prose/skills/prose/guidance/patterns.md +0 -700
- package/extensions/open-prose/skills/prose/guidance/system-prompt.md +0 -180
- package/extensions/open-prose/skills/prose/help.md +0 -143
- package/extensions/open-prose/skills/prose/lib/README.md +0 -105
- package/extensions/open-prose/skills/prose/lib/calibrator.prose +0 -215
- package/extensions/open-prose/skills/prose/lib/cost-analyzer.prose +0 -174
- package/extensions/open-prose/skills/prose/lib/error-forensics.prose +0 -250
- package/extensions/open-prose/skills/prose/lib/inspector.prose +0 -196
- package/extensions/open-prose/skills/prose/lib/profiler.prose +0 -460
- package/extensions/open-prose/skills/prose/lib/program-improver.prose +0 -275
- package/extensions/open-prose/skills/prose/lib/project-memory.prose +0 -118
- package/extensions/open-prose/skills/prose/lib/user-memory.prose +0 -93
- package/extensions/open-prose/skills/prose/lib/vm-improver.prose +0 -243
- package/extensions/open-prose/skills/prose/primitives/session.md +0 -587
- package/extensions/open-prose/skills/prose/prose.md +0 -1235
- package/extensions/open-prose/skills/prose/state/filesystem.md +0 -478
- package/extensions/open-prose/skills/prose/state/in-context.md +0 -380
- package/extensions/open-prose/skills/prose/state/postgres.md +0 -875
- package/extensions/open-prose/skills/prose/state/sqlite.md +0 -572
- package/extensions/qwen-portal-auth/README.md +0 -24
- package/extensions/qwen-portal-auth/clawdbot.plugin.json +0 -11
- package/extensions/qwen-portal-auth/index.ts +0 -127
- package/extensions/qwen-portal-auth/oauth.ts +0 -190
- package/extensions/signal/clawdbot.plugin.json +0 -11
- package/extensions/signal/index.ts +0 -18
- package/extensions/signal/package.json +0 -11
- package/extensions/signal/src/channel.ts +0 -312
- package/extensions/signal/src/runtime.ts +0 -14
- package/extensions/telegram/clawdbot.plugin.json +0 -11
- package/extensions/telegram/index.ts +0 -18
- package/extensions/telegram/package.json +0 -11
- package/extensions/telegram/src/channel.ts +0 -478
- package/extensions/telegram/src/runtime.ts +0 -14
- package/extensions/tlon/README.md +0 -5
- package/extensions/tlon/clawdbot.plugin.json +0 -11
- package/extensions/tlon/index.ts +0 -18
- package/extensions/tlon/package.json +0 -30
- package/extensions/tlon/src/channel.ts +0 -379
- package/extensions/tlon/src/config-schema.test.ts +0 -32
- package/extensions/tlon/src/config-schema.ts +0 -43
- package/extensions/tlon/src/monitor/discovery.ts +0 -71
- package/extensions/tlon/src/monitor/history.ts +0 -87
- package/extensions/tlon/src/monitor/index.ts +0 -501
- package/extensions/tlon/src/monitor/processed-messages.test.ts +0 -24
- package/extensions/tlon/src/monitor/processed-messages.ts +0 -38
- package/extensions/tlon/src/monitor/utils.ts +0 -83
- package/extensions/tlon/src/onboarding.ts +0 -213
- package/extensions/tlon/src/runtime.ts +0 -14
- package/extensions/tlon/src/targets.ts +0 -79
- package/extensions/tlon/src/types.ts +0 -85
- package/extensions/tlon/src/urbit/auth.ts +0 -18
- package/extensions/tlon/src/urbit/http-api.ts +0 -36
- package/extensions/tlon/src/urbit/send.test.ts +0 -38
- package/extensions/tlon/src/urbit/send.ts +0 -127
- package/extensions/tlon/src/urbit/sse-client.test.ts +0 -41
- package/extensions/tlon/src/urbit/sse-client.ts +0 -367
- package/extensions/twitch/CHANGELOG.md +0 -21
- package/extensions/twitch/README.md +0 -89
- package/extensions/twitch/clawdbot.plugin.json +0 -9
- package/extensions/twitch/index.ts +0 -20
- package/extensions/twitch/package.json +0 -20
- package/extensions/twitch/src/access-control.test.ts +0 -489
- package/extensions/twitch/src/access-control.ts +0 -154
- package/extensions/twitch/src/actions.ts +0 -173
- package/extensions/twitch/src/client-manager-registry.ts +0 -115
- package/extensions/twitch/src/config-schema.ts +0 -82
- package/extensions/twitch/src/config.test.ts +0 -88
- package/extensions/twitch/src/config.ts +0 -116
- package/extensions/twitch/src/monitor.ts +0 -257
- package/extensions/twitch/src/onboarding.test.ts +0 -311
- package/extensions/twitch/src/onboarding.ts +0 -411
- package/extensions/twitch/src/outbound.test.ts +0 -373
- package/extensions/twitch/src/outbound.ts +0 -186
- package/extensions/twitch/src/plugin.test.ts +0 -39
- package/extensions/twitch/src/plugin.ts +0 -274
- package/extensions/twitch/src/probe.test.ts +0 -198
- package/extensions/twitch/src/probe.ts +0 -118
- package/extensions/twitch/src/resolver.ts +0 -137
- package/extensions/twitch/src/runtime.ts +0 -14
- package/extensions/twitch/src/send.test.ts +0 -289
- package/extensions/twitch/src/send.ts +0 -136
- package/extensions/twitch/src/status.test.ts +0 -270
- package/extensions/twitch/src/status.ts +0 -176
- package/extensions/twitch/src/token.test.ts +0 -171
- package/extensions/twitch/src/token.ts +0 -87
- package/extensions/twitch/src/twitch-client.test.ts +0 -574
- package/extensions/twitch/src/twitch-client.ts +0 -277
- package/extensions/twitch/src/types.ts +0 -141
- package/extensions/twitch/src/utils/markdown.ts +0 -92
- package/extensions/twitch/src/utils/twitch.ts +0 -78
- package/extensions/twitch/test/setup.ts +0 -7
- package/extensions/voice-call/CHANGELOG.md +0 -72
- package/extensions/voice-call/README.md +0 -134
- package/extensions/voice-call/clawdbot.plugin.json +0 -601
- package/extensions/voice-call/index.ts +0 -497
- package/extensions/voice-call/package.json +0 -16
- package/extensions/voice-call/src/cli.ts +0 -300
- package/extensions/voice-call/src/config.test.ts +0 -204
- package/extensions/voice-call/src/config.ts +0 -493
- package/extensions/voice-call/src/core-bridge.ts +0 -196
- package/extensions/voice-call/src/manager/context.ts +0 -21
- package/extensions/voice-call/src/manager/events.ts +0 -177
- package/extensions/voice-call/src/manager/lookup.ts +0 -33
- package/extensions/voice-call/src/manager/outbound.ts +0 -248
- package/extensions/voice-call/src/manager/state.ts +0 -50
- package/extensions/voice-call/src/manager/store.ts +0 -88
- package/extensions/voice-call/src/manager/timers.ts +0 -86
- package/extensions/voice-call/src/manager/twiml.ts +0 -9
- package/extensions/voice-call/src/manager.test.ts +0 -108
- package/extensions/voice-call/src/manager.ts +0 -876
- package/extensions/voice-call/src/media-stream.test.ts +0 -97
- package/extensions/voice-call/src/media-stream.ts +0 -393
- package/extensions/voice-call/src/providers/base.ts +0 -67
- package/extensions/voice-call/src/providers/index.ts +0 -10
- package/extensions/voice-call/src/providers/mock.ts +0 -168
- package/extensions/voice-call/src/providers/plivo.test.ts +0 -28
- package/extensions/voice-call/src/providers/plivo.ts +0 -504
- package/extensions/voice-call/src/providers/stt-openai-realtime.ts +0 -311
- package/extensions/voice-call/src/providers/telnyx.ts +0 -364
- package/extensions/voice-call/src/providers/tts-openai.ts +0 -264
- package/extensions/voice-call/src/providers/twilio/api.ts +0 -45
- package/extensions/voice-call/src/providers/twilio/webhook.ts +0 -29
- package/extensions/voice-call/src/providers/twilio.test.ts +0 -64
- package/extensions/voice-call/src/providers/twilio.ts +0 -595
- package/extensions/voice-call/src/response-generator.ts +0 -171
- package/extensions/voice-call/src/runtime.ts +0 -205
- package/extensions/voice-call/src/telephony-audio.ts +0 -88
- package/extensions/voice-call/src/telephony-tts.ts +0 -95
- package/extensions/voice-call/src/tunnel.ts +0 -331
- package/extensions/voice-call/src/types.ts +0 -272
- package/extensions/voice-call/src/utils.ts +0 -12
- package/extensions/voice-call/src/voice-mapping.ts +0 -65
- package/extensions/voice-call/src/webhook-security.test.ts +0 -233
- package/extensions/voice-call/src/webhook-security.ts +0 -446
- package/extensions/voice-call/src/webhook.ts +0 -490
- package/extensions/whatsapp/clawdbot.plugin.json +0 -11
- package/extensions/whatsapp/index.ts +0 -18
- package/extensions/whatsapp/package.json +0 -11
- package/extensions/whatsapp/src/channel.ts +0 -500
- package/extensions/whatsapp/src/runtime.ts +0 -14
- package/extensions/zalo/CHANGELOG.md +0 -55
- package/extensions/zalo/README.md +0 -50
- package/extensions/zalo/clawdbot.plugin.json +0 -11
- package/extensions/zalo/index.ts +0 -20
- package/extensions/zalo/package.json +0 -33
- package/extensions/zalo/src/accounts.ts +0 -71
- package/extensions/zalo/src/actions.ts +0 -62
- package/extensions/zalo/src/api.ts +0 -206
- package/extensions/zalo/src/channel.directory.test.ts +0 -35
- package/extensions/zalo/src/channel.ts +0 -394
- package/extensions/zalo/src/config-schema.ts +0 -24
- package/extensions/zalo/src/monitor.ts +0 -760
- package/extensions/zalo/src/monitor.webhook.test.ts +0 -70
- package/extensions/zalo/src/onboarding.ts +0 -405
- package/extensions/zalo/src/probe.ts +0 -46
- package/extensions/zalo/src/proxy.ts +0 -18
- package/extensions/zalo/src/runtime.ts +0 -14
- package/extensions/zalo/src/send.ts +0 -117
- package/extensions/zalo/src/status-issues.ts +0 -50
- package/extensions/zalo/src/token.ts +0 -55
- package/extensions/zalo/src/types.ts +0 -42
- package/extensions/zalouser/CHANGELOG.md +0 -33
- package/extensions/zalouser/README.md +0 -221
- package/extensions/zalouser/clawdbot.plugin.json +0 -11
- package/extensions/zalouser/index.ts +0 -32
- package/extensions/zalouser/package.json +0 -33
- package/extensions/zalouser/src/accounts.ts +0 -117
- package/extensions/zalouser/src/channel.test.ts +0 -17
- package/extensions/zalouser/src/channel.ts +0 -641
- package/extensions/zalouser/src/config-schema.ts +0 -27
- package/extensions/zalouser/src/monitor.ts +0 -574
- package/extensions/zalouser/src/onboarding.ts +0 -488
- package/extensions/zalouser/src/probe.ts +0 -28
- package/extensions/zalouser/src/runtime.ts +0 -14
- package/extensions/zalouser/src/send.ts +0 -150
- package/extensions/zalouser/src/status-issues.test.ts +0 -58
- package/extensions/zalouser/src/status-issues.ts +0 -81
- package/extensions/zalouser/src/tool.ts +0 -156
- package/extensions/zalouser/src/types.ts +0 -102
- package/extensions/zalouser/src/zca.ts +0 -208
- package/skills/1password/SKILL.md +0 -53
- package/skills/1password/references/cli-examples.md +0 -29
- package/skills/1password/references/get-started.md +0 -17
- package/skills/apple-notes/SKILL.md +0 -50
- package/skills/apple-reminders/SKILL.md +0 -67
- package/skills/bear-notes/SKILL.md +0 -79
- package/skills/bird/SKILL.md +0 -197
- package/skills/blogwatcher/SKILL.md +0 -46
- package/skills/blucli/SKILL.md +0 -27
- package/skills/bluebubbles/SKILL.md +0 -39
- package/skills/camsnap/SKILL.md +0 -25
- package/skills/canvas/SKILL.md +0 -189
- package/skills/clawdhub/SKILL.md +0 -53
- package/skills/coding-agent/SKILL.md +0 -278
- package/skills/discord/SKILL.md +0 -475
- package/skills/eightctl/SKILL.md +0 -29
- package/skills/food-order/SKILL.md +0 -41
- package/skills/gemini/SKILL.md +0 -23
- package/skills/gifgrep/SKILL.md +0 -47
- package/skills/github/SKILL.md +0 -48
- package/skills/gog/SKILL.md +0 -92
- package/skills/goplaces/SKILL.md +0 -30
- package/skills/himalaya/SKILL.md +0 -217
- package/skills/himalaya/references/configuration.md +0 -174
- package/skills/himalaya/references/message-composition.md +0 -182
- package/skills/imsg/SKILL.md +0 -25
- package/skills/local-places/SERVER_README.md +0 -101
- package/skills/local-places/SKILL.md +0 -91
- package/skills/local-places/pyproject.toml +0 -27
- package/skills/local-places/src/local_places/__init__.py +0 -2
- package/skills/local-places/src/local_places/google_places.py +0 -314
- package/skills/local-places/src/local_places/main.py +0 -65
- package/skills/local-places/src/local_places/schemas.py +0 -107
- package/skills/mcporter/SKILL.md +0 -38
- package/skills/model-usage/SKILL.md +0 -45
- package/skills/model-usage/references/codexbar-cli.md +0 -28
- package/skills/model-usage/scripts/model_usage.py +0 -310
- package/skills/nano-banana-pro/SKILL.md +0 -30
- package/skills/nano-banana-pro/scripts/generate_image.py +0 -169
- package/skills/nano-pdf/SKILL.md +0 -20
- package/skills/notion/SKILL.md +0 -156
- package/skills/obsidian/SKILL.md +0 -55
- package/skills/openai-image-gen/SKILL.md +0 -71
- package/skills/openai-image-gen/scripts/gen.py +0 -240
- package/skills/openai-whisper/SKILL.md +0 -19
- package/skills/openai-whisper-api/SKILL.md +0 -43
- package/skills/openai-whisper-api/scripts/transcribe.sh +0 -85
- package/skills/openhue/SKILL.md +0 -30
- package/skills/oracle/SKILL.md +0 -105
- package/skills/ordercli/SKILL.md +0 -47
- package/skills/peekaboo/SKILL.md +0 -153
- package/skills/sag/SKILL.md +0 -62
- package/skills/session-logs/SKILL.md +0 -105
- package/skills/sherpa-onnx-tts/SKILL.md +0 -49
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +0 -178
- package/skills/skill-creator/SKILL.md +0 -371
- package/skills/skill-creator/license.txt +0 -202
- package/skills/skill-creator/scripts/init_skill.py +0 -378
- package/skills/skill-creator/scripts/package_skill.py +0 -111
- package/skills/skill-creator/scripts/quick_validate.py +0 -101
- package/skills/slack/SKILL.md +0 -144
- package/skills/songsee/SKILL.md +0 -29
- package/skills/sonoscli/SKILL.md +0 -26
- package/skills/spotify-player/SKILL.md +0 -34
- package/skills/summarize/SKILL.md +0 -67
- package/skills/things-mac/SKILL.md +0 -61
- package/skills/tmux/SKILL.md +0 -121
- package/skills/tmux/scripts/find-sessions.sh +0 -112
- package/skills/tmux/scripts/wait-for-text.sh +0 -83
- package/skills/trello/SKILL.md +0 -84
- package/skills/video-frames/SKILL.md +0 -29
- package/skills/video-frames/scripts/frame.sh +0 -81
- package/skills/voice-call/SKILL.md +0 -35
- package/skills/wacli/SKILL.md +0 -42
- package/skills/weather/SKILL.md +0 -49
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ClawdbotPluginApi } from "clawdbot/plugin-sdk";
|
|
2
|
-
import { emptyPluginConfigSchema } from "clawdbot/plugin-sdk";
|
|
3
|
-
|
|
4
|
-
import { msteamsPlugin } from "./src/channel.js";
|
|
5
|
-
import { setMSTeamsRuntime } from "./src/runtime.js";
|
|
6
|
-
|
|
7
|
-
const plugin = {
|
|
8
|
-
id: "msteams",
|
|
9
|
-
name: "Microsoft Teams",
|
|
10
|
-
description: "Microsoft Teams channel plugin (Bot Framework)",
|
|
11
|
-
configSchema: emptyPluginConfigSchema(),
|
|
12
|
-
register(api: ClawdbotPluginApi) {
|
|
13
|
-
setMSTeamsRuntime(api.runtime);
|
|
14
|
-
api.registerChannel({ plugin: msteamsPlugin });
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default plugin;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@clawdbot/msteams",
|
|
3
|
-
"version": "2026.1.25",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Clawdbot Microsoft Teams channel plugin",
|
|
6
|
-
"clawdbot": {
|
|
7
|
-
"extensions": [
|
|
8
|
-
"./index.ts"
|
|
9
|
-
],
|
|
10
|
-
"channel": {
|
|
11
|
-
"id": "msteams",
|
|
12
|
-
"label": "Microsoft Teams",
|
|
13
|
-
"selectionLabel": "Microsoft Teams (Bot Framework)",
|
|
14
|
-
"docsPath": "/channels/msteams",
|
|
15
|
-
"docsLabel": "msteams",
|
|
16
|
-
"blurb": "Bot Framework; enterprise support.",
|
|
17
|
-
"aliases": [
|
|
18
|
-
"teams"
|
|
19
|
-
],
|
|
20
|
-
"order": 60
|
|
21
|
-
},
|
|
22
|
-
"install": {
|
|
23
|
-
"npmSpec": "@clawdbot/msteams",
|
|
24
|
-
"localPath": "extensions/msteams",
|
|
25
|
-
"defaultChoice": "npm"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@microsoft/agents-hosting": "^1.2.2",
|
|
30
|
-
"@microsoft/agents-hosting-express": "^1.2.2",
|
|
31
|
-
"@microsoft/agents-hosting-extensions-teams": "^1.2.2",
|
|
32
|
-
"clawdbot": "workspace:*",
|
|
33
|
-
"express": "^5.2.1",
|
|
34
|
-
"proper-lockfile": "^4.1.2"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { getMSTeamsRuntime } from "../runtime.js";
|
|
2
|
-
import {
|
|
3
|
-
extractInlineImageCandidates,
|
|
4
|
-
inferPlaceholder,
|
|
5
|
-
isDownloadableAttachment,
|
|
6
|
-
isRecord,
|
|
7
|
-
isUrlAllowed,
|
|
8
|
-
normalizeContentType,
|
|
9
|
-
resolveAllowedHosts,
|
|
10
|
-
} from "./shared.js";
|
|
11
|
-
import type {
|
|
12
|
-
MSTeamsAccessTokenProvider,
|
|
13
|
-
MSTeamsAttachmentLike,
|
|
14
|
-
MSTeamsInboundMedia,
|
|
15
|
-
} from "./types.js";
|
|
16
|
-
|
|
17
|
-
type DownloadCandidate = {
|
|
18
|
-
url: string;
|
|
19
|
-
fileHint?: string;
|
|
20
|
-
contentTypeHint?: string;
|
|
21
|
-
placeholder: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function resolveDownloadCandidate(att: MSTeamsAttachmentLike): DownloadCandidate | null {
|
|
25
|
-
const contentType = normalizeContentType(att.contentType);
|
|
26
|
-
const name = typeof att.name === "string" ? att.name.trim() : "";
|
|
27
|
-
|
|
28
|
-
if (contentType === "application/vnd.microsoft.teams.file.download.info") {
|
|
29
|
-
if (!isRecord(att.content)) return null;
|
|
30
|
-
const downloadUrl =
|
|
31
|
-
typeof att.content.downloadUrl === "string" ? att.content.downloadUrl.trim() : "";
|
|
32
|
-
if (!downloadUrl) return null;
|
|
33
|
-
|
|
34
|
-
const fileType = typeof att.content.fileType === "string" ? att.content.fileType.trim() : "";
|
|
35
|
-
const uniqueId = typeof att.content.uniqueId === "string" ? att.content.uniqueId.trim() : "";
|
|
36
|
-
const fileName = typeof att.content.fileName === "string" ? att.content.fileName.trim() : "";
|
|
37
|
-
|
|
38
|
-
const fileHint = name || fileName || (uniqueId && fileType ? `${uniqueId}.${fileType}` : "");
|
|
39
|
-
return {
|
|
40
|
-
url: downloadUrl,
|
|
41
|
-
fileHint: fileHint || undefined,
|
|
42
|
-
contentTypeHint: undefined,
|
|
43
|
-
placeholder: inferPlaceholder({
|
|
44
|
-
contentType,
|
|
45
|
-
fileName: fileHint,
|
|
46
|
-
fileType,
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const contentUrl = typeof att.contentUrl === "string" ? att.contentUrl.trim() : "";
|
|
52
|
-
if (!contentUrl) return null;
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
url: contentUrl,
|
|
56
|
-
fileHint: name || undefined,
|
|
57
|
-
contentTypeHint: contentType,
|
|
58
|
-
placeholder: inferPlaceholder({ contentType, fileName: name }),
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function scopeCandidatesForUrl(url: string): string[] {
|
|
63
|
-
try {
|
|
64
|
-
const host = new URL(url).hostname.toLowerCase();
|
|
65
|
-
const looksLikeGraph =
|
|
66
|
-
host.endsWith("graph.microsoft.com") ||
|
|
67
|
-
host.endsWith("sharepoint.com") ||
|
|
68
|
-
host.endsWith("1drv.ms") ||
|
|
69
|
-
host.includes("sharepoint");
|
|
70
|
-
return looksLikeGraph
|
|
71
|
-
? ["https://graph.microsoft.com", "https://api.botframework.com"]
|
|
72
|
-
: ["https://api.botframework.com", "https://graph.microsoft.com"];
|
|
73
|
-
} catch {
|
|
74
|
-
return ["https://api.botframework.com", "https://graph.microsoft.com"];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function fetchWithAuthFallback(params: {
|
|
79
|
-
url: string;
|
|
80
|
-
tokenProvider?: MSTeamsAccessTokenProvider;
|
|
81
|
-
fetchFn?: typeof fetch;
|
|
82
|
-
}): Promise<Response> {
|
|
83
|
-
const fetchFn = params.fetchFn ?? fetch;
|
|
84
|
-
const firstAttempt = await fetchFn(params.url);
|
|
85
|
-
if (firstAttempt.ok) return firstAttempt;
|
|
86
|
-
if (!params.tokenProvider) return firstAttempt;
|
|
87
|
-
if (firstAttempt.status !== 401 && firstAttempt.status !== 403) return firstAttempt;
|
|
88
|
-
|
|
89
|
-
const scopes = scopeCandidatesForUrl(params.url);
|
|
90
|
-
for (const scope of scopes) {
|
|
91
|
-
try {
|
|
92
|
-
const token = await params.tokenProvider.getAccessToken(scope);
|
|
93
|
-
const res = await fetchFn(params.url, {
|
|
94
|
-
headers: { Authorization: `Bearer ${token}` },
|
|
95
|
-
});
|
|
96
|
-
if (res.ok) return res;
|
|
97
|
-
} catch {
|
|
98
|
-
// Try the next scope.
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return firstAttempt;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Download all file attachments from a Teams message (images, documents, etc.).
|
|
107
|
-
* Renamed from downloadMSTeamsImageAttachments to support all file types.
|
|
108
|
-
*/
|
|
109
|
-
export async function downloadMSTeamsAttachments(params: {
|
|
110
|
-
attachments: MSTeamsAttachmentLike[] | undefined;
|
|
111
|
-
maxBytes: number;
|
|
112
|
-
tokenProvider?: MSTeamsAccessTokenProvider;
|
|
113
|
-
allowHosts?: string[];
|
|
114
|
-
fetchFn?: typeof fetch;
|
|
115
|
-
/** When true, embeds original filename in stored path for later extraction. */
|
|
116
|
-
preserveFilenames?: boolean;
|
|
117
|
-
}): Promise<MSTeamsInboundMedia[]> {
|
|
118
|
-
const list = Array.isArray(params.attachments) ? params.attachments : [];
|
|
119
|
-
if (list.length === 0) return [];
|
|
120
|
-
const allowHosts = resolveAllowedHosts(params.allowHosts);
|
|
121
|
-
|
|
122
|
-
// Download ANY downloadable attachment (not just images)
|
|
123
|
-
const downloadable = list.filter(isDownloadableAttachment);
|
|
124
|
-
const candidates: DownloadCandidate[] = downloadable
|
|
125
|
-
.map(resolveDownloadCandidate)
|
|
126
|
-
.filter(Boolean) as DownloadCandidate[];
|
|
127
|
-
|
|
128
|
-
const inlineCandidates = extractInlineImageCandidates(list);
|
|
129
|
-
|
|
130
|
-
const seenUrls = new Set<string>();
|
|
131
|
-
for (const inline of inlineCandidates) {
|
|
132
|
-
if (inline.kind === "url") {
|
|
133
|
-
if (!isUrlAllowed(inline.url, allowHosts)) continue;
|
|
134
|
-
if (seenUrls.has(inline.url)) continue;
|
|
135
|
-
seenUrls.add(inline.url);
|
|
136
|
-
candidates.push({
|
|
137
|
-
url: inline.url,
|
|
138
|
-
fileHint: inline.fileHint,
|
|
139
|
-
contentTypeHint: inline.contentType,
|
|
140
|
-
placeholder: inline.placeholder,
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (candidates.length === 0 && inlineCandidates.length === 0) return [];
|
|
145
|
-
|
|
146
|
-
const out: MSTeamsInboundMedia[] = [];
|
|
147
|
-
for (const inline of inlineCandidates) {
|
|
148
|
-
if (inline.kind !== "data") continue;
|
|
149
|
-
if (inline.data.byteLength > params.maxBytes) continue;
|
|
150
|
-
try {
|
|
151
|
-
// Data inline candidates (base64 data URLs) don't have original filenames
|
|
152
|
-
const saved = await getMSTeamsRuntime().channel.media.saveMediaBuffer(
|
|
153
|
-
inline.data,
|
|
154
|
-
inline.contentType,
|
|
155
|
-
"inbound",
|
|
156
|
-
params.maxBytes,
|
|
157
|
-
);
|
|
158
|
-
out.push({
|
|
159
|
-
path: saved.path,
|
|
160
|
-
contentType: saved.contentType,
|
|
161
|
-
placeholder: inline.placeholder,
|
|
162
|
-
});
|
|
163
|
-
} catch {
|
|
164
|
-
// Ignore decode failures and continue.
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
for (const candidate of candidates) {
|
|
168
|
-
if (!isUrlAllowed(candidate.url, allowHosts)) continue;
|
|
169
|
-
try {
|
|
170
|
-
const res = await fetchWithAuthFallback({
|
|
171
|
-
url: candidate.url,
|
|
172
|
-
tokenProvider: params.tokenProvider,
|
|
173
|
-
fetchFn: params.fetchFn,
|
|
174
|
-
});
|
|
175
|
-
if (!res.ok) continue;
|
|
176
|
-
const buffer = Buffer.from(await res.arrayBuffer());
|
|
177
|
-
if (buffer.byteLength > params.maxBytes) continue;
|
|
178
|
-
const mime = await getMSTeamsRuntime().media.detectMime({
|
|
179
|
-
buffer,
|
|
180
|
-
headerMime: res.headers.get("content-type"),
|
|
181
|
-
filePath: candidate.fileHint ?? candidate.url,
|
|
182
|
-
});
|
|
183
|
-
const originalFilename = params.preserveFilenames ? candidate.fileHint : undefined;
|
|
184
|
-
const saved = await getMSTeamsRuntime().channel.media.saveMediaBuffer(
|
|
185
|
-
buffer,
|
|
186
|
-
mime ?? candidate.contentTypeHint,
|
|
187
|
-
"inbound",
|
|
188
|
-
params.maxBytes,
|
|
189
|
-
originalFilename,
|
|
190
|
-
);
|
|
191
|
-
out.push({
|
|
192
|
-
path: saved.path,
|
|
193
|
-
contentType: saved.contentType,
|
|
194
|
-
placeholder: candidate.placeholder,
|
|
195
|
-
});
|
|
196
|
-
} catch {
|
|
197
|
-
// Ignore download failures and continue with next candidate.
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return out;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* @deprecated Use `downloadMSTeamsAttachments` instead (supports all file types).
|
|
205
|
-
*/
|
|
206
|
-
export const downloadMSTeamsImageAttachments = downloadMSTeamsAttachments;
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import { getMSTeamsRuntime } from "../runtime.js";
|
|
2
|
-
import { downloadMSTeamsAttachments } from "./download.js";
|
|
3
|
-
import { GRAPH_ROOT, inferPlaceholder, isRecord, normalizeContentType, resolveAllowedHosts } from "./shared.js";
|
|
4
|
-
import type {
|
|
5
|
-
MSTeamsAccessTokenProvider,
|
|
6
|
-
MSTeamsAttachmentLike,
|
|
7
|
-
MSTeamsGraphMediaResult,
|
|
8
|
-
MSTeamsInboundMedia,
|
|
9
|
-
} from "./types.js";
|
|
10
|
-
|
|
11
|
-
type GraphHostedContent = {
|
|
12
|
-
id?: string | null;
|
|
13
|
-
contentType?: string | null;
|
|
14
|
-
contentBytes?: string | null;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type GraphAttachment = {
|
|
18
|
-
id?: string | null;
|
|
19
|
-
contentType?: string | null;
|
|
20
|
-
contentUrl?: string | null;
|
|
21
|
-
name?: string | null;
|
|
22
|
-
thumbnailUrl?: string | null;
|
|
23
|
-
content?: unknown;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function readNestedString(value: unknown, keys: Array<string | number>): string | undefined {
|
|
27
|
-
let current: unknown = value;
|
|
28
|
-
for (const key of keys) {
|
|
29
|
-
if (!isRecord(current)) return undefined;
|
|
30
|
-
current = current[key as keyof typeof current];
|
|
31
|
-
}
|
|
32
|
-
return typeof current === "string" && current.trim() ? current.trim() : undefined;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function buildMSTeamsGraphMessageUrls(params: {
|
|
36
|
-
conversationType?: string | null;
|
|
37
|
-
conversationId?: string | null;
|
|
38
|
-
messageId?: string | null;
|
|
39
|
-
replyToId?: string | null;
|
|
40
|
-
conversationMessageId?: string | null;
|
|
41
|
-
channelData?: unknown;
|
|
42
|
-
}): string[] {
|
|
43
|
-
const conversationType = params.conversationType?.trim().toLowerCase() ?? "";
|
|
44
|
-
const messageIdCandidates = new Set<string>();
|
|
45
|
-
const pushCandidate = (value: string | null | undefined) => {
|
|
46
|
-
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
47
|
-
if (trimmed) messageIdCandidates.add(trimmed);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
pushCandidate(params.messageId);
|
|
51
|
-
pushCandidate(params.conversationMessageId);
|
|
52
|
-
pushCandidate(readNestedString(params.channelData, ["messageId"]));
|
|
53
|
-
pushCandidate(readNestedString(params.channelData, ["teamsMessageId"]));
|
|
54
|
-
|
|
55
|
-
const replyToId = typeof params.replyToId === "string" ? params.replyToId.trim() : "";
|
|
56
|
-
|
|
57
|
-
if (conversationType === "channel") {
|
|
58
|
-
const teamId =
|
|
59
|
-
readNestedString(params.channelData, ["team", "id"]) ??
|
|
60
|
-
readNestedString(params.channelData, ["teamId"]);
|
|
61
|
-
const channelId =
|
|
62
|
-
readNestedString(params.channelData, ["channel", "id"]) ??
|
|
63
|
-
readNestedString(params.channelData, ["channelId"]) ??
|
|
64
|
-
readNestedString(params.channelData, ["teamsChannelId"]);
|
|
65
|
-
if (!teamId || !channelId) return [];
|
|
66
|
-
const urls: string[] = [];
|
|
67
|
-
if (replyToId) {
|
|
68
|
-
for (const candidate of messageIdCandidates) {
|
|
69
|
-
if (candidate === replyToId) continue;
|
|
70
|
-
urls.push(
|
|
71
|
-
`${GRAPH_ROOT}/teams/${encodeURIComponent(teamId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(replyToId)}/replies/${encodeURIComponent(candidate)}`,
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (messageIdCandidates.size === 0 && replyToId) messageIdCandidates.add(replyToId);
|
|
76
|
-
for (const candidate of messageIdCandidates) {
|
|
77
|
-
urls.push(
|
|
78
|
-
`${GRAPH_ROOT}/teams/${encodeURIComponent(teamId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(candidate)}`,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
return Array.from(new Set(urls));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const chatId = params.conversationId?.trim() || readNestedString(params.channelData, ["chatId"]);
|
|
85
|
-
if (!chatId) return [];
|
|
86
|
-
if (messageIdCandidates.size === 0 && replyToId) messageIdCandidates.add(replyToId);
|
|
87
|
-
const urls = Array.from(messageIdCandidates).map(
|
|
88
|
-
(candidate) =>
|
|
89
|
-
`${GRAPH_ROOT}/chats/${encodeURIComponent(chatId)}/messages/${encodeURIComponent(candidate)}`,
|
|
90
|
-
);
|
|
91
|
-
return Array.from(new Set(urls));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function fetchGraphCollection<T>(params: {
|
|
95
|
-
url: string;
|
|
96
|
-
accessToken: string;
|
|
97
|
-
fetchFn?: typeof fetch;
|
|
98
|
-
}): Promise<{ status: number; items: T[] }> {
|
|
99
|
-
const fetchFn = params.fetchFn ?? fetch;
|
|
100
|
-
const res = await fetchFn(params.url, {
|
|
101
|
-
headers: { Authorization: `Bearer ${params.accessToken}` },
|
|
102
|
-
});
|
|
103
|
-
const status = res.status;
|
|
104
|
-
if (!res.ok) return { status, items: [] };
|
|
105
|
-
try {
|
|
106
|
-
const data = (await res.json()) as { value?: T[] };
|
|
107
|
-
return { status, items: Array.isArray(data.value) ? data.value : [] };
|
|
108
|
-
} catch {
|
|
109
|
-
return { status, items: [] };
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function normalizeGraphAttachment(att: GraphAttachment): MSTeamsAttachmentLike {
|
|
114
|
-
let content: unknown = att.content;
|
|
115
|
-
if (typeof content === "string") {
|
|
116
|
-
try {
|
|
117
|
-
content = JSON.parse(content);
|
|
118
|
-
} catch {
|
|
119
|
-
// Keep as raw string if it's not JSON.
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
contentType: normalizeContentType(att.contentType) ?? undefined,
|
|
124
|
-
contentUrl: att.contentUrl ?? undefined,
|
|
125
|
-
name: att.name ?? undefined,
|
|
126
|
-
thumbnailUrl: att.thumbnailUrl ?? undefined,
|
|
127
|
-
content,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Download all hosted content from a Teams message (images, documents, etc.).
|
|
133
|
-
* Renamed from downloadGraphHostedImages to support all file types.
|
|
134
|
-
*/
|
|
135
|
-
async function downloadGraphHostedContent(params: {
|
|
136
|
-
accessToken: string;
|
|
137
|
-
messageUrl: string;
|
|
138
|
-
maxBytes: number;
|
|
139
|
-
fetchFn?: typeof fetch;
|
|
140
|
-
preserveFilenames?: boolean;
|
|
141
|
-
}): Promise<{ media: MSTeamsInboundMedia[]; status: number; count: number }> {
|
|
142
|
-
const hosted = await fetchGraphCollection<GraphHostedContent>({
|
|
143
|
-
url: `${params.messageUrl}/hostedContents`,
|
|
144
|
-
accessToken: params.accessToken,
|
|
145
|
-
fetchFn: params.fetchFn,
|
|
146
|
-
});
|
|
147
|
-
if (hosted.items.length === 0) {
|
|
148
|
-
return { media: [], status: hosted.status, count: 0 };
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const out: MSTeamsInboundMedia[] = [];
|
|
152
|
-
for (const item of hosted.items) {
|
|
153
|
-
const contentBytes = typeof item.contentBytes === "string" ? item.contentBytes : "";
|
|
154
|
-
if (!contentBytes) continue;
|
|
155
|
-
let buffer: Buffer;
|
|
156
|
-
try {
|
|
157
|
-
buffer = Buffer.from(contentBytes, "base64");
|
|
158
|
-
} catch {
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
if (buffer.byteLength > params.maxBytes) continue;
|
|
162
|
-
const mime = await getMSTeamsRuntime().media.detectMime({
|
|
163
|
-
buffer,
|
|
164
|
-
headerMime: item.contentType ?? undefined,
|
|
165
|
-
});
|
|
166
|
-
// Download any file type, not just images
|
|
167
|
-
try {
|
|
168
|
-
const saved = await getMSTeamsRuntime().channel.media.saveMediaBuffer(
|
|
169
|
-
buffer,
|
|
170
|
-
mime ?? item.contentType ?? undefined,
|
|
171
|
-
"inbound",
|
|
172
|
-
params.maxBytes,
|
|
173
|
-
);
|
|
174
|
-
out.push({
|
|
175
|
-
path: saved.path,
|
|
176
|
-
contentType: saved.contentType,
|
|
177
|
-
placeholder: inferPlaceholder({ contentType: saved.contentType }),
|
|
178
|
-
});
|
|
179
|
-
} catch {
|
|
180
|
-
// Ignore save failures.
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return { media: out, status: hosted.status, count: hosted.items.length };
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export async function downloadMSTeamsGraphMedia(params: {
|
|
188
|
-
messageUrl?: string | null;
|
|
189
|
-
tokenProvider?: MSTeamsAccessTokenProvider;
|
|
190
|
-
maxBytes: number;
|
|
191
|
-
allowHosts?: string[];
|
|
192
|
-
fetchFn?: typeof fetch;
|
|
193
|
-
/** When true, embeds original filename in stored path for later extraction. */
|
|
194
|
-
preserveFilenames?: boolean;
|
|
195
|
-
}): Promise<MSTeamsGraphMediaResult> {
|
|
196
|
-
if (!params.messageUrl || !params.tokenProvider) return { media: [] };
|
|
197
|
-
const allowHosts = resolveAllowedHosts(params.allowHosts);
|
|
198
|
-
const messageUrl = params.messageUrl;
|
|
199
|
-
let accessToken: string;
|
|
200
|
-
try {
|
|
201
|
-
accessToken = await params.tokenProvider.getAccessToken("https://graph.microsoft.com");
|
|
202
|
-
} catch {
|
|
203
|
-
return { media: [], messageUrl, tokenError: true };
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Fetch the full message to get SharePoint file attachments (for group chats)
|
|
207
|
-
const fetchFn = params.fetchFn ?? fetch;
|
|
208
|
-
const sharePointMedia: MSTeamsInboundMedia[] = [];
|
|
209
|
-
const downloadedReferenceUrls = new Set<string>();
|
|
210
|
-
try {
|
|
211
|
-
const msgRes = await fetchFn(messageUrl, {
|
|
212
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
213
|
-
});
|
|
214
|
-
if (msgRes.ok) {
|
|
215
|
-
const msgData = (await msgRes.json()) as {
|
|
216
|
-
body?: { content?: string; contentType?: string };
|
|
217
|
-
attachments?: Array<{
|
|
218
|
-
id?: string;
|
|
219
|
-
contentUrl?: string;
|
|
220
|
-
contentType?: string;
|
|
221
|
-
name?: string;
|
|
222
|
-
}>;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
// Extract SharePoint file attachments (contentType: "reference")
|
|
226
|
-
// Download any file type, not just images
|
|
227
|
-
const spAttachments = (msgData.attachments ?? []).filter(
|
|
228
|
-
(a) => a.contentType === "reference" && a.contentUrl && a.name,
|
|
229
|
-
);
|
|
230
|
-
for (const att of spAttachments) {
|
|
231
|
-
const name = att.name ?? "file";
|
|
232
|
-
|
|
233
|
-
try {
|
|
234
|
-
// SharePoint URLs need to be accessed via Graph shares API
|
|
235
|
-
const shareUrl = att.contentUrl!;
|
|
236
|
-
const encodedUrl = Buffer.from(shareUrl).toString("base64url");
|
|
237
|
-
const sharesUrl = `${GRAPH_ROOT}/shares/u!${encodedUrl}/driveItem/content`;
|
|
238
|
-
|
|
239
|
-
const spRes = await fetchFn(sharesUrl, {
|
|
240
|
-
headers: { Authorization: `Bearer ${accessToken}` },
|
|
241
|
-
redirect: "follow",
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
if (spRes.ok) {
|
|
245
|
-
const buffer = Buffer.from(await spRes.arrayBuffer());
|
|
246
|
-
if (buffer.byteLength <= params.maxBytes) {
|
|
247
|
-
const mime = await getMSTeamsRuntime().media.detectMime({
|
|
248
|
-
buffer,
|
|
249
|
-
headerMime: spRes.headers.get("content-type") ?? undefined,
|
|
250
|
-
filePath: name,
|
|
251
|
-
});
|
|
252
|
-
const originalFilename = params.preserveFilenames ? name : undefined;
|
|
253
|
-
const saved = await getMSTeamsRuntime().channel.media.saveMediaBuffer(
|
|
254
|
-
buffer,
|
|
255
|
-
mime ?? "application/octet-stream",
|
|
256
|
-
"inbound",
|
|
257
|
-
params.maxBytes,
|
|
258
|
-
originalFilename,
|
|
259
|
-
);
|
|
260
|
-
sharePointMedia.push({
|
|
261
|
-
path: saved.path,
|
|
262
|
-
contentType: saved.contentType,
|
|
263
|
-
placeholder: inferPlaceholder({ contentType: saved.contentType, fileName: name }),
|
|
264
|
-
});
|
|
265
|
-
downloadedReferenceUrls.add(shareUrl);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
} catch {
|
|
269
|
-
// Ignore SharePoint download failures.
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
} catch {
|
|
274
|
-
// Ignore message fetch failures.
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
const hosted = await downloadGraphHostedContent({
|
|
278
|
-
accessToken,
|
|
279
|
-
messageUrl,
|
|
280
|
-
maxBytes: params.maxBytes,
|
|
281
|
-
fetchFn: params.fetchFn,
|
|
282
|
-
preserveFilenames: params.preserveFilenames,
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
const attachments = await fetchGraphCollection<GraphAttachment>({
|
|
286
|
-
url: `${messageUrl}/attachments`,
|
|
287
|
-
accessToken,
|
|
288
|
-
fetchFn: params.fetchFn,
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
const normalizedAttachments = attachments.items.map(normalizeGraphAttachment);
|
|
292
|
-
const filteredAttachments =
|
|
293
|
-
sharePointMedia.length > 0
|
|
294
|
-
? normalizedAttachments.filter((att) => {
|
|
295
|
-
const contentType = att.contentType?.toLowerCase();
|
|
296
|
-
if (contentType !== "reference") return true;
|
|
297
|
-
const url = typeof att.contentUrl === "string" ? att.contentUrl : "";
|
|
298
|
-
if (!url) return true;
|
|
299
|
-
return !downloadedReferenceUrls.has(url);
|
|
300
|
-
})
|
|
301
|
-
: normalizedAttachments;
|
|
302
|
-
const attachmentMedia = await downloadMSTeamsAttachments({
|
|
303
|
-
attachments: filteredAttachments,
|
|
304
|
-
maxBytes: params.maxBytes,
|
|
305
|
-
tokenProvider: params.tokenProvider,
|
|
306
|
-
allowHosts,
|
|
307
|
-
fetchFn: params.fetchFn,
|
|
308
|
-
preserveFilenames: params.preserveFilenames,
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
media: [...sharePointMedia, ...hosted.media, ...attachmentMedia],
|
|
313
|
-
hostedCount: hosted.count,
|
|
314
|
-
attachmentCount: filteredAttachments.length + sharePointMedia.length,
|
|
315
|
-
hostedStatus: hosted.status,
|
|
316
|
-
attachmentStatus: attachments.status,
|
|
317
|
-
messageUrl,
|
|
318
|
-
};
|
|
319
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ATTACHMENT_TAG_RE,
|
|
3
|
-
extractHtmlFromAttachment,
|
|
4
|
-
extractInlineImageCandidates,
|
|
5
|
-
IMG_SRC_RE,
|
|
6
|
-
isLikelyImageAttachment,
|
|
7
|
-
safeHostForUrl,
|
|
8
|
-
} from "./shared.js";
|
|
9
|
-
import type { MSTeamsAttachmentLike, MSTeamsHtmlAttachmentSummary } from "./types.js";
|
|
10
|
-
|
|
11
|
-
export function summarizeMSTeamsHtmlAttachments(
|
|
12
|
-
attachments: MSTeamsAttachmentLike[] | undefined,
|
|
13
|
-
): MSTeamsHtmlAttachmentSummary | undefined {
|
|
14
|
-
const list = Array.isArray(attachments) ? attachments : [];
|
|
15
|
-
if (list.length === 0) return undefined;
|
|
16
|
-
let htmlAttachments = 0;
|
|
17
|
-
let imgTags = 0;
|
|
18
|
-
let dataImages = 0;
|
|
19
|
-
let cidImages = 0;
|
|
20
|
-
const srcHosts = new Set<string>();
|
|
21
|
-
let attachmentTags = 0;
|
|
22
|
-
const attachmentIds = new Set<string>();
|
|
23
|
-
|
|
24
|
-
for (const att of list) {
|
|
25
|
-
const html = extractHtmlFromAttachment(att);
|
|
26
|
-
if (!html) continue;
|
|
27
|
-
htmlAttachments += 1;
|
|
28
|
-
IMG_SRC_RE.lastIndex = 0;
|
|
29
|
-
let match: RegExpExecArray | null = IMG_SRC_RE.exec(html);
|
|
30
|
-
while (match) {
|
|
31
|
-
imgTags += 1;
|
|
32
|
-
const src = match[1]?.trim();
|
|
33
|
-
if (src) {
|
|
34
|
-
if (src.startsWith("data:")) dataImages += 1;
|
|
35
|
-
else if (src.startsWith("cid:")) cidImages += 1;
|
|
36
|
-
else srcHosts.add(safeHostForUrl(src));
|
|
37
|
-
}
|
|
38
|
-
match = IMG_SRC_RE.exec(html);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
ATTACHMENT_TAG_RE.lastIndex = 0;
|
|
42
|
-
let attachmentMatch: RegExpExecArray | null = ATTACHMENT_TAG_RE.exec(html);
|
|
43
|
-
while (attachmentMatch) {
|
|
44
|
-
attachmentTags += 1;
|
|
45
|
-
const id = attachmentMatch[1]?.trim();
|
|
46
|
-
if (id) attachmentIds.add(id);
|
|
47
|
-
attachmentMatch = ATTACHMENT_TAG_RE.exec(html);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (htmlAttachments === 0) return undefined;
|
|
52
|
-
return {
|
|
53
|
-
htmlAttachments,
|
|
54
|
-
imgTags,
|
|
55
|
-
dataImages,
|
|
56
|
-
cidImages,
|
|
57
|
-
srcHosts: Array.from(srcHosts).slice(0, 5),
|
|
58
|
-
attachmentTags,
|
|
59
|
-
attachmentIds: Array.from(attachmentIds).slice(0, 5),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function buildMSTeamsAttachmentPlaceholder(
|
|
64
|
-
attachments: MSTeamsAttachmentLike[] | undefined,
|
|
65
|
-
): string {
|
|
66
|
-
const list = Array.isArray(attachments) ? attachments : [];
|
|
67
|
-
if (list.length === 0) return "";
|
|
68
|
-
const imageCount = list.filter(isLikelyImageAttachment).length;
|
|
69
|
-
const inlineCount = extractInlineImageCandidates(list).length;
|
|
70
|
-
const totalImages = imageCount + inlineCount;
|
|
71
|
-
if (totalImages > 0) {
|
|
72
|
-
return `<media:image>${totalImages > 1 ? ` (${totalImages} images)` : ""}`;
|
|
73
|
-
}
|
|
74
|
-
const count = list.length;
|
|
75
|
-
return `<media:document>${count > 1 ? ` (${count} files)` : ""}`;
|
|
76
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export function buildMSTeamsMediaPayload(
|
|
2
|
-
mediaList: Array<{ path: string; contentType?: string }>,
|
|
3
|
-
): {
|
|
4
|
-
MediaPath?: string;
|
|
5
|
-
MediaType?: string;
|
|
6
|
-
MediaUrl?: string;
|
|
7
|
-
MediaPaths?: string[];
|
|
8
|
-
MediaUrls?: string[];
|
|
9
|
-
MediaTypes?: string[];
|
|
10
|
-
} {
|
|
11
|
-
const first = mediaList[0];
|
|
12
|
-
const mediaPaths = mediaList.map((media) => media.path);
|
|
13
|
-
const mediaTypes = mediaList.map((media) => media.contentType ?? "");
|
|
14
|
-
return {
|
|
15
|
-
MediaPath: first?.path,
|
|
16
|
-
MediaType: first?.contentType,
|
|
17
|
-
MediaUrl: first?.path,
|
|
18
|
-
MediaPaths: mediaPaths.length > 0 ? mediaPaths : undefined,
|
|
19
|
-
MediaUrls: mediaPaths.length > 0 ? mediaPaths : undefined,
|
|
20
|
-
MediaTypes: mediaPaths.length > 0 ? mediaTypes : undefined,
|
|
21
|
-
};
|
|
22
|
-
}
|