@react-grab/cursor 0.1.15 → 0.1.16

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 CHANGED
@@ -8,9 +8,13 @@ var path = require('path');
8
8
  var realScriptPath = fs.realpathSync(process.argv[1]);
9
9
  var scriptDir = path.dirname(realScriptPath);
10
10
  var serverPath = path.join(scriptDir, "server.cjs");
11
- var child = child_process.spawn(process.execPath, [serverPath], {
12
- detached: true,
13
- stdio: "inherit"
14
- });
11
+ var child = child_process.spawn(
12
+ process.execPath,
13
+ ["-e", `require(${JSON.stringify(serverPath)}).startServer()`],
14
+ {
15
+ detached: true,
16
+ stdio: "inherit"
17
+ }
18
+ );
15
19
  child.unref();
16
20
  process.exit(0);
package/dist/cli.js CHANGED
@@ -6,9 +6,13 @@ import { dirname, join } from 'path';
6
6
  var realScriptPath = realpathSync(process.argv[1]);
7
7
  var scriptDir = dirname(realScriptPath);
8
8
  var serverPath = join(scriptDir, "server.cjs");
9
- var child = spawn(process.execPath, [serverPath], {
10
- detached: true,
11
- stdio: "inherit"
12
- });
9
+ var child = spawn(
10
+ process.execPath,
11
+ ["-e", `require(${JSON.stringify(serverPath)}).startServer()`],
12
+ {
13
+ detached: true,
14
+ stdio: "inherit"
15
+ }
16
+ );
13
17
  child.unref();
14
18
  process.exit(0);
package/dist/client.cjs CHANGED
@@ -374,70 +374,77 @@ var getDefaultRelayClient = () => {
374
374
  }
375
375
  return defaultRelayClient;
376
376
  };
377
-
378
- // src/client.ts
379
- var AGENT_ID = "cursor";
380
377
  var isReactGrabApi = (value) => typeof value === "object" && value !== null && "registerPlugin" in value;
