@moda-labs/bobi-events-core 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 (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +32 -0
  3. package/dist/adapters/chat-sdk-slack.d.ts +18 -0
  4. package/dist/adapters/chat-sdk-slack.d.ts.map +1 -0
  5. package/dist/adapters/chat-sdk-slack.js +201 -0
  6. package/dist/adapters/chat-sdk-slack.js.map +1 -0
  7. package/dist/adapters/github.d.ts +3 -0
  8. package/dist/adapters/github.d.ts.map +1 -0
  9. package/dist/adapters/github.js +114 -0
  10. package/dist/adapters/github.js.map +1 -0
  11. package/dist/adapters/linear.d.ts +3 -0
  12. package/dist/adapters/linear.d.ts.map +1 -0
  13. package/dist/adapters/linear.js +47 -0
  14. package/dist/adapters/linear.js.map +1 -0
  15. package/dist/adapters/whatsapp.d.ts +25 -0
  16. package/dist/adapters/whatsapp.d.ts.map +1 -0
  17. package/dist/adapters/whatsapp.js +96 -0
  18. package/dist/adapters/whatsapp.js.map +1 -0
  19. package/dist/channels.d.ts +80 -0
  20. package/dist/channels.d.ts.map +1 -0
  21. package/dist/channels.js +499 -0
  22. package/dist/channels.js.map +1 -0
  23. package/dist/circuit-breaker.d.ts +79 -0
  24. package/dist/circuit-breaker.d.ts.map +1 -0
  25. package/dist/circuit-breaker.js +288 -0
  26. package/dist/circuit-breaker.js.map +1 -0
  27. package/dist/conversation.d.ts +29 -0
  28. package/dist/conversation.d.ts.map +1 -0
  29. package/dist/conversation.js +86 -0
  30. package/dist/conversation.js.map +1 -0
  31. package/dist/core.d.ts +254 -0
  32. package/dist/core.d.ts.map +1 -0
  33. package/dist/core.js +1775 -0
  34. package/dist/core.js.map +1 -0
  35. package/package.json +40 -0
  36. package/src/adapters/chat-sdk-slack.ts +209 -0
  37. package/src/adapters/github.ts +111 -0
  38. package/src/adapters/linear.ts +53 -0
  39. package/src/adapters/whatsapp.ts +120 -0
  40. package/src/channels.ts +600 -0
  41. package/src/circuit-breaker.ts +337 -0
  42. package/src/conversation.ts +96 -0
  43. package/src/core.ts +2413 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Moda Labs
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @moda-labs/bobi-events-core
2
+
3
+ Runtime-agnostic core of the [Bobi](https://github.com/moda-labs/bobi-agent)
4
+ event protocol: normalized events, the webhook ingest pipeline, channel
5
+ adapters (Slack, WhatsApp, GitHub, Linear), conversation references, and the
6
+ delivery circuit breaker. Consumed by both the local Node event server
7
+ (bundled with Bobi) and Cloudflare Worker deployments.
8
+
9
+ ## Entry points
10
+
11
+ - `@moda-labs/bobi-events-core` - normalized event model, topic keys, webhook
12
+ pipeline, signatures.
13
+ - `./channels` - outbound channel adapters and send helpers.
14
+ - `./conversation` - channel-agnostic conversation reference codec.
15
+ - `./circuit-breaker` - delivery loop detection.
16
+ - `./adapters/chat-sdk-slack` - Slack Chat SDK webhook bridge.
17
+
18
+ ## Development
19
+
20
+ This package lives in the `bobi-agent` repo as the `event-server/core/`
21
+ workspace. The workspace manifest is `private: true` and exports TypeScript
22
+ sources directly; do not publish it as-is. The publishable tarball (compiled
23
+ ESM + `.d.ts`, exports pointing at `dist/`) is produced by:
24
+
25
+ ```bash
26
+ # from event-server/
27
+ npm run pack:publish -w core # build dist/ + npm pack, prints tarball path
28
+ npm run smoke -w core # pack + install into a scratch consumer + verify
29
+ ```
30
+
31
+ Docs: `docs/EVENT_SERVER.md` in the repo covers the architecture, topics, and
32
+ security model.
@@ -0,0 +1,18 @@
1
+ import type { SlackNormalizationResult } from "../core.js";
2
+ export type ChatSdkBridgeResult = SlackNormalizationResult;
3
+ /**
4
+ * Whether *text* @-mentions any of OUR bot users (`<@Uxxx>` or `<@Uxxx|label>`).
5
+ * Accepts a bare string for single-bot callers/tests.
6
+ */
7
+ export declare function mentionsAnySelfUser(text: string, selfBotUserIds?: string | Iterable<string>): boolean;
8
+ /**
9
+ * Bridge the Chat SDK's Slack webhook parsing into our NormalizedEvent
10
+ * envelope.
11
+ *
12
+ * @param body - Raw JSON string from the Slack webhook POST body
13
+ * @param selfBotId - Our bot's ID, used to filter self-loop messages
14
+ * @param payload - Optional pre-parsed body (callers that already parsed it
15
+ * for signature/challenge handling pass it to avoid a second JSON.parse)
16
+ */
17
+ export declare function bridgeSlackWebhook(body: string, selfBotIds?: string | Iterable<string>, selfBotUserIds?: string | Iterable<string>, payload?: Record<string, unknown>): ChatSdkBridgeResult;
18
+ //# sourceMappingURL=chat-sdk-slack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-sdk-slack.d.ts","sourceRoot":"","sources":["../../src/adapters/chat-sdk-slack.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAmB,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAG5E,MAAM,MAAM,mBAAmB,GAAG,wBAAwB,CAAC;AAM3D;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GACxC,OAAO,CAQT;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,MAAM,EAGZ,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,EACtC,cAAc,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,EAC1C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,mBAAmB,CA8JrB"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Chat SDK adapter for Slack inbound webhooks (#191, #628).
3
+ *
4
+ * Wraps the Chat SDK's Slack webhook parser to produce our NormalizedEvent
5
+ * envelope. This is the only Slack inbound normalizer; it replaced the
6
+ * hand-rolled normalizeSlackWebhook once the bridge soaked (#629, #647).
7
+ */
8
+ import { parseSlackWebhookBody } from "@chat-adapter/slack/webhook";
9
+ import { slackConversation } from "../conversation.js";
10
+ function escapeRegExp(value) {
11
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
12
+ }
13
+ /**
14
+ * Whether *text* @-mentions any of OUR bot users (`<@Uxxx>` or `<@Uxxx|label>`).
15
+ * Accepts a bare string for single-bot callers/tests.
16
+ */
17
+ export function mentionsAnySelfUser(text, selfBotUserIds) {
18
+ const ids = typeof selfBotUserIds === "string"
19
+ ? new Set([selfBotUserIds])
20
+ : new Set(selfBotUserIds ?? []);
21
+ return ids.size > 0
22
+ && [...ids].some((id) => new RegExp(`<@${escapeRegExp(id)}(?:\\|[^>]+)?>`).test(text));
23
+ }
24
+ /**
25
+ * Bridge the Chat SDK's Slack webhook parsing into our NormalizedEvent
26
+ * envelope.
27
+ *
28
+ * @param body - Raw JSON string from the Slack webhook POST body
29
+ * @param selfBotId - Our bot's ID, used to filter self-loop messages
30
+ * @param payload - Optional pre-parsed body (callers that already parsed it
31
+ * for signature/challenge handling pass it to avoid a second JSON.parse)
32
+ */
33
+ export function bridgeSlackWebhook(body,
34
+ // A workspace may host several of our bots, so both filters take a set
35
+ // (bare string accepted for single-bot callers/tests).
36
+ selfBotIds, selfBotUserIds, payload) {
37
+ let parsed;
38
+ try {
39
+ parsed = parseSlackWebhookBody(body);
40
+ }
41
+ catch (err) {
42
+ // Never silent: a parser rejection here drops a user message. Keep the
43
+ // skip (the route must still 200 so Slack stops retrying) but log it.
44
+ console.warn(`chat-sdk bridge failed to parse Slack webhook: ${String(err)}`);
45
+ return { event: null, skip: true };
46
+ }
47
+ // url_verification — return challenge, skip event processing
48
+ // Chat SDK uses `kind` as the discriminant field
49
+ if (parsed.kind === "url_verification") {
50
+ return {
51
+ event: null,
52
+ challenge: parsed.challenge,
53
+ skip: true,
54
+ };
55
+ }
56
+ // We only process event_callback payloads
57
+ const raw = payload ?? JSON.parse(body);
58
+ if (raw.type !== "event_callback") {
59
+ return { event: null, skip: true };
60
+ }
61
+ const innerEvent = raw.event;
62
+ if (!innerEvent)
63
+ return { event: null, skip: true };
64
+ // Skip subtypes (message_changed, message_deleted, etc.)
65
+ if (innerEvent.subtype) {
66
+ return { event: null, skip: true };
67
+ }
68
+ // Self-loop filter: skip messages authored by ANY of our bots - both to
69
+ // stop a bot looping on itself and to stop two of our bots looping on
70
+ // each other. Messages from third-party bots (not ours) pass through.
71
+ const selfSet = typeof selfBotIds === "string"
72
+ ? new Set([selfBotIds])
73
+ : new Set(selfBotIds ?? []);
74
+ if (innerEvent.bot_id && selfSet.has(innerEvent.bot_id)) {
75
+ return { event: null, skip: true };
76
+ }
77
+ // Classify event type
78
+ const eventType = innerEvent.type;
79
+ const channelType = innerEvent.channel_type || "";
80
+ const threadTs = innerEvent.thread_ts || "";
81
+ const rawText = (innerEvent.text || "").slice(0, 4000);
82
+ // Mention/message dedup: a channel @mention arrives as both app_mention
83
+ // and message.* with the same ts; drop the message copy so one human
84
+ // message yields one event.
85
+ const mentionsSelfUser = mentionsAnySelfUser(rawText, selfBotUserIds);
86
+ let slackEventType;
87
+ if (eventType === "app_mention") {
88
+ slackEventType = "slack.mention";
89
+ }
90
+ else if (eventType === "message" && mentionsSelfUser && channelType !== "im" && channelType !== "mpim") {
91
+ return { event: null, skip: true };
92
+ }
93
+ else if (channelType === "im" || channelType === "mpim") {
94
+ slackEventType = "slack.dm";
95
+ }
96
+ else if (threadTs) {
97
+ slackEventType = "slack.thread_reply";
98
+ }
99
+ else {
100
+ return { event: null, skip: true };
101
+ }
102
+ const teamId = raw.team_id || "";
103
+ const appId = raw.api_app_id || "";
104
+ const channel = innerEvent.channel || "";
105
+ const userId = innerEvent.user || "";
106
+ const ts = innerEvent.ts || "";
107
+ const isDm = channelType === "im" || channelType === "mpim";
108
+ // Legacy workspace/channel topics are emitted ONLY when Slack omits
109
+ // api_app_id. Emitting both app-qualified and legacy topics lets stale
110
+ // legacy subscriptions cross-deliver events between two apps in the same
111
+ // workspace.
112
+ const topics = [];
113
+ if (teamId) {
114
+ if (appId) {
115
+ topics.push(`slack:${teamId}:app:${appId}`);
116
+ }
117
+ else {
118
+ topics.push(`slack:${teamId}`);
119
+ }
120
+ if (channel && !isDm) {
121
+ if (appId) {
122
+ topics.push(`slack:${teamId}:app:${appId}:${channel}`);
123
+ }
124
+ else {
125
+ topics.push(`slack:${teamId}:${channel}`);
126
+ }
127
+ }
128
+ }
129
+ const botId = innerEvent.bot_id || "";
130
+ // Extract file attachments (images, documents, etc.) from the event.
131
+ // Slack includes a `files` array on messages with shared files.
132
+ const rawFiles = innerEvent.files;
133
+ const files = [];
134
+ if (Array.isArray(rawFiles)) {
135
+ for (const f of rawFiles) {
136
+ const entry = {};
137
+ if (f.id)
138
+ entry.id = String(f.id);
139
+ if (f.name)
140
+ entry.name = String(f.name);
141
+ if (f.mimetype)
142
+ entry.mimetype = String(f.mimetype);
143
+ if (f.filetype)
144
+ entry.filetype = String(f.filetype);
145
+ if (f.url_private)
146
+ entry.url_private = String(f.url_private);
147
+ if (f.url_private_download)
148
+ entry.url_private_download = String(f.url_private_download);
149
+ if (f.size)
150
+ entry.size = String(f.size);
151
+ files.push(entry);
152
+ }
153
+ }
154
+ const fields = {};
155
+ if (userId)
156
+ fields.user_id = userId;
157
+ if (channel)
158
+ fields.channel = channel;
159
+ if (channelType)
160
+ fields.channel_type = channelType;
161
+ if (appId)
162
+ fields.api_app_id = appId;
163
+ if (ts)
164
+ fields.ts = ts;
165
+ if (threadTs)
166
+ fields.thread_ts = threadTs;
167
+ // Preserve bot_id so the circuit breaker can detect bot authorship.
168
+ if (botId)
169
+ fields.bot_id = botId;
170
+ if (files.length > 0)
171
+ fields.files = JSON.stringify(files);
172
+ // Channel-agnostic reply address (#618). Anchoring policy lives in
173
+ // slackConversation.
174
+ const conversation = slackConversation(teamId, channel, channelType, ts, threadTs);
175
+ return {
176
+ event: {
177
+ v: 2,
178
+ id: raw.event_id || crypto.randomUUID(),
179
+ source: "slack",
180
+ type: slackEventType,
181
+ topics,
182
+ delivery: "chat",
183
+ text: rawText,
184
+ ...(conversation ? { conversation } : {}),
185
+ fields,
186
+ timestamp: new Date().toISOString(),
187
+ payload: {
188
+ user_id: userId,
189
+ channel,
190
+ channel_type: channelType,
191
+ text: rawText,
192
+ ts,
193
+ thread_ts: threadTs,
194
+ ...(botId ? { bot_id: botId } : {}),
195
+ ...(files.length > 0 ? { files } : {}),
196
+ },
197
+ },
198
+ skip: false,
199
+ };
200
+ }
201
+ //# sourceMappingURL=chat-sdk-slack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-sdk-slack.js","sourceRoot":"","sources":["../../src/adapters/chat-sdk-slack.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIvD,SAAS,YAAY,CAAC,KAAa;IAClC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAClC,IAAY,EACZ,cAA0C;IAE1C,MAAM,GAAG,GACR,OAAO,cAAc,KAAK,QAAQ;QACjC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;QAC3B,CAAC,CAAC,IAAI,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;IAClC,OAAO,GAAG,CAAC,IAAI,GAAG,CAAC;WACf,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CACvB,IAAI,MAAM,CAAC,KAAK,YAAY,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CACjC,IAAY;AACZ,uEAAu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AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { NormalizedEvent } from "../core.js";
2
+ export declare function normalizeGitHubWebhook(eventHeader: string, deliveryId: string, payload: Record<string, unknown>): NormalizedEvent | null;
3
+ //# sourceMappingURL=github.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/adapters/github.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,eAAe,GAAG,IAAI,CAwGxB"}
@@ -0,0 +1,114 @@
1
+ export function normalizeGitHubWebhook(eventHeader, deliveryId, payload) {
2
+ const repo = payload.repository;
3
+ const repoFullName = repo?.full_name;
4
+ if (!repoFullName)
5
+ return null;
6
+ const action = payload.action;
7
+ // Extract the primary object (issue, PR, etc.)
8
+ const issue = payload.issue;
9
+ const pr = payload.pull_request;
10
+ const obj = issue || pr;
11
+ // Build fields — structurally guarantees key data is always present,
12
+ // making the issues.assigned miss (Finding 4) impossible.
13
+ const fields = {};
14
+ if (action)
15
+ fields.action = action;
16
+ if (payload.sender) {
17
+ const sender = payload.sender;
18
+ if (sender.login)
19
+ fields.sender = sender.login;
20
+ }
21
+ if (obj) {
22
+ const num = obj.number;
23
+ const title = obj.title;
24
+ const state = obj.state;
25
+ const url = obj.html_url;
26
+ if (num !== undefined)
27
+ fields.number = num;
28
+ if (title)
29
+ fields.title = title;
30
+ if (state)
31
+ fields.state = state;
32
+ if (url)
33
+ fields.url = url;
34
+ // Assignee(s) — always extracted when present
35
+ const assignee = obj.assignee;
36
+ const assignees = obj.assignees;
37
+ if (assignees?.length) {
38
+ fields.assignees = assignees.map((a) => a.login).join(", ");
39
+ }
40
+ else if (assignee?.login) {
41
+ fields.assignee = assignee.login;
42
+ }
43
+ }
44
+ // PR-specific fields — merged status and head branch for cleanup dispatch
45
+ if (pr) {
46
+ const head = pr.head;
47
+ if (head?.ref)
48
+ fields.head_branch = head.ref;
49
+ if (typeof pr.merged === "boolean")
50
+ fields.merged = pr.merged;
51
+ }
52
+ // Review-specific fields — pull_request_review and pull_request_review_comment
53
+ // carry a review/comment object with state, body, and file context that the
54
+ // consuming agent needs to decide whether to dispatch pr-feedback. The review
55
+ // id is a stable per-review identifier used to dedup dispatch (issue #411).
56
+ const review = payload.review;
57
+ if (review) {
58
+ if (review.state)
59
+ fields.review_state = review.state;
60
+ if (review.body)
61
+ fields.review_body = review.body.slice(0, 500);
62
+ if (review.html_url)
63
+ fields.review_url = review.html_url;
64
+ if (review.id !== undefined)
65
+ fields.review_id = review.id;
66
+ }
67
+ const comment = payload.comment;
68
+ if (comment && (eventHeader === "pull_request_review_comment" ||
69
+ eventHeader === "issue_comment")) {
70
+ if (comment.body)
71
+ fields.comment_body = comment.body.slice(0, 500);
72
+ if (comment.html_url)
73
+ fields.comment_url = comment.html_url;
74
+ }
75
+ if (comment && eventHeader === "pull_request_review_comment") {
76
+ if (comment.path)
77
+ fields.comment_path = comment.path;
78
+ }
79
+ // Stable per-comment id — dedups dispatch so one comment can't fan out into
80
+ // multiple feedback engines (issue #411). Present on issue_comment and
81
+ // pull_request_review_comment payloads.
82
+ if (comment && (eventHeader === "pull_request_review_comment" ||
83
+ eventHeader === "issue_comment")) {
84
+ if (comment.id !== undefined)
85
+ fields.comment_id = comment.id;
86
+ }
87
+ // issue_comment on a PR — GitHub sends issue_comment for both issues and
88
+ // PRs, but includes a pull_request key on the issue when it's a PR.
89
+ if (eventHeader === "issue_comment" && issue) {
90
+ const prRef = issue.pull_request;
91
+ if (prRef) {
92
+ fields.is_pull_request = true;
93
+ }
94
+ }
95
+ // Human-readable text summary
96
+ const objLabel = pr ? "PR" : issue ? "issue" : eventHeader;
97
+ const objNum = obj?.number ? `#${obj.number}` : "";
98
+ const objTitle = obj?.title ? ` ${obj.title}` : "";
99
+ const reviewSuffix = review?.state ? ` (${review.state})` : "";
100
+ const text = `[${repoFullName}] ${action || eventHeader} ${objLabel} ${objNum}${objTitle}${reviewSuffix}`.trim();
101
+ return {
102
+ v: 2,
103
+ id: deliveryId || crypto.randomUUID(),
104
+ source: "github",
105
+ type: `github.${eventHeader}`,
106
+ topics: [`github:${repoFullName}`],
107
+ delivery: "bulk",
108
+ text,
109
+ fields,
110
+ timestamp: new Date().toISOString(),
111
+ payload,
112
+ };
113
+ }
114
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.js","sourceRoot":"","sources":["../../src/adapters/github.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CACrC,WAAmB,EACnB,UAAkB,EAClB,OAAgC;IAEhC,MAAM,IAAI,GAAG,OAAO,CAAC,UAAiD,CAAC;IACvE,MAAM,YAAY,GAAG,IAAI,EAAE,SAA+B,CAAC;IAE3D,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAE/B,MAAM,MAAM,GAAG,OAAO,CAAC,MAA4B,CAAC;IAEpD,+CAA+C;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,KAA4C,CAAC;IACnE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAmD,CAAC;IACvE,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE,CAAC;IAExB,qEAAqE;IACrE,0DAA0D;IAC1D,MAAM,MAAM,GAA8C,EAAE,CAAC;IAC7D,IAAI,MAAM;QAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACnC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAiC,CAAC;QACzD,IAAI,MAAM,CAAC,KAAK;YAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,KAAe,CAAC;IAC1D,CAAC;IACD,IAAI,GAAG,EAAE,CAAC;QACT,MAAM,GAAG,GA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,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { NormalizedEvent } from "../core.js";
2
+ export declare function normalizeLinearWebhook(payload: Record<string, unknown>, deliveryId?: string): NormalizedEvent;
3
+ //# sourceMappingURL=linear.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linear.d.ts","sourceRoot":"","sources":["../../src/adapters/linear.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAWlD,wBAAgB,sBAAsB,CACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,UAAU,SAAK,GACb,eAAe,CAsCjB"}
@@ -0,0 +1,47 @@
1
+ function asRecord(value) {
2
+ return value && typeof value === "object" ? value : undefined;
3
+ }
4
+ function stringField(record, key) {
5
+ const value = record?.[key];
6
+ return typeof value === "string" ? value : undefined;
7
+ }
8
+ export function normalizeLinearWebhook(payload, deliveryId = "") {
9
+ const action = payload.action || "unknown";
10
+ const dataType = payload.type || "unknown";
11
+ const data = asRecord(payload.data);
12
+ const issue = asRecord(data?.issue);
13
+ const teamKey = stringField(asRecord(data?.team), "key") || stringField(asRecord(issue?.team), "key");
14
+ const identifier = stringField(data, "identifier") || stringField(issue, "identifier") || "";
15
+ const title = stringField(data, "title") || stringField(issue, "title") || "";
16
+ const state = asRecord(data?.state) || asRecord(issue?.state);
17
+ const stateName = stringField(state, "name");
18
+ const url = stringField(data, "url") || stringField(issue, "url");
19
+ const topics = [];
20
+ if (teamKey)
21
+ topics.push(`linear:${teamKey}`);
22
+ const fields = { action };
23
+ if (data) {
24
+ if (identifier)
25
+ fields.identifier = identifier;
26
+ if (title)
27
+ fields.title = title;
28
+ if (stateName)
29
+ fields.state = stateName;
30
+ if (url)
31
+ fields.url = url;
32
+ }
33
+ const text = `[Linear] ${action} ${dataType} ${identifier} ${title}`.trim();
34
+ return {
35
+ v: 2,
36
+ id: deliveryId || crypto.randomUUID(),
37
+ source: "linear",
38
+ type: `linear.${dataType}.${action}`,
39
+ topics,
40
+ delivery: "bulk",
41
+ text,
42
+ fields,
43
+ timestamp: new Date().toISOString(),
44
+ payload,
45
+ };
46
+ }
47
+ //# sourceMappingURL=linear.js.map