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 +25 -0
- package/dist/index.cjs +43 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +43 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3844,7 +3844,12 @@ interface ManualSyncOptions {
|
|
|
3844
3844
|
/**
|
|
3845
3845
|
* Keeps the skill file at the manual the texts announce. `start()` syncs once
|
|
3846
3846
|
* and then on every texts change (the texts' own cadence: daily, sooner while
|
|
3847
|
-
* the server does not answer).
|
|
3847
|
+
* the server does not answer). While a sync has left the file not the
|
|
3848
|
+
* announced manual (offline, an error answer, a body that failed a check, a
|
|
3849
|
+
* write that failed), it is tried again on its own after 5 min, doubling to
|
|
3850
|
+
* 1 h (±20 %), until one is current: the texts may not change again for a
|
|
3851
|
+
* day or more. A texts change syncs at once and starts the backoff over.
|
|
3852
|
+
* Calls are serialised; `stop()` cancels a pending retry and aborts a
|
|
3848
3853
|
* download in flight.
|
|
3849
3854
|
*/
|
|
3850
3855
|
declare class ManualSync {
|
|
@@ -3854,14 +3859,28 @@ declare class ManualSync {
|
|
|
3854
3859
|
private unsubscribe;
|
|
3855
3860
|
private lastError;
|
|
3856
3861
|
private last;
|
|
3862
|
+
/** Syncs in a row, since the last current one or texts change, that left the file not the announced manual. */
|
|
3863
|
+
private misses;
|
|
3864
|
+
private retryTimer;
|
|
3857
3865
|
constructor(options: ManualSyncOptions);
|
|
3858
3866
|
/** The latest result, for an integration's status. */
|
|
3859
3867
|
get result(): ManualSyncResult | null;
|
|
3860
|
-
/** Sync now, then follow every texts change. Resolves with the first result. */
|
|
3868
|
+
/** Sync now, then follow every texts change, and retry while the file is not current. Resolves with the first result. */
|
|
3861
3869
|
start(): Promise<ManualSyncResult | null>;
|
|
3862
3870
|
stop(): void;
|
|
3863
3871
|
/** One serialised sync against `served` (default: the texts in hand). Null when nothing is in hand or stopped. */
|
|
3864
3872
|
sync(served?: ServedManual | null): Promise<ManualSyncResult | null>;
|
|
3873
|
+
/** `sync`, on the chain. `announced`: the texts changed, so the backoff starts over. */
|
|
3874
|
+
private run;
|
|
3875
|
+
/**
|
|
3876
|
+
* After each result: a current one (or nothing announced) ends the retries
|
|
3877
|
+
* and resets the backoff; any other arms the next attempt, while following
|
|
3878
|
+
* (between `start()` and `stop()`). At most one is pending; it runs on the
|
|
3879
|
+
* chain like any sync, against the texts in hand when it fires. The timer
|
|
3880
|
+
* never keeps the process alive.
|
|
3881
|
+
*/
|
|
3882
|
+
private scheduleRetry;
|
|
3883
|
+
private cancelRetry;
|
|
3865
3884
|
}
|
|
3866
3885
|
|
|
3867
3886
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -3844,7 +3844,12 @@ interface ManualSyncOptions {
|
|
|
3844
3844
|
/**
|
|
3845
3845
|
* Keeps the skill file at the manual the texts announce. `start()` syncs once
|
|
3846
3846
|
* and then on every texts change (the texts' own cadence: daily, sooner while
|
|
3847
|
-
* the server does not answer).
|
|
3847
|
+
* the server does not answer). While a sync has left the file not the
|
|
3848
|
+
* announced manual (offline, an error answer, a body that failed a check, a
|
|
3849
|
+
* write that failed), it is tried again on its own after 5 min, doubling to
|
|
3850
|
+
* 1 h (±20 %), until one is current: the texts may not change again for a
|
|
3851
|
+
* day or more. A texts change syncs at once and starts the backoff over.
|
|
3852
|
+
* Calls are serialised; `stop()` cancels a pending retry and aborts a
|
|
3848
3853
|
* download in flight.
|
|
3849
3854
|
*/
|
|
3850
3855
|
declare class ManualSync {
|
|
@@ -3854,14 +3859,28 @@ declare class ManualSync {
|
|
|
3854
3859
|
private unsubscribe;
|
|
3855
3860
|
private lastError;
|
|
3856
3861
|
private last;
|
|
3862
|
+
/** Syncs in a row, since the last current one or texts change, that left the file not the announced manual. */
|
|
3863
|
+
private misses;
|
|
3864
|
+
private retryTimer;
|
|
3857
3865
|
constructor(options: ManualSyncOptions);
|
|
3858
3866
|
/** The latest result, for an integration's status. */
|
|
3859
3867
|
get result(): ManualSyncResult | null;
|
|
3860
|
-
/** Sync now, then follow every texts change. Resolves with the first result. */
|
|
3868
|
+
/** Sync now, then follow every texts change, and retry while the file is not current. Resolves with the first result. */
|
|
3861
3869
|
start(): Promise<ManualSyncResult | null>;
|
|
3862
3870
|
stop(): void;
|
|
3863
3871
|
/** One serialised sync against `served` (default: the texts in hand). Null when nothing is in hand or stopped. */
|
|
3864
3872
|
sync(served?: ServedManual | null): Promise<ManualSyncResult | null>;
|
|
3873
|
+
/** `sync`, on the chain. `announced`: the texts changed, so the backoff starts over. */
|
|
3874
|
+
private run;
|
|
3875
|
+
/**
|
|
3876
|
+
* After each result: a current one (or nothing announced) ends the retries
|
|
3877
|
+
* and resets the backoff; any other arms the next attempt, while following
|
|
3878
|
+
* (between `start()` and `stop()`). At most one is pending; it runs on the
|
|
3879
|
+
* chain like any sync, against the texts in hand when it fires. The timer
|
|
3880
|
+
* never keeps the process alive.
|
|
3881
|
+
*/
|
|
3882
|
+
private scheduleRetry;
|
|
3883
|
+
private cancelRetry;
|
|
3865
3884
|
}
|
|
3866
3885
|
|
|
3867
3886
|
/**
|
package/dist/index.js
CHANGED
|
@@ -350,7 +350,7 @@ function createAgentChatError(body, status, headers) {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
// src/version.ts
|
|
353
|
-
var VERSION = "1.6.
|
|
353
|
+
var VERSION = "1.6.1" ;
|
|
354
354
|
|
|
355
355
|
// src/runtime.ts
|
|
356
356
|
function detectRuntime() {
|
|
@@ -4529,6 +4529,7 @@ var MANUAL_MAX_BYTES = 512 * 1024;
|
|
|
4529
4529
|
var MANUAL_FETCH_TIMEOUT_MS = 1e4;
|
|
4530
4530
|
var MANUAL_MAX_REDIRECTS = 3;
|
|
4531
4531
|
var MANUAL_SKILL_NAME = "agentchat";
|
|
4532
|
+
var MANUAL_RETRY_JITTER = 0.2;
|
|
4532
4533
|
function manualFrontMatter(raw) {
|
|
4533
4534
|
const text2 = (raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw).replace(/\r\n/g, "\n");
|
|
4534
4535
|
if (!text2.startsWith("---\n")) return null;
|
|
@@ -4624,6 +4625,9 @@ var ManualSync = class {
|
|
|
4624
4625
|
unsubscribe = null;
|
|
4625
4626
|
lastError = null;
|
|
4626
4627
|
last = null;
|
|
4628
|
+
/** Syncs in a row, since the last current one or texts change, that left the file not the announced manual. */
|
|
4629
|
+
misses = 0;
|
|
4630
|
+
retryTimer = null;
|
|
4627
4631
|
constructor(options) {
|
|
4628
4632
|
this.options = options;
|
|
4629
4633
|
}
|
|
@@ -4631,11 +4635,12 @@ var ManualSync = class {
|
|
|
4631
4635
|
get result() {
|
|
4632
4636
|
return this.last;
|
|
4633
4637
|
}
|
|
4634
|
-
/** Sync now, then follow every texts change. Resolves with the first result. */
|
|
4638
|
+
/** Sync now, then follow every texts change, and retry while the file is not current. Resolves with the first result. */
|
|
4635
4639
|
start() {
|
|
4636
4640
|
if (this.unsubscribe === null) {
|
|
4637
4641
|
this.unsubscribe = this.options.texts.onChange((texts) => {
|
|
4638
|
-
|
|
4642
|
+
this.cancelRetry();
|
|
4643
|
+
void this.run(texts.manual, true);
|
|
4639
4644
|
});
|
|
4640
4645
|
}
|
|
4641
4646
|
return this.sync();
|
|
@@ -4643,10 +4648,15 @@ var ManualSync = class {
|
|
|
4643
4648
|
stop() {
|
|
4644
4649
|
this.unsubscribe?.();
|
|
4645
4650
|
this.unsubscribe = null;
|
|
4651
|
+
this.cancelRetry();
|
|
4646
4652
|
this.controller.abort();
|
|
4647
4653
|
}
|
|
4648
4654
|
/** One serialised sync against `served` (default: the texts in hand). Null when nothing is in hand or stopped. */
|
|
4649
4655
|
sync(served = this.options.texts.current()?.manual ?? null) {
|
|
4656
|
+
return this.run(served, false);
|
|
4657
|
+
}
|
|
4658
|
+
/** `sync`, on the chain. `announced`: the texts changed, so the backoff starts over. */
|
|
4659
|
+
run(served, announced) {
|
|
4650
4660
|
const next = this.chain.then(async () => {
|
|
4651
4661
|
if (served === null || this.controller.signal.aborted) return null;
|
|
4652
4662
|
const result = await syncManual({
|
|
@@ -4668,11 +4678,41 @@ var ManualSync = class {
|
|
|
4668
4678
|
}
|
|
4669
4679
|
}
|
|
4670
4680
|
this.lastError = result.upToDate === true ? null : result.error;
|
|
4681
|
+
if (announced) this.misses = 0;
|
|
4682
|
+
this.scheduleRetry(result);
|
|
4671
4683
|
return result;
|
|
4672
4684
|
});
|
|
4673
4685
|
this.chain = next.catch(() => void 0);
|
|
4674
4686
|
return next;
|
|
4675
4687
|
}
|
|
4688
|
+
/**
|
|
4689
|
+
* After each result: a current one (or nothing announced) ends the retries
|
|
4690
|
+
* and resets the backoff; any other arms the next attempt, while following
|
|
4691
|
+
* (between `start()` and `stop()`). At most one is pending; it runs on the
|
|
4692
|
+
* chain like any sync, against the texts in hand when it fires. The timer
|
|
4693
|
+
* never keeps the process alive.
|
|
4694
|
+
*/
|
|
4695
|
+
scheduleRetry(result) {
|
|
4696
|
+
this.cancelRetry();
|
|
4697
|
+
if (result.served === null || result.upToDate === true) {
|
|
4698
|
+
this.misses = 0;
|
|
4699
|
+
return;
|
|
4700
|
+
}
|
|
4701
|
+
if (this.unsubscribe === null || this.controller.signal.aborted) return;
|
|
4702
|
+
this.misses += 1;
|
|
4703
|
+
const step = Math.min(TEXTS_RETRY_MAX_MS, TEXTS_RETRY_MS * 2 ** Math.min(this.misses - 1, 20));
|
|
4704
|
+
const delay = Math.floor(step * (1 - MANUAL_RETRY_JITTER + Math.random() * 2 * MANUAL_RETRY_JITTER));
|
|
4705
|
+
this.retryTimer = setTimeout(() => {
|
|
4706
|
+
this.retryTimer = null;
|
|
4707
|
+
this.sync().catch(() => void 0);
|
|
4708
|
+
}, delay);
|
|
4709
|
+
this.retryTimer.unref?.();
|
|
4710
|
+
}
|
|
4711
|
+
cancelRetry() {
|
|
4712
|
+
if (this.retryTimer === null) return;
|
|
4713
|
+
clearTimeout(this.retryTimer);
|
|
4714
|
+
this.retryTimer = null;
|
|
4715
|
+
}
|
|
4676
4716
|
};
|
|
4677
4717
|
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
4678
4718
|
var MANUAL_HOME = "agentchat.me";
|