@cuylabs/channel-slack 0.5.0 → 0.6.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/README.md +25 -136
- package/dist/app-home.d.ts +23 -0
- package/dist/app-home.js +35 -0
- package/dist/artifacts/index.d.ts +135 -0
- package/dist/artifacts/index.js +299 -0
- package/dist/{assistant.d.ts → assistant/index.d.ts} +1 -1
- package/dist/{assistant.js → assistant/index.js} +2 -2
- package/dist/auth/index.d.ts +56 -0
- package/dist/auth/index.js +168 -0
- package/dist/{chunk-IDVDMJ5U.js → chunk-6JSGIVQH.js} +110 -3
- package/dist/chunk-6WHFQUYQ.js +54 -0
- package/dist/{bolt.js → chunk-73QXT7MA.js} +29 -322
- package/dist/{chunk-CMR6B76C.js → chunk-DNVSH7H5.js} +407 -1
- package/dist/chunk-QJYCHWN6.js +76 -0
- package/dist/chunk-S3SWPYXJ.js +81 -0
- package/dist/{chunk-JZG4IETE.js → chunk-X4WBBBYM.js} +0 -52
- package/dist/core.js +5 -3
- package/dist/diagnostics/index.d.ts +71 -0
- package/dist/{diagnostics.js → diagnostics/index.js} +5 -1
- package/dist/entrypoints/index.d.ts +120 -0
- package/dist/entrypoints/index.js +132 -0
- package/dist/{history.d.ts → history/index.d.ts} +2 -2
- package/dist/{history.js → history/index.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -15
- package/dist/{policy.d.ts → policy/index.d.ts} +103 -2
- package/dist/{policy.js → policy/index.js} +13 -1
- package/dist/runtime-BNBHOZSQ.d.ts +53 -0
- package/dist/{setup.d.ts → setup/index.d.ts} +30 -3
- package/dist/{setup.js → setup/index.js} +134 -3
- package/dist/transports/http/index.d.ts +68 -0
- package/dist/transports/http/index.js +8 -0
- package/dist/transports/index.d.ts +8 -0
- package/dist/transports/index.js +24 -0
- package/dist/transports/socket/index.d.ts +94 -0
- package/dist/transports/socket/index.js +19 -0
- package/dist/types-B9NfCVrk.d.ts +141 -0
- package/docs/README.md +31 -0
- package/docs/concepts/activity.md +3 -3
- package/docs/concepts/artifacts.md +56 -0
- package/docs/concepts/entrypoints.md +73 -0
- package/docs/concepts/message-policy.md +13 -0
- package/docs/concepts/setup-requirements.md +23 -0
- package/docs/concepts/{bolt-runtime.md → transport-runtime.md} +14 -4
- package/docs/recipes/app-mention-handler.md +5 -0
- package/docs/recipes/generate-slack-manifest.md +16 -0
- package/docs/recipes/publish-artifact.md +45 -0
- package/docs/recipes/slash-command-and-shortcut.md +51 -0
- package/docs/recipes/socket-mode-app.md +1 -1
- package/docs/reference/channel-slack-boundary.md +10 -6
- package/docs/reference/exports.md +7 -2
- package/docs/reference/source-layout.md +35 -0
- package/package.json +63 -39
- package/dist/bolt.d.ts +0 -364
- package/dist/chunk-NE57BLLU.js +0 -0
- package/dist/diagnostics.d.ts +0 -22
- package/dist/shared.d.ts +0 -2
- package/dist/shared.js +0 -43
- /package/dist/{feedback.d.ts → feedback/index.d.ts} +0 -0
- /package/dist/{feedback.js → feedback/index.js} +0 -0
- /package/dist/{targets.d.ts → targets/index.d.ts} +0 -0
- /package/dist/{targets.js → targets/index.js} +0 -0
- /package/dist/{users.d.ts → users/index.d.ts} +0 -0
- /package/dist/{users.js → users/index.js} +0 -0
package/docs/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Channel Slack Docs
|
|
2
|
+
|
|
3
|
+
`@cuylabs/channel-slack` is the reusable Slack mechanics package. Start with
|
|
4
|
+
the package boundary, then use the reference and recipes for the feature surface
|
|
5
|
+
your adapter or application needs.
|
|
6
|
+
|
|
7
|
+
## Reference
|
|
8
|
+
|
|
9
|
+
- [Package boundary](reference/channel-slack-boundary.md)
|
|
10
|
+
- [Exports and peer expectations](reference/exports.md)
|
|
11
|
+
- [Source layout](reference/source-layout.md)
|
|
12
|
+
|
|
13
|
+
## Concepts
|
|
14
|
+
|
|
15
|
+
- [Activity parsing](concepts/activity.md)
|
|
16
|
+
- [Artifacts](concepts/artifacts.md)
|
|
17
|
+
- [Entrypoints](concepts/entrypoints.md)
|
|
18
|
+
- [Message policy](concepts/message-policy.md)
|
|
19
|
+
- [Setup requirements](concepts/setup-requirements.md)
|
|
20
|
+
- [Supplemental history](concepts/supplemental-history.md)
|
|
21
|
+
- [Transport runtime](concepts/transport-runtime.md)
|
|
22
|
+
|
|
23
|
+
## Recipes
|
|
24
|
+
|
|
25
|
+
- [App mention handler](recipes/app-mention-handler.md)
|
|
26
|
+
- [Assistant thread handler](recipes/assistant-thread-handler.md)
|
|
27
|
+
- [Socket Mode app](recipes/socket-mode-app.md)
|
|
28
|
+
- [Slash command and shortcut handler](recipes/slash-command-and-shortcut.md)
|
|
29
|
+
- [Publish an artifact](recipes/publish-artifact.md)
|
|
30
|
+
- [Generate a Slack manifest](recipes/generate-slack-manifest.md)
|
|
31
|
+
- [History visibility filter](recipes/history-visibility.md)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Activity
|
|
2
2
|
|
|
3
|
-
An activity is the normalized message shape an
|
|
4
|
-
|
|
5
|
-
Bolt.
|
|
3
|
+
An activity is the normalized Slack message shape an adapter or application can
|
|
4
|
+
map into its own runtime. It is intentionally smaller than a raw Slack event and
|
|
5
|
+
does not depend on Bolt.
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
8
|
import { parseSlackMentionActivity } from "@cuylabs/channel-slack/core";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Artifacts
|
|
2
|
+
|
|
3
|
+
Artifacts publish generated outputs to Slack without depending on any agent
|
|
4
|
+
runtime. The package accepts a structural Slack Web API client, so callers can
|
|
5
|
+
pass a real `WebClient`, a scoped client from a request handler, or a test
|
|
6
|
+
double with the methods they use.
|
|
7
|
+
|
|
8
|
+
```typescript
|
|
9
|
+
import { publishSlackArtifact } from "@cuylabs/channel-slack/artifacts";
|
|
10
|
+
|
|
11
|
+
const publication = await publishSlackArtifact({
|
|
12
|
+
client,
|
|
13
|
+
channelId: activity.channelId,
|
|
14
|
+
threadTs: activity.threadTs ?? activity.messageTs,
|
|
15
|
+
artifact: {
|
|
16
|
+
kind: "text",
|
|
17
|
+
title: "Investigation summary",
|
|
18
|
+
summary: "Key findings from the thread.",
|
|
19
|
+
text: reportMarkdown,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Artifact Kinds
|
|
25
|
+
|
|
26
|
+
- `text`: uploads text as a Slack file by default. Set `publishAs: "message"`
|
|
27
|
+
to post it as a Block Kit message instead.
|
|
28
|
+
- `file`: uploads binary or text data from `data` or `filePath`.
|
|
29
|
+
- `image`: uploads an image file and requires `altText`.
|
|
30
|
+
- `link`: posts a Block Kit message with a Slack-formatted link.
|
|
31
|
+
- `canvas`: creates or updates a Slack Canvas from Markdown.
|
|
32
|
+
|
|
33
|
+
## Results
|
|
34
|
+
|
|
35
|
+
`publishSlackArtifact` returns a `SlackArtifactPublication` with:
|
|
36
|
+
|
|
37
|
+
- `method`: `message`, `file`, or `canvas`.
|
|
38
|
+
- the original `artifact`.
|
|
39
|
+
- the raw Slack API `response`.
|
|
40
|
+
- target metadata such as `channelId`, `threadTs`, `messageTs`, `fileId`, or
|
|
41
|
+
`canvasId` when Slack returns it.
|
|
42
|
+
|
|
43
|
+
## Slack Client Surface
|
|
44
|
+
|
|
45
|
+
Only the method required by the selected artifact kind must exist:
|
|
46
|
+
|
|
47
|
+
- message/link artifacts use `client.chat.postMessage`.
|
|
48
|
+
- text/file/image file uploads use `client.files.uploadV2`.
|
|
49
|
+
- Canvas creation uses `client.conversations.canvases.create` for channel
|
|
50
|
+
canvases when available, or `client.canvases.create` otherwise.
|
|
51
|
+
- Canvas updates use `client.canvases.edit`.
|
|
52
|
+
|
|
53
|
+
## Setup
|
|
54
|
+
|
|
55
|
+
The `artifacts` setup feature adds `chat:write` and `files:write`.
|
|
56
|
+
The `canvas-artifacts` setup feature adds `canvases:write`.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Entrypoints
|
|
2
|
+
|
|
3
|
+
Entrypoints normalize Slack slash command and shortcut payloads into small
|
|
4
|
+
package contracts. They do not start a turn or choose a runtime request shape.
|
|
5
|
+
|
|
6
|
+
```typescript
|
|
7
|
+
import { parseSlackSlashCommandEntrypoint } from "@cuylabs/channel-slack/entrypoints";
|
|
8
|
+
|
|
9
|
+
const entrypoint = parseSlackSlashCommandEntrypoint(payload);
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Slash Commands
|
|
13
|
+
|
|
14
|
+
`parseSlackSlashCommandEntrypoint` returns:
|
|
15
|
+
|
|
16
|
+
- `kind: "slash-command"`.
|
|
17
|
+
- `command`: the invoked slash command, such as `/ask`.
|
|
18
|
+
- `activity`: a `SlackActivityInfo` shape with channel, user, team, and text.
|
|
19
|
+
- optional Slack request metadata such as `triggerId`, `responseUrl`,
|
|
20
|
+
`channelName`, `teamDomain`, `appId`, and enterprise fields.
|
|
21
|
+
|
|
22
|
+
The parser treats the command text as the model-facing text. A host adapter can
|
|
23
|
+
map `entrypoint.activity.text` into its own runtime input while preserving the
|
|
24
|
+
Slack metadata for routing, logging, or response targets.
|
|
25
|
+
|
|
26
|
+
## Shortcuts
|
|
27
|
+
|
|
28
|
+
Use `parseSlackShortcutEntrypoint` when one handler receives both global and
|
|
29
|
+
message shortcuts:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { parseSlackShortcutEntrypoint } from "@cuylabs/channel-slack/entrypoints";
|
|
33
|
+
|
|
34
|
+
const entrypoint = parseSlackShortcutEntrypoint(payload);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Global shortcuts return `kind: "global-shortcut"` and include trigger/user/team
|
|
38
|
+
metadata, but no selected message.
|
|
39
|
+
|
|
40
|
+
Message shortcuts return `kind: "message-shortcut"`, include the selected
|
|
41
|
+
message text, and also expose `activity` so a runtime adapter can treat the
|
|
42
|
+
selection as a Slack turn candidate.
|
|
43
|
+
|
|
44
|
+
## Setup
|
|
45
|
+
|
|
46
|
+
Passing `slashCommands` or `shortcuts` to setup helpers automatically enables
|
|
47
|
+
the matching feature, the `commands` scope, and Slack interactivity settings.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { createSlackAppManifest } from "@cuylabs/channel-slack/setup";
|
|
51
|
+
|
|
52
|
+
const manifest = createSlackAppManifest({
|
|
53
|
+
name: "My Agent",
|
|
54
|
+
preset: false,
|
|
55
|
+
transport: "http",
|
|
56
|
+
baseUrl: "https://agent.example.com",
|
|
57
|
+
slashCommands: [
|
|
58
|
+
{
|
|
59
|
+
command: "/ask",
|
|
60
|
+
description: "Ask the agent",
|
|
61
|
+
usage_hint: "summarize this thread",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
shortcuts: [
|
|
65
|
+
{
|
|
66
|
+
type: "message",
|
|
67
|
+
name: "Summarize message",
|
|
68
|
+
callback_id: "summarize_message",
|
|
69
|
+
description: "Summarize the selected Slack message",
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
```
|
|
@@ -16,6 +16,10 @@ const decision = policy.resolve(activity);
|
|
|
16
16
|
if (!decision.accepted) return;
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
`decision.reason` is intended for host-owned logs, metrics, and audit records.
|
|
20
|
+
For example, a host can distinguish `bot-mentioned` from
|
|
21
|
+
`mentioned-thread-reply` without the SDK choosing log levels or log shape.
|
|
22
|
+
|
|
19
23
|
## Channel Message Policy
|
|
20
24
|
|
|
21
25
|
`messagePolicy` controls passive channel messages:
|
|
@@ -27,6 +31,15 @@ if (!decision.accepted) return;
|
|
|
27
31
|
|
|
28
32
|
DMs and direct mentions are always accepted unless they are duplicates.
|
|
29
33
|
|
|
34
|
+
Accepted decisions include one of these reasons:
|
|
35
|
+
|
|
36
|
+
- `direct-message`: the message came from a DM.
|
|
37
|
+
- `bot-mentioned`: the bot was directly mentioned.
|
|
38
|
+
- `mentioned-thread-reply`: a non-mentioned reply continued a remembered
|
|
39
|
+
mentioned thread.
|
|
40
|
+
- `allowed-channel`: a passive message matched `allowed-channels`.
|
|
41
|
+
- `any-added-channel`: a passive message matched `any-added-channel`.
|
|
42
|
+
|
|
30
43
|
## Thread Reply Policy
|
|
31
44
|
|
|
32
45
|
`threadReplyPolicy` controls non-mentioned replies inside remembered mentioned
|
|
@@ -19,6 +19,10 @@ const requirements = getSlackSetupRequirements({
|
|
|
19
19
|
- `agent-app`: Assistant, app mentions, direct messages, and feedback.
|
|
20
20
|
|
|
21
21
|
Pass `preset: false` and provide `features` when an app needs exact control.
|
|
22
|
+
Supplying `slashCommands` or `shortcuts` automatically enables the matching
|
|
23
|
+
feature and adds the Slack `commands` scope plus interactivity settings.
|
|
24
|
+
The `artifacts` feature adds `chat:write` and `files:write`; the
|
|
25
|
+
`canvas-artifacts` feature adds `canvases:write`.
|
|
22
26
|
|
|
23
27
|
## Features
|
|
24
28
|
|
|
@@ -32,12 +36,31 @@ Feature selections produce:
|
|
|
32
36
|
Socket Mode.
|
|
33
37
|
- environment variables needed by the chosen transport.
|
|
34
38
|
|
|
39
|
+
Common feature selections:
|
|
40
|
+
|
|
41
|
+
- `assistant`: Assistant view events, `assistant:write`, and `chat:write`.
|
|
42
|
+
- `app-mentions`: app mention event subscription and reply permission.
|
|
43
|
+
- `direct-messages`: DM message events and DM history/read scopes.
|
|
44
|
+
- `channel-messages`: passive channel/group message events and history scopes.
|
|
45
|
+
- `slash-commands`: `commands` scope and interactivity.
|
|
46
|
+
- `shortcuts`: `commands` scope and interactivity.
|
|
47
|
+
- `artifacts`: `chat:write` and `files:write`.
|
|
48
|
+
- `canvas-artifacts`: `canvases:write`.
|
|
49
|
+
- `history`: channel, group, DM, and MPIM history scopes.
|
|
50
|
+
- `feedback` and `interactivity`: `chat:write` plus interactivity.
|
|
51
|
+
- `user-profiles` and `user-emails`: Slack user profile scopes.
|
|
52
|
+
- `workspace-search`: Slack search scopes.
|
|
53
|
+
|
|
35
54
|
## Manifests
|
|
36
55
|
|
|
37
56
|
`createSlackAppManifest` produces a Slack app manifest from the same
|
|
38
57
|
requirements. `compareSlackAppManifest` checks an existing manifest-like object
|
|
39
58
|
against requirements and returns path-level findings.
|
|
40
59
|
|
|
60
|
+
Pass `slashCommands` and `shortcuts` to include those manifest sections. For
|
|
61
|
+
HTTP transport, command and interactivity URLs are filled from `baseUrl` and
|
|
62
|
+
`eventsPath` unless a command defines its own `url`.
|
|
63
|
+
|
|
41
64
|
## Inspection
|
|
42
65
|
|
|
43
66
|
`inspectSlackAppSetup` combines requirements with a live token inspection. It
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Transport Runtime
|
|
2
2
|
|
|
3
|
-
The
|
|
4
|
-
not register handlers, own prompts, run agents, or choose deployment policy.
|
|
3
|
+
The transport helpers create Slack apps with Bolt auth wiring. They deliberately
|
|
4
|
+
do not register handlers, own prompts, run agents, or choose deployment policy.
|
|
5
|
+
|
|
6
|
+
Use transport-specific imports:
|
|
7
|
+
|
|
8
|
+
- `@cuylabs/channel-slack/transports/http`
|
|
9
|
+
- `@cuylabs/channel-slack/transports/socket`
|
|
5
10
|
|
|
6
11
|
## HTTP
|
|
7
12
|
|
|
@@ -29,6 +34,11 @@ that can:
|
|
|
29
34
|
|
|
30
35
|
Use `runtime.close()` during shutdown so a process lock is released.
|
|
31
36
|
|
|
37
|
+
The runtime log reports the SDK-local process lock separately as
|
|
38
|
+
`processLockConfigured` and `processLockAcquired`. These fields describe only
|
|
39
|
+
the SDK file/process lock created by `createSlackSocketModeRuntime`; they do not
|
|
40
|
+
describe a distributed Postgres lock acquired separately.
|
|
41
|
+
|
|
32
42
|
For distributed deployments, `acquireSlackSocketModePostgresLock` can acquire a
|
|
33
43
|
Postgres advisory lock before starting the Socket Mode app:
|
|
34
44
|
|
|
@@ -36,7 +46,7 @@ Postgres advisory lock before starting the Socket Mode app:
|
|
|
36
46
|
import {
|
|
37
47
|
acquireSlackSocketModePostgresLock,
|
|
38
48
|
createSlackSocketModeRuntime,
|
|
39
|
-
} from "@cuylabs/channel-slack/
|
|
49
|
+
} from "@cuylabs/channel-slack/transports/socket";
|
|
40
50
|
|
|
41
51
|
const postgresLock = await acquireSlackSocketModePostgresLock({
|
|
42
52
|
appSlug: "my-agent",
|
|
@@ -19,6 +19,11 @@ app.event("app_mention", async ({ event, client }) => {
|
|
|
19
19
|
const activity = parseSlackMentionActivity(event);
|
|
20
20
|
const decision = policy.resolve(activity);
|
|
21
21
|
if (!decision.accepted) return;
|
|
22
|
+
logger.info("Slack message accepted", {
|
|
23
|
+
channelId: activity.channelId,
|
|
24
|
+
reason: decision.reason,
|
|
25
|
+
threadTs: activity.threadTs,
|
|
26
|
+
});
|
|
22
27
|
|
|
23
28
|
const answer = await runAgent({
|
|
24
29
|
input: decision.text,
|
|
@@ -9,6 +9,22 @@ const manifest = createSlackAppManifest({
|
|
|
9
9
|
preset: "agent-app",
|
|
10
10
|
transport: "socket",
|
|
11
11
|
assistantDescription: "Ask the agent for help with workspace tasks.",
|
|
12
|
+
slashCommands: [
|
|
13
|
+
{
|
|
14
|
+
command: "/ask",
|
|
15
|
+
description: "Ask the agent",
|
|
16
|
+
usage_hint: "summarize this thread",
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
shortcuts: [
|
|
20
|
+
{
|
|
21
|
+
type: "message",
|
|
22
|
+
name: "Summarize message",
|
|
23
|
+
callback_id: "summarize_message",
|
|
24
|
+
description: "Summarize the selected Slack message",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
features: ["artifacts", "canvas-artifacts"],
|
|
12
28
|
});
|
|
13
29
|
|
|
14
30
|
console.log(JSON.stringify(manifest, null, 2));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Publish An Artifact
|
|
2
|
+
|
|
3
|
+
Use artifact helpers when a runtime produces a report, file, image, link, or
|
|
4
|
+
Canvas and the Slack adapter only needs to publish it.
|
|
5
|
+
|
|
6
|
+
```typescript
|
|
7
|
+
import { publishSlackArtifact } from "@cuylabs/channel-slack/artifacts";
|
|
8
|
+
|
|
9
|
+
const result = await publishSlackArtifact({
|
|
10
|
+
client,
|
|
11
|
+
channelId: activity.channelId,
|
|
12
|
+
threadTs: activity.threadTs ?? activity.messageTs,
|
|
13
|
+
artifact: {
|
|
14
|
+
kind: "text",
|
|
15
|
+
title: "Launch summary",
|
|
16
|
+
summary: "Generated from the selected Slack thread.",
|
|
17
|
+
text: reportMarkdown,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
logger.info("Slack artifact published", {
|
|
22
|
+
method: result.method,
|
|
23
|
+
fileId: result.fileId,
|
|
24
|
+
messageTs: result.messageTs,
|
|
25
|
+
canvasId: result.canvasId,
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To create a Canvas instead:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
await publishSlackArtifact({
|
|
33
|
+
client,
|
|
34
|
+
channelId: activity.channelId,
|
|
35
|
+
artifact: {
|
|
36
|
+
kind: "canvas",
|
|
37
|
+
title: "Launch plan",
|
|
38
|
+
summary: "Generated plan",
|
|
39
|
+
markdown: canvasMarkdown,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Enable the `artifacts` setup feature for files and messages. Enable
|
|
45
|
+
`canvas-artifacts` when publishing canvases.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Slash Command And Shortcut Handler
|
|
2
|
+
|
|
3
|
+
Use entrypoint parsers to normalize Slack request payloads before handing them
|
|
4
|
+
to an application-owned runtime.
|
|
5
|
+
|
|
6
|
+
```typescript
|
|
7
|
+
import {
|
|
8
|
+
parseSlackShortcutEntrypoint,
|
|
9
|
+
parseSlackSlashCommandEntrypoint,
|
|
10
|
+
} from "@cuylabs/channel-slack/entrypoints";
|
|
11
|
+
|
|
12
|
+
app.command("/ask", async ({ ack, body, client }) => {
|
|
13
|
+
await ack();
|
|
14
|
+
|
|
15
|
+
const entrypoint = parseSlackSlashCommandEntrypoint(body);
|
|
16
|
+
const answer = await runAgent({
|
|
17
|
+
input: entrypoint.activity.text,
|
|
18
|
+
slack: entrypoint.activity,
|
|
19
|
+
entrypoint,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
await client.chat.postMessage({
|
|
23
|
+
channel: entrypoint.activity.channelId,
|
|
24
|
+
text: answer,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
app.shortcut("summarize_message", async ({ ack, body, client }) => {
|
|
29
|
+
await ack();
|
|
30
|
+
|
|
31
|
+
const entrypoint = parseSlackShortcutEntrypoint(body);
|
|
32
|
+
if (entrypoint.kind !== "message-shortcut") return;
|
|
33
|
+
|
|
34
|
+
const answer = await runAgent({
|
|
35
|
+
input: entrypoint.selectedMessage.text,
|
|
36
|
+
slack: entrypoint.activity,
|
|
37
|
+
entrypoint,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
await client.chat.postMessage({
|
|
41
|
+
channel: entrypoint.selectedMessage.channelId,
|
|
42
|
+
thread_ts:
|
|
43
|
+
entrypoint.selectedMessage.threadTs ??
|
|
44
|
+
entrypoint.selectedMessage.messageTs,
|
|
45
|
+
text: answer,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For manifest setup, pass `slashCommands` and `shortcuts` to
|
|
51
|
+
`createSlackAppManifest`.
|
|
@@ -5,16 +5,19 @@ Slack events, formats Slack output, applies reusable admission and history
|
|
|
5
5
|
policies, and provides Slack setup/runtime helpers. It does not create or run an
|
|
6
6
|
agent.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
Runtime-specific adapter packages compose these primitives with their own
|
|
9
|
+
runtime scopes, event streams, context fragments, and approval or human-input
|
|
10
|
+
contracts.
|
|
11
11
|
|
|
12
12
|
## In This Package
|
|
13
13
|
|
|
14
14
|
- Slack activity parsing and text extraction.
|
|
15
|
+
- Slack slash command and shortcut entrypoint normalization.
|
|
16
|
+
- Slack artifact publishing contracts and helpers.
|
|
15
17
|
- Markdown-to-Slack formatting.
|
|
16
18
|
- Thread-aware session helpers.
|
|
17
|
-
- Slack auth and installation
|
|
19
|
+
- Slack auth and installation-store helpers.
|
|
20
|
+
- HTTP and Socket Mode Bolt transport helpers.
|
|
18
21
|
- Socket Mode runtime guard, process lock, and optional Postgres advisory lock.
|
|
19
22
|
- Setup requirements and manifest helpers.
|
|
20
23
|
- Diagnostics.
|
|
@@ -29,6 +32,7 @@ approval or human-input contracts.
|
|
|
29
32
|
|
|
30
33
|
- Agent runtime execution.
|
|
31
34
|
- Agent-runtime scopes and context-fragment middleware.
|
|
35
|
+
- Runtime-specific mapping from Slack entrypoints into an agent turn.
|
|
32
36
|
- Agent event stream rendering.
|
|
33
37
|
- Agent-specific approval and human-input request contracts.
|
|
34
38
|
- Product prompts, tools, audit policy, and deployment policy.
|
|
@@ -38,8 +42,8 @@ Those pieces belong in runtime-specific adapters or product applications.
|
|
|
38
42
|
## Behavior Notes
|
|
39
43
|
|
|
40
44
|
- The root export is lightweight: `core`, `policy`, and `Logger`.
|
|
41
|
-
- Peer-backed helpers live behind feature subpaths such as `
|
|
42
|
-
`setup`, `diagnostics`, and `users`.
|
|
45
|
+
- Peer-backed helpers live behind feature subpaths such as `transports`,
|
|
46
|
+
`app-home`, `history`, `setup`, `diagnostics`, and `users`.
|
|
43
47
|
- Interactive request types are generic rather than derived from any
|
|
44
48
|
agent-runtime event type.
|
|
45
49
|
- Socket Mode logging uses this package's logger bridge rather than an agent
|
|
@@ -6,12 +6,17 @@ keep application code close to the package boundary it uses.
|
|
|
6
6
|
| Export | Depends on | Notes |
|
|
7
7
|
| ------------------------------------ | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
8
8
|
| `@cuylabs/channel-slack/core` | no Slack SDK runtime imports | Transport-neutral parsing, formatting, types, sessions, turn context |
|
|
9
|
-
| `@cuylabs/channel-slack/shared` | no Slack SDK runtime imports | Compatibility alias for `core` |
|
|
10
9
|
| `@cuylabs/channel-slack/policy` | `pg` only when using connection-string Postgres state | Message admission and in-memory/Postgres policy state |
|
|
11
10
|
| `@cuylabs/channel-slack/history` | `@slack/web-api` types | History reader accepts a Slack WebClient or minimal conversations client |
|
|
12
|
-
| `@cuylabs/channel-slack/
|
|
11
|
+
| `@cuylabs/channel-slack/app-home` | `@slack/bolt`, `@slack/types` | Slack App Home registration helper |
|
|
12
|
+
| `@cuylabs/channel-slack/artifacts` | no Slack SDK runtime imports; requires a Web API-like client at call time | Text, file, image, link, and Canvas artifact publishing |
|
|
13
|
+
| `@cuylabs/channel-slack/auth` | no Slack SDK runtime imports; `pg` is not required | Auth option types, auth resolution, OAuth installation stores |
|
|
14
|
+
| `@cuylabs/channel-slack/transports` | `@slack/bolt`, `express`; `pg` only when using connection-string Postgres locks | HTTP and Socket Mode transport helpers |
|
|
15
|
+
| `@cuylabs/channel-slack/transports/http` | `@slack/bolt`, `express` | HTTP Events API Bolt app factory |
|
|
16
|
+
| `@cuylabs/channel-slack/transports/socket` | `@slack/bolt`; `pg` only when using connection-string Postgres locks | Socket Mode app factory, runtime guard, process/Postgres locks |
|
|
13
17
|
| `@cuylabs/channel-slack/setup` | diagnostics only when inspecting live tokens | Setup requirements and app manifest helpers |
|
|
14
18
|
| `@cuylabs/channel-slack/diagnostics` | `@slack/web-api` | Token, auth, and scope inspection |
|
|
19
|
+
| `@cuylabs/channel-slack/entrypoints` | no Slack SDK runtime imports | Slash command and shortcut payload normalization |
|
|
15
20
|
| `@cuylabs/channel-slack/users` | `@slack/web-api` when using default client | User profile lookup and mention enrichment |
|
|
16
21
|
| `@cuylabs/channel-slack/targets` | no Slack SDK runtime imports unless resolving names through a client | Parse and resolve channel/user targets |
|
|
17
22
|
| `@cuylabs/channel-slack/feedback` | `@slack/types` types | Feedback block and action helpers |
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Source Layout
|
|
2
|
+
|
|
3
|
+
The package is organized by Slack capability. Public imports should use package
|
|
4
|
+
exports such as `@cuylabs/channel-slack/core` or
|
|
5
|
+
`@cuylabs/channel-slack/transports/socket`; application code should not import
|
|
6
|
+
from `src`.
|
|
7
|
+
|
|
8
|
+
```text
|
|
9
|
+
src/
|
|
10
|
+
core.ts public core entrypoint
|
|
11
|
+
shared/ types, parsing, formatting, turn helpers
|
|
12
|
+
assistant/ Slack Assistant API helpers
|
|
13
|
+
app-home.ts Slack App Home registration helper
|
|
14
|
+
artifacts/ text, file, image, link, and Canvas publishing
|
|
15
|
+
auth/ auth options, auth resolution, installation stores
|
|
16
|
+
diagnostics/ token and scope inspection
|
|
17
|
+
entrypoints/ slash command and shortcut normalization
|
|
18
|
+
feedback/ feedback blocks and action parsing
|
|
19
|
+
history/
|
|
20
|
+
context/ turn-history loading component
|
|
21
|
+
reader.ts Slack history API reader and prompt formatter
|
|
22
|
+
visibility-policy.ts model-visible history filters
|
|
23
|
+
inclusion-policy.ts direct-message supplemental-history inclusion policy
|
|
24
|
+
policy/
|
|
25
|
+
message/ message admission and state-store component
|
|
26
|
+
setup/ scopes, events, manifests, setup inspection
|
|
27
|
+
transports/
|
|
28
|
+
http/ HTTP Events API Bolt app factory
|
|
29
|
+
socket/ Socket Mode Bolt app factory, runtime, locks
|
|
30
|
+
targets/ channel/user target parsing and resolution
|
|
31
|
+
users/ profile lookup and mention enrichment
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For public export details and peer dependency expectations, see
|
|
35
|
+
[Exports](exports.md).
|