@sideboard-ai/core 0.1.53 → 0.1.57

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 (30) hide show
  1. package/dist/agents/cursor-runner.cjs +83 -7
  2. package/dist/agents/cursor-runner.js +1 -1
  3. package/dist/{agents-KYACODJ3.js → agents-2YYWW723.js} +3 -3
  4. package/dist/{agents-KP7UJEHJ.js → agents-AQFEFKBL.js} +2 -2
  5. package/dist/{app-settings-LZP632KI.js → app-settings-2LQNRTBE.js} +3 -1
  6. package/dist/{app-settings-7XVDQJ7F.js → app-settings-73DI4B6T.js} +3 -1
  7. package/dist/{chunk-VG22SETP.js → chunk-3WJAUKIL.js} +83 -7
  8. package/dist/{chunk-GNML24AW.js → chunk-5DMYULLC.js} +1 -1
  9. package/dist/{chunk-A6HVEMIB.js → chunk-7F454EE2.js} +86 -11
  10. package/dist/{chunk-BZST4HMJ.js → chunk-C3J4GDW4.js} +172 -21
  11. package/dist/{chunk-HBJSHRY2.js → chunk-C4BCC5X5.js} +17 -1
  12. package/dist/{chunk-T5QQVXK3.js → chunk-DIOF73S2.js} +17 -1
  13. package/dist/{chunk-UEAHMGHW.js → chunk-DQJ5D42H.js} +16 -2
  14. package/dist/{chunk-YOWIYAVA.js → chunk-EBWEKG52.js} +36 -11
  15. package/dist/{chunk-XX5BB7NV.js → chunk-S42XDFKF.js} +36 -11
  16. package/dist/{chunk-LRLKJM3O.js → chunk-UA5NDAHL.js} +16 -2
  17. package/dist/{chunk-YDXQ72MD.js → chunk-V2DUTUNC.js} +1 -1
  18. package/dist/{coordinator-prompt-S6JZD5EF.js → coordinator-prompt-ICF36NUQ.js} +2 -1
  19. package/dist/{coordinator-prompt-6FXVTSFN.js → coordinator-prompt-RBKUNRPR.js} +2 -1
  20. package/dist/{global-workspace-EV4G2WMQ.js → global-workspace-667XLBW6.js} +3 -2
  21. package/dist/{global-workspace-MSX2K27Y.js → global-workspace-S7VLWPWG.js} +3 -2
  22. package/dist/index.cjs +338 -55
  23. package/dist/index.d.cts +36 -2
  24. package/dist/index.d.ts +36 -2
  25. package/dist/index.js +121 -40
  26. package/dist/mcp/run-stdio.cjs +332 -51
  27. package/dist/mcp/run-stdio.js +121 -41
  28. package/dist/{workspaces-AYTBR6KQ.js → workspaces-FPJJXXAE.js} +4 -3
  29. package/dist/{workspaces-3RQQZQRO.js → workspaces-LYIDE2VR.js} +4 -3
  30. package/package.json +1 -1
@@ -84,6 +84,75 @@ function usageFromCursor(usage) {
84
84
  cacheWriteTokens: usage.cacheWriteTokens ? Number(usage.cacheWriteTokens) : void 0
85
85
  };
86
86
  }
