@gakr-gakr/msteams 0.1.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.
Files changed (107) hide show
  1. package/api.ts +3 -0
  2. package/autobot.plugin.json +15 -0
  3. package/channel-config-api.ts +1 -0
  4. package/channel-plugin-api.ts +2 -0
  5. package/config-api.ts +4 -0
  6. package/contract-api.ts +4 -0
  7. package/index.ts +20 -0
  8. package/package.json +72 -0
  9. package/runtime-api.ts +66 -0
  10. package/secret-contract-api.ts +5 -0
  11. package/setup-entry.ts +13 -0
  12. package/setup-plugin-api.ts +3 -0
  13. package/src/ai-entity.ts +7 -0
  14. package/src/approval-auth.ts +44 -0
  15. package/src/attachments/bot-framework.ts +348 -0
  16. package/src/attachments/download.ts +328 -0
  17. package/src/attachments/graph.ts +489 -0
  18. package/src/attachments/html.ts +122 -0
  19. package/src/attachments/payload.ts +14 -0
  20. package/src/attachments/remote-media.ts +86 -0
  21. package/src/attachments/shared.ts +655 -0
  22. package/src/attachments/types.ts +47 -0
  23. package/src/attachments.ts +18 -0
  24. package/src/channel-api.ts +1 -0
  25. package/src/channel.runtime.ts +56 -0
  26. package/src/channel.setup.ts +77 -0
  27. package/src/channel.ts +1176 -0
  28. package/src/config-schema.ts +6 -0
  29. package/src/config-ui-hints.ts +40 -0
  30. package/src/conversation-store-fs.ts +149 -0
  31. package/src/conversation-store-helpers.ts +105 -0
  32. package/src/conversation-store-memory.ts +51 -0
  33. package/src/conversation-store.ts +71 -0
  34. package/src/directory-live.ts +111 -0
  35. package/src/doctor.ts +27 -0
  36. package/src/errors.ts +270 -0
  37. package/src/feedback-reflection-prompt.ts +117 -0
  38. package/src/feedback-reflection-store.ts +113 -0
  39. package/src/feedback-reflection.ts +271 -0
  40. package/src/file-consent-helpers.ts +115 -0
  41. package/src/file-consent-invoke.ts +150 -0
  42. package/src/file-consent.ts +223 -0
  43. package/src/graph-chat.ts +36 -0
  44. package/src/graph-group-management.ts +168 -0
  45. package/src/graph-members.ts +48 -0
  46. package/src/graph-messages.ts +534 -0
  47. package/src/graph-teams.ts +114 -0
  48. package/src/graph-thread.ts +146 -0
  49. package/src/graph-upload.ts +531 -0
  50. package/src/graph-users.ts +29 -0
  51. package/src/graph.ts +308 -0
  52. package/src/inbound.ts +148 -0
  53. package/src/index.ts +4 -0
  54. package/src/media-helpers.ts +105 -0
  55. package/src/mentions.ts +114 -0
  56. package/src/messenger.ts +608 -0
  57. package/src/monitor-handler/access.ts +136 -0
  58. package/src/monitor-handler/inbound-media.ts +180 -0
  59. package/src/monitor-handler/message-handler-mock-support.test-support.ts +28 -0
  60. package/src/monitor-handler/message-handler.test-support.ts +102 -0
  61. package/src/monitor-handler/message-handler.ts +1015 -0
  62. package/src/monitor-handler/reaction-handler.ts +124 -0
  63. package/src/monitor-handler/thread-session.ts +30 -0
  64. package/src/monitor-handler.ts +538 -0
  65. package/src/monitor-handler.types.ts +27 -0
  66. package/src/monitor-types.ts +6 -0
  67. package/src/monitor.ts +476 -0
  68. package/src/oauth.flow.ts +77 -0
  69. package/src/oauth.shared.ts +37 -0
  70. package/src/oauth.token.ts +162 -0
  71. package/src/oauth.ts +130 -0
  72. package/src/outbound.ts +198 -0
  73. package/src/pending-uploads-fs.ts +235 -0
  74. package/src/pending-uploads.ts +121 -0
  75. package/src/policy.ts +245 -0
  76. package/src/polls-store-memory.ts +32 -0
  77. package/src/polls.ts +312 -0
  78. package/src/presentation.ts +93 -0
  79. package/src/probe.ts +132 -0
  80. package/src/reply-dispatcher.ts +523 -0
  81. package/src/reply-stream-controller.ts +334 -0
  82. package/src/resolve-allowlist.ts +309 -0
  83. package/src/revoked-context.ts +17 -0
  84. package/src/runtime.ts +12 -0
  85. package/src/sdk-types.ts +59 -0
  86. package/src/sdk.ts +916 -0
  87. package/src/secret-contract.ts +49 -0
  88. package/src/secret-input.ts +7 -0
  89. package/src/send-context.ts +269 -0
  90. package/src/send.ts +697 -0
  91. package/src/sent-message-cache.ts +174 -0
  92. package/src/session-route.ts +40 -0
  93. package/src/setup-core.ts +162 -0
  94. package/src/setup-surface.ts +319 -0
  95. package/src/sso-token-store.ts +166 -0
  96. package/src/sso.ts +300 -0
  97. package/src/storage.ts +25 -0
  98. package/src/store-fs.ts +42 -0
  99. package/src/streaming-message.ts +327 -0
  100. package/src/thread-parent-context.ts +159 -0
  101. package/src/token-response.ts +11 -0
  102. package/src/token.ts +194 -0
  103. package/src/user-agent.ts +53 -0
  104. package/src/webhook-timeouts.ts +27 -0
  105. package/src/welcome-card.ts +57 -0
  106. package/test-api.ts +1 -0
  107. package/tsconfig.json +16 -0
