@sideboard-ai/core 0.1.31 → 0.1.33

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.
@@ -1,92 +0,0 @@
1
- // src/agents/cursor-events.ts
2
- function usageFromCursor(usage) {
3
- if (!usage) return null;
4
- const inputTokens = Number(usage.inputTokens ?? 0);
5
- const outputTokens = Number(usage.outputTokens ?? 0);
6
- if (!inputTokens && !outputTokens) return null;
7
- return {
8
- inputTokens,
9
- outputTokens,
10
- cacheReadTokens: usage.cacheReadTokens ? Number(usage.cacheReadTokens) : void 0,
11
- cacheWriteTokens: usage.cacheWriteTokens ? Number(usage.cacheWriteTokens) : void 0
12
- };
13
- }
14
- function cursorSdkMessageToEvents(msg) {
15
- if (!msg?.type) return [];
16
- if (msg.type === "system" && msg.agent_id) {
17
- return [{ type: "session_id", data: msg.agent_id }];
18
- }
19
- if (msg.type === "thinking" && msg.text) {
20
- return [{ type: "thinking", data: msg.text }];
21
- }
22
- if (msg.type === "assistant" && msg.message?.content?.length) {
23
- const out = [];
24
- for (const block of msg.message.content) {
25
- if (block?.type === "text" && block.text) {
26
- out.push({ type: "stdout", data: block.text });
27
- } else if (block?.type === "tool_use" && block.id && block.name) {
28
- out.push({
29
- type: "tool_use",
30
- id: block.id,
31
- name: block.name,
32
- input: block.input && typeof block.input === "object" ? block.input : void 0
33
- });
34
- }
35
- }
36
- return out;
37
- }
38
- if (msg.type === "tool_call" && msg.call_id && msg.name) {
39
- if (msg.status === "running") {
40
- return [
41
- {
42
- type: "tool_use",
43
- id: msg.call_id,
44
- name: msg.name,
45
- input: msg.args && typeof msg.args === "object" ? msg.args : void 0
46
- }
47
- ];
48
- }
49
- if (msg.status === "completed" || msg.status === "error") {
50
- const content = typeof msg.result === "string" ? msg.result : msg.result != null ? JSON.stringify(msg.result) : void 0;
51
- return [
52
- {
53
- type: "tool_result",
54
- id: msg.call_id,
55
- content,
56
- isError: msg.status === "error"
57
- }
58
- ];
59
- }
60
- }
61
- if (msg.type === "usage") {
62
- const usage = usageFromCursor(msg.usage);
63
- if (usage) return [{ type: "usage", data: usage }];
64
- }
65
- if (msg.type === "status" && msg.status === "ERROR") {
66
- const detail = msg.message || msg.text || "Cursor run entered ERROR status";
67
- return [{ type: "stderr", data: detail }];
68
- }
69
- return [];
70
- }
71
- function parseCursorRunnerLine(line) {
72
- const trimmed = line.trim();
73
- if (!trimmed) return null;
74
- try {
75
- const obj = JSON.parse(trimmed);
76
- if (Array.isArray(obj)) return obj;
77
- if (obj && typeof obj === "object" && "events" in obj && Array.isArray(obj.events)) {
78
- return obj.events;
79
- }
80
- if (obj && typeof obj === "object" && "type" in obj) {
81
- return obj;
82
- }
83
- return null;
84
- } catch {
85
- return { type: "stdout", data: line };
86
- }
87
- }
88
-
89
- export {
90
- cursorSdkMessageToEvents,
91
- parseCursorRunnerLine
92
- };