@react-grab/gemini 0.0.81
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/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/cli.cjs +617 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +614 -0
- package/dist/client.cjs +173 -0
- package/dist/client.d.cts +28 -0
- package/dist/client.d.ts +28 -0
- package/dist/client.global.js +4 -0
- package/dist/client.js +170 -0
- package/dist/server.cjs +6025 -0
- package/dist/server.d.cts +7 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +6013 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Aiden Bai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @react-grab/gemini
|
|
2
|
+
|
|
3
|
+
Google Gemini CLI provider for React Grab.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @react-grab/gemini
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Server
|
|
14
|
+
|
|
15
|
+
The server runs on port `8567` and interfaces with the Gemini CLI. Add to your `package.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "npx @react-grab/gemini@latest && next dev"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> **Note:** You must have [Gemini CLI](https://github.com/google-gemini/gemini-cli) installed (`npm i -g @anthropic-ai/gemini-cli`).
|
|
26
|
+
|
|
27
|
+
### Client
|
|
28
|
+
|
|
29
|
+
Add the client script to your HTML:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<script src="//unpkg.com/@react-grab/gemini/dist/client.global.js"></script>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or import programmatically:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import "@react-grab/gemini/client";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Follow-ups**: Continue conversations with the same session
|
|
44
|
+
- **Streaming**: Real-time status updates during execution
|
|
45
|
+
- **Tool calls**: See tool usage as it happens
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var url = require('url');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
|
|
7
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
15
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
16
|
+
}) : x)(function(x) {
|
|
17
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
18
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
19
|
+
});
|
|
20
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
21
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
37
|
+
mod
|
|
38
|
+
));
|
|
39
|
+
|
|
40
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
|
|
41
|
+
var require_windows = __commonJS({
|
|
42
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
|
|
43
|
+
module.exports = isexe;
|
|
44
|
+
isexe.sync = sync;
|
|
45
|
+
var fs = __require("fs");
|
|
46
|
+
function checkPathExt(path, options) {
|
|
47
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
48
|
+
if (!pathext) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
pathext = pathext.split(";");
|
|
52
|
+
if (pathext.indexOf("") !== -1) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
56
|
+
var p = pathext[i].toLowerCase();
|
|
57
|
+
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
function checkStat(stat, path, options) {
|
|
64
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return checkPathExt(path, options);
|
|
68
|
+
}
|
|
69
|
+
function isexe(path, options, cb) {
|
|
70
|
+
fs.stat(path, function(er, stat) {
|
|
71
|
+
cb(er, er ? false : checkStat(stat, path, options));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function sync(path, options) {
|
|
75
|
+
return checkStat(fs.statSync(path), path, options);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
|
|
81
|
+
var require_mode = __commonJS({
|
|
82
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
|
|
83
|
+
module.exports = isexe;
|
|
84
|
+
isexe.sync = sync;
|
|
85
|
+
var fs = __require("fs");
|
|
86
|
+
function isexe(path, options, cb) {
|
|
87
|
+
fs.stat(path, function(er, stat) {
|
|
88
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function sync(path, options) {
|
|
92
|
+
return checkStat(fs.statSync(path), options);
|
|
93
|
+
}
|
|
94
|
+
function checkStat(stat, options) {
|
|
95
|
+
return stat.isFile() && checkMode(stat, options);
|
|
96
|
+
}
|
|
97
|
+
function checkMode(stat, options) {
|
|
98
|
+
var mod = stat.mode;
|
|
99
|
+
var uid = stat.uid;
|
|
100
|
+
var gid = stat.gid;
|
|
101
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
102
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
103
|
+
var u = parseInt("100", 8);
|
|
104
|
+
var g = parseInt("010", 8);
|
|
105
|
+
var o = parseInt("001", 8);
|
|
106
|
+
var ug = u | g;
|
|
107
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
108
|
+
return ret;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
|
|
114
|
+
var require_isexe = __commonJS({
|
|
115
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
|
|
116
|
+
__require("fs");
|
|
117
|
+
var core;
|
|
118
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
119
|
+
core = require_windows();
|
|
120
|
+
} else {
|
|
121
|
+
core = require_mode();
|
|
122
|
+
}
|
|
123
|
+
module.exports = isexe;
|
|
124
|
+
isexe.sync = sync;
|
|
125
|
+
function isexe(path, options, cb) {
|
|
126
|
+
if (typeof options === "function") {
|
|
127
|
+
cb = options;
|
|
128
|
+
options = {};
|
|
129
|
+
}
|
|
130
|
+
if (!cb) {
|
|
131
|
+
if (typeof Promise !== "function") {
|
|
132
|
+
throw new TypeError("callback not provided");
|
|
133
|
+
}
|
|
134
|
+
return new Promise(function(resolve, reject) {
|
|
135
|
+
isexe(path, options || {}, function(er, is) {
|
|
136
|
+
if (er) {
|
|
137
|
+
reject(er);
|
|
138
|
+
} else {
|
|
139
|
+
resolve(is);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
core(path, options || {}, function(er, is) {
|
|
145
|
+
if (er) {
|
|
146
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
147
|
+
er = null;
|
|
148
|
+
is = false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
cb(er, is);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function sync(path, options) {
|
|
155
|
+
try {
|
|
156
|
+
return core.sync(path, options || {});
|
|
157
|
+
} catch (er) {
|
|
158
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
159
|
+
return false;
|
|
160
|
+
} else {
|
|
161
|
+
throw er;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
|
|
169
|
+
var require_which = __commonJS({
|
|
170
|
+
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
171
|
+
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
172
|
+
var path = __require("path");
|
|
173
|
+
var COLON = isWindows ? ";" : ":";
|
|
174
|
+
var isexe = require_isexe();
|
|
175
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
176
|
+
var getPathInfo = (cmd, opt) => {
|
|
177
|
+
const colon = opt.colon || COLON;
|
|
178
|
+
const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
|
|
179
|
+
// windows always checks the cwd first
|
|
180
|
+
...isWindows ? [process.cwd()] : [],
|
|
181
|
+
...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
|
|
182
|
+
"").split(colon)
|
|
183
|
+
];
|
|
184
|
+
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
185
|
+
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
186
|
+
if (isWindows) {
|
|
187
|
+
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
|
|
188
|
+
pathExt.unshift("");
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
pathEnv,
|
|
192
|
+
pathExt,
|
|
193
|
+
pathExtExe
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
var which = (cmd, opt, cb) => {
|
|
197
|
+
if (typeof opt === "function") {
|
|
198
|
+
cb = opt;
|
|
199
|
+
opt = {};
|
|
200
|
+
}
|
|
201
|
+
if (!opt)
|
|
202
|
+
opt = {};
|
|
203
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
204
|
+
const found = [];
|
|
205
|
+
const step = (i) => new Promise((resolve, reject) => {
|
|
206
|
+
if (i === pathEnv.length)
|
|
207
|
+
return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
208
|
+
const ppRaw = pathEnv[i];
|
|
209
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
210
|
+
const pCmd = path.join(pathPart, cmd);
|
|
211
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
212
|
+
resolve(subStep(p, i, 0));
|
|
213
|
+
});
|
|
214
|
+
const subStep = (p, i, ii) => new Promise((resolve, reject) => {
|
|
215
|
+
if (ii === pathExt.length)
|
|
216
|
+
return resolve(step(i + 1));
|
|
217
|
+
const ext = pathExt[ii];
|
|
218
|
+
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
219
|
+
if (!er && is) {
|
|
220
|
+
if (opt.all)
|
|
221
|
+
found.push(p + ext);
|
|
222
|
+
else
|
|
223
|
+
return resolve(p + ext);
|
|
224
|
+
}
|
|
225
|
+
return resolve(subStep(p, i, ii + 1));
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
229
|
+
};
|
|
230
|
+
var whichSync = (cmd, opt) => {
|
|
231
|
+
opt = opt || {};
|
|
232
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
233
|
+
const found = [];
|
|
234
|
+
for (let i = 0; i < pathEnv.length; i++) {
|
|
235
|
+
const ppRaw = pathEnv[i];
|
|
236
|
+
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
237
|
+
const pCmd = path.join(pathPart, cmd);
|
|
238
|
+
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
239
|
+
for (let j = 0; j < pathExt.length; j++) {
|
|
240
|
+
const cur = p + pathExt[j];
|
|
241
|
+
try {
|
|
242
|
+
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
243
|
+
if (is) {
|
|
244
|
+
if (opt.all)
|
|
245
|
+
found.push(cur);
|
|
246
|
+
else
|
|
247
|
+
return cur;
|
|
248
|
+
}
|
|
249
|
+
} catch (ex) {
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (opt.all && found.length)
|
|
254
|
+
return found;
|
|
255
|
+
if (opt.nothrow)
|
|
256
|
+
return null;
|
|
257
|
+
throw getNotFoundError(cmd);
|
|
258
|
+
};
|
|
259
|
+
module.exports = which;
|
|
260
|
+
which.sync = whichSync;
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
// ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
|
|
265
|
+
var require_path_key = __commonJS({
|
|
266
|
+
"../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module) {
|
|
267
|
+
var pathKey = (options = {}) => {
|
|
268
|
+
const environment = options.env || process.env;
|
|
269
|
+
const platform = options.platform || process.platform;
|
|
270
|
+
if (platform !== "win32") {
|
|
271
|
+
return "PATH";
|
|
272
|
+
}
|
|
273
|
+
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
|
|
274
|
+
};
|
|
275
|
+
module.exports = pathKey;
|
|
276
|
+
module.exports.default = pathKey;
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
281
|
+
var require_resolveCommand = __commonJS({
|
|
282
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
283
|
+
var path = __require("path");
|
|
284
|
+
var which = require_which();
|
|
285
|
+
var getPathKey = require_path_key();
|
|
286
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
287
|
+
const env = parsed.options.env || process.env;
|
|
288
|
+
const cwd = process.cwd();
|
|
289
|
+
const hasCustomCwd = parsed.options.cwd != null;
|
|
290
|
+
const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
|
|
291
|
+
if (shouldSwitchCwd) {
|
|
292
|
+
try {
|
|
293
|
+
process.chdir(parsed.options.cwd);
|
|
294
|
+
} catch (err) {
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
let resolved;
|
|
298
|
+
try {
|
|
299
|
+
resolved = which.sync(parsed.command, {
|
|
300
|
+
path: env[getPathKey({ env })],
|
|
301
|
+
pathExt: withoutPathExt ? path.delimiter : void 0
|
|
302
|
+
});
|
|
303
|
+
} catch (e) {
|
|
304
|
+
} finally {
|
|
305
|
+
if (shouldSwitchCwd) {
|
|
306
|
+
process.chdir(cwd);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (resolved) {
|
|
310
|
+
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
311
|
+
}
|
|
312
|
+
return resolved;
|
|
313
|
+
}
|
|
314
|
+
function resolveCommand(parsed) {
|
|
315
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
316
|
+
}
|
|
317
|
+
module.exports = resolveCommand;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
|
|
322
|
+
var require_escape = __commonJS({
|
|
323
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
|
|
324
|
+
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
325
|
+
function escapeCommand(arg) {
|
|
326
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
327
|
+
return arg;
|
|
328
|
+
}
|
|
329
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
330
|
+
arg = `${arg}`;
|
|
331
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
|
|
332
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
333
|
+
arg = `"${arg}"`;
|
|
334
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
335
|
+
if (doubleEscapeMetaChars) {
|
|
336
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
337
|
+
}
|
|
338
|
+
return arg;
|
|
339
|
+
}
|
|
340
|
+
module.exports.command = escapeCommand;
|
|
341
|
+
module.exports.argument = escapeArgument;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
|
|
346
|
+
var require_shebang_regex = __commonJS({
|
|
347
|
+
"../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module) {
|
|
348
|
+
module.exports = /^#!(.*)/;
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
|
|
353
|
+
var require_shebang_command = __commonJS({
|
|
354
|
+
"../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module) {
|
|
355
|
+
var shebangRegex = require_shebang_regex();
|
|
356
|
+
module.exports = (string = "") => {
|
|
357
|
+
const match = string.match(shebangRegex);
|
|
358
|
+
if (!match) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
362
|
+
const binary = path.split("/").pop();
|
|
363
|
+
if (binary === "env") {
|
|
364
|
+
return argument;
|
|
365
|
+
}
|
|
366
|
+
return argument ? `${binary} ${argument}` : binary;
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
|
|
372
|
+
var require_readShebang = __commonJS({
|
|
373
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
|
|
374
|
+
var fs = __require("fs");
|
|
375
|
+
var shebangCommand = require_shebang_command();
|
|
376
|
+
function readShebang(command) {
|
|
377
|
+
const size = 150;
|
|
378
|
+
const buffer = Buffer.alloc(size);
|
|
379
|
+
let fd;
|
|
380
|
+
try {
|
|
381
|
+
fd = fs.openSync(command, "r");
|
|
382
|
+
fs.readSync(fd, buffer, 0, size, 0);
|
|
383
|
+
fs.closeSync(fd);
|
|
384
|
+
} catch (e) {
|
|
385
|
+
}
|
|
386
|
+
return shebangCommand(buffer.toString());
|
|
387
|
+
}
|
|
388
|
+
module.exports = readShebang;
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
393
|
+
var require_parse = __commonJS({
|
|
394
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
395
|
+
var path = __require("path");
|
|
396
|
+
var resolveCommand = require_resolveCommand();
|
|
397
|
+
var escape = require_escape();
|
|
398
|
+
var readShebang = require_readShebang();
|
|
399
|
+
var isWin = process.platform === "win32";
|
|
400
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
401
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
402
|
+
function detectShebang(parsed) {
|
|
403
|
+
parsed.file = resolveCommand(parsed);
|
|
404
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
405
|
+
if (shebang) {
|
|
406
|
+
parsed.args.unshift(parsed.file);
|
|
407
|
+
parsed.command = shebang;
|
|
408
|
+
return resolveCommand(parsed);
|
|
409
|
+
}
|
|
410
|
+
return parsed.file;
|
|
411
|
+
}
|
|
412
|
+
function parseNonShell(parsed) {
|
|
413
|
+
if (!isWin) {
|
|
414
|
+
return parsed;
|
|
415
|
+
}
|
|
416
|
+
const commandFile = detectShebang(parsed);
|
|
417
|
+
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
418
|
+
if (parsed.options.forceShell || needsShell) {
|
|
419
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
420
|
+
parsed.command = path.normalize(parsed.command);
|
|
421
|
+
parsed.command = escape.command(parsed.command);
|
|
422
|
+
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
423
|
+
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
424
|
+
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
|
|
425
|
+
parsed.command = process.env.comspec || "cmd.exe";
|
|
426
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
427
|
+
}
|
|
428
|
+
return parsed;
|
|
429
|
+
}
|
|
430
|
+
function parse(command, args, options) {
|
|
431
|
+
if (args && !Array.isArray(args)) {
|
|
432
|
+
options = args;
|
|
433
|
+
args = null;
|
|
434
|
+
}
|
|
435
|
+
args = args ? args.slice(0) : [];
|
|
436
|
+
options = Object.assign({}, options);
|
|
437
|
+
const parsed = {
|
|
438
|
+
command,
|
|
439
|
+
args,
|
|
440
|
+
options,
|
|
441
|
+
file: void 0,
|
|
442
|
+
original: {
|
|
443
|
+
command,
|
|
444
|
+
args
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
return options.shell ? parsed : parseNonShell(parsed);
|
|
448
|
+
}
|
|
449
|
+
module.exports = parse;
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
|
|
454
|
+
var require_enoent = __commonJS({
|
|
455
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module) {
|
|
456
|
+
var isWin = process.platform === "win32";
|
|
457
|
+
function notFoundError(original, syscall) {
|
|
458
|
+
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
|
|
459
|
+
code: "ENOENT",
|
|
460
|
+
errno: "ENOENT",
|
|
461
|
+
syscall: `${syscall} ${original.command}`,
|
|
462
|
+
path: original.command,
|
|
463
|
+
spawnargs: original.args
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
function hookChildProcess(cp, parsed) {
|
|
467
|
+
if (!isWin) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
const originalEmit = cp.emit;
|
|
471
|
+
cp.emit = function(name, arg1) {
|
|
472
|
+
if (name === "exit") {
|
|
473
|
+
const err = verifyENOENT(arg1, parsed);
|
|
474
|
+
if (err) {
|
|
475
|
+
return originalEmit.call(cp, "error", err);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return originalEmit.apply(cp, arguments);
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function verifyENOENT(status, parsed) {
|
|
482
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
483
|
+
return notFoundError(parsed.original, "spawn");
|
|
484
|
+
}
|
|
485
|
+
return null;
|
|
486
|
+
}
|
|
487
|
+
function verifyENOENTSync(status, parsed) {
|
|
488
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
489
|
+
return notFoundError(parsed.original, "spawnSync");
|
|
490
|
+
}
|
|
491
|
+
return null;
|
|
492
|
+
}
|
|
493
|
+
module.exports = {
|
|
494
|
+
hookChildProcess,
|
|
495
|
+
verifyENOENT,
|
|
496
|
+
verifyENOENTSync,
|
|
497
|
+
notFoundError
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
// ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
|
|
503
|
+
var require_cross_spawn = __commonJS({
|
|
504
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
|
|
505
|
+
var cp = __require("child_process");
|
|
506
|
+
var parse = require_parse();
|
|
507
|
+
var enoent = require_enoent();
|
|
508
|
+
function spawn2(command, args, options) {
|
|
509
|
+
const parsed = parse(command, args, options);
|
|
510
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
511
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
512
|
+
return spawned;
|
|
513
|
+
}
|
|
514
|
+
function spawnSync(command, args, options) {
|
|
515
|
+
const parsed = parse(command, args, options);
|
|
516
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
517
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
518
|
+
return result;
|
|
519
|
+
}
|
|
520
|
+
module.exports = spawn2;
|
|
521
|
+
module.exports.spawn = spawn2;
|
|
522
|
+
module.exports.sync = spawnSync;
|
|
523
|
+
module.exports._parse = parse;
|
|
524
|
+
module.exports._enoent = enoent;
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
// ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
529
|
+
var require_picocolors = __commonJS({
|
|
530
|
+
"../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
|
|
531
|
+
var p = process || {};
|
|
532
|
+
var argv = p.argv || [];
|
|
533
|
+
var env = p.env || {};
|
|
534
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
535
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
536
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
537
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
538
|
+
};
|
|
539
|
+
var replaceClose = (string, close, replace, index) => {
|
|
540
|
+
let result = "", cursor = 0;
|
|
541
|
+
do {
|
|
542
|
+
result += string.substring(cursor, index) + replace;
|
|
543
|
+
cursor = index + close.length;
|
|
544
|
+
index = string.indexOf(close, cursor);
|
|
545
|
+
} while (~index);
|
|
546
|
+
return result + string.substring(cursor);
|
|
547
|
+
};
|
|
548
|
+
var createColors = (enabled = isColorSupported) => {
|
|
549
|
+
let f = enabled ? formatter : () => String;
|
|
550
|
+
return {
|
|
551
|
+
isColorSupported: enabled,
|
|
552
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
553
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
554
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
555
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
556
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
557
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
558
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
559
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
560
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
561
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
562
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
563
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
564
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
565
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
566
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
567
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
568
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
569
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
570
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
571
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
572
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
573
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
574
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
575
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
576
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
577
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
578
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
579
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
580
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
581
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
582
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
583
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
584
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
585
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
586
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
587
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
588
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
589
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
590
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
591
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
592
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
593
|
+
};
|
|
594
|
+
};
|
|
595
|
+
module.exports = createColors();
|
|
596
|
+
module.exports.createColors = createColors;
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
// src/cli.ts
|
|
601
|
+
var import_cross_spawn = __toESM(require_cross_spawn());
|
|
602
|
+
var import_picocolors = __toESM(require_picocolors());
|
|
603
|
+
|
|
604
|
+
// src/constants.ts
|
|
605
|
+
var DEFAULT_PORT = 8567;
|
|
606
|
+
|
|
607
|
+
// src/cli.ts
|
|
608
|
+
var VERSION = "0.0.81";
|
|
609
|
+
var __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.cjs', document.baseURI).href)));
|
|
610
|
+
var __dirname$1 = path.dirname(__filename$1);
|
|
611
|
+
var serverPath = path.join(__dirname$1, "server.js");
|
|
612
|
+
(0, import_cross_spawn.default)(process.execPath, [serverPath], {
|
|
613
|
+
detached: true,
|
|
614
|
+
stdio: "ignore"
|
|
615
|
+
}).unref();
|
|
616
|
+
console.log(`${import_picocolors.default.magenta("\u269B")} ${import_picocolors.default.bold("React Grab")} ${import_picocolors.default.gray(VERSION)} ${import_picocolors.default.dim("(Gemini)")}`);
|
|
617
|
+
console.log(`- Local: ${import_picocolors.default.cyan(`http://localhost:${DEFAULT_PORT}`)}`);
|
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|