@stablekernel/opencode-cursor 0.9.0 → 0.9.1-next.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.
@@ -14,13 +14,12 @@ import {
14
14
  resolveControls,
15
15
  resolveCursorApiKey,
16
16
  resolveSystemDelivery,
17
- resultText,
18
17
  sendAgentTurnSilently,
19
18
  setPreferredTransport,
20
19
  streamAgentTurn,
21
20
  unregisterSubagentCall,
22
21
  withSessionLock
23
- } from "../chunk-HWSH5L4H.js";
22
+ } from "../chunk-2R7BHCKG.js";
24
23
 
25
24
  // src/provider/index.ts
26
25
  import { NoSuchModelError } from "@ai-sdk/provider";
@@ -157,7 +156,6 @@ var SubagentTranscriptSink = class _SubagentTranscriptSink {
157
156
  session;
158
157
  text = "";
159
158
  reasoning = "";
160
- tools = [];
161
159
  pending = false;
162
160
  lastFlush = 0;
163
161
  timer;
@@ -197,8 +195,6 @@ var SubagentTranscriptSink = class _SubagentTranscriptSink {
197
195
  this.pending = true;
198
196
  break;
199
197
  case "tool-start": {
200
- this.tools.push(`**\`${event.name}\`** ${formatArgs(event.input)}`);
201
- this.pending = true;
202
198
  const key = this.nestedKey(event.id);
203
199
  const start = Date.now();
204
200
  this.enqueuePart(async () => {
@@ -224,8 +220,6 @@ var SubagentTranscriptSink = class _SubagentTranscriptSink {
224
220
  break;
225
221
  }
226
222
  case "tool-result": {
227
- this.tools.push(formatResult(event.name, event.result, event.isError));
228
- this.pending = true;
229
223
  const key = event.id || `result-${++this.anonSeq}`;
230
224
  this.enqueuePart(async () => {
231
225
  const handle = this.partHandles.get(key);
@@ -241,29 +235,37 @@ var SubagentTranscriptSink = class _SubagentTranscriptSink {
241
235
  end: Date.now()
242
236
  });
243
237
  });
244
- this.flushNow();
245
- return;
238
+ break;
246
239
  }
247
240
  }
248
241
  this.armTimer();
249
242
  }
250
243
  /**
251
- * Flush any buffered content, then append the subagent's final answer
252
- * (`resultSuffix`), a render of its `conversationSteps` (its own
253
- * text/thinking/tool activity), and the optional activity line, and mark
254
- * the sink done. Further pushes and flushes become no-ops.
244
+ * Merge the subagent's final answer (`resultSuffix`), a render of its
245
+ * `conversationSteps` (its own text/thinking/tool activity), and the
246
+ * optional activity line into the cumulative transcript, flush once, and
247
+ * mark the sink done. Further pushes and flushes become no-ops.
255
248
  */
256
249
  async finalize(resultValue, activity) {
257
250
  if (this.done) return;
258
251
  this.done = true;
259
252
  if (this.timer) clearTimeout(this.timer);
260
253
  this.timer = void 0;
261
- const body = this.render();
262
- if (body) await this.session.flush(body);
263
254
  const suffix = typeof resultValue === "object" && resultValue !== null ? resultValue["resultSuffix"] : void 0;
264
- if (typeof suffix === "string" && suffix) await this.session.flush(suffix);
255
+ if (typeof suffix === "string" && suffix) this.text += `
256
+
257
+ ${suffix}`;
265
258
  const steps = renderConversationSteps(resultValue);
266
- if (steps) await this.session.flush(steps);
259
+ if (steps) this.text += `
260
+
261
+ ${steps}`;
262
+ if (activity) this.text += `
263
+
264
+ ${activity}`;
265
+ if (this.text.trim() || this.reasoning.trim()) {
266
+ this.pending = false;
267
+ await this.session.flush(this.render());
268
+ }
267
269
  await this.partChain;
268
270
  for (const [, handle] of this.partHandles) {
269
271
  await this.session.toolPart({
@@ -278,8 +280,7 @@ var SubagentTranscriptSink = class _SubagentTranscriptSink {
278
280
  });
279
281
  }
280
282
  this.partHandles.clear();
281
- if (activity) await this.session.finalize(activity);
282
- else await this.session.finalize();
283
+ await this.session.finalize();
283
284
  }
284
285
  armTimer() {
285
286
  if (this.done || this.timer) return;
@@ -303,39 +304,18 @@ var SubagentTranscriptSink = class _SubagentTranscriptSink {
303
304
  this.lastFlush = Date.now();
304
305
  if (body) void this.session.flush(body);
305
306
  }
306
- /** Render the accumulated activity into a single markdown message. */
307
+ /**
308
+ * Render the FULL cumulative transcript (everything pushed so far, plus
309
+ * finalize additions). `flush` replaces the growing message's text with
310
+ * this, so each flush carries the whole transcript, not just new content.
311
+ */
307
312
  render() {
308
313
  const parts = [];
309
314
  if (this.text.trim()) parts.push(this.text.trim());
310
315
  if (this.reasoning.trim()) parts.push(`> ${this.reasoning.trim()}`);
311
- if (this.tools.length > 0) parts.push(this.tools.join("\n\n"));
312
- const body = parts.join("\n\n").trim();
313
- this.text = "";
314
- this.reasoning = "";
315
- this.tools.length = 0;
316
- return body;
316
+ return parts.join("\n\n").trim();
317
317
  }
318
318
  };
319
- function formatArgs(input) {
320
- let s = "";
321
- try {
322
- s = typeof input === "string" ? input : JSON.stringify(input);
323
- } catch {
324
- return "";
325
- }
326
- if (!s || s === "{}" || s === '""') return "";
327
- return s;
328
- }
329
- function formatResult(name, result, isError) {
330
- if (isError) return `**\`${name}\`** \u2014 _failed_`;
331
- const text = resultText(result);
332
- if (!text) return `**\`${name}\`** \u2014 _done_`;
333
- return `**\`${name}\`**
334
-
335
- \`\`\`
336
- ${text}
337
- \`\`\``;
338
- }
339
319
 
340
320
  // src/provider/stream-map.ts
341
321
  var TASK_TOOL_NAME = "task";