@react-grab/cursor 0.0.71 → 0.0.73
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 +24 -1
- package/dist/client.d.cts +9 -2
- package/dist/client.d.ts +9 -2
- package/dist/client.global.js +3 -3
- package/dist/client.js +24 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -111,7 +111,7 @@ var import_picocolors = __toESM(require_picocolors());
|
|
|
111
111
|
var DEFAULT_PORT = 5567;
|
|
112
112
|
|
|
113
113
|
// src/cli.ts
|
|
114
|
-
var VERSION = "0.0.
|
|
114
|
+
var VERSION = "0.0.73";
|
|
115
115
|
var __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
|
116
116
|
var __dirname$1 = path.dirname(__filename$1);
|
|
117
117
|
var serverPath = path.join(__dirname$1, "server.js");
|
package/dist/cli.js
CHANGED
|
@@ -108,7 +108,7 @@ var import_picocolors = __toESM(require_picocolors());
|
|
|
108
108
|
var DEFAULT_PORT = 5567;
|
|
109
109
|
|
|
110
110
|
// src/cli.ts
|
|
111
|
-
var VERSION = "0.0.
|
|
111
|
+
var VERSION = "0.0.73";
|
|
112
112
|
var __filename = fileURLToPath(import.meta.url);
|
|
113
113
|
var __dirname = dirname(__filename);
|
|
114
114
|
var serverPath = join(__dirname, "server.js");
|
package/dist/client.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/constants.ts
|
|
4
4
|
var DEFAULT_PORT = 5567;
|
|
5
|
+
var CONNECTION_CHECK_TTL_MS = 5e3;
|
|
5
6
|
|
|
6
7
|
// src/client.ts
|
|
7
8
|
var DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_PORT}`;
|
|
@@ -75,6 +76,7 @@ async function* streamFromServer(serverUrl, context, signal) {
|
|
|
75
76
|
}
|
|
76
77
|
var createCursorAgentProvider = (providerOptions = {}) => {
|
|
77
78
|
const { serverUrl = DEFAULT_SERVER_URL, getOptions } = providerOptions;
|
|
79
|
+
let connectionCache = null;
|
|
78
80
|
const mergeOptions = (contextOptions) => ({
|
|
79
81
|
...getOptions?.() ?? {},
|
|
80
82
|
...contextOptions ?? {}
|
|
@@ -105,7 +107,28 @@ var createCursorAgentProvider = (providerOptions = {}) => {
|
|
|
105
107
|
yield "Resuming...";
|
|
106
108
|
yield* streamFromServer(serverUrl, mergedContext, signal);
|
|
107
109
|
},
|
|
108
|
-
supportsResume: true
|
|
110
|
+
supportsResume: true,
|
|
111
|
+
checkConnection: async () => {
|
|
112
|
+
const now = Date.now();
|
|
113
|
+
if (connectionCache && now - connectionCache.timestamp < CONNECTION_CHECK_TTL_MS) {
|
|
114
|
+
return connectionCache.result;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const response = await fetch(`${serverUrl}/health`, { method: "GET" });
|
|
118
|
+
const result = response.ok;
|
|
119
|
+
connectionCache = { result, timestamp: now };
|
|
120
|
+
return result;
|
|
121
|
+
} catch {
|
|
122
|
+
connectionCache = { result: false, timestamp: now };
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
undo: async () => {
|
|
127
|
+
try {
|
|
128
|
+
await fetch(`${serverUrl}/undo`, { method: "POST" });
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
}
|
|
109
132
|
};
|
|
110
133
|
};
|
|
111
134
|
var attachAgent = async () => {
|
package/dist/client.d.cts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { init,
|
|
1
|
+
import { init, AgentContext, AgentSessionStorage } from 'react-grab/core';
|
|
2
2
|
|
|
3
3
|
interface CursorAgentOptions {
|
|
4
4
|
model?: string;
|
|
5
5
|
workspace?: string;
|
|
6
6
|
}
|
|
7
|
+
type CursorAgentContext = AgentContext<CursorAgentOptions>;
|
|
7
8
|
interface CursorAgentProviderOptions {
|
|
8
9
|
serverUrl?: string;
|
|
9
10
|
getOptions?: () => Partial<CursorAgentOptions>;
|
|
10
11
|
}
|
|
11
|
-
declare const createCursorAgentProvider: (providerOptions?: CursorAgentProviderOptions) =>
|
|
12
|
+
declare const createCursorAgentProvider: (providerOptions?: CursorAgentProviderOptions) => {
|
|
13
|
+
send: (context: CursorAgentContext, signal: AbortSignal) => AsyncGenerator<string, void, unknown>;
|
|
14
|
+
resume: (sessionId: string, signal: AbortSignal, storage: AgentSessionStorage) => AsyncGenerator<string, void, unknown>;
|
|
15
|
+
supportsResume: boolean;
|
|
16
|
+
checkConnection: () => Promise<boolean>;
|
|
17
|
+
undo: () => Promise<void>;
|
|
18
|
+
};
|
|
12
19
|
declare global {
|
|
13
20
|
interface Window {
|
|
14
21
|
__REACT_GRAB__?: ReturnType<typeof init>;
|
package/dist/client.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { init,
|
|
1
|
+
import { init, AgentContext, AgentSessionStorage } from 'react-grab/core';
|
|
2
2
|
|
|
3
3
|
interface CursorAgentOptions {
|
|
4
4
|
model?: string;
|
|
5
5
|
workspace?: string;
|
|
6
6
|
}
|
|
7
|
+
type CursorAgentContext = AgentContext<CursorAgentOptions>;
|
|
7
8
|
interface CursorAgentProviderOptions {
|
|
8
9
|
serverUrl?: string;
|
|
9
10
|
getOptions?: () => Partial<CursorAgentOptions>;
|
|
10
11
|
}
|
|
11
|
-
declare const createCursorAgentProvider: (providerOptions?: CursorAgentProviderOptions) =>
|
|
12
|
+
declare const createCursorAgentProvider: (providerOptions?: CursorAgentProviderOptions) => {
|
|
13
|
+
send: (context: CursorAgentContext, signal: AbortSignal) => AsyncGenerator<string, void, unknown>;
|
|
14
|
+
resume: (sessionId: string, signal: AbortSignal, storage: AgentSessionStorage) => AsyncGenerator<string, void, unknown>;
|
|
15
|
+
supportsResume: boolean;
|
|
16
|
+
checkConnection: () => Promise<boolean>;
|
|
17
|
+
undo: () => Promise<void>;
|
|
18
|
+
};
|
|
12
19
|
declare global {
|
|
13
20
|
interface Window {
|
|
14
21
|
__REACT_GRAB__?: ReturnType<typeof init>;
|
package/dist/client.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ReactGrabCursor=(function(exports){'use strict';var
|
|
2
|
-
`))
|
|
1
|
+
var ReactGrabCursor=(function(exports){'use strict';var m=`http://localhost:${5567}`,E="react-grab:agent-sessions",C=o=>{let t="",n="";for(let e of o.split(`
|
|
2
|
+
`))e.startsWith("event:")?t=e.slice(6).trim():e.startsWith("data:")&&(n=e.slice(5).trim());return {eventType:t,data:n}};async function*b(o,t){let n=o.getReader(),e=new TextDecoder,s="",r=false,a=()=>{r=true,n.cancel().catch(()=>{});};t.addEventListener("abort",a);try{if(t.aborted)throw new DOMException("Aborted","AbortError");for(;;){let i=await n.read();if(r||t.aborted)throw new DOMException("Aborted","AbortError");let{done:g,value:l}=i;l&&(s+=e.decode(l,{stream:!0}));let c;for(;(c=s.indexOf(`
|
|
3
3
|
|
|
4
|
-
`))!==-1;){let{eventType:
|
|
4
|
+
`))!==-1;){let{eventType:d,data:u}=C(s.slice(0,c));if(s=s.slice(c+2),d==="done")return;if(d==="error"){console.error("[react-grab]",u||"Agent error");return}u&&(yield u);}if(g)break}}finally{t.removeEventListener("abort",a);try{n.releaseLock();}catch{}}}async function*p(o,t,n){let e=await fetch(`${o}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n});if(!e.ok)throw new Error(`Server error: ${e.status}`);if(!e.body)throw new Error("No response body");yield*b(e.body,n);}var y=(o={})=>{let{serverUrl:t=m,getOptions:n}=o,e=null,s=r=>({...n?.()??{},...r??{}});return {send:async function*(r,a){let i={...r,options:s(r.options)};yield*p(t,i,a);},resume:async function*(r,a,i){let g=i.getItem(E);if(!g)throw new Error("No sessions to resume");let c=JSON.parse(g)[r];if(!c)throw new Error(`Session ${r} not found`);let d=c.context,u={...d,options:s(d.options)};yield "Resuming...",yield*p(t,u,a);},supportsResume:true,checkConnection:async()=>{let r=Date.now();if(e&&r-e.timestamp<5e3)return e.result;try{let i=(await fetch(`${t}/health`,{method:"GET"})).ok;return e={result:i,timestamp:r},i}catch{return e={result:false,timestamp:r},false}},undo:async()=>{try{await fetch(`${t}/undo`,{method:"POST"});}catch{}}}},S=async()=>{if(typeof window>"u")return;let o=y(),t=window.__REACT_GRAB__;if(t){t.setAgent({provider:o,storage:sessionStorage});return}window.addEventListener("react-grab:init",n=>{n.detail.setAgent({provider:o,storage:sessionStorage});},{once:true});};S();exports.attachAgent=S;exports.createCursorAgentProvider=y;return exports;})({});
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/constants.ts
|
|
2
2
|
var DEFAULT_PORT = 5567;
|
|
3
|
+
var CONNECTION_CHECK_TTL_MS = 5e3;
|
|
3
4
|
|
|
4
5
|
// src/client.ts
|
|
5
6
|
var DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_PORT}`;
|
|
@@ -73,6 +74,7 @@ async function* streamFromServer(serverUrl, context, signal) {
|
|
|
73
74
|
}
|
|
74
75
|
var createCursorAgentProvider = (providerOptions = {}) => {
|
|
75
76
|
const { serverUrl = DEFAULT_SERVER_URL, getOptions } = providerOptions;
|
|
77
|
+
let connectionCache = null;
|
|
76
78
|
const mergeOptions = (contextOptions) => ({
|
|
77
79
|
...getOptions?.() ?? {},
|
|
78
80
|
...contextOptions ?? {}
|
|
@@ -103,7 +105,28 @@ var createCursorAgentProvider = (providerOptions = {}) => {
|
|
|
103
105
|
yield "Resuming...";
|
|
104
106
|
yield* streamFromServer(serverUrl, mergedContext, signal);
|
|
105
107
|
},
|
|
106
|
-
supportsResume: true
|
|
108
|
+
supportsResume: true,
|
|
109
|
+
checkConnection: async () => {
|
|
110
|
+
const now = Date.now();
|
|
111
|
+
if (connectionCache && now - connectionCache.timestamp < CONNECTION_CHECK_TTL_MS) {
|
|
112
|
+
return connectionCache.result;
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const response = await fetch(`${serverUrl}/health`, { method: "GET" });
|
|
116
|
+
const result = response.ok;
|
|
117
|
+
connectionCache = { result, timestamp: now };
|
|
118
|
+
return result;
|
|
119
|
+
} catch {
|
|
120
|
+
connectionCache = { result: false, timestamp: now };
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
undo: async () => {
|
|
125
|
+
try {
|
|
126
|
+
await fetch(`${serverUrl}/undo`, { method: "POST" });
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
107
130
|
};
|
|
108
131
|
};
|
|
109
132
|
var attachAgent = async () => {
|
package/dist/server.cjs
CHANGED
|
@@ -2366,7 +2366,7 @@ var import_picocolors = __toESM(require_picocolors());
|
|
|
2366
2366
|
var DEFAULT_PORT = 5567;
|
|
2367
2367
|
|
|
2368
2368
|
// src/server.ts
|
|
2369
|
-
var VERSION = "0.0.
|
|
2369
|
+
var VERSION = "0.0.73";
|
|
2370
2370
|
var parseStreamLine = (line) => {
|
|
2371
2371
|
const trimmed = line.trim();
|
|
2372
2372
|
if (!trimmed) return null;
|
package/dist/server.js
CHANGED
|
@@ -2358,7 +2358,7 @@ var import_picocolors = __toESM(require_picocolors());
|
|
|
2358
2358
|
var DEFAULT_PORT = 5567;
|
|
2359
2359
|
|
|
2360
2360
|
// src/server.ts
|
|
2361
|
-
var VERSION = "0.0.
|
|
2361
|
+
var VERSION = "0.0.73";
|
|
2362
2362
|
var parseStreamLine = (line) => {
|
|
2363
2363
|
const trimmed = line.trim();
|
|
2364
2364
|
if (!trimmed) return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-grab/cursor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"react-grab-cursor": "./dist/cli.js"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@hono/node-server": "^1.19.6",
|
|
31
31
|
"hono": "^4.0.0",
|
|
32
32
|
"picocolors": "^1.1.1",
|
|
33
|
-
"react-grab": "0.0.
|
|
33
|
+
"react-grab": "0.0.73"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"dev": "tsup --watch",
|