opensteer 0.4.13 → 0.4.14
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 +5 -0
- package/bin/opensteer.mjs +42 -6
- package/dist/{chunk-QTGJO7RC.js → chunk-QHZFY3ZK.js} +9 -0
- package/dist/{chunk-V4OOJO4S.js → chunk-SPHS6YWD.js} +1 -1
- package/dist/{chunk-JSH3VLMH.js → chunk-WXUXG76V.js} +404 -47
- package/dist/{chunk-UIUDSWZV.js → chunk-YIQDOALV.js} +1 -1
- package/dist/cli/server.cjs +497 -67
- package/dist/cli/server.js +90 -24
- package/dist/{extractor-I6TJPTXV.js → extractor-CZFCFUME.js} +2 -2
- package/dist/index.cjs +410 -45
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +4 -4
- package/dist/{resolver-HVZJQZ32.js → resolver-ZREUOOTV.js} +2 -2
- package/package.json +3 -3
package/dist/cli/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Opensteer
|
|
3
|
-
|
|
2
|
+
Opensteer,
|
|
3
|
+
normalizeError
|
|
4
|
+
} from "../chunk-WXUXG76V.js";
|
|
4
5
|
import "../chunk-3H5RRIMZ.js";
|
|
5
6
|
|
|
6
7
|
// src/cli/server.ts
|
|
@@ -321,7 +322,16 @@ function enqueueRequest(request, socket) {
|
|
|
321
322
|
void handleRequest(request, socket);
|
|
322
323
|
return;
|
|
323
324
|
}
|
|
324
|
-
requestQueue = requestQueue.then(() => handleRequest(request, socket)).catch(() => {
|
|
325
|
+
requestQueue = requestQueue.then(() => handleRequest(request, socket)).catch((error) => {
|
|
326
|
+
sendResponse(
|
|
327
|
+
socket,
|
|
328
|
+
buildErrorResponse(
|
|
329
|
+
request.id,
|
|
330
|
+
error,
|
|
331
|
+
"Unexpected server error while handling request.",
|
|
332
|
+
"CLI_INTERNAL_ERROR"
|
|
333
|
+
)
|
|
334
|
+
);
|
|
325
335
|
});
|
|
326
336
|
}
|
|
327
337
|
async function handleRequest(request, socket) {
|
|
@@ -330,7 +340,11 @@ async function handleRequest(request, socket) {
|
|
|
330
340
|
sendResponse(socket, {
|
|
331
341
|
id,
|
|
332
342
|
ok: false,
|
|
333
|
-
error: `Session '${session}' is shutting down
|
|
343
|
+
error: `Session '${session}' is shutting down.`,
|
|
344
|
+
errorInfo: {
|
|
345
|
+
message: `Session '${session}' is shutting down.`,
|
|
346
|
+
code: "SESSION_SHUTTING_DOWN"
|
|
347
|
+
}
|
|
334
348
|
});
|
|
335
349
|
return;
|
|
336
350
|
}
|
|
@@ -338,7 +352,11 @@ async function handleRequest(request, socket) {
|
|
|
338
352
|
sendResponse(socket, {
|
|
339
353
|
id,
|
|
340
354
|
ok: false,
|
|
341
|
-
error: `Session '${session}' is shutting down. Retry your command
|
|
355
|
+
error: `Session '${session}' is shutting down. Retry your command.`,
|
|
356
|
+
errorInfo: {
|
|
357
|
+
message: `Session '${session}' is shutting down. Retry your command.`,
|
|
358
|
+
code: "SESSION_SHUTTING_DOWN"
|
|
359
|
+
}
|
|
342
360
|
});
|
|
343
361
|
return;
|
|
344
362
|
}
|
|
@@ -354,7 +372,16 @@ async function handleRequest(request, socket) {
|
|
|
354
372
|
sendResponse(socket, {
|
|
355
373
|
id,
|
|
356
374
|
ok: false,
|
|
357
|
-
error: `Session '${session}' is already bound to selector namespace '${selectorNamespace}'. Requested '${requestedName}' does not match. Use the same --name for this session or start a different --session
|
|
375
|
+
error: `Session '${session}' is already bound to selector namespace '${selectorNamespace}'. Requested '${requestedName}' does not match. Use the same --name for this session or start a different --session.`,
|
|
376
|
+
errorInfo: {
|
|
377
|
+
message: `Session '${session}' is already bound to selector namespace '${selectorNamespace}'. Requested '${requestedName}' does not match. Use the same --name for this session or start a different --session.`,
|
|
378
|
+
code: "SESSION_NAMESPACE_MISMATCH",
|
|
379
|
+
details: {
|
|
380
|
+
session,
|
|
381
|
+
activeNamespace: selectorNamespace,
|
|
382
|
+
requestedNamespace: requestedName
|
|
383
|
+
}
|
|
384
|
+
}
|
|
358
385
|
});
|
|
359
386
|
return;
|
|
360
387
|
}
|
|
@@ -412,11 +439,10 @@ async function handleRequest(request, socket) {
|
|
|
412
439
|
}
|
|
413
440
|
});
|
|
414
441
|
} catch (err) {
|
|
415
|
-
sendResponse(
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
});
|
|
442
|
+
sendResponse(
|
|
443
|
+
socket,
|
|
444
|
+
buildErrorResponse(id, err, "Failed to open browser session.")
|
|
445
|
+
);
|
|
420
446
|
}
|
|
421
447
|
return;
|
|
422
448
|
}
|
|
@@ -432,11 +458,10 @@ async function handleRequest(request, socket) {
|
|
|
432
458
|
result: { sessionClosed: true }
|
|
433
459
|
});
|
|
434
460
|
} catch (err) {
|
|
435
|
-
sendResponse(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
});
|
|
461
|
+
sendResponse(
|
|
462
|
+
socket,
|
|
463
|
+
buildErrorResponse(id, err, "Failed to close browser session.")
|
|
464
|
+
);
|
|
440
465
|
}
|
|
441
466
|
beginShutdown();
|
|
442
467
|
return;
|
|
@@ -449,7 +474,14 @@ async function handleRequest(request, socket) {
|
|
|
449
474
|
sendResponse(socket, {
|
|
450
475
|
id,
|
|
451
476
|
ok: false,
|
|
452
|
-
error: `No browser session in session '${session}'. Call 'opensteer open --session ${session}' first, or use 'opensteer sessions' to list active sessions
|
|
477
|
+
error: `No browser session in session '${session}'. Call 'opensteer open --session ${session}' first, or use 'opensteer sessions' to list active sessions.`,
|
|
478
|
+
errorInfo: {
|
|
479
|
+
message: `No browser session in session '${session}'. Call 'opensteer open --session ${session}' first, or use 'opensteer sessions' to list active sessions.`,
|
|
480
|
+
code: "SESSION_NOT_OPEN",
|
|
481
|
+
details: {
|
|
482
|
+
session
|
|
483
|
+
}
|
|
484
|
+
}
|
|
453
485
|
});
|
|
454
486
|
return;
|
|
455
487
|
}
|
|
@@ -458,7 +490,14 @@ async function handleRequest(request, socket) {
|
|
|
458
490
|
sendResponse(socket, {
|
|
459
491
|
id,
|
|
460
492
|
ok: false,
|
|
461
|
-
error: `Unknown command: ${command}
|
|
493
|
+
error: `Unknown command: ${command}`,
|
|
494
|
+
errorInfo: {
|
|
495
|
+
message: `Unknown command: ${command}`,
|
|
496
|
+
code: "UNKNOWN_COMMAND",
|
|
497
|
+
details: {
|
|
498
|
+
command
|
|
499
|
+
}
|
|
500
|
+
}
|
|
462
501
|
});
|
|
463
502
|
return;
|
|
464
503
|
}
|
|
@@ -466,11 +505,12 @@ async function handleRequest(request, socket) {
|
|
|
466
505
|
const result = await handler(instance, args);
|
|
467
506
|
sendResponse(socket, { id, ok: true, result });
|
|
468
507
|
} catch (err) {
|
|
469
|
-
sendResponse(
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
508
|
+
sendResponse(
|
|
509
|
+
socket,
|
|
510
|
+
buildErrorResponse(id, err, `Command "${command}" failed.`, void 0, {
|
|
511
|
+
command
|
|
512
|
+
})
|
|
513
|
+
);
|
|
474
514
|
}
|
|
475
515
|
}
|
|
476
516
|
if (existsSync(socketPath)) {
|
|
@@ -491,7 +531,11 @@ var server = createServer((socket) => {
|
|
|
491
531
|
sendResponse(socket, {
|
|
492
532
|
id: 0,
|
|
493
533
|
ok: false,
|
|
494
|
-
error: "Invalid JSON request"
|
|
534
|
+
error: "Invalid JSON request",
|
|
535
|
+
errorInfo: {
|
|
536
|
+
message: "Invalid JSON request",
|
|
537
|
+
code: "INVALID_JSON_REQUEST"
|
|
538
|
+
}
|
|
495
539
|
});
|
|
496
540
|
}
|
|
497
541
|
}
|
|
@@ -530,3 +574,25 @@ async function shutdown() {
|
|
|
530
574
|
}
|
|
531
575
|
process.on("SIGTERM", shutdown);
|
|
532
576
|
process.on("SIGINT", shutdown);
|
|
577
|
+
function buildErrorResponse(id, error, fallbackMessage, fallbackCode, details) {
|
|
578
|
+
const normalized = normalizeError(error, fallbackMessage);
|
|
579
|
+
let mergedDetails;
|
|
580
|
+
if (normalized.details || details) {
|
|
581
|
+
mergedDetails = {
|
|
582
|
+
...normalized.details || {},
|
|
583
|
+
...details || {}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
id,
|
|
588
|
+
ok: false,
|
|
589
|
+
error: normalized.message,
|
|
590
|
+
errorInfo: {
|
|
591
|
+
message: normalized.message,
|
|
592
|
+
...normalized.code || fallbackCode ? { code: normalized.code || fallbackCode } : {},
|
|
593
|
+
...normalized.name ? { name: normalized.name } : {},
|
|
594
|
+
...mergedDetails ? { details: mergedDetails } : {},
|
|
595
|
+
...normalized.cause ? { cause: normalized.cause } : {}
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|