@react-grab/claude-code 0.0.61 → 0.0.63
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/README.md +30 -0
- package/dist/client.cjs +2 -2
- package/dist/client.global.js +4 -4
- package/dist/client.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -67,6 +67,36 @@ if (process.env.NODE_ENV === "development") {
|
|
|
67
67
|
<script src="//unpkg.com/@react-grab/claude-code/dist/client.global.js"></script>
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
### Next.js
|
|
71
|
+
|
|
72
|
+
Using the `Script` component in your `app/layout.tsx`:
|
|
73
|
+
|
|
74
|
+
```jsx
|
|
75
|
+
import Script from "next/script";
|
|
76
|
+
|
|
77
|
+
export default function RootLayout({ children }) {
|
|
78
|
+
return (
|
|
79
|
+
<html>
|
|
80
|
+
<head>
|
|
81
|
+
{process.env.NODE_ENV === "development" && (
|
|
82
|
+
<>
|
|
83
|
+
<Script
|
|
84
|
+
src="//unpkg.com/react-grab/dist/index.global.js"
|
|
85
|
+
strategy="beforeInteractive"
|
|
86
|
+
/>
|
|
87
|
+
<Script
|
|
88
|
+
src="//unpkg.com/@react-grab/claude-code/dist/client.global.js"
|
|
89
|
+
strategy="lazyOnload"
|
|
90
|
+
/>
|
|
91
|
+
</>
|
|
92
|
+
)}
|
|
93
|
+
</head>
|
|
94
|
+
<body>{children}</body>
|
|
95
|
+
</html>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
70
100
|
### ES Module
|
|
71
101
|
|
|
72
102
|
```tsx
|
package/dist/client.cjs
CHANGED
|
@@ -79,8 +79,8 @@ var createClaudeAgentProvider = (providerOptions = {}) => {
|
|
|
79
79
|
};
|
|
80
80
|
yield* streamFromServer(serverUrl, mergedContext, signal);
|
|
81
81
|
},
|
|
82
|
-
resume: async function* (sessionId, signal) {
|
|
83
|
-
const savedSessions =
|
|
82
|
+
resume: async function* (sessionId, signal, storage) {
|
|
83
|
+
const savedSessions = storage.getItem(STORAGE_KEY);
|
|
84
84
|
if (!savedSessions) {
|
|
85
85
|
throw new Error("No sessions to resume");
|
|
86
86
|
}
|
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 f=`http://localhost:${4567}`,m="react-grab:agent-sessions",y={systemPrompt:{type:"preset",preset:"claude_code",append:`You are helping a user make changes to a React component based on a selected element.
|
|
2
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},
|
|
4
|
-
`))e.startsWith("event:")?t=e.slice(6).trim():e.startsWith("data:")&&(o=e.slice(5).trim());return {eventType:t,data:o}};async function*
|
|
3
|
+
Provide clear, concise status updates as you work.`},model:"haiku",permissionMode:"bypassPermissions",maxTurns:10},A=n=>{let t="",o="";for(let e of n.split(`
|
|
4
|
+
`))e.startsWith("event:")?t=e.slice(6).trim():e.startsWith("data:")&&(o=e.slice(5).trim());return {eventType:t,data:o}};async function*S(n){let t=n.getReader(),o=new TextDecoder,e="";try{for(;;){let{done:r,value:i}=await t.read();i&&(e+=o.decode(i,{stream:!0}));let s;for(;(s=e.indexOf(`
|
|
5
5
|
|
|
6
|
-
`))!==-1;){let{eventType:
|
|
6
|
+
`))!==-1;){let{eventType:a,data:d}=A(e.slice(0,s));if(e=e.slice(s+2),a==="done")return;if(a==="error")throw new Error(d||"Agent error");d&&(yield d);}if(r)break}}finally{t.releaseLock();}}async function*p(n,t,o){let e=await fetch(`${n}/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*S(e.body);}var E=(n={})=>{let{serverUrl:t=f,getOptions:o}=n,e=r=>({...y,...o?.()??{},...r??{}});return {send:async function*(r,i){let s={...r,options:e(r.options)};yield*p(t,s,i);},resume:async function*(r,i,s){let a=s.getItem(m);if(!a)throw new Error("No sessions to resume");let c=JSON.parse(a)[r];if(!c)throw new Error(`Session ${r} not found`);let l=c.context,u={...l,options:e(l.options)};yield "Resuming...",yield*p(t,u,i);},supportsResume:true}},C=async()=>{if(typeof window>"u")return;let n=E(),t=window.__REACT_GRAB__;if(t){t.setAgent({provider:n});return}window.addEventListener("react-grab:init",o=>{o.detail.setAgent({provider:n});},{once:true});};C();exports.attachAgent=C;exports.createClaudeAgentProvider=E;return exports;})({});
|
package/dist/client.js
CHANGED
|
@@ -77,8 +77,8 @@ var createClaudeAgentProvider = (providerOptions = {}) => {
|
|
|
77
77
|
};
|
|
78
78
|
yield* streamFromServer(serverUrl, mergedContext, signal);
|
|
79
79
|
},
|
|
80
|
-
resume: async function* (sessionId, signal) {
|
|
81
|
-
const savedSessions =
|
|
80
|
+
resume: async function* (sessionId, signal, storage) {
|
|
81
|
+
const savedSessions = storage.getItem(STORAGE_KEY);
|
|
82
82
|
if (!savedSessions) {
|
|
83
83
|
throw new Error("No sessions to resume");
|
|
84
84
|
}
|
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.63",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"react-grab-claude-code": "./dist/cli.js"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@anthropic-ai/claude-agent-sdk": "^0.1.0",
|
|
31
31
|
"@hono/node-server": "^1.19.6",
|
|
32
32
|
"hono": "^4.0.0",
|
|
33
|
-
"react-grab": "0.0.
|
|
33
|
+
"react-grab": "0.0.63"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"dev": "tsup --watch",
|