clavarium 0.2.236-beta.1 → 0.2.237-beta.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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/talk.mjs +17 -7
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.237-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.237-beta.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/talk.mjs
CHANGED
|
@@ -773,8 +773,8 @@ export class Talk {
|
|
|
773
773
|
}
|
|
774
774
|
if (!(await this.#type(name, this.rereadLine()).catch((error) => { this.#log(`talk: ${name}: NOT typed: ${error?.message}`); return false; }))) return later(RETRY_MS);
|
|
775
775
|
/* Reading the whole thread, it reads what waits too: that line is not typed after it. */
|
|
776
|
-
const
|
|
777
|
-
this.#store.put({ ...this.#store.get(name), reread: false, ...(waits ? { pending: false, woke: true, why: null, again: false, toldRead: this.#readCount(name), renudged: 0 } : {}), typedAt: new Date(this.#now()).toISOString() });
|
|
776
|
+
const unread = this.#parley(name).unread(); const waits = unread > 0;
|
|
777
|
+
this.#store.put({ ...this.#store.get(name), reread: false, ...(waits ? { pending: false, woke: true, why: null, again: false, toldRead: this.#readCount(name), toldUnread: unread, renudged: 0 } : {}), typedAt: new Date(this.#now()).toISOString() });
|
|
778
778
|
return 'typed';
|
|
779
779
|
}
|
|
780
780
|
|
|
@@ -787,6 +787,13 @@ export class Talk {
|
|
|
787
787
|
/* TOLD, THEN READ, THEN WRITTEN TO AGAIN before `woke` was put back (the tick's, every second -- or
|
|
788
788
|
never, while a tick waited on another conversation): the line typed was used, the next is owed. */
|
|
789
789
|
#readSince(name, r) { return Number.isInteger(r?.toldRead) && this.#readCount(name) > r.toldRead; }
|
|
790
|
+
/* More waits than when its line was typed: a message came since (its reminders, used up, do not hold it back). */
|
|
791
|
+
/* One told before this was counted, its reminders used up (stuck since 17-11): told once more, then counted. */
|
|
792
|
+
/* Messages come together (a burst): one line for them, a minute at least after the last. */
|
|
793
|
+
#newSince(r, unread) {
|
|
794
|
+
if (!(this.#now() - Date.parse(r?.typedAt ?? '') >= RENUDGE_MS[0])) return false;
|
|
795
|
+
return Number.isInteger(r?.toldUnread) ? unread > r.toldUnread : (r?.renudged ?? 0) >= RENUDGE_MS.length;
|
|
796
|
+
}
|
|
790
797
|
|
|
791
798
|
#want(name) {
|
|
792
799
|
const r = this.#store.get(name);
|
|
@@ -808,17 +815,20 @@ export class Talk {
|
|
|
808
815
|
const r = this.#store.get(name);
|
|
809
816
|
if (r?.on !== true) return 'read';
|
|
810
817
|
const waits = (why, ms) => { this.#store.put({ ...this.#store.get(name), pending: true, why, again, renudge }); this.#nextTry.set(name, this.#now() + ms); return why; };
|
|
811
|
-
|
|
818
|
+
const unread = this.#parley(name).unread();
|
|
819
|
+
if (unread === 0) { if (r.pending || r.woke) this.#store.put({ ...r, pending: false, woke: false, why: null, again: false, renudge: false }); return 'read'; }
|
|
812
820
|
/* Its machine has just restarted: the line that will be typed tells it to read everything. */
|
|
813
821
|
if (r.reread === true) { this.#store.put({ ...r, pending: true, why: 'restarting', again }); return 'restarting'; }
|
|
814
|
-
|
|
822
|
+
/* Told already, nothing read since -- and nothing new either: one line is enough. A message come since is
|
|
823
|
+
owed its own line (19-11: an AI that missed its reminders was never told again, a room's questions with it). */
|
|
824
|
+
if (r.woke === true && !again && !this.#readSince(name, r) && !this.#newSince(r, unread)) { if (r.pending) this.#store.put({ ...r, pending: false, why: null }); return 'told'; }
|
|
815
825
|
if (!this.#conversations.awake().includes(name)) return waits('asleep', RETRY_MS);
|
|
816
826
|
const quiet = this.#now() - (this.#typedAt.get(name) ?? 0);
|
|
817
827
|
if (quiet < TYPING_QUIET_MS) return waits('typing', TYPING_QUIET_MS - quiet + 100);
|
|
818
828
|
if (!(await this.#runs(name))) return waits('asleep', RETRY_MS);
|
|
819
829
|
if (renudge) this.#log(`talk: ${name}: still unread ${Math.round((this.#now() - Date.parse(r.typedAt ?? '')) / 1000)} s after its line: typed again (${(r.renudged ?? 0) + 1})`);
|
|
820
830
|
if (!(await this.#type(name, urgent ? URGENT : WAKE).catch((error) => { this.#log(`talk: ${name}: NOT typed: ${error?.message}`); return false; }))) return waits('failed', RETRY_MS);
|
|
821
|
-
this.#store.put({ ...this.#store.get(name), pending: false, woke: true, why: null, again: false, renudge: false, typedAt: new Date(this.#now()).toISOString(), toldRead: this.#readCount(name), renudged: renudge ? (r.renudged ?? 0) + 1 : 0 });
|
|
831
|
+
this.#store.put({ ...this.#store.get(name), pending: false, woke: true, why: null, again: false, renudge: false, typedAt: new Date(this.#now()).toISOString(), toldRead: this.#readCount(name), toldUnread: unread, renudged: renudge ? (r.renudged ?? 0) + 1 : 0 });
|
|
822
832
|
return 'typed';
|
|
823
833
|
}
|
|
824
834
|
|
|
@@ -850,8 +860,8 @@ export class Talk {
|
|
|
850
860
|
try { unread = this.#parley(r.name).unread(); } catch { return; /* its folder went */ }
|
|
851
861
|
/* It has read: what waited is done, and the next message wakes it again. */
|
|
852
862
|
if (unread === 0) { this.#store.put({ ...r, woke: false }); return; }
|
|
853
|
-
/* It read since, and more was written: the line is owed now. */
|
|
854
|
-
if (this.#readSince(r.name, r)) { await this.#wake(r.name); return; }
|
|
863
|
+
/* It read since, and more was written: the line is owed now. A message come since its line: the same. */
|
|
864
|
+
if (this.#readSince(r.name, r) || this.#newSince(r, unread)) { await this.#wake(r.name); return; }
|
|
855
865
|
/* Still unread long after: typed again, RENUDGE_MS apart -- AS MANY TIMES AS THERE ARE, NO MORE (17-11,
|
|
856
866
|
the owner: never a reminder without end). Then it waits: its chat keeps "Remind it" for the owner. */
|
|
857
867
|
if ((r.renudged ?? 0) >= RENUDGE_MS.length) return;
|