dsh-loop-engine 1.0.0-rc12 → 1.0.0-rc14

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/lib/index.js CHANGED
@@ -1347,6 +1347,11 @@ var ClaudeCodeLoop = class extends Service {
1347
1347
  const handle = await persistence.create(session.header, {
1348
1348
  inheritedEventCount: session.inheritedEventCount,
1349
1349
  ...signal === void 0 ? {} : { signal }
1350
+ }).catch((error) => {
1351
+ if (error instanceof TypeError && error.message.includes("SessionLogOffset")) {
1352
+ return persistence.create(session.header, session.inheritedEventCount);
1353
+ }
1354
+ throw error;
1350
1355
  });
1351
1356
  return { handle, storedCount: 0 };
1352
1357
  }
@@ -1395,26 +1400,38 @@ var ClaudeCodeLoop = class extends Service {
1395
1400
  let preparation;
1396
1401
  try {
1397
1402
  try {
1398
- handle = await raceAbortCall(
1399
- () => persistence.open(id, "write", { signal: fused }),
1400
- fused,
1401
- id,
1402
- (abandoned) => {
1403
- void abandoned.close();
1404
- }
1405
- );
1406
- const persisted = await handle.read(0, void 0, { signal: fused });
1407
- fused.throwIfAborted();
1408
- const closers = interruptedTurnClosers(persisted);
1409
- if (closers.length > 0) await handle.append(closers);
1410
- preparation = SessionPreparation.create(this.runtime.ctx.sessions.prepare(id, {
1411
- seed: [...persisted, ...closers],
1412
- meta: structuredClone(handle.header),
1413
- inheritedEventCount: handle.inheritedEventCount,
1414
- seedSource: "persistence"
1415
- }));
1416
- stored = { handle, storedCount: persisted.length + closers.length };
1417
- await this.appendUnstoredSuffix(stored, preparation.session);
1403
+ if (typeof persistence.open === "function") {
1404
+ handle = await raceAbortCall(
1405
+ () => persistence.open(id, "write", { signal: fused }),
1406
+ fused,
1407
+ id,
1408
+ (abandoned) => {
1409
+ void abandoned.close();
1410
+ }
1411
+ );
1412
+ const persisted = await handle.read(0, void 0, { signal: fused });
1413
+ fused.throwIfAborted();
1414
+ const closers = interruptedTurnClosers(persisted);
1415
+ if (closers.length > 0) await handle.append(closers);
1416
+ preparation = SessionPreparation.create(this.runtime.ctx.sessions.prepare(id, {
1417
+ seed: [...persisted, ...closers],
1418
+ meta: structuredClone(handle.header),
1419
+ inheritedEventCount: handle.inheritedEventCount,
1420
+ seedSource: "persistence"
1421
+ }));
1422
+ stored = { handle, storedCount: persisted.length + closers.length };
1423
+ await this.appendUnstoredSuffix(stored, preparation.session);
1424
+ } else {
1425
+ const publishedApi = persistence;
1426
+ preparation = await raceAbortCall(
1427
+ () => publishedApi.prepare(id, fused),
1428
+ fused,
1429
+ id,
1430
+ (abandoned) => {
1431
+ abandoned?.[Symbol.dispose]?.();
1432
+ }
1433
+ );
1434
+ }
1418
1435
  } finally {
1419
1436
  await unfollowOwner();
1420
1437
  }
@@ -1534,7 +1551,7 @@ var AppServerClient = class _AppServerClient {
1534
1551
  clientInfo: {
1535
1552
  name: "dsh-loop-engine",
1536
1553
  title: null,
1537
- version: "1.0.0-rc12"
1554
+ version: "1.0.0-rc13"
1538
1555
  },
1539
1556
  capabilities: { experimentalApi: true, requestAttestation: false }
1540
1557
  };
@@ -2573,6 +2590,11 @@ var CodexLoop = class extends Service2 {
2573
2590
  const handle = await persistence.create(session.header, {
2574
2591
  inheritedEventCount: session.inheritedEventCount,
2575
2592
  ...signal === void 0 ? {} : { signal }
2593
+ }).catch((error) => {
2594
+ if (error instanceof TypeError && error.message.includes("SessionLogOffset")) {
2595
+ return persistence.create(session.header, session.inheritedEventCount);
2596
+ }
2597
+ throw error;
2576
2598
  });
2577
2599
  return { handle, storedCount: 0 };
2578
2600
  }
@@ -2621,26 +2643,38 @@ var CodexLoop = class extends Service2 {
2621
2643
  let preparation;
2622
2644
  try {
2623
2645
  try {
2624
- handle = await raceAbortCall(
2625
- () => persistence.open(id, "write", { signal: fused }),
2626
- fused,
2627
- id,
2628
- (abandoned) => {
2629
- void abandoned.close();
2630
- }
2631
- );
2632
- const persisted = await handle.read(0, void 0, { signal: fused });
2633
- fused.throwIfAborted();
2634
- const closers = interruptedTurnClosers2(persisted);
2635
- if (closers.length > 0) await handle.append(closers);
2636
- preparation = SessionPreparation2.create(this.runtime.ctx.sessions.prepare(id, {
2637
- seed: [...persisted, ...closers],
2638
- meta: structuredClone(handle.header),
2639
- inheritedEventCount: handle.inheritedEventCount,
2640
- seedSource: "persistence"
2641
- }));
2642
- stored = { handle, storedCount: persisted.length + closers.length };
2643
- await this.appendUnstoredSuffix(stored, preparation.session);
2646
+ if (typeof persistence.open === "function") {
2647
+ handle = await raceAbortCall(
2648
+ () => persistence.open(id, "write", { signal: fused }),
2649
+ fused,
2650
+ id,
2651
+ (abandoned) => {
2652
+ void abandoned.close();
2653
+ }
2654
+ );
2655
+ const persisted = await handle.read(0, void 0, { signal: fused });
2656
+ fused.throwIfAborted();
2657
+ const closers = interruptedTurnClosers2(persisted);
2658
+ if (closers.length > 0) await handle.append(closers);
2659
+ preparation = SessionPreparation2.create(this.runtime.ctx.sessions.prepare(id, {
2660
+ seed: [...persisted, ...closers],
2661
+ meta: structuredClone(handle.header),
2662
+ inheritedEventCount: handle.inheritedEventCount,
2663
+ seedSource: "persistence"
2664
+ }));
2665
+ stored = { handle, storedCount: persisted.length + closers.length };
2666
+ await this.appendUnstoredSuffix(stored, preparation.session);
2667
+ } else {
2668
+ const publishedApi = persistence;
2669
+ preparation = await raceAbortCall(
2670
+ () => publishedApi.prepare(id, fused),
2671
+ fused,
2672
+ id,
2673
+ (abandoned) => {
2674
+ abandoned?.[Symbol.dispose]?.();
2675
+ }
2676
+ );
2677
+ }
2644
2678
  } finally {
2645
2679
  await unfollowOwner();
2646
2680
  }
@@ -3906,6 +3940,11 @@ var PiLoop = class extends Service3 {
3906
3940
  const handle = await persistence.create(session.header, {
3907
3941
  inheritedEventCount: session.inheritedEventCount,
3908
3942
  ...signal === void 0 ? {} : { signal }
3943
+ }).catch((error) => {
3944
+ if (error instanceof TypeError && error.message.includes("SessionLogOffset")) {
3945
+ return persistence.create(session.header, session.inheritedEventCount);
3946
+ }
3947
+ throw error;
3909
3948
  });
3910
3949
  return { handle, storedCount: 0 };
3911
3950
  }
@@ -3954,26 +3993,38 @@ var PiLoop = class extends Service3 {
3954
3993
  let preparation;
3955
3994
  try {
3956
3995
  try {
3957
- handle = await raceAbortCall(
3958
- () => persistence.open(id, "write", { signal: fused }),
3959
- fused,
3960
- id,
3961
- (abandoned) => {
3962
- void abandoned.close();
3963
- }
3964
- );
3965
- const persisted = await handle.read(0, void 0, { signal: fused });
3966
- fused.throwIfAborted();
3967
- const closers = interruptedTurnClosers3(persisted);
3968
- if (closers.length > 0) await handle.append(closers);
3969
- preparation = SessionPreparation3.create(this.runtime.ctx.sessions.prepare(id, {
3970
- seed: [...persisted, ...closers],
3971
- meta: structuredClone(handle.header),
3972
- inheritedEventCount: handle.inheritedEventCount,
3973
- seedSource: "persistence"
3974
- }));
3975
- stored = { handle, storedCount: persisted.length + closers.length };
3976
- await this.appendUnstoredSuffix(stored, preparation.session);
3996
+ if (typeof persistence.open === "function") {
3997
+ handle = await raceAbortCall(
3998
+ () => persistence.open(id, "write", { signal: fused }),
3999
+ fused,
4000
+ id,
4001
+ (abandoned) => {
4002
+ void abandoned.close();
4003
+ }
4004
+ );
4005
+ const persisted = await handle.read(0, void 0, { signal: fused });
4006
+ fused.throwIfAborted();
4007
+ const closers = interruptedTurnClosers3(persisted);
4008
+ if (closers.length > 0) await handle.append(closers);
4009
+ preparation = SessionPreparation3.create(this.runtime.ctx.sessions.prepare(id, {
4010
+ seed: [...persisted, ...closers],
4011
+ meta: structuredClone(handle.header),
4012
+ inheritedEventCount: handle.inheritedEventCount,
4013
+ seedSource: "persistence"
4014
+ }));
4015
+ stored = { handle, storedCount: persisted.length + closers.length };
4016
+ await this.appendUnstoredSuffix(stored, preparation.session);
4017
+ } else {
4018
+ const publishedApi = persistence;
4019
+ preparation = await raceAbortCall(
4020
+ () => publishedApi.prepare(id, fused),
4021
+ fused,
4022
+ id,
4023
+ (abandoned) => {
4024
+ abandoned?.[Symbol.dispose]?.();
4025
+ }
4026
+ );
4027
+ }
3977
4028
  } finally {
3978
4029
  await unfollowOwner();
3979
4030
  }
@@ -5020,6 +5071,11 @@ var KimiLoop = class extends Service4 {
5020
5071
  const handle = await persistence.create(session.header, {
5021
5072
  inheritedEventCount: session.inheritedEventCount,
5022
5073
  ...signal === void 0 ? {} : { signal }
5074
+ }).catch((error) => {
5075
+ if (error instanceof TypeError && error.message.includes("SessionLogOffset")) {
5076
+ return persistence.create(session.header, session.inheritedEventCount);
5077
+ }
5078
+ throw error;
5023
5079
  });
5024
5080
  return { handle, storedCount: 0 };
5025
5081
  }
@@ -5068,26 +5124,38 @@ var KimiLoop = class extends Service4 {
5068
5124
  let preparation;
5069
5125
  try {
5070
5126
  try {
5071
- handle = await raceAbortCall(
5072
- () => persistence.open(id, "write", { signal: fused }),
5073
- fused,
5074
- id,
5075
- (abandoned) => {
5076
- void abandoned.close();
5077
- }
5078
- );
5079
- const persisted = await handle.read(0, void 0, { signal: fused });
5080
- fused.throwIfAborted();
5081
- const closers = interruptedTurnClosers4(persisted);
5082
- if (closers.length > 0) await handle.append(closers);
5083
- preparation = SessionPreparation4.create(this.runtime.ctx.sessions.prepare(id, {
5084
- seed: [...persisted, ...closers],
5085
- meta: structuredClone(handle.header),
5086
- inheritedEventCount: handle.inheritedEventCount,
5087
- seedSource: "persistence"
5088
- }));
5089
- stored = { handle, storedCount: persisted.length + closers.length };
5090
- await this.appendUnstoredSuffix(stored, preparation.session);
5127
+ if (typeof persistence.open === "function") {
5128
+ handle = await raceAbortCall(
5129
+ () => persistence.open(id, "write", { signal: fused }),
5130
+ fused,
5131
+ id,
5132
+ (abandoned) => {
5133
+ void abandoned.close();
5134
+ }
5135
+ );
5136
+ const persisted = await handle.read(0, void 0, { signal: fused });
5137
+ fused.throwIfAborted();
5138
+ const closers = interruptedTurnClosers4(persisted);
5139
+ if (closers.length > 0) await handle.append(closers);
5140
+ preparation = SessionPreparation4.create(this.runtime.ctx.sessions.prepare(id, {
5141
+ seed: [...persisted, ...closers],
5142
+ meta: structuredClone(handle.header),
5143
+ inheritedEventCount: handle.inheritedEventCount,
5144
+ seedSource: "persistence"
5145
+ }));
5146
+ stored = { handle, storedCount: persisted.length + closers.length };
5147
+ await this.appendUnstoredSuffix(stored, preparation.session);
5148
+ } else {
5149
+ const publishedApi = persistence;
5150
+ preparation = await raceAbortCall(
5151
+ () => publishedApi.prepare(id, fused),
5152
+ fused,
5153
+ id,
5154
+ (abandoned) => {
5155
+ abandoned?.[Symbol.dispose]?.();
5156
+ }
5157
+ );
5158
+ }
5091
5159
  } finally {
5092
5160
  await unfollowOwner();
5093
5161
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-loop-engine",
3
3
  "description": "Web-switchable agent loop engine selection for the DeepSeek Harness - out-of-tree plugin (Claude Code / Codex / Pi / Kimi Code drivers) maintained by @kuun993, zero main-repo changes",
4
- "version": "1.0.0-rc12",
4
+ "version": "1.0.0-rc14",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -52,6 +52,7 @@
52
52
  "platform": "web",
53
53
  "external": [
54
54
  "@deepseek-ai/dsh-client-locale/client",
55
+ "@deepseek-ai/dsh-client-store",
55
56
  "@deepseek-ai/dsh-client-ui-settings/client",
56
57
  "@deepseek-ai/dsh-api-remotes/client",
57
58
  "@deepseek-ai/dsh-settings/types"