@dreki-gg/pi-slack 0.3.0 → 0.5.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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/extensions/slack/client/messages.ts +21 -0
- package/extensions/slack/format.ts +9 -1
- package/extensions/slack/index.ts +44 -1
- package/extensions/slack/tools.ts +10 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @dreki-gg/pi-slack
|
|
2
2
|
|
|
3
|
+
## [0.5.0](https://github.com/jalbarrang/pi-slack/compare/v0.4.0...v0.5.0) (2026-07-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* extract pi-slack from dreki-gg/pi-extensions monorepo ([1e14b33](https://github.com/jalbarrang/pi-slack/commit/1e14b33f8d8dd537d2e4df5d6f1ef78ae45855c1))
|
|
9
|
+
|
|
10
|
+
## 0.4.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Add a `slack_delete_message` tool that deletes a message the bot previously
|
|
15
|
+
posted via Slack's `chat.delete` API. Pass the channel ID and the message `ts`;
|
|
16
|
+
bots can only delete their own messages. No new scope is required — it uses the
|
|
17
|
+
existing `chat:write` permission.
|
|
18
|
+
|
|
3
19
|
## 0.3.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Juan Albarran
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ Uses [Effect](https://effect.website) for the Slack client layer (typed errors,
|
|
|
15
15
|
| `slack_download_file` | Download a shared file/image to temp directory |
|
|
16
16
|
| `slack_post_message` | Post a message to a channel or reply in a thread (requires `chat:write`) |
|
|
17
17
|
| `slack_edit_message` | Edit a message the bot previously posted (requires `chat:write`) |
|
|
18
|
+
| `slack_delete_message` | Delete a message the bot previously posted (requires `chat:write`) |
|
|
18
19
|
|
|
19
20
|
## Setup
|
|
20
21
|
|
|
@@ -19,6 +19,13 @@ export interface EditMessageResult {
|
|
|
19
19
|
channel: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
export interface DeleteMessageResult {
|
|
23
|
+
/** Timestamp of the deleted message. */
|
|
24
|
+
ts: string;
|
|
25
|
+
/** Channel the message lived in. */
|
|
26
|
+
channel: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
// ---------------------------------------------------------------------------
|
|
23
30
|
// Effects
|
|
24
31
|
// ---------------------------------------------------------------------------
|
|
@@ -63,3 +70,17 @@ export function editMessage(params: { channel: string; ts: string; text: string
|
|
|
63
70
|
} satisfies EditMessageResult;
|
|
64
71
|
});
|
|
65
72
|
}
|
|
73
|
+
|
|
74
|
+
export function deleteMessage(params: { channel: string; ts: string }) {
|
|
75
|
+
return Effect.gen(function* () {
|
|
76
|
+
const resp = yield* slackPost<{ ok: true; ts: string; channel: string }>('chat.delete', {
|
|
77
|
+
channel: params.channel,
|
|
78
|
+
ts: params.ts,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
ts: resp.ts,
|
|
83
|
+
channel: resp.channel,
|
|
84
|
+
} satisfies DeleteMessageResult;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { SlackChannel, SlackMessage, ReadMessagesResult } from './client/channels.js';
|
|
2
2
|
import type { SearchResult } from './client/search.js';
|
|
3
3
|
import type { DownloadedFile, SlackFileInfo } from './client/files.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
PostMessageResult,
|
|
6
|
+
EditMessageResult,
|
|
7
|
+
DeleteMessageResult,
|
|
8
|
+
} from './client/messages.js';
|
|
5
9
|
|
|
6
10
|
// ---------------------------------------------------------------------------
|
|
7
11
|
// Channels
|
|
@@ -94,6 +98,10 @@ export function formatEditedMessage(result: EditMessageResult): string {
|
|
|
94
98
|
return `✏️ Message edited in ${result.channel} (ts: ${result.ts})`;
|
|
95
99
|
}
|
|
96
100
|
|
|
101
|
+
export function formatDeletedMessage(result: DeleteMessageResult): string {
|
|
102
|
+
return `🗑️ Message deleted in ${result.channel} (ts: ${result.ts})`;
|
|
103
|
+
}
|
|
104
|
+
|
|
97
105
|
// ---------------------------------------------------------------------------
|
|
98
106
|
// Files
|
|
99
107
|
// ---------------------------------------------------------------------------
|
|
@@ -14,7 +14,7 @@ import { listChannels } from './client/channels.js';
|
|
|
14
14
|
import { readMessages, readThread } from './client/channels.js';
|
|
15
15
|
import { searchMessages } from './client/search.js';
|
|
16
16
|
import { downloadFile } from './client/files.js';
|
|
17
|
-
import { postMessage, editMessage } from './client/messages.js';
|
|
17
|
+
import { postMessage, editMessage, deleteMessage } from './client/messages.js';
|
|
18
18
|
import {
|
|
19
19
|
formatChannelList,
|
|
20
20
|
formatMessages,
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
formatDownloadedFile,
|
|
24
24
|
formatPostedMessage,
|
|
25
25
|
formatEditedMessage,
|
|
26
|
+
formatDeletedMessage,
|
|
26
27
|
} from './format.js';
|
|
27
28
|
import {
|
|
28
29
|
TOOL_GUIDELINES,
|
|
@@ -33,6 +34,7 @@ import {
|
|
|
33
34
|
downloadFileParams,
|
|
34
35
|
postMessageParams,
|
|
35
36
|
editMessageParams,
|
|
37
|
+
deleteMessageParams,
|
|
36
38
|
} from './tools.js';
|
|
37
39
|
|
|
38
40
|
// ---------------------------------------------------------------------------
|
|
@@ -379,6 +381,47 @@ export default function slackExtension(pi: ExtensionAPI) {
|
|
|
379
381
|
},
|
|
380
382
|
});
|
|
381
383
|
|
|
384
|
+
// -------------------------------------------------------------------------
|
|
385
|
+
// slack_delete_message
|
|
386
|
+
// -------------------------------------------------------------------------
|
|
387
|
+
|
|
388
|
+
pi.registerTool({
|
|
389
|
+
name: 'slack_delete_message',
|
|
390
|
+
label: 'Slack Delete Message',
|
|
391
|
+
description:
|
|
392
|
+
'Delete a message the bot previously posted. Requires the bot token to have the `chat:write` scope. Bots can only delete their own messages.',
|
|
393
|
+
promptSnippet: 'Delete a message the bot previously posted',
|
|
394
|
+
promptGuidelines: TOOL_GUIDELINES,
|
|
395
|
+
parameters: deleteMessageParams,
|
|
396
|
+
|
|
397
|
+
async execute(
|
|
398
|
+
_toolCallId: string,
|
|
399
|
+
params: {
|
|
400
|
+
channel: string;
|
|
401
|
+
ts: string;
|
|
402
|
+
},
|
|
403
|
+
) {
|
|
404
|
+
const creds = getCredentials();
|
|
405
|
+
if (!creds) return missingCredentials('bot');
|
|
406
|
+
|
|
407
|
+
try {
|
|
408
|
+
const result = await runSlack(
|
|
409
|
+
creds,
|
|
410
|
+
deleteMessage({
|
|
411
|
+
channel: params.channel,
|
|
412
|
+
ts: params.ts,
|
|
413
|
+
}),
|
|
414
|
+
);
|
|
415
|
+
return textResult(formatDeletedMessage(result), {
|
|
416
|
+
channel: result.channel,
|
|
417
|
+
ts: result.ts,
|
|
418
|
+
});
|
|
419
|
+
} catch (err) {
|
|
420
|
+
return errorResult(`❌ ${(err as Error).message}`);
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
|
|
382
425
|
// -------------------------------------------------------------------------
|
|
383
426
|
// /slack command — status check
|
|
384
427
|
// -------------------------------------------------------------------------
|
|
@@ -13,6 +13,7 @@ export const TOOL_GUIDELINES = [
|
|
|
13
13
|
'Use `slack_download_file` to download images or files shared in Slack. The tool saves files to a temp directory and returns the path — use `read` to view images.',
|
|
14
14
|
'Use `slack_post_message` to send a message to a channel or reply in a thread. The bot token must have the `chat:write` scope and the bot must be a member of the target channel.',
|
|
15
15
|
'Use `slack_edit_message` to edit a message the bot previously posted. Pass the channel ID and the message `ts` (returned by `slack_post_message`). Bots can only edit their own messages.',
|
|
16
|
+
'Use `slack_delete_message` to delete a message the bot previously posted. Pass the channel ID and the message `ts`. Bots can only delete their own messages.',
|
|
16
17
|
'When messages reference files or images (shown with 📎), download them with `slack_download_file` using the file ID to get visual context.',
|
|
17
18
|
'Channel IDs look like C0123ABC456. Thread timestamps look like 1512085950.000216.',
|
|
18
19
|
];
|
|
@@ -147,3 +148,12 @@ export const editMessageParams = Type.Object({
|
|
|
147
148
|
description: 'New message text. Supports Slack mrkdwn formatting.',
|
|
148
149
|
}),
|
|
149
150
|
});
|
|
151
|
+
|
|
152
|
+
export const deleteMessageParams = Type.Object({
|
|
153
|
+
channel: Type.String({
|
|
154
|
+
description: 'Channel ID (e.g. C0123ABC456) where the message lives.',
|
|
155
|
+
}),
|
|
156
|
+
ts: Type.String({
|
|
157
|
+
description: 'Timestamp of the message to delete (the `ts` returned by slack_post_message).',
|
|
158
|
+
}),
|
|
159
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreki-gg/pi-slack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Slack read tools for pi — messages, threads, channels, search, and file/image downloads with Effect-powered client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/
|
|
17
|
-
"directory": "packages/slack"
|
|
16
|
+
"url": "git+https://github.com/jalbarrang/pi-slack.git"
|
|
18
17
|
},
|
|
19
18
|
"type": "module",
|
|
20
19
|
"files": [
|
|
@@ -44,7 +43,9 @@
|
|
|
44
43
|
"bun-types": "^1.3.14",
|
|
45
44
|
"oxfmt": "^0.43.0",
|
|
46
45
|
"oxlint": "^1.58.0",
|
|
47
|
-
"typescript": "^6.0.0"
|
|
46
|
+
"typescript": "^6.0.0",
|
|
47
|
+
"@earendil-works/pi-coding-agent": "^0.75.4",
|
|
48
|
+
"typebox": "^1.0.55"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"@earendil-works/pi-coding-agent": "*",
|