@cursor/july 0.1.7 → 0.1.9
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/bin/agent-serve.js +31 -2
- package/dist/channels/slack/channel-watch.d.ts +6 -1
- package/dist/channels/slack/channel-watch.d.ts.map +1 -1
- package/dist/channels/slack/channel-watch.js +22 -1
- package/dist/channels/slack/cursor-account.d.ts +4 -0
- package/dist/channels/slack/cursor-account.d.ts.map +1 -1
- package/dist/channels/slack/cursor-account.js +12 -2
- package/dist/channels/slack/defaults.d.ts +10 -5
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +39 -17
- package/dist/channels/slack/dispatch.d.ts +18 -0
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +141 -38
- package/dist/channels/slack/inbound.d.ts +13 -3
- package/dist/channels/slack/inbound.d.ts.map +1 -1
- package/dist/channels/slack/inbound.js +17 -9
- package/dist/channels/slack/index.d.ts +4 -0
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +4 -0
- package/dist/channels/slack/live-delivery.d.ts.map +1 -1
- package/dist/channels/slack/live-delivery.js +1 -0
- package/dist/channels/slack/manifest.d.ts.map +1 -1
- package/dist/channels/slack/manifest.js +3 -0
- package/dist/channels/slack/nudge-carrier.d.ts +19 -0
- package/dist/channels/slack/nudge-carrier.d.ts.map +1 -0
- package/dist/channels/slack/nudge-carrier.js +166 -0
- package/dist/channels/slack/nudge-store.d.ts +61 -0
- package/dist/channels/slack/nudge-store.d.ts.map +1 -0
- package/dist/channels/slack/nudge-store.js +266 -0
- package/dist/channels/slack/post-update-delivery.js +318 -0
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +74 -25
- package/dist/channels/slack/stop.d.ts +14 -0
- package/dist/channels/slack/stop.d.ts.map +1 -0
- package/dist/channels/slack/stop.js +22 -0
- package/dist/channels/slack/thread-context.d.ts +81 -0
- package/dist/channels/slack/thread-context.d.ts.map +1 -0
- package/dist/channels/slack/thread-context.js +470 -0
- package/dist/channels/slack/types.d.ts +27 -0
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +4 -4
- package/dist/docs/assets/{app.COTN7wgo.js → app.Ciosf24M.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.D154Detj.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.BW3TBdT0.js → VPLocalSearchBox.BcRDly7n.js} +1 -1
- package/dist/docs/assets/chunks/{theme.BEJW0vE7.js → theme.CMpbjdfx.js} +2 -2
- package/dist/docs/assets/{deployment.md.BtfEsc9S.js → deployment.md.DC5-ImcM.js} +1 -1
- package/dist/docs/assets/{example-agents_approval-buddy.md.8R5phXb5.js → example-agents_approval-buddy.md.DFGBYLcc.js} +2 -2
- package/dist/docs/assets/{example-agents_approval-buddy.md.8R5phXb5.lean.js → example-agents_approval-buddy.md.DFGBYLcc.lean.js} +1 -1
- package/dist/docs/assets/example-agents_index.md.BPXjUtRB.js +2 -0
- package/dist/docs/assets/example-agents_index.md.BPXjUtRB.lean.js +1 -0
- package/dist/docs/assets/example-agents_oncall.md.BG_sUMly.js +10 -0
- package/dist/docs/assets/example-agents_oncall.md.BG_sUMly.lean.js +1 -0
- package/dist/docs/assets/{example-agents_security-reviewer.md.D2rtwDTO.js → example-agents_security-reviewer.md.CE9v-aKm.js} +2 -2
- package/dist/docs/assets/{example-agents_security-reviewer.md.D2rtwDTO.lean.js → example-agents_security-reviewer.md.CE9v-aKm.lean.js} +1 -1
- package/dist/docs/assets/{guides_slack.md.CCwqHvSV.js → guides_slack.md.FWale6Ip.js} +4 -3
- package/dist/docs/assets/{guides_slack.md.CCwqHvSV.lean.js → guides_slack.md.FWale6Ip.lean.js} +1 -1
- package/dist/docs/assets/{reference_sessions.md.DdjWabnN.js → reference_sessions.md.DLd6mvbv.js} +2 -2
- package/dist/docs/assets/{reference_sessions.md.DdjWabnN.lean.js → reference_sessions.md.DLd6mvbv.lean.js} +1 -1
- package/dist/docs/assets/{storage.md.CVnInNiN.js → storage.md.DRTdnFvd.js} +9 -2
- package/dist/docs/assets/{storage.md.CVnInNiN.lean.js → storage.md.DRTdnFvd.lean.js} +1 -1
- package/dist/docs/building-with-agents.html +4 -4
- package/dist/docs/concepts.html +4 -4
- package/dist/docs/deployment.html +6 -6
- package/dist/docs/evals.html +4 -4
- package/dist/docs/example-agents/approval-buddy.html +5 -5
- package/dist/docs/example-agents/benny.html +5 -5
- package/dist/docs/example-agents/bugbot.html +5 -5
- package/dist/docs/example-agents/codebase-wiki.html +4 -4
- package/dist/docs/example-agents/codeowners-review.html +4 -4
- package/dist/docs/example-agents/concierge.html +4 -4
- package/dist/docs/example-agents/fsd.html +4 -4
- package/dist/docs/example-agents/index.html +6 -6
- package/dist/docs/example-agents/knowledge-base.html +4 -4
- package/dist/docs/example-agents/oncall.html +34 -0
- package/dist/docs/example-agents/security-reviewer.html +6 -6
- package/dist/docs/example-agents/slack-agent.html +4 -4
- package/dist/docs/example-agents/weather-agent.html +4 -4
- package/dist/docs/guides/agent-to-agent.html +4 -4
- package/dist/docs/guides/cloud-runtime.html +4 -4
- package/dist/docs/guides/github.html +4 -4
- package/dist/docs/guides/human-in-the-loop.html +4 -4
- package/dist/docs/guides/slack.html +7 -6
- package/dist/docs/guides/webhooks.html +4 -4
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +4 -4
- package/dist/docs/index.html +4 -4
- package/dist/docs/quickstart.html +4 -4
- package/dist/docs/reference/agent-config.html +4 -4
- package/dist/docs/reference/channels.html +4 -4
- package/dist/docs/reference/cli.html +4 -4
- package/dist/docs/reference/connections.html +4 -4
- package/dist/docs/reference/hooks.html +4 -4
- package/dist/docs/reference/http-api.html +4 -4
- package/dist/docs/reference/instructions.html +4 -4
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +4 -4
- package/dist/docs/reference/schedules.html +4 -4
- package/dist/docs/reference/sessions.html +5 -5
- package/dist/docs/reference/skills.html +4 -4
- package/dist/docs/reference/subagents.html +4 -4
- package/dist/docs/reference/tools.html +4 -4
- package/dist/docs/scaffolding-agents.html +4 -4
- package/dist/docs/storage.html +13 -6
- package/dist/docs/troubleshooting.html +4 -4
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +45 -18
- package/dist/internal/cli-mcp.d.ts +64 -0
- package/dist/internal/cli-mcp.d.ts.map +1 -0
- package/dist/internal/cli-mcp.js +570 -0
- package/dist/internal/deploy-client.d.ts +7 -1
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +3 -0
- package/dist/internal/deploy-source.d.ts +3 -0
- package/dist/internal/deploy-source.d.ts.map +1 -1
- package/dist/internal/deploy-source.js +25 -7
- package/dist/internal/discovery.js +1 -1
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +3 -0
- package/dist/internal/host-kv.d.ts +17 -0
- package/dist/internal/host-kv.d.ts.map +1 -0
- package/dist/internal/host-kv.js +77 -0
- package/dist/internal/hosting.d.ts +12 -2
- package/dist/internal/hosting.d.ts.map +1 -1
- package/dist/internal/hosting.js +21 -4
- package/dist/internal/json-dir-store.js +100 -0
- package/dist/internal/logs-client.d.ts +16 -2
- package/dist/internal/logs-client.d.ts.map +1 -1
- package/dist/internal/logs-client.js +51 -16
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +8 -0
- package/dist/internal/session-engine.d.ts +42 -7
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +276 -66
- package/dist/internal/storage-coordinator.d.ts +18 -1
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +43 -0
- package/dist/internal/workspace.d.ts +19 -0
- package/dist/internal/workspace.d.ts.map +1 -1
- package/dist/internal/workspace.js +47 -13
- package/dist/playground/assets/{index-72vCOBWO.js → index-C0-QEG4O.js} +42 -42
- package/dist/playground/assets/index-z3JY9O2x.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage-backends/cursor-hosted.d.ts +65 -0
- package/dist/storage-backends/cursor-hosted.d.ts.map +1 -0
- package/dist/storage-backends/cursor-hosted.js +203 -0
- package/dist/storage-backends/file-kv.d.ts +42 -0
- package/dist/storage-backends/file-kv.d.ts.map +1 -0
- package/dist/storage-backends/file-kv.js +190 -0
- package/dist/storage-backends/postgres-kv.d.ts +82 -0
- package/dist/storage-backends/postgres-kv.d.ts.map +1 -0
- package/dist/storage-backends/postgres-kv.js +185 -0
- package/dist/storage.d.ts +10 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +10 -1
- package/dist/types.d.ts +79 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/.vitepress/cache/deps/package.json +3 -0
- package/docs/deployment.md +7 -3
- package/docs/example-agents/approval-buddy.md +1 -1
- package/docs/example-agents/index.md +15 -10
- package/docs/example-agents/oncall.md +216 -0
- package/docs/example-agents/security-reviewer.md +5 -5
- package/docs/guides/slack.md +11 -2
- package/docs/reference/sessions.md +13 -4
- package/docs/storage.md +41 -0
- package/package.json +22 -1
- package/skills/framework-map/SKILL.md +6 -4
- package/src/bin/agent-serve.ts +32 -2
- package/src/channels/slack/channel-watch.ts +28 -1
- package/src/channels/slack/cursor-account.ts +20 -0
- package/src/channels/slack/defaults.ts +51 -20
- package/src/channels/slack/dispatch.ts +215 -40
- package/src/channels/slack/inbound.ts +30 -10
- package/src/channels/slack/index.ts +4 -0
- package/src/channels/slack/live-delivery.ts +1 -0
- package/src/channels/slack/manifest.ts +3 -0
- package/src/channels/slack/nudge-carrier.ts +182 -0
- package/src/channels/slack/nudge-store.ts +308 -0
- package/src/channels/slack/slack-channel.ts +106 -31
- package/src/channels/slack/stop.ts +25 -0
- package/src/channels/slack/thread-context.ts +572 -0
- package/src/channels/slack/types.ts +27 -0
- package/src/internal/cli-deploy.ts +58 -20
- package/src/internal/cli-mcp.ts +708 -0
- package/src/internal/deploy-client.ts +11 -0
- package/src/internal/deploy-source.ts +24 -6
- package/src/internal/discovery.ts +1 -1
- package/src/internal/distribution.ts +3 -0
- package/src/internal/host-kv.ts +85 -0
- package/src/internal/hosting.ts +24 -4
- package/src/internal/logs-client.ts +67 -21
- package/src/internal/server.ts +31 -0
- package/src/internal/session-engine.ts +379 -61
- package/src/internal/storage-coordinator.ts +41 -0
- package/src/internal/workspace.ts +48 -11
- package/src/storage-backends/cursor-hosted.ts +246 -0
- package/src/storage-backends/file-kv.ts +221 -0
- package/src/storage-backends/postgres-kv.ts +253 -0
- package/src/storage.ts +11 -1
- package/src/types.ts +83 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.B7UcKvIn.js +0 -1
- package/dist/docs/assets/example-agents_index.md.CRqJlnIf.js +0 -2
- package/dist/docs/assets/example-agents_index.md.CRqJlnIf.lean.js +0 -1
- package/dist/internal/persistence-coordinator.d.ts +0 -127
- package/dist/internal/persistence-coordinator.d.ts.map +0 -1
- package/dist/persistence.d.ts +0 -184
- package/dist/persistence.d.ts.map +0 -1
- package/dist/playground/assets/index-BjnMwYoR.css +0 -1
- /package/dist/docs/assets/{deployment.md.BtfEsc9S.lean.js → deployment.md.DC5-ImcM.lean.js} +0 -0
|
@@ -20,7 +20,7 @@ import { slackContinuationKey } from "./api.js";
|
|
|
20
20
|
import { createChannelPostWatcher, resolveChannelNames, SlackChannelAllowlist, } from "./channel-watch.js";
|
|
21
21
|
import { credentialsFromEnv, slackEnvKeys, tryResolveAppToken, tryResolveBotToken, } from "./credentials.js";
|
|
22
22
|
import { createPendingSlackApiTransport, registerSlackCursorAccountRuntime, } from "./cursor-account.js";
|
|
23
|
-
import { buildDefaultEvents,
|
|
23
|
+
import { buildDefaultEvents, createDefaultOnChannelPost, createDefaultOnInbound, } from "./defaults.js";
|
|
24
24
|
import { dispatchInboundFromEventBody, dispatchInboundMessage, emptySlackChannelState, } from "./dispatch.js";
|
|
25
25
|
import { createEventIdDedupe } from "./event-id-dedupe.js";
|
|
26
26
|
import { dispatchInteractiveFromPayload } from "./interactive.js";
|
|
@@ -82,9 +82,11 @@ export function slackChannel(options = {}) {
|
|
|
82
82
|
? { botToken: accountTransport }
|
|
83
83
|
: ((_d = options.credentials) !== null && _d !== void 0 ? _d : credentialsFromEnv(options.envPrefix));
|
|
84
84
|
const envKeys = slackEnvKeys(options.envPrefix);
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
85
|
+
const loadingMessages = options.loadingMessages;
|
|
86
|
+
const defaultInbound = createDefaultOnInbound(loadingMessages);
|
|
87
|
+
const onAppMention = (_e = options.onAppMention) !== null && _e !== void 0 ? _e : defaultInbound;
|
|
88
|
+
const onDirectMessage = (_f = options.onDirectMessage) !== null && _f !== void 0 ? _f : defaultInbound;
|
|
89
|
+
const onChannelPost = (_g = options.onChannelPost) !== null && _g !== void 0 ? _g : createDefaultOnChannelPost(loadingMessages);
|
|
88
90
|
const engagement = (_h = options.engagement) !== null && _h !== void 0 ? _h : {};
|
|
89
91
|
const mentionsEnabled = engagement.mentions !== false;
|
|
90
92
|
const directMessagesEnabled = engagement.directMessages !== false;
|
|
@@ -113,6 +115,7 @@ export function slackChannel(options = {}) {
|
|
|
113
115
|
thinkingSteps: options.thinkingSteps,
|
|
114
116
|
suggestedPrompts: options.suggestedPrompts,
|
|
115
117
|
suggestedPromptsTitle: options.suggestedPromptsTitle,
|
|
118
|
+
loadingMessages,
|
|
116
119
|
getLog,
|
|
117
120
|
}));
|
|
118
121
|
}
|
|
@@ -123,11 +126,21 @@ export function slackChannel(options = {}) {
|
|
|
123
126
|
let socketHandle = null;
|
|
124
127
|
let channelWatch;
|
|
125
128
|
function inboundDeps(args) {
|
|
126
|
-
return Object.assign({ send: args.send, waitUntil: args.waitUntil, onAppMention,
|
|
129
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ send: args.send, waitUntil: args.waitUntil, onAppMention,
|
|
127
130
|
onDirectMessage,
|
|
128
131
|
credentials,
|
|
129
132
|
eventIds, host: args.host, log: getLog(), mentionsEnabled,
|
|
130
|
-
directMessagesEnabled }, (
|
|
133
|
+
directMessagesEnabled }, (args.hasContinuationSession === undefined
|
|
134
|
+
? {}
|
|
135
|
+
: { hasContinuationSession: args.hasContinuationSession })), (args.isContinuationBusy === undefined
|
|
136
|
+
? {}
|
|
137
|
+
: { isContinuationBusy: args.isContinuationBusy })), (args.getContinuationLastBotMessageTs === undefined
|
|
138
|
+
? {}
|
|
139
|
+
: {
|
|
140
|
+
getContinuationLastBotMessageTs: args.getContinuationLastBotMessageTs,
|
|
141
|
+
})), (args.interruptContinuation === undefined
|
|
142
|
+
? {}
|
|
143
|
+
: { interruptContinuation: args.interruptContinuation })), (channelWatch === undefined ? {} : { channelWatch }));
|
|
131
144
|
}
|
|
132
145
|
const definition = defineChannel({
|
|
133
146
|
auth: [allowAll()],
|
|
@@ -156,6 +169,7 @@ export function slackChannel(options = {}) {
|
|
|
156
169
|
});
|
|
157
170
|
return send(input.message, {
|
|
158
171
|
auth: input.auth,
|
|
172
|
+
admission: "coalesce",
|
|
159
173
|
continuationToken: slackContinuationKey(channelId, threadTs),
|
|
160
174
|
state: emptySlackChannelState({
|
|
161
175
|
channelId,
|
|
@@ -190,12 +204,15 @@ export function slackChannel(options = {}) {
|
|
|
190
204
|
if (channelPosts !== undefined) {
|
|
191
205
|
const allowlist = new SlackChannelAllowlist(channelPosts.allow);
|
|
192
206
|
let botUserId;
|
|
207
|
+
let botId;
|
|
193
208
|
try {
|
|
194
209
|
const { WebClient } = yield import("@slack/web-api");
|
|
195
210
|
const client = new WebClient(botToken);
|
|
196
211
|
const identity = yield client.auth.test();
|
|
197
212
|
botUserId =
|
|
198
213
|
typeof identity.user_id === "string" ? identity.user_id : undefined;
|
|
214
|
+
botId =
|
|
215
|
+
typeof identity.bot_id === "string" ? identity.bot_id : undefined;
|
|
199
216
|
const names = allowlist.unresolvedNames();
|
|
200
217
|
if (names.length > 0) {
|
|
201
218
|
allowlist.applyResolvedNames(yield resolveChannelNames(client, names, getLog()));
|
|
@@ -206,30 +223,60 @@ export function slackChannel(options = {}) {
|
|
|
206
223
|
error: error instanceof Error ? error.message : String(error),
|
|
207
224
|
});
|
|
208
225
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
226
|
+
if (channelPosts.includeBotPosts === true &&
|
|
227
|
+
botUserId === undefined &&
|
|
228
|
+
botId === undefined) {
|
|
229
|
+
getLog().error("channel watch disabled", {
|
|
230
|
+
reason: "includeBotPosts requires bot identity from auth.test (loop safety)",
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
channelWatch = createChannelPostWatcher({
|
|
235
|
+
options: channelPosts,
|
|
236
|
+
allowlist,
|
|
237
|
+
getBotUserId: () => botUserId,
|
|
238
|
+
getBotId: () => botId,
|
|
239
|
+
log: getLog(),
|
|
240
|
+
dispatch: (message, eventId) => {
|
|
241
|
+
args.waitUntil(dispatchInboundMessage(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ kind: "channel_post", message, handler: onChannelPost, send: args.send, credentials, host: args.host, log: getLog() }, (args.hasContinuationSession === undefined
|
|
242
|
+
? {}
|
|
243
|
+
: {
|
|
244
|
+
hasContinuationSession: args.hasContinuationSession,
|
|
245
|
+
})), (args.isContinuationBusy === undefined
|
|
246
|
+
? {}
|
|
247
|
+
: { isContinuationBusy: args.isContinuationBusy })), (args.getContinuationLastBotMessageTs === undefined
|
|
248
|
+
? {}
|
|
249
|
+
: {
|
|
250
|
+
getContinuationLastBotMessageTs: args.getContinuationLastBotMessageTs,
|
|
251
|
+
})), (args.interruptContinuation === undefined
|
|
252
|
+
? {}
|
|
253
|
+
: {
|
|
254
|
+
interruptContinuation: args.interruptContinuation,
|
|
255
|
+
})), (eventId === undefined ? {} : { eventId }))));
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
getLog().info("channel watch enabled", {
|
|
259
|
+
channels: channelPosts.allow.join(","),
|
|
260
|
+
posts: (_b = channelPosts.posts) !== null && _b !== void 0 ? _b : "top-level",
|
|
261
|
+
debounce_ms: (_c = channelPosts.debounceMs) !== null && _c !== void 0 ? _c : 0,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
223
264
|
}
|
|
224
265
|
const socketOptions = {
|
|
225
266
|
appToken,
|
|
226
267
|
logger: (line) => getLog().write(line),
|
|
227
268
|
onEvent: (payload) => {
|
|
228
|
-
dispatchInboundFromEventBody(payload, inboundDeps({
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
269
|
+
dispatchInboundFromEventBody(payload, inboundDeps(Object.assign(Object.assign(Object.assign(Object.assign({ send: args.send, waitUntil: args.waitUntil, host: args.host }, (args.hasContinuationSession === undefined
|
|
270
|
+
? {}
|
|
271
|
+
: { hasContinuationSession: args.hasContinuationSession })), (args.isContinuationBusy === undefined
|
|
272
|
+
? {}
|
|
273
|
+
: { isContinuationBusy: args.isContinuationBusy })), (args.getContinuationLastBotMessageTs === undefined
|
|
274
|
+
? {}
|
|
275
|
+
: {
|
|
276
|
+
getContinuationLastBotMessageTs: args.getContinuationLastBotMessageTs,
|
|
277
|
+
})), (args.interruptContinuation === undefined
|
|
278
|
+
? {}
|
|
279
|
+
: { interruptContinuation: args.interruptContinuation }))));
|
|
233
280
|
},
|
|
234
281
|
};
|
|
235
282
|
if (routeInteractive) {
|
|
@@ -264,11 +311,13 @@ export function slackChannel(options = {}) {
|
|
|
264
311
|
});
|
|
265
312
|
},
|
|
266
313
|
onStop: () => __awaiter(this, void 0, void 0, function* () {
|
|
314
|
+
var _a;
|
|
267
315
|
getLog().info("channel stop");
|
|
268
316
|
channelWatch === null || channelWatch === void 0 ? void 0 : channelWatch.stop();
|
|
269
317
|
channelWatch = undefined;
|
|
270
318
|
yield socketHandle === null || socketHandle === void 0 ? void 0 : socketHandle.stop();
|
|
271
319
|
socketHandle = null;
|
|
320
|
+
yield (_a = options.onStop) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
272
321
|
}),
|
|
273
322
|
});
|
|
274
323
|
if (accountTransport !== undefined) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whole-message Slack "stop" directive (Benny parity).
|
|
3
|
+
*
|
|
4
|
+
* A message whose body is only `@bot stop` / `stop` cancels the active turn.
|
|
5
|
+
* The word "stop" embedded in a longer message is not a directive.
|
|
6
|
+
*/
|
|
7
|
+
/** Strip leading Slack user mentions and surrounding whitespace. */
|
|
8
|
+
export declare function stripLeadingSlackMentions(text: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* True when the message (after stripping @mentions) is exactly `stop`
|
|
11
|
+
* (case-insensitive).
|
|
12
|
+
*/
|
|
13
|
+
export declare function isWholeMessageStop(text: string): boolean;
|
|
14
|
+
//# sourceMappingURL=stop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/stop.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,oEAAoE;AACpE,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM9D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whole-message Slack "stop" directive (Benny parity).
|
|
3
|
+
*
|
|
4
|
+
* A message whose body is only `@bot stop` / `stop` cancels the active turn.
|
|
5
|
+
* The word "stop" embedded in a longer message is not a directive.
|
|
6
|
+
*/
|
|
7
|
+
const MENTION_RE = /^<@[A-Z0-9]+>\s*/i;
|
|
8
|
+
/** Strip leading Slack user mentions and surrounding whitespace. */
|
|
9
|
+
export function stripLeadingSlackMentions(text) {
|
|
10
|
+
let current = text.trim();
|
|
11
|
+
while (MENTION_RE.test(current)) {
|
|
12
|
+
current = current.replace(MENTION_RE, "").trim();
|
|
13
|
+
}
|
|
14
|
+
return current;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* True when the message (after stripping @mentions) is exactly `stop`
|
|
18
|
+
* (case-insensitive).
|
|
19
|
+
*/
|
|
20
|
+
export function isWholeMessageStop(text) {
|
|
21
|
+
return stripLeadingSlackMentions(text).toLowerCase() === "stop";
|
|
22
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch prior Slack thread messages and format them for the model prompt.
|
|
3
|
+
*
|
|
4
|
+
* Cold-start mentions (`@agent what happened here?`) only carry the mention
|
|
5
|
+
* text; the parent alert / earlier replies live in `conversations.replies`.
|
|
6
|
+
*/
|
|
7
|
+
import { type SlackLog } from "./log.js";
|
|
8
|
+
import type { SlackBotToken } from "./types.js";
|
|
9
|
+
/** Keep the thread root plus the newest replies when over the fetch cap. */
|
|
10
|
+
export declare function trimThreadMessagesForPrompt(messages: JsonRecord[], options: {
|
|
11
|
+
threadTs: string;
|
|
12
|
+
limit: number;
|
|
13
|
+
excludeTs?: string | readonly string[];
|
|
14
|
+
}): JsonRecord[];
|
|
15
|
+
type JsonRecord = Record<string, unknown>;
|
|
16
|
+
/** Pull readable text out of Slack attachment / Block Kit payloads. */
|
|
17
|
+
export declare function slackApiMessageBody(message: JsonRecord): string;
|
|
18
|
+
/** True when `ts` is strictly after `afterTs`. */
|
|
19
|
+
export declare function isSlackTsAfter(ts: string, afterTs: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Merge triggering messages (by ts) into a replies window when Slack lag
|
|
22
|
+
* omits them from `conversations.replies`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function mergeThreadMessagesByTs(messages: JsonRecord[], extras: readonly JsonRecord[]): JsonRecord[];
|
|
25
|
+
/**
|
|
26
|
+
* Latest bot-authored message ts in a thread (own posts), used as the warm
|
|
27
|
+
* delta watermark when channel state has not recorded one yet.
|
|
28
|
+
*/
|
|
29
|
+
export declare function findLastBotMessageTs(messages: readonly JsonRecord[], options?: {
|
|
30
|
+
botUserId?: string;
|
|
31
|
+
botId?: string;
|
|
32
|
+
}): string | undefined;
|
|
33
|
+
/** Messages strictly after `afterTs`, excluding listed timestamps. */
|
|
34
|
+
export declare function selectThreadDeltaMessages(messages: JsonRecord[], options: {
|
|
35
|
+
afterTs?: string;
|
|
36
|
+
excludeTs?: string | readonly string[];
|
|
37
|
+
}): JsonRecord[];
|
|
38
|
+
export declare function formatSlackThreadContextBlock(messages: JsonRecord[], options?: {
|
|
39
|
+
threadTs?: string;
|
|
40
|
+
excludeTs?: string | readonly string[];
|
|
41
|
+
maxChars?: number;
|
|
42
|
+
}): string | undefined;
|
|
43
|
+
export declare function formatSlackThreadDeltaBlock(messages: JsonRecord[], options?: {
|
|
44
|
+
excludeTs?: string | readonly string[];
|
|
45
|
+
afterTs?: string;
|
|
46
|
+
maxChars?: number;
|
|
47
|
+
}): string | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Load prior messages in a Slack thread and return a prompt context block.
|
|
50
|
+
* Soft-fails (returns undefined) when credentials are missing or the API errors.
|
|
51
|
+
*/
|
|
52
|
+
export declare function loadSlackThreadContextBlock(args: {
|
|
53
|
+
botToken: SlackBotToken | undefined;
|
|
54
|
+
channelId: string;
|
|
55
|
+
threadTs: string;
|
|
56
|
+
excludeTs?: string | readonly string[];
|
|
57
|
+
log?: SlackLog;
|
|
58
|
+
limit?: number;
|
|
59
|
+
maxChars?: number;
|
|
60
|
+
/** Extra messages merged by ts when Slack replies lag (Benny parity). */
|
|
61
|
+
mergeMessages?: readonly JsonRecord[];
|
|
62
|
+
}): Promise<string | undefined>;
|
|
63
|
+
/**
|
|
64
|
+
* Warm-turn delta: messages since the last bot post (or all new replies when
|
|
65
|
+
* the watermark is unknown), with optional merge-by-ts for the triggering ask.
|
|
66
|
+
*/
|
|
67
|
+
export declare function loadSlackThreadDeltaBlock(args: {
|
|
68
|
+
botToken: SlackBotToken | undefined;
|
|
69
|
+
channelId: string;
|
|
70
|
+
threadTs: string;
|
|
71
|
+
/** Watermark from channel state (`lastBotMessageTs`). */
|
|
72
|
+
afterTs?: string;
|
|
73
|
+
excludeTs?: string | readonly string[];
|
|
74
|
+
log?: SlackLog;
|
|
75
|
+
maxChars?: number;
|
|
76
|
+
mergeMessages?: readonly JsonRecord[];
|
|
77
|
+
botUserId?: string;
|
|
78
|
+
botId?: string;
|
|
79
|
+
}): Promise<string | undefined>;
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=thread-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-context.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/thread-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,YAAY,CAAC;AA4BjE,4EAA4E;AAC5E,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,UAAU,EAAE,EACtB,OAAO,EAAE;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CACxC,GACA,UAAU,EAAE,CAoCd;AAED,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAa1C,uEAAuE;AACvE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAkE/D;AAwCD,kDAAkD;AAClD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAA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