87
+ function asRecord(value) {
88
+ if (value && typeof value === "object" && !Array.isArray(value)) {
89
+ return value;
90
+ }
91
+ return void 0;
92
+ }
93
+ function normalizeCursorToolCall(name, args) {
94
+ const raw = asRecord(args);
95
+ const toolName = typeof raw?.toolName === "string" && raw.toolName.trim() ? raw.toolName.trim() : null;
96
+ const looksLikeMcp = name === "mcp" || toolName != null && (typeof raw?.providerIdentifier === "string" || asRecord(raw?.args) != null);
97
+ if (looksLikeMcp && toolName) {
98
+ const providerRaw = typeof raw.providerIdentifier === "string" && raw.providerIdentifier.trim() ? raw.providerIdentifier.trim() : "sideboard";
99
+ const provider = providerRaw.replace(/[^a-zA-Z0-9_-]/g, "_");
100
+ const nested = asRecord(raw.args);
101
+ return {
102
+ name: `mcp__${provider}__${toolName}`,
103
+ input: nested ?? { toolName }
104
+ };
105
+ }
106
+ return { name, input: raw };
107
+ }
108
+ function unwrapCursorToolResult(result) {
109
+ if (result == null) return void 0;
110
+ if (typeof result === "string") return result;
111
+ const rec = asRecord(result);
112
+ if (!rec) {
113
+ try {
114
+ return JSON.stringify(result);
115
+ } catch {
116
+ return String(result);
117
+ }
118
+ }
119
+ const collectTexts = (items) => {
120
+ const texts = [];
121
+ for (const item of items) {
122
+ const row = asRecord(item);
123
+ if (!row) continue;
124
+ if (typeof row.text === "string") {
125
+ texts.push(row.text);
126
+ continue;
127
+ }
128
+ const nested = asRecord(row.text);
129
+ if (typeof nested?.text === "string") texts.push(nested.text);
130
+ }
131
+ return texts;
132
+ };
133
+ const value = asRecord(rec.value);
134
+ if (value && Array.isArray(value.content)) {
135
+ const texts = collectTexts(value.content);
136
+ if (texts.length) return texts.join("\n");
137
+ }
138
+ if (Array.isArray(rec.content)) {
139
+ const texts = collectTexts(rec.content);
140
+ if (texts.length) return texts.join("\n");
141
+ }
142
+ try {
143
+ return JSON.stringify(result);
144
+ } catch {
145
+ return String(result);
146
+ }
147
+ }
148
+ function cursorToolResultIsError(status, result) {
149
+ if (status === "error") return true;
150
+ const rec = asRecord(result);
151
+ if (!rec) return false;
152
+ if (rec.status === "error") return true;
153
+ const value = asRecord(rec.value);
154
+ return value?.isError === true;
155
+ }
87
156
  function cursorSdkMessageToEvents(msg) {
88
157
  if (!msg?.type) return [];
89
158
  if (msg.type === "system" && msg.agent_id) {
@@ -98,35 +167,42 @@ function cursorSdkMessageToEvents(msg) {
98
167
  if (block?.type === "text" && block.text) {
99
168
  out.push({ type: "stdout", data: block.text });
100
169
  } else if (block?.type === "tool_use" && block.id && block.name) {
170
+ const normalized = normalizeCursorToolCall(block.name, block.input);
101
171
  out.push({
102
172
  type: "tool_use",
103
173
  id: block.id,
104
- name: block.name,
105
- input: block.input && typeof block.input === "object" ? block.input : void 0
174
+ name: normalized.name,
175
+ input: normalized.input
106
176
  });
107
177
  }
108
178
  }
109
179
  return out;
110
180
  }
111
181
  if (msg.type === "tool_call" && msg.call_id && msg.name) {
182
+ const normalized = normalizeCursorToolCall(msg.name, msg.args);
112
183
  if (msg.status === "running") {
113
184
  return [
114
185
  {
115
186
  type: "tool_use",
116
187
  id: msg.call_id,
117
- name: msg.name,
118
- input: msg.args && typeof msg.args === "object" ? msg.args : void 0
188
+ name: normalized.name,
189
+ input: normalized.input
119
190
  }
120
191
  ];
121
192
  }
122
193
  if (msg.status === "completed" || msg.status === "error") {
123
- const content = typeof msg.result === "string" ? msg.result : msg.result != null ? JSON.stringify(msg.result) : void 0;
124
194
  return [
195
+ {
196
+ type: "tool_use",
197
+ id: msg.call_id,
198
+ name: normalized.name,
199
+ input: normalized.input
200
+ },
125
201
  {
126
202
  type: "tool_result",
127
203
  id: msg.call_id,
128
- content,
129
- isError: msg.status === "error"
204
+ content: unwrapCursorToolResult(msg.result),
205
+ isError: cursorToolResultIsError(msg.status, msg.result)
130
206
  }
131
207
  ];
132
208
  }
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  cursorSdkMessageToEvents,
4
4
  formatUnknownDetail
5
- } from "../chunk-VG22SETP.js";
5
+ } from "../chunk-3WJAUKIL.js";
6
6
  import {
7
7
  appDataDir
8
8
  } from "../chunk-M37RITA6.js";
