@react-grab/codex 0.1.0-beta.11 → 0.1.0-beta.13
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 +1 -1
- package/dist/client.js +1 -1
- package/package.json +12 -12
package/dist/cli.cjs
CHANGED
|
@@ -7856,7 +7856,7 @@ async function fkill(inputs, options = {}) {
|
|
|
7856
7856
|
}
|
|
7857
7857
|
}
|
|
7858
7858
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7859
|
-
var VERSION = "0.1.0-beta.
|
|
7859
|
+
var VERSION = "0.1.0-beta.12";
|
|
7860
7860
|
var checkIfRelayServerIsRunning = async (port, token) => {
|
|
7861
7861
|
try {
|
|
7862
7862
|
const healthUrl = token ? `http://localhost:${port}/health?${RELAY_TOKEN_PARAM}=${encodeURIComponent(token)}` : `http://localhost:${port}/health`;
|
package/dist/cli.js
CHANGED
|
@@ -7845,7 +7845,7 @@ async function fkill(inputs, options = {}) {
|
|
|
7845
7845
|
}
|
|
7846
7846
|
}
|
|
7847
7847
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7848
|
-
var VERSION = "0.1.0-beta.
|
|
7848
|
+
var VERSION = "0.1.0-beta.12";
|
|
7849
7849
|
var checkIfRelayServerIsRunning = async (port, token) => {
|
|
7850
7850
|
try {
|
|
7851
7851
|
const healthUrl = token ? `http://localhost:${port}/health?${RELAY_TOKEN_PARAM}=${encodeURIComponent(token)}` : `http://localhost:${port}/health`;
|
package/dist/client.cjs
CHANGED
|
@@ -210,7 +210,7 @@ var createRelayAgentProvider = (options) => {
|
|
|
210
210
|
rejectNextMessage = null;
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
|
-
signal.addEventListener("abort", handleAbort);
|
|
213
|
+
signal.addEventListener("abort", handleAbort, { once: true });
|
|
214
214
|
const handleConnectionChange = (connected) => {
|
|
215
215
|
if (!connected && !isDone) {
|
|
216
216
|
errorMessage = "Relay connection lost";
|
package/dist/client.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ReactGrabCodex=(function(exports){'use strict';var $=4722,q=3e3,D="token",G=(i={})=>{let n=i.serverUrl??`ws://localhost:${$}`,c=i.autoReconnect??true,E=i.reconnectIntervalMs??q,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,d=()=>{!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);d();},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,d=null,l=false,p=null,v=()=>{n.abortAgent(c,w),l=true,r&&(r({value:void 0,done:true}),r=null,d=null);};o.addEventListener("abort",v);let m=u=>{!u&&!l&&(p="Relay connection lost",l=true,d&&(d(new Error(p)),r=null,d=null));},R=n.onConnectionChange(m),M=n.onMessage(u=>{if(u.sessionId===w)if(u.type==="agent-status"&&u.content){if(g.push(u.content),r){let b=g.shift();b!==void 0&&(r({value:b,done:false}),r=null,d=null);}}else u.type==="agent-done"?(l=true,r&&(r({value:void 0,done:true}),r=null,d=null)):u.type==="agent-error"&&(p=u.content??"Unknown error",l=true,d&&(d(new Error(p)),r=null,d=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 u=await new Promise((b,T)=>{r=b,d=T;});if(u.done)break;yield u.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(),d());},r=n.onMessage(l=>{l.sessionId===t&&(g(),l.type==="agent-done"?o():l.type==="agent-error"&&w(new Error(l.content??"Operation failed")));}),d=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 L="codex",x=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:L})},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:L}),c=s=>{let f={provider:n,storage:sessionStorage},A={name:"codex-agent",actions:[{id:"edit-with-codex",label:"Edit with Codex",shortcut:"Enter",onAction:C=>{C.enterPromptMode?.(f);},agent:f}]};s.registerPlugin(A);},E=window.__REACT_GRAB__;if(x(E)){c(E);return}window.addEventListener("react-grab:init",s=>{s instanceof CustomEvent&&x(s.detail)&&c(s.detail);},{once:true});let h=window.__REACT_GRAB__;x(h)&&c(h);};N();
|
|
1
|
+
var ReactGrabCodex=(function(exports){'use strict';var $=4722,q=3e3,D="token",G=(i={})=>{let n=i.serverUrl??`ws://localhost:${$}`,c=i.autoReconnect??true,E=i.reconnectIntervalMs??q,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,d=()=>{!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);d();},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,d=null,l=false,p=null,v=()=>{n.abortAgent(c,w),l=true,r&&(r({value:void 0,done:true}),r=null,d=null);};o.addEventListener("abort",v,{once:true});let m=u=>{!u&&!l&&(p="Relay connection lost",l=true,d&&(d(new Error(p)),r=null,d=null));},R=n.onConnectionChange(m),M=n.onMessage(u=>{if(u.sessionId===w)if(u.type==="agent-status"&&u.content){if(g.push(u.content),r){let b=g.shift();b!==void 0&&(r({value:b,done:false}),r=null,d=null);}}else u.type==="agent-done"?(l=true,r&&(r({value:void 0,done:true}),r=null,d=null)):u.type==="agent-error"&&(p=u.content??"Unknown error",l=true,d&&(d(new Error(p)),r=null,d=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 u=await new Promise((b,T)=>{r=b,d=T;});if(u.done)break;yield u.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(),d());},r=n.onMessage(l=>{l.sessionId===t&&(g(),l.type==="agent-done"?o():l.type==="agent-error"&&w(new Error(l.content??"Operation failed")));}),d=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 L="codex",x=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:L})},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:L}),c=s=>{let f={provider:n,storage:sessionStorage},A={name:"codex-agent",actions:[{id:"edit-with-codex",label:"Edit with Codex",shortcut:"Enter",onAction:C=>{C.enterPromptMode?.(f);},agent:f}]};s.registerPlugin(A);},E=window.__REACT_GRAB__;if(x(E)){c(E);return}window.addEventListener("react-grab:init",s=>{s instanceof CustomEvent&&x(s.detail)&&c(s.detail);},{once:true});let h=window.__REACT_GRAB__;x(h)&&c(h);};N();
|
|
2
2
|
exports.attachAgent=N;exports.createCodexAgentProvider=Y;return exports;})({});
|
package/dist/client.js
CHANGED
|
@@ -208,7 +208,7 @@ var createRelayAgentProvider = (options) => {
|
|
|
208
208
|
rejectNextMessage = null;
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
|
-
signal.addEventListener("abort", handleAbort);
|
|
211
|
+
signal.addEventListener("abort", handleAbort, { once: true });
|
|
212
212
|
const handleConnectionChange = (connected) => {
|
|
213
213
|
if (!connected && !isDone) {
|
|
214
214
|
errorMessage = "Relay connection lost";
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-grab/codex",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.1.0-beta.13",
|
|
5
4
|
"bin": {
|
|
6
5
|
"react-grab-codex": "./dist/cli.cjs"
|
|
7
6
|
},
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"browser": "dist/client.global.js",
|
|
8
12
|
"exports": {
|
|
9
13
|
"./client": {
|
|
10
14
|
"types": "./dist/client.d.ts",
|
|
@@ -19,19 +23,15 @@
|
|
|
19
23
|
"./dist/*": "./dist/*.js",
|
|
20
24
|
"./dist/*.js": "./dist/*.js"
|
|
21
25
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@openai/codex-sdk": "^0.66.0",
|
|
28
|
+
"@react-grab/relay": "0.1.0-beta.13",
|
|
29
|
+
"react-grab": "0.1.0-beta.13"
|
|
30
|
+
},
|
|
26
31
|
"devDependencies": {
|
|
27
32
|
"@types/node": "^22.10.7",
|
|
28
33
|
"tsup": "^8.4.0",
|
|
29
|
-
"@react-grab/utils": "0.1.0-beta.
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@openai/codex-sdk": "^0.66.0",
|
|
33
|
-
"react-grab": "0.1.0-beta.11",
|
|
34
|
-
"@react-grab/relay": "0.1.0-beta.11"
|
|
34
|
+
"@react-grab/utils": "0.1.0-beta.13"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"dev": "tsup --watch",
|