@cursor/july 0.1.11 → 0.1.12

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.
Files changed (69) hide show
  1. package/dist/docs/404.html +1 -1
  2. package/dist/docs/ab.html +2 -2
  3. package/dist/docs/assets/{app.BcXUGca7.js → app.Dh_JkJjI.js} +1 -1
  4. package/dist/docs/assets/chunks/@localSearchIndexroot.Er_R50vY.js +1 -0
  5. package/dist/docs/assets/chunks/{VPLocalSearchBox.CWur6XGZ.js → VPLocalSearchBox.CptQNLkR.js} +1 -1
  6. package/dist/docs/assets/chunks/{theme.BnvulOX2.js → theme.DWflH-LQ.js} +2 -2
  7. package/dist/docs/building-with-agents.html +2 -2
  8. package/dist/docs/concepts.html +2 -2
  9. package/dist/docs/deployment.html +2 -2
  10. package/dist/docs/evals.html +2 -2
  11. package/dist/docs/example-agents/approval-buddy.html +2 -2
  12. package/dist/docs/example-agents/benny.html +2 -2
  13. package/dist/docs/example-agents/bugbot.html +2 -2
  14. package/dist/docs/example-agents/codebase-wiki.html +2 -2
  15. package/dist/docs/example-agents/codeowners-review.html +2 -2
  16. package/dist/docs/example-agents/concierge.html +2 -2
  17. package/dist/docs/example-agents/fsd.html +2 -2
  18. package/dist/docs/example-agents/index.html +2 -2
  19. package/dist/docs/example-agents/knowledge-base.html +2 -2
  20. package/dist/docs/example-agents/oncall.html +2 -2
  21. package/dist/docs/example-agents/security-reviewer.html +2 -2
  22. package/dist/docs/example-agents/slack-agent.html +2 -2
  23. package/dist/docs/example-agents/weather-agent.html +2 -2
  24. package/dist/docs/guides/agent-to-agent.html +2 -2
  25. package/dist/docs/guides/cloud-runtime.html +2 -2
  26. package/dist/docs/guides/github.html +2 -2
  27. package/dist/docs/guides/human-in-the-loop.html +2 -2
  28. package/dist/docs/guides/mcp-oauth.html +2 -2
  29. package/dist/docs/guides/slack.html +2 -2
  30. package/dist/docs/guides/webhooks.html +2 -2
  31. package/dist/docs/hillclimbing.html +2 -2
  32. package/dist/docs/index.html +2 -2
  33. package/dist/docs/quickstart.html +2 -2
  34. package/dist/docs/reference/agent-config.html +2 -2
  35. package/dist/docs/reference/channels.html +2 -2
  36. package/dist/docs/reference/cli.html +2 -2
  37. package/dist/docs/reference/connections.html +2 -2
  38. package/dist/docs/reference/hooks.html +2 -2
  39. package/dist/docs/reference/http-api.html +2 -2
  40. package/dist/docs/reference/instructions.html +2 -2
  41. package/dist/docs/reference/playground.html +2 -2
  42. package/dist/docs/reference/project-layout.html +2 -2
  43. package/dist/docs/reference/prompt.html +2 -2
  44. package/dist/docs/reference/schedules.html +2 -2
  45. package/dist/docs/reference/sessions.html +2 -2
  46. package/dist/docs/reference/skills.html +2 -2
  47. package/dist/docs/reference/subagents.html +2 -2
  48. package/dist/docs/reference/tools.html +2 -2
  49. package/dist/docs/scaffolding-agents.html +2 -2
  50. package/dist/docs/storage.html +2 -2
  51. package/dist/docs/troubleshooting.html +2 -2
  52. package/dist/internal/cursor-event-relay.d.ts +2 -0
  53. package/dist/internal/cursor-event-relay.d.ts.map +1 -1
  54. package/dist/internal/cursor-event-relay.js +3 -0
  55. package/dist/playground/assets/index-1dzluIcW.js +86 -0
  56. package/dist/playground/assets/index-kZjeJs1v.css +1 -0
  57. package/dist/playground/index.html +2 -2
  58. package/package.json +1 -1
  59. package/src/internal/cursor-event-relay.ts +5 -0
  60. package/dist/channels/slack/post-update-delivery.d.ts +0 -85
  61. package/dist/channels/slack/post-update-delivery.d.ts.map +0 -1
  62. package/dist/channels/slack/post-update-delivery.js +0 -318
  63. package/dist/docs/assets/chunks/@localSearchIndexroot.BIbvK8M1.js +0 -1
  64. package/dist/internal/corp-ca.d.ts +0 -9
  65. package/dist/internal/corp-ca.d.ts.map +0 -1
  66. package/dist/internal/corp-ca.js +0 -44
  67. package/dist/playground/assets/index-BIGLubwK.js +0 -86
  68. package/dist/playground/assets/index-C17ZQKDG.css +0 -1
  69. package/docs/.vitepress/cache/deps/package.json +0 -3