381
- var createCursorAgentProvider = (providerOptions = {}) => {
382
- const relayClient = providerOptions.relayClient ?? getDefaultRelayClient();
383
- if (!relayClient) {
384
- throw new Error("RelayClient is required in browser environments");
385
- }
386
- return createRelayAgentProvider({
387
- relayClient,
388
- agentId: AGENT_ID
389
- });
390
- };
391
- var attachAgent = async () => {
392
- if (typeof window === "undefined") return;
393
- const relayClient = getDefaultRelayClient();
394
- if (!relayClient) return;
395
- try {
396
- await relayClient.connect();
397
- } catch {
398
- return;
399
- }
400
- const provider = createRelayAgentProvider({
401
- relayClient,
402
- agentId: AGENT_ID
403
- });
404
- const attach = (api) => {
405
- const agent = { provider, storage: sessionStorage };
406
- const plugin = {
407
- name: "cursor-agent",
408
- actions: [
409
- {
410
- id: "edit-with-cursor",
411
- label: "Edit with Cursor",
412
- shortcut: "Enter",
413
- onAction: (actionContext) => {
414
- actionContext.enterPromptMode?.(agent);
415
- },
416
- agent
417
- }
418
- ]
378
+ var createProviderClientPlugin = (config) => {
379
+ const createAgentProvider = (providerOptions = {}) => {
380
+ const relayClient = providerOptions.relayClient ?? getDefaultRelayClient();
381
+ if (!relayClient) {
382
+ throw new Error("RelayClient is required in browser environments");
383
+ }
384
+ return createRelayAgentProvider({
385
+ relayClient,
386
+ agentId: config.agentId
387
+ });
388
+ };
389
+ const attachAgent2 = async () => {
390
+ if (typeof window === "undefined") return;
391
+ const relayClient = getDefaultRelayClient();
392
+ if (!relayClient) return;
393
+ try {
394
+ await relayClient.connect();
395
+ } catch {
396
+ return;
397
+ }
398
+ const provider = createRelayAgentProvider({
399
+ relayClient,
400
+ agentId: config.agentId
401
+ });
402
+ const attach = (api) => {
403
+ const agent = { provider, storage: sessionStorage };
404
+ api.registerPlugin({
405
+ name: config.pluginName,
406
+ actions: [
407
+ {
408
+ id: config.actionId,
409
+ label: config.actionLabel,
410
+ shortcut: "Enter",
411
+ onAction: (actionContext) => {
412
+ actionContext.enterPromptMode?.(agent);
413
+ },
414
+ agent
415
+ }
416
+ ]
417
+ });
419
418
  };
420
- api.registerPlugin(plugin);
419
+ const existingApi = window.__REACT_GRAB__;
420
+ if (isReactGrabApi(existingApi)) {
421
+ attach(existingApi);
422
+ return;
423
+ }
424
+ window.addEventListener(
425
+ "react-grab:init",
426
+ (event) => {
427
+ if (!(event instanceof CustomEvent)) return;
428
+ if (!isReactGrabApi(event.detail)) return;
429
+ attach(event.detail);
430
+ },
431
+ { once: true }
432
+ );
433
+ const apiAfterListener = window.__REACT_GRAB__;
434
+ if (isReactGrabApi(apiAfterListener)) {
435
+ attach(apiAfterListener);
436
+ }
421
437
  };
422
- const existingApi = window.__REACT_GRAB__;
423
- if (isReactGrabApi(existingApi)) {
424
- attach(existingApi);
425
- return;
426
- }
427
- window.addEventListener(
428
- "react-grab:init",
429
- (event) => {
430
- if (!(event instanceof CustomEvent)) return;
431
- if (!isReactGrabApi(event.detail)) return;
432
- attach(event.detail);
433
- },
434
- { once: true }
435
- );
436
- const apiAfterListener = window.__REACT_GRAB__;
437
- if (isReactGrabApi(apiAfterListener)) {
438
- attach(apiAfterListener);
439
- }
438
+ return { createAgentProvider, attachAgent: attachAgent2 };
440
439
  };
440
+
441
+ // src/client.ts
442
+ var { createAgentProvider: createCursorAgentProvider, attachAgent } = createProviderClientPlugin({
443
+ agentId: "cursor",
444
+ pluginName: "cursor-agent",
445
+ actionId: "edit-with-cursor",
446
+ actionLabel: "Edit with Cursor"
447
+ });
441
448
  attachAgent();
442
449
 
443
450
  exports.attachAgent = attachAgent;
package/dist/client.d.cts CHANGED
@@ -1,16 +1,9 @@
1
- import { init } from 'react-grab/core';
1
+ import * as _react_grab_relay_client from '@react-grab/relay/client';
2
2
  export { AgentCompleteResult } from 'react-grab/core';
3
- import { RelayClient, AgentProvider } from '@react-grab/relay/client';
4
3
 
5
- interface CursorAgentProviderOptions {
6
- relayClient?: RelayClient;
7
- }
8
- declare const createCursorAgentProvider: (providerOptions?: CursorAgentProviderOptions) => AgentProvider;
9
- declare global {
10
- interface Window {
11
- __REACT_GRAB__?: ReturnType<typeof init>;
12
- }
13
- }
4
+ declare const createCursorAgentProvider: (providerOptions?: {
5
+ relayClient?: _react_grab_relay_client.RelayClient;
6
+ }) => _react_grab_relay_client.AgentProvider;
14
7
  declare const attachAgent: () => Promise<void>;
15
8
 
16
9
  export { attachAgent, createCursorAgentProvider };
package/dist/client.d.ts CHANGED
@@ -1,16 +1,9 @@
1
- import { init } from 'react-grab/core';
1
+ import * as _react_grab_relay_client from '@react-grab/relay/client';
2
2
  export { AgentCompleteResult } from 'react-grab/core';
3
- import { RelayClient, AgentProvider } from '@react-grab/relay/client';
4
3
 
5
- interface CursorAgentProviderOptions {
6
- relayClient?: RelayClient;
7
- }
8
- declare const createCursorAgentProvider: (providerOptions?: CursorAgentProviderOptions) => AgentProvider;
9
- declare global {
10
- interface Window {
11
- __REACT_GRAB__?: ReturnType<typeof init>;
12
- }
13
- }
4
+ declare const createCursorAgentProvider: (providerOptions?: {
5
+ relayClient?: _react_grab_relay_client.RelayClient;
6
+ }) => _react_grab_relay_client.AgentProvider;
14
7
  declare const attachAgent: () => Promise<void>;
15
8
 
16
9
  export { attachAgent, createCursorAgentProvider };
@@ -1,2 +1,2 @@
1
- var ReactGrabCursor=(function(exports){'use strict';var q=4722,x=3e3,D="token",G=(i={})=>{let n=i.serverUrl??`ws://localhost:${q}`,c=i.autoReconnect??true,E=i.reconnectIntervalMs??x,h=i.token,s=null,f=false,A=[],C=null,t=null,o=null,w=false,y=new Set,g=new Set,r=new Set,u=()=>{!c||C||w||(C=setTimeout(()=>{C=null,p().catch(()=>{});},E));},l=e=>{try{let a=JSON.parse(e.data);if(a.type==="handlers"&&a.handlers){A=a.handlers;for(let S of g)S(A);}for(let S of y)S(a);}catch{}},p=()=>s?.readyState===WebSocket.OPEN?Promise.resolve():t||(w=false,t=new Promise((e,a)=>{o=a;let S=h?`${n}?${D}=${encodeURIComponent(h)}`:n;s=new WebSocket(S),s.onopen=()=>{t=null,o=null,f=true;for(let P of r)P(true);e();},s.onmessage=l,s.onclose=()=>{o&&(o(new Error("WebSocket connection closed")),o=null),t=null,f=false,A=[];for(let P of g)P(A);for(let P of r)P(false);u();},s.onerror=()=>{t=null,o=null,f=false,a(new Error("WebSocket connection failed"));};}),t),v=()=>{w=true,C&&(clearTimeout(C),C=null),o&&(o(new Error("Connection aborted")),o=null),t=null,s?.close(),s=null,f=false,A=[];},m=()=>f,R=e=>s?.readyState===WebSocket.OPEN?(s.send(JSON.stringify(e)),true):false;return {connect:p,disconnect:v,isConnected:m,sendAgentRequest:(e,a)=>R({type:"agent-request",agentId:e,sessionId:a.sessionId,context:a}),abortAgent:(e,a)=>{R({type:"agent-abort",agentId:e,sessionId:a});},undoAgent:(e,a)=>R({type:"agent-undo",agentId:e,sessionId:a}),redoAgent:(e,a)=>R({type:"agent-redo",agentId:e,sessionId:a}),onMessage:e=>(y.add(e),()=>y.delete(e)),onHandlersChange:e=>(g.add(e),()=>g.delete(e)),onConnectionChange:e=>(r.add(e),queueMicrotask(()=>{r.has(e)&&e(f);}),()=>r.delete(e)),getAvailableHandlers:()=>A}},I=i=>{let{relayClient:n,agentId:c}=i,E=async()=>{if(!n.isConnected())try{await n.connect();}catch{return false}return n.getAvailableHandlers().includes(c)},h=async function*(t,o){if(o.aborted)throw new DOMException("Aborted","AbortError");yield "Connecting\u2026";let w=t.sessionId??`session-${Date.now()}-${Math.random().toString(36).slice(2)}`,y={...t,sessionId:w},g=[],r=null,u=null,l=false,p=null,v=()=>{n.abortAgent(c,w),l=true,r&&(r({value:void 0,done:true}),r=null,u=null);};o.addEventListener("abort",v,{once:true});let m=d=>{!d&&!l&&(p="Relay connection lost",l=true,u&&(u(new Error(p)),r=null,u=null));},R=n.onConnectionChange(m),M=n.onMessage(d=>{if(d.sessionId===w)if(d.type==="agent-status"&&d.content){if(g.push(d.content),r){let b=g.shift();b!==void 0&&(r({value:b,done:false}),r=null,u=null);}}else d.type==="agent-done"?(l=true,r&&(r({value:void 0,done:true}),r=null,u=null)):d.type==="agent-error"&&(p=d.content??"Unknown error",l=true,u&&(u(new Error(p)),r=null,u=null));});if(!n.isConnected())throw R(),M(),o.removeEventListener("abort",v),new Error("Relay connection is not open");if(!n.sendAgentRequest(c,y))throw R(),M(),o.removeEventListener("abort",v),new Error("Failed to send agent request: connection not open");try{for(;;){if(g.length>0){let b=g.shift();b!==void 0&&(yield b);continue}if(l||o.aborted)break;let d=await new Promise((b,L)=>{r=b,u=L;});if(d.done)break;yield d.value;}if(p)throw new Error(p)}finally{o.removeEventListener("abort",v),R(),M();}},s=async t=>{n.abortAgent(c,t);},f=t=>new Promise((o,w)=>{let y=false,g=()=>{y||(y=true,r(),u());},r=n.onMessage(l=>{l.sessionId===t&&(g(),l.type==="agent-done"?o():l.type==="agent-error"&&w(new Error(l.content??"Operation failed")));}),u=n.onConnectionChange(l=>{l||(g(),w(new Error("Connection lost while waiting for operation response")));});});return {send:h,abort:s,undo:async()=>{let t=`undo-${c}-${Date.now()}-${Math.random().toString(36).slice(2)}`;if(!n.undoAgent(c,t))throw new Error("Failed to send undo request: connection not open");return f(t)},redo:async()=>{let t=`redo-${c}-${Date.now()}-${Math.random().toString(36).slice(2)}`;if(!n.redoAgent(c,t))throw new Error("Failed to send redo request: connection not open");return f(t)},checkConnection:E,supportsResume:true,supportsFollowUp:true}},_=null,k=()=>typeof window>"u"?null:window.__REACT_GRAB_RELAY__?(_=window.__REACT_GRAB_RELAY__,_):(_||(_=G(),window.__REACT_GRAB_RELAY__=_),_);var O="cursor",T=i=>typeof i=="object"&&i!==null&&"registerPlugin"in i,Y=(i={})=>{let n=i.relayClient??k();if(!n)throw new Error("RelayClient is required in browser environments");return I({relayClient:n,agentId:O})},N=async()=>{if(typeof window>"u")return;let i=k();if(!i)return;try{await i.connect();}catch{return}let n=I({relayClient:i,agentId:O}),c=s=>{let f={provider:n,storage:sessionStorage},A={name:"cursor-agent",actions:[{id:"edit-with-cursor",label:"Edit with Cursor",shortcut:"Enter",onAction:C=>{C.enterPromptMode?.(f);},agent:f}]};s.registerPlugin(A);},E=window.__REACT_GRAB__;if(T(E)){c(E);return}window.addEventListener("react-grab:init",s=>{s instanceof CustomEvent&&T(s.detail)&&c(s.detail);},{once:true});let h=window.__REACT_GRAB__;T(h)&&c(h);};N();
2
- exports.attachAgent=N;exports.createCursorAgentProvider=Y;return exports;})({});
1
+ var ReactGrabCursor=(function(exports){'use strict';var q=4722,O=3e3,D="token",x=(s={})=>{let r=s.serverUrl??`ws://localhost:${q}`,w=s.autoReconnect??true,p=s.reconnectIntervalMs??O,h=s.token,i=null,f=false,C=[],d=null,e=null,t=null,A=false,y=new Set,g=new Set,o=new Set,l=()=>{!w||d||A||(d=setTimeout(()=>{d=null,b().catch(()=>{});},p));},c=n=>{try{let a=JSON.parse(n.data);if(a.type==="handlers"&&a.handlers){C=a.handlers;for(let S of g)S(C);}for(let S of y)S(a);}catch{}},b=()=>i?.readyState===WebSocket.OPEN?Promise.resolve():e||(A=false,e=new Promise((n,a)=>{t=a;let S=h?`${r}?${D}=${encodeURIComponent(h)}`:r;i=new WebSocket(S),i.onopen=()=>{e=null,t=null,f=true;for(let m of o)m(true);n();},i.onmessage=c,i.onclose=()=>{t&&(t(new Error("WebSocket connection closed")),t=null),e=null,f=false,C=[];for(let m of g)m(C);for(let m of o)m(false);l();},i.onerror=()=>{e=null,t=null,f=false,a(new Error("WebSocket connection failed"));};}),e),R=()=>{A=true,d&&(clearTimeout(d),d=null),t&&(t(new Error("Connection aborted")),t=null),e=null,i?.close(),i=null,f=false,C=[];},M=()=>f,v=n=>i?.readyState===WebSocket.OPEN?(i.send(JSON.stringify(n)),true):false;return {connect:b,disconnect:R,isConnected:M,sendAgentRequest:(n,a)=>v({type:"agent-request",agentId:n,sessionId:a.sessionId,context:a}),abortAgent:(n,a)=>{v({type:"agent-abort",agentId:n,sessionId:a});},undoAgent:(n,a)=>v({type:"agent-undo",agentId:n,sessionId:a}),redoAgent:(n,a)=>v({type:"agent-redo",agentId:n,sessionId:a}),onMessage:n=>(y.add(n),()=>y.delete(n)),onHandlersChange:n=>(g.add(n),()=>g.delete(n)),onConnectionChange:n=>(o.add(n),queueMicrotask(()=>{o.has(n)&&n(f);}),()=>o.delete(n)),getAvailableHandlers:()=>C}},L=s=>{let{relayClient:r,agentId:w}=s,p=async()=>{if(!r.isConnected())try{await r.connect();}catch{return false}return r.getAvailableHandlers().includes(w)},h=async function*(e,t){if(t.aborted)throw new DOMException("Aborted","AbortError");yield "Connecting\u2026";let A=e.sessionId??`session-${Date.now()}-${Math.random().toString(36).slice(2)}`,y={...e,sessionId:A},g=[],o=null,l=null,c=false,b=null,R=()=>{r.abortAgent(w,A),c=true,o&&(o({value:void 0,done:true}),o=null,l=null);};t.addEventListener("abort",R,{once:true});let M=u=>{!u&&!c&&(b="Relay connection lost",c=true,l&&(l(new Error(b)),o=null,l=null));},v=r.onConnectionChange(M),I=r.onMessage(u=>{if(u.sessionId===A)if(u.type==="agent-status"&&u.content){if(g.push(u.content),o){let E=g.shift();E!==void 0&&(o({value:E,done:false}),o=null,l=null);}}else u.type==="agent-done"?(c=true,o&&(o({value:void 0,done:true}),o=null,l=null)):u.type==="agent-error"&&(b=u.content??"Unknown error",c=true,l&&(l(new Error(b)),o=null,l=null));});if(!r.isConnected())throw v(),I(),t.removeEventListener("abort",R),new Error("Relay connection is not open");if(!r.sendAgentRequest(w,y))throw v(),I(),t.removeEventListener("abort",R),new Error("Failed to send agent request: connection not open");try{for(;;){if(g.length>0){let E=g.shift();E!==void 0&&(yield E);continue}if(c||t.aborted)break;let u=await new Promise((E,k)=>{o=E,l=k;});if(u.done)break;yield u.value;}if(b)throw new Error(b)}finally{t.removeEventListener("abort",R),v(),I();}},i=async e=>{r.abortAgent(w,e);},f=e=>new Promise((t,A)=>{let y=false,g=()=>{y||(y=true,o(),l());},o=r.onMessage(c=>{c.sessionId===e&&(g(),c.type==="agent-done"?t():c.type==="agent-error"&&A(new Error(c.content??"Operation failed")));}),l=r.onConnectionChange(c=>{c||(g(),A(new Error("Connection lost while waiting for operation response")));});});return {send:h,abort:i,undo:async()=>{let e=`undo-${w}-${Date.now()}-${Math.random().toString(36).slice(2)}`;if(!r.undoAgent(w,e))throw new Error("Failed to send undo request: connection not open");return f(e)},redo:async()=>{let e=`redo-${w}-${Date.now()}-${Math.random().toString(36).slice(2)}`;if(!r.redoAgent(w,e))throw new Error("Failed to send redo request: connection not open");return f(e)},checkConnection:p,supportsResume:true,supportsFollowUp:true}},_=null,T=()=>typeof window>"u"?null:window.__REACT_GRAB_RELAY__?(_=window.__REACT_GRAB_RELAY__,_):(_||(_=x(),window.__REACT_GRAB_RELAY__=_),_),P=s=>typeof s=="object"&&s!==null&&"registerPlugin"in s,N=s=>({createAgentProvider:(p={})=>{let h=p.relayClient??T();if(!h)throw new Error("RelayClient is required in browser environments");return L({relayClient:h,agentId:s.agentId})},attachAgent:async()=>{if(typeof window>"u")return;let p=T();if(!p)return;try{await p.connect();}catch{return}let h=L({relayClient:p,agentId:s.agentId}),i=d=>{let e={provider:h,storage:sessionStorage};d.registerPlugin({name:s.pluginName,actions:[{id:s.actionId,label:s.actionLabel,shortcut:"Enter",onAction:t=>{t.enterPromptMode?.(e);},agent:e}]});},f=window.__REACT_GRAB__;if(P(f)){i(f);return}window.addEventListener("react-grab:init",d=>{d instanceof CustomEvent&&P(d.detail)&&i(d.detail);},{once:true});let C=window.__REACT_GRAB__;P(C)&&i(C);}});var {createAgentProvider:Y,attachAgent:U}=N({agentId:"cursor",pluginName:"cursor-agent",actionId:"edit-with-cursor",actionLabel:"Edit with Cursor"});U();
2
+ exports.attachAgent=U;exports.createCursorAgentProvider=Y;return exports;})({});
package/dist/client.js CHANGED
@@ -372,70 +372,77 @@ var getDefaultRelayClient = () => {
372
372
  }
373
373
  return defaultRelayClient;
374
374
  };
375
-
376
- // src/client.ts
377
- var AGENT_ID = "cursor";
378
375
  var isReactGrabApi = (value) => typeof value === "object" && value !== null && "registerPlugin" in value;
379
- var createCursorAgentProvider = (providerOptions = {}) => {
380
- const relayClient = providerOptions.relayClient ?? getDefaultRelayClient();
381
- if (!relayClient) {
382
- throw new Error("RelayClient is required in browser environments");
383
- }
384
- return createRelayAgentProvider({
385
- relayClient,
386
- agentId: AGENT_ID
387
- });
388
- };
389
- var attachAgent = async () => {
390
- if (typeof window === "undefined") return;
391
- const relayClient = getDefaultRelayClient();
392
- if (!relayClient) return;
393
- try {
394
- await relayClient.connect();
395
- } catch {
396
- return;
397
- }
398
- const provider = createRelayAgentProvider({
399
- relayClient,
400
- agentId: AGENT_ID
401
- });
402
- const attach = (api) => {
403
- const agent = { provider, storage: sessionStorage };
404
- const plugin = {
405
- name: "cursor-agent",
406
- actions: [
407
- {
408
- id: "edit-with-cursor",
409
- label: "Edit with Cursor",
410
- shortcut: "Enter",
411
- onAction: (actionContext) => {
412
- actionContext.enterPromptMode?.(agent);
413
- },
414
- agent
415
- }
416
- ]
376
+ var createProviderClientPlugin = (config) => {
377
+ const createAgentProvider = (providerOptions = {}) => {
378
+ const relayClient = providerOptions.relayClient ?? getDefaultRelayClient();
379
+ if (!relayClient) {
380
+ throw new Error("RelayClient is required in browser environments");
381
+ }
382
+ return createRelayAgentProvider({
383
+ relayClient,
384
+ agentId: config.agentId
385
+ });
386
+ };
387
+ const attachAgent2 = async () => {
388
+ if (typeof window === "undefined") return;
389
+ const relayClient = getDefaultRelayClient();
390
+ if (!relayClient) return;
391
+ try {
392
+ await relayClient.connect();
393
+ } catch {
394
+ return;
395
+ }
396
+ const provider = createRelayAgentProvider({
397
+ relayClient,
398
+ agentId: config.agentId
399
+ });
400
+ const attach = (api) => {
401
+ const agent = { provider, storage: sessionStorage };
402
+ api.registerPlugin({
403
+ name: config.pluginName,
404
+ actions: [
405
+ {
406
+ id: config.actionId,
407
+ label: config.actionLabel,
408
+ shortcut: "Enter",
409
+ onAction: (actionContext) => {
410
+ actionContext.enterPromptMode?.(agent);
411
+ },
412
+ agent
413
+ }
414
+ ]
415
+ });
417
416
  };
418
- api.registerPlugin(plugin);
417
+ const existingApi = window.__REACT_GRAB__;
418
+ if (isReactGrabApi(existingApi)) {
419
+ attach(existingApi);
420
+ return;
421
+ }
422
+ window.addEventListener(
423
+ "react-grab:init",
424
+ (event) => {
425
+ if (!(event instanceof CustomEvent)) return;
426
+ if (!isReactGrabApi(event.detail)) return;
427
+ attach(event.detail);
428
+ },
429
+ { once: true }
430
+ );
431
+ const apiAfterListener = window.__REACT_GRAB__;
432
+ if (isReactGrabApi(apiAfterListener)) {
433
+ attach(apiAfterListener);
434
+ }
419
435
  };
420
- const existingApi = window.__REACT_GRAB__;
421
- if (isReactGrabApi(existingApi)) {
422
- attach(existingApi);
423
- return;
424
- }
425
- window.addEventListener(
426
- "react-grab:init",
427
- (event) => {
428
- if (!(event instanceof CustomEvent)) return;
429
- if (!isReactGrabApi(event.detail)) return;
430
- attach(event.detail);
431
- },
432
- { once: true }
433
- );
434
- const apiAfterListener = window.__REACT_GRAB__;
435
- if (isReactGrabApi(apiAfterListener)) {
436
- attach(apiAfterListener);
437
- }
436
+ return { createAgentProvider, attachAgent: attachAgent2 };
438
437
  };
438
+
439
+ // src/client.ts
440
+ var { createAgentProvider: createCursorAgentProvider, attachAgent } = createProviderClientPlugin({
441
+ agentId: "cursor",
442
+ pluginName: "cursor-agent",
443
+ actionId: "edit-with-cursor",
444
+ actionLabel: "Edit with Cursor"
445
+ });
439
446
  attachAgent();
440
447
 
441
448
  export { attachAgent, createCursorAgentProvider };
package/dist/server.cjs CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  'use strict';
3
2
 
4
3
  var http = require('http');
@@ -8374,7 +8373,7 @@ async function fkill(inputs, options = {}) {
8374
8373
  }
8375
8374
  }
8376
8375
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
8377
- var VERSION = "0.1.15";
8376
+ var VERSION = "0.1.16";
8378
8377
  var checkIfRelayServerIsRunning = async (port, token) => {
8379
8378
  try {
8380
8379
  const healthUrl = token ? `http://localhost:${port}/health?${RELAY_TOKEN_PARAM}=${encodeURIComponent(token)}` : `http://localhost:${port}/health`;
@@ -8606,6 +8605,13 @@ var printStartupMessage = (agentId, port) => {
8606
8605
  );
8607
8606
  console.log(`- Local: ${import_picocolors.default.cyan(`ws://localhost:${port}`)}`);
8608
8607
  };
8608
+ var startProviderServer = (source, handler) => {
8609
+ fetch(
8610
+ `https://www.react-grab.com/api/version?source=${source}&t=${Date.now()}`
8611
+ ).catch(() => {
8612
+ });
8613
+ connectRelay({ handler });
8614
+ };
8609
8615
 
8610
8616
  // ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
8611
8617
  function isPlainObject(value) {
@@ -15415,8 +15421,8 @@ var cursorAgentHandler = {
15415
15421
  };
15416
15422
 
15417
15423
  // src/server.ts
15418
- fetch(
15419
- `https://www.react-grab.com/api/version?source=cursor&t=${Date.now()}`
15420
- ).catch(() => {
15421
- });
15422
- connectRelay({ handler: cursorAgentHandler });
15424
+ var startServer = () => {
15425
+ startProviderServer("cursor", cursorAgentHandler);
15426
+ };
15427
+
15428
+ exports.startServer = startServer;
package/dist/server.d.cts CHANGED
@@ -1 +1,3 @@
1
- #!/usr/bin/env node
1
+ declare const startServer: () => void;
2
+
3
+ export { startServer };
package/dist/server.d.ts CHANGED
@@ -1 +1,3 @@
1
- #!/usr/bin/env node
1
+ declare const startServer: () => void;
2
+
3
+ export { startServer };
package/dist/server.js CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  import { createServer } from 'http';
3
2
  import process2, { hrtime, execPath, execArgv, platform } from 'process';
4
3
  import { Buffer as Buffer$1 } from 'buffer';
@@ -8363,7 +8362,7 @@ async function fkill(inputs, options = {}) {
8363
8362
  }
8364
8363
  }
8365
8364
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
8366
- var VERSION = "0.1.15";
8365
+ var VERSION = "0.1.16";
8367
8366
  var checkIfRelayServerIsRunning = async (port, token) => {
8368
8367
  try {
8369
8368
  const healthUrl = token ? `http://localhost:${port}/health?${RELAY_TOKEN_PARAM}=${encodeURIComponent(token)}` : `http://localhost:${port}/health`;
@@ -8595,6 +8594,13 @@ var printStartupMessage = (agentId, port) => {
8595
8594
  );
8596
8595
  console.log(`- Local: ${import_picocolors.default.cyan(`ws://localhost:${port}`)}`);
8597
8596
  };
8597
+ var startProviderServer = (source, handler) => {
8598
+ fetch(
8599
+ `https://www.react-grab.com/api/version?source=${source}&t=${Date.now()}`
8600
+ ).catch(() => {
8601
+ });
8602
+ connectRelay({ handler });
8603
+ };
8598
8604
 
8599
8605
  // ../../node_modules/.pnpm/is-plain-obj@4.1.0/node_modules/is-plain-obj/index.js
8600
8606
  function isPlainObject(value) {
@@ -15404,8 +15410,8 @@ var cursorAgentHandler = {
15404
15410
  };
15405
15411
 
15406
15412
  // src/server.ts
15407
- fetch(
15408
- `https://www.react-grab.com/api/version?source=cursor&t=${Date.now()}`
15409
- ).catch(() => {
15410
- });
15411
- connectRelay({ handler: cursorAgentHandler });
15413
+ var startServer = () => {
15414
+ startProviderServer("cursor", cursorAgentHandler);
15415
+ };
15416
+
15417
+ export { startServer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-grab/cursor",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "bin": {
5
5
  "react-grab-cursor": "./dist/cli.cjs"
6
6
  },
@@ -30,13 +30,13 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "execa": "^9.6.0",
33
- "@react-grab/relay": "0.1.15",
34
- "react-grab": "0.1.15"
33
+ "@react-grab/relay": "0.1.16",
34
+ "react-grab": "0.1.16"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^22.10.7",
38
38
  "tsup": "^8.4.0",
39
- "@react-grab/utils": "0.1.15"
39
+ "@react-grab/utils": "0.1.16"
40
40
  },
41
41
  "scripts": {
42
42
  "dev": "tsup --watch",