@cursor/july 0.1.32 → 0.1.34

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 (186) hide show
  1. package/README.md +1 -1
  2. package/dist/artifacts.d.ts.map +1 -1
  3. package/dist/artifacts.js +0 -5
  4. package/dist/bin/agent-serve.d.ts +1 -0
  5. package/dist/bin/agent-serve.d.ts.map +1 -1
  6. package/dist/bin/agent-serve.js +32 -2
  7. package/dist/channels/github/types.d.ts +10 -7
  8. package/dist/channels/github/types.d.ts.map +1 -1
  9. package/dist/docs/404.html +2 -2
  10. package/dist/docs/ab.html +3 -3
  11. package/dist/docs/assets/{app.C2aVczmo.js → app.FPupl4SP.js} +1 -1
  12. package/dist/docs/assets/chunks/@localSearchIndexroot.WoYunhnT.js +1 -0
  13. package/dist/docs/assets/chunks/{VPLocalSearchBox.DLEzetbD.js → VPLocalSearchBox.Cd182Cu0.js} +1 -1
  14. package/dist/docs/assets/chunks/{theme.BkOH1oMp.js → theme.BEM3Okcd.js} +2 -2
  15. package/dist/docs/assets/{example-agents_weather-agent.md.Dmrcphhl.js → example-agents_weather-agent.md.BADkPqxQ.js} +6 -4
  16. package/dist/docs/assets/example-agents_weather-agent.md.BADkPqxQ.lean.js +1 -0
  17. package/dist/docs/assets/guides_cloud-runtime.md.CDJGvVC4.js +9 -0
  18. package/dist/docs/assets/guides_cloud-runtime.md.CDJGvVC4.lean.js +1 -0
  19. package/dist/docs/building-with-agents.html +3 -3
  20. package/dist/docs/concepts.html +3 -3
  21. package/dist/docs/deployment.html +3 -3
  22. package/dist/docs/evals.html +3 -3
  23. package/dist/docs/example-agents/approval-buddy.html +3 -3
  24. package/dist/docs/example-agents/benny.html +3 -3
  25. package/dist/docs/example-agents/bugbot.html +3 -3
  26. package/dist/docs/example-agents/codebase-wiki.html +3 -3
  27. package/dist/docs/example-agents/codeowners-review.html +3 -3
  28. package/dist/docs/example-agents/concierge.html +3 -3
  29. package/dist/docs/example-agents/fsd.html +3 -3
  30. package/dist/docs/example-agents/index.html +3 -3
  31. package/dist/docs/example-agents/knowledge-base.html +3 -3
  32. package/dist/docs/example-agents/oncall.html +3 -3
  33. package/dist/docs/example-agents/security-reviewer.html +3 -3
  34. package/dist/docs/example-agents/slack-agent.html +3 -3
  35. package/dist/docs/example-agents/weather-agent.html +10 -8
  36. package/dist/docs/guides/agent-to-agent.html +3 -3
  37. package/dist/docs/guides/cloud-runtime.html +5 -5
  38. package/dist/docs/guides/github.html +3 -3
  39. package/dist/docs/guides/human-in-the-loop.html +3 -3
  40. package/dist/docs/guides/mcp-oauth.html +3 -3
  41. package/dist/docs/guides/slack.html +3 -3
  42. package/dist/docs/guides/webhooks.html +3 -3
  43. package/dist/docs/hashmap.json +1 -1
  44. package/dist/docs/hillclimbing.html +3 -3
  45. package/dist/docs/index.html +3 -3
  46. package/dist/docs/quickstart.html +3 -3
  47. package/dist/docs/reference/agent-config.html +3 -3
  48. package/dist/docs/reference/channels.html +3 -3
  49. package/dist/docs/reference/cli.html +3 -3
  50. package/dist/docs/reference/connections.html +3 -3
  51. package/dist/docs/reference/hooks.html +3 -3
  52. package/dist/docs/reference/http-api.html +3 -3
  53. package/dist/docs/reference/instructions.html +3 -3
  54. package/dist/docs/reference/playground.html +3 -3
  55. package/dist/docs/reference/project-layout.html +3 -3
  56. package/dist/docs/reference/prompt.html +3 -3
  57. package/dist/docs/reference/schedules.html +3 -3
  58. package/dist/docs/reference/sessions.html +3 -3
  59. package/dist/docs/reference/skills.html +3 -3
  60. package/dist/docs/reference/subagents.html +3 -3
  61. package/dist/docs/reference/tools.html +3 -3
  62. package/dist/docs/scaffolding-agents.html +3 -3
  63. package/dist/docs/storage.html +3 -3
  64. package/dist/docs/troubleshooting.html +3 -3
  65. package/dist/files-backends/agent-store-presigned-url.d.ts.map +1 -1
  66. package/dist/files-backends/agent-store-presigned-url.js +19 -810
  67. package/dist/files.d.ts +20 -0
  68. package/dist/files.d.ts.map +1 -1
  69. package/dist/files.js +20 -0
  70. package/dist/index.d.ts +2 -2
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +2 -2
  73. package/dist/internal/artifacts-store.d.ts +14 -6
  74. package/dist/internal/artifacts-store.d.ts.map +1 -1
  75. package/dist/internal/artifacts-store.js +160 -16
  76. package/dist/internal/cli-convert-automation.d.ts +39 -0
  77. package/dist/internal/cli-convert-automation.d.ts.map +1 -0
  78. package/dist/internal/cli-convert-automation.js +280 -0
  79. package/dist/internal/cli-deploy.d.ts +2 -0
  80. package/dist/internal/cli-deploy.d.ts.map +1 -1
  81. package/dist/internal/cli-deploy.js +1 -1
  82. package/dist/internal/cli-mcp-oauth.d.ts +23 -0
  83. package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
  84. package/dist/internal/cli-mcp-oauth.js +57 -33
  85. package/dist/internal/convert-automation/convert-workflow.d.ts +10 -0
  86. package/dist/internal/convert-automation/convert-workflow.d.ts.map +1 -0
  87. package/dist/internal/convert-automation/convert-workflow.js +998 -0
  88. package/dist/internal/convert-automation/index.d.ts +3 -0
  89. package/dist/internal/convert-automation/index.d.ts.map +1 -0
  90. package/dist/internal/convert-automation/index.js +1 -0
  91. package/dist/internal/convert-automation/slug.d.ts +11 -0
  92. package/dist/internal/convert-automation/slug.d.ts.map +1 -0
  93. package/dist/internal/convert-automation/slug.js +36 -0
  94. package/dist/internal/convert-automation/types.d.ts +191 -0
  95. package/dist/internal/convert-automation/types.d.ts.map +1 -0
  96. package/dist/internal/convert-automation/types.js +13 -0
  97. package/dist/internal/cursor-relay-core.d.ts +12 -0
  98. package/dist/internal/cursor-relay-core.d.ts.map +1 -1
  99. package/dist/internal/cursor-relay-core.js +42 -8
  100. package/dist/internal/deploy-client.d.ts +31 -0
  101. package/dist/internal/deploy-client.d.ts.map +1 -1
  102. package/dist/internal/deploy-client.js +48 -0
  103. package/dist/internal/discovery.d.ts.map +1 -1
  104. package/dist/internal/discovery.js +3 -32
  105. package/dist/internal/init-project.d.ts +1 -0
  106. package/dist/internal/init-project.d.ts.map +1 -1
  107. package/dist/internal/init-project.js +1 -1
  108. package/dist/internal/mcp-endpoint.d.ts +6 -0
  109. package/dist/internal/mcp-endpoint.d.ts.map +1 -1
  110. package/dist/internal/mcp-endpoint.js +168 -0
  111. package/dist/internal/resolved-connections.d.ts +15 -0
  112. package/dist/internal/resolved-connections.d.ts.map +1 -1
  113. package/dist/internal/resolved-connections.js +12 -5
  114. package/dist/internal/review-comments.d.ts +9 -1
  115. package/dist/internal/review-comments.d.ts.map +1 -1
  116. package/dist/internal/review-comments.js +76 -0
  117. package/dist/internal/server.d.ts.map +1 -1
  118. package/dist/internal/server.js +83 -8
  119. package/dist/internal/session-engine.d.ts +56 -3
  120. package/dist/internal/session-engine.d.ts.map +1 -1
  121. package/dist/internal/session-engine.js +252 -83
  122. package/dist/internal/storage-coordinator.d.ts +0 -15
  123. package/dist/internal/storage-coordinator.d.ts.map +1 -1
  124. package/dist/internal/storage-coordinator.js +0 -52
  125. package/dist/internal/workspace.d.ts +10 -5
  126. package/dist/internal/workspace.d.ts.map +1 -1
  127. package/dist/internal/workspace.js +13 -0
  128. package/dist/memory.d.ts +22 -6
  129. package/dist/memory.d.ts.map +1 -1
  130. package/dist/memory.js +100 -8
  131. package/dist/playground/assets/index-CDDWw0YX.js +85 -0
  132. package/dist/playground/assets/index-MVuNTd8v.css +1 -0
  133. package/dist/playground/index.html +2 -2
  134. package/dist/storage.d.ts +0 -4
  135. package/dist/storage.d.ts.map +1 -1
  136. package/dist/storage.js +0 -4
  137. package/dist/types.d.ts +18 -0
  138. package/dist/types.d.ts.map +1 -1
  139. package/docs/example-agents/weather-agent.md +29 -11
  140. package/docs/guides/cloud-runtime.md +6 -4
  141. package/package.json +3 -22
  142. package/src/artifacts.ts +0 -6
  143. package/src/bin/agent-serve.ts +36 -2
  144. package/src/channels/github/types.ts +10 -7
  145. package/src/files-backends/agent-store-presigned-url.ts +7 -5
  146. package/src/files.ts +27 -0
  147. package/src/index.ts +6 -1
  148. package/src/internal/artifacts-store.ts +185 -22
  149. package/src/internal/cli-convert-automation.ts +352 -0
  150. package/src/internal/cli-deploy.ts +1 -1
  151. package/src/internal/cli-mcp-oauth.ts +69 -31
  152. package/src/internal/convert-automation/convert-workflow.ts +1422 -0
  153. package/src/internal/convert-automation/index.ts +10 -0
  154. package/src/internal/convert-automation/slug.ts +38 -0
  155. package/src/internal/convert-automation/types.ts +199 -0
  156. package/src/internal/cursor-relay-core.ts +62 -3
  157. package/src/internal/deploy-client.ts +78 -0
  158. package/src/internal/discovery.ts +3 -37
  159. package/src/internal/init-project.ts +1 -1
  160. package/src/internal/mcp-endpoint.ts +243 -0
  161. package/src/internal/resolved-connections.ts +32 -6
  162. package/src/internal/review-comments.ts +102 -2
  163. package/src/internal/server.ts +108 -2
  164. package/src/internal/session-engine.ts +329 -99
  165. package/src/internal/storage-coordinator.ts +0 -62
  166. package/src/internal/workspace.ts +19 -5
  167. package/src/memory.ts +126 -10
  168. package/src/storage.ts +0 -6
  169. package/src/types.ts +15 -0
  170. package/dist/channels/slack/post-update-delivery.d.ts +0 -85
  171. package/dist/channels/slack/post-update-delivery.d.ts.map +0 -1
  172. package/dist/docs/assets/chunks/@localSearchIndexroot.xgMnlUSO.js +0 -1
  173. package/dist/docs/assets/example-agents_weather-agent.md.Dmrcphhl.lean.js +0 -1
  174. package/dist/docs/assets/guides_cloud-runtime.md.BZ2GA7Es.js +0 -9
  175. package/dist/docs/assets/guides_cloud-runtime.md.BZ2GA7Es.lean.js +0 -1
  176. package/dist/internal/json-dir-store.d.ts +0 -32
  177. package/dist/internal/json-dir-store.d.ts.map +0 -1
  178. package/dist/internal/persistence-coordinator.d.ts +0 -127
  179. package/dist/internal/persistence-coordinator.d.ts.map +0 -1
  180. package/dist/multi-tenant.d.ts +0 -80
  181. package/dist/multi-tenant.d.ts.map +0 -1
  182. package/dist/multi-tenant.js +0 -69
  183. package/dist/persistence.d.ts +0 -184
  184. package/dist/persistence.d.ts.map +0 -1
  185. package/dist/playground/assets/index-50PKeJlG.css +0 -1
  186. package/dist/playground/assets/index-C0f2Wl1q.js +0 -85
