@wheatley-ai/cli 0.0.0-stage → 0.0.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/LICENSE +15 -0
- package/bin/wheatley.js +2 -0
- package/dist/approvals/gate.js +278 -0
- package/dist/approvals/module.js +21 -0
- package/dist/approvals/policy.js +30 -0
- package/dist/approvals/preview.js +17 -0
- package/dist/approvals/prompt.js +98 -0
- package/dist/approvals/rpc.js +16 -0
- package/dist/approvals/store.js +159 -0
- package/dist/cli/ask.js +94 -0
- package/dist/cli/chat.js +180 -0
- package/dist/cli/client.js +104 -0
- package/dist/cli/daemon.js +35 -0
- package/dist/cli/init.js +72 -0
- package/dist/cli/io.js +45 -0
- package/dist/cli/main.js +204 -0
- package/dist/cli/session.js +87 -0
- package/dist/cli/status.js +46 -0
- package/dist/contracts/approval-gate.js +1 -0
- package/dist/contracts/config-store.js +1 -0
- package/dist/contracts/delivery-outbox.js +1 -0
- package/dist/contracts/errors.js +28 -0
- package/dist/contracts/extension-catalog.js +1 -0
- package/dist/contracts/maintenance-runner.js +1 -0
- package/dist/contracts/memory-store.js +1 -0
- package/dist/contracts/module.js +7 -0
- package/dist/contracts/tool-names.js +43 -0
- package/dist/contracts/trigger-runtime.js +1 -0
- package/dist/contracts/webhook-ingress.js +2 -0
- package/dist/core/agent/agent-store.js +300 -0
- package/dist/core/agent/agent.js +1020 -0
- package/dist/core/agent/gated-models.js +89 -0
- package/dist/core/agent/pi-adapter.js +401 -0
- package/dist/core/agent/policy-gate.js +44 -0
- package/dist/core/builtin-catalog.js +20 -0
- package/dist/core/concurrency-gate.js +87 -0
- package/dist/core/config/atomic-file.js +61 -0
- package/dist/core/config/config-store.js +138 -0
- package/dist/core/config/pending-restart.js +53 -0
- package/dist/core/config/secret-references.js +69 -0
- package/dist/core/config/secret-store.js +147 -0
- package/dist/core/config/validate.js +55 -0
- package/dist/core/config/yaml-patch.js +57 -0
- package/dist/core/daemon.js +88 -0
- package/dist/core/deployment.js +347 -0
- package/dist/core/error-message.js +4 -0
- package/dist/core/events.js +25 -0
- package/dist/core/logger.js +81 -0
- package/dist/core/models.js +27 -0
- package/dist/core/module.js +42 -0
- package/dist/core/rpc/agent-handlers.js +82 -0
- package/dist/core/rpc/deployment-handlers.js +63 -0
- package/dist/core/rpc/router.js +95 -0
- package/dist/core/server/connection.js +170 -0
- package/dist/core/server/control-server.js +152 -0
- package/dist/core/server/static-files.js +79 -0
- package/dist/core/supervisor.js +206 -0
- package/dist/core/tool-routing.js +41 -0
- package/dist/dashboard/assets/index-3COz_MZq.css +2 -0
- package/dist/dashboard/assets/index-RnxedkKh.js +11 -0
- package/dist/dashboard/assets/sheet-presentation-U1UUymXc.js +1 -0
- package/dist/dashboard/index.html +13 -0
- package/dist/db/database.js +16 -0
- package/dist/db/migrations.js +184 -0
- package/dist/frontends/discord/approvals.js +199 -0
- package/dist/frontends/discord/attachments.js +115 -0
- package/dist/frontends/discord/binding.js +489 -0
- package/dist/frontends/discord/config.js +107 -0
- package/dist/frontends/discord/discord-runtime.js +52 -0
- package/dist/frontends/discord/errors.js +61 -0
- package/dist/frontends/discord/live-runs.js +189 -0
- package/dist/frontends/discord/module.js +39 -0
- package/dist/frontends/discord/recent-ids.js +20 -0
- package/dist/frontends/slack/approval-blocks.js +98 -0
- package/dist/frontends/slack/attachments.js +102 -0
- package/dist/frontends/slack/background-tasks.js +20 -0
- package/dist/frontends/slack/binding.js +405 -0
- package/dist/frontends/slack/bounded.js +9 -0
- package/dist/frontends/slack/chat-id.js +17 -0
- package/dist/frontends/slack/config.js +80 -0
- package/dist/frontends/slack/delivery-errors.js +81 -0
- package/dist/frontends/slack/inbound.js +76 -0
- package/dist/frontends/slack/live-progress.js +190 -0
- package/dist/frontends/slack/manifest.js +66 -0
- package/dist/frontends/slack/outbound.js +160 -0
- package/dist/frontends/slack/schemas.js +99 -0
- package/dist/frontends/slack/signature.js +30 -0
- package/dist/frontends/slack/slack-client.js +60 -0
- package/dist/frontends/slack/slack-frontend.js +38 -0
- package/dist/frontends/slack/state-store.js +112 -0
- package/dist/frontends/telegram/approvals.js +134 -0
- package/dist/frontends/telegram/attachments.js +126 -0
- package/dist/frontends/telegram/binding.js +144 -0
- package/dist/frontends/telegram/chat-key.js +43 -0
- package/dist/frontends/telegram/client.js +88 -0
- package/dist/frontends/telegram/config.js +93 -0
- package/dist/frontends/telegram/delivery.js +215 -0
- package/dist/frontends/telegram/frontend.js +42 -0
- package/dist/frontends/telegram/grammy-client.js +122 -0
- package/dist/frontends/telegram/http-status.js +6 -0
- package/dist/frontends/telegram/inbound.js +149 -0
- package/dist/frontends/telegram/live.js +182 -0
- package/dist/frontends/telegram/markdown.js +103 -0
- package/dist/frontends/telegram/recent-set.js +18 -0
- package/dist/frontends/telegram/serial-queue.js +23 -0
- package/dist/index.js +7 -0
- package/dist/mcp/content.js +61 -0
- package/dist/mcp/mcp-module.js +35 -0
- package/dist/mcp/mcp-tool-provider.js +93 -0
- package/dist/mcp/server-connection.js +297 -0
- package/dist/memory/consolidation.js +260 -0
- package/dist/memory/format.js +5 -0
- package/dist/memory/migrations.js +76 -0
- package/dist/memory/module.js +69 -0
- package/dist/memory/names.js +20 -0
- package/dist/memory/rows.js +22 -0
- package/dist/memory/rpc.js +49 -0
- package/dist/memory/snapshots.js +12 -0
- package/dist/memory/store.js +281 -0
- package/dist/memory/tools.js +158 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/config.d.ts +252 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/config.js +110 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/domain.d.ts +512 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/domain.js +441 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/duration.d.ts +8 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/duration.js +28 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/events.d.ts +234 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/events.js +124 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/index.d.ts +11 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/index.js +11 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/json-rpc.d.ts +81 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/json-rpc.js +157 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/json.d.ts +14 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/json.js +23 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/limits.d.ts +17 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/limits.js +17 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/methods.d.ts +1107 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/methods.js +201 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/rpc-error.d.ts +45 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/rpc-error.js +44 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/validation.d.ts +20 -0
- package/dist/node_modules/@wheatley-ai/protocol/dist/validation.js +11 -0
- package/dist/node_modules/@wheatley-ai/protocol/package.json +14 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/chunk.d.ts +11 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/chunk.js +162 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/commands.d.ts +48 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/commands.js +39 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/delivery-error.d.ts +29 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/delivery-error.js +27 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/frontend.d.ts +236 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/frontend.js +2 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/index.d.ts +10 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/index.js +7 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/json.d.ts +9 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/json.js +2 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/logger.d.ts +18 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/logger.js +2 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/plugin.d.ts +48 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/plugin.js +5 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/schema.d.ts +69 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/schema.js +3 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/tool.d.ts +69 -0
- package/dist/node_modules/@wheatley-ai/sdk/dist/tool.js +3 -0
- package/dist/node_modules/@wheatley-ai/sdk/package.json +11 -0
- package/dist/ops/backup.js +185 -0
- package/dist/ops/cli.js +195 -0
- package/dist/ops/command-runner.js +34 -0
- package/dist/ops/dashboard-assets.js +37 -0
- package/dist/ops/migrate.js +63 -0
- package/dist/ops/module.js +47 -0
- package/dist/ops/paths.js +55 -0
- package/dist/ops/service.js +376 -0
- package/dist/ops/update.js +145 -0
- package/dist/plugins/contributions.js +89 -0
- package/dist/plugins/guards.js +111 -0
- package/dist/plugins/load.js +76 -0
- package/dist/plugins/module.js +31 -0
- package/dist/plugins/provider.js +349 -0
- package/dist/plugins/schema.js +69 -0
- package/dist/skills/disclosure.js +142 -0
- package/dist/skills/discovery.js +120 -0
- package/dist/skills/fs-errors.js +8 -0
- package/dist/skills/read-skill-tool.js +3 -0
- package/dist/skills/skill-file.js +90 -0
- package/dist/skills/skills.js +140 -0
- package/dist/tools/builtin-tools.js +61 -0
- package/dist/tools/input.js +45 -0
- package/dist/tools/paths.js +6 -0
- package/dist/tools/read-file.js +65 -0
- package/dist/tools/shell.js +156 -0
- package/dist/tools/write-file.js +58 -0
- package/dist/triggers/delivery-codec.js +99 -0
- package/dist/triggers/delivery-outbox.js +313 -0
- package/dist/triggers/due-timer.js +14 -0
- package/dist/triggers/errors.js +2 -0
- package/dist/triggers/migrations.js +91 -0
- package/dist/triggers/module.js +104 -0
- package/dist/triggers/rpc.js +35 -0
- package/dist/triggers/schedule.js +52 -0
- package/dist/triggers/sql-row.js +59 -0
- package/dist/triggers/trigger-runtime.js +445 -0
- package/dist/triggers/trigger-tools.js +207 -0
- package/dist/triggers/webhook-ingress.js +216 -0
- package/dist/wiring/agent-services.js +144 -0
- package/dist/wiring/catalog.js +81 -0
- package/dist/wiring/daemon.js +83 -0
- package/dist/wiring/frontend-host.js +268 -0
- package/package.json +50 -3
- package/README.md +0 -3
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { BackgroundTasks } from "./background-tasks.js";
|
|
2
|
+
import { parseChatId } from "./chat-id.js";
|
|
3
|
+
import { postToChat } from "./slack-client.js";
|
|
4
|
+
/** Slack accepts at most 12,000 characters of `markdown_text` per message. */
|
|
5
|
+
export const MAX_MARKDOWN_LENGTH = 12_000;
|
|
6
|
+
/** How long the binding keeps a finished draft for the final `message` delivery with the same `runId`. */
|
|
7
|
+
const DRAFT_RETENTION_MS = 600_000;
|
|
8
|
+
const ELLIPSIS = "…";
|
|
9
|
+
const truncate = (text) => text.length <= MAX_MARKDOWN_LENGTH
|
|
10
|
+
? text
|
|
11
|
+
: `${text.slice(0, MAX_MARKDOWN_LENGTH - ELLIPSIS.length)}${ELLIPSIS}`;
|
|
12
|
+
/**
|
|
13
|
+
* Shows live Run progress in Slack (ADR 0012): a reaction on the Sender message as the typing indicator, and, in `edit`
|
|
14
|
+
* streaming mode, a draft reply that the binding edits at most once per `editIntervalMs`.
|
|
15
|
+
*
|
|
16
|
+
* Every Slack call is best effort. Failures log at `debug` level and never reach the caller.
|
|
17
|
+
*/
|
|
18
|
+
export class LiveProgress {
|
|
19
|
+
#deps;
|
|
20
|
+
#drafts = new Map();
|
|
21
|
+
#typing = new Map();
|
|
22
|
+
#reactionCalls = new BackgroundTasks();
|
|
23
|
+
constructor(deps) {
|
|
24
|
+
this.#deps = deps;
|
|
25
|
+
}
|
|
26
|
+
/** Handles one Run event. Never throws and never waits for Slack. */
|
|
27
|
+
onEvent = (event) => {
|
|
28
|
+
switch (event.kind) {
|
|
29
|
+
case "run_started": {
|
|
30
|
+
this.#startTyping(event.runId, event.chatId);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
case "text_delta": {
|
|
34
|
+
this.#appendDraft(event.runId, event.chatId, event.delta);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case "run_finished": {
|
|
38
|
+
this.#stopTyping(event.runId);
|
|
39
|
+
this.#finishDraft(event.runId);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case "tool_started":
|
|
43
|
+
case "tool_finished": {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Removes the draft of a Run and returns it, after every pending draft write finished. Returns `undefined` if the Run
|
|
53
|
+
* has no draft. The caller then replaces the draft with the final message.
|
|
54
|
+
*/
|
|
55
|
+
takeDraft = async (runId) => {
|
|
56
|
+
const draft = this.#drafts.get(runId);
|
|
57
|
+
if (draft === undefined) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
this.#drafts.delete(runId);
|
|
61
|
+
clearTimeout(draft.timer);
|
|
62
|
+
clearTimeout(draft.retention);
|
|
63
|
+
await draft.writes;
|
|
64
|
+
return { target: draft.target, ts: draft.ts };
|
|
65
|
+
};
|
|
66
|
+
/** Cancels timers and removes typing reactions. Resolves after pending Slack calls finished. */
|
|
67
|
+
stop = async () => {
|
|
68
|
+
const drafts = [...this.#drafts.values()];
|
|
69
|
+
this.#drafts.clear();
|
|
70
|
+
for (const draft of drafts) {
|
|
71
|
+
clearTimeout(draft.timer);
|
|
72
|
+
clearTimeout(draft.retention);
|
|
73
|
+
}
|
|
74
|
+
for (const runId of this.#typing.keys()) {
|
|
75
|
+
this.#stopTyping(runId);
|
|
76
|
+
}
|
|
77
|
+
await Promise.all([
|
|
78
|
+
...drafts.map(async (draft) => {
|
|
79
|
+
await draft.writes;
|
|
80
|
+
}),
|
|
81
|
+
this.#reactionCalls.settled(),
|
|
82
|
+
]);
|
|
83
|
+
};
|
|
84
|
+
#startTyping = (runId, chatId) => {
|
|
85
|
+
const message = this.#deps.lastInbound(chatId);
|
|
86
|
+
if (message !== undefined) {
|
|
87
|
+
this.#typing.set(runId, message);
|
|
88
|
+
this.#reactionCalls.add(this.#react("add", message));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
#stopTyping = (runId) => {
|
|
92
|
+
const message = this.#typing.get(runId);
|
|
93
|
+
if (message !== undefined) {
|
|
94
|
+
this.#typing.delete(runId);
|
|
95
|
+
this.#reactionCalls.add(this.#react("remove", message));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/** Adds or removes the typing reaction. Never rejects. */
|
|
99
|
+
#react = async (action, message) => {
|
|
100
|
+
const args = {
|
|
101
|
+
channel: message.channel,
|
|
102
|
+
name: this.#deps.typingReaction,
|
|
103
|
+
timestamp: message.ts,
|
|
104
|
+
};
|
|
105
|
+
try {
|
|
106
|
+
await (action === "add"
|
|
107
|
+
? this.#deps.client.reactions.add(args)
|
|
108
|
+
: this.#deps.client.reactions.remove(args));
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
this.#deps.log.debug(`Could not ${action} the typing reaction`, {
|
|
112
|
+
error: String(error),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
#appendDraft = (runId, chatId, delta) => {
|
|
117
|
+
if (this.#deps.streaming !== "edit") {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const draft = this.#drafts.get(runId) ?? {
|
|
121
|
+
lastSentAt: 0,
|
|
122
|
+
retention: undefined,
|
|
123
|
+
sentText: "",
|
|
124
|
+
target: parseChatId(chatId),
|
|
125
|
+
text: "",
|
|
126
|
+
timer: undefined,
|
|
127
|
+
ts: undefined,
|
|
128
|
+
writes: Promise.resolve(),
|
|
129
|
+
};
|
|
130
|
+
this.#drafts.set(runId, draft);
|
|
131
|
+
draft.text += delta;
|
|
132
|
+
this.#schedule(draft);
|
|
133
|
+
};
|
|
134
|
+
/** Flushes at once if the last edit is `editIntervalMs` old, else when it is. Later deltas join that flush. */
|
|
135
|
+
#schedule = (draft) => {
|
|
136
|
+
if (draft.timer !== undefined) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const delay = Math.max(0, draft.lastSentAt + this.#deps.editIntervalMs - Date.now());
|
|
140
|
+
draft.timer = setTimeout(() => {
|
|
141
|
+
draft.timer = undefined;
|
|
142
|
+
this.#flush(draft);
|
|
143
|
+
}, delay);
|
|
144
|
+
};
|
|
145
|
+
#flush = (draft) => {
|
|
146
|
+
const { text } = draft;
|
|
147
|
+
if (text === draft.sentText || text.trim() === "") {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
draft.sentText = text;
|
|
151
|
+
draft.lastSentAt = Date.now();
|
|
152
|
+
draft.writes = this.#writeAfter(draft.writes, draft, truncate(text));
|
|
153
|
+
};
|
|
154
|
+
/** Posts the draft, or edits it once it exists. Writes of one draft run one at a time. Never rejects. */
|
|
155
|
+
#writeAfter = async (previous, draft, text) => {
|
|
156
|
+
await previous;
|
|
157
|
+
try {
|
|
158
|
+
if (draft.ts === undefined) {
|
|
159
|
+
draft.ts = await postToChat(this.#deps.client, draft.target, {
|
|
160
|
+
markdown_text: text,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
await this.#deps.client.chat.update({
|
|
165
|
+
channel: draft.target.channel,
|
|
166
|
+
markdown_text: text,
|
|
167
|
+
ts: draft.ts,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
this.#deps.log.debug("Could not update the draft reply", {
|
|
173
|
+
error: String(error),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
/** Keeps the draft for the final `message` delivery. A pending flush still sends the last text. */
|
|
178
|
+
#finishDraft = (runId) => {
|
|
179
|
+
const draft = this.#drafts.get(runId);
|
|
180
|
+
if (draft === undefined) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
draft.retention = setTimeout(() => {
|
|
184
|
+
if (this.#drafts.get(runId) === draft) {
|
|
185
|
+
this.#drafts.delete(runId);
|
|
186
|
+
}
|
|
187
|
+
}, DRAFT_RETENTION_MS);
|
|
188
|
+
draft.retention.unref();
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BUILTIN_COMMANDS } from "@wheatley-ai/sdk";
|
|
2
|
+
/** The webhook path suffix of a binding in `webhook` transport. Events, commands, and interactions share it. */
|
|
3
|
+
export const WEBHOOK_PATH_SUFFIX = "events";
|
|
4
|
+
/** Slack limits a bot display name to 80 characters. */
|
|
5
|
+
const MAX_DISPLAY_NAME_LENGTH = 80;
|
|
6
|
+
/** The bot scopes that the binding uses. */
|
|
7
|
+
export const SLACK_BOT_SCOPES = [
|
|
8
|
+
"channels:history",
|
|
9
|
+
"chat:write",
|
|
10
|
+
"commands",
|
|
11
|
+
"files:read",
|
|
12
|
+
"files:write",
|
|
13
|
+
"groups:history",
|
|
14
|
+
"im:history",
|
|
15
|
+
"mpim:history",
|
|
16
|
+
"reactions:write",
|
|
17
|
+
"users:read",
|
|
18
|
+
];
|
|
19
|
+
/** The message events that the binding subscribes to. */
|
|
20
|
+
export const SLACK_BOT_EVENTS = [
|
|
21
|
+
"message.channels",
|
|
22
|
+
"message.groups",
|
|
23
|
+
"message.im",
|
|
24
|
+
"message.mpim",
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Builds the Slack App manifest for a binding. The Operator pastes it at api.slack.com/apps, because Slack has no
|
|
28
|
+
* bot-token API to register Slash Commands.
|
|
29
|
+
*
|
|
30
|
+
* The manifest declares every built-in command as a native Slash Command, the message events, the Approval button
|
|
31
|
+
* interactivity, and the bot scopes. In `webhook` transport, events, commands, and interactions use `requestUrl`. In
|
|
32
|
+
* `socket` transport, the URL fields are `undefined`, and `JSON.stringify` omits them.
|
|
33
|
+
*/
|
|
34
|
+
export const createSlackAppManifest = (options) => {
|
|
35
|
+
const commands = options.commands ?? BUILTIN_COMMANDS;
|
|
36
|
+
const requestUrl = options.transport === "webhook" ? options.requestUrl : undefined;
|
|
37
|
+
const name = options.appName.slice(0, MAX_DISPLAY_NAME_LENGTH);
|
|
38
|
+
return {
|
|
39
|
+
display_information: { name },
|
|
40
|
+
features: {
|
|
41
|
+
app_home: {
|
|
42
|
+
messages_tab_enabled: true,
|
|
43
|
+
messages_tab_read_only_enabled: false,
|
|
44
|
+
},
|
|
45
|
+
bot_user: { always_online: true, display_name: name },
|
|
46
|
+
slash_commands: commands.map((command) => ({
|
|
47
|
+
command: `/${command.name}`,
|
|
48
|
+
description: command.description,
|
|
49
|
+
should_escape: false,
|
|
50
|
+
usage_hint: command.argument,
|
|
51
|
+
url: requestUrl,
|
|
52
|
+
})),
|
|
53
|
+
},
|
|
54
|
+
oauth_config: { scopes: { bot: SLACK_BOT_SCOPES } },
|
|
55
|
+
settings: {
|
|
56
|
+
event_subscriptions: {
|
|
57
|
+
bot_events: SLACK_BOT_EVENTS,
|
|
58
|
+
request_url: requestUrl,
|
|
59
|
+
},
|
|
60
|
+
interactivity: { is_enabled: true, request_url: requestUrl },
|
|
61
|
+
org_deploy_enabled: false,
|
|
62
|
+
socket_mode_enabled: options.transport === "socket",
|
|
63
|
+
token_rotation_enabled: false,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { chunkMarkdown } from "@wheatley-ai/sdk";
|
|
2
|
+
import { approvalOutcomeText, approvalRequestBlocks, approvalRequestText, approvalResolvedBlocks, approvalResolvedText, } from "./approval-blocks.js";
|
|
3
|
+
import { assertAttachmentSizes, uploadAttachment } from "./attachments.js";
|
|
4
|
+
import { dropOldest } from "./bounded.js";
|
|
5
|
+
import { parseChatId } from "./chat-id.js";
|
|
6
|
+
import { MAX_MARKDOWN_LENGTH } from "./live-progress.js";
|
|
7
|
+
import { postToChat } from "./slack-client.js";
|
|
8
|
+
/** The number of delivered outbox IDs that the binding remembers to drop duplicate deliveries. */
|
|
9
|
+
const MAX_DELIVERED_MESSAGES = 1000;
|
|
10
|
+
const postChunk = async (web, target, chunk, replaceTs) => {
|
|
11
|
+
if (replaceTs === undefined) {
|
|
12
|
+
await postToChat(web, target, { markdown_text: chunk });
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
await web.chat.update({
|
|
16
|
+
channel: target.channel,
|
|
17
|
+
markdown_text: chunk,
|
|
18
|
+
ts: replaceTs,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
/** Posts the Block Kit prompt once per `approvalId`, and stores its message for the update on resolve. */
|
|
22
|
+
const deliverApprovalRequested = async (deps, delivery) => {
|
|
23
|
+
if (deps.store.approval(delivery.approvalId) !== undefined) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const target = parseChatId(delivery.chatId);
|
|
27
|
+
const ts = await postToChat(deps.web, target, {
|
|
28
|
+
blocks: approvalRequestBlocks(delivery),
|
|
29
|
+
text: approvalRequestText(delivery),
|
|
30
|
+
});
|
|
31
|
+
if (ts === undefined) {
|
|
32
|
+
throw new Error("Slack chat.postMessage returned no message ts");
|
|
33
|
+
}
|
|
34
|
+
await deps.store.putApproval(delivery.approvalId, {
|
|
35
|
+
channel: target.channel,
|
|
36
|
+
chatId: delivery.chatId,
|
|
37
|
+
inputPreview: delivery.inputPreview,
|
|
38
|
+
resolved: false,
|
|
39
|
+
toolName: delivery.toolName,
|
|
40
|
+
ts,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Replaces the prompt with the outcome and removes its buttons. If the binding has no record of the prompt, it posts
|
|
45
|
+
* the outcome as a new message. A repeated delivery after success does nothing.
|
|
46
|
+
*/
|
|
47
|
+
const deliverApprovalResolved = async (deps, delivery) => {
|
|
48
|
+
const record = deps.store.approval(delivery.approvalId);
|
|
49
|
+
if (record?.resolved === true) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (record !== undefined) {
|
|
53
|
+
await deps.web.chat.update({
|
|
54
|
+
blocks: approvalResolvedBlocks(record, delivery),
|
|
55
|
+
channel: record.channel,
|
|
56
|
+
text: approvalResolvedText(record, delivery),
|
|
57
|
+
ts: record.ts,
|
|
58
|
+
});
|
|
59
|
+
await deps.store.putApproval(delivery.approvalId, {
|
|
60
|
+
...record,
|
|
61
|
+
resolved: true,
|
|
62
|
+
});
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const target = parseChatId(delivery.chatId);
|
|
66
|
+
const ts = await postToChat(deps.web, target, {
|
|
67
|
+
text: approvalOutcomeText(delivery),
|
|
68
|
+
});
|
|
69
|
+
if (ts !== undefined) {
|
|
70
|
+
await deps.store.putApproval(delivery.approvalId, {
|
|
71
|
+
channel: target.channel,
|
|
72
|
+
chatId: delivery.chatId,
|
|
73
|
+
inputPreview: "",
|
|
74
|
+
resolved: true,
|
|
75
|
+
toolName: "",
|
|
76
|
+
ts,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/** Delivers durable outbound work to Slack. Keeps the per-message progress that makes retries safe. */
|
|
81
|
+
export class SlackOutbound {
|
|
82
|
+
#deps;
|
|
83
|
+
#delivered = new Set();
|
|
84
|
+
#progress = new Map();
|
|
85
|
+
constructor(deps) {
|
|
86
|
+
this.#deps = deps;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Delivers one item. Rejects with the raw Slack error, which the binding converts with `toDeliveryError`. After
|
|
90
|
+
* a thread delivery, replies in that thread need no bot mention.
|
|
91
|
+
*/
|
|
92
|
+
deliver = async (delivery) => {
|
|
93
|
+
switch (delivery.kind) {
|
|
94
|
+
case "message": {
|
|
95
|
+
await this.#deliverMessage(delivery);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case "approval_requested": {
|
|
99
|
+
await deliverApprovalRequested(this.#deps, delivery);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case "approval_resolved": {
|
|
103
|
+
await deliverApprovalResolved(this.#deps, delivery);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
default: {
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (parseChatId(delivery.chatId).threadTs !== undefined) {
|
|
111
|
+
await this.#deps.store.engage(delivery.chatId);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Posts the Markdown chunks, then uploads the attachments. If the message finishes a streamed Run, the first chunk
|
|
116
|
+
* replaces the draft reply. A retry resumes after the last part that Slack confirmed, and a repeated `messageId`
|
|
117
|
+
* after success does nothing.
|
|
118
|
+
*/
|
|
119
|
+
#deliverMessage = async (delivery) => {
|
|
120
|
+
if (this.#delivered.has(delivery.messageId)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const { web } = this.#deps;
|
|
124
|
+
const attachments = delivery.attachments ?? [];
|
|
125
|
+
assertAttachmentSizes(attachments, this.#deps.maxAttachmentBytes);
|
|
126
|
+
const target = parseChatId(delivery.chatId);
|
|
127
|
+
const chunks = delivery.text.trim() === ""
|
|
128
|
+
? []
|
|
129
|
+
: chunkMarkdown(delivery.text, MAX_MARKDOWN_LENGTH);
|
|
130
|
+
const progress = await this.#messageProgress(delivery);
|
|
131
|
+
const steps = [
|
|
132
|
+
...chunks.map((chunk, index) => async () => {
|
|
133
|
+
await postChunk(web, target, chunk, index === 0 ? progress.draftTs : undefined);
|
|
134
|
+
}),
|
|
135
|
+
...attachments.map((attachment) => async () => {
|
|
136
|
+
await uploadAttachment(web, target, attachment);
|
|
137
|
+
}),
|
|
138
|
+
];
|
|
139
|
+
for (const step of steps.slice(progress.done)) {
|
|
140
|
+
// oxlint-disable-next-line no-await-in-loop -- Slack must show chunks and files in order.
|
|
141
|
+
await step();
|
|
142
|
+
progress.done += 1;
|
|
143
|
+
}
|
|
144
|
+
this.#progress.delete(delivery.messageId);
|
|
145
|
+
this.#delivered.add(delivery.messageId);
|
|
146
|
+
dropOldest(this.#delivered, MAX_DELIVERED_MESSAGES);
|
|
147
|
+
};
|
|
148
|
+
#messageProgress = async (delivery) => {
|
|
149
|
+
const existing = this.#progress.get(delivery.messageId);
|
|
150
|
+
if (existing !== undefined) {
|
|
151
|
+
return existing;
|
|
152
|
+
}
|
|
153
|
+
const draft = delivery.runId === undefined
|
|
154
|
+
? undefined
|
|
155
|
+
: await this.#deps.live.takeDraft(delivery.runId);
|
|
156
|
+
const progress = { done: 0, draftTs: draft?.ts };
|
|
157
|
+
this.#progress.set(delivery.messageId, progress);
|
|
158
|
+
return progress;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { decode, isJsonValue } from "@wheatley-ai/protocol";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
const NonEmpty = Type.String({ minLength: 1 });
|
|
4
|
+
const isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
/** Converts a TypeBox schema into the plain JSON Schema document that `@wheatley-ai/sdk` accepts. */
|
|
6
|
+
export const toJsonSchema = (schema) => {
|
|
7
|
+
// TypeBox keeps its metadata in non-enumerable properties, which the clone drops.
|
|
8
|
+
const document = structuredClone(schema);
|
|
9
|
+
if (!isJsonValue(document) || !isJsonObject(document)) {
|
|
10
|
+
throw new TypeError("A TypeBox schema must serialize to a JSON object");
|
|
11
|
+
}
|
|
12
|
+
return document;
|
|
13
|
+
};
|
|
14
|
+
/** Parses JSON text. Returns `undefined` for invalid JSON. */
|
|
15
|
+
export const parseJsonText = (text) => {
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse(text);
|
|
18
|
+
return isJsonValue(parsed) ? parsed : undefined;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/** Decodes `value` against `schema`. Returns `undefined` if the value does not match. */
|
|
25
|
+
export const decodeOptional = (schema, value) => {
|
|
26
|
+
if (value === undefined) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const decoded = decode(schema, value);
|
|
30
|
+
return decoded.ok ? decoded.value : undefined;
|
|
31
|
+
};
|
|
32
|
+
/** A file of a Slack message event. */
|
|
33
|
+
export const SlackFileSchema = Type.Object({
|
|
34
|
+
id: NonEmpty,
|
|
35
|
+
mimetype: Type.Optional(Type.String()),
|
|
36
|
+
name: Type.Optional(Type.String()),
|
|
37
|
+
size: Type.Optional(Type.Number()),
|
|
38
|
+
url_private_download: Type.Optional(NonEmpty),
|
|
39
|
+
});
|
|
40
|
+
/** A `message` event from a user, inside an Events API `event_callback` payload. */
|
|
41
|
+
export const MessageEventCallbackSchema = Type.Object({
|
|
42
|
+
event: Type.Object({
|
|
43
|
+
bot_id: Type.Optional(Type.String()),
|
|
44
|
+
channel: NonEmpty,
|
|
45
|
+
channel_type: Type.Optional(Type.String()),
|
|
46
|
+
files: Type.Optional(Type.Array(SlackFileSchema)),
|
|
47
|
+
parent_user_id: Type.Optional(Type.String()),
|
|
48
|
+
subtype: Type.Optional(Type.String()),
|
|
49
|
+
text: Type.Optional(Type.String()),
|
|
50
|
+
thread_ts: Type.Optional(NonEmpty),
|
|
51
|
+
ts: NonEmpty,
|
|
52
|
+
type: Type.Literal("message"),
|
|
53
|
+
user: NonEmpty,
|
|
54
|
+
}),
|
|
55
|
+
event_id: Type.Optional(NonEmpty),
|
|
56
|
+
});
|
|
57
|
+
/** The Events API handshake when the Operator sets the request URL. */
|
|
58
|
+
export const UrlVerificationSchema = Type.Object({
|
|
59
|
+
challenge: NonEmpty,
|
|
60
|
+
type: Type.Literal("url_verification"),
|
|
61
|
+
});
|
|
62
|
+
/** A Slash Command payload from Socket Mode, or the form fields of a webhook request. */
|
|
63
|
+
export const SlashCommandSchema = Type.Object({
|
|
64
|
+
channel_id: NonEmpty,
|
|
65
|
+
command: NonEmpty,
|
|
66
|
+
text: Type.Optional(Type.String()),
|
|
67
|
+
user_id: NonEmpty,
|
|
68
|
+
user_name: Type.Optional(Type.String()),
|
|
69
|
+
});
|
|
70
|
+
/** A `block_actions` interactivity payload. */
|
|
71
|
+
export const BlockActionsSchema = Type.Object({
|
|
72
|
+
actions: Type.Array(Type.Object({ action_id: NonEmpty, value: Type.Optional(NonEmpty) }), { minItems: 1 }),
|
|
73
|
+
channel: Type.Optional(Type.Object({ id: NonEmpty })),
|
|
74
|
+
container: Type.Optional(Type.Object({ channel_id: Type.Optional(NonEmpty) })),
|
|
75
|
+
message: Type.Optional(Type.Object({
|
|
76
|
+
thread_ts: Type.Optional(NonEmpty),
|
|
77
|
+
ts: Type.Optional(NonEmpty),
|
|
78
|
+
})),
|
|
79
|
+
type: Type.Literal("block_actions"),
|
|
80
|
+
user: Type.Object({
|
|
81
|
+
id: NonEmpty,
|
|
82
|
+
name: Type.Optional(Type.String()),
|
|
83
|
+
username: Type.Optional(Type.String()),
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
/** The Slack message that shows one Approval prompt. */
|
|
87
|
+
export const ApprovalRecordSchema = Type.Object({
|
|
88
|
+
channel: NonEmpty,
|
|
89
|
+
chatId: NonEmpty,
|
|
90
|
+
inputPreview: Type.String(),
|
|
91
|
+
resolved: Type.Boolean(),
|
|
92
|
+
toolName: Type.String(),
|
|
93
|
+
ts: NonEmpty,
|
|
94
|
+
});
|
|
95
|
+
/** The state file of one binding. */
|
|
96
|
+
export const StateFileSchema = Type.Object({
|
|
97
|
+
approvals: Type.Record(Type.String(), ApprovalRecordSchema),
|
|
98
|
+
threads: Type.Array(Type.String()),
|
|
99
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
2
|
+
/** Slack rejects replays older than five minutes, and so does the binding. */
|
|
3
|
+
export const SIGNATURE_MAX_AGE_SECONDS = 300;
|
|
4
|
+
const MS_PER_SECOND = 1000;
|
|
5
|
+
const TIMESTAMP = /^\d+$/u;
|
|
6
|
+
/**
|
|
7
|
+
* Verifies the `x-slack-signature` HMAC-SHA256 signature and the `x-slack-request-timestamp` age of a Slack request.
|
|
8
|
+
*
|
|
9
|
+
* Returns false for a missing header, a timestamp more than `SIGNATURE_MAX_AGE_SECONDS` away from `nowMs`, or a wrong
|
|
10
|
+
* signature. Compares signatures in constant time.
|
|
11
|
+
*/
|
|
12
|
+
export const verifySlackSignature = (request, signingSecret, nowMs) => {
|
|
13
|
+
const timestamp = request.headers["x-slack-request-timestamp"];
|
|
14
|
+
const signature = request.headers["x-slack-signature"];
|
|
15
|
+
if (timestamp === undefined ||
|
|
16
|
+
signature === undefined ||
|
|
17
|
+
!TIMESTAMP.test(timestamp)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const ageSeconds = Math.abs(nowMs / MS_PER_SECOND - Number(timestamp));
|
|
21
|
+
if (ageSeconds > SIGNATURE_MAX_AGE_SECONDS) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const expected = Buffer.from(`v0=${createHmac("sha256", signingSecret)
|
|
25
|
+
.update(`v0:${timestamp}:`)
|
|
26
|
+
.update(request.body)
|
|
27
|
+
.digest("hex")}`);
|
|
28
|
+
const given = Buffer.from(signature);
|
|
29
|
+
return given.length === expected.length && timingSafeEqual(given, expected);
|
|
30
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** The binding gets no automatic retries from the Slack client, because the Agent outbox retries deliveries. */
|
|
2
|
+
const WEB_CLIENT_RETRIES = 0;
|
|
3
|
+
const toText = (parts) => parts.join(" ");
|
|
4
|
+
/**
|
|
5
|
+
* Forwards Slack client logs to the binding logger. Slack `info` logs report routine reconnects, so they go to
|
|
6
|
+
* `debug`.
|
|
7
|
+
*/
|
|
8
|
+
const createSlackLogger = (log, initialLevel) => {
|
|
9
|
+
let level = initialLevel;
|
|
10
|
+
let prefix = "";
|
|
11
|
+
const format = (parts) => `${prefix}${toText(parts)}`;
|
|
12
|
+
return {
|
|
13
|
+
debug: (...parts) => {
|
|
14
|
+
log.debug(format(parts));
|
|
15
|
+
},
|
|
16
|
+
error: (...parts) => {
|
|
17
|
+
log.error(format(parts));
|
|
18
|
+
},
|
|
19
|
+
getLevel: () => level,
|
|
20
|
+
info: (...parts) => {
|
|
21
|
+
log.debug(format(parts));
|
|
22
|
+
},
|
|
23
|
+
setLevel: (next) => {
|
|
24
|
+
level = next;
|
|
25
|
+
},
|
|
26
|
+
setName: (name) => {
|
|
27
|
+
prefix = `${name}: `;
|
|
28
|
+
},
|
|
29
|
+
warn: (...parts) => {
|
|
30
|
+
log.warn(format(parts));
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/** Loads `@slack/web-api` and `@slack/socket-mode` with dynamic imports, so Agents without Slack never load them. */
|
|
35
|
+
export const loadSlackSdk = async () => {
|
|
36
|
+
const [webApi, socketMode] = await Promise.all([
|
|
37
|
+
import("@slack/web-api"),
|
|
38
|
+
import("@slack/socket-mode"),
|
|
39
|
+
]);
|
|
40
|
+
return {
|
|
41
|
+
createSocketClient: (appToken, log) => new socketMode.SocketModeClient({
|
|
42
|
+
appToken,
|
|
43
|
+
logger: createSlackLogger(log, webApi.LogLevel.INFO),
|
|
44
|
+
}),
|
|
45
|
+
createWebClient: (botToken, log) => new webApi.WebClient(botToken, {
|
|
46
|
+
logger: createSlackLogger(log, webApi.LogLevel.INFO),
|
|
47
|
+
rejectRateLimitedCalls: true,
|
|
48
|
+
retryConfig: { retries: WEB_CLIENT_RETRIES },
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/** Posts a message into a Chat, in its thread if the Chat is a thread. Returns the message `ts`. */
|
|
53
|
+
export const postToChat = async (client, target, content) => {
|
|
54
|
+
const args = target.threadTs === undefined
|
|
55
|
+
? { channel: target.channel, ...content }
|
|
56
|
+
: { channel: target.channel, thread_ts: target.threadTs, ...content };
|
|
57
|
+
// oxlint-disable-next-line unicorn/require-post-message-target-origin -- This is Slack chat.postMessage, not window.postMessage.
|
|
58
|
+
const posted = await client.chat.postMessage(args);
|
|
59
|
+
return posted.ts;
|
|
60
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SlackBinding } from "./binding.js";
|
|
2
|
+
import { parseSlackConfig, SLACK_CONFIG_SCHEMA } from "./config.js";
|
|
3
|
+
import { loadSlackSdk } from "./slack-client.js";
|
|
4
|
+
/** The `type` of Slack entries in `frontends` of `config.yaml`. */
|
|
5
|
+
export const SLACK_FRONTEND_TYPE = "slack";
|
|
6
|
+
const defaultFetch = async (url, init) => await fetch(url, { headers: init.headers });
|
|
7
|
+
/**
|
|
8
|
+
* Creates the built-in Slack Frontend (ADR 0007, ADR 0012).
|
|
9
|
+
*
|
|
10
|
+
* `createBinding` validates the config and resolves its secrets. It throws for an empty `allowedChatIds`, a missing
|
|
11
|
+
* secret, or `webhook` transport while the Webhook Ingress is disabled. It loads no Slack package: `start` does that.
|
|
12
|
+
*/
|
|
13
|
+
export const createSlackFrontend = (options = {}) => {
|
|
14
|
+
const deps = {
|
|
15
|
+
fetch: options.fetch ?? defaultFetch,
|
|
16
|
+
loadSdk: options.loadSdk ?? loadSlackSdk,
|
|
17
|
+
now: options.now ?? Date.now,
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
configSchema: SLACK_CONFIG_SCHEMA,
|
|
21
|
+
createBinding: (config, ctx) => new SlackBinding(parseSlackConfig(config, ctx.secrets), ctx, deps),
|
|
22
|
+
type: SLACK_FRONTEND_TYPE,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/** The Slack Frontend keeps its state in `FrontendContext.dataDir` and has no `agent.sqlite` tables. */
|
|
26
|
+
export const slackMigrations = [];
|
|
27
|
+
/** The Slack Frontend serves no JSON-RPC methods. */
|
|
28
|
+
export const slackRpcHandlers = {};
|
|
29
|
+
/**
|
|
30
|
+
* The Agent module of the Slack Frontend. Its `api` is the `Frontend` of the `slack` type, for
|
|
31
|
+
* `AgentExtensions.frontends`.
|
|
32
|
+
*/
|
|
33
|
+
export const slackFrontendModule = {
|
|
34
|
+
create: () => ({ api: createSlackFrontend(), rpc: slackRpcHandlers }),
|
|
35
|
+
migrations: slackMigrations,
|
|
36
|
+
name: "frontend_slack",
|
|
37
|
+
scope: "agent",
|
|
38
|
+
};
|