lody 0.46.2-next.1 → 0.46.3-next.1

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 +30 -66
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -36820,7 +36820,7 @@ Mongoose Error Code: ${error2.code}` : ""}`
36820
36820
  return client;
36821
36821
  }
36822
36822
  const name = "lody";
36823
- const version$4 = "0.46.2-next.1";
36823
+ const version$4 = "0.46.3-next.1";
36824
36824
  const description = "Lody Agent CLI tool for managing remote command execution";
36825
36825
  const type = "module";
36826
36826
  const main$3 = "dist/index.js";
@@ -82846,7 +82846,6 @@ ${tailedOutput}` : null;
82846
82846
  const LODY_PRESENCE_CHANNEL = "presence";
82847
82847
  const LODY_PRESENCE_TTL_MS = 6e4;
82848
82848
  const LODY_PRESENCE_HEARTBEAT_MS = 2e4;
82849
- const LODY_PRESENCE_STREAM_HEARTBEAT_MS = 15e3;
82850
82849
  const ActiveSessionStatusSchema = discriminatedUnion("type", [
82851
82850
  object({
82852
82851
  type: literal("running")
@@ -93097,7 +93096,6 @@ stream:${scope2.streamId}`;
93097
93096
  adaptor;
93098
93097
  client;
93099
93098
  reconnectConfig;
93100
- heartbeatMs;
93101
93099
  debug;
93102
93100
  joinState;
93103
93101
  constructor(options) {
@@ -93107,7 +93105,6 @@ stream:${scope2.streamId}`;
93107
93105
  ...DEFAULT_RECONNECT_CONFIG,
93108
93106
  ...options.reconnectConfig
93109
93107
  };
93110
- this.heartbeatMs = options.heartbeatMs ?? 15e3;
93111
93108
  this.debug = options.debug ?? false;
93112
93109
  this.client = new StreamsTransportClient({
93113
93110
  streamUrl: options.streamUrl,
@@ -93188,18 +93185,15 @@ stream:${scope2.streamId}`;
93188
93185
  };
93189
93186
  }
93190
93187
  async startJoin(state2) {
93188
+ state2.unsubscribeLocal = this.adaptor.subscribeLocalUpdates((update2) => {
93189
+ this.enqueueLocal(state2, normalizeEphemeralUpdate(update2));
93190
+ });
93191
93191
  state2.requestController = new AbortController();
93192
93192
  const firstOpen = this.waitForFirstOpen(state2);
93193
93193
  this.runReadLoop(state2);
93194
93194
  await firstOpen;
93195
93195
  if (state2.closed) return;
93196
- state2.unsubscribeLocal = this.adaptor.subscribeLocalUpdates((update2) => {
93197
- this.enqueueLocal(state2, normalizeEphemeralUpdate(update2));
93198
- });
93199
93196
  this.setWriteStatus(state2, "ok");
93200
- const fullState = normalizeEphemeralUpdate(await this.adaptor.encodeAll());
93201
- if (fullState != null) state2.pendingLocal.pushBack(fullState);
93202
- this.startHeartbeat(state2);
93203
93197
  await this.flushPendingLocal(state2);
93204
93198
  if (state2.status === "error" || state2.status === "disconnected") throw new Error(`ephemeral stream failed to join: ${state2.status}`);
93205
93199
  }
@@ -93257,7 +93251,6 @@ stream:${scope2.streamId}`;
93257
93251
  if (state2.closed) return;
93258
93252
  state2.closed = true;
93259
93253
  state2.unsubscribeLocal?.();
93260
- if (state2.heartbeatTimer != null) clearInterval(state2.heartbeatTimer);
93261
93254
  state2.requestController?.abort();
93262
93255
  state2.retrySleepController.abort();
93263
93256
  this.rejectFirstOpen(state2, closedSubscriptionError());
@@ -93285,7 +93278,6 @@ stream:${scope2.streamId}`;
93285
93278
  ]);
93286
93279
  this.setReadStatus(state2, "ok");
93287
93280
  this.resolveFirstOpen(state2);