@@ -8,8 +8,8 @@
8
8
  />
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1" />
10
10
  <title>agent-serve playground</title>
11
- <script type="module" crossorigin src="./assets/index-BIGLubwK.js"></script>
12
- <link rel="stylesheet" crossorigin href="./assets/index-C17ZQKDG.css">
11
+ <script type="module" crossorigin src="./assets/index-1dzluIcW.js"></script>
12
+ <link rel="stylesheet" crossorigin href="./assets/index-kZjeJs1v.css">
13
13
  </head>
14
14
  <body>
15
15
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cursor/july",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "(early alpha) Filesystem-first framework for defining Cursor agents as markdown and TypeScript and serving them over channels with the Cursor SDK.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
@@ -25,6 +25,8 @@ export type CursorScmPullRequestMeta = {
25
25
  title?: string;
26
26
  body?: string | null;
27
27
  draft?: boolean;
28
+ /** True when the PR was merged — required by closed+merged channel hooks. */
29
+ merged?: boolean;
28
30
  authorLogin?: string;
29
31
  headRef?: string;
30
32
  headSha?: string;
@@ -163,6 +165,9 @@ export function scmMetadataToGitHubPayload(event: {
163
165
  head: { ref: headRef, sha: headSha },
164
166
  base: { ref: baseRef, sha: prMeta?.baseSha },
165
167
  };
168
+ if (prMeta?.merged !== undefined) {
169
+ pullRequest.merged = prMeta.merged;
170
+ }
166
171
  if (prMeta?.authorLogin !== undefined) {
167
172
  pullRequest.user = { login: prMeta.authorLogin };
168
173
  }
@@ -1,85 +0,0 @@
1
- /**
2
- * Live-reply delivery strategies for the Slack default handlers.
3
- *
4
- * A single strategy owns how an in-progress reply is opened, updated,
5
- * finalized, and cleaned up so the handlers in `defaults.ts` don't fork on the
6
- * delivery mode at every event:
7
- *
8
- * - `stream`: Slack chat.startStream / appendStream / stopStream.
9
- * - `post-update`: a chat.postMessage skeleton edited with chat.update. This is
10
- * the only path that preserves Cursor-account identity pinning (which only
11
- * covers postMessage).
12
- *
13
- * `buildDefaultEvents` selects one via {@link selectLiveDeliveryStrategy} up
14
- * front and calls into it. All calls keep the same soft-fail / log behavior as
15
- * the inlined logic they replaced.
16
- */
17
- import type { ChannelEventContext } from "../../types.js";
18
- import type { SlackLog } from "./log.js";
19
- import type { SlackBotToken, SlackChannelState } from "./types.js";
20
- type SlackChannel = ChannelEventContext<SlackChannelState>;
21
- export interface LiveDeliveryDeps {
22
- botToken: SlackBotToken | undefined;
23
- getLog: () => SlackLog;
24
- }
25
- /**
26
- * How the default handlers deliver an in-progress reply. Methods write live
27
- * delivery state (`streamTs`, `streamChannelId`, `lastPostedText`,
28
- * `lastPostUpdateAtMs`, `streamingUnavailable`) on `channel.state` directly.
29
- */
30
- export interface LiveDeliveryStrategy {
31
- /** True when tool-call thinking steps can be appended to the live message. */
32
- readonly inlineToolSteps: boolean;
33
- /** Open the live message (skeleton post / stream start). */
34
- start(args: {
35
- channel: SlackChannel;
36
- channelId: string;
37
- threadTs: string;
38
- sessionId: string;
39
- }): Promise<void>;
40
- /** Push the latest cumulative text to the live message (throttled). */
41
- append(args: {
42
- channel: SlackChannel;
43
- channelId: string;
44
- streamTs: string;
45
- text: string;
46
- sessionId: string;
47
- }): Promise<void>;
48
- /**
49
- * Flush the final reply text. `delivered` is false only when the caller must
50
- * post the full reply as a fresh message (finalize failed on partial text).
51
- */
52
- finalize(args: {
53
- channel: SlackChannel;
54
- channelId: string;
55
- streamTs: string;
56
- text: string;
57
- sessionId: string;
58
- }): Promise<{
59
- delivered: boolean;
60
- }>;
61
- /** Close the live message when the turn produced no final text. */
62
- finalizeEmpty(args: {
63
- channel: SlackChannel;
64
- channelId: string;
65
- streamTs: string;
66
- }): Promise<void>;
67
- /** Best-effort remove a live message left open after the turn ended. */
68
- cleanupOrphan(args: {
69
- channel: SlackChannel;
70
- }): Promise<void>;
71
- /** Deliver the error text into the live message; `delivered` gates a fallback post. */
72
- fail(args: {
73
- channel: SlackChannel;
74
- channelId: string;
75
- streamTs: string;
76
- errorText: string;
77
- sessionId: string;
78
- }): Promise<{
79
- delivered: boolean;
80
- }>;
81
- }
82
- /** Pick the live-reply delivery strategy for a `buildDefaultEvents` instance. */
83
- export declare function selectLiveDeliveryStrategy(deps: LiveDeliveryDeps, usePostUpdate: boolean): LiveDeliveryStrategy;
84
- export {};
85
- //# sourceMappingURL=post-update-delivery.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"post-update-delivery.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/post-update-delivery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAW1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEnE,KAAK,YAAY,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;IACpC,MAAM,EAAE,MAAM,QAAQ,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,4DAA4D;IAC5D,KAAK,CAAC,IAAI,EAAE;QACV,OAAO,EAAE,YAAY,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,uEAAuE;IACvE,MAAM,CAAC,IAAI,EAAE;QACX,OAAO,EAAE,YAAY,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE;QACb,OAAO,EAAE,YAAY,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACpC,mEAAmE;IACnE,aAAa,CAAC,IAAI,EAAE;QAClB,OAAO,EAAE,YAAY,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,wEAAwE;IACxE,aAAa,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,YAAY,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,uFAAuF;IACvF,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,YAAY,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACrC;AA6RD,iFAAiF;AACjF,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,gBAAgB,EACtB,aAAa,EAAE,OAAO,GACrB,oBAAoB,CAItB"}
@@ -1,318 +0,0 @@
1
- /**
2
- * Live-reply delivery strategies for the Slack default handlers.
3
- *
4
- * A single strategy owns how an in-progress reply is opened, updated,
5
- * finalized, and cleaned up so the handlers in `defaults.ts` don't fork on the
6
- * delivery mode at every event:
7
- *
8
- * - `stream`: Slack chat.startStream / appendStream / stopStream.
9
- * - `post-update`: a chat.postMessage skeleton edited with chat.update. This is
10
- * the only path that preserves Cursor-account identity pinning (which only
11
- * covers postMessage).
12
- *
13
- * `buildDefaultEvents` selects one via {@link selectLiveDeliveryStrategy} up
14
- * front and calls into it. All calls keep the same soft-fail / log behavior as
15
- * the inlined logic they replaced.
16
- */
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- import { appendChatStream, deleteMessage, postMessage, setThreadStatus, startChatStream, stopChatStream, updateMessage, } from "./api.js";
27
- import { SLACK_POST_UPDATE_MIN_INTERVAL_MS } from "./constants.js";
28
- import { computeStreamAppend } from "./stream.js";
29
- function createPostUpdateStrategy(deps) {
30
- const { botToken, getLog } = deps;
31
- return {
32
- inlineToolSteps: false,
33
- start(_a) {
34
- return __awaiter(this, arguments, void 0, function* ({ channel, channelId, threadTs, sessionId }) {
35
- const log = getLog();
36
- try {
37
- const posted = yield postMessage({
38
- botToken,
39
- channel: channelId,
40
- text: "…",
41
- threadTs,
42
- });
43
- if (posted.ts !== "") {
44
- channel.state.streamTs = posted.ts;
45
- channel.state.streamChannelId = channelId;
46
- channel.state.lastPostedText = "";
47
- log.info("postMessage skeleton ok", {
48
- channel: channelId,
49
- message_ts: posted.ts,
50
- session: sessionId,
51
- });
52
- }
53
- }
54
- catch (error) {
55
- log.warn("postMessage skeleton failed", {
56
- error: error instanceof Error ? error.message : String(error),
57
- channel: channelId,
58
- session: sessionId,
59
- });
60
- // Transient proxy/network failures must not permanently disable
61
- // live delivery — only the stream path sets streamingUnavailable
62
- // when Slack reports the feature unsupported.
63
- }
64
- });
65
- },
66
- append(_a) {
67
- return __awaiter(this, arguments, void 0, function* ({ channel, channelId, streamTs, text, sessionId }) {
68
- var _b;
69
- const now = Date.now();
70
- const isFirstUpdate = channel.state.lastPostedText === null ||
71
- channel.state.lastPostedText === "";
72
- const lastAt = (_b = channel.state.lastPostUpdateAtMs) !== null && _b !== void 0 ? _b : 0;
73
- const due = isFirstUpdate || now - lastAt >= SLACK_POST_UPDATE_MIN_INTERVAL_MS;
74
- if (!due) {
75
- // Skip intermediate update; message.completed flushes full text.
76
- return;
77
- }
78
- const result = yield updateMessage({
79
- botToken,
80
- channel: channelId,
81
- ts: streamTs,
82
- text,
83
- });
84
- if (!result.ok) {
85
- getLog().warn("chat.update failed", {
86
- error: result.error,
87
- channel: channelId,
88
- message_ts: streamTs,
89
- session: sessionId,
90
- });
91
- return;
92
- }
93
- channel.state.lastPostUpdateAtMs = now;
94
- channel.state.lastPostedText = text;
95
- });
96
- },
97
- finalize(_a) {
98
- return __awaiter(this, arguments, void 0, function* ({ channel, channelId, streamTs, text, sessionId }) {
99
- const log = getLog();
100
- const result = yield updateMessage({
101
- botToken,
102
- channel: channelId,
103
- ts: streamTs,
104
- text,
105
- });
106
- channel.state.streamTs = null;
107
- if (result.ok) {
108
- channel.state.lastPostedText = text;
109
- log.info("reply delivered via chat.update", {
110
- channel: channelId,
111
- message_ts: streamTs,
112
- session: sessionId,
113
- chars: text.length,
114
- });
115
- return { delivered: true };
116
- }
117
- log.warn("chat.update finalize failed; falling back to postMessage", {
118
- error: result.error,
119
- channel: channelId,
120
- message_ts: streamTs,
121
- session: sessionId,
122
- });
123
- // Only suppress the fallback when the skeleton already holds the exact
124
- // final text. Partial updates must not permanently truncate.
125
- if (channel.state.lastPostedText === text) {
126
- return { delivered: true };
127
- }
128
- // The skeleton still shows the placeholder or a stale partial and we're
129
- // about to post the full reply as a fresh message. Best-effort delete the
130
- // orphan so the thread doesn't show a duplicate.
131
- yield deleteMessage({ botToken, channel: channelId, ts: streamTs });
132
- return { delivered: false };
133
- });
134
- },
135
- finalizeEmpty(_a) {
136
- return __awaiter(this, arguments, void 0, function* ({ channelId, streamTs }) {
137
- yield updateMessage({
138
- botToken,
139
- channel: channelId,
140
- ts: streamTs,
141
- text: " ",
142
- });
143
- });
144
- },
145
- cleanupOrphan(_a) {
146
- return __awaiter(this, arguments, void 0, function* ({ channel }) {
147
- var _b;
148
- // A skeleton that was never finalized (e.g. an empty turn that produced
149
- // no message.completed) would otherwise linger as a "…" placeholder
150
- // forever. Best-effort delete it and clear typing.
151
- const orphanTs = channel.state.streamTs;
152
- if (orphanTs === null || orphanTs === "") {
153
- return;
154
- }
155
- const orphanChannelId = (_b = channel.state.streamChannelId) !== null && _b !== void 0 ? _b : channel.state.channelId;
156
- if (orphanChannelId !== null && orphanChannelId !== "") {
157
- yield deleteMessage({
158
- botToken,
159
- channel: orphanChannelId,
160
- ts: orphanTs,
161
- });
162
- }
163
- channel.state.streamTs = null;
164
- if (channel.state.channelId !== null && channel.state.threadTs !== null) {
165
- yield setThreadStatus({
166
- botToken,
167
- channelId: channel.state.channelId,
168
- threadTs: channel.state.threadTs,
169
- status: "",
170
- });
171
- }
172
- });
173
- },
174
- fail(_a) {
175
- return __awaiter(this, arguments, void 0, function* ({ channel, channelId, streamTs, errorText }) {
176
- const updated = yield updateMessage({
177
- botToken,
178
- channel: channelId,
179
- ts: streamTs,
180
- text: errorText,
181
- });
182
- channel.state.streamTs = null;
183
- return { delivered: updated.ok };
184
- });
185
- },
186
- };
187
- }
188
- function createStreamStrategy(deps) {
189
- const { botToken, getLog } = deps;
190
- return {
191
- inlineToolSteps: true,
192
- start(_a) {
193
- return __awaiter(this, arguments, void 0, function* ({ channel, channelId, threadTs, sessionId }) {
194
- const log = getLog();
195
- const started = yield startChatStream({
196
- botToken,
197
- channel: channelId,
198
- thread_ts: threadTs,
199
- markdown_text: "",
200
- });
201
- if (!started.ok) {
202
- log.warn("chat.startStream unavailable", {
203
- error: started.error,
204
- channel: channelId,
205
- thread_ts: threadTs,
206
- session: sessionId,
207
- });
208
- if (started.unsupported === true) {
209
- channel.state.streamingUnavailable = true;
210
- }
211
- return;
212
- }
213
- channel.state.streamTs = started.ts;
214
- channel.state.streamChannelId = started.channel;
215
- channel.state.lastPostedText = "";
216
- log.info("chat.startStream ok", {
217
- channel: started.channel,
218
- stream_ts: started.ts,
219
- session: sessionId,
220
- });
221
- });
222
- },
223
- append(_a) {
224
- return __awaiter(this, arguments, void 0, function* ({ channel, channelId, streamTs, text, sessionId }) {
225
- const appendText = computeStreamAppend(channel.state.lastPostedText, text);
226
- if (appendText === "") {
227
- return;
228
- }
229
- const result = yield appendChatStream({
230
- botToken,
231
- channel: channelId,
232
- ts: streamTs,
233
- markdown_text: appendText,
234
- });
235
- if (!result.ok) {
236
- getLog().warn("appendStream failed", {
237
- error: result.error,
238
- channel: channelId,
239
- stream_ts: streamTs,
240
- session: sessionId,
241
- });
242
- if (result.unsupported === true) {
243
- channel.state.streamingUnavailable = true;
244
- }
245
- return;
246
- }
247
- channel.state.lastPostedText = text;
248
- });
249
- },
250
- finalize(_a) {
251
- return __awaiter(this, arguments, void 0, function* ({ channel, channelId, streamTs, text, sessionId }) {
252
- const log = getLog();
253
- // Only send the unsent suffix — full text was already appended.
254
- const appendText = computeStreamAppend(channel.state.lastPostedText, text);
255
- const stopped = yield stopChatStream({
256
- botToken,
257
- channel: channelId,
258
- ts: streamTs,
259
- markdown_text: appendText === "" ? undefined : appendText,
260
- });
261
- if (stopped.ok) {
262
- channel.state.streamTs = null;
263
- channel.state.lastPostedText = text;
264
- log.info("reply delivered via stream", {
265
- channel: channelId,
266
- stream_ts: streamTs,
267
- session: sessionId,
268
- chars: text.length,
269
- });
270
- return { delivered: true };
271
- }
272
- log.warn("chat.stopStream failed; falling back to postMessage", {
273
- error: stopped.error,
274
- channel: channelId,
275
- stream_ts: streamTs,
276
- session: sessionId,
277
- });
278
- if (stopped.unsupported === true) {
279
- channel.state.streamingUnavailable = true;
280
- }
281
- channel.state.streamTs = null;
282
- // If we already streamed content, do not post the full reply again.
283
- const alreadyStreamed = typeof channel.state.lastPostedText === "string" &&
284
- channel.state.lastPostedText.length > 0;
285
- return { delivered: alreadyStreamed };
286
- });
287
- },
288
- finalizeEmpty(_a) {
289
- return __awaiter(this, arguments, void 0, function* ({ channelId, streamTs }) {
290
- yield stopChatStream({ botToken, channel: channelId, ts: streamTs });
291
- });
292
- },
293
- cleanupOrphan() {
294
- return __awaiter(this, void 0, void 0, function* () {
295
- // The stream path closes its message in message.completed / turn.failed;
296
- // there is nothing to clean up after turn.completed.
297
- });
298
- },
299
- fail(_a) {
300
- return __awaiter(this, arguments, void 0, function* ({ channel, channelId, streamTs, errorText }) {
301
- const stopped = yield stopChatStream({
302
- botToken,
303
- channel: channelId,
304
- ts: streamTs,
305
- markdown_text: errorText,
306
- });
307
- channel.state.streamTs = null;
308
- return { delivered: stopped.ok };
309
- });
310
- },
311
- };
312
- }
313
- /** Pick the live-reply delivery strategy for a `buildDefaultEvents` instance. */
314
- export function selectLiveDeliveryStrategy(deps, usePostUpdate) {
315
- return usePostUpdate
316
- ? createPostUpdateStrategy(deps)
317
- : createStreamStrategy(deps);
318
- }