@react-grab/cursor 0.0.90 → 0.0.92
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/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.global.js +2 -2
- package/dist/client.js +1 -1
- package/dist/server.cjs +45 -13
- package/dist/server.js +45 -13
- package/package.json +3 -3
package/dist/cli.cjs
CHANGED
|
@@ -7138,7 +7138,7 @@ var import_picocolors = __toESM(require_picocolors());
|
|
|
7138
7138
|
var DEFAULT_PORT = 5567;
|
|
7139
7139
|
|
|
7140
7140
|
// src/cli.ts
|
|
7141
|
-
var VERSION = "0.0.
|
|
7141
|
+
var VERSION = "0.0.92";
|
|
7142
7142
|
var serverPath = path2.join(__dirname, "server.cjs");
|
|
7143
7143
|
execa(process.execPath, [serverPath], {
|
|
7144
7144
|
detached: true,
|
package/dist/cli.js
CHANGED
|
@@ -7130,7 +7130,7 @@ var import_picocolors = __toESM(require_picocolors());
|
|
|
7130
7130
|
var DEFAULT_PORT = 5567;
|
|
7131
7131
|
|
|
7132
7132
|
// src/cli.ts
|
|
7133
|
-
var VERSION = "0.0.
|
|
7133
|
+
var VERSION = "0.0.92";
|
|
7134
7134
|
var serverPath = join(__dirname, "server.cjs");
|
|
7135
7135
|
execa(process.execPath, [serverPath], {
|
|
7136
7136
|
detached: true,
|
package/dist/client.cjs
CHANGED
|
@@ -71,7 +71,7 @@ var getStoredAgentContext = (storage, sessionId, storageKey = STORAGE_KEY) => {
|
|
|
71
71
|
if (!isRecord(context)) throw new Error(`Session ${sessionId} is invalid`);
|
|
72
72
|
const content = context.content;
|
|
73
73
|
const prompt = context.prompt;
|
|
74
|
-
if (
|
|
74
|
+
if (!Array.isArray(content) || typeof prompt !== "string") {
|
|
75
75
|
throw new Error(`Session ${sessionId} is invalid`);
|
|
76
76
|
}
|
|
77
77
|
const options = context.options;
|
package/dist/client.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var ReactGrabCursor=(function(exports){'use strict';var
|
|
1
|
+
var ReactGrabCursor=(function(exports){'use strict';var m=5e3,b="react-grab:agent-sessions",v=e=>{let t="",r="";for(let n of e.split(`
|
|
2
2
|
`))n.startsWith("event:")?t=n.slice(6).trim():n.startsWith("data:")&&(r=n.slice(5).trim());return {eventType:t,data:r}},T=async function*(e,t){let r=e.getReader(),n=new TextDecoder,o="",s=false,a=()=>{s=true,r.cancel().catch(()=>{});};t.addEventListener("abort",a);try{if(t.aborted)throw new DOMException("Aborted","AbortError");for(;;){let d=await r.read();if(s||t.aborted)throw new DOMException("Aborted","AbortError");let{done:i,value:l}=d;l&&(o+=n.decode(l,{stream:!0}));let c;for(;(c=o.indexOf(`
|
|
3
3
|
|
|
4
|
-
`))!==-1;){let{eventType:f,data:p}=v(o.slice(0,c));if(o=o.slice(c+2),f==="done")return;if(f==="error")throw new Error(p||"Agent error");p&&(yield p);}if(i)break}}finally{t.removeEventListener("abort",a);try{r.releaseLock();}catch{}}},
|
|
4
|
+
`))!==-1;){let{eventType:f,data:p}=v(o.slice(0,c));if(o=o.slice(c+2),f==="done")return;if(f==="error")throw new Error(p||"Agent error");p&&(yield p);}if(i)break}}finally{t.removeEventListener("abort",a);try{r.releaseLock();}catch{}}},A=e=>typeof e=="object"&&e!==null,S=(e,t,r=b)=>{let n=e.getItem(r);if(!n)throw new Error("No sessions to resume");let o;try{o=JSON.parse(n);}catch{throw new Error("Failed to parse stored sessions")}if(!A(o))throw new Error("Invalid stored sessions");let s=o[t];if(!A(s))throw new Error(`Session ${t} not found`);let a=s.context;if(!A(a))throw new Error(`Session ${t} is invalid`);let d=a.content,i=a.prompt;if(!Array.isArray(d)||typeof i!="string")throw new Error(`Session ${t} is invalid`);let l=a.options,c=a.sessionId;return {content:d,prompt:i,options:l,sessionId:typeof c=="string"?c:void 0}},y=async function*(e,t,r){let n=Date.now(),o=t.sessionId,s=e.pollIntervalMs??100,a=`${e.serverUrl}${e.agentPath??"/agent"}`,d=()=>{if(!o)return;let i=e.abortPath?.(o)??`/abort/${o}`;fetch(`${e.serverUrl}${i}`,{method:"POST"}).catch(()=>{});};r.addEventListener("abort",d);try{let i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:r});if(!i.ok)throw new Error(`Server error: ${i.status}`);if(!i.body)throw new Error("No response body");let l=T(i.body,r)[Symbol.asyncIterator](),c=!1,f=l.next(),p=null;for(;!c;){let C=await Promise.race([f.then(u=>({type:"status",iteratorResult:u})),new Promise(u=>setTimeout(()=>u({type:"timeout"}),s))]),g=(Date.now()-n)/1e3;if(C.type==="status"){let u=C.iteratorResult;c=u.done??!1,!c&&u.value&&(p=u.value,f=l.next());}p===e.completedStatus?yield `Completed in ${g.toFixed(1)}s`:p?yield `${p} ${g.toFixed(1)}s`:yield `Working\u2026 ${g.toFixed(1)}s`;}}finally{r.removeEventListener("abort",d);}},E=(e,t=m)=>{let r=null;return async()=>{let n=Date.now();if(r&&n-r.timestamp<t)return r.result;try{let o=await e();return r={result:o,timestamp:n},o}catch{return r={result:false,timestamp:n},false}}};var h="Completed successfully";var x=`http://localhost:${5567}`,w=e=>typeof e=="object"&&e!==null&&"setAgent"in e,_=(e={})=>{let{serverUrl:t=x,getOptions:r}=e,n=s=>({...r?.()??{},...s??{}}),o=E(async()=>(await fetch(`${t}/health`,{method:"GET"})).ok,m);return {send:async function*(s,a){let d={...s,options:n(s.options)};yield*y({serverUrl:t,completedStatus:h},d,a);},resume:async function*(s,a,d){let i=S(d,s),l={content:i.content,prompt:i.prompt,options:i.options,sessionId:i.sessionId??s},c={...l,options:n(l.options)};yield "Resuming...",yield*y({serverUrl:t,completedStatus:h},c,a);},supportsResume:true,supportsFollowUp:true,checkConnection:o,abort:async s=>{try{await fetch(`${t}/abort/${s}`,{method:"POST"});}catch{}},undo:async()=>{try{await fetch(`${t}/undo`,{method:"POST"});}catch{}}}},R=async()=>{if(typeof window>"u")return;let e=_(),t=o=>{o.setAgent({provider:e,storage:sessionStorage});},r=window.__REACT_GRAB__;if(w(r)){t(r);return}window.addEventListener("react-grab:init",o=>{o instanceof CustomEvent&&w(o.detail)&&t(o.detail);},{once:true});let n=window.__REACT_GRAB__;w(n)&&t(n);};R();
|
|
5
5
|
exports.attachAgent=R;exports.createCursorAgentProvider=_;return exports;})({});
|
package/dist/client.js
CHANGED
|
@@ -69,7 +69,7 @@ var getStoredAgentContext = (storage, sessionId, storageKey = STORAGE_KEY) => {
|
|
|
69
69
|
if (!isRecord(context)) throw new Error(`Session ${sessionId} is invalid`);
|
|
70
70
|
const content = context.content;
|
|
71
71
|
const prompt = context.prompt;
|
|
72
|
-
if (
|
|
72
|
+
if (!Array.isArray(content) || typeof prompt !== "string") {
|
|
73
73
|
throw new Error(`Session ${sessionId} is invalid`);
|
|
74
74
|
}
|
|
75
75
|
const options = context.options;
|
package/dist/server.cjs
CHANGED
|
@@ -12129,7 +12129,7 @@ Check that the command is executable: chmod +x $(which ${commandName})`;
|
|
|
12129
12129
|
};
|
|
12130
12130
|
|
|
12131
12131
|
// src/server.ts
|
|
12132
|
-
var VERSION = "0.0.
|
|
12132
|
+
var VERSION = "0.0.92";
|
|
12133
12133
|
try {
|
|
12134
12134
|
fetch(
|
|
12135
12135
|
`https://www.react-grab.com/api/version?source=cursor&t=${Date.now()}`
|
|
@@ -12336,21 +12336,53 @@ var createServer = () => {
|
|
|
12336
12336
|
const { content, prompt, options, sessionId } = body;
|
|
12337
12337
|
const cursorChatId = sessionId ? cursorSessionMap.get(sessionId) : void 0;
|
|
12338
12338
|
const isFollowUp = Boolean(cursorChatId);
|
|
12339
|
-
const
|
|
12340
|
-
|
|
12341
|
-
${content}`;
|
|
12339
|
+
const contentItems = Array.isArray(content) ? content : [content];
|
|
12342
12340
|
return streamSSE(context, async (stream2) => {
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
|
|
12341
|
+
if (isFollowUp) {
|
|
12342
|
+
for await (const message of runAgent(prompt, {
|
|
12343
|
+
...options,
|
|
12344
|
+
sessionId
|
|
12345
|
+
})) {
|
|
12346
|
+
if (message.type === "error") {
|
|
12347
|
+
await stream2.writeSSE({
|
|
12348
|
+
data: `Error: ${message.content}`,
|
|
12349
|
+
event: "error"
|
|
12350
|
+
});
|
|
12351
|
+
} else {
|
|
12352
|
+
await stream2.writeSSE({
|
|
12353
|
+
data: message.content,
|
|
12354
|
+
event: message.type
|
|
12355
|
+
});
|
|
12356
|
+
}
|
|
12357
|
+
}
|
|
12358
|
+
return;
|
|
12359
|
+
}
|
|
12360
|
+
for (let i2 = 0; i2 < contentItems.length; i2++) {
|
|
12361
|
+
const elementContent = contentItems[i2];
|
|
12362
|
+
const userPrompt = `${prompt}
|
|
12363
|
+
|
|
12364
|
+
${elementContent}`;
|
|
12365
|
+
if (contentItems.length > 1) {
|
|
12348
12366
|
await stream2.writeSSE({
|
|
12349
|
-
data: `
|
|
12350
|
-
event: "
|
|
12367
|
+
data: `Processing element ${i2 + 1} of ${contentItems.length}...`,
|
|
12368
|
+
event: "status"
|
|
12351
12369
|
});
|
|
12352
|
-
}
|
|
12353
|
-
|
|
12370
|
+
}
|
|
12371
|
+
for await (const message of runAgent(userPrompt, {
|
|
12372
|
+
...options,
|
|
12373
|
+
sessionId
|
|
12374
|
+
})) {
|
|
12375
|
+
if (message.type === "error") {
|
|
12376
|
+
await stream2.writeSSE({
|
|
12377
|
+
data: `Error: ${message.content}`,
|
|
12378
|
+
event: "error"
|
|
12379
|
+
});
|
|
12380
|
+
} else {
|
|
12381
|
+
await stream2.writeSSE({
|
|
12382
|
+
data: message.content,
|
|
12383
|
+
event: message.type
|
|
12384
|
+
});
|
|
12385
|
+
}
|
|
12354
12386
|
}
|
|
12355
12387
|
}
|
|
12356
12388
|
});
|
package/dist/server.js
CHANGED
|
@@ -12117,7 +12117,7 @@ Check that the command is executable: chmod +x $(which ${commandName})`;
|
|
|
12117
12117
|
};
|
|
12118
12118
|
|
|
12119
12119
|
// src/server.ts
|
|
12120
|
-
var VERSION = "0.0.
|
|
12120
|
+
var VERSION = "0.0.92";
|
|
12121
12121
|
try {
|
|
12122
12122
|
fetch(
|
|
12123
12123
|
`https://www.react-grab.com/api/version?source=cursor&t=${Date.now()}`
|
|
@@ -12324,21 +12324,53 @@ var createServer = () => {
|
|
|
12324
12324
|
const { content, prompt, options, sessionId } = body;
|
|
12325
12325
|
const cursorChatId = sessionId ? cursorSessionMap.get(sessionId) : void 0;
|
|
12326
12326
|
const isFollowUp = Boolean(cursorChatId);
|
|
12327
|
-
const
|
|
12328
|
-
|
|
12329
|
-
${content}`;
|
|
12327
|
+
const contentItems = Array.isArray(content) ? content : [content];
|
|
12330
12328
|
return streamSSE(context, async (stream2) => {
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
|
|
12335
|
-
|
|
12329
|
+
if (isFollowUp) {
|
|
12330
|
+
for await (const message of runAgent(prompt, {
|
|
12331
|
+
...options,
|
|
12332
|
+
sessionId
|
|
12333
|
+
})) {
|
|
12334
|
+
if (message.type === "error") {
|
|
12335
|
+
await stream2.writeSSE({
|
|
12336
|
+
data: `Error: ${message.content}`,
|
|
12337
|
+
event: "error"
|
|
12338
|
+
});
|
|
12339
|
+
} else {
|
|
12340
|
+
await stream2.writeSSE({
|
|
12341
|
+
data: message.content,
|
|
12342
|
+
event: message.type
|
|
12343
|
+
});
|
|
12344
|
+
}
|
|
12345
|
+
}
|
|
12346
|
+
return;
|
|
12347
|
+
}
|
|
12348
|
+
for (let i2 = 0; i2 < contentItems.length; i2++) {
|
|
12349
|
+
const elementContent = contentItems[i2];
|
|
12350
|
+
const userPrompt = `${prompt}
|
|
12351
|
+
|
|
12352
|
+
${elementContent}`;
|
|
12353
|
+
if (contentItems.length > 1) {
|
|
12336
12354
|
await stream2.writeSSE({
|
|
12337
|
-
data: `
|
|
12338
|
-
event: "
|
|
12355
|
+
data: `Processing element ${i2 + 1} of ${contentItems.length}...`,
|
|
12356
|
+
event: "status"
|
|
12339
12357
|
});
|
|
12340
|
-
}
|
|
12341
|
-
|
|
12358
|
+
}
|
|
12359
|
+
for await (const message of runAgent(userPrompt, {
|
|
12360
|
+
...options,
|
|
12361
|
+
sessionId
|
|
12362
|
+
})) {
|
|
12363
|
+
if (message.type === "error") {
|
|
12364
|
+
await stream2.writeSSE({
|
|
12365
|
+
data: `Error: ${message.content}`,
|
|
12366
|
+
event: "error"
|
|
12367
|
+
});
|
|
12368
|
+
} else {
|
|
12369
|
+
await stream2.writeSSE({
|
|
12370
|
+
data: message.content,
|
|
12371
|
+
event: message.type
|
|
12372
|
+
});
|
|
12373
|
+
}
|
|
12342
12374
|
}
|
|
12343
12375
|
}
|
|
12344
12376
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-grab/cursor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.92",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"react-grab-cursor": "./dist/cli.cjs"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^22.10.7",
|
|
28
28
|
"tsup": "^8.4.0",
|
|
29
|
-
"@react-grab/utils": "0.0.
|
|
29
|
+
"@react-grab/utils": "0.0.92"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@hono/node-server": "^1.19.6",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"fkill": "^9.0.0",
|
|
35
35
|
"hono": "^4.0.0",
|
|
36
36
|
"picocolors": "^1.1.1",
|
|
37
|
-
"react-grab": "0.0.
|
|
37
|
+
"react-grab": "0.0.92"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"dev": "tsup --watch",
|