@teamvibe/poller 0.1.68 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-update.d.ts +15 -0
- package/dist/auto-update.js +151 -0
- package/dist/cli/commands.js +7 -0
- package/dist/cli/doctor.d.ts +1 -0
- package/dist/cli/doctor.js +195 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.js +3 -0
- package/dist/control-handler.d.ts +4 -0
- package/dist/control-handler.js +143 -0
- package/dist/control-handler.test.js +74 -0
- package/dist/index.js +1 -1
- package/dist/poller.js +53 -1
- package/dist/types.d.ts +7 -0
- package/package.json +2 -1
- package/dist/kb-manager.d.ts +0 -15
- package/dist/kb-manager.js +0 -61
- package/dist/mailbox-manager.d.ts +0 -26
- package/dist/mailbox-manager.js +0 -95
- package/dist/scripts/add-reaction.d.ts +0 -9
- package/dist/scripts/add-reaction.js +0 -22
- package/dist/scripts/lib/slack-client.d.ts +0 -16
- package/dist/scripts/lib/slack-client.js +0 -48
- package/dist/scripts/read-thread.d.ts +0 -9
- package/dist/scripts/read-thread.js +0 -26
- package/dist/scripts/remove-reaction.d.ts +0 -9
- package/dist/scripts/remove-reaction.js +0 -22
- package/dist/scripts/send-message.d.ts +0 -10
- package/dist/scripts/send-message.js +0 -31
- package/dist/scripts/set-status.d.ts +0 -8
- package/dist/scripts/set-status.js +0 -19
- package/dist/scripts/slack-tool.js +0 -155
- package/dist/scripts/upload-snippet.d.ts +0 -8
- package/dist/scripts/upload-snippet.js +0 -21
- /package/dist/{scripts/slack-tool.d.ts → control-handler.test.d.ts} +0 -0
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { WebClient } from '@slack/web-api';
|
|
2
|
-
const BOT_TOKEN = process.env['SLACK_BOT_TOKEN'];
|
|
3
|
-
const CHANNEL = process.env['SLACK_CHANNEL'];
|
|
4
|
-
const THREAD_TS = process.env['SLACK_THREAD_TS'];
|
|
5
|
-
const MESSAGE_TS = process.env['SLACK_MESSAGE_TS'];
|
|
6
|
-
function fail(error) {
|
|
7
|
-
console.log(JSON.stringify({ ok: false, error }));
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
function succeed(data = {}) {
|
|
11
|
-
console.log(JSON.stringify({ ok: true, ...data }));
|
|
12
|
-
process.exit(0);
|
|
13
|
-
}
|
|
14
|
-
if (!BOT_TOKEN)
|
|
15
|
-
fail('SLACK_BOT_TOKEN not set');
|
|
16
|
-
const slack = new WebClient(BOT_TOKEN);
|
|
17
|
-
const [, , command, ...args] = process.argv;
|
|
18
|
-
/**
|
|
19
|
-
* Strip --channel, --thread_ts, --text flags that Claude sometimes adds.
|
|
20
|
-
* These values come from env vars, not CLI args.
|
|
21
|
-
*/
|
|
22
|
-
function stripFlags(rawArgs) {
|
|
23
|
-
const flagsToStrip = ['--channel', '--thread_ts', '--thread-ts', '--text'];
|
|
24
|
-
const cleaned = [];
|
|
25
|
-
let i = 0;
|
|
26
|
-
while (i < rawArgs.length) {
|
|
27
|
-
if (flagsToStrip.includes(rawArgs[i])) {
|
|
28
|
-
// If this is --text, everything after the next arg is the message
|
|
29
|
-
if (rawArgs[i] === '--text') {
|
|
30
|
-
return rawArgs.slice(i + 1).join(' ');
|
|
31
|
-
}
|
|
32
|
-
i += 2; // skip flag + value
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
cleaned.push(rawArgs[i]);
|
|
36
|
-
i++;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return cleaned.join(' ');
|
|
40
|
-
}
|
|
41
|
-
async function main() {
|
|
42
|
-
switch (command) {
|
|
43
|
-
case 'send_message': {
|
|
44
|
-
const text = stripFlags(args);
|
|
45
|
-
if (!text)
|
|
46
|
-
fail('Message text required');
|
|
47
|
-
if (!CHANNEL)
|
|
48
|
-
fail('SLACK_CHANNEL not set');
|
|
49
|
-
if (!THREAD_TS)
|
|
50
|
-
fail('SLACK_THREAD_TS not set');
|
|
51
|
-
console.error(`[slack-tool] send_message: channel=${CHANNEL}, thread_ts=${THREAD_TS}`);
|
|
52
|
-
const result = await slack.chat.postMessage({
|
|
53
|
-
channel: CHANNEL,
|
|
54
|
-
thread_ts: THREAD_TS,
|
|
55
|
-
text,
|
|
56
|
-
unfurl_links: false,
|
|
57
|
-
unfurl_media: false,
|
|
58
|
-
});
|
|
59
|
-
console.error(`[slack-tool] posted: ts=${result.ts}, thread_ts=${result.message?.thread_ts}`);
|
|
60
|
-
succeed({ ts: result.ts });
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
case 'add_reaction': {
|
|
64
|
-
const emoji = args[0];
|
|
65
|
-
if (!emoji)
|
|
66
|
-
fail('Emoji name required');
|
|
67
|
-
if (!CHANNEL)
|
|
68
|
-
fail('SLACK_CHANNEL not set');
|
|
69
|
-
if (!MESSAGE_TS)
|
|
70
|
-
fail('SLACK_MESSAGE_TS not set');
|
|
71
|
-
await slack.reactions.add({
|
|
72
|
-
channel: CHANNEL,
|
|
73
|
-
timestamp: MESSAGE_TS,
|
|
74
|
-
name: emoji,
|
|
75
|
-
});
|
|
76
|
-
succeed();
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
case 'remove_reaction': {
|
|
80
|
-
const emoji = args[0];
|
|
81
|
-
if (!emoji)
|
|
82
|
-
fail('Emoji name required');
|
|
83
|
-
if (!CHANNEL)
|
|
84
|
-
fail('SLACK_CHANNEL not set');
|
|
85
|
-
if (!MESSAGE_TS)
|
|
86
|
-
fail('SLACK_MESSAGE_TS not set');
|
|
87
|
-
await slack.reactions.remove({
|
|
88
|
-
channel: CHANNEL,
|
|
89
|
-
timestamp: MESSAGE_TS,
|
|
90
|
-
name: emoji,
|
|
91
|
-
});
|
|
92
|
-
succeed();
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case 'read_thread': {
|
|
96
|
-
if (!CHANNEL)
|
|
97
|
-
fail('SLACK_CHANNEL not set');
|
|
98
|
-
if (!THREAD_TS)
|
|
99
|
-
fail('SLACK_THREAD_TS not set');
|
|
100
|
-
const limit = parseInt(args[0] || '20', 10);
|
|
101
|
-
const result = await slack.conversations.replies({
|
|
102
|
-
channel: CHANNEL,
|
|
103
|
-
ts: THREAD_TS,
|
|
104
|
-
limit,
|
|
105
|
-
});
|
|
106
|
-
const messages = (result.messages || []).map((m) => ({
|
|
107
|
-
user: m.user || m.bot_id || 'unknown',
|
|
108
|
-
text: m.text || '',
|
|
109
|
-
ts: m.ts,
|
|
110
|
-
is_bot: Boolean(m.bot_id),
|
|
111
|
-
}));
|
|
112
|
-
succeed({ messages });
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
case 'set_status': {
|
|
116
|
-
const status = args.join(' ');
|
|
117
|
-
if (!CHANNEL)
|
|
118
|
-
fail('SLACK_CHANNEL not set');
|
|
119
|
-
if (!THREAD_TS)
|
|
120
|
-
fail('SLACK_THREAD_TS not set');
|
|
121
|
-
await slack.apiCall('assistant.threads.setStatus', {
|
|
122
|
-
channel_id: CHANNEL,
|
|
123
|
-
thread_ts: THREAD_TS,
|
|
124
|
-
status,
|
|
125
|
-
});
|
|
126
|
-
succeed();
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
case 'upload_snippet': {
|
|
130
|
-
const title = args[0];
|
|
131
|
-
const content = args[1];
|
|
132
|
-
const filetype = args[2] || 'text';
|
|
133
|
-
if (!title || !content)
|
|
134
|
-
fail('Title and content required');
|
|
135
|
-
if (!CHANNEL)
|
|
136
|
-
fail('SLACK_CHANNEL not set');
|
|
137
|
-
if (!THREAD_TS)
|
|
138
|
-
fail('SLACK_THREAD_TS not set');
|
|
139
|
-
await slack.filesUploadV2({
|
|
140
|
-
channel_id: CHANNEL,
|
|
141
|
-
thread_ts: THREAD_TS,
|
|
142
|
-
title,
|
|
143
|
-
content,
|
|
144
|
-
filetype,
|
|
145
|
-
});
|
|
146
|
-
succeed();
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
default:
|
|
150
|
-
fail(`Unknown command: ${command}. Available: send_message, add_reaction, remove_reaction, read_thread, set_status, upload_snippet`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
main().catch((err) => {
|
|
154
|
-
fail(err instanceof Error ? err.message : String(err));
|
|
155
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Upload a code/text snippet to a Slack thread.
|
|
4
|
-
*
|
|
5
|
-
* Usage:
|
|
6
|
-
* node upload-snippet.js "title" "content" [filetype]
|
|
7
|
-
*/
|
|
8
|
-
import { slack, fail, succeed, parseArgs } from './lib/slack-client.js';
|
|
9
|
-
const { channel, threadTs, positional } = parseArgs();
|
|
10
|
-
const [title, content, filetype = 'text'] = positional;
|
|
11
|
-
if (!title || !content)
|
|
12
|
-
fail('Title and content required');
|
|
13
|
-
if (!channel)
|
|
14
|
-
fail('Channel required');
|
|
15
|
-
if (!threadTs)
|
|
16
|
-
fail('Thread TS required');
|
|
17
|
-
async function main() {
|
|
18
|
-
await slack.filesUploadV2({ channel_id: channel, thread_ts: threadTs, title: title, content: content, filetype });
|
|
19
|
-
succeed();
|
|
20
|
-
}
|
|
21
|
-
main().catch((err) => fail(err instanceof Error ? err.message : String(err)));
|
|
File without changes
|