@react-grab/claude-code 0.0.78 → 0.0.80

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.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { spawn } from 'child_process';
3
2
  import { fileURLToPath } from 'url';
4
3
  import { dirname, join } from 'path';
5
4
 
@@ -9,7 +8,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
8
  var __getOwnPropNames = Object.getOwnPropertyNames;
10
9
  var __getProtoOf = Object.getPrototypeOf;
11
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __commonJS = (cb, mod) => function __require() {
11
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
12
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
13
+ }) : x)(function(x) {
14
+ if (typeof require !== "undefined") return require.apply(this, arguments);
15
+ throw Error('Dynamic require of "' + x + '" is not supported');
16
+ });
17
+ var __commonJS = (cb, mod) => function __require2() {
13
18
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
19
  };
15
20
  var __copyProps = (to, from, except, desc) => {
@@ -29,6 +34,494 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
34
  mod
30
35
  ));
31
36
 
37
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
38
+ var require_windows = __commonJS({
39
+ "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module) {
40
+ module.exports = isexe;
41
+ isexe.sync = sync;
42
+ var fs = __require("fs");
43
+ function checkPathExt(path, options) {
44
+ var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
45
+ if (!pathext) {
46
+ return true;
47
+ }
48
+ pathext = pathext.split(";");
49
+ if (pathext.indexOf("") !== -1) {
50
+ return true;
51
+ }
52
+ for (var i = 0; i < pathext.length; i++) {
53
+ var p = pathext[i].toLowerCase();
54
+ if (p && path.substr(-p.length).toLowerCase() === p) {
55
+ return true;
56
+ }
57
+ }
58
+ return false;
59
+ }
60
+ function checkStat(stat, path, options) {
61
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
62
+ return false;
63
+ }
64
+ return checkPathExt(path, options);
65
+ }
66
+ function isexe(path, options, cb) {
67
+ fs.stat(path, function(er, stat) {
68
+ cb(er, er ? false : checkStat(stat, path, options));
69
+ });
70
+ }
71
+ function sync(path, options) {
72
+ return checkStat(fs.statSync(path), path, options);
73
+ }
74
+ }
75
+ });
76
+
77
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
78
+ var require_mode = __commonJS({
79
+ "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module) {
80
+ module.exports = isexe;
81
+ isexe.sync = sync;
82
+ var fs = __require("fs");
83
+ function isexe(path, options, cb) {
84
+ fs.stat(path, function(er, stat) {
85
+ cb(er, er ? false : checkStat(stat, options));
86
+ });
87
+ }
88
+ function sync(path, options) {
89
+ return checkStat(fs.statSync(path), options);
90
+ }
91
+ function checkStat(stat, options) {
92
+ return stat.isFile() && checkMode(stat, options);
93
+ }
94
+ function checkMode(stat, options) {
95
+ var mod = stat.mode;
96
+ var uid = stat.uid;
97
+ var gid = stat.gid;
98
+ var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
99
+ var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
100
+ var u = parseInt("100", 8);
101
+ var g = parseInt("010", 8);
102
+ var o = parseInt("001", 8);
103
+ var ug = u | g;
104
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
105
+ return ret;
106
+ }
107
+ }
108
+ });
109
+
110
+ // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
111
+ var require_isexe = __commonJS({
112
+ "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
113
+ __require("fs");
114
+ var core;
115
+ if (process.platform === "win32" || global.TESTING_WINDOWS) {
116
+ core = require_windows();
117
+ } else {
118
+ core = require_mode();
119
+ }
120
+ module.exports = isexe;
121
+ isexe.sync = sync;
122
+ function isexe(path, options, cb) {
123
+ if (typeof options === "function") {
124
+ cb = options;
125
+ options = {};
126
+ }
127
+ if (!cb) {
128
+ if (typeof Promise !== "function") {
129
+ throw new TypeError("callback not provided");
130
+ }
131
+ return new Promise(function(resolve, reject) {
132
+ isexe(path, options || {}, function(er, is) {
133
+ if (er) {
134
+ reject(er);
135
+ } else {
136
+ resolve(is);
137
+ }
138
+ });
139
+ });
140
+ }
141
+ core(path, options || {}, function(er, is) {
142
+ if (er) {
143
+ if (er.code === "EACCES" || options && options.ignoreErrors) {
144
+ er = null;
145
+ is = false;
146
+ }
147
+ }
148
+ cb(er, is);
149
+ });
150
+ }
151
+ function sync(path, options) {
152
+ try {
153
+ return core.sync(path, options || {});
154
+ } catch (er) {
155
+ if (options && options.ignoreErrors || er.code === "EACCES") {
156
+ return false;
157
+ } else {
158
+ throw er;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ });
164
+
165
+ // ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
166
+ var require_which = __commonJS({
167
+ "../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
168
+ var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
169
+ var path = __require("path");
170
+ var COLON = isWindows ? ";" : ":";
171
+ var isexe = require_isexe();
172
+ var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
173
+ var getPathInfo = (cmd, opt) => {
174
+ const colon = opt.colon || COLON;
175
+ const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
176
+ // windows always checks the cwd first
177
+ ...isWindows ? [process.cwd()] : [],
178
+ ...(opt.path || process.env.PATH || /* istanbul ignore next: very unusual */
179
+ "").split(colon)
180
+ ];
181
+ const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
182
+ const pathExt = isWindows ? pathExtExe.split(colon) : [""];
183
+ if (isWindows) {
184
+ if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
185
+ pathExt.unshift("");
186
+ }
187
+ return {
188
+ pathEnv,
189
+ pathExt,
190
+ pathExtExe
191
+ };
192
+ };
193
+ var which = (cmd, opt, cb) => {
194
+ if (typeof opt === "function") {
195
+ cb = opt;
196
+ opt = {};
197
+ }
198
+ if (!opt)
199
+ opt = {};
200
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
201
+ const found = [];
202
+ const step = (i) => new Promise((resolve, reject) => {
203
+ if (i === pathEnv.length)
204
+ return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
205
+ const ppRaw = pathEnv[i];
206
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
207
+ const pCmd = path.join(pathPart, cmd);
208
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
209
+ resolve(subStep(p, i, 0));
210
+ });
211
+ const subStep = (p, i, ii) => new Promise((resolve, reject) => {
212
+ if (ii === pathExt.length)
213
+ return resolve(step(i + 1));
214
+ const ext = pathExt[ii];
215
+ isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
216
+ if (!er && is) {
217
+ if (opt.all)
218
+ found.push(p + ext);
219
+ else
220
+ return resolve(p + ext);
221
+ }
222
+ return resolve(subStep(p, i, ii + 1));
223
+ });
224
+ });
225
+ return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
226
+ };
227
+ var whichSync = (cmd, opt) => {
228
+ opt = opt || {};
229
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
230
+ const found = [];
231
+ for (let i = 0; i < pathEnv.length; i++) {
232
+ const ppRaw = pathEnv[i];
233
+ const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
234
+ const pCmd = path.join(pathPart, cmd);
235
+ const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
236
+ for (let j = 0; j < pathExt.length; j++) {
237
+ const cur = p + pathExt[j];
238
+ try {
239
+ const is = isexe.sync(cur, { pathExt: pathExtExe });
240
+ if (is) {
241
+ if (opt.all)
242
+ found.push(cur);
243
+ else
244
+ return cur;
245
+ }
246
+ } catch (ex) {
247
+ }
248
+ }
249
+ }
250
+ if (opt.all && found.length)
251
+ return found;
252
+ if (opt.nothrow)
253
+ return null;
254
+ throw getNotFoundError(cmd);
255
+ };
256
+ module.exports = which;
257
+ which.sync = whichSync;
258
+ }
259
+ });
260
+
261
+ // ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
262
+ var require_path_key = __commonJS({
263
+ "../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module) {
264
+ var pathKey = (options = {}) => {
265
+ const environment = options.env || process.env;
266
+ const platform = options.platform || process.platform;
267
+ if (platform !== "win32") {
268
+ return "PATH";
269
+ }
270
+ return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
271
+ };
272
+ module.exports = pathKey;
273
+ module.exports.default = pathKey;
274
+ }
275
+ });
276
+
277
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
278
+ var require_resolveCommand = __commonJS({
279
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
280
+ var path = __require("path");
281
+ var which = require_which();
282
+ var getPathKey = require_path_key();
283
+ function resolveCommandAttempt(parsed, withoutPathExt) {
284
+ const env = parsed.options.env || process.env;
285
+ const cwd = process.cwd();
286
+ const hasCustomCwd = parsed.options.cwd != null;
287
+ const shouldSwitchCwd = hasCustomCwd && process.chdir !== void 0 && !process.chdir.disabled;
288
+ if (shouldSwitchCwd) {
289
+ try {
290
+ process.chdir(parsed.options.cwd);
291
+ } catch (err) {
292
+ }
293
+ }
294
+ let resolved;
295
+ try {
296
+ resolved = which.sync(parsed.command, {
297
+ path: env[getPathKey({ env })],
298
+ pathExt: withoutPathExt ? path.delimiter : void 0
299
+ });
300
+ } catch (e) {
301
+ } finally {
302
+ if (shouldSwitchCwd) {
303
+ process.chdir(cwd);
304
+ }
305
+ }
306
+ if (resolved) {
307
+ resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
308
+ }
309
+ return resolved;
310
+ }
311
+ function resolveCommand(parsed) {
312
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
313
+ }
314
+ module.exports = resolveCommand;
315
+ }
316
+ });
317
+
318
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js
319
+ var require_escape = __commonJS({
320
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js"(exports, module) {
321
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
322
+ function escapeCommand(arg) {
323
+ arg = arg.replace(metaCharsRegExp, "^$1");
324
+ return arg;
325
+ }
326
+ function escapeArgument(arg, doubleEscapeMetaChars) {
327
+ arg = `${arg}`;
328
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
329
+ arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
330
+ arg = `"${arg}"`;
331
+ arg = arg.replace(metaCharsRegExp, "^$1");
332
+ if (doubleEscapeMetaChars) {
333
+ arg = arg.replace(metaCharsRegExp, "^$1");
334
+ }
335
+ return arg;
336
+ }
337
+ module.exports.command = escapeCommand;
338
+ module.exports.argument = escapeArgument;
339
+ }
340
+ });
341
+
342
+ // ../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js
343
+ var require_shebang_regex = __commonJS({
344
+ "../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js"(exports, module) {
345
+ module.exports = /^#!(.*)/;
346
+ }
347
+ });
348
+
349
+ // ../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js
350
+ var require_shebang_command = __commonJS({
351
+ "../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js"(exports, module) {
352
+ var shebangRegex = require_shebang_regex();
353
+ module.exports = (string = "") => {
354
+ const match = string.match(shebangRegex);
355
+ if (!match) {
356
+ return null;
357
+ }
358
+ const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
359
+ const binary = path.split("/").pop();
360
+ if (binary === "env") {
361
+ return argument;
362
+ }
363
+ return argument ? `${binary} ${argument}` : binary;
364
+ };
365
+ }
366
+ });
367
+
368
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js
369
+ var require_readShebang = __commonJS({
370
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module) {
371
+ var fs = __require("fs");
372
+ var shebangCommand = require_shebang_command();
373
+ function readShebang(command) {
374
+ const size = 150;
375
+ const buffer = Buffer.alloc(size);
376
+ let fd;
377
+ try {
378
+ fd = fs.openSync(command, "r");
379
+ fs.readSync(fd, buffer, 0, size, 0);
380
+ fs.closeSync(fd);
381
+ } catch (e) {
382
+ }
383
+ return shebangCommand(buffer.toString());
384
+ }
385
+ module.exports = readShebang;
386
+ }
387
+ });
388
+
389
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
390
+ var require_parse = __commonJS({
391
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
392
+ var path = __require("path");
393
+ var resolveCommand = require_resolveCommand();
394
+ var escape = require_escape();
395
+ var readShebang = require_readShebang();
396
+ var isWin = process.platform === "win32";
397
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
398
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
399
+ function detectShebang(parsed) {
400
+ parsed.file = resolveCommand(parsed);
401
+ const shebang = parsed.file && readShebang(parsed.file);
402
+ if (shebang) {
403
+ parsed.args.unshift(parsed.file);
404
+ parsed.command = shebang;
405
+ return resolveCommand(parsed);
406
+ }
407
+ return parsed.file;
408
+ }
409
+ function parseNonShell(parsed) {
410
+ if (!isWin) {
411
+ return parsed;
412
+ }
413
+ const commandFile = detectShebang(parsed);
414
+ const needsShell = !isExecutableRegExp.test(commandFile);
415
+ if (parsed.options.forceShell || needsShell) {
416
+ const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
417
+ parsed.command = path.normalize(parsed.command);
418
+ parsed.command = escape.command(parsed.command);
419
+ parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
420
+ const shellCommand = [parsed.command].concat(parsed.args).join(" ");
421
+ parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
422
+ parsed.command = process.env.comspec || "cmd.exe";
423
+ parsed.options.windowsVerbatimArguments = true;
424
+ }
425
+ return parsed;
426
+ }
427
+ function parse(command, args, options) {
428
+ if (args && !Array.isArray(args)) {
429
+ options = args;
430
+ args = null;
431
+ }
432
+ args = args ? args.slice(0) : [];
433
+ options = Object.assign({}, options);
434
+ const parsed = {
435
+ command,
436
+ args,
437
+ options,
438
+ file: void 0,
439
+ original: {
440
+ command,
441
+ args
442
+ }
443
+ };
444
+ return options.shell ? parsed : parseNonShell(parsed);
445
+ }
446
+ module.exports = parse;
447
+ }
448
+ });
449
+
450
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js
451
+ var require_enoent = __commonJS({
452
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js"(exports, module) {
453
+ var isWin = process.platform === "win32";
454
+ function notFoundError(original, syscall) {
455
+ return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
456
+ code: "ENOENT",
457
+ errno: "ENOENT",
458
+ syscall: `${syscall} ${original.command}`,
459
+ path: original.command,
460
+ spawnargs: original.args
461
+ });
462
+ }
463
+ function hookChildProcess(cp, parsed) {
464
+ if (!isWin) {
465
+ return;
466
+ }
467
+ const originalEmit = cp.emit;
468
+ cp.emit = function(name, arg1) {
469
+ if (name === "exit") {
470
+ const err = verifyENOENT(arg1, parsed);
471
+ if (err) {
472
+ return originalEmit.call(cp, "error", err);
473
+ }
474
+ }
475
+ return originalEmit.apply(cp, arguments);
476
+ };
477
+ }
478
+ function verifyENOENT(status, parsed) {
479
+ if (isWin && status === 1 && !parsed.file) {
480
+ return notFoundError(parsed.original, "spawn");
481
+ }
482
+ return null;
483
+ }
484
+ function verifyENOENTSync(status, parsed) {
485
+ if (isWin && status === 1 && !parsed.file) {
486
+ return notFoundError(parsed.original, "spawnSync");
487
+ }
488
+ return null;
489
+ }
490
+ module.exports = {
491
+ hookChildProcess,
492
+ verifyENOENT,
493
+ verifyENOENTSync,
494
+ notFoundError
495
+ };
496
+ }
497
+ });
498
+
499
+ // ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js
500
+ var require_cross_spawn = __commonJS({
501
+ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js"(exports, module) {
502
+ var cp = __require("child_process");
503
+ var parse = require_parse();
504
+ var enoent = require_enoent();
505
+ function spawn2(command, args, options) {
506
+ const parsed = parse(command, args, options);
507
+ const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
508
+ enoent.hookChildProcess(spawned, parsed);
509
+ return spawned;
510
+ }
511
+ function spawnSync(command, args, options) {
512
+ const parsed = parse(command, args, options);
513
+ const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
514
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
515
+ return result;
516
+ }
517
+ module.exports = spawn2;
518
+ module.exports.spawn = spawn2;
519
+ module.exports.sync = spawnSync;
520
+ module.exports._parse = parse;
521
+ module.exports._enoent = enoent;
522
+ }
523
+ });
524
+
32
525
  // ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
