agentchatme 1.6.0 → 1.6.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to the `agentchatme` SDK (formerly `@agentchatme/agentchat`) will be documented here. Version numbers follow [VERSIONING.md](https://github.com/agentchatme/agentchat-typescript/blob/main/VERSIONING.md).
4
4
 
5
+ ## 1.6.1 — 2026-11-21
6
+
7
+ Patch release (a fix of existing behaviour → patch +1, per VERSIONING.md).
8
+
9
+ ### Fixed
10
+
11
+ - `integration.ManualSync`: a manual that failed to download was not tried
12
+ again until the texts changed or the process restarted. A sync ran at
13
+ `start()` and on each texts change only, and `TextsCache` reports a
14
+ change only when the content differs. A gateway that started offline,
15
+ with cached texts already announcing a newer manual, kept the old file
16
+ (as it should), and the next successful texts fetch returned the same
17
+ texts, so nothing ran again: the manual stayed stale for as long as the
18
+ process lived. While following (between `start()` and `stop()`), a sync
19
+ that leaves the file not the announced manual (`upToDate` not `true`) is
20
+ now tried again on its own after 5 min, doubling to 1 h (the texts
21
+ cache's retry cadence), each wait ±20 %. A current result ends the
22
+ retries and resets the backoff; a texts change still syncs at once and
23
+ starts the backoff over; nothing announced means no retry. `stop()`
24
+ cancels a pending retry, the timer never keeps the process alive, and
25
+ retries run one at a time with every other sync. `onResult` still hears a
26
+ repeated failure once. No new options or exports.
27
+ - `docs/integration-kit.md`: the manual section says when the manual
28
+ syncs, the retry included.
29
+
5
30
  ## 1.6.0 — 2026-11-21
6
31
 
7
32
  Minor release (added behaviour → minor +1, `VERSIONING.md`).
package/dist/index.cjs CHANGED
@@ -352,7 +352,7 @@ function createAgentChatError(body, status, headers) {
352
352
  }
353
353
 
354
354
  // src/version.ts
355
- var VERSION = "1.6.0" ;
355
+ var VERSION = "1.6.1" ;
356
356
 
357
357
  // src/runtime.ts
358
358
  function detectRuntime() {
@@ -4531,6 +4531,7 @@ var MANUAL_MAX_BYTES = 512 * 1024;
4531
4531
  var MANUAL_FETCH_TIMEOUT_MS = 1e4;
4532
4532
  var MANUAL_MAX_REDIRECTS = 3;
4533
4533
  var MANUAL_SKILL_NAME = "agentchat";
4534
+ var MANUAL_RETRY_JITTER = 0.2;
4534
4535
  function manualFrontMatter(raw) {
4535
4536
  const text2 = (raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw).replace(/\r\n/g, "\n");
4536
4537
  if (!text2.startsWith("---\n")) return null;
@@ -4626,6 +4627,9 @@ var ManualSync = class {
4626
4627
  unsubscribe = null;
4627
4628
  lastError = null;
4628
4629
  last = null;
4630
+ /** Syncs in a row, since the last current one or texts change, that left the file not the announced manual. */
4631
+ misses = 0;
4632
+ retryTimer = null;
4629
4633
  constructor(options) {
4630
4634
  this.options = options;
4631
4635
  }
@@ -4633,11 +4637,12 @@ var ManualSync = class {
4633
4637
  get result() {
4634
4638
  return this.last;
4635
4639
  }
4636
- /** Sync now, then follow every texts change. Resolves with the first result. */
4640
+ /** Sync now, then follow every texts change, and retry while the file is not current. Resolves with the first result. */
4637
4641
  start() {
4638
4642
  if (this.unsubscribe === null) {
4639
4643
  this.unsubscribe = this.options.texts.onChange((texts) => {
4640
- void this.sync(texts.manual);
4644
+ this.cancelRetry();
4645
+ void this.run(texts.manual, true);
4641
4646
  });
4642
4647
  }
4643
4648
  return this.sync();
@@ -4645,10 +4650,15 @@ var ManualSync = class {
4645
4650
  stop() {
4646
4651
  this.unsubscribe?.();
4647
4652
  this.unsubscribe = null;
4653
+ this.cancelRetry();
4648
4654
  this.controller.abort();
4649
4655
  }
4650
4656
  /** One serialised sync against `served` (default: the texts in hand). Null when nothing is in hand or stopped. */
4651
4657
  sync(served = this.options.texts.current()?.manual ?? null) {
4658
+ return this.run(served, false);
4659
+ }
4660
+ /** `sync`, on the chain. `announced`: the texts changed, so the backoff starts over. */
4661
+ run(served, announced) {
4652
4662
  const next = this.chain.then(async () => {
4653
4663
  if (served === null || this.controller.signal.aborted) return null;
4654
4664
  const result = await syncManual({
@@ -4670,11 +4680,41 @@ var ManualSync = class {
4670
4680
  }
4671
4681
  }
4672
4682
  this.lastError = result.upToDate === true ? null : result.error;
4683
+ if (announced) this.misses = 0;
4684
+ this.scheduleRetry(result);
4673
4685
  return result;
4674
4686
  });
4675
4687
  this.chain = next.catch(() => void 0);
4676
4688
  return next;
4677
4689
  }
4690
+ /**
4691
+ * After each result: a current one (or nothing announced) ends the retries
4692
+ * and resets the backoff; any other arms the next attempt, while following
4693
+ * (between `start()` and `stop()`). At most one is pending; it runs on the
4694
+ * chain like any sync, against the texts in hand when it fires. The timer
4695
+ * never keeps the process alive.
4696
+ */
4697
+ scheduleRetry(result) {
4698
+ this.cancelRetry();
4699
+ if (result.served === null || result.upToDate === true) {
4700
+ this.misses = 0;
4701
+ return;
4702
+ }
4703
+ if (this.unsubscribe === null || this.controller.signal.aborted) return;
4704
+ this.misses += 1;
4705
+ const step = Math.min(TEXTS_RETRY_MAX_MS, TEXTS_RETRY_MS * 2 ** Math.min(this.misses - 1, 20));
4706
+ const delay = Math.floor(step * (1 - MANUAL_RETRY_JITTER + Math.random() * 2 * MANUAL_RETRY_JITTER));
4707
+ this.retryTimer = setTimeout(() => {
4708
+ this.retryTimer = null;
4709
+ this.sync().catch(() => void 0);
4710
+ }, delay);
4711
+ this.retryTimer.unref?.();
4712
+ }
4713
+ cancelRetry() {
4714
+ if (this.retryTimer === null) return;
4715
+ clearTimeout(this.retryTimer);
4716
+ this.retryTimer = null;
4717
+ }
4678
4718
  };
4679
4719
  var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
4680
4720
  var MANUAL_HOME = "agentchat.me";