@@ -26,7 +26,7 @@ import {
26
26
  permissionMode,
27
27
  resolveCursorModelId,
28
28
  resolveQuotaFallbackAgent
29
- } from "./chunk-A6HVEMIB.js";
29
+ } from "./chunk-7F454EE2.js";
30
30
  import {
31
31
  ORCHESTRATOR_AGENT_KINDS,
32
32
  assertOrchestratorCapableAgent,
@@ -37,8 +37,8 @@ import "./chunk-BXJ76RHF.js";
37
37
  import {
38
38
  cursorSdkMessageToEvents,
39
39
  parseCursorRunnerLine
40
- } from "./chunk-VG22SETP.js";
41
- import "./chunk-T5QQVXK3.js";
40
+ } from "./chunk-3WJAUKIL.js";
41
+ import "./chunk-DIOF73S2.js";
42
42
  import "./chunk-77WWLBCI.js";
43
43
  import "./chunk-M37RITA6.js";
44
44
  import {
@@ -30,9 +30,8 @@ import {
30
30
  permissionMode,
31
31
  resolveCursorModelId,
32
32
  resolveQuotaFallbackAgent
33
- } from "./chunk-BZST4HMJ.js";
33
+ } from "./chunk-C3J4GDW4.js";
34
34
  import "./chunk-H6GGDLYS.js";
