cyrus-slack-event-transport 0.2.22
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/LICENSE +201 -0
- package/dist/SlackEventTransport.d.ts +53 -0
- package/dist/SlackEventTransport.d.ts.map +1 -0
- package/dist/SlackEventTransport.js +137 -0
- package/dist/SlackEventTransport.js.map +1 -0
- package/dist/SlackMessageService.d.ts +64 -0
- package/dist/SlackMessageService.d.ts.map +1 -0
- package/dist/SlackMessageService.js +89 -0
- package/dist/SlackMessageService.js.map +1 -0
- package/dist/SlackMessageTranslator.d.ts +66 -0
- package/dist/SlackMessageTranslator.d.ts.map +1 -0
- package/dist/SlackMessageTranslator.js +176 -0
- package/dist/SlackMessageTranslator.js.map +1 -0
- package/dist/SlackReactionService.d.ts +30 -0
- package/dist/SlackReactionService.d.ts.map +1 -0
- package/dist/SlackReactionService.js +43 -0
- package/dist/SlackReactionService.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +115 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -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 [yyyy] [name of copyright owner]
|
|
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.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import type { TranslationContext } from "cyrus-core";
|
|
3
|
+
import { type ILogger } from "cyrus-core";
|
|
4
|
+
import type { SlackEventTransportConfig, SlackEventTransportEvents } from "./types.js";
|
|
5
|
+
export declare interface SlackEventTransport {
|
|
6
|
+
on<K extends keyof SlackEventTransportEvents>(event: K, listener: SlackEventTransportEvents[K]): this;
|
|
7
|
+
emit<K extends keyof SlackEventTransportEvents>(event: K, ...args: Parameters<SlackEventTransportEvents[K]>): boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* SlackEventTransport - Handles forwarded Slack webhook event delivery
|
|
11
|
+
*
|
|
12
|
+
* This class provides a typed EventEmitter-based transport
|
|
13
|
+
* for handling Slack webhooks forwarded from CYHOST.
|
|
14
|
+
*
|
|
15
|
+
* It registers a POST /slack-webhook endpoint with a Fastify server
|
|
16
|
+
* and verifies incoming webhooks using Bearer token authentication.
|
|
17
|
+
*
|
|
18
|
+
* Supported Slack event types:
|
|
19
|
+
* - app_mention: When the bot is mentioned with @ in a channel or thread
|
|
20
|
+
*/
|
|
21
|
+
export declare class SlackEventTransport extends EventEmitter {
|
|
22
|
+
private config;
|
|
23
|
+
private logger;
|
|
24
|
+
private messageTranslator;
|
|
25
|
+
private translationContext;
|
|
26
|
+
constructor(config: SlackEventTransportConfig, logger?: ILogger, translationContext?: TranslationContext);
|
|
27
|
+
/**
|
|
28
|
+
* Set the translation context for message translation.
|
|
29
|
+
*/
|
|
30
|
+
setTranslationContext(context: TranslationContext): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get Slack bot token from the SLACK_BOT_TOKEN environment variable.
|
|
33
|
+
*/
|
|
34
|
+
private getSlackBotToken;
|
|
35
|
+
/**
|
|
36
|
+
* Register the /slack-webhook endpoint with the Fastify server
|
|
37
|
+
*/
|
|
38
|
+
register(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Handle webhook using Bearer token authentication (forwarded from CYHOST)
|
|
41
|
+
*/
|
|
42
|
+
private handleProxyWebhook;
|
|
43
|
+
/**
|
|
44
|
+
* Process the webhook request and emit the appropriate event
|
|
45
|
+
*/
|
|
46
|
+
private processAndEmitEvent;
|
|
47
|
+
/**
|
|
48
|
+
* Translate and emit an internal message from a webhook event.
|
|
49
|
+
* Only emits if translation succeeds; logs debug message on failure.
|
|
50
|
+
*/
|
|
51
|
+
private emitMessage;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=SlackEventTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlackEventTransport.d.ts","sourceRoot":"","sources":["../src/SlackEventTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAGxD,OAAO,KAAK,EAEX,yBAAyB,EACzB,yBAAyB,EAEzB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,OAAO,WAAW,mBAAmB;IAC3C,EAAE,CAAC,CAAC,SAAS,MAAM,yBAAyB,EAC3C,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,yBAAyB,CAAC,CAAC,CAAC,GACpC,IAAI,CAAC;IACR,IAAI,CAAC,CAAC,SAAS,MAAM,yBAAyB,EAC7C,KAAK,EAAE,CAAC,EACR,GAAG,IAAI,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,GAC/C,OAAO,CAAC;CACX;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,mBAAoB,SAAQ,YAAY;IACpD,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,kBAAkB,CAAqB;gBAG9C,MAAM,EAAE,yBAAyB,EACjC,MAAM,CAAC,EAAE,OAAO,EAChB,kBAAkB,CAAC,EAAE,kBAAkB;IASxC;;OAEG;IACH,qBAAqB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAIxD;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,QAAQ,IAAI,IAAI;IAuBhB;;OAEG;YACW,kBAAkB;IA4BhC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAoD3B;;;OAGG;IACH,OAAO,CAAC,WAAW;CAYnB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { createLogger } from "cyrus-core";
|
|
3
|
+
import { SlackMessageTranslator } from "./SlackMessageTranslator.js";
|
|
4
|
+
/**
|
|
5
|
+
* SlackEventTransport - Handles forwarded Slack webhook event delivery
|
|
6
|
+
*
|
|
7
|
+
* This class provides a typed EventEmitter-based transport
|
|
8
|
+
* for handling Slack webhooks forwarded from CYHOST.
|
|
9
|
+
*
|
|
10
|
+
* It registers a POST /slack-webhook endpoint with a Fastify server
|
|
11
|
+
* and verifies incoming webhooks using Bearer token authentication.
|
|
12
|
+
*
|
|
13
|
+
* Supported Slack event types:
|
|
14
|
+
* - app_mention: When the bot is mentioned with @ in a channel or thread
|
|
15
|
+
*/
|
|
16
|
+
export class SlackEventTransport extends EventEmitter {
|
|
17
|
+
config;
|
|
18
|
+
logger;
|
|
19
|
+
messageTranslator;
|
|
20
|
+
translationContext;
|
|
21
|
+
constructor(config, logger, translationContext) {
|
|
22
|
+
super();
|
|
23
|
+
this.config = config;
|
|
24
|
+
this.logger = logger ?? createLogger({ component: "SlackEventTransport" });
|
|
25
|
+
this.messageTranslator = new SlackMessageTranslator();
|
|
26
|
+
this.translationContext = translationContext ?? {};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Set the translation context for message translation.
|
|
30
|
+
*/
|
|
31
|
+
setTranslationContext(context) {
|
|
32
|
+
this.translationContext = { ...this.translationContext, ...context };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get Slack bot token from the SLACK_BOT_TOKEN environment variable.
|
|
36
|
+
*/
|
|
37
|
+
getSlackBotToken() {
|
|
38
|
+
return process.env.SLACK_BOT_TOKEN;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Register the /slack-webhook endpoint with the Fastify server
|
|
42
|
+
*/
|
|
43
|
+
register() {
|
|
44
|
+
this.config.fastifyServer.post("/slack-webhook", async (request, reply) => {
|
|
45
|
+
try {
|
|
46
|
+
await this.handleProxyWebhook(request, reply);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const err = new Error("Webhook error");
|
|
50
|
+
if (error instanceof Error) {
|
|
51
|
+
err.cause = error;
|
|
52
|
+
}
|
|
53
|
+
this.logger.error("Webhook error", err);
|
|
54
|
+
this.emit("error", err);
|
|
55
|
+
reply.code(500).send({ error: "Internal server error" });
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
this.logger.info(`Registered POST /slack-webhook endpoint (${this.config.verificationMode} mode)`);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handle webhook using Bearer token authentication (forwarded from CYHOST)
|
|
62
|
+
*/
|
|
63
|
+
async handleProxyWebhook(request, reply) {
|
|
64
|
+
const authHeader = request.headers.authorization;
|
|
65
|
+
if (!authHeader) {
|
|
66
|
+
reply.code(401).send({ error: "Missing Authorization header" });
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const expectedAuth = `Bearer ${this.config.secret}`;
|
|
70
|
+
if (authHeader !== expectedAuth) {
|
|
71
|
+
reply.code(401).send({ error: "Invalid authorization token" });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
this.processAndEmitEvent(request, reply);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const err = new Error("Proxy webhook processing failed");
|
|
79
|
+
if (error instanceof Error) {
|
|
80
|
+
err.cause = error;
|
|
81
|
+
}
|
|
82
|
+
this.logger.error("Proxy webhook processing failed", err);
|
|
83
|
+
reply.code(500).send({ error: "Failed to process webhook" });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Process the webhook request and emit the appropriate event
|
|
88
|
+
*/
|
|
89
|
+
processAndEmitEvent(request, reply) {
|
|
90
|
+
const envelope = request.body;
|
|
91
|
+
// Handle Slack URL verification challenge
|
|
92
|
+
if (envelope.type === "url_verification") {
|
|
93
|
+
this.logger.info("Responding to Slack URL verification challenge");
|
|
94
|
+
reply.code(200).send({ challenge: envelope.challenge });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (envelope.type !== "event_callback") {
|
|
98
|
+
this.logger.debug(`Ignoring unsupported envelope type: ${envelope.type}`);
|
|
99
|
+
reply.code(200).send({ success: true, ignored: true });
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const event = envelope.event;
|
|
103
|
+
if (!event || event.type !== "app_mention") {
|
|
104
|
+
this.logger.debug(`Ignoring unsupported event type: ${event?.type ?? "unknown"}`);
|
|
105
|
+
reply.code(200).send({ success: true, ignored: true });
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const slackBotToken = this.getSlackBotToken();
|
|
109
|
+
const webhookEvent = {
|
|
110
|
+
eventType: "app_mention",
|
|
111
|
+
eventId: envelope.event_id,
|
|
112
|
+
payload: event,
|
|
113
|
+
slackBotToken,
|
|
114
|
+
teamId: envelope.team_id,
|
|
115
|
+
};
|
|
116
|
+
this.logger.info(`Received app_mention webhook (event: ${envelope.event_id}, channel: ${event.channel})`);
|
|
117
|
+
// Emit "event" for transport-level listeners
|
|
118
|
+
this.emit("event", webhookEvent);
|
|
119
|
+
// Emit "message" with translated internal message
|
|
120
|
+
this.emitMessage(webhookEvent);
|
|
121
|
+
reply.code(200).send({ success: true });
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Translate and emit an internal message from a webhook event.
|
|
125
|
+
* Only emits if translation succeeds; logs debug message on failure.
|
|
126
|
+
*/
|
|
127
|
+
emitMessage(event) {
|
|
128
|
+
const result = this.messageTranslator.translate(event, this.translationContext);
|
|
129
|
+
if (result.success) {
|
|
130
|
+
this.emit("message", result.message);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
this.logger.debug(`Message translation skipped: ${result.reason}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=SlackEventTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlackEventTransport.js","sourceRoot":"","sources":["../src/SlackEventTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAmBrE;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IAC5C,MAAM,CAA4B;IAClC,MAAM,CAAU;IAChB,iBAAiB,CAAyB;IAC1C,kBAAkB,CAAqB;IAE/C,YACC,MAAiC,EACjC,MAAgB,EAChB,kBAAuC;QAEvC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,YAAY,CAAC,EAAE,SAAS,EAAE,qBAAqB,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,iBAAiB,GAAG,IAAI,sBAAsB,EAAE,CAAC;QACtD,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,IAAI,EAAE,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,qBAAqB,CAAC,OAA2B;QAChD,IAAI,CAAC,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC,kBAAkB,EAAE,GAAG,OAAO,EAAE,CAAC;IACtE,CAAC;IAED;;OAEG;IACK,gBAAgB;QACvB,OAAO,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,QAAQ;QACP,IAAI,CAAC,MA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ACtC,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACpE,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service for posting messages to Slack channels.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Slack Web API with a bot token to post messages,
|
|
5
|
+
* typically used to reply to @mention webhooks in a thread.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A single message from a Slack thread (conversations.replies)
|
|
9
|
+
*/
|
|
10
|
+
export interface SlackThreadMessage {
|
|
11
|
+
/** User ID who posted the message (absent for some bot messages) */
|
|
12
|
+
user?: string;
|
|
13
|
+
/** Message text */
|
|
14
|
+
text: string;
|
|
15
|
+
/** Message timestamp (unique ID) */
|
|
16
|
+
ts: string;
|
|
17
|
+
/** Bot ID if the message was posted by a bot */
|
|
18
|
+
bot_id?: string;
|
|
19
|
+
/** Message subtype (e.g., "bot_message") */
|
|
20
|
+
subtype?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parameters for fetching thread messages from Slack
|
|
24
|
+
*/
|
|
25
|
+
export interface SlackFetchThreadParams {
|
|
26
|
+
/** Slack Bot OAuth token */
|
|
27
|
+
token: string;
|
|
28
|
+
/** Channel ID containing the thread */
|
|
29
|
+
channel: string;
|
|
30
|
+
/** Timestamp of the thread parent message */
|
|
31
|
+
thread_ts: string;
|
|
32
|
+
/** Maximum number of messages to fetch (default 100) */
|
|
33
|
+
limit?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Parameters for posting a message to Slack
|
|
37
|
+
*/
|
|
38
|
+
export interface SlackPostMessageParams {
|
|
39
|
+
/** Slack Bot OAuth token */
|
|
40
|
+
token: string;
|
|
41
|
+
/** Channel ID to post the message in */
|
|
42
|
+
channel: string;
|
|
43
|
+
/** Message text */
|
|
44
|
+
text: string;
|
|
45
|
+
/** Thread timestamp to reply in a thread */
|
|
46
|
+
thread_ts?: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class SlackMessageService {
|
|
49
|
+
private apiBaseUrl;
|
|
50
|
+
constructor(apiBaseUrl?: string);
|
|
51
|
+
/**
|
|
52
|
+
* Post a message to a Slack channel.
|
|
53
|
+
*
|
|
54
|
+
* @see https://api.slack.com/methods/chat.postMessage
|
|
55
|
+
*/
|
|
56
|
+
postMessage(params: SlackPostMessageParams): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Fetch all messages in a Slack thread using cursor-based pagination.
|
|
59
|
+
*
|
|
60
|
+
* @see https://api.slack.com/methods/conversations.replies
|
|
61
|
+
*/
|
|
62
|
+
fetchThreadMessages(params: SlackFetchThreadParams): Promise<SlackThreadMessage[]>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=SlackMessageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlackMessageService.d.ts","sourceRoot":"","sources":["../src/SlackMessageService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,UAAU,CAAS;gBAEf,UAAU,CAAC,EAAE,MAAM;IAI/B;;;;OAIG;IACG,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsChE;;;;OAIG;IACG,mBAAmB,CACxB,MAAM,EAAE,sBAAsB,GAC5B,OAAO,CAAC,kBAAkB,EAAE,CAAC;CA4DhC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service for posting messages to Slack channels.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Slack Web API with a bot token to post messages,
|
|
5
|
+
* typically used to reply to @mention webhooks in a thread.
|
|
6
|
+
*/
|
|
7
|
+
export class SlackMessageService {
|
|
8
|
+
apiBaseUrl;
|
|
9
|
+
constructor(apiBaseUrl) {
|
|
10
|
+
this.apiBaseUrl = apiBaseUrl ?? "https://slack.com/api";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Post a message to a Slack channel.
|
|
14
|
+
*
|
|
15
|
+
* @see https://api.slack.com/methods/chat.postMessage
|
|
16
|
+
*/
|
|
17
|
+
async postMessage(params) {
|
|
18
|
+
const { token, channel, text, thread_ts } = params;
|
|
19
|
+
const url = `${this.apiBaseUrl}/chat.postMessage`;
|
|
20
|
+
const body = { channel, text };
|
|
21
|
+
if (thread_ts) {
|
|
22
|
+
body.thread_ts = thread_ts;
|
|
23
|
+
}
|
|
24
|
+
const response = await fetch(url, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: {
|
|
27
|
+
Authorization: `Bearer ${token}`,
|
|
28
|
+
"Content-Type": "application/json",
|
|
29
|
+
},
|
|
30
|
+
body: JSON.stringify(body),
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
const errorBody = await response.text();
|
|
34
|
+
throw new Error(`[SlackMessageService] Failed to post message: ${response.status} ${response.statusText} - ${errorBody}`);
|
|
35
|
+
}
|
|
36
|
+
// Slack API returns HTTP 200 even for errors — check the response body
|
|
37
|
+
const responseBody = (await response.json());
|
|
38
|
+
if (!responseBody.ok) {
|
|
39
|
+
throw new Error(`[SlackMessageService] Slack API error: ${responseBody.error ?? "unknown"}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Fetch all messages in a Slack thread using cursor-based pagination.
|
|
44
|
+
*
|
|
45
|
+
* @see https://api.slack.com/methods/conversations.replies
|
|
46
|
+
*/
|
|
47
|
+
async fetchThreadMessages(params) {
|
|
48
|
+
const { token, channel, thread_ts, limit = 100 } = params;
|
|
49
|
+
const messages = [];
|
|
50
|
+
let cursor;
|
|
51
|
+
while (messages.length < limit) {
|
|
52
|
+
const queryParams = new URLSearchParams({
|
|
53
|
+
channel,
|
|
54
|
+
ts: thread_ts,
|
|
55
|
+
limit: String(Math.min(limit - messages.length, 200)),
|
|
56
|
+
});
|
|
57
|
+
if (cursor) {
|
|
58
|
+
queryParams.set("cursor", cursor);
|
|
59
|
+
}
|
|
60
|
+
const url = `${this.apiBaseUrl}/conversations.replies?${queryParams.toString()}`;
|
|
61
|
+
const response = await fetch(url, {
|
|
62
|
+
method: "GET",
|
|
63
|
+
headers: {
|
|
64
|
+
Authorization: `Bearer ${token}`,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
const errorBody = await response.text();
|
|
69
|
+
throw new Error(`[SlackMessageService] Failed to fetch thread messages: ${response.status} ${response.statusText} - ${errorBody}`);
|
|
70
|
+
}
|
|
71
|
+
const responseBody = (await response.json());
|
|
72
|
+
if (!responseBody.ok) {
|
|
73
|
+
throw new Error(`[SlackMessageService] Slack API error: ${responseBody.error ?? "unknown"}`);
|
|
74
|
+
}
|
|
75
|
+
if (responseBody.messages) {
|
|
76
|
+
messages.push(...responseBody.messages);
|
|
77
|
+
}
|
|
78
|
+
// Continue pagination if there are more messages
|
|
79
|
+
const nextCursor = responseBody.response_metadata?.next_cursor;
|
|
80
|
+
if (!responseBody.has_more || !nextCursor) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
cursor = nextCursor;
|
|
84
|
+
}
|
|
85
|
+
// Enforce limit
|
|
86
|
+
return messages.slice(0, limit);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=SlackMessageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlackMessageService.js","sourceRoot":"","sources":["../src/SlackMessageService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA8CH,MAAM,OAAO,mBAAmB;IACvB,UAAU,CAAS;IAE3B,YAAY,UAAmB;QAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,uBAAuB,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,MAA8B;QAC/C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAEnD,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,mBAAmB,CAAC;QAElD,MAAM,IAAI,GAA2B,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACvD,IAAI,SAAS,EAAE,CAAC;YACf,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC5B,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YACjC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACR,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,cAAc,EAAE,kBAAkB;aAClC;YACD,IAAI,EAAE,IAAI,CAAC,S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,CAAC,GAAG,EAAE;gBACjC,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACR,aAAa,EAAE,UAAU,KAAK,EAAE;iBAChC;aACD,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBAClB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACxC,MAAM,IAAI,KAAK,CACd,0DAA0D,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CACjH,CAAC;YACH,CAAC;YAED,MAAM,YAAY,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAM1C,CAAC;YAEF,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CACd,0CAA0C,YAAY,CAAC,KAAK,IAAI,SAAS,EAAE,CAC3E,CAAC;YACH,CAAC;YAED,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;gBAC3B,QAAQ,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;YACzC,CAAC;YAED,iDAAiD;YACjD,MAAM,UAAU,GAAG,YAAY,CAAC,iBAAiB,EAAE,WAAW,CAAC;YAC/D,IAAI,CAAC,YAAY,CAAC,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC3C,MAAM;YACP,CAAC;YACD,MAAM,GAAG,UAAU,CAAC;QACrB,CAAC;QAED,gBAAgB;QAChB,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;CACD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack Message Translator
|
|
3
|
+
*
|
|
4
|
+
* Translates Slack webhook events into unified internal messages for the
|
|
5
|
+
* internal message bus.
|
|
6
|
+
*
|
|
7
|
+
* @module slack-event-transport/SlackMessageTranslator
|
|
8
|
+
*/
|
|
9
|
+
import type { IMessageTranslator, TranslationContext, TranslationResult } from "cyrus-core";
|
|
10
|
+
import type { SlackWebhookEvent } from "./types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Strips the @mention from Slack message text.
|
|
13
|
+
* Slack mentions are in the format <@U1234567890> at the start of the text.
|
|
14
|
+
*/
|
|
15
|
+
export declare function stripMention(text: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Translates Slack webhook events into internal messages.
|
|
18
|
+
*
|
|
19
|
+
* Note: Slack webhooks can result in either:
|
|
20
|
+
* - SessionStartMessage: First mention in a channel/thread that starts a session
|
|
21
|
+
* - UserPromptMessage: Follow-up messages in an existing thread session
|
|
22
|
+
*
|
|
23
|
+
* The distinction between session start vs user prompt is determined by
|
|
24
|
+
* the EdgeWorker based on whether an active session exists for the thread.
|
|
25
|
+
*/
|
|
26
|
+
export declare class SlackMessageTranslator implements IMessageTranslator<SlackWebhookEvent> {
|
|
27
|
+
/**
|
|
28
|
+
* Check if this translator can handle the given event.
|
|
29
|
+
*/
|
|
30
|
+
canTranslate(event: unknown): event is SlackWebhookEvent;
|
|
31
|
+
/**
|
|
32
|
+
* Translate a Slack webhook event into an internal message.
|
|
33
|
+
*
|
|
34
|
+
* By default, creates a SessionStartMessage. The EdgeWorker will
|
|
35
|
+
* determine if this should actually be a UserPromptMessage based
|
|
36
|
+
* on whether an active session exists.
|
|
37
|
+
*/
|
|
38
|
+
translate(event: SlackWebhookEvent, context?: TranslationContext): TranslationResult;
|
|
39
|
+
/**
|
|
40
|
+
* Create a UserPromptMessage from a Slack event.
|
|
41
|
+
* This is called by EdgeWorker when it determines the message
|
|
42
|
+
* is a follow-up to an existing session.
|
|
43
|
+
*/
|
|
44
|
+
translateAsUserPrompt(event: SlackWebhookEvent, context?: TranslationContext): TranslationResult;
|
|
45
|
+
/**
|
|
46
|
+
* Translate app_mention event to SessionStartMessage.
|
|
47
|
+
*/
|
|
48
|
+
private translateAppMention;
|
|
49
|
+
/**
|
|
50
|
+
* Translate app_mention as UserPromptMessage.
|
|
51
|
+
*/
|
|
52
|
+
private translateAppMentionAsUserPrompt;
|
|
53
|
+
/**
|
|
54
|
+
* Build channel reference from channel ID.
|
|
55
|
+
*/
|
|
56
|
+
private buildChannelRef;
|
|
57
|
+
/**
|
|
58
|
+
* Build thread reference from message timestamps.
|
|
59
|
+
*/
|
|
60
|
+
private buildThreadRef;
|
|
61
|
+
/**
|
|
62
|
+
* Build message reference from event payload.
|
|
63
|
+
*/
|
|
64
|
+
private buildMessageRef;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=SlackMessageTranslator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlackMessageTranslator.d.ts","sourceRoot":"","sources":["../src/SlackMessageTranslator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACX,kBAAkB,EAKlB,kBAAkB,EAClB,iBAAiB,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;;;;;GASG;AACH,qBAAa,sBACZ,YAAW,kBAAkB,CAAC,iBAAiB,CAAC;IAEhD;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB;IAgBxD;;;;;;OAMG;IACH,SAAS,CACR,KAAK,EAAE,iBAAiB,EACxB,OAAO,CAAC,EAAE,kBAAkB,GAC1B,iBAAiB;IAWpB;;;;OAIG;IACH,qBAAqB,CACpB,KAAK,EAAE,iBAAiB,EACxB,OAAO,CAAC,EAAE,kBAAkB,GAC1B,iBAAiB;IAWpB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgD3B;;OAEG;IACH,OAAO,CAAC,+BAA+B;IA8CvC;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,cAAc;IAUtB;;OAEG;IACH,OAAO,CAAC,eAAe;CAWvB"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack Message Translator
|
|
3
|
+
*
|
|
4
|
+
* Translates Slack webhook events into unified internal messages for the
|
|
5
|
+
* internal message bus.
|
|
6
|
+
*
|
|
7
|
+
* @module slack-event-transport/SlackMessageTranslator
|
|
8
|
+
*/
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
/**
|
|
11
|
+
* Strips the @mention from Slack message text.
|
|
12
|
+
* Slack mentions are in the format <@U1234567890> at the start of the text.
|
|
13
|
+
*/
|
|
14
|
+
export function stripMention(text) {
|
|
15
|
+
return text.replace(/^\s*<@[A-Z0-9]+>\s*/, "").trim();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Translates Slack webhook events into internal messages.
|
|
19
|
+
*
|
|
20
|
+
* Note: Slack webhooks can result in either:
|
|
21
|
+
* - SessionStartMessage: First mention in a channel/thread that starts a session
|
|
22
|
+
* - UserPromptMessage: Follow-up messages in an existing thread session
|
|
23
|
+
*
|
|
24
|
+
* The distinction between session start vs user prompt is determined by
|
|
25
|
+
* the EdgeWorker based on whether an active session exists for the thread.
|
|
26
|
+
*/
|
|
27
|
+
export class SlackMessageTranslator {
|
|
28
|
+
/**
|
|
29
|
+
* Check if this translator can handle the given event.
|
|
30
|
+
*/
|
|
31
|
+
canTranslate(event) {
|
|
32
|
+
if (!event || typeof event !== "object") {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const e = event;
|
|
36
|
+
return (typeof e.eventType === "string" &&
|
|
37
|
+
e.eventType === "app_mention" &&
|
|
38
|
+
typeof e.eventId === "string" &&
|
|
39
|
+
e.payload !== null &&
|
|
40
|
+
typeof e.payload === "object");
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Translate a Slack webhook event into an internal message.
|
|
44
|
+
*
|
|
45
|
+
* By default, creates a SessionStartMessage. The EdgeWorker will
|
|
46
|
+
* determine if this should actually be a UserPromptMessage based
|
|
47
|
+
* on whether an active session exists.
|
|
48
|
+
*/
|
|
49
|
+
translate(event, context) {
|
|
50
|
+
if (event.eventType === "app_mention") {
|
|
51
|
+
return this.translateAppMention(event, context);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
success: false,
|
|
55
|
+
reason: `Unsupported Slack event type: ${event.eventType}`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a UserPromptMessage from a Slack event.
|
|
60
|
+
* This is called by EdgeWorker when it determines the message
|
|
61
|
+
* is a follow-up to an existing session.
|
|
62
|
+
*/
|
|
63
|
+
translateAsUserPrompt(event, context) {
|
|
64
|
+
if (event.eventType === "app_mention") {
|
|
65
|
+
return this.translateAppMentionAsUserPrompt(event, context);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
success: false,
|
|
69
|
+
reason: `Unsupported Slack event type: ${event.eventType}`,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Translate app_mention event to SessionStartMessage.
|
|
74
|
+
*/
|
|
75
|
+
translateAppMention(event, context) {
|
|
76
|
+
const { payload } = event;
|
|
77
|
+
const organizationId = context?.organizationId || event.teamId;
|
|
78
|
+
// Session key: channel:thread_ts (or channel:ts if not in a thread)
|
|
79
|
+
const threadTs = payload.thread_ts || payload.ts;
|
|
80
|
+
const sessionKey = `${payload.channel}:${threadTs}`;
|
|
81
|
+
// Work item identifier uses channel:thread format
|
|
82
|
+
const workItemIdentifier = `slack:${payload.channel}:${threadTs}`;
|
|
83
|
+
// Strip the @mention from the text to get the actual prompt
|
|
84
|
+
const promptText = stripMention(payload.text);
|
|
85
|
+
const platformData = {
|
|
86
|
+
channel: this.buildChannelRef(payload.channel),
|
|
87
|
+
thread: this.buildThreadRef(payload.ts, payload.thread_ts),
|
|
88
|
+
message: this.buildMessageRef(payload),
|
|
89
|
+
slackBotToken: event.slackBotToken,
|
|
90
|
+
};
|
|
91
|
+
const message = {
|
|
92
|
+
id: randomUUID(),
|
|
93
|
+
source: "slack",
|
|
94
|
+
action: "session_start",
|
|
95
|
+
receivedAt: new Date(Number.parseFloat(payload.event_ts) * 1000).toISOString(),
|
|
96
|
+
organizationId,
|
|
97
|
+
sessionKey,
|
|
98
|
+
workItemId: `${payload.channel}:${threadTs}`,
|
|
99
|
+
workItemIdentifier,
|
|
100
|
+
author: {
|
|
101
|
+
id: payload.user,
|
|
102
|
+
name: payload.user,
|
|
103
|
+
},
|
|
104
|
+
initialPrompt: promptText,
|
|
105
|
+
title: promptText.slice(0, 100) + (promptText.length > 100 ? "..." : ""),
|
|
106
|
+
platformData,
|
|
107
|
+
};
|
|
108
|
+
return { success: true, message };
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Translate app_mention as UserPromptMessage.
|
|
112
|
+
*/
|
|
113
|
+
translateAppMentionAsUserPrompt(event, context) {
|
|
114
|
+
const { payload } = event;
|
|
115
|
+
const organizationId = context?.organizationId || event.teamId;
|
|
116
|
+
const threadTs = payload.thread_ts || payload.ts;
|
|
117
|
+
const sessionKey = `${payload.channel}:${threadTs}`;
|
|
118
|
+
const promptText = stripMention(payload.text);
|
|
119
|
+
const platformData = {
|
|
120
|
+
channel: this.buildChannelRef(payload.channel),
|
|
121
|
+
thread: this.buildThreadRef(payload.ts, payload.thread_ts),
|
|
122
|
+
message: this.buildMessageRef(payload),
|
|
123
|
+
slackBotToken: event.slackBotToken,
|
|
124
|
+
};
|
|
125
|
+
const message = {
|
|
126
|
+
id: randomUUID(),
|
|
127
|
+
source: "slack",
|
|
128
|
+
action: "user_prompt",
|
|
129
|
+
receivedAt: new Date(Number.parseFloat(payload.event_ts) * 1000).toISOString(),
|
|
130
|
+
organizationId,
|
|
131
|
+
sessionKey,
|
|
132
|
+
workItemId: `${payload.channel}:${threadTs}`,
|
|
133
|
+
workItemIdentifier: `slack:${payload.channel}:${threadTs}`,
|
|
134
|
+
author: {
|
|
135
|
+
id: payload.user,
|
|
136
|
+
name: payload.user,
|
|
137
|
+
},
|
|
138
|
+
content: promptText,
|
|
139
|
+
platformData,
|
|
140
|
+
};
|
|
141
|
+
return { success: true, message };
|
|
142
|
+
}
|
|
143
|
+
// ============================================================================
|
|
144
|
+
// HELPER METHODS
|
|
145
|
+
// ============================================================================
|
|
146
|
+
/**
|
|
147
|
+
* Build channel reference from channel ID.
|
|
148
|
+
*/
|
|
149
|
+
buildChannelRef(channelId) {
|
|
150
|
+
return {
|
|
151
|
+
id: channelId,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Build thread reference from message timestamps.
|
|
156
|
+
*/
|
|
157
|
+
buildThreadRef(ts, threadTs) {
|
|
158
|
+
return {
|
|
159
|
+
ts,
|
|
160
|
+
parentTs: threadTs,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Build message reference from event payload.
|
|
165
|
+
*/
|
|
166
|
+
buildMessageRef(payload) {
|
|
167
|
+
return {
|
|
168
|
+
ts: payload.ts,
|
|
169
|
+
text: payload.text,
|
|
170
|
+
user: {
|
|
171
|
+
id: payload.user,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=SlackMessageTranslator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlackMessageTranslator.js","sourceRoot":"","sources":["../src/SlackMessageTranslator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAazC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACvD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,OA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YACnB,YAAY;SACZ,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACnC,CAAC;IAED,+EAA+E;IAC/E,iBAAiB;IACjB,+EAA+E;IAE/E;;OAEG;IACK,eAAe,CAAC,SAAiB;QACxC,OAAO;YACN,EAAE,EAAE,SAAS;SACb,CAAC;IACH,CAAC;IAED;;OAEG;IACK,cAAc,CACrB,EAAU,EACV,QAAiB;QAEjB,OAAO;YACN,EAAE;YACF,QAAQ,EAAE,QAAQ;SAClB,CAAC;IACH,CAAC;IAED;;OAEG;IACK,eAAe,CACtB,OAAqC;QAErC,OAAO;YACN,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE;gBACL,EAAE,EAAE,OAAO,CAAC,IAAI;aAChB;SACD,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service for adding reactions to Slack messages.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Slack Web API with a bot token to add emoji reactions,
|
|
5
|
+
* typically used to acknowledge receipt of @mention webhooks.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Parameters for adding a reaction to a Slack message
|
|
9
|
+
*/
|
|
10
|
+
export interface SlackAddReactionParams {
|
|
11
|
+
/** Slack Bot OAuth token */
|
|
12
|
+
token: string;
|
|
13
|
+
/** Channel ID where the message is */
|
|
14
|
+
channel: string;
|
|
15
|
+
/** Timestamp of the message to react to */
|
|
16
|
+
timestamp: string;
|
|
17
|
+
/** Emoji name (without colons), e.g. "eyes" */
|
|
18
|
+
name: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class SlackReactionService {
|
|
21
|
+
private apiBaseUrl;
|
|
22
|
+
constructor(apiBaseUrl?: string);
|
|
23
|
+
/**
|
|
24
|
+
* Add a reaction to a Slack message.
|
|
25
|
+
*
|
|
26
|
+
* @see https://api.slack.com/methods/reactions.add
|
|
27
|
+
*/
|
|
28
|
+
addReaction(params: SlackAddReactionParams): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=SlackReactionService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlackReactionService.d.ts","sourceRoot":"","sources":["../src/SlackReactionService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;CACb;AAED,qBAAa,oBAAoB;IAChC,OAAO,CAAC,UAAU,CAAS;gBAEf,UAAU,CAAC,EAAE,MAAM;IAI/B;;;;OAIG;IACG,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CAoChE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service for adding reactions to Slack messages.
|
|
3
|
+
*
|
|
4
|
+
* Uses the Slack Web API with a bot token to add emoji reactions,
|
|
5
|
+
* typically used to acknowledge receipt of @mention webhooks.
|
|
6
|
+
*/
|
|
7
|
+
export class SlackReactionService {
|
|
8
|
+
apiBaseUrl;
|
|
9
|
+
constructor(apiBaseUrl) {
|
|
10
|
+
this.apiBaseUrl = apiBaseUrl ?? "https://slack.com/api";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Add a reaction to a Slack message.
|
|
14
|
+
*
|
|
15
|
+
* @see https://api.slack.com/methods/reactions.add
|
|
16
|
+
*/
|
|
17
|
+
async addReaction(params) {
|
|
18
|
+
const { token, channel, timestamp, name } = params;
|
|
19
|
+
const url = `${this.apiBaseUrl}/reactions.add`;
|
|
20
|
+
const response = await fetch(url, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: {
|
|
23
|
+
Authorization: `Bearer ${token}`,
|
|
24
|
+
"Content-Type": "application/json",
|
|
25
|
+
},
|
|
26
|
+
body: JSON.stringify({ channel, timestamp, name }),
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
const errorBody = await response.text();
|
|
30
|
+
throw new Error(`[SlackReactionService] Failed to add reaction: ${response.status} ${response.statusText} - ${errorBody}`);
|
|
31
|
+
}
|
|
32
|
+
// Slack API returns HTTP 200 even for errors — check the response body
|
|
33
|
+
const responseBody = (await response.json());
|
|
34
|
+
if (!responseBody.ok) {
|
|
35
|
+
// "already_reacted" is not an error worth surfacing
|
|
36
|
+
if (responseBody.error === "already_reacted") {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`[SlackReactionService] Slack API error: ${responseBody.error ?? "unknown"}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=SlackReactionService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlackReactionService.js","sourceRoot":"","sources":["../src/SlackReactionService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,MAAM,OAAO,oBAAoB;IACxB,UAAU,CAAS;IAE3B,YAAY,UAAmB;QAC9B,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,uBAAuB,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,MAA8B;QAC/C,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;QAEnD,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,gBAAgB,CAAC;QAE/C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YACjC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACR,aAAa,EAAE,UAAU,KAAK,EAAE;gBAChC,cAAc,EAAE,kBAAkB;aAClC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;SAClD,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YAClB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACd,kDAAkD,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CACzG,CAAC;QACH,CAAC;QAED,uEAAuE;QACvE,MAAM,YAAY,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAG1C,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC;YACtB,oDAAoD;YACpD,IAAI,YAAY,CAAC,KAAK,KAAK,iBAAiB,EAAE,CAAC;gBAC9C,OAAO;YACR,CAAC;YACD,MAAM,IAAI,KAAK,CACd,2CAA2C,YAAY,CAAC,KAAK,IAAI,SAAS,EAAE,CAC5E,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SlackEventTransport } from "./SlackEventTransport.js";
|
|
2
|
+
export type { SlackFetchThreadParams, SlackPostMessageParams, SlackThreadMessage, } from "./SlackMessageService.js";
|
|
3
|
+
export { SlackMessageService } from "./SlackMessageService.js";
|
|
4
|
+
export { SlackMessageTranslator, stripMention, } from "./SlackMessageTranslator.js";
|
|
5
|
+
export type { SlackAddReactionParams } from "./SlackReactionService.js";
|
|
6
|
+
export { SlackReactionService } from "./SlackReactionService.js";
|
|
7
|
+
export type { SlackAppMentionEvent, SlackChannel, SlackEventEnvelope, SlackEventTransportConfig, SlackEventTransportEvents, SlackEventType, SlackUser, SlackVerificationMode, SlackWebhookEvent, } from "./types.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EACX,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACN,sBAAsB,EACtB,YAAY,GACZ,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EACX,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SlackEventTransport } from "./SlackEventTransport.js";
|
|
2
|
+
export { SlackMessageService } from "./SlackMessageService.js";
|
|
3
|
+
export { SlackMessageTranslator, stripMention, } from "./SlackMessageTranslator.js";
|
|
4
|
+
export { SlackReactionService } from "./SlackReactionService.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAM/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACN,sBAAsB,EACtB,YAAY,GACZ,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for Slack event transport
|
|
3
|
+
*/
|
|
4
|
+
import type { InternalMessage } from "cyrus-core";
|
|
5
|
+
import type { FastifyInstance } from "fastify";
|
|
6
|
+
/**
|
|
7
|
+
* Verification mode for Slack webhooks forwarded from CYHOST
|
|
8
|
+
* - 'proxy': Use Bearer token for authentication (webhooks forwarded from CYHOST)
|
|
9
|
+
*/
|
|
10
|
+
export type SlackVerificationMode = "proxy";
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for SlackEventTransport
|
|
13
|
+
*/
|
|
14
|
+
export interface SlackEventTransportConfig {
|
|
15
|
+
/** Fastify server instance to mount routes on */
|
|
16
|
+
fastifyServer: FastifyInstance;
|
|
17
|
+
/** Verification mode: 'proxy' (webhooks forwarded from CYHOST) */
|
|
18
|
+
verificationMode: SlackVerificationMode;
|
|
19
|
+
/** Secret for verification (CYRUS_API_KEY for proxy mode) */
|
|
20
|
+
secret: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Events emitted by SlackEventTransport
|
|
24
|
+
*/
|
|
25
|
+
export interface SlackEventTransportEvents {
|
|
26
|
+
/** Emitted when a Slack webhook is received and verified */
|
|
27
|
+
event: (event: SlackWebhookEvent) => void;
|
|
28
|
+
/** Emitted when a unified internal message is received */
|
|
29
|
+
message: (message: InternalMessage) => void;
|
|
30
|
+
/** Emitted when an error occurs */
|
|
31
|
+
error: (error: Error) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Processed Slack webhook event that is emitted to listeners
|
|
35
|
+
*/
|
|
36
|
+
export interface SlackWebhookEvent {
|
|
37
|
+
/** The Slack event type (e.g., 'app_mention') */
|
|
38
|
+
eventType: SlackEventType;
|
|
39
|
+
/** Unique event ID from Slack */
|
|
40
|
+
eventId: string;
|
|
41
|
+
/** The full Slack event payload */
|
|
42
|
+
payload: SlackAppMentionEvent;
|
|
43
|
+
/** Slack Bot token for API access */
|
|
44
|
+
slackBotToken?: string;
|
|
45
|
+
/** Workspace/team ID */
|
|
46
|
+
teamId: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Supported Slack event types
|
|
50
|
+
*/
|
|
51
|
+
export type SlackEventType = "app_mention";
|
|
52
|
+
/**
|
|
53
|
+
* Slack user object (minimal)
|
|
54
|
+
*/
|
|
55
|
+
export interface SlackUser {
|
|
56
|
+
/** User ID (e.g., "U1234567890") */
|
|
57
|
+
id: string;
|
|
58
|
+
/** Display name */
|
|
59
|
+
name?: string;
|
|
60
|
+
/** Real name */
|
|
61
|
+
real_name?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Slack channel object (minimal)
|
|
65
|
+
*/
|
|
66
|
+
export interface SlackChannel {
|
|
67
|
+
/** Channel ID (e.g., "C1234567890") */
|
|
68
|
+
id: string;
|
|
69
|
+
/** Channel name */
|
|
70
|
+
name?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Slack app_mention event payload
|
|
74
|
+
* @see https://api.slack.com/events/app_mention
|
|
75
|
+
*/
|
|
76
|
+
export interface SlackAppMentionEvent {
|
|
77
|
+
/** Event type - always "app_mention" */
|
|
78
|
+
type: "app_mention";
|
|
79
|
+
/** User ID who mentioned the app */
|
|
80
|
+
user: string;
|
|
81
|
+
/** The message text (includes the @mention) */
|
|
82
|
+
text: string;
|
|
83
|
+
/** Message timestamp (unique ID within channel) */
|
|
84
|
+
ts: string;
|
|
85
|
+
/** Channel ID where the mention occurred */
|
|
86
|
+
channel: string;
|
|
87
|
+
/** Thread timestamp - present if this is a threaded reply */
|
|
88
|
+
thread_ts?: string;
|
|
89
|
+
/** Event timestamp */
|
|
90
|
+
event_ts: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Slack Event API wrapper envelope
|
|
94
|
+
* This is the outer payload that wraps the actual event.
|
|
95
|
+
* @see https://api.slack.com/types/event
|
|
96
|
+
*/
|
|
97
|
+
export interface SlackEventEnvelope {
|
|
98
|
+
/** Token for verification (deprecated, use signing secret) */
|
|
99
|
+
token?: string;
|
|
100
|
+
/** Team/workspace ID */
|
|
101
|
+
team_id: string;
|
|
102
|
+
/** API app ID */
|
|
103
|
+
api_app_id: string;
|
|
104
|
+
/** The actual event data */
|
|
105
|
+
event: SlackAppMentionEvent;
|
|
106
|
+
/** Type of envelope - "event_callback" for events */
|
|
107
|
+
type: "event_callback" | "url_verification";
|
|
108
|
+
/** Unique event ID */
|
|
109
|
+
event_id: string;
|
|
110
|
+
/** Event timestamp */
|
|
111
|
+
event_time: number;
|
|
112
|
+
/** Challenge string (only for url_verification) */
|
|
113
|
+
challenge?: string;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC,iDAAiD;IACjD,aAAa,EAAE,eAAe,CAAC;IAC/B,kEAAkE;IAClE,gBAAgB,EAAE,qBAAqB,CAAC;IACxC,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC,4DAA4D;IAC5D,KAAK,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC1C,0DAA0D;IAC1D,OAAO,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;IAC5C,mCAAmC;IACnC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,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D;IACrD,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,CAAC;IAC5C,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cyrus-slack-event-transport",
|
|
3
|
+
"version": "0.2.22",
|
|
4
|
+
"description": "Slack event transport for receiving and verifying forwarded Slack webhooks",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"fastify": "^5.2.0",
|
|
13
|
+
"cyrus-core": "0.2.22"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^20.0.0",
|
|
17
|
+
"typescript": "^5.3.3",
|
|
18
|
+
"vitest": "^3.1.4"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"dev": "tsc --watch",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"test": "vitest",
|
|
28
|
+
"test:run": "vitest run"
|
|
29
|
+
}
|
|
30
|
+
}
|