@react-grab/codex 0.0.85 → 0.0.86
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 +2 -2
- package/dist/cli.js +2 -2
- package/dist/client.cjs +12 -11
- package/dist/client.global.js +4 -4
- package/dist/client.js +12 -11
- package/dist/server.cjs +6 -5
- package/dist/server.js +6 -5
- package/package.json +4 -3
package/dist/cli.cjs
CHANGED
|
@@ -7138,7 +7138,7 @@ var import_picocolors = __toESM(require_picocolors());
|
|
|
7138
7138
|
var DEFAULT_PORT = 7567;
|
|
7139
7139
|
|
|
7140
7140
|
// src/cli.ts
|
|
7141
|
-
var VERSION = "0.0.
|
|
7141
|
+
var VERSION = "0.0.86";
|
|
7142
7142
|
var serverPath = path2.join(__dirname, "server.js");
|
|
7143
7143
|
execa(process.execPath, [serverPath], {
|
|
7144
7144
|
detached: true,
|
|
@@ -7146,6 +7146,6 @@ execa(process.execPath, [serverPath], {
|
|
|
7146
7146
|
cleanup: false
|
|
7147
7147
|
}).unref();
|
|
7148
7148
|
console.log(
|
|
7149
|
-
`${import_picocolors.default.magenta("\
|
|
7149
|
+
`${import_picocolors.default.magenta("\u273F")} ${import_picocolors.default.bold("React Grab")} ${import_picocolors.default.gray(VERSION)} ${import_picocolors.default.dim("(Codex)")}`
|
|
7150
7150
|
);
|
|
7151
7151
|
console.log(`- Local: ${import_picocolors.default.cyan(`http://localhost:${DEFAULT_PORT}`)}`);
|
package/dist/cli.js
CHANGED
|
@@ -7130,7 +7130,7 @@ var import_picocolors = __toESM(require_picocolors());
|
|
|
7130
7130
|
var DEFAULT_PORT = 7567;
|
|
7131
7131
|
|
|
7132
7132
|
// src/cli.ts
|
|
7133
|
-
var VERSION = "0.0.
|
|
7133
|
+
var VERSION = "0.0.86";
|
|
7134
7134
|
var serverPath = join(__dirname, "server.js");
|
|
7135
7135
|
execa(process.execPath, [serverPath], {
|
|
7136
7136
|
detached: true,
|
|
@@ -7138,6 +7138,6 @@ execa(process.execPath, [serverPath], {
|
|
|
7138
7138
|
cleanup: false
|
|
7139
7139
|
}).unref();
|
|
7140
7140
|
console.log(
|
|
7141
|
-
`${import_picocolors.default.magenta("\
|
|
7141
|
+
`${import_picocolors.default.magenta("\u273F")} ${import_picocolors.default.bold("React Grab")} ${import_picocolors.default.gray(VERSION)} ${import_picocolors.default.dim("(Codex)")}`
|
|
7142
7142
|
);
|
|
7143
7143
|
console.log(`- Local: ${import_picocolors.default.cyan(`http://localhost:${DEFAULT_PORT}`)}`);
|
package/dist/client.cjs
CHANGED
|
@@ -55,6 +55,7 @@ async function* streamSSE(stream, signal) {
|
|
|
55
55
|
|
|
56
56
|
// src/constants.ts
|
|
57
57
|
var DEFAULT_PORT = 7567;
|
|
58
|
+
var COMPLETED_STATUS = "Completed successfully";
|
|
58
59
|
|
|
59
60
|
// src/client.ts
|
|
60
61
|
var DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_PORT}`;
|
|
@@ -86,6 +87,7 @@ var streamFromServer = async function* (serverUrl, context, signal) {
|
|
|
86
87
|
const iterator = streamSSE(response.body, signal)[Symbol.asyncIterator]();
|
|
87
88
|
let done = false;
|
|
88
89
|
let pendingNext = iterator.next();
|
|
90
|
+
let lastStatus = null;
|
|
89
91
|
while (!done) {
|
|
90
92
|
const result = await Promise.race([
|
|
91
93
|
pendingNext.then((iteratorResult) => ({
|
|
@@ -96,23 +98,22 @@ var streamFromServer = async function* (serverUrl, context, signal) {
|
|
|
96
98
|
(resolve) => setTimeout(() => resolve({ type: "timeout" }), 100)
|
|
97
99
|
)
|
|
98
100
|
]);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
yield `Working\u2026 ${elapsedSeconds.toFixed(1)}s`;
|
|
102
|
-
} else {
|
|
101
|
+
const elapsedSeconds = (Date.now() - startTime) / 1e3;
|
|
102
|
+
if (result.type === "status") {
|
|
103
103
|
const iteratorResult = result.iteratorResult;
|
|
104
104
|
done = iteratorResult.done ?? false;
|
|
105
105
|
if (!done && iteratorResult.value) {
|
|
106
|
-
|
|
107
|
-
if (status === "Completed successfully") {
|
|
108
|
-
const totalSeconds = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
109
|
-
yield `Completed in ${totalSeconds}s`;
|
|
110
|
-
} else {
|
|
111
|
-
yield status;
|
|
112
|
-
}
|
|
106
|
+
lastStatus = iteratorResult.value;
|
|
113
107
|
pendingNext = iterator.next();
|
|
114
108
|
}
|
|
115
109
|
}
|
|
110
|
+
if (lastStatus === COMPLETED_STATUS) {
|
|
111
|
+
yield `Completed in ${elapsedSeconds.toFixed(1)}s`;
|
|
112
|
+
} else if (lastStatus) {
|
|
113
|
+
yield `${lastStatus} ${elapsedSeconds.toFixed(1)}s`;
|
|
114
|
+
} else {
|
|
115
|
+
yield `Working\u2026 ${elapsedSeconds.toFixed(1)}s`;
|
|
116
|
+
}
|
|
116
117
|
}
|
|
117
118
|
} finally {
|
|
118
119
|
signal.removeEventListener("abort", handleAbort);
|
package/dist/client.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var ReactGrabCodex=(function(exports){'use strict';var
|
|
2
|
-
`))
|
|
1
|
+
var ReactGrabCodex=(function(exports){'use strict';var m=5e3,A="react-grab:agent-sessions",C=c=>{let e="",n="";for(let o of c.split(`
|
|
2
|
+
`))o.startsWith("event:")?e=o.slice(6).trim():o.startsWith("data:")&&(n=o.slice(5).trim());return {eventType:e,data:n}};async function*g(c,e){let n=c.getReader(),o=new TextDecoder,r="",t=false,s=()=>{t=true,n.cancel().catch(()=>{});};e.addEventListener("abort",s);try{if(e.aborted)throw new DOMException("Aborted","AbortError");for(;;){let i=await n.read();if(t||e.aborted)throw new DOMException("Aborted","AbortError");let{done:l,value:f}=i;f&&(r+=o.decode(f,{stream:!0}));let a;for(;(a=r.indexOf(`
|
|
3
3
|
|
|
4
|
-
`))!==-1;){let{eventType:
|
|
5
|
-
exports.attachAgent=
|
|
4
|
+
`))!==-1;){let{eventType:p,data:d}=C(r.slice(0,a));if(r=r.slice(a+2),p==="done")return;if(p==="error")throw new Error(d||"Agent error");d&&(yield d);}if(l)break}}finally{e.removeEventListener("abort",s);try{n.releaseLock();}catch{}}}var y="Completed successfully";var S=`http://localhost:${7567}`,E=async function*(c,e,n){let o=Date.now(),r=e.sessionId,t=()=>{r&&fetch(`${c}/abort/${r}`,{method:"POST"}).catch(()=>{});};n.addEventListener("abort",t);try{let s=await fetch(`${c}/agent`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:n});if(!s.ok)throw new Error(`Server error: ${s.status}`);if(!s.body)throw new Error("No response body");let i=g(s.body,n)[Symbol.asyncIterator](),l=!1,f=i.next(),a=null;for(;!l;){let p=await Promise.race([f.then(u=>({type:"status",iteratorResult:u})),new Promise(u=>setTimeout(()=>u({type:"timeout"}),100))]),d=(Date.now()-o)/1e3;if(p.type==="status"){let u=p.iteratorResult;l=u.done??!1,!l&&u.value&&(a=u.value,f=i.next());}a===y?yield `Completed in ${d.toFixed(1)}s`:a?yield `${a} ${d.toFixed(1)}s`:yield `Working\u2026 ${d.toFixed(1)}s`;}}finally{n.removeEventListener("abort",t);}},x=(c={})=>{let{serverUrl:e=S,getOptions:n}=c,o=null,r=t=>({...n?.()??{},...t??{}});return {send:async function*(t,s){let i={...t,options:r(t.options)};yield*E(e,i,s);},resume:async function*(t,s,i){let l=i.getItem(A);if(!l)throw new Error("No sessions to resume");let a=JSON.parse(l)[t];if(!a)throw new Error(`Session ${t} not found`);let p=a.context,d={...p,options:r(p.options)};yield "Resuming...",yield*E(e,d,s);},supportsResume:true,supportsFollowUp:true,checkConnection:async()=>{let t=Date.now();if(o&&t-o.timestamp<m)return o.result;try{let i=(await fetch(`${e}/health`,{method:"GET"})).ok;return o={result:i,timestamp:t},i}catch{return o={result:false,timestamp:t},false}},undo:async()=>{try{await fetch(`${e}/undo`,{method:"POST"});}catch{}}}},b=async()=>{if(typeof window>"u")return;let c=x(),e=r=>{r.setAgent({provider:c,storage:sessionStorage});},n=window.__REACT_GRAB__;if(n){e(n);return}window.addEventListener("react-grab:init",r=>{e(r.detail);},{once:true});let o=window.__REACT_GRAB__;o&&e(o);};b();
|
|
5
|
+
exports.attachAgent=b;exports.createCodexAgentProvider=x;return exports;})({});
|
package/dist/client.js
CHANGED
|
@@ -53,6 +53,7 @@ async function* streamSSE(stream, signal) {
|
|
|
53
53
|
|
|
54
54
|
// src/constants.ts
|
|
55
55
|
var DEFAULT_PORT = 7567;
|
|
56
|
+
var COMPLETED_STATUS = "Completed successfully";
|
|
56
57
|
|
|
57
58
|
// src/client.ts
|
|
58
59
|
var DEFAULT_SERVER_URL = `http://localhost:${DEFAULT_PORT}`;
|
|
@@ -84,6 +85,7 @@ var streamFromServer = async function* (serverUrl, context, signal) {
|
|
|
84
85
|
const iterator = streamSSE(response.body, signal)[Symbol.asyncIterator]();
|
|
85
86
|
let done = false;
|
|
86
87
|
let pendingNext = iterator.next();
|
|
88
|
+
let lastStatus = null;
|
|
87
89
|
while (!done) {
|
|
88
90
|
const result = await Promise.race([
|
|
89
91
|
pendingNext.then((iteratorResult) => ({
|
|
@@ -94,23 +96,22 @@ var streamFromServer = async function* (serverUrl, context, signal) {
|
|
|
94
96
|
(resolve) => setTimeout(() => resolve({ type: "timeout" }), 100)
|
|
95
97
|
)
|
|
96
98
|
]);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
yield `Working\u2026 ${elapsedSeconds.toFixed(1)}s`;
|
|
100
|
-
} else {
|
|
99
|
+
const elapsedSeconds = (Date.now() - startTime) / 1e3;
|
|
100
|
+
if (result.type === "status") {
|
|
101
101
|
const iteratorResult = result.iteratorResult;
|
|
102
102
|
done = iteratorResult.done ?? false;
|
|
103
103
|
if (!done && iteratorResult.value) {
|
|
104
|
-
|
|
105
|
-
if (status === "Completed successfully") {
|
|
106
|
-
const totalSeconds = ((Date.now() - startTime) / 1e3).toFixed(1);
|
|
107
|
-
yield `Completed in ${totalSeconds}s`;
|
|
108
|
-
} else {
|
|
109
|
-
yield status;
|
|
110
|
-
}
|
|
104
|
+
lastStatus = iteratorResult.value;
|
|
111
105
|
pendingNext = iterator.next();
|
|
112
106
|
}
|
|
113
107
|
}
|
|
108
|
+
if (lastStatus === COMPLETED_STATUS) {
|
|
109
|
+
yield `Completed in ${elapsedSeconds.toFixed(1)}s`;
|
|
110
|
+
} else if (lastStatus) {
|
|
111
|
+
yield `${lastStatus} ${elapsedSeconds.toFixed(1)}s`;
|
|
112
|
+
} else {
|
|
113
|
+
yield `Working\u2026 ${elapsedSeconds.toFixed(1)}s`;
|
|
114
|
+
}
|
|
114
115
|
}
|
|
115
116
|
} finally {
|
|
116
117
|
signal.removeEventListener("abort", handleAbort);
|
package/dist/server.cjs
CHANGED
|
@@ -19,10 +19,11 @@ var pc__default = /*#__PURE__*/_interopDefault(pc);
|
|
|
19
19
|
|
|
20
20
|
// src/constants.ts
|
|
21
21
|
var DEFAULT_PORT = 7567;
|
|
22
|
+
var COMPLETED_STATUS = "Completed successfully";
|
|
22
23
|
|
|
23
24
|
// ../utils/dist/server.js
|
|
24
25
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
25
|
-
var VERSION = "0.0.
|
|
26
|
+
var VERSION = "0.0.86";
|
|
26
27
|
try {
|
|
27
28
|
fetch(`https://www.react-grab.com/api/version?source=codex&t=${Date.now()}`).catch(() => {
|
|
28
29
|
});
|
|
@@ -44,7 +45,7 @@ var getOrCreateThread = (sessionId, options) => {
|
|
|
44
45
|
return { thread: threadMap.get(sessionId).thread, isExisting: true };
|
|
45
46
|
}
|
|
46
47
|
const thread = codex.startThread({
|
|
47
|
-
workingDirectory: options?.workingDirectory ?? process.cwd()
|
|
48
|
+
workingDirectory: options?.workingDirectory ?? process.env.REACT_GRAB_CWD ?? process.cwd()
|
|
48
49
|
});
|
|
49
50
|
return { thread, isExisting: false };
|
|
50
51
|
};
|
|
@@ -82,7 +83,7 @@ ${content}`;
|
|
|
82
83
|
}
|
|
83
84
|
const isAborted = () => abortController.signal.aborted;
|
|
84
85
|
try {
|
|
85
|
-
await stream.writeSSE({ data: "Thinking
|
|
86
|
+
await stream.writeSSE({ data: "Thinking\u2026", event: "status" });
|
|
86
87
|
const { thread } = getOrCreateThread(sessionId, options);
|
|
87
88
|
if (sessionId && thread.id) {
|
|
88
89
|
lastThreadId = thread.id;
|
|
@@ -100,7 +101,7 @@ ${content}`;
|
|
|
100
101
|
}
|
|
101
102
|
if (!isAborted()) {
|
|
102
103
|
await stream.writeSSE({
|
|
103
|
-
data:
|
|
104
|
+
data: COMPLETED_STATUS,
|
|
104
105
|
event: "status"
|
|
105
106
|
});
|
|
106
107
|
await stream.writeSSE({ data: "", event: "done" });
|
|
@@ -156,7 +157,7 @@ var startServer = async (port = DEFAULT_PORT) => {
|
|
|
156
157
|
const honoApplication = createServer();
|
|
157
158
|
nodeServer.serve({ fetch: honoApplication.fetch, port });
|
|
158
159
|
console.log(
|
|
159
|
-
`${pc__default.default.magenta("\
|
|
160
|
+
`${pc__default.default.magenta("\u273F")} ${pc__default.default.bold("React Grab")} ${pc__default.default.gray(VERSION)} ${pc__default.default.dim("(Codex)")}`
|
|
160
161
|
);
|
|
161
162
|
console.log(`- Local: ${pc__default.default.cyan(`http://localhost:${port}`)}`);
|
|
162
163
|
};
|
package/dist/server.js
CHANGED
|
@@ -11,10 +11,11 @@ import { pathToFileURL } from 'url';
|
|
|
11
11
|
|
|
12
12
|
// src/constants.ts
|
|
13
13
|
var DEFAULT_PORT = 7567;
|
|
14
|
+
var COMPLETED_STATUS = "Completed successfully";
|
|
14
15
|
|
|
15
16
|
// ../utils/dist/server.js
|
|
16
17
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
17
|
-
var VERSION = "0.0.
|
|
18
|
+
var VERSION = "0.0.86";
|
|
18
19
|
try {
|
|
19
20
|
fetch(`https://www.react-grab.com/api/version?source=codex&t=${Date.now()}`).catch(() => {
|
|
20
21
|
});
|
|
@@ -36,7 +37,7 @@ var getOrCreateThread = (sessionId, options) => {
|
|
|
36
37
|
return { thread: threadMap.get(sessionId).thread, isExisting: true };
|
|
37
38
|
}
|
|
38
39
|
const thread = codex.startThread({
|
|
39
|
-
workingDirectory: options?.workingDirectory ?? process.cwd()
|
|
40
|
+
workingDirectory: options?.workingDirectory ?? process.env.REACT_GRAB_CWD ?? process.cwd()
|
|
40
41
|
});
|
|
41
42
|
return { thread, isExisting: false };
|
|
42
43
|
};
|
|
@@ -74,7 +75,7 @@ ${content}`;
|
|
|
74
75
|
}
|
|
75
76
|
const isAborted = () => abortController.signal.aborted;
|
|
76
77
|
try {
|
|
77
|
-
await stream.writeSSE({ data: "Thinking
|
|
78
|
+
await stream.writeSSE({ data: "Thinking\u2026", event: "status" });
|
|
78
79
|
const { thread } = getOrCreateThread(sessionId, options);
|
|
79
80
|
if (sessionId && thread.id) {
|
|
80
81
|
lastThreadId = thread.id;
|
|
@@ -92,7 +93,7 @@ ${content}`;
|
|
|
92
93
|
}
|
|
93
94
|
if (!isAborted()) {
|
|
94
95
|
await stream.writeSSE({
|
|
95
|
-
data:
|
|
96
|
+
data: COMPLETED_STATUS,
|
|
96
97
|
event: "status"
|
|
97
98
|
});
|
|
98
99
|
await stream.writeSSE({ data: "", event: "done" });
|
|
@@ -148,7 +149,7 @@ var startServer = async (port = DEFAULT_PORT) => {
|
|
|
148
149
|
const honoApplication = createServer();
|
|
149
150
|
serve({ fetch: honoApplication.fetch, port });
|
|
150
151
|
console.log(
|
|
151
|
-
`${pc.magenta("\
|
|
152
|
+
`${pc.magenta("\u273F")} ${pc.bold("React Grab")} ${pc.gray(VERSION)} ${pc.dim("(Codex)")}`
|
|
152
153
|
);
|
|
153
154
|
console.log(`- Local: ${pc.cyan(`http://localhost:${port}`)}`);
|
|
154
155
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-grab/codex",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.86",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"react-grab-codex": "./dist/cli.cjs"
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.10.7",
|
|
27
28
|
"tsup": "^8.4.0",
|
|
28
|
-
"@react-grab/utils": "0.0.
|
|
29
|
+
"@react-grab/utils": "0.0.86"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@hono/node-server": "^1.19.6",
|
|
@@ -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.
|
|
38
|
+
"react-grab": "0.0.86"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"dev": "tsup --watch",
|