@mastra/cursor 0.0.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.
- package/CHANGELOG.md +34 -0
- package/README.md +93 -0
- package/dist/docs/SKILL.md +22 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/docs-agents-sdk-agents.md +261 -0
- package/dist/index.cjs +1041 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1039 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +138 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +65 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1039 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
import { ReadableStream, TransformStream } from 'stream/web';
|
|
3
|
+
import { Agent as Agent$1 } from '@cursor/sdk';
|
|
4
|
+
import { Agent } from '@mastra/core/agent';
|
|
5
|
+
import { RequestContext } from '@mastra/core/request-context';
|
|
6
|
+
import { ChunkFrom, MastraModelOutput } from '@mastra/core/stream';
|
|
7
|
+
import { MessageList } from '@mastra/core/agent/message-list';
|
|
8
|
+
import { getOrCreateSpan, EntityType, SpanType, executeWithContext } from '@mastra/core/observability';
|
|
9
|
+
|
|
10
|
+
// src/index.ts
|
|
11
|
+
function createNoopModel({ modelId, provider }) {
|
|
12
|
+
return {
|
|
13
|
+
modelId,
|
|
14
|
+
provider,
|
|
15
|
+
specificationVersion: "v3",
|
|
16
|
+
supportedUrls: {},
|
|
17
|
+
doGenerate: async () => createNoopStreamResult(),
|
|
18
|
+
doStream: async () => createNoopStreamResult()
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function createNoopStreamResult() {
|
|
22
|
+
return {
|
|
23
|
+
stream: new ReadableStream({
|
|
24
|
+
start: (controller) => controller.close()
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function createCompletedMastraStream({
|
|
29
|
+
runId,
|
|
30
|
+
prompt,
|
|
31
|
+
text,
|
|
32
|
+
responseId,
|
|
33
|
+
modelId,
|
|
34
|
+
usage,
|
|
35
|
+
providerMetadata,
|
|
36
|
+
costContext
|
|
37
|
+
}) {
|
|
38
|
+
return new ReadableStream({
|
|
39
|
+
start(controller) {
|
|
40
|
+
const textId = randomUUID();
|
|
41
|
+
enqueueStartChunks(controller, {
|
|
42
|
+
runId,
|
|
43
|
+
prompt,
|
|
44
|
+
textId,
|
|
45
|
+
responseId,
|
|
46
|
+
modelId,
|
|
47
|
+
providerMetadata
|
|
48
|
+
});
|
|
49
|
+
if (text) {
|
|
50
|
+
enqueueTextDelta(controller, runId, textId, text);
|
|
51
|
+
}
|
|
52
|
+
enqueueFinishChunks(controller, {
|
|
53
|
+
runId,
|
|
54
|
+
prompt,
|
|
55
|
+
textId,
|
|
56
|
+
text,
|
|
57
|
+
responseId,
|
|
58
|
+
modelId,
|
|
59
|
+
usage,
|
|
60
|
+
providerMetadata,
|
|
61
|
+
costContext
|
|
62
|
+
});
|
|
63
|
+
controller.close();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function createMastraOutput({
|
|
68
|
+
messages,
|
|
69
|
+
runId,
|
|
70
|
+
modelId,
|
|
71
|
+
provider,
|
|
72
|
+
stream,
|
|
73
|
+
options
|
|
74
|
+
}) {
|
|
75
|
+
const messageList = new MessageList();
|
|
76
|
+
messageList.add(messages, "input");
|
|
77
|
+
messageList.add([{ role: "assistant", content: "" }], "response");
|
|
78
|
+
return new MastraModelOutput({
|
|
79
|
+
model: {
|
|
80
|
+
modelId,
|
|
81
|
+
provider,
|
|
82
|
+
version: "v3"
|
|
83
|
+
},
|
|
84
|
+
stream,
|
|
85
|
+
messageList,
|
|
86
|
+
messageId: randomUUID(),
|
|
87
|
+
options: {
|
|
88
|
+
...options,
|
|
89
|
+
runId
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function toFullOutput({
|
|
94
|
+
messages,
|
|
95
|
+
runId,
|
|
96
|
+
provider,
|
|
97
|
+
result,
|
|
98
|
+
options
|
|
99
|
+
}) {
|
|
100
|
+
const text = result.content.map((part) => part.text).join("");
|
|
101
|
+
const stream = createCompletedMastraStream({
|
|
102
|
+
runId,
|
|
103
|
+
prompt: promptToText(messages),
|
|
104
|
+
text,
|
|
105
|
+
responseId: result.response.id,
|
|
106
|
+
modelId: result.response.modelId,
|
|
107
|
+
usage: toLanguageModelUsage(result.usage),
|
|
108
|
+
providerMetadata: result.providerMetadata,
|
|
109
|
+
costContext: result.costContext
|
|
110
|
+
});
|
|
111
|
+
return createMastraOutput({
|
|
112
|
+
messages,
|
|
113
|
+
runId,
|
|
114
|
+
modelId: result.response.modelId,
|
|
115
|
+
provider,
|
|
116
|
+
stream,
|
|
117
|
+
options
|
|
118
|
+
}).getFullOutput();
|
|
119
|
+
}
|
|
120
|
+
function createSDKAgentTelemetry({
|
|
121
|
+
agentId,
|
|
122
|
+
agentName,
|
|
123
|
+
provider,
|
|
124
|
+
modelId,
|
|
125
|
+
messages,
|
|
126
|
+
prompt,
|
|
127
|
+
runId,
|
|
128
|
+
streaming,
|
|
129
|
+
method,
|
|
130
|
+
requestContext,
|
|
131
|
+
instructions,
|
|
132
|
+
maxSteps,
|
|
133
|
+
tracingOptions,
|
|
134
|
+
tracingContext,
|
|
135
|
+
onFinish,
|
|
136
|
+
onStepFinish,
|
|
137
|
+
mastra
|
|
138
|
+
}) {
|
|
139
|
+
const agentSpan = getOrCreateSpan({
|
|
140
|
+
type: SpanType.AGENT_RUN,
|
|
141
|
+
name: `agent run: '${agentId}'`,
|
|
142
|
+
entityType: EntityType.AGENT,
|
|
143
|
+
entityId: agentId,
|
|
144
|
+
entityName: agentName,
|
|
145
|
+
input: messages,
|
|
146
|
+
attributes: {
|
|
147
|
+
prompt,
|
|
148
|
+
instructions,
|
|
149
|
+
maxSteps
|
|
150
|
+
},
|
|
151
|
+
metadata: {
|
|
152
|
+
runId,
|
|
153
|
+
sdkAgent: true,
|
|
154
|
+
sdkProvider: provider,
|
|
155
|
+
sdkMethod: method
|
|
156
|
+
},
|
|
157
|
+
tracingOptions,
|
|
158
|
+
tracingContext,
|
|
159
|
+
requestContext,
|
|
160
|
+
mastra
|
|
161
|
+
});
|
|
162
|
+
const modelSpan = agentSpan?.createChildSpan({
|
|
163
|
+
type: SpanType.MODEL_GENERATION,
|
|
164
|
+
name: `llm: '${modelId}'`,
|
|
165
|
+
input: {
|
|
166
|
+
messages
|
|
167
|
+
},
|
|
168
|
+
attributes: {
|
|
169
|
+
model: modelId,
|
|
170
|
+
provider,
|
|
171
|
+
streaming
|
|
172
|
+
},
|
|
173
|
+
metadata: {
|
|
174
|
+
runId,
|
|
175
|
+
sdkAgent: true,
|
|
176
|
+
sdkProvider: provider,
|
|
177
|
+
sdkMethod: method
|
|
178
|
+
},
|
|
179
|
+
requestContext
|
|
180
|
+
});
|
|
181
|
+
const modelSpanTracker = getModelSpanTracker(modelSpan);
|
|
182
|
+
const toolSpans = /* @__PURE__ */ new Map();
|
|
183
|
+
let ended = false;
|
|
184
|
+
const startToolCall = ({ toolCallId, toolName, input }) => {
|
|
185
|
+
if (toolSpans.has(toolCallId)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const parentSpan = agentSpan ?? modelSpan;
|
|
189
|
+
if (!parentSpan) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const mcp = parseMcpToolName(toolName);
|
|
193
|
+
const span = mcp ? parentSpan.createChildSpan({
|
|
194
|
+
type: SpanType.MCP_TOOL_CALL,
|
|
195
|
+
name: `mcp_tool: '${toolName}' on '${mcp.serverName}'`,
|
|
196
|
+
input,
|
|
197
|
+
entityType: EntityType.TOOL,
|
|
198
|
+
entityId: toolName,
|
|
199
|
+
entityName: toolName,
|
|
200
|
+
attributes: {
|
|
201
|
+
mcpServer: mcp.serverName
|
|
202
|
+
},
|
|
203
|
+
metadata: {
|
|
204
|
+
runId,
|
|
205
|
+
sdkAgent: true,
|
|
206
|
+
sdkProvider: provider,
|
|
207
|
+
sdkMethod: method,
|
|
208
|
+
toolCallId
|
|
209
|
+
},
|
|
210
|
+
requestContext
|
|
211
|
+
}) : parentSpan.createChildSpan({
|
|
212
|
+
type: SpanType.TOOL_CALL,
|
|
213
|
+
name: `tool: '${toolName}'`,
|
|
214
|
+
input,
|
|
215
|
+
entityType: EntityType.TOOL,
|
|
216
|
+
entityId: toolName,
|
|
217
|
+
entityName: toolName,
|
|
218
|
+
attributes: {
|
|
219
|
+
toolType: "tool"
|
|
220
|
+
},
|
|
221
|
+
metadata: {
|
|
222
|
+
runId,
|
|
223
|
+
sdkAgent: true,
|
|
224
|
+
sdkProvider: provider,
|
|
225
|
+
sdkMethod: method,
|
|
226
|
+
toolCallId
|
|
227
|
+
},
|
|
228
|
+
requestContext
|
|
229
|
+
});
|
|
230
|
+
toolSpans.set(toolCallId, span);
|
|
231
|
+
};
|
|
232
|
+
const endToolCall = ({ toolCallId, output, isError }) => {
|
|
233
|
+
const span = toolSpans.get(toolCallId);
|
|
234
|
+
if (!span) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
toolSpans.delete(toolCallId);
|
|
238
|
+
if (isError) {
|
|
239
|
+
span.error({
|
|
240
|
+
error: output instanceof Error ? output : new Error(typeof output === "string" ? output : "SDK tool call failed"),
|
|
241
|
+
attributes: { success: false }
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
span.end({
|
|
246
|
+
output,
|
|
247
|
+
attributes: { success: true }
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
const closeOpenToolSpans = (success, error) => {
|
|
251
|
+
for (const [toolCallId, span] of toolSpans) {
|
|
252
|
+
toolSpans.delete(toolCallId);
|
|
253
|
+
if (success) {
|
|
254
|
+
span.end({ attributes: { success: true } });
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const normalized = error instanceof Error ? error : new Error(String(error ?? "SDK agent run failed"));
|
|
258
|
+
span.error({ error: normalized, attributes: { success: false } });
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
const endModel = ({
|
|
262
|
+
text,
|
|
263
|
+
usage,
|
|
264
|
+
providerMetadata,
|
|
265
|
+
finishReason = "stop",
|
|
266
|
+
responseId,
|
|
267
|
+
responseModel,
|
|
268
|
+
costContext
|
|
269
|
+
}) => {
|
|
270
|
+
if (modelSpanTracker) {
|
|
271
|
+
modelSpanTracker.endGeneration({
|
|
272
|
+
output: {
|
|
273
|
+
text
|
|
274
|
+
},
|
|
275
|
+
attributes: {
|
|
276
|
+
finishReason,
|
|
277
|
+
responseId,
|
|
278
|
+
responseModel,
|
|
279
|
+
costContext
|
|
280
|
+
},
|
|
281
|
+
usage,
|
|
282
|
+
providerMetadata
|
|
283
|
+
});
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
modelSpan?.end({
|
|
287
|
+
output: {
|
|
288
|
+
text
|
|
289
|
+
},
|
|
290
|
+
attributes: {
|
|
291
|
+
finishReason,
|
|
292
|
+
responseId,
|
|
293
|
+
responseModel,
|
|
294
|
+
usage: usage ? toUsageStats(usage) : void 0,
|
|
295
|
+
costContext
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
const end = (result) => {
|
|
300
|
+
if (ended) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
ended = true;
|
|
304
|
+
closeOpenToolSpans(true);
|
|
305
|
+
endModel(result);
|
|
306
|
+
agentSpan?.end({
|
|
307
|
+
output: {
|
|
308
|
+
text: result.text
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
const fail = (error) => {
|
|
313
|
+
if (ended) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
ended = true;
|
|
317
|
+
const normalized = error instanceof Error ? error : new Error(String(error));
|
|
318
|
+
closeOpenToolSpans(false, normalized);
|
|
319
|
+
if (modelSpanTracker) {
|
|
320
|
+
modelSpanTracker.reportGenerationError({ error: normalized });
|
|
321
|
+
} else {
|
|
322
|
+
modelSpan?.error({ error: normalized });
|
|
323
|
+
}
|
|
324
|
+
agentSpan?.error({ error: normalized });
|
|
325
|
+
};
|
|
326
|
+
return {
|
|
327
|
+
execute: (fn) => executeWithContext({ span: modelSpan ?? agentSpan, fn }),
|
|
328
|
+
endGenerate(result) {
|
|
329
|
+
end({
|
|
330
|
+
text: result.content.map((part) => part.text).join(""),
|
|
331
|
+
usage: toLanguageModelUsage(result.usage),
|
|
332
|
+
providerMetadata: result.providerMetadata,
|
|
333
|
+
finishReason: result.finishReason.unified,
|
|
334
|
+
responseId: result.response.id,
|
|
335
|
+
responseModel: result.response.modelId,
|
|
336
|
+
costContext: result.costContext
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
fail,
|
|
340
|
+
startToolCall,
|
|
341
|
+
endToolCall,
|
|
342
|
+
wrapStream(stream) {
|
|
343
|
+
const trackedStream = modelSpanTracker?.wrapStream(stream) ?? stream;
|
|
344
|
+
return wrapStreamForAgentSpan(trackedStream, {
|
|
345
|
+
end,
|
|
346
|
+
fail
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
outputOptions() {
|
|
350
|
+
return {
|
|
351
|
+
onFinish,
|
|
352
|
+
onStepFinish,
|
|
353
|
+
requestContext,
|
|
354
|
+
tracingContext: agentSpan ? { currentSpan: agentSpan } : tracingContext
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
function parseMcpToolName(toolName) {
|
|
360
|
+
const match = /^mcp__([^_].*?)__(.+)$/.exec(toolName);
|
|
361
|
+
if (!match?.[1] || !match[2]) {
|
|
362
|
+
return void 0;
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
serverName: match[1],
|
|
366
|
+
toolName: match[2]
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function getModelSpanTracker(modelSpan) {
|
|
370
|
+
if (!modelSpan || !("createTracker" in modelSpan)) {
|
|
371
|
+
return void 0;
|
|
372
|
+
}
|
|
373
|
+
return modelSpan.createTracker();
|
|
374
|
+
}
|
|
375
|
+
function wrapStreamForAgentSpan(stream, telemetry) {
|
|
376
|
+
let text = "";
|
|
377
|
+
return stream.pipeThrough(
|
|
378
|
+
new TransformStream({
|
|
379
|
+
transform(chunk, controller) {
|
|
380
|
+
if (chunk.type === "text-delta") {
|
|
381
|
+
text += chunk.payload.text;
|
|
382
|
+
}
|
|
383
|
+
if (chunk.type === "finish") {
|
|
384
|
+
telemetry.end({
|
|
385
|
+
text,
|
|
386
|
+
usage: chunk.payload.output.usage,
|
|
387
|
+
providerMetadata: chunk.payload.providerMetadata,
|
|
388
|
+
finishReason: chunk.payload.stepResult.reason,
|
|
389
|
+
responseId: chunk.payload.response?.id,
|
|
390
|
+
responseModel: chunk.payload.response?.modelId,
|
|
391
|
+
costContext: getCostContext(chunk.payload.metadata?.costContext)
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
if (chunk.type === "error") {
|
|
395
|
+
telemetry.fail(chunk.payload.error);
|
|
396
|
+
}
|
|
397
|
+
controller.enqueue(chunk);
|
|
398
|
+
},
|
|
399
|
+
flush() {
|
|
400
|
+
telemetry.end({ text });
|
|
401
|
+
}
|
|
402
|
+
})
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
function toUsageStats(usage) {
|
|
406
|
+
return {
|
|
407
|
+
inputTokens: usage.inputTokens,
|
|
408
|
+
outputTokens: usage.outputTokens,
|
|
409
|
+
inputDetails: {
|
|
410
|
+
cacheRead: usage.cachedInputTokens,
|
|
411
|
+
cacheWrite: usage.cacheCreationInputTokens
|
|
412
|
+
},
|
|
413
|
+
outputDetails: {
|
|
414
|
+
text: usage.outputTokens,
|
|
415
|
+
reasoning: usage.reasoningTokens
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function getCostContext(value) {
|
|
420
|
+
if (!value || typeof value !== "object") {
|
|
421
|
+
return void 0;
|
|
422
|
+
}
|
|
423
|
+
return value;
|
|
424
|
+
}
|
|
425
|
+
function enqueueStartChunks(controller, {
|
|
426
|
+
runId,
|
|
427
|
+
prompt,
|
|
428
|
+
textId,
|
|
429
|
+
responseId,
|
|
430
|
+
modelId,
|
|
431
|
+
providerMetadata
|
|
432
|
+
}) {
|
|
433
|
+
controller.enqueue({
|
|
434
|
+
type: "start",
|
|
435
|
+
runId,
|
|
436
|
+
from: ChunkFrom.AGENT,
|
|
437
|
+
payload: {}
|
|
438
|
+
});
|
|
439
|
+
controller.enqueue({
|
|
440
|
+
type: "step-start",
|
|
441
|
+
runId,
|
|
442
|
+
from: ChunkFrom.AGENT,
|
|
443
|
+
payload: {
|
|
444
|
+
request: { body: prompt }
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
controller.enqueue({
|
|
448
|
+
type: "response-metadata",
|
|
449
|
+
runId,
|
|
450
|
+
from: ChunkFrom.AGENT,
|
|
451
|
+
payload: {
|
|
452
|
+
id: responseId,
|
|
453
|
+
modelId,
|
|
454
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
controller.enqueue({
|
|
458
|
+
type: "text-start",
|
|
459
|
+
runId,
|
|
460
|
+
from: ChunkFrom.AGENT,
|
|
461
|
+
payload: {
|
|
462
|
+
id: textId,
|
|
463
|
+
providerMetadata
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function enqueueTextDelta(controller, runId, textId, text) {
|
|
468
|
+
controller.enqueue({
|
|
469
|
+
type: "text-delta",
|
|
470
|
+
runId,
|
|
471
|
+
from: ChunkFrom.AGENT,
|
|
472
|
+
payload: {
|
|
473
|
+
id: textId,
|
|
474
|
+
text
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
function enqueueFinishChunks(controller, {
|
|
479
|
+
runId,
|
|
480
|
+
prompt,
|
|
481
|
+
textId,
|
|
482
|
+
text,
|
|
483
|
+
responseId,
|
|
484
|
+
modelId,
|
|
485
|
+
usage,
|
|
486
|
+
providerMetadata,
|
|
487
|
+
costContext
|
|
488
|
+
}) {
|
|
489
|
+
const timestamp = /* @__PURE__ */ new Date();
|
|
490
|
+
const response = {
|
|
491
|
+
id: responseId,
|
|
492
|
+
modelId,
|
|
493
|
+
timestamp
|
|
494
|
+
};
|
|
495
|
+
const metadata = {
|
|
496
|
+
providerMetadata,
|
|
497
|
+
costContext,
|
|
498
|
+
request: { body: prompt },
|
|
499
|
+
modelId,
|
|
500
|
+
timestamp
|
|
501
|
+
};
|
|
502
|
+
controller.enqueue({
|
|
503
|
+
type: "text-end",
|
|
504
|
+
runId,
|
|
505
|
+
from: ChunkFrom.AGENT,
|
|
506
|
+
payload: {
|
|
507
|
+
id: textId,
|
|
508
|
+
providerMetadata
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
controller.enqueue({
|
|
512
|
+
type: "step-finish",
|
|
513
|
+
runId,
|
|
514
|
+
from: ChunkFrom.AGENT,
|
|
515
|
+
payload: {
|
|
516
|
+
id: responseId,
|
|
517
|
+
providerMetadata,
|
|
518
|
+
totalUsage: usage,
|
|
519
|
+
response,
|
|
520
|
+
stepResult: {
|
|
521
|
+
reason: "stop",
|
|
522
|
+
warnings: []
|
|
523
|
+
},
|
|
524
|
+
output: {
|
|
525
|
+
text,
|
|
526
|
+
usage,
|
|
527
|
+
steps: []
|
|
528
|
+
},
|
|
529
|
+
metadata
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
controller.enqueue({
|
|
533
|
+
type: "finish",
|
|
534
|
+
runId,
|
|
535
|
+
from: ChunkFrom.AGENT,
|
|
536
|
+
payload: {
|
|
537
|
+
stepResult: {
|
|
538
|
+
reason: "stop",
|
|
539
|
+
warnings: []
|
|
540
|
+
},
|
|
541
|
+
output: {
|
|
542
|
+
usage,
|
|
543
|
+
steps: []
|
|
544
|
+
},
|
|
545
|
+
metadata,
|
|
546
|
+
providerMetadata,
|
|
547
|
+
messages: {
|
|
548
|
+
all: [],
|
|
549
|
+
user: [],
|
|
550
|
+
nonUser: []
|
|
551
|
+
},
|
|
552
|
+
response
|
|
553
|
+
}
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
function toLanguageModelUsage(usage) {
|
|
557
|
+
const inputTokens = usage.inputTokens.total ?? 0;
|
|
558
|
+
const outputTokens = usage.outputTokens.total ?? 0;
|
|
559
|
+
return {
|
|
560
|
+
inputTokens,
|
|
561
|
+
outputTokens,
|
|
562
|
+
totalTokens: inputTokens + outputTokens,
|
|
563
|
+
cachedInputTokens: usage.inputTokens.cacheRead,
|
|
564
|
+
cacheCreationInputTokens: usage.inputTokens.cacheWrite,
|
|
565
|
+
raw: usage
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function createProviderMetadata(provider, metadata) {
|
|
569
|
+
return {
|
|
570
|
+
[provider]: toJsonRecord(metadata)
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
function toJsonRecord(record) {
|
|
574
|
+
return Object.fromEntries(
|
|
575
|
+
Object.entries(record).filter((entry) => entry[1] !== void 0).map(([key, value]) => [key, toJsonValue(value)])
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
function toJsonValue(value) {
|
|
579
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
580
|
+
return value;
|
|
581
|
+
}
|
|
582
|
+
if (Array.isArray(value)) {
|
|
583
|
+
return value.filter((item) => item !== void 0).map(toJsonValue);
|
|
584
|
+
}
|
|
585
|
+
if (value instanceof Date) {
|
|
586
|
+
return value.toISOString();
|
|
587
|
+
}
|
|
588
|
+
if (typeof value === "object") {
|
|
589
|
+
return toJsonRecord(value);
|
|
590
|
+
}
|
|
591
|
+
return String(value);
|
|
592
|
+
}
|
|
593
|
+
function promptToText(prompt) {
|
|
594
|
+
if (typeof prompt === "string") {
|
|
595
|
+
return prompt;
|
|
596
|
+
}
|
|
597
|
+
if (Array.isArray(prompt)) {
|
|
598
|
+
return prompt.map(promptToText).filter(Boolean).join("\n");
|
|
599
|
+
}
|
|
600
|
+
if (!prompt || typeof prompt !== "object") {
|
|
601
|
+
return "";
|
|
602
|
+
}
|
|
603
|
+
const record = prompt;
|
|
604
|
+
if (typeof record.text === "string") {
|
|
605
|
+
return record.text;
|
|
606
|
+
}
|
|
607
|
+
if (typeof record.content === "string") {
|
|
608
|
+
return record.content;
|
|
609
|
+
}
|
|
610
|
+
if (record.content) {
|
|
611
|
+
return promptToText(record.content);
|
|
612
|
+
}
|
|
613
|
+
return "";
|
|
614
|
+
}
|
|
615
|
+
function sumDefined(...values) {
|
|
616
|
+
const defined = values.filter((value) => typeof value === "number");
|
|
617
|
+
if (defined.length === 0) {
|
|
618
|
+
return void 0;
|
|
619
|
+
}
|
|
620
|
+
return defined.reduce((sum, value) => sum + value, 0);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
// src/index.ts
|
|
624
|
+
var PROVIDER = "@cursor/sdk";
|
|
625
|
+
var MODEL_ID = "cursor-agent-sdk";
|
|
626
|
+
var CursorSDKAgent = class extends Agent {
|
|
627
|
+
options;
|
|
628
|
+
#mastra;
|
|
629
|
+
#createdAgent;
|
|
630
|
+
constructor(options) {
|
|
631
|
+
super({
|
|
632
|
+
id: options.id,
|
|
633
|
+
name: options.name ?? options.id,
|
|
634
|
+
description: options.description,
|
|
635
|
+
instructions: "",
|
|
636
|
+
model: createNoopModel({
|
|
637
|
+
modelId: getModelId(getRequestedModel(options)),
|
|
638
|
+
provider: PROVIDER
|
|
639
|
+
})
|
|
640
|
+
});
|
|
641
|
+
this.options = options;
|
|
642
|
+
}
|
|
643
|
+
__registerMastra(mastra) {
|
|
644
|
+
super.__registerMastra(mastra);
|
|
645
|
+
this.#mastra = mastra;
|
|
646
|
+
}
|
|
647
|
+
supportsMemory() {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
async generate(messages, options) {
|
|
651
|
+
const prompt = promptToText(messages);
|
|
652
|
+
const runId = options?.runId ?? randomUUID();
|
|
653
|
+
const sdkAgent = await this.resolveCursorAgent();
|
|
654
|
+
const modelId = getCursorModelId(this.options, sdkAgent);
|
|
655
|
+
const requestContext = options?.requestContext ?? new RequestContext();
|
|
656
|
+
const instructions = options?.instructions ? promptToText(options.instructions) : void 0;
|
|
657
|
+
const telemetry = createSDKAgentTelemetry({
|
|
658
|
+
agentId: this.id,
|
|
659
|
+
agentName: this.name,
|
|
660
|
+
provider: PROVIDER,
|
|
661
|
+
modelId,
|
|
662
|
+
messages,
|
|
663
|
+
prompt,
|
|
664
|
+
runId,
|
|
665
|
+
streaming: false,
|
|
666
|
+
method: "generate",
|
|
667
|
+
requestContext,
|
|
668
|
+
instructions,
|
|
669
|
+
maxSteps: options?.maxSteps,
|
|
670
|
+
tracingOptions: options?.tracingOptions,
|
|
671
|
+
tracingContext: options?.tracingContext,
|
|
672
|
+
onFinish: options?.onFinish,
|
|
673
|
+
onStepFinish: options?.onStepFinish,
|
|
674
|
+
mastra: this.#mastra
|
|
675
|
+
});
|
|
676
|
+
let result;
|
|
677
|
+
try {
|
|
678
|
+
result = await telemetry.execute(() => runCursorGenerate(prompt, this.options, sdkAgent, telemetry));
|
|
679
|
+
telemetry.endGenerate(result);
|
|
680
|
+
} catch (error) {
|
|
681
|
+
telemetry.fail(error);
|
|
682
|
+
throw error;
|
|
683
|
+
}
|
|
684
|
+
return toFullOutput({
|
|
685
|
+
messages,
|
|
686
|
+
runId,
|
|
687
|
+
provider: PROVIDER,
|
|
688
|
+
result,
|
|
689
|
+
options: telemetry.outputOptions()
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
async stream(messages, options) {
|
|
693
|
+
const runId = options?.runId ?? randomUUID();
|
|
694
|
+
const prompt = promptToText(messages);
|
|
695
|
+
const sdkAgent = await this.resolveCursorAgent();
|
|
696
|
+
const modelId = getCursorModelId(this.options, sdkAgent);
|
|
697
|
+
const requestContext = options?.requestContext ?? new RequestContext();
|
|
698
|
+
const instructions = options?.instructions ? promptToText(options.instructions) : void 0;
|
|
699
|
+
const telemetry = createSDKAgentTelemetry({
|
|
700
|
+
agentId: this.id,
|
|
701
|
+
agentName: this.name,
|
|
702
|
+
provider: PROVIDER,
|
|
703
|
+
modelId,
|
|
704
|
+
messages,
|
|
705
|
+
prompt,
|
|
706
|
+
runId,
|
|
707
|
+
streaming: true,
|
|
708
|
+
method: "stream",
|
|
709
|
+
requestContext,
|
|
710
|
+
instructions,
|
|
711
|
+
maxSteps: options?.maxSteps,
|
|
712
|
+
tracingOptions: options?.tracingOptions,
|
|
713
|
+
tracingContext: options?.tracingContext,
|
|
714
|
+
onFinish: options?.onFinish,
|
|
715
|
+
onStepFinish: options?.onStepFinish,
|
|
716
|
+
mastra: this.#mastra
|
|
717
|
+
});
|
|
718
|
+
return createMastraOutput({
|
|
719
|
+
messages,
|
|
720
|
+
runId,
|
|
721
|
+
modelId,
|
|
722
|
+
provider: PROVIDER,
|
|
723
|
+
stream: telemetry.wrapStream(runCursorAsMastraStream(prompt, this.options, sdkAgent, runId, telemetry)),
|
|
724
|
+
options: telemetry.outputOptions()
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
resolveCursorAgent() {
|
|
728
|
+
this.#createdAgent ??= resolveCursorAgent(this.options.agent, this.options).catch((error) => {
|
|
729
|
+
this.#createdAgent = void 0;
|
|
730
|
+
throw error;
|
|
731
|
+
});
|
|
732
|
+
return this.#createdAgent;
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
async function runCursorGenerate(prompt, options, agent, telemetry) {
|
|
736
|
+
const usage = createCursorUsageCollector();
|
|
737
|
+
const run = await agent.send(prompt, createCursorSendOptions(options, usage, telemetry));
|
|
738
|
+
const result = await run.wait();
|
|
739
|
+
if (result.status === "error" || result.status === "cancelled") {
|
|
740
|
+
throw new Error(`Cursor run ${result.id} ended with status ${result.status}`);
|
|
741
|
+
}
|
|
742
|
+
const responseModel = getModelId(result.model ?? run.model ?? getRequestedModel(options) ?? agent.model);
|
|
743
|
+
const providerMetadata = getCursorProviderMetadata(
|
|
744
|
+
options,
|
|
745
|
+
agent.agentId,
|
|
746
|
+
result.id,
|
|
747
|
+
result.status,
|
|
748
|
+
result.durationMs,
|
|
749
|
+
usage.totals(),
|
|
750
|
+
responseModel
|
|
751
|
+
);
|
|
752
|
+
return {
|
|
753
|
+
content: [{ type: "text", text: result.result ?? "" }],
|
|
754
|
+
finishReason: { unified: "stop", raw: "stop" },
|
|
755
|
+
usage: usage.toV3Usage(),
|
|
756
|
+
response: {
|
|
757
|
+
id: result.id,
|
|
758
|
+
modelId: responseModel,
|
|
759
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
760
|
+
},
|
|
761
|
+
providerMetadata
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function runCursorAsMastraStream(prompt, options, agent, runId, telemetry) {
|
|
765
|
+
return new ReadableStream({
|
|
766
|
+
start: async (controller) => {
|
|
767
|
+
const textId = randomUUID();
|
|
768
|
+
const usage = createCursorUsageCollector();
|
|
769
|
+
let text = "";
|
|
770
|
+
try {
|
|
771
|
+
const run = await agent.send(prompt, createCursorSendOptions(options, usage, telemetry));
|
|
772
|
+
const responseId = run.id;
|
|
773
|
+
const responseModel = getModelId(run.model ?? getRequestedModel(options) ?? agent.model);
|
|
774
|
+
enqueueStartChunks(controller, {
|
|
775
|
+
runId,
|
|
776
|
+
prompt,
|
|
777
|
+
textId,
|
|
778
|
+
responseId,
|
|
779
|
+
modelId: responseModel,
|
|
780
|
+
providerMetadata: getCursorProviderMetadata(
|
|
781
|
+
options,
|
|
782
|
+
agent.agentId,
|
|
783
|
+
run.id,
|
|
784
|
+
run.status,
|
|
785
|
+
run.durationMs,
|
|
786
|
+
usage.totals(),
|
|
787
|
+
responseModel
|
|
788
|
+
)
|
|
789
|
+
});
|
|
790
|
+
let result;
|
|
791
|
+
if (run.supports("stream")) {
|
|
792
|
+
for await (const message of run.stream()) {
|
|
793
|
+
const delta = getTextFromCursorMessage(message);
|
|
794
|
+
if (delta) {
|
|
795
|
+
text += delta;
|
|
796
|
+
enqueueTextDelta(controller, runId, textId, delta);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
result = await run.wait();
|
|
800
|
+
} else {
|
|
801
|
+
result = await run.wait();
|
|
802
|
+
if (result.status === "error" || result.status === "cancelled") {
|
|
803
|
+
throw new Error(`Cursor run ${result.id} ended with status ${result.status}`);
|
|
804
|
+
}
|
|
805
|
+
if (result.result) {
|
|
806
|
+
text += result.result;
|
|
807
|
+
enqueueTextDelta(controller, runId, textId, result.result);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
if (result.status === "error" || result.status === "cancelled") {
|
|
811
|
+
throw new Error(`Cursor run ${result.id} ended with status ${result.status}`);
|
|
812
|
+
}
|
|
813
|
+
if (!text && result.result) {
|
|
814
|
+
text = result.result;
|
|
815
|
+
enqueueTextDelta(controller, runId, textId, result.result);
|
|
816
|
+
}
|
|
817
|
+
const providerMetadata = getCursorProviderMetadata(
|
|
818
|
+
options,
|
|
819
|
+
agent.agentId,
|
|
820
|
+
run.id,
|
|
821
|
+
result.status,
|
|
822
|
+
result.durationMs,
|
|
823
|
+
usage.totals(),
|
|
824
|
+
getModelId(result.model ?? run.model ?? getRequestedModel(options) ?? agent.model)
|
|
825
|
+
);
|
|
826
|
+
enqueueFinishChunks(controller, {
|
|
827
|
+
runId,
|
|
828
|
+
prompt,
|
|
829
|
+
textId,
|
|
830
|
+
text,
|
|
831
|
+
responseId,
|
|
832
|
+
modelId: getModelId(result.model ?? run.model ?? getRequestedModel(options) ?? agent.model),
|
|
833
|
+
usage: usage.toLanguageModelUsage(),
|
|
834
|
+
providerMetadata
|
|
835
|
+
});
|
|
836
|
+
controller.close();
|
|
837
|
+
} catch (error) {
|
|
838
|
+
controller.enqueue({
|
|
839
|
+
type: "error",
|
|
840
|
+
runId,
|
|
841
|
+
from: ChunkFrom.AGENT,
|
|
842
|
+
payload: { error }
|
|
843
|
+
});
|
|
844
|
+
controller.close();
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
async function resolveCursorAgent(agent, options) {
|
|
850
|
+
if (!agent) {
|
|
851
|
+
return Agent$1.create(toCursorCreateOptions(options));
|
|
852
|
+
}
|
|
853
|
+
return typeof agent === "function" ? agent(toCursorCreateOptions(options)) : agent;
|
|
854
|
+
}
|
|
855
|
+
function toCursorCreateOptions(options) {
|
|
856
|
+
const createOptions = { ...options.sdkOptions };
|
|
857
|
+
const apiKey = createOptions.apiKey ?? process.env["CURSOR_API_KEY"];
|
|
858
|
+
if (apiKey) createOptions.apiKey = apiKey;
|
|
859
|
+
if (options.name && !createOptions.name) createOptions.name = options.name;
|
|
860
|
+
return createOptions;
|
|
861
|
+
}
|
|
862
|
+
function createCursorSendOptions(options, usage, telemetry) {
|
|
863
|
+
return {
|
|
864
|
+
mcpServers: options.sdkOptions?.mcpServers,
|
|
865
|
+
onDelta: async (args) => {
|
|
866
|
+
usage.record(args.update);
|
|
867
|
+
recordCursorToolTelemetry(args.update, telemetry);
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
function createCursorUsageCollector() {
|
|
872
|
+
const totals = {
|
|
873
|
+
inputTokens: 0,
|
|
874
|
+
outputTokens: 0,
|
|
875
|
+
cacheReadTokens: 0,
|
|
876
|
+
cacheWriteTokens: 0
|
|
877
|
+
};
|
|
878
|
+
return {
|
|
879
|
+
record(update) {
|
|
880
|
+
if (update.type !== "turn-ended" || !update.usage) {
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
totals.inputTokens += update.usage.inputTokens;
|
|
884
|
+
totals.outputTokens += update.usage.outputTokens;
|
|
885
|
+
totals.cacheReadTokens += update.usage.cacheReadTokens;
|
|
886
|
+
totals.cacheWriteTokens += update.usage.cacheWriteTokens;
|
|
887
|
+
},
|
|
888
|
+
totals() {
|
|
889
|
+
return {
|
|
890
|
+
inputTokens: totals.inputTokens || void 0,
|
|
891
|
+
outputTokens: totals.outputTokens || void 0,
|
|
892
|
+
cacheReadTokens: totals.cacheReadTokens || void 0,
|
|
893
|
+
cacheWriteTokens: totals.cacheWriteTokens || void 0
|
|
894
|
+
};
|
|
895
|
+
},
|
|
896
|
+
toV3Usage() {
|
|
897
|
+
return toV3Usage(totals);
|
|
898
|
+
},
|
|
899
|
+
toLanguageModelUsage() {
|
|
900
|
+
return toLanguageModelUsage(toV3Usage(totals));
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
function toV3Usage(usage) {
|
|
905
|
+
const noCache = usage.inputTokens;
|
|
906
|
+
const cacheRead = usage.cacheReadTokens;
|
|
907
|
+
const cacheWrite = usage.cacheWriteTokens;
|
|
908
|
+
const totalInputTokens = sumDefined(noCache, cacheRead, cacheWrite);
|
|
909
|
+
const outputTokens = usage.outputTokens;
|
|
910
|
+
return {
|
|
911
|
+
inputTokens: {
|
|
912
|
+
total: totalInputTokens,
|
|
913
|
+
noCache,
|
|
914
|
+
cacheRead,
|
|
915
|
+
cacheWrite
|
|
916
|
+
},
|
|
917
|
+
outputTokens: {
|
|
918
|
+
total: outputTokens,
|
|
919
|
+
text: outputTokens
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
function getRequestedModel(options) {
|
|
924
|
+
return options.sdkOptions?.model;
|
|
925
|
+
}
|
|
926
|
+
function getModelId(model) {
|
|
927
|
+
if (!model) {
|
|
928
|
+
return MODEL_ID;
|
|
929
|
+
}
|
|
930
|
+
return typeof model === "string" ? model : model.id;
|
|
931
|
+
}
|
|
932
|
+
function getCursorModelId(options, agent) {
|
|
933
|
+
return getModelId(getRequestedModel(options) ?? agent.model);
|
|
934
|
+
}
|
|
935
|
+
function getCursorProviderMetadata(options, agentId, runId, status, durationMs, usage, requestedModel) {
|
|
936
|
+
return createProviderMetadata("cursor", {
|
|
937
|
+
agentId,
|
|
938
|
+
runId,
|
|
939
|
+
status,
|
|
940
|
+
requestedModel: requestedModel ?? getModelId(getRequestedModel(options)),
|
|
941
|
+
durationMs,
|
|
942
|
+
mcpServerNames: getMcpServerNames(options),
|
|
943
|
+
usage
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
function getMcpServerNames(options) {
|
|
947
|
+
const servers = options.sdkOptions?.mcpServers;
|
|
948
|
+
return servers ? Object.keys(servers) : void 0;
|
|
949
|
+
}
|
|
950
|
+
function getTextFromCursorMessage(message) {
|
|
951
|
+
if (message.type === "assistant") {
|
|
952
|
+
return message.message.content.map((block) => {
|
|
953
|
+
if (block.type === "text") {
|
|
954
|
+
return block.text;
|
|
955
|
+
}
|
|
956
|
+
return "";
|
|
957
|
+
}).filter(Boolean).join("");
|
|
958
|
+
}
|
|
959
|
+
if (message.type === "task") {
|
|
960
|
+
return message.text ?? "";
|
|
961
|
+
}
|
|
962
|
+
return "";
|
|
963
|
+
}
|
|
964
|
+
function recordCursorToolTelemetry(update, telemetry) {
|
|
965
|
+
const updateRecord = toRecord(update);
|
|
966
|
+
if (!updateRecord) {
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
const updateType = typeof updateRecord?.type === "string" ? updateRecord.type : void 0;
|
|
970
|
+
if (updateType !== "tool-call-started" && updateType !== "partial-tool-call" && updateType !== "tool-call-completed") {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
const toolCall = getCursorToolCall(updateRecord);
|
|
974
|
+
if (!toolCall) {
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (updateType === "tool-call-started" || updateType === "partial-tool-call") {
|
|
978
|
+
telemetry.startToolCall({
|
|
979
|
+
toolCallId: toolCall.toolCallId,
|
|
980
|
+
toolName: toolCall.toolName,
|
|
981
|
+
input: toolCall.input
|
|
982
|
+
});
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
telemetry.startToolCall({
|
|
986
|
+
toolCallId: toolCall.toolCallId,
|
|
987
|
+
toolName: toolCall.toolName,
|
|
988
|
+
input: toolCall.input
|
|
989
|
+
});
|
|
990
|
+
telemetry.endToolCall({
|
|
991
|
+
toolCallId: toolCall.toolCallId,
|
|
992
|
+
output: toolCall.output,
|
|
993
|
+
isError: toolCall.isError
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
function getCursorToolCall(update) {
|
|
997
|
+
const toolCallId = typeof update.callId === "string" ? update.callId : void 0;
|
|
998
|
+
const toolCall = toRecord(update.toolCall);
|
|
999
|
+
if (!toolCallId || !toolCall) {
|
|
1000
|
+
return void 0;
|
|
1001
|
+
}
|
|
1002
|
+
if (toolCall.type === "mcp") {
|
|
1003
|
+
const args = toRecord(toolCall.args);
|
|
1004
|
+
if (!args) {
|
|
1005
|
+
return void 0;
|
|
1006
|
+
}
|
|
1007
|
+
const providerIdentifier = typeof args?.providerIdentifier === "string" ? args.providerIdentifier : void 0;
|
|
1008
|
+
const toolName2 = typeof args?.toolName === "string" ? args.toolName : void 0;
|
|
1009
|
+
if (!providerIdentifier || !toolName2) {
|
|
1010
|
+
return void 0;
|
|
1011
|
+
}
|
|
1012
|
+
const result = toRecord(toolCall.result);
|
|
1013
|
+
return {
|
|
1014
|
+
toolCallId,
|
|
1015
|
+
toolName: `mcp__${providerIdentifier}__${toolName2}`,
|
|
1016
|
+
input: args.args,
|
|
1017
|
+
output: result?.value ?? toolCall.result,
|
|
1018
|
+
isError: result?.status === "error" || result?.status === "failed"
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
const toolName = typeof toolCall.name === "string" ? toolCall.name : typeof toolCall.type === "string" ? toolCall.type : void 0;
|
|
1022
|
+
if (!toolName) {
|
|
1023
|
+
return void 0;
|
|
1024
|
+
}
|
|
1025
|
+
return {
|
|
1026
|
+
toolCallId,
|
|
1027
|
+
toolName,
|
|
1028
|
+
input: "args" in toolCall ? toolCall.args : void 0,
|
|
1029
|
+
output: "result" in toolCall ? toolCall.result : void 0,
|
|
1030
|
+
isError: toolCall.status === "error"
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
function toRecord(value) {
|
|
1034
|
+
return value !== null && typeof value === "object" ? value : void 0;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
export { CursorSDKAgent };
|
|
1038
|
+
//# sourceMappingURL=index.js.map
|
|
1039
|
+
//# sourceMappingURL=index.js.map
|