33
526
  var require_picocolors = __commonJS({
34
527
  "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"(exports, module) {
@@ -102,17 +595,18 @@ var require_picocolors = __commonJS({
102
595
  });
103
596
 
104
597
  // src/cli.ts
598
+ var import_cross_spawn = __toESM(require_cross_spawn());
105
599
  var import_picocolors = __toESM(require_picocolors());
106
600
 
107
601
  // src/constants.ts
108
602
  var DEFAULT_PORT = 4567;
109
603
 
110
604
  // src/cli.ts
111
- var VERSION = "0.0.78";
605
+ var VERSION = "0.0.80";
112
606
  var __filename = fileURLToPath(import.meta.url);
113
607
  var __dirname = dirname(__filename);
114
608
  var serverPath = join(__dirname, "server.js");
115
- spawn(process.execPath, [serverPath], {
609
+ (0, import_cross_spawn.default)(process.execPath, [serverPath], {
116
610
  detached: true,
117
611
  stdio: "ignore"
118
612
  }).unref();
package/dist/client.cjs CHANGED
@@ -69,19 +69,33 @@ async function* streamSSE(stream, signal) {
69
69
  }
70
70
  }
71
71
  async function* streamFromServer(serverUrl, context, signal) {
72
- const response = await fetch(`${serverUrl}/agent`, {
73
- method: "POST",
74
- headers: { "Content-Type": "application/json" },
75
- body: JSON.stringify(context),
76
- signal
77
- });
78
- if (!response.ok) {
79
- throw new Error(`Server error: ${response.status}`);
80
- }
81
- if (!response.body) {
82
- throw new Error("No response body");
72
+ const sessionId = context.sessionId;
73
+ const handleAbort = () => {
74
+ if (sessionId) {
75
+ fetch(`${serverUrl}/abort/${sessionId}`, { method: "POST" }).catch(
76
+ () => {
77
+ }
78
+ );
79
+ }
80
+ };
81
+ signal.addEventListener("abort", handleAbort);
82
+ try {
83
+ const response = await fetch(`${serverUrl}/agent`, {
84
+ method: "POST",
85
+ headers: { "Content-Type": "application/json" },
86
+ body: JSON.stringify(context),
87
+ signal
88
+ });
89
+ if (!response.ok) {
90
+ throw new Error(`Server error: ${response.status}`);
91
+ }
92
+ if (!response.body) {
93
+ throw new Error("No response body");
94
+ }
95
+ yield* streamSSE(response.body, signal);
96
+ } finally {
97
+ signal.removeEventListener("abort", handleAbort);
83
98
  }
84
- yield* streamSSE(response.body, signal);
85
99
  }
86
100
  var createClaudeAgentProvider = (providerOptions = {}) => {
87
101
  const { serverUrl = DEFAULT_SERVER_URL, getOptions } = providerOptions;
@@ -118,6 +132,7 @@ var createClaudeAgentProvider = (providerOptions = {}) => {
118
132
  yield* streamFromServer(serverUrl, mergedContext, signal);
119
133
  },
120
134
  supportsResume: true,
135
+ supportsFollowUp: true,
121
136
  checkConnection: async () => {
122
137
  const now = Date.now();
123
138
  if (connectionCache && now - connectionCache.timestamp < CONNECTION_CHECK_TTL_MS) {
@@ -144,19 +159,26 @@ var createClaudeAgentProvider = (providerOptions = {}) => {
144
159
  var attachAgent = async () => {
145
160
  if (typeof window === "undefined") return;
146
161
  const provider = createClaudeAgentProvider();
162
+ const attach = (api2) => {
163
+ api2.setAgent({ provider, storage: sessionStorage });
164
+ };
147
165
  const api = window.__REACT_GRAB__;
148
166
  if (api) {
149
- api.setAgent({ provider, storage: sessionStorage });
167
+ attach(api);
150
168
  return;
151
169
  }
152
170
  window.addEventListener(
153
171
  "react-grab:init",
154
172
  (event) => {
155
173
  const customEvent = event;
156
- customEvent.detail.setAgent({ provider, storage: sessionStorage });
174
+ attach(customEvent.detail);
157
175
  },
158
176
  { once: true }
159
177
  );
178
+ const apiAfterListener = window.__REACT_GRAB__;
179
+ if (apiAfterListener) {
180
+ attach(apiAfterListener);
181
+ }
160
182
  };
161
183
  attachAgent();
162
184
 
package/dist/client.d.cts CHANGED
@@ -11,6 +11,7 @@ declare const createClaudeAgentProvider: (providerOptions?: ClaudeAgentProviderO
11
11
  send: (context: ClaudeAgentContext, signal: AbortSignal) => AsyncGenerator<string, void, unknown>;
12
12
  resume: (sessionId: string, signal: AbortSignal, storage: AgentSessionStorage) => AsyncGenerator<string, void, unknown>;
13
13
  supportsResume: boolean;
14
+ supportsFollowUp: boolean;
14
15
  checkConnection: () => Promise<boolean>;
15
16
  undo: () => Promise<void>;
16
17
  };
package/dist/client.d.ts CHANGED
@@ -11,6 +11,7 @@ declare const createClaudeAgentProvider: (providerOptions?: ClaudeAgentProviderO
11
11
  send: (context: ClaudeAgentContext, signal: AbortSignal) => AsyncGenerator<string, void, unknown>;
12
12
  resume: (sessionId: string, signal: AbortSignal, storage: AgentSessionStorage) => AsyncGenerator<string, void, unknown>;
13
13
  supportsResume: boolean;
14
+ supportsFollowUp: boolean;
14
15
  checkConnection: () => Promise<boolean>;
15
16
  undo: () => Promise<void>;
16
17
  };
@@ -1,6 +1,6 @@
1
- var ReactGrabClaudeCode=(function(exports){'use strict';var y=`http://localhost:${4567}`,A="react-grab:agent-sessions",E={systemPrompt:{type:"preset",preset:"claude_code",append:`You are helping a user make changes to a React component based on a selected element.
1
+ var ReactGrabClaudeCode=(function(exports){'use strict';var A=`http://localhost:${4567}`,y="react-grab:agent-sessions",h={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},h=r=>{let t="",o="";for(let e of r.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*C(r,t){let o=r.getReader(),e=new TextDecoder,s="",n=false,i=()=>{n=true,o.cancel().catch(()=>{});};t.addEventListener("abort",i);try{if(t.aborted)throw new DOMException("Aborted","AbortError");for(;;){let a=await o.read();if(n||t.aborted)throw new DOMException("Aborted","AbortError");let{done:p,value:u}=a;u&&(s+=e.decode(u,{stream:!0}));let c;for(;(c=s.indexOf(`
3
+ Provide clear, concise status updates as you work.`},model:"haiku",permissionMode:"bypassPermissions",maxTurns:10},E=s=>{let t="",o="";for(let n of s.split(`
4
+ `))n.startsWith("event:")?t=n.slice(6).trim():n.startsWith("data:")&&(o=n.slice(5).trim());return {eventType:t,data:o}};async function*b(s,t){let o=s.getReader(),n=new TextDecoder,r="",e=false,i=()=>{e=true,o.cancel().catch(()=>{});};t.addEventListener("abort",i);try{if(t.aborted)throw new DOMException("Aborted","AbortError");for(;;){let a=await o.read();if(e||t.aborted)throw new DOMException("Aborted","AbortError");let{done:p,value:u}=a;u&&(r+=n.decode(u,{stream:!0}));let c;for(;(c=r.indexOf(`
5
5
 
6
- `))!==-1;){let{eventType:d,data:l}=h(s.slice(0,c));if(s=s.slice(c+2),d==="done")return;if(d==="error")throw new Error(l||"Agent error");l&&(yield l);}if(p)break}}finally{t.removeEventListener("abort",i);try{o.releaseLock();}catch{}}}async function*g(r,t,o){let e=await fetch(`${r}/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*C(e.body,o);}var b=(r={})=>{let{serverUrl:t=y,getOptions:o}=r,e=null,s=n=>({...E,...o?.()??{},...n??{}});return {send:async function*(n,i){let a={...n,options:s(n.options)};yield*g(t,a,i);},resume:async function*(n,i,a){let p=a.getItem(A);if(!p)throw new Error("No sessions to resume");let c=JSON.parse(p)[n];if(!c)throw new Error(`Session ${n} not found`);let d=c.context,l={...d,options:s(d.options)};yield "Resuming...",yield*g(t,l,i);},supportsResume:true,checkConnection:async()=>{let n=Date.now();if(e&&n-e.timestamp<5e3)return e.result;try{let a=(await fetch(`${t}/health`,{method:"GET"})).ok;return e={result:a,timestamp:n},a}catch{return e={result:false,timestamp:n},false}},undo:async()=>{try{await fetch(`${t}/undo`,{method:"POST"});}catch{}}}},S=async()=>{if(typeof window>"u")return;let r=b(),t=window.__REACT_GRAB__;if(t){t.setAgent({provider:r,storage:sessionStorage});return}window.addEventListener("react-grab:init",o=>{o.detail.setAgent({provider:r,storage:sessionStorage});},{once:true});};S();exports.attachAgent=S;exports.createClaudeAgentProvider=b;return exports;})({});
6
+ `))!==-1;){let{eventType:d,data:l}=E(r.slice(0,c));if(r=r.slice(c+2),d==="done")return;if(d==="error")throw new Error(l||"Agent error");l&&(yield l);}if(p)break}}finally{t.removeEventListener("abort",i);try{o.releaseLock();}catch{}}}async function*m(s,t,o){let n=t.sessionId,r=()=>{n&&fetch(`${s}/abort/${n}`,{method:"POST"}).catch(()=>{});};o.addEventListener("abort",r);try{let e=await fetch(`${s}/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*b(e.body,o);}finally{o.removeEventListener("abort",r);}}var C=(s={})=>{let{serverUrl:t=A,getOptions:o}=s,n=null,r=e=>({...h,...o?.()??{},...e??{}});return {send:async function*(e,i){let a={...e,options:r(e.options)};yield*m(t,a,i);},resume:async function*(e,i,a){let p=a.getItem(y);if(!p)throw new Error("No sessions to resume");let c=JSON.parse(p)[e];if(!c)throw new Error(`Session ${e} not found`);let d=c.context,l={...d,options:r(d.options)};yield "Resuming...",yield*m(t,l,i);},supportsResume:true,supportsFollowUp:true,checkConnection:async()=>{let e=Date.now();if(n&&e-n.timestamp<5e3)return n.result;try{let a=(await fetch(`${t}/health`,{method:"GET"})).ok;return n={result:a,timestamp:e},a}catch{return n={result:false,timestamp:e},false}},undo:async()=>{try{await fetch(`${t}/undo`,{method:"POST"});}catch{}}}},w=async()=>{if(typeof window>"u")return;let s=C(),t=r=>{r.setAgent({provider:s,storage:sessionStorage});},o=window.__REACT_GRAB__;if(o){t(o);return}window.addEventListener("react-grab:init",r=>{t(r.detail);},{once:true});let n=window.__REACT_GRAB__;n&&t(n);};w();exports.attachAgent=w;exports.createClaudeAgentProvider=C;return exports;})({});