@nextclaw/remote 0.1.23 → 0.1.25

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -64
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -437,30 +437,11 @@ function parseRemoteSseFrame(frame) {
437
437
  return { event, payload: data };
438
438
  }
439
439
  }
440
- function readRemoteStreamError(payload, fallback) {
441
- if (typeof payload === "object" && payload && "error" in payload) {
442
- const typed = payload;
443
- if (typed.error?.message) {
444
- return typed.error.message;
445
- }
446
- }
447
- if (typeof payload === "string" && payload.trim()) {
448
- return payload.trim();
449
- }
450
- return fallback;
451
- }
452
440
  function processRemoteStreamFrame(params) {
453
441
  const frame = parseRemoteSseFrame(params.rawFrame);
454
442
  if (!frame) {
455
443
  return;
456
444
  }
457
- if (frame.event === "final") {
458
- params.setFinalResult(frame.payload);
459
- return;
460
- }
461
- if (frame.event === "error") {
462
- throw new Error(readRemoteStreamError(frame.payload, "stream failed"));
463
- }
464
445
  params.onEvent(frame);
465
446
  }
466
447
  function flushRemoteStreamFrames(params) {
@@ -468,8 +449,7 @@ function flushRemoteStreamFrames(params) {
468
449
  while (boundary !== -1) {
469
450
  processRemoteStreamFrame({
470
451
  rawFrame: params.bufferState.value.slice(0, boundary),
471
- onEvent: params.onEvent,
472
- setFinalResult: params.setFinalResult
452
+ onEvent: params.onEvent
473
453
  });
474
454
  params.bufferState.value = params.bufferState.value.slice(boundary + 2);
475
455
  boundary = params.bufferState.value.indexOf("\n\n");
@@ -482,7 +462,6 @@ async function readRemoteAppStreamResult(params) {
482
462
  }
483
463
  const decoder = new TextDecoder();
484
464
  const bufferState = { value: "" };
485
- let finalResult = void 0;
486
465
  try {
487
466
  while (true) {
488
467
  const { value, done } = await reader.read();
@@ -492,28 +471,18 @@ async function readRemoteAppStreamResult(params) {
492
471
  bufferState.value += decoder.decode(value, { stream: true });
493
472
  flushRemoteStreamFrames({
494
473
  bufferState,
495
- onEvent: params.onEvent,
496
- setFinalResult: (nextValue) => {
497
- finalResult = nextValue;
498
- }
474
+ onEvent: params.onEvent
499
475
  });
500
476
  }
501
477
  if (bufferState.value.trim()) {
502
478
  processRemoteStreamFrame({
503
479
  rawFrame: bufferState.value,
504
- onEvent: params.onEvent,
505
- setFinalResult: (nextValue) => {
506
- finalResult = nextValue;
507
- }
480
+ onEvent: params.onEvent
508
481
  });
509
482
  }
510
483
  } finally {
511
484
  reader.releaseLock();
512
485
  }
513
- if (finalResult === void 0) {
514
- throw new Error("stream ended without final event");
515
- }
516
- return finalResult;
517
486
  }
518
487
 
519
488
  // src/remote-app.adapter.ts
@@ -604,7 +573,7 @@ var RemoteAppAdapter = class {
604
573
  if (!response) {
605
574
  return;
606
575
  }
607
- const finalResult = await readRemoteAppStreamResult({
576
+ await readRemoteAppStreamResult({
608
577
  response,
609
578
  onEvent: (event) => {
610
579
  this.send({
@@ -619,8 +588,7 @@ var RemoteAppAdapter = class {
619
588
  this.send({
620
589
  type: "client.stream.end",
621
590
  clientId: frame.clientId,
622
- streamId: frame.streamId,
623
- result: finalResult
591
+ streamId: frame.streamId
624
592
  });
625
593
  } catch (error) {
626
594
  if (controller.signal.aborted) {
@@ -739,19 +707,6 @@ var RemoteAppAdapter = class {
739
707
  }
740
708
  };
741
709
 
742
- // src/remote-connector-error.ts
743
- var TERMINAL_REMOTE_ERROR_PATTERNS = [
744
- /invalid or expired token/i,
745
- /missing bearer token/i,
746
- /token expired/i,
747
- /token is invalid/i,
748
- /run "nextclaw login"/i
749
- ];
750
- function isTerminalRemoteConnectorError(error) {
751
- const message = error instanceof Error ? error.message : String(error);
752
- return TERMINAL_REMOTE_ERROR_PATTERNS.some((pattern) => pattern.test(message));
753
- }
754
-
755
710
  // src/remote-connector.ts
756
711
  var RemoteConnector = class {
757
712
  constructor(deps) {
@@ -947,7 +902,7 @@ var RemoteConnector = class {
947
902
  lastError: null
948
903
  });
949
904
  }
950
- return { device, outcome: outcome === "aborted" ? "aborted" : "retry" };
905
+ return { device, aborted: outcome === "aborted" };
951
906
  } catch (error) {
952
907
  const message = error instanceof Error ? error.message : String(error);
953
908
  this.writeRemoteState(params.opts.statusStore, {
@@ -960,10 +915,7 @@ var RemoteConnector = class {
960
915
  lastError: message
961
916
  });
962
917
  this.logger.error(`Remote connector error: ${message}`);
963
- return {
964
- device: params.device,
965
- outcome: isTerminalRemoteConnectorError(error) ? "stop" : "retry"
966
- };
918
+ return { device: params.device, aborted: false };
967
919
  }
968
920
  }
969
921
  async run(opts = {}) {
@@ -973,15 +925,10 @@ var RemoteConnector = class {
973
925
  );
974
926
  await relayBridge.ensureLocalUiHealthy();
975
927
  let device = null;
976
- let preserveRuntimeError = false;
977
928
  while (!opts.signal?.aborted) {
978
929
  const cycle = await this.runCycle({ device, context, relayBridge, opts });
979
930
  device = cycle.device;
980
- if (cycle.outcome === "stop") {
981
- preserveRuntimeError = true;
982
- break;
983
- }
984
- if (cycle.outcome === "aborted" || !context.autoReconnect || opts.signal?.aborted) {
931
+ if (cycle.aborted || !context.autoReconnect || opts.signal?.aborted) {
985
932
  break;
986
933
  }
987
934
  this.logger.warn("Remote connector disconnected. Reconnecting in 3s...");
@@ -991,9 +938,6 @@ var RemoteConnector = class {
991
938
  break;
992
939
  }
993
940
  }
994
- if (preserveRuntimeError) {
995
- return;
996
- }
997
941
  this.writeRemoteState(opts.statusStore, {
998
942
  enabled: opts.mode === "service" ? true : Boolean(context.config.remote.enabled),
999
943
  state: opts.signal?.aborted ? "disconnected" : "disabled",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/remote",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "private": false,
5
5
  "description": "Remote access runtime for NextClaw device registration, relay bridging, and service-managed connectivity.",
6
6
  "type": "module",
@@ -30,8 +30,8 @@
30
30
  "dependencies": {
31
31
  "commander": "^12.1.0",
32
32
  "ws": "^8.18.0",
33
- "@nextclaw/server": "0.10.27",
34
- "@nextclaw/core": "0.9.10"
33
+ "@nextclaw/core": "0.9.11",
34
+ "@nextclaw/server": "0.10.31"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^20.17.6",