35
- import "./chunk-HBJSHRY2.js";
36
35
  import {
37
36
  ORCHESTRATOR_AGENT_KINDS,
38
37
  assertOrchestratorCapableAgent,
@@ -42,6 +41,7 @@ import {
42
41
  import {
43
42
  ensureAgentPath
44
43
  } from "./chunk-ZNM4MAN4.js";
44
+ import "./chunk-C4BCC5X5.js";
45
45
  import "./chunk-KGZBYWZ3.js";
46
46
  import "./chunk-7MV3RXSC.js";
47
47
  export {
@@ -27,6 +27,7 @@ import {
27
27
  orchestrationQuotaOnLimit,
28
28
  resolveClaudeExecutable,
29
29
  resolveEffectiveIssueSource,
30
+ resolveNewThreadOptions,
30
31
  resolveThreadDefaults,
31
32
  saveAppSettings,
32
33
  updateAdvancedSettings,
@@ -35,7 +36,7 @@ import {
35
36
  updateClaudeSettings,
36
37
  updateDefaultsSettings,
37
38
  updateIntegrationsSettings
38
- } from "./chunk-T5QQVXK3.js";
39
+ } from "./chunk-DIOF73S2.js";
39
40
  import "./chunk-77WWLBCI.js";
40
41
  import "./chunk-M37RITA6.js";
41
42
  export {
@@ -67,6 +68,7 @@ export {
67
68
  orchestrationQuotaOnLimit,
68
69
  resolveClaudeExecutable,
69
70
  resolveEffectiveIssueSource,
71
+ resolveNewThreadOptions,
70
72
  resolveThreadDefaults,
71
73
  saveAppSettings,
72
74
  updateAdvancedSettings,
@@ -29,6 +29,7 @@ import {
29
29
  orchestrationQuotaOnLimit,
30
30
  resolveClaudeExecutable,
31
31
  resolveEffectiveIssueSource,
32
+ resolveNewThreadOptions,
32
33
  resolveThreadDefaults,
33
34
  saveAppSettings,
34
35
  updateAdvancedSettings,
@@ -37,7 +38,7 @@ import {
37
38
  updateClaudeSettings,
38
39
  updateDefaultsSettings,
39
40
  updateIntegrationsSettings
40
- } from "./chunk-HBJSHRY2.js";
41
+ } from "./chunk-C4BCC5X5.js";
41
42
  import "./chunk-KGZBYWZ3.js";
42
43
  import "./chunk-7MV3RXSC.js";
43
44
  export {
@@ -69,6 +70,7 @@ export {
69
70
  orchestrationQuotaOnLimit,
70
71
  resolveClaudeExecutable,
71
72
  resolveEffectiveIssueSource,
73
+ resolveNewThreadOptions,
72
74
  resolveThreadDefaults,
73
75
  saveAppSettings,
74
76
  updateAdvancedSettings,
@@ -132,6 +132,75 @@ function usageFromCursor(usage) {
132
132
  cacheWriteTokens: usage.cacheWriteTokens ? Number(usage.cacheWriteTokens) : void 0
133
133
  };
134
134
  }
135
+ function asRecord(value) {
136
+ if (value && typeof value === "object" && !Array.isArray(value)) {
137
+ return value;
138
+ }
139
+ return void 0;
140
+ }
141
+ function normalizeCursorToolCall(name, args) {
142
+ const raw = asRecord(args);
143
+ const toolName = typeof raw?.toolName === "string" && raw.toolName.trim() ? raw.toolName.trim() : null;
144
+ const looksLikeMcp = name === "mcp" || toolName != null && (typeof raw?.providerIdentifier === "string" || asRecord(raw?.args) != null);
145
+ if (looksLikeMcp && toolName) {
146
+ const providerRaw = typeof raw.providerIdentifier === "string" && raw.providerIdentifier.trim() ? raw.providerIdentifier.trim() : "sideboard";
147
+ const provider = providerRaw.replace(/[^a-zA-Z0-9_-]/g, "_");
148
+ const nested = asRecord(raw.args);
149
+ return {
150
+ name: `mcp__${provider}__${toolName}`,
151
+ input: nested ?? { toolName }
152
+ };
153
+ }
154
+ return { name, input: raw };
155
+ }
156
+ function unwrapCursorToolResult(result) {
157
+ if (result == null) return void 0;
158
+ if (typeof result === "string") return result;
159
+ const rec = asRecord(result);
160
+ if (!rec) {
161
+ try {
162
+ return JSON.stringify(result);
163
+ } catch {
164
+ return String(result);
165
+ }
166
+ }
167
+ const collectTexts = (items) => {
168
+ const texts = [];
169
+ for (const item of items) {
170
+ const row = asRecord(item);
171
+ if (!row) continue;
172
+ if (typeof row.text === "string") {
173
+ texts.push(row.text);
174
+ continue;
175
+ }
176
+ const nested = asRecord(row.text);
177
+ if (typeof nested?.text === "string") texts.push(nested.text);
178
+ }
179
+ return texts;
180
+ };
181
+ const value = asRecord(rec.value);
182
+ if (value && Array.isArray(value.content)) {
183
+ const texts = collectTexts(value.content);
184
+ if (texts.length) return texts.join("\n");
185
+ }
186
+ if (Array.isArray(rec.content)) {
187
+ const texts = collectTexts(rec.content);
188
+ if (texts.length) return texts.join("\n");
189
+ }
190
+ try {
191
+ return JSON.stringify(result);
192
+ } catch {
193
+ return String(result);
194
+ }
195
+ }
196
+ function cursorToolResultIsError(status, result) {
197
+ if (status === "error") return true;
198
+ const rec = asRecord(result);
199
+ if (!rec) return false;
200
+ if (rec.status === "error") return true;
201
+ const value = asRecord(rec.value);
202
+ return value?.isError === true;
203
+ }
135
204
  function cursorSdkMessageToEvents(msg) {
136
205
  if (!msg?.type) return [];
137
206
  if (msg.type === "system" && msg.agent_id) {
@@ -146,35 +215,42 @@ function cursorSdkMessageToEvents(msg) {
146
215
  if (block?.type === "text" && block.text) {
147
216
  out.push({ type: "stdout", data: block.text });
148
217
  } else if (block?.type === "tool_use" && block.id && block.name) {
218
+ const normalized = normalizeCursorToolCall(block.name, block.input);
149
219
  out.push({
150
220
  type: "tool_use",
151
221
  id: block.id,
152
- name: block.name,
153
- input: block.input && typeof block.input === "object" ? block.input : void 0
222
+ name: normalized.name,
223
+ input: normalized.input
154
224
  });
155
225
  }
156
226
  }
157
227
  return out;
158
228
  }
159
229
  if (msg.type === "tool_call" && msg.call_id && msg.name) {
230
+ const normalized = normalizeCursorToolCall(msg.name, msg.args);
160
231
  if (msg.status === "running") {
161
232
  return [
162
233
  {
163
234
  type: "tool_use",
164
235
  id: msg.call_id,
165
- name: msg.name,
166
- input: msg.args && typeof msg.args === "object" ? msg.args : void 0
236
+ name: normalized.name,
237
+ input: normalized.input
167
238
  }
168
239
  ];
169
240
  }
170
241
  if (msg.status === "completed" || msg.status === "error") {
171
- const content = typeof msg.result === "string" ? msg.result : msg.result != null ? JSON.stringify(msg.result) : void 0;
172
242
  return [
243
+ {
244
+ type: "tool_use",
245
+ id: msg.call_id,
246
+ name: normalized.name,
247
+ input: normalized.input
248
+ },
173
249
  {
174
250
  type: "tool_result",
175
251
  id: msg.call_id,
176
- content,
177
- isError: msg.status === "error"
252
+ content: unwrapCursorToolResult(msg.result),
253
+ isError: cursorToolResultIsError(msg.status, msg.result)
178
254
  }
179
255
  ];
180
256
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isGlobalRepoPath
3
- } from "./chunk-XX5BB7NV.js";
3
+ } from "./chunk-S42XDFKF.js";
4
4
  import {
5
5
  ensureGhPreferOrigin,
6
6
  resolveRepoRoot
@@ -10,12 +10,12 @@ import {
10
10
  formatUnknownDetail,
11
11
  looksLikeAgentFailureMessage,
12
12
  parseCursorRunnerLine
13
- } from "./chunk-VG22SETP.js";
13
+ } from "./chunk-3WJAUKIL.js";
14
14
  import {
15
15
  claudeChromeEnabled,
16
16
  loadAppSettings,
17
17
  resolveClaudeExecutable
18
- } from "./chunk-T5QQVXK3.js";
18
+ } from "./chunk-DIOF73S2.js";
19
19
  import {
20
20
  ensureAgentPath,
21
21
  run
@@ -623,6 +623,7 @@ function toCodexMcpConfigArgs(servers) {
623
623
  args.push("-c", `${prefix}.env.${key}=${JSON.stringify(value)}`);
624
624
  }
625
625
  }
626
+ args.push("-c", `${prefix}.default_tools_approval_mode=${JSON.stringify("approve")}`);
626
627
  }
627
628
  return args;
628
629
  }
@@ -839,7 +840,7 @@ var claudeAdapter = {
839
840
  );
840
841
  }
841
842
  const mode = permissionMode(thread);
842
- const { isOrchestratorThread } = await import("./global-workspace-MSX2K27Y.js");
843
+ const { isOrchestratorThread } = await import("./global-workspace-S7VLWPWG.js");
843
844
  const isOrchestrator = isOrchestratorThread(thread);
844
845
  const injectedServers = await buildInjectedMcpServers({
845
846
  includeSideboard: true,
@@ -1099,6 +1100,32 @@ function codexConfigHasNetworkAccess() {
1099
1100
  }
1100
1101
  return false;
1101
1102
  }
1103
+ function unwrapCodexMcpResult(result) {
1104
+ if (result == null) return void 0;
1105
+ if (typeof result === "string") return result;
1106
+ if (typeof result !== "object") return String(result);
1107
+ const rec = result;
1108
+ if (Array.isArray(rec.content)) {
1109
+ const texts = [];
1110
+ for (const item of rec.content) {
1111
+ if (!item || typeof item !== "object") continue;
1112
+ const text = item.text;
1113
+ if (typeof text === "string") texts.push(text);
1114
+ }
1115
+ if (texts.length) return texts.join("\n");
1116
+ }
1117
+ try {
1118
+ return JSON.stringify(result);
1119
+ } catch {
1120
+ return String(result);
1121
+ }
1122
+ }
1123
+ function asRecord(value) {
1124
+ if (value && typeof value === "object" && !Array.isArray(value)) {
1125
+ return value;
1126
+ }
1127
+ return void 0;
1128
+ }
1102
1129
  var codexAdapter = {
1103
1130
  kind: "codex",
1104
1131
  async detect() {
@@ -1189,15 +1216,49 @@ var codexAdapter = {
1189
1216
  }
1190
1217
  if (typeof obj.item === "object" && obj.item !== null) {
1191
1218
  const item = obj.item;
1192
- if (item.type === "error") {
1219
+ const itemType = item.type ?? item.item_type;
1220
+ if (itemType === "error") {
1193
1221
  const detail = item.message?.trim() || extractJsonErrorMessage(obj) || "Codex item error";
1194
1222
  return { type: "stderr", data: detail };
1195
1223
  }
1196
- if (item.type === "agent_message" && item.text) {
1224
+ if (itemType === "agent_message" && item.text) {
1197
1225
  return { type: "stdout", data: item.text };
1198
1226
  }
1227
+ if (itemType === "mcp_tool_call" && item.id && item.server && item.tool) {
1228
+ const name = `mcp__${item.server}__${item.tool}`;
1229
+ const input = asRecord(item.arguments);
1230
+ const events = [
1231
+ { type: "tool_use", id: item.id, name, input }
1232
+ ];
1233
+ const finished = type === "item.completed" || item.status === "completed" || item.status === "failed";
1234
+ if (finished) {
1235
+ const errMsg = item.error && typeof item.error.message === "string" ? item.error.message : void 0;
1236
+ events.push({
1237
+ type: "tool_result",
1238
+ id: item.id,
1239
+ content: unwrapCodexMcpResult(item.result) ?? errMsg,
1240
+ isError: item.status === "failed" || Boolean(errMsg)
1241
+ });
1242
+ }
1243
+ return events.length === 1 ? events[0] : events;
1244
+ }
1245
+ if (itemType === "command_execution" && item.id) {
1246
+ const input = item.command ? { command: item.command } : void 0;
1247
+ const events = [
1248
+ { type: "tool_use", id: item.id, name: "Bash", input }
1249
+ ];
1250
+ if (type === "item.completed" || item.status === "completed" || item.status === "failed") {
1251
+ events.push({
1252
+ type: "tool_result",
1253
+ id: item.id,
1254
+ content: item.aggregated_output,
1255
+ isError: item.status === "failed"
1256
+ });
1257
+ }
1258
+ return events.length === 1 ? events[0] : events;
1259
+ }
1199
1260
  if (item.status === "failed") {
1200
- const detail = item.message?.trim() || extractJsonErrorMessage(item) || `Codex ${item.type ?? "item"} failed`;
1261
+ const detail = item.message?.trim() || extractJsonErrorMessage(item) || `Codex ${itemType ?? "item"} failed`;
1201
1262
  return { type: "stderr", data: detail };
1202
1263
  }
1203
1264
  }
@@ -1571,17 +1632,31 @@ var opencodeAdapter = {
1571
1632
  return { type: "stderr", data: detail };
1572
1633
  }
1573
1634
  const sid = typeof obj.sessionID === "string" && obj.sessionID || typeof obj.sessionId === "string" && obj.sessionId || typeof obj.session_id === "string" && obj.session_id;
1574
- if (sid) return { type: "session_id", data: sid };
1635
+ if (sid && (!obj.type || obj.type === "step_start" || obj.type === "session")) {
1636
+ return { type: "session_id", data: sid };
1637
+ }
1575
1638
  if (obj.type === "text") {
1576
1639
  const text = obj.part?.text ?? obj.text;
1577
1640
  if (text) return { type: "stdout", data: text };
1578
1641
  }
1579
1642
  if (obj.type === "tool_use") {
1580
1643
  const part = obj.part;
1581
- const id = part?.id ?? obj.id ?? `tool-${Date.now()}`;
1582
- const name = part?.name ?? part?.tool ?? obj.name ?? obj.tool ?? "tool";
1583
- const input = part?.input ?? obj.input;
1584
- return { type: "tool_use", id, name, input };
1644
+ const id = part?.callID ?? part?.id ?? obj.id ?? `tool-${Date.now()}`;
1645
+ const name = part?.tool ?? part?.name ?? obj.tool ?? obj.name ?? "tool";
1646
+ const state = part?.state;
1647
+ const input = (state?.input && typeof state.input === "object" ? state.input : void 0) ?? part?.input ?? obj.input;
1648
+ const events = [{ type: "tool_use", id, name, input }];
1649
+ const output = state?.output;
1650
+ if (output != null || state?.status === "completed" || state?.status === "error") {
1651
+ const content = typeof output === "string" ? output : output != null ? JSON.stringify(output) : formatUnknownDetail(state?.error) || void 0;
1652
+ events.push({
1653
+ type: "tool_result",
1654
+ id,
1655
+ content,
1656
+ isError: state?.status === "error" || state?.status === "failed"
1657
+ });
1658
+ }
1659
+ return events.length === 1 ? events[0] : events;
1585
1660
  }
1586
1661
  if (obj.type === "tool_result") {
1587
1662
  const part = obj.part;