93288
- if (state2.unsubscribeLocal != null) this.enqueueFullState(state2);
93289
93281
  }, async (update2) => {
93290
93282
  if (update2.byteLength > 0) await this.adaptor.applyRemoteUpdates([
93291
93283
  update2
@@ -93333,27 +93325,10 @@ stream:${scope2.streamId}`;
93333
93325
  }
93334
93326
  }
93335
93327
  }
93336
- startHeartbeat(state2) {
93337
- if (this.heartbeatMs === false || this.heartbeatMs <= 0) return;
93338
- state2.heartbeatTimer = setInterval(() => {
93339
- this.enqueueFullState(state2);
93340
- }, this.heartbeatMs);
93341
- }
93342
- async enqueueFullState(state2) {
93343
- try {
93344
- const update2 = await this.adaptor.encodeAll();
93345
- this.enqueueLocal(state2, normalizeEphemeralUpdate(update2));
93346
- } catch (error2) {
93347
- this.logError("ephemeral encodeAll failed", error2, {
93348
- streamUrl: this.streamUrl
93349
- });
93350
- this.setWriteStatus(state2, "error");
93351
- }
93352
- }
93353
93328
  enqueueLocal(state2, update2) {
93354
93329
  if (state2.closed || update2 == null || update2.byteLength === 0) return;
93355
93330
  state2.pendingLocal.pushBack(update2);
93356
- this.flushPendingLocal(state2);
93331
+ if (state2.writeStatus !== "connecting") this.flushPendingLocal(state2);
93357
93332
  }
93358
93333
  async flushPendingLocal(state2) {
93359
93334
  if (state2.flushingLocal || state2.closed) return;
@@ -94962,12 +94937,25 @@ stream:${scope2.streamId}`;
94962
94937
  };
94963
94938
  }
94964
94939
  function EphemeralStoreAdaptor(store) {
94940
+ let applyingRemoteDepth = 0;
94965
94941
  return {
94966
- encodeAll: () => store.encodeAll(),
94967
94942
  applyRemoteUpdates: (updates) => {
94968
- for (const update2 of updates) store.apply(update2);
94943
+ applyingRemoteDepth += 1;
94944
+ try {
94945
+ for (const update2 of updates) store.apply(update2);
94946
+ } finally {
94947
+ applyingRemoteDepth -= 1;
94948
+ }
94969
94949
  },
94970
- subscribeLocalUpdates: (listener) => store.subscribeLocalUpdates(listener)
94950
+ subscribeLocalUpdates: (listener) => {
94951
+ const unsubscribeLocalUpdates = store.subscribeLocalUpdates((update2) => {
94952
+ if (applyingRemoteDepth > 0) return;
94953
+ listener(update2);
94954
+ });
94955
+ return () => {
94956
+ unsubscribeLocalUpdates();
94957
+ };
94958
+ }
94971
94959
  };
94972
94960
  }
94973
94961
  function isAfter(entry2, current2) {
@@ -95862,8 +95850,7 @@ stream:${scope2.streamId}`;
95862
95850
  this.transport = new EphemeralStreamCrdt({
95863
95851
  streamUrl: toLodyPresenceStreamUrl(durableStreamUrl),
95864
95852
  auth: options.auth,
95865
- adaptor: EphemeralStoreAdaptor(this.store),
95866
- heartbeatMs: LODY_PRESENCE_STREAM_HEARTBEAT_MS
95853
+ adaptor: EphemeralStoreAdaptor(this.store)
95867
95854
  });
95868
95855
  this.machineTimer = setInterval(() => {
95869
95856
  this.writeMachineHeartbeat();
@@ -133609,37 +133596,14 @@ export PATH=${toSingleQuotedShellString(ghShimBinDir)}:"$PATH"
133609
133596
  args: callbacks.args ?? [],
133610
133597
  getStderrTail: () => stderrTail
133611
133598
  });
133612
- agentProcess.stdin?.on("error", (err2) => {
133613
- if (err2.code !== "EPIPE") {
133614
- this.logger.error(`[${this.sessionId}] Agent stdin error: ${err2.message}`);
133615
- }
133616
- });
133617
- const input2 = new WritableStream({
133618
- write(chunk) {
133619
- if (agentProcess.stdin && !agentProcess.stdin.destroyed) {
133620
- agentProcess.stdin.write(chunk);
133621
- }
133622
- },
133623
- close() {
133624
- if (agentProcess.stdin && !agentProcess.stdin.destroyed) {
133625
- agentProcess.stdin.end();
133626
- }
133627
- }
133628
- });
133629
- const output = new ReadableStream({
133630
- start(controller) {
133631
- if (!agentProcess.stdout) {
133632
- controller.error(new Error("Agent process stdout is not available"));
133633
- return;
133634
- }
133635
- agentProcess.stdout.on("data", (chunk) => {
133636
- controller.enqueue(chunk);
133637
- });
133638
- agentProcess.stdout.on("end", () => {
133639
- controller.close();
133640
- });
133641
- }
133642
- });
133599
+ if (!agentProcess.stdin) {
133600
+ throw new Error("Agent process stdin is not available");
133601
+ }
133602
+ if (!agentProcess.stdout) {
133603
+ throw new Error("Agent process stdout is not available");
133604
+ }
133605
+ const input2 = createStdinWritableStream(agentProcess.stdin);
133606
+ const output = createStdoutReadableStream(agentProcess.stdout);
133643
133607
  const stream2 = ndJsonStream(input2, output);
133644
133608
  this.logger.debug(`[${this.sessionId}] ndJsonStream created, calling createAcpClient`);
133645
133609
  const { client, acpSessionId } = await createAcpClient({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lody",
3
- "version": "0.46.2-next.1",
3
+ "version": "0.46.3-next.1",
4
4
  "description": "Lody Agent CLI tool for managing remote command execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "@better-auth/api-key": "1.5.5",
29
29
  "@convex-dev/better-auth": "0.11.2",
30
30
  "@loro-dev/flock-wasm": "^0.2.1",
31
- "@loro-dev/streams-crdt": "0.8.0",
31
+ "@loro-dev/streams-crdt": "0.8.1",
32
32
  "@sentry/node": "^10.29.0",
33
33
  "@types/cross-spawn": "^6.0.6",
34
34
  "@types/iconv-lite": "^0.0.1",
@@ -72,8 +72,8 @@
72
72
  "winston-transport": "^4.7.1",
73
73
  "ws": "^8.18.3",
74
74
  "zod": "^4.1.5",
75
- "@lody/convex": "0.0.1",
76
75
  "@lody/cli-supervisor": "0.0.1",
76
+ "@lody/convex": "0.0.1",
77
77
  "@lody/loro-streams-rpc": "0.0.1",
78
78
  "@lody/shared": "0.0.1",
79
79
  "loro-code": "0.0.1"