@react-grab/claude-code 0.0.91 → 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 +3 -3
- 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 = 4567;
|
|
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 = 4567;
|
|
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,6 +1,6 @@
|
|
|
1
|
-
var ReactGrabClaudeCode=(function(exports){'use strict';var
|
|
1
|
+
var ReactGrabClaudeCode=(function(exports){'use strict';var h=5e3,b="react-grab:agent-sessions",v=t=>{let e="",o="";for(let n of t.split(`
|
|
2
2
|
`))n.startsWith("event:")?e=n.slice(6).trim():n.startsWith("data:")&&(o=n.slice(5).trim());return {eventType:e,data:o}},T=async function*(t,e){let o=t.getReader(),n=new TextDecoder,r="",s=false,i=()=>{s=true,o.cancel().catch(()=>{});};e.addEventListener("abort",i);try{if(e.aborted)throw new DOMException("Aborted","AbortError");for(;;){let d=await o.read();if(s||e.aborted)throw new DOMException("Aborted","AbortError");let{done:a,value:l}=d;l&&(r+=n.decode(l,{stream:!0}));let c;for(;(c=r.indexOf(`
|
|
3
3
|
|
|
4
|
-
`))!==-1;){let{eventType:f,data:p}=v(r.slice(0,c));if(r=r.slice(c+2),f==="done")return;if(f==="error")throw new Error(p||"Agent error");p&&(yield p);}if(a)break}}finally{e.removeEventListener("abort",i);try{o.releaseLock();}catch{}}},
|
|
4
|
+
`))!==-1;){let{eventType:f,data:p}=v(r.slice(0,c));if(r=r.slice(c+2),f==="done")return;if(f==="error")throw new Error(p||"Agent error");p&&(yield p);}if(a)break}}finally{e.removeEventListener("abort",i);try{o.releaseLock();}catch{}}},y=t=>typeof t=="object"&&t!==null,S=(t,e,o=b)=>{let n=t.getItem(o);if(!n)throw new Error("No sessions to resume");let r;try{r=JSON.parse(n);}catch{throw new Error("Failed to parse stored sessions")}if(!y(r))throw new Error("Invalid stored sessions");let s=r[e];if(!y(s))throw new Error(`Session ${e} not found`);let i=s.context;if(!y(i))throw new Error(`Session ${e} is invalid`);let d=i.content,a=i.prompt;if(!Array.isArray(d)||typeof a!="string")throw new Error(`Session ${e} is invalid`);let l=i.options,c=i.sessionId;return {content:d,prompt:a,options:l,sessionId:typeof c=="string"?c:void 0}},w=async function*(t,e,o){let n=Date.now(),r=e.sessionId,s=t.pollIntervalMs??100,i=`${t.serverUrl}${t.agentPath??"/agent"}`,d=()=>{if(!r)return;let a=t.abortPath?.(r)??`/abort/${r}`;fetch(`${t.serverUrl}${a}`,{method:"POST"}).catch(()=>{});};o.addEventListener("abort",d);try{let a=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:o});if(!a.ok)throw new Error(`Server error: ${a.status}`);if(!a.body)throw new Error("No response body");let l=T(a.body,o)[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))]),m=(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===t.completedStatus?yield `Completed in ${m.toFixed(1)}s`:p?yield `${p} ${m.toFixed(1)}s`:yield `Working\u2026 ${m.toFixed(1)}s`;}}finally{o.removeEventListener("abort",d);}},E=(t,e=h)=>{let o=null;return async()=>{let n=Date.now();if(o&&n-o.timestamp<e)return o.result;try{let r=await t();return o={result:r,timestamp:n},r}catch{return o={result:false,timestamp:n},false}}};var g="Completed successfully";var _=`http://localhost:${4567}`,x={systemPrompt:{type:"preset",preset:"claude_code",append:`You are helping a user make changes to a React component based on a selected element.
|
|
5
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},
|
|
6
|
+
Provide clear, concise status updates as you work.`},model:"haiku",permissionMode:"bypassPermissions",maxTurns:10},A=t=>typeof t=="object"&&t!==null&&"setAgent"in t,R=(t={})=>{let{serverUrl:e=_,getOptions:o}=t,n=s=>({...x,...o?.()??{},...s??{}}),r=E(async()=>(await fetch(`${e}/health`,{method:"GET"})).ok,h);return {send:async function*(s,i){let d={...s,options:n(s.options)};yield*w({serverUrl:e,completedStatus:g},d,i);},resume:async function*(s,i,d){let a=S(d,s),l={content:a.content,prompt:a.prompt,options:a.options,sessionId:a.sessionId??s},c={...l,options:n(l.options)};yield "Resuming...",yield*w({serverUrl:e,completedStatus:g},c,i);},supportsResume:true,supportsFollowUp:true,checkConnection:r,undo:async()=>{try{await fetch(`${e}/undo`,{method:"POST"});}catch{}}}},P=async()=>{if(typeof window>"u")return;let t=R(),e=r=>{r.setAgent({provider:t,storage:sessionStorage});},o=window.__REACT_GRAB__;if(A(o)){e(o);return}window.addEventListener("react-grab:init",r=>{r instanceof CustomEvent&&A(r.detail)&&e(r.detail);},{once:true});let n=window.__REACT_GRAB__;A(n)&&e(n);};P();exports.attachAgent=P;exports.createClaudeAgentProvider=R;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
|
@@ -18187,7 +18187,7 @@ Check that the command is executable: chmod +x $(which ${commandName})`;
|
|
|
18187
18187
|
};
|
|
18188
18188
|
|
|
18189
18189
|
// src/server.ts
|
|
18190
|
-
var VERSION = "0.0.
|
|
18190
|
+
var VERSION = "0.0.92";
|
|
18191
18191
|
try {
|
|
18192
18192
|
fetch(
|
|
18193
18193
|
`https://www.react-grab.com/api/version?source=claude-code&t=${Date.now()}`
|
|
@@ -18285,21 +18285,53 @@ var createServer = () => {
|
|
|
18285
18285
|
const { content, prompt, options, sessionId } = body;
|
|
18286
18286
|
const claudeSessionId = sessionId ? claudeSessionMap.get(sessionId) : void 0;
|
|
18287
18287
|
const isFollowUp = Boolean(claudeSessionId);
|
|
18288
|
-
const
|
|
18289
|
-
|
|
18290
|
-
${content}`;
|
|
18288
|
+
const contentItems = Array.isArray(content) ? content : [content];
|
|
18291
18289
|
return streamSSE(context, async (stream2) => {
|
|
18292
|
-
|
|
18293
|
-
|
|
18294
|
-
|
|
18295
|
-
|
|
18296
|
-
|
|
18290
|
+
if (isFollowUp) {
|
|
18291
|
+
for await (const message of runAgent(prompt, {
|
|
18292
|
+
...options,
|
|
18293
|
+
sessionId
|
|
18294
|
+
})) {
|
|
18295
|
+
if (message.type === "error") {
|
|
18296
|
+
await stream2.writeSSE({
|
|
18297
|
+
data: `Error: ${message.content}`,
|
|
18298
|
+
event: "error"
|
|
18299
|
+
});
|
|
18300
|
+
} else {
|
|
18301
|
+
await stream2.writeSSE({
|
|
18302
|
+
data: message.content,
|
|
18303
|
+
event: message.type
|
|
18304
|
+
});
|
|
18305
|
+
}
|
|
18306
|
+
}
|
|
18307
|
+
return;
|
|
18308
|
+
}
|
|
18309
|
+
for (let i = 0; i < contentItems.length; i++) {
|
|
18310
|
+
const elementContent = contentItems[i];
|
|
18311
|
+
const userPrompt = `${prompt}
|
|
18312
|
+
|
|
18313
|
+
${elementContent}`;
|
|
18314
|
+
if (contentItems.length > 1) {
|
|
18297
18315
|
await stream2.writeSSE({
|
|
18298
|
-
data: `
|
|
18299
|
-
event: "
|
|
18316
|
+
data: `Processing element ${i + 1} of ${contentItems.length}...`,
|
|
18317
|
+
event: "status"
|
|
18300
18318
|
});
|
|
18301
|
-
}
|
|
18302
|
-
|
|
18319
|
+
}
|
|
18320
|
+
for await (const message of runAgent(userPrompt, {
|
|
18321
|
+
...options,
|
|
18322
|
+
sessionId
|
|
18323
|
+
})) {
|
|
18324
|
+
if (message.type === "error") {
|
|
18325
|
+
await stream2.writeSSE({
|
|
18326
|
+
data: `Error: ${message.content}`,
|
|
18327
|
+
event: "error"
|
|
18328
|
+
});
|
|
18329
|
+
} else {
|
|
18330
|
+
await stream2.writeSSE({
|
|
18331
|
+
data: message.content,
|
|
18332
|
+
event: message.type
|
|
18333
|
+
});
|
|
18334
|
+
}
|
|
18303
18335
|
}
|
|
18304
18336
|
}
|
|
18305
18337
|
});
|
package/dist/server.js
CHANGED
|
@@ -18158,7 +18158,7 @@ Check that the command is executable: chmod +x $(which ${commandName})`;
|
|
|
18158
18158
|
};
|
|
18159
18159
|
|
|
18160
18160
|
// src/server.ts
|
|
18161
|
-
var VERSION = "0.0.
|
|
18161
|
+
var VERSION = "0.0.92";
|
|
18162
18162
|
try {
|
|
18163
18163
|
fetch(
|
|
18164
18164
|
`https://www.react-grab.com/api/version?source=claude-code&t=${Date.now()}`
|
|
@@ -18256,21 +18256,53 @@ var createServer = () => {
|
|
|
18256
18256
|
const { content, prompt, options, sessionId } = body;
|
|
18257
18257
|
const claudeSessionId = sessionId ? claudeSessionMap.get(sessionId) : void 0;
|
|
18258
18258
|
const isFollowUp = Boolean(claudeSessionId);
|
|
18259
|
-
const
|
|
18260
|
-
|
|
18261
|
-
${content}`;
|
|
18259
|
+
const contentItems = Array.isArray(content) ? content : [content];
|
|
18262
18260
|
return streamSSE(context, async (stream2) => {
|
|
18263
|
-
|
|
18264
|
-
|
|
18265
|
-
|
|
18266
|
-
|
|
18267
|
-
|
|
18261
|
+
if (isFollowUp) {
|
|
18262
|
+
for await (const message of runAgent(prompt, {
|
|
18263
|
+
...options,
|
|
18264
|
+
sessionId
|
|
18265
|
+
})) {
|
|
18266
|
+
if (message.type === "error") {
|
|
18267
|
+
await stream2.writeSSE({
|
|
18268
|
+
data: `Error: ${message.content}`,
|
|
18269
|
+
event: "error"
|
|
18270
|
+
});
|
|
18271
|
+
} else {
|
|
18272
|
+
await stream2.writeSSE({
|
|
18273
|
+
data: message.content,
|
|
18274
|
+
event: message.type
|
|
18275
|
+
});
|
|
18276
|
+
}
|
|
18277
|
+
}
|
|
18278
|
+
return;
|
|
18279
|
+
}
|
|
18280
|
+
for (let i = 0; i < contentItems.length; i++) {
|
|
18281
|
+
const elementContent = contentItems[i];
|
|
18282
|
+
const userPrompt = `${prompt}
|
|
18283
|
+
|
|
18284
|
+
${elementContent}`;
|
|
18285
|
+
if (contentItems.length > 1) {
|
|
18268
18286
|
await stream2.writeSSE({
|
|
18269
|
-
data: `
|
|
18270
|
-
event: "
|
|
18287
|
+
data: `Processing element ${i + 1} of ${contentItems.length}...`,
|
|
18288
|
+
event: "status"
|
|
18271
18289
|
});
|
|
18272
|
-
}
|
|
18273
|
-
|
|
18290
|
+
}
|
|
18291
|
+
for await (const message of runAgent(userPrompt, {
|
|
18292
|
+
...options,
|
|
18293
|
+
sessionId
|
|
18294
|
+
})) {
|
|
18295
|
+
if (message.type === "error") {
|
|
18296
|
+
await stream2.writeSSE({
|
|
18297
|
+
data: `Error: ${message.content}`,
|
|
18298
|
+
event: "error"
|
|
18299
|
+
});
|
|
18300
|
+
} else {
|
|
18301
|
+
await stream2.writeSSE({
|
|
18302
|
+
data: message.content,
|
|
18303
|
+
event: message.type
|
|
18304
|
+
});
|
|
18305
|
+
}
|
|
18274
18306
|
}
|
|
18275
18307
|
}
|
|
18276
18308
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-grab/claude-code",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.92",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"react-grab-claude-code": "./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
|
"@anthropic-ai/claude-agent-sdk": "^0.1.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"fkill": "^9.0.0",
|
|
36
36
|
"hono": "^4.0.0",
|
|
37
37
|
"picocolors": "^1.1.1",
|
|
38
|
-
"react-grab": "0.0.
|
|
38
|
+
"react-grab": "0.0.92"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"dev": "tsup --watch",
|