@react-grab/claude-code 0.0.82 → 0.0.83

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
@@ -603,7 +603,7 @@ var import_picocolors = __toESM(require_picocolors());
603
603
  var DEFAULT_PORT = 4567;
604
604
 
605
605
  // src/cli.ts
606
- var VERSION = "0.0.82";
606
+ var VERSION = "0.0.83";
607
607
  var serverPath = path.join(__dirname, "server.cjs");
608
608
  (0, import_cross_spawn.default)(process.execPath, [serverPath], {
609
609
  detached: true,
package/dist/cli.js CHANGED
@@ -601,7 +601,7 @@ var import_picocolors = __toESM(require_picocolors());
601
601
  var DEFAULT_PORT = 4567;
602
602
 
603
603
  // src/cli.ts
604
- var VERSION = "0.0.82";
604
+ var VERSION = "0.0.83";
605
605
  var serverPath = join(__dirname, "server.cjs");
606
606
  (0, import_cross_spawn.default)(process.execPath, [serverPath], {
607
607
  detached: true,
package/dist/client.cjs CHANGED
@@ -1,24 +1,8 @@
1
1
  'use strict';
2
2
 
3
- // src/constants.ts
4
- var DEFAULT_PORT = 4567;
3
+ // ../utils/dist/client.js
5
4
  var CONNECTION_CHECK_TTL_MS = 5e3;
6
-
7
- // src/client.ts
8
- var DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_PORT}`;
9
5
  var STORAGE_KEY = "react-grab:agent-sessions";
10
- var DEFAULT_OPTIONS = {
11
- systemPrompt: {
12
- type: "preset",
13
- preset: "claude_code",
14
- append: `You are helping a user make changes to a React component based on a selected element.
15
- The user has selected an element from their UI and wants you to help modify it.
16
- Provide clear, concise status updates as you work.`
17
- },
18
- model: "haiku",
19
- permissionMode: "bypassPermissions",
20
- maxTurns: 10
21
- };
22
6
  var parseSSEEvent = (eventBlock) => {
23
7
  let eventType = "";
24
8
  let data = "";
@@ -68,7 +52,26 @@ async function* streamSSE(stream, signal) {
68
52
  }
69
53
  }
70
54
  }
55
+
56
+ // src/constants.ts
57
+ var DEFAULT_PORT = 4567;
58
+
59
+ // src/client.ts
60
+ var DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_PORT}`;
61
+ var DEFAULT_OPTIONS = {
62
+ systemPrompt: {
63
+ type: "preset",
64
+ preset: "claude_code",
65
+ append: `You are helping a user make changes to a React component based on a selected element.
66
+ The user has selected an element from their UI and wants you to help modify it.
67
+ Provide clear, concise status updates as you work.`
68
+ },
69
+ model: "haiku",
70
+ permissionMode: "bypassPermissions",
71
+ maxTurns: 10
72
+ };
71
73
  async function* streamFromServer(serverUrl, context, signal) {
74
+ const startTime = Date.now();
72
75
  const sessionId = context.sessionId;
73
76
  const handleAbort = () => {
74
77
  if (sessionId) {
@@ -92,7 +95,37 @@ async function* streamFromServer(serverUrl, context, signal) {
92
95
  if (!response.body) {
93
96
  throw new Error("No response body");
94
97
  }
95
- yield* streamSSE(response.body, signal);
98
+ const iterator = streamSSE(response.body, signal)[Symbol.asyncIterator]();
99
+ let done = false;
100
+ let pendingNext = iterator.next();
101
+ while (!done) {
102
+ const result = await Promise.race([
103
+ pendingNext.then((iteratorResult) => ({
104
+ type: "status",
105
+ iteratorResult
106
+ })),
107
+ new Promise(
108
+ (resolve) => setTimeout(() => resolve({ type: "timeout" }), 100)
109
+ )
110
+ ]);
111
+ if (result.type === "timeout") {
112
+ const elapsedSeconds = (Date.now() - startTime) / 1e3;
113
+ yield `Working\u2026 ${elapsedSeconds.toFixed(1)}s`;
114
+ } else {
115
+ const iteratorResult = result.iteratorResult;
116
+ done = iteratorResult.done ?? false;
117
+ if (!done && iteratorResult.value) {
118
+ const status = iteratorResult.value;
119
+ if (status === "Completed successfully") {
120
+ const totalSeconds = ((Date.now() - startTime) / 1e3).toFixed(1);
121
+ yield `Completed in ${totalSeconds}s`;
122
+ } else {
123
+ yield status;
124
+ }
125
+ pendingNext = iterator.next();
126
+ }
127
+ }
128
+ }
96
129
  } finally {
97
130
  signal.removeEventListener("abort", handleAbort);
98
131
  }
@@ -1,6 +1,6 @@
1
- var ReactGrabClaudeCode=(function(exports){'use strict';var A=`http://localhost:${4567}`,y="react-grab:agent-sessions",E={systemPrompt:{type:"preset",preset:"claude_code",append:`You are helping a user make changes to a React component based on a selected element.
2
- The user has selected an element from their UI and wants you to help modify it.
3
- Provide clear, concise status updates as you work.`},model:"haiku",permissionMode:"bypassPermissions",maxTurns:10},b=s=>{let t="",o="";for(let n of s.split(`
4
- `))n.startsWith("event:")?t=n.slice(6).trim():n.startsWith("data:")&&(o=n.slice(5).trim());return {eventType:t,data:o}};async function*h(s,t){let o=s.getReader(),n=new TextDecoder,r="",e=false,i=()=>{e=true,o.cancel().catch(()=>{});};t.addEventListener("abort",i);try{if(t.aborted)throw new DOMException("Aborted","AbortError");for(;;){let a=await o.read();if(e||t.aborted)throw new DOMException("Aborted","AbortError");let{done:p,value:u}=a;u&&(r+=n.decode(u,{stream:!0}));let c;for(;(c=r.indexOf(`
1
+ var ReactGrabClaudeCode=(function(exports){'use strict';var m=5e3,f="react-grab:agent-sessions",A=c=>{let e="",n="";for(let t of c.split(`
2
+ `))t.startsWith("event:")?e=t.slice(6).trim():t.startsWith("data:")&&(n=t.slice(5).trim());return {eventType:e,data:n}};async function*y(c,e){let n=c.getReader(),t=new TextDecoder,s="",o=false,a=()=>{o=true,n.cancel().catch(()=>{});};e.addEventListener("abort",a);try{if(e.aborted)throw new DOMException("Aborted","AbortError");for(;;){let i=await n.read();if(o||e.aborted)throw new DOMException("Aborted","AbortError");let{done:l,value:u}=i;u&&(s+=t.decode(u,{stream:!0}));let d;for(;(d=s.indexOf(`
5
3
 
6
- `))!==-1;){let{eventType:d,data:l}=b(r.slice(0,c));if(r=r.slice(c+2),d==="done")return;if(d==="error")throw new Error(l||"Agent error");l&&(yield l);}if(p)break}}finally{t.removeEventListener("abort",i);try{o.releaseLock();}catch{}}}async function*m(s,t,o){let n=t.sessionId,r=()=>{n&&fetch(`${s}/abort/${n}`,{method:"POST"}).catch(()=>{});};o.addEventListener("abort",r);try{let e=await fetch(`${s}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:o});if(!e.ok)throw new Error(`Server error: ${e.status}`);if(!e.body)throw new Error("No response body");yield*h(e.body,o);}finally{o.removeEventListener("abort",r);}}var C=(s={})=>{let{serverUrl:t=A,getOptions:o}=s,n=null,r=e=>({...E,...o?.()??{},...e??{}});return {send:async function*(e,i){let a={...e,options:r(e.options)};yield*m(t,a,i);},resume:async function*(e,i,a){let p=a.getItem(y);if(!p)throw new Error("No sessions to resume");let c=JSON.parse(p)[e];if(!c)throw new Error(`Session ${e} not found`);let d=c.context,l={...d,options:r(d.options)};yield "Resuming...",yield*m(t,l,i);},supportsResume:true,supportsFollowUp:true,checkConnection:async()=>{let e=Date.now();if(n&&e-n.timestamp<5e3)return n.result;try{let a=(await fetch(`${t}/health`,{method:"GET"})).ok;return n={result:a,timestamp:e},a}catch{return n={result:false,timestamp:e},false}}}},w=async()=>{if(typeof window>"u")return;let s=C(),t=r=>{r.setAgent({provider:s,storage:sessionStorage});},o=window.__REACT_GRAB__;if(o){t(o);return}window.addEventListener("react-grab:init",r=>{t(r.detail);},{once:true});let n=window.__REACT_GRAB__;n&&t(n);};w();exports.attachAgent=w;exports.createClaudeAgentProvider=C;return exports;})({});
4
+ `))!==-1;){let{eventType:r,data:p}=A(s.slice(0,d));if(s=s.slice(d+2),r==="done")return;if(r==="error")throw new Error(p||"Agent error");p&&(yield p);}if(l)break}}finally{e.removeEventListener("abort",a);try{n.releaseLock();}catch{}}}var w=`http://localhost:${4567}`,C={systemPrompt:{type:"preset",preset:"claude_code",append:`You are helping a user make changes to a React component based on a selected element.
5
+ The user has selected an element from their UI and wants you to help modify it.
6
+ Provide clear, concise status updates as you work.`},model:"haiku",permissionMode:"bypassPermissions",maxTurns:10};async function*g(c,e,n){let t=Date.now(),s=e.sessionId,o=()=>{s&&fetch(`${c}/abort/${s}`,{method:"POST"}).catch(()=>{});};n.addEventListener("abort",o);try{let a=await fetch(`${c}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:n});if(!a.ok)throw new Error(`Server error: ${a.status}`);if(!a.body)throw new Error("No response body");let i=y(a.body,n)[Symbol.asyncIterator](),l=!1,u=i.next();for(;!l;){let d=await Promise.race([u.then(r=>({type:"status",iteratorResult:r})),new Promise(r=>setTimeout(()=>r({type:"timeout"}),100))]);if(d.type==="timeout")yield `Working\u2026 ${((Date.now()-t)/1e3).toFixed(1)}s`;else {let r=d.iteratorResult;if(l=r.done??!1,!l&&r.value){let p=r.value;p==="Completed successfully"?yield `Completed in ${((Date.now()-t)/1e3).toFixed(1)}s`:yield p,u=i.next();}}}}finally{n.removeEventListener("abort",o);}}var E=(c={})=>{let{serverUrl:e=w,getOptions:n}=c,t=null,s=o=>({...C,...n?.()??{},...o??{}});return {send:async function*(o,a){let i={...o,options:s(o.options)};yield*g(e,i,a);},resume:async function*(o,a,i){let l=i.getItem(f);if(!l)throw new Error("No sessions to resume");let d=JSON.parse(l)[o];if(!d)throw new Error(`Session ${o} not found`);let r=d.context,p={...r,options:s(r.options)};yield "Resuming...",yield*g(e,p,a);},supportsResume:true,supportsFollowUp:true,checkConnection:async()=>{let o=Date.now();if(t&&o-t.timestamp<m)return t.result;try{let i=(await fetch(`${e}/health`,{method:"GET"})).ok;return t={result:i,timestamp:o},i}catch{return t={result:false,timestamp:o},false}}}},b=async()=>{if(typeof window>"u")return;let c=E(),e=s=>{s.setAgent({provider:c,storage:sessionStorage});},n=window.__REACT_GRAB__;if(n){e(n);return}window.addEventListener("react-grab:init",s=>{e(s.detail);},{once:true});let t=window.__REACT_GRAB__;t&&e(t);};b();exports.attachAgent=b;exports.createClaudeAgentProvider=E;return exports;})({});
package/dist/client.js CHANGED
@@ -1,22 +1,6 @@
1
- // src/constants.ts
2
- var DEFAULT_PORT = 4567;
1
+ // ../utils/dist/client.js
3
2
  var CONNECTION_CHECK_TTL_MS = 5e3;
4
-
5
- // src/client.ts
6
- var DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_PORT}`;
7
3
  var STORAGE_KEY = "react-grab:agent-sessions";
8
- var DEFAULT_OPTIONS = {
9
- systemPrompt: {
10
- type: "preset",
11
- preset: "claude_code",
12
- append: `You are helping a user make changes to a React component based on a selected element.
13
- The user has selected an element from their UI and wants you to help modify it.
14
- Provide clear, concise status updates as you work.`
15
- },
16
- model: "haiku",
17
- permissionMode: "bypassPermissions",
18
- maxTurns: 10
19
- };
20
4
  var parseSSEEvent = (eventBlock) => {
21
5
  let eventType = "";
22
6
  let data = "";
@@ -66,7 +50,26 @@ async function* streamSSE(stream, signal) {
66
50
  }
67
51
  }
68
52
  }
53
+
54
+ // src/constants.ts
55
+ var DEFAULT_PORT = 4567;
56
+
57
+ // src/client.ts
58
+ var DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_PORT}`;
59
+ var DEFAULT_OPTIONS = {
60
+ systemPrompt: {
61
+ type: "preset",
62
+ preset: "claude_code",
63
+ append: `You are helping a user make changes to a React component based on a selected element.
64
+ The user has selected an element from their UI and wants you to help modify it.
65
+ Provide clear, concise status updates as you work.`
66
+ },
67
+ model: "haiku",
68
+ permissionMode: "bypassPermissions",
69
+ maxTurns: 10
70
+ };
69
71
  async function* streamFromServer(serverUrl, context, signal) {
72
+ const startTime = Date.now();
70
73
  const sessionId = context.sessionId;
71
74
  const handleAbort = () => {
72
75
  if (sessionId) {
@@ -90,7 +93,37 @@ async function* streamFromServer(serverUrl, context, signal) {
90
93
  if (!response.body) {
91
94
  throw new Error("No response body");
92
95
  }
93
- yield* streamSSE(response.body, signal);
96
+ const iterator = streamSSE(response.body, signal)[Symbol.asyncIterator]();
97
+ let done = false;
98
+ let pendingNext = iterator.next();
99
+ while (!done) {
100
+ const result = await Promise.race([
101
+ pendingNext.then((iteratorResult) => ({
102
+ type: "status",
103
+ iteratorResult
104
+ })),
105
+ new Promise(
106
+ (resolve) => setTimeout(() => resolve({ type: "timeout" }), 100)
107
+ )
108
+ ]);
109
+ if (result.type === "timeout") {
110
+ const elapsedSeconds = (Date.now() - startTime) / 1e3;
111
+ yield `Working\u2026 ${elapsedSeconds.toFixed(1)}s`;
112
+ } else {
113
+ const iteratorResult = result.iteratorResult;
114
+ done = iteratorResult.done ?? false;
115
+ if (!done && iteratorResult.value) {
116
+ const status = iteratorResult.value;
117
+ if (status === "Completed successfully") {
118
+ const totalSeconds = ((Date.now() - startTime) / 1e3).toFixed(1);
119
+ yield `Completed in ${totalSeconds}s`;
120
+ } else {
121
+ yield status;
122
+ }
123
+ pendingNext = iterator.next();
124
+ }
125
+ }
126
+ }
94
127
  } finally {
95
128
  signal.removeEventListener("abort", handleAbort);
96
129
  }
package/dist/server.cjs CHANGED
@@ -18157,8 +18157,11 @@ function query({
18157
18157
  // src/constants.ts
18158
18158
  var DEFAULT_PORT = 4567;
18159
18159
 
18160
+ // ../utils/dist/server.js
18161
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
18162
+
18160
18163
  // src/server.ts
18161
- var VERSION = "0.0.82";
18164
+ var VERSION = "0.0.83";
18162
18165
  var resolveClaudePath = () => {
18163
18166
  const command = process.platform === "win32" ? "where claude" : "which claude";
18164
18167
  try {
@@ -18257,7 +18260,6 @@ ${stderr.trim()}` : errorMessage;
18257
18260
  });
18258
18261
  return app;
18259
18262
  };
18260
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
18261
18263
  var startServer = async (port = DEFAULT_PORT) => {
18262
18264
  await fkill(`:${port}`, { force: true, silent: true }).catch(() => {
18263
18265
  });
package/dist/server.js CHANGED
@@ -18128,8 +18128,11 @@ function query({
18128
18128
  // src/constants.ts
18129
18129
  var DEFAULT_PORT = 4567;
18130
18130
 
18131
+ // ../utils/dist/server.js
18132
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
18133
+
18131
18134
  // src/server.ts
18132
- var VERSION = "0.0.82";
18135
+ var VERSION = "0.0.83";
18133
18136
  var resolveClaudePath = () => {
18134
18137
  const command = process.platform === "win32" ? "where claude" : "which claude";
18135
18138
  try {
@@ -18228,7 +18231,6 @@ ${stderr.trim()}` : errorMessage;
18228
18231
  });
18229
18232
  return app;
18230
18233
  };
18231
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
18232
18234
  var startServer = async (port = DEFAULT_PORT) => {
18233
18235
  await fkill(`:${port}`, { force: true, silent: true }).catch(() => {
18234
18236
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-grab/claude-code",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "react-grab-claude-code": "./dist/cli.cjs"
@@ -25,7 +25,8 @@
25
25
  ],
26
26
  "devDependencies": {
27
27
  "@types/cross-spawn": "^6.0.6",
28
- "tsup": "^8.4.0"
28
+ "tsup": "^8.4.0",
29
+ "@react-grab/utils": "0.0.83"
29
30
  },
30
31
  "dependencies": {
31
32
  "@anthropic-ai/claude-agent-sdk": "^0.1.0",
@@ -34,7 +35,7 @@
34
35
  "fkill": "^9.0.0",
35
36
  "hono": "^4.0.0",
36
37
  "picocolors": "^1.1.1",
37
- "react-grab": "0.0.82"
38
+ "react-grab": "0.0.83"
38
39
  },
39
40
  "scripts": {
40
41
  "dev": "tsup --watch",