@rivus/agent 0.14.1 → 0.14.2

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/chunks/src.js +11 -1
  2. package/package.json +1 -1
@@ -1108,7 +1108,7 @@ function decodeInboundDeliverySnapshots(raw, options) {
1108
1108
  if (delivery.revision !== (previous?.revision ?? 0) + 1) throw new Error(`invalid ${options.label} revision at line ${index + 1}`);
1109
1109
  try {
1110
1110
  if (previous) {
1111
- if (!isValidInboundDeliveryTransition(previous, delivery)) throw new Error("transition");
1111
+ if (!isValidPersistedTransition(previous, delivery, options.acceptLegacySameAttemptClaims ?? false)) throw new Error("transition");
1112
1112
  } else validateNewInboundDelivery(delivery);
1113
1113
  } catch {
1114
1114
  throw new Error(`invalid ${options.label} transition at line ${index + 1}`);
@@ -1153,6 +1153,14 @@ function decodeDelivery(value, payloadCodec) {
1153
1153
  function isEnvelope(value) {
1154
1154
  return isRecord$5(value) && value.version === 1 && "delivery" in value;
1155
1155
  }
1156
+ function isValidPersistedTransition(previous, next, acceptLegacySameAttemptClaims) {
1157
+ if (isValidInboundDeliveryTransition(previous, next)) return true;
1158
+ if (!acceptLegacySameAttemptClaims || previous.state.status !== "pending" || next.state.status !== "leased" || next.attempts !== previous.attempts) return false;
1159
+ return isValidInboundDeliveryTransition(previous, {
1160
+ ...next,
1161
+ attempts: next.attempts + 1
1162
+ });
1163
+ }
1156
1164
  //#endregion
1157
1165
  //#region src/modules/inbound-delivery/infrastructure/persistence/delivery/jsonl-inbound-delivery-repository.ts
1158
1166
  function openJsonlInboundDeliveryRepository(options) {
@@ -1160,6 +1168,7 @@ function openJsonlInboundDeliveryRepository(options) {
1160
1168
  catch: (error) => error,
1161
1169
  try: () => readPersistenceFile(options.filePath)
1162
1170
  }).pipe(Effect.map((raw) => decodeInboundDeliverySnapshots(raw, {
1171
+ ...options.acceptLegacySameAttemptClaims === void 0 ? {} : { acceptLegacySameAttemptClaims: options.acceptLegacySameAttemptClaims },
1163
1172
  label: options.label ?? "Inbound Delivery",
1164
1173
  payload: options.payload
1165
1174
  })), Effect.map((initial) => createInMemoryInboundDeliveryRepository({
@@ -1588,6 +1597,7 @@ function nonEmpty$1(value) {
1588
1597
  //#region src/adapters/compatibility/inbound-delivery/jsonl-feishu-inbox-repository.ts
1589
1598
  function openJsonlFeishuInboxRepository(options) {
1590
1599
  return Effect.runPromise(openJsonlInboundDeliveryRepository({
1600
+ acceptLegacySameAttemptClaims: true,
1591
1601
  filePath: options.filePath,
1592
1602
  label: "Feishu inbox",
1593
1603
  payload: feishuInboundDeliveryPayloadCodec
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivus/agent",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "A local agent daemon core built around a usable agent harness and domain events.",
5
5
  "type": "module",
6
6
  "license": "MIT",