clavarium 0.2.498-next.1 → 0.2.500-next.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 +22 -9
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.500-next.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.500-next.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
|
@@ -255,8 +255,11 @@ export class Talk {
|
|
|
255
255
|
this.#timer.unref?.();
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
/* One conversation's record, as kept (18-11: the whole list was made again -- sorted, each with its tool -- for each
|
|
259
|
+
path a message showed: half a second for one page of a long thread on the owner's server). */
|
|
260
|
+
#one(name) { return typeof this.#conversations.get === 'function' ? this.#conversations.get(name) : this.#conversations.list().find((x) => x.name === name); }
|
|
258
261
|
#known(name) {
|
|
259
|
-
const c = isConversationName(name) ? this.#
|
|
262
|
+
const c = isConversationName(name) ? this.#one(name) : undefined;
|
|
260
263
|
if (!c) throw new Refusal(404, 'No such conversation.');
|
|
261
264
|
return c;
|
|
262
265
|
}
|
|
@@ -325,7 +328,7 @@ export class Talk {
|
|
|
325
328
|
const inner = p.slice('/work/'.length);
|
|
326
329
|
/* The bridge folder is not the tool's to show -- but for the files the person attached there. */
|
|
327
330
|
if (!inner || inner === FOLDER || (inner.startsWith(`${FOLDER}/`) && !ATTACHED.test(p))) return null;
|
|
328
|
-
return this.#
|
|
331
|
+
return this.#one(name)?.work === 'kept' ? `work:${inner}` : null;
|
|
329
332
|
}
|
|
330
333
|
const m = /^\/resources\/([a-z][a-z0-9-]{0,31})\/(.+)$/.exec(p);
|
|
331
334
|
return m && this.#resources.of(name).some((x) => x.name === m[1]) ? `${m[1]}:${m[2]}` : null;
|
|
@@ -770,8 +773,8 @@ export class Talk {
|
|
|
770
773
|
}
|
|
771
774
|
if (!(await this.#type(name, this.rereadLine()).catch((error) => { this.#log(`talk: ${name}: NOT typed: ${error?.message}`); return false; }))) return later(RETRY_MS);
|
|
772
775
|
/* Reading the whole thread, it reads what waits too: that line is not typed after it. */
|
|
773
|
-
const
|
|
774
|
-
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() });
|
|
775
778
|
return 'typed';
|
|
776
779
|
}
|
|
777
780
|
|
|
@@ -784,6 +787,13 @@ export class Talk {
|
|
|
784
787
|
/* TOLD, THEN READ, THEN WRITTEN TO AGAIN before `woke` was put back (the tick's, every second -- or
|
|
785
788
|
never, while a tick waited on another conversation): the line typed was used, the next is owed. */
|
|
786
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
|
+
}
|
|
787
797
|
|
|
788
798
|
#want(name) {
|
|
789
799
|
const r = this.#store.get(name);
|
|
@@ -805,17 +815,20 @@ export class Talk {
|
|
|
805
815
|
const r = this.#store.get(name);
|
|
806
816
|
if (r?.on !== true) return 'read';
|
|
807
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; };
|
|
808
|
-
|
|
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'; }
|
|
809
820
|
/* Its machine has just restarted: the line that will be typed tells it to read everything. */
|
|
810
821
|
if (r.reread === true) { this.#store.put({ ...r, pending: true, why: 'restarting', again }); return 'restarting'; }
|
|
811
|
-
|
|
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'; }
|
|
812
825
|
if (!this.#conversations.awake().includes(name)) return waits('asleep', RETRY_MS);
|
|
813
826
|
const quiet = this.#now() - (this.#typedAt.get(name) ?? 0);
|
|
814
827
|
if (quiet < TYPING_QUIET_MS) return waits('typing', TYPING_QUIET_MS - quiet + 100);
|
|
815
828
|
if (!(await this.#runs(name))) return waits('asleep', RETRY_MS);
|
|
816
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})`);
|
|
817
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);
|
|
818
|
-
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 });
|
|
819
832
|
return 'typed';
|
|
820
833
|
}
|
|
821
834
|
|
|
@@ -847,8 +860,8 @@ export class Talk {
|
|
|
847
860
|
try { unread = this.#parley(r.name).unread(); } catch { return; /* its folder went */ }
|
|
848
861
|
/* It has read: what waited is done, and the next message wakes it again. */
|
|
849
862
|
if (unread === 0) { this.#store.put({ ...r, woke: false }); return; }
|
|
850
|
-
/* It read since, and more was written: the line is owed now. */
|
|
851
|
-
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; }
|
|
852
865
|
/* Still unread long after: typed again, RENUDGE_MS apart -- AS MANY TIMES AS THERE ARE, NO MORE (17-11,
|
|
853
866
|
the owner: never a reminder without end). Then it waits: its chat keeps "Remind it" for the owner. */
|
|
854
867
|
if ((r.renudged ?? 0) >= RENUDGE_MS.length) return;
|