@@ -0,0 +1,18 @@
1
+ export {
2
+ downloadMSTeamsBotFrameworkAttachments,
3
+ isBotFrameworkPersonalChatId,
4
+ } from "./attachments/bot-framework.js";
5
+ export { downloadMSTeamsAttachments } from "./attachments/download.js";
6
+ export { buildMSTeamsGraphMessageUrls, downloadMSTeamsGraphMedia } from "./attachments/graph.js";
7
+ export {
8
+ buildMSTeamsAttachmentPlaceholder,
9
+ extractMSTeamsHtmlAttachmentIds,
10
+ summarizeMSTeamsHtmlAttachments,
11
+ } from "./attachments/html.js";
12
+ export { buildMSTeamsMediaPayload } from "./attachments/payload.js";
13
+ export type {
14
+ MSTeamsAccessTokenProvider,
15
+ MSTeamsAttachmentLike,
16
+ MSTeamsHtmlAttachmentSummary,
17
+ MSTeamsInboundMedia,
18
+ } from "./attachments/types.js";
@@ -0,0 +1 @@
1
+ export type { ChannelPlugin } from "autobot/plugin-sdk/channel-core";
@@ -0,0 +1,56 @@
1
+ import {
2
+ listMSTeamsDirectoryGroupsLive as listMSTeamsDirectoryGroupsLiveImpl,
3
+ listMSTeamsDirectoryPeersLive as listMSTeamsDirectoryPeersLiveImpl,
4
+ } from "./directory-live.js";
5
+ import {
6
+ addParticipantMSTeams as addParticipantMSTeamsImpl,
7
+ removeParticipantMSTeams as removeParticipantMSTeamsImpl,
8
+ renameGroupMSTeams as renameGroupMSTeamsImpl,
9
+ } from "./graph-group-management.js";
10
+ import { getMemberInfoMSTeams as getMemberInfoMSTeamsImpl } from "./graph-members.js";
11
+ import {
12
+ getMessageMSTeams as getMessageMSTeamsImpl,
13
+ listPinsMSTeams as listPinsMSTeamsImpl,
14
+ listReactionsMSTeams as listReactionsMSTeamsImpl,
15
+ pinMessageMSTeams as pinMessageMSTeamsImpl,
16
+ reactMessageMSTeams as reactMessageMSTeamsImpl,
17
+ searchMessagesMSTeams as searchMessagesMSTeamsImpl,
18
+ unpinMessageMSTeams as unpinMessageMSTeamsImpl,
19
+ unreactMessageMSTeams as unreactMessageMSTeamsImpl,
20
+ } from "./graph-messages.js";
21
+ import {
22
+ listChannelsMSTeams as listChannelsMSTeamsImpl,
23
+ getChannelInfoMSTeams as getChannelInfoMSTeamsImpl,
24
+ } from "./graph-teams.js";
25
+ import { msteamsOutbound as msteamsOutboundImpl } from "./outbound.js";
26
+ import { probeMSTeams as probeMSTeamsImpl } from "./probe.js";
27
+ import {
28
+ deleteMessageMSTeams as deleteMessageMSTeamsImpl,
29
+ editMessageMSTeams as editMessageMSTeamsImpl,
30
+ sendAdaptiveCardMSTeams as sendAdaptiveCardMSTeamsImpl,
31
+ sendMessageMSTeams as sendMessageMSTeamsImpl,
32
+ } from "./send.js";
33
+ export const msTeamsChannelRuntime = {
34
+ addParticipantMSTeams: addParticipantMSTeamsImpl,
35
+ deleteMessageMSTeams: deleteMessageMSTeamsImpl,
36
+ editMessageMSTeams: editMessageMSTeamsImpl,
37
+ getChannelInfoMSTeams: getChannelInfoMSTeamsImpl,
38
+ getMemberInfoMSTeams: getMemberInfoMSTeamsImpl,
39
+ getMessageMSTeams: getMessageMSTeamsImpl,
40
+ listChannelsMSTeams: listChannelsMSTeamsImpl,
41
+ listPinsMSTeams: listPinsMSTeamsImpl,
42
+ listReactionsMSTeams: listReactionsMSTeamsImpl,
43
+ pinMessageMSTeams: pinMessageMSTeamsImpl,
44
+ reactMessageMSTeams: reactMessageMSTeamsImpl,
45
+ removeParticipantMSTeams: removeParticipantMSTeamsImpl,
46
+ renameGroupMSTeams: renameGroupMSTeamsImpl,
47
+ searchMessagesMSTeams: searchMessagesMSTeamsImpl,
48
+ unpinMessageMSTeams: unpinMessageMSTeamsImpl,
49
+ unreactMessageMSTeams: unreactMessageMSTeamsImpl,
50
+ listMSTeamsDirectoryGroupsLive: listMSTeamsDirectoryGroupsLiveImpl,
51
+ listMSTeamsDirectoryPeersLive: listMSTeamsDirectoryPeersLiveImpl,
52
+ msteamsOutbound: { ...msteamsOutboundImpl },
53
+ probeMSTeams: probeMSTeamsImpl,
54
+ sendAdaptiveCardMSTeams: sendAdaptiveCardMSTeamsImpl,
55
+ sendMessageMSTeams: sendMessageMSTeamsImpl,
56
+ };
@@ -0,0 +1,77 @@
1
+ import { describeAccountSnapshot } from "autobot/plugin-sdk/account-helpers";
2
+ import { formatAllowFromLowercase } from "autobot/plugin-sdk/allow-from";
3
+ import { createTopLevelChannelConfigAdapter } from "autobot/plugin-sdk/channel-config-helpers";
4
+ import type { ChannelPlugin } from "autobot/plugin-sdk/channel-core";
5
+ import type { AutoBotConfig } from "autobot/plugin-sdk/config-contracts";
6
+ import { MSTeamsChannelConfigSchema } from "./config-schema.js";
7
+ import { msteamsSetupAdapter } from "./setup-core.js";
8
+ import { msteamsSetupWizard } from "./setup-surface.js";
9
+ import { resolveMSTeamsCredentials } from "./token.js";
10
+
11
+ type ResolvedMSTeamsAccount = {
12
+ accountId: string;
13
+ enabled: boolean;
14
+ configured: boolean;
15
+ };
16
+
17
+ const meta = {
18
+ id: "msteams",
19
+ label: "Microsoft Teams",
20
+ selectionLabel: "Microsoft Teams (Bot Framework)",
21
+ docsPath: "/channels/msteams",
22
+ docsLabel: "msteams",
23
+ blurb: "Teams SDK; enterprise support.",
24
+ aliases: ["teams"],
25
+ order: 60,
26
+ } as const;
27
+
28
+ const resolveMSTeamsChannelConfig = (cfg: AutoBotConfig) => ({
29
+ allowFrom: cfg.channels?.msteams?.allowFrom,
30
+ defaultTo: cfg.channels?.msteams?.defaultTo,
31
+ });
32
+
33
+ const msteamsConfigAdapter = createTopLevelChannelConfigAdapter<
34
+ ResolvedMSTeamsAccount,
35
+ {
36
+ allowFrom?: Array<string | number>;
37
+ defaultTo?: string;
38
+ }
39
+ >({
40
+ sectionKey: "msteams",
41
+ resolveAccount: (cfg) => ({
42
+ accountId: "default",
43
+ enabled: cfg.channels?.msteams?.enabled !== false,
44
+ configured: Boolean(resolveMSTeamsCredentials(cfg.channels?.msteams)),
45
+ }),
46
+ resolveAccessorAccount: ({ cfg }) => resolveMSTeamsChannelConfig(cfg),
47
+ resolveAllowFrom: (account) => account.allowFrom,
48
+ formatAllowFrom: (allowFrom) => formatAllowFromLowercase({ allowFrom }),
49
+ resolveDefaultTo: (account) => account.defaultTo,
50
+ });
51
+
52
+ export const msteamsSetupPlugin: ChannelPlugin<ResolvedMSTeamsAccount> = {
53
+ id: "msteams",
54
+ meta: {
55
+ ...meta,
56
+ aliases: [...meta.aliases],
57
+ },
58
+ capabilities: {
59
+ chatTypes: ["direct", "channel", "thread"],
60
+ polls: true,
61
+ threads: true,
62
+ media: true,
63
+ },
64
+ reload: { configPrefixes: ["channels.msteams"] },
65
+ configSchema: MSTeamsChannelConfigSchema,
66
+ config: {
67
+ ...msteamsConfigAdapter,
68
+ isConfigured: (_account, cfg) => Boolean(resolveMSTeamsCredentials(cfg.channels?.msteams)),
69
+ describeAccount: (account) =>
70
+ describeAccountSnapshot({
71
+ account,
72
+ configured: account.configured,
73
+ }),
74
+ },
75
+ setupWizard: msteamsSetupWizard,
76
+ setup: msteamsSetupAdapter,
77
+ };