package/src/memory.ts CHANGED
@@ -16,14 +16,21 @@
16
16
  * path — typically a server tool under `agent/tools/`, which can resolve
17
17
  * state via `ctx.stateRoot`.
18
18
  *
19
- * TODO(agent-store): once agent-serve can mount the agent's AgentStore
20
- * (durable S3-backed filesystem shared across serve hosts and cloud VMs),
21
- * ship an AgentStore-backed backend and make it the default. The journal
22
- * format is designed to survive that move unchanged.
19
+ * On Cursor-managed hosting the default is {@link agentStoreMemoryBackend}:
20
+ * the journal lives on the deployment's Agent Store (survives deploys,
21
+ * visible on cloud VMs under the store mount) and is mirrored to
22
+ * `<stateRoot>/memory/journal.jsonl` so the workspace symlink read path
23
+ * keeps working for local-runtime turns.
23
24
  */
24
25
 
25
- import { appendFile, mkdir, rename, stat } from "node:fs/promises";
26
+ import { randomUUID } from "node:crypto";
27
+ import { appendFile, mkdir, rename, stat, writeFile } from "node:fs/promises";
26
28
  import { join } from "node:path";
29
+ import { agentStoreKeys, FileConflictError, type FileSink } from "./files.js";
30
+ import {
31
+ cursorHostedFiles,
32
+ isCursorHostedFilesAvailable,
33
+ } from "./files-backends/cursor-hosted.js";
27
34
  import { defineHook } from "./hooks.js";
