@meetopenbot/cursor 0.0.5 → 1.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/dist/session.js +1 -1
- package/dist/state.js +6 -2
- package/dist/stream.js +16 -4
- package/package.json +2 -2
package/dist/session.js
CHANGED
|
@@ -8,7 +8,7 @@ export class StaleAgentSessionError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
const sessionCache = new Map();
|
|
11
|
-
const buildSessionKey = (state) => state.threadId ? `${state.channelId}:${state.threadId}` : state.channelId;
|
|
11
|
+
const buildSessionKey = (state) => state.threadId ? `${state.channelId ?? ''}:${state.threadId}` : (state.channelId ?? '');
|
|
12
12
|
const buildAgentOptions = (config) => {
|
|
13
13
|
const options = {
|
|
14
14
|
apiKey: config.apiKey,
|
package/dist/state.js
CHANGED
|
@@ -9,13 +9,17 @@ export const readPersistedState = (state) => {
|
|
|
9
9
|
: {};
|
|
10
10
|
};
|
|
11
11
|
export const persistCursorState = async (state, storage, patch) => {
|
|
12
|
+
const channelId = state.channelId;
|
|
13
|
+
if (!channelId) {
|
|
14
|
+
throw new Error('channelId is required to persist Cursor session state');
|
|
15
|
+
}
|
|
12
16
|
if (state.threadId) {
|
|
13
17
|
await storage.patchThreadState({
|
|
14
|
-
channelId
|
|
18
|
+
channelId,
|
|
15
19
|
threadId: state.threadId,
|
|
16
20
|
state: patch,
|
|
17
21
|
});
|
|
18
22
|
return;
|
|
19
23
|
}
|
|
20
|
-
await storage.patchChannelState({ channelId
|
|
24
|
+
await storage.patchChannelState({ channelId, state: patch });
|
|
21
25
|
};
|
package/dist/stream.js
CHANGED
|
@@ -14,18 +14,30 @@ export const classifyCursorEvent = (event) => {
|
|
|
14
14
|
const text = assistantText(event);
|
|
15
15
|
return text ? { type: 'delta', text } : { type: 'skip' };
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (event.type === 'tool_call') {
|
|
18
|
+
if (event.status === 'running') {
|
|
19
|
+
return { type: 'tool_call', id: event.call_id, name: event.name, input: event.args };
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
type: 'tool_result',
|
|
23
|
+
id: event.call_id,
|
|
24
|
+
name: event.name,
|
|
25
|
+
input: event.args,
|
|
26
|
+
output: event.result,
|
|
27
|
+
error: event.status === 'error',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (event.type === 'usage')
|
|
19
31
|
return { type: 'flush' };
|
|
20
32
|
return { type: 'skip' };
|
|
21
33
|
};
|
|
22
|
-
/** Run a Cursor prompt and yield each completed assistant turn. */
|
|
34
|
+
/** Run a Cursor prompt and yield each completed assistant turn and tool widget. */
|
|
23
35
|
export async function* runCursorPrompt(agent, prompt, config, wasResumed) {
|
|
24
36
|
const run = await agent.send(prompt, {
|
|
25
37
|
...(config.mode ? { mode: config.mode } : {}),
|
|
26
38
|
model: buildModelSelection(config),
|
|
27
39
|
});
|
|
28
|
-
yield* emitTextReplies(run.stream(), classifyCursorEvent);
|
|
40
|
+
yield* emitTextReplies(run.stream(), classifyCursorEvent, { groupId: 'cursor:tools' });
|
|
29
41
|
const result = await run.wait();
|
|
30
42
|
if (result.status === 'error') {
|
|
31
43
|
if (wasResumed && (result.durationMs ?? 0) < 2000) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meetopenbot/cursor",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "OpenBot agent plugin powered by the Cursor SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@cursor/sdk": "^1.0.18",
|
|
23
|
-
"@meetopenbot/plugin-sdk": "^0.
|
|
23
|
+
"@meetopenbot/plugin-sdk": "^1.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^25.9.2",
|