28
35
  import type { HookContext, HookDefinition, TurnUsage } from "./types.js";
29
36
 
@@ -48,11 +55,11 @@ export type TurnMemoryRecord = {
48
55
  usage?: TurnUsage;
49
56
  };
50
57
 
51
- /** Where turn records go. Receives the agent's state root per append. */
58
+ /** Where turn records go. Receives the agent's state root and name per append. */
52
59
  export interface MemoryBackend {
53
60
  appendTurn(
54
61
  record: TurnMemoryRecord,
55
- ctx: { stateRoot: string }
62
+ ctx: { stateRoot: string; agentName: string }
56
63
  ): Promise<void>;
57
64
  }
58
65
 
@@ -65,7 +72,7 @@ export interface FileMemoryBackendOptions {
65
72
  }
66
73
 
67
74
  /**
68
- * Default backend: append-only JSONL at `<stateRoot>/memory/journal.jsonl`
75
+ * Local default backend: append-only JSONL at `<stateRoot>/memory/journal.jsonl`
69
76
  * — the directory the framework symlinks into session workspaces. Rotated
70
77
  * segments stay alongside as `journal-<epoch-ms>.jsonl`.
71
78
  */
@@ -105,6 +112,112 @@ export function fileMemoryBackend(
105
112
  };
106
113
  }
107
114
 
115
+ export interface AgentStoreMemoryBackendOptions {
116
+ /** Sink override (tests). Defaults to the deployment's Agent Store. */
117
+ sink?: FileSink;
118
+ /** Rotation threshold, same meaning as {@link FileMemoryBackendOptions}. */
119
+ maxJournalBytes?: number;
120
+ }
121
+
122
+ /**
123
+ * Journal on the deployment's Agent Store — durable across deploys, visible
124
+ * on cloud VMs under the store mount. Appends are read-modify-write with
125
+ * etag preconditions (retried on a lost race), then mirrored to
126
+ * `<stateRoot>/memory/journal.jsonl` for the workspace symlink read path.
127
+ */
128
+ export function agentStoreMemoryBackend(
129
+ options: AgentStoreMemoryBackendOptions = {}
130
+ ): MemoryBackend {
131
+ const sink = options.sink ?? cursorHostedFiles();
132
+ const maxJournalBytes = options.maxJournalBytes ?? 5 * 1024 * 1024;
133
+ // Appends are chained per journal key (same shape as fileMemoryBackend);
134
+ // a failed append must not poison the chain for later turns.
135
+ const appendChains = new Map<string, Promise<void>>();
136
+
137
+ const append = async (
138
+ record: TurnMemoryRecord,
139
+ ctx: { stateRoot: string; agentName: string }
140
+ ): Promise<void> => {
141
+ const key = agentStoreKeys.memoryJournal(ctx.agentName);
142
+ const line = Buffer.from(`${JSON.stringify(record)}\n`, "utf8");
143
+ for (let attempt = 0; attempt < 3; attempt += 1) {
144
+ const current = await sink.get(key);
145
+ const currentBody =
146
+ current === undefined
147
+ ? new Uint8Array(0)
148
+ : current instanceof Uint8Array
149
+ ? current
150
+ : current.body;
151
+ const etag =
152
+ current === undefined || current instanceof Uint8Array
153
+ ? undefined
154
+ : current.etag;
155
+ let next: Uint8Array;
156
+ let rotatedStamp: string | undefined;
157
+ if (currentBody.byteLength >= maxJournalBytes) {
158
+ rotatedStamp = `${Date.now()}-${randomUUID().slice(0, 8)}`;
159
+ await sink.put(
160
+ agentStoreKeys.memoryJournalRotated(ctx.agentName, rotatedStamp),
161
+ currentBody,
162
+ { ifMatch: null }
163
+ );
164
+ next = line;
165
+ } else {
166
+ next = Buffer.concat([currentBody, line]);
167
+ }
168
+ try {
169
+ await sink.put(key, next, {
170
+ ifMatch: current === undefined ? null : etag,
171
+ });
172
+ } catch (error) {
173
+ if (error instanceof FileConflictError && attempt < 2) {
174
+ continue;
175
+ }
176
+ throw error;
177
+ }
178
+ await mirrorJournalLocally(ctx.stateRoot, next);
179
+ if (rotatedStamp !== undefined) {
180
+ // Rotated segments sit beside the live journal locally too, so the
181
+ // workspace symlink read path keeps pre-rotation history.
182
+ await writeFile(
183
+ join(ctx.stateRoot, MEMORY_DIR_NAME, `journal-${rotatedStamp}.jsonl`),
184
+ currentBody
185
+ );
186
+ }
187
+ return;
188
+ }
189
+ };
190
+
191
+ return {
192
+ async appendTurn(record, ctx) {
193
+ const key = agentStoreKeys.memoryJournal(ctx.agentName);
194
+ const prior = appendChains.get(key) ?? Promise.resolve();
195
+ const next = prior.catch(() => {}).then(() => append(record, ctx));
196
+ appendChains.set(key, next);
197
+ await next;
198
+ },
199
+ };
200
+ }
201
+
202
+ /** Atomic full rewrite of the local mirror; also hydrates a fresh pod after a deploy. */
203
+ async function mirrorJournalLocally(
204
+ stateRoot: string,
205
+ contents: Uint8Array
206
+ ): Promise<void> {
207
+ const dir = join(stateRoot, MEMORY_DIR_NAME);
208
+ await mkdir(dir, { recursive: true });
209
+ const tmp = join(dir, `.tmp-${randomUUID()}`);
210
+ await writeFile(tmp, contents);
211
+ await rename(tmp, join(dir, "journal.jsonl"));
212
+ }
213
+
214
+ /** Hosted deployments journal to the Agent Store; local dev to plain files. */
215
+ function defaultMemoryBackend(): MemoryBackend {
216
+ return isCursorHostedFilesAvailable()
217
+ ? agentStoreMemoryBackend()
218
+ : fileMemoryBackend();
219
+ }
220
+
108
221
  export interface MemoryHookOptions {
109
222
  /** Where records go. Defaults to {@link fileMemoryBackend}. */
110
223
  backend?: MemoryBackend;
@@ -126,7 +239,7 @@ function truncate(text: string, max: number): string {
126
239
  * ```
127
240
  */
128
241
  export function memoryHook(options: MemoryHookOptions = {}): HookDefinition {
129
- const backend = options.backend ?? fileMemoryBackend();
242
+ const backend = options.backend ?? defaultMemoryBackend();
130
243
  const maxTextLength = options.maxTextLength ?? 2000;
131
244
  // Inbound message per turn (truncated at receipt so large pastes are not
132
245
  // retained), keyed `<sessionId>/<turnId>` — `message.received` and the
@@ -167,7 +280,10 @@ export function memoryHook(options: MemoryHookOptions = {}): HookDefinition {
167
280
  if (usage !== undefined) {
168
281
  entry.usage = usage;
169
282
  }
170
- await backend.appendTurn(entry, { stateRoot: ctx.stateRoot });
283
+ await backend.appendTurn(entry, {
284
+ stateRoot: ctx.stateRoot,
285
+ agentName: ctx.agent.name,
286
+ });
171
287
  };
172
288
 
173
289
  const sweepSession = (ctx: HookContext): void => {
package/src/storage.ts CHANGED
@@ -276,7 +276,6 @@ export const STORAGE_KEY_ROOT = "agentkit/v1" as const;
276
276
  * | `agentkit/v1/{agent}/session-events/{sessionId}/{index}` | `SessionEvent[]` chunk (index = first event's index, zero-padded) |
277
277
  * | `agentkit/v1/{agent}/continuation/{channelId}/{token}` | `{ sessionId }` |
278
278
  * | `agentkit/v1/{agent}/kv/{key}` | Author JSON via {@link HostContext.kv} |
279
- * | `agentkit/v1/{agent}/artifacts/{id}` | `ArtifactRecord` via `ctx.artifacts` |
280
279
  *
281
280
  * Eval-run and A/B history do not flow through this KV scheme — they have
282
281
  * dedicated tables ({@link StorageConfig.evals} / {@link StorageConfig.abs}).
@@ -307,11 +306,6 @@ export const storageKeys = {
307
306
  kv: (agent: string, key: string): string =>
308
307
  `${STORAGE_KEY_ROOT}/${agent}/kv/${keySegment(key)}`,
309
308
  kvPrefix: (agent: string): string => `${STORAGE_KEY_ROOT}/${agent}/kv/`,
310
- /** Tagged artifact rows (see `ctx.artifacts` / `ArtifactsApi`). */
311
- artifact: (agent: string, id: string): string =>
312
- `${STORAGE_KEY_ROOT}/${agent}/artifacts/${keySegment(id)}`,
313
- artifactPrefix: (agent: string): string =>
314
- `${STORAGE_KEY_ROOT}/${agent}/artifacts/`,
315
309
  } as const;
316
310
 
317
311
  /**
package/src/types.ts CHANGED
@@ -1838,6 +1838,8 @@ export interface ArtifactRecord {
1838
1838
  key?: string;
1839
1839
  title?: string;
1840
1840
  data: JsonValue;
1841
+ /** Present when the artifact carries a file/blob payload (served at `GET /v1/artifacts/:id/content`). */
1842
+ content?: { size: number; contentType?: string };
1841
1843
  sessionId?: string;
1842
1844
  turnId?: string;
1843
1845
  source: ArtifactSource;
@@ -1853,6 +1855,13 @@ export interface ArtifactTagInput {
1853
1855
  title?: string;
1854
1856
  /** Upsert key: tagging the same key again replaces the row. */
1855
1857
  key?: string;
1858
+ /**
1859
+ * File/blob payload, served via `GET /v1/artifacts/:id/content`.
1860
+ * Re-tagging a keyed artifact without `contents` keeps the existing payload.
1861
+ */
1862
+ contents?: string | Uint8Array;
1863
+ /** MIME type reported when serving {@link contents}. */
1864
+ contentType?: string;
1856
1865
  /**
1857
1866
  * Session to attribute (and stream an `artifact.tagged` event to). On
1858
1867
  * session-bound facades ({@link ToolContext.artifacts},
@@ -2460,6 +2469,12 @@ export interface ServeOptions {
2460
2469
  * Local turns always use the loopback URL.
2461
2470
  */
2462
2471
  publicUrl?: string;
2472
+ /**
2473
+ * Authenticated HTTP MCP URL that proxies this hosted deployment's
2474
+ * `/v1/mcp/tools` endpoint. Cloud turns use it to call authored server tools
2475
+ * on the AgentSDK host. The resolved Cursor API key authenticates requests.
2476
+ */
2477
+ cloudToolsUrl?: string;
2463
2478
  /**
2464
2479
  * Pull GitHub webhook metadata from `/v0/scm-events` (Cursor account auth).
2465
2480
  * The stream is read as the host's Cursor user, so this requires a signed-in
@@ -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"}