clavarium 0.2.73-next.1 → 0.2.77-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/deploy/install.sh +1 -1
- package/deploy/updater.mjs +1 -1
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/accounts.mjs +7 -7
- package/server/gitkeeper.mjs +30 -1
- package/server/oauth.mjs +8 -6
- package/web/app.js +19 -8
- package/web/style.css +4 -2
package/deploy/install.sh
CHANGED
|
@@ -605,7 +605,7 @@ $BIND
|
|
|
605
605
|
@api path /api/* /c/api/*
|
|
606
606
|
handle @api {
|
|
607
607
|
header Content-Type "application/json; charset=utf-8"
|
|
608
|
-
respond "{\"error\":\"Clavarium
|
|
608
|
+
respond "{\"error\":\"Clavarium did not answer just now -- it may be busy or restarting. It comes back by itself; try again in a moment.\",\"down\":true}" 503
|
|
609
609
|
}
|
|
610
610
|
handle {
|
|
611
611
|
root * /var/lib/clavarium/maintenance
|
package/deploy/updater.mjs
CHANGED
|
@@ -140,7 +140,7 @@ export const MAINTENANCE_BLOCK = [
|
|
|
140
140
|
'\t\t\t\t@api path /api/* /c/api/*',
|
|
141
141
|
'\t\t\t\thandle @api {',
|
|
142
142
|
'\t\t\t\t\theader Content-Type "application/json; charset=utf-8"',
|
|
143
|
-
'\t\t\t\t\trespond "{\\"error\\":\\"Clavarium
|
|
143
|
+
'\t\t\t\t\trespond "{\\"error\\":\\"Clavarium did not answer just now -- it may be busy or restarting. It comes back by itself; try again in a moment.\\",\\"down\\":true}" 503',
|
|
144
144
|
'\t\t\t\t}',
|
|
145
145
|
'\t\t\t\thandle {',
|
|
146
146
|
`\t\t\t\t\troot * ${MAINTENANCE_DIR}`,
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.77-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.77-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"clavarium-binder": "0.1.8-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.1",
|
|
16
16
|
"clavarium-parley": "0.17.11-next.1",
|
|
17
|
-
"clavarium-tether": "0.1.0-next.
|
|
17
|
+
"clavarium-tether": "0.1.0-next.12",
|
|
18
18
|
"mermaid": "11.17.2",
|
|
19
19
|
"node-pty": "^1.1.0",
|
|
20
20
|
"pdfjs-dist": "6.4.299",
|
|
@@ -755,9 +755,9 @@
|
|
|
755
755
|
}
|
|
756
756
|
},
|
|
757
757
|
"node_modules/clavarium-tether": {
|
|
758
|
-
"version": "0.1.0-next.
|
|
759
|
-
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.
|
|
760
|
-
"integrity": "sha512-
|
|
758
|
+
"version": "0.1.0-next.12",
|
|
759
|
+
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.12.tgz",
|
|
760
|
+
"integrity": "sha512-3lbTV27WEyVLEHze8xbsTzA9iBGv6VxPMIGY20zzpeCb9JGZ2rU7cq8sk7VcWyPpoqSnBh3SyvXqA3LoM0zYmA==",
|
|
761
761
|
"license": "MIT",
|
|
762
762
|
"bin": {
|
|
763
763
|
"tether": "bin/cli.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.77-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"clavarium-binder": "0.1.8-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.1",
|
|
49
49
|
"clavarium-parley": "0.17.11-next.1",
|
|
50
|
-
"clavarium-tether": "0.1.0-next.
|
|
50
|
+
"clavarium-tether": "0.1.0-next.12",
|
|
51
51
|
"mermaid": "11.17.2",
|
|
52
52
|
"node-pty": "^1.1.0",
|
|
53
53
|
"pdfjs-dist": "6.4.299",
|
package/server/accounts.mjs
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
* instead the keeper reveals it to the connector alone, host-side, and acts on
|
|
11
11
|
* the agent's behalf within the level and rules the person set.
|
|
12
12
|
*
|
|
13
|
-
* ONE ACCOUNT, ONE TOKEN, SEVERAL TARGETS. A
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* ONE ACCOUNT, ONE TOKEN, SEVERAL TARGETS. A consent for mail+calendar+contacts
|
|
14
|
+
* yields a single refresh token; this makes one host-only secret and a Tether
|
|
15
|
+
* target per kind, each naming that secret. Both providers borrow an open-source
|
|
16
|
+
* desktop client verified for all three: Google uses GNOME Online Accounts' over
|
|
17
|
+
* IMAP + CalDAV/CardDAV, Microsoft uses its Graph client (mail, calendar and
|
|
18
|
+
* contacts all over Microsoft Graph).
|
|
19
19
|
*
|
|
20
20
|
* A CREATED TARGET IS GIVEN TO NO ONE. The person grants it per conversation, at
|
|
21
21
|
* its own level, from the page (Assets > Access) -- like git: one mailbox, many
|
|
@@ -42,7 +42,7 @@ const KIND = {
|
|
|
42
42
|
contacts: { connector: 'contacts', kind: 'contacts', title: 'Contacts', needsUser: true },
|
|
43
43
|
};
|
|
44
44
|
/* What each provider's built-in (Thunderbird) client grants a refresh token for. */
|
|
45
|
-
const SUPPORTED = { google: ['mail', 'calendar', 'contacts'], microsoft: ['mail'] };
|
|
45
|
+
const SUPPORTED = { google: ['mail', 'calendar', 'contacts'], microsoft: ['mail', 'calendar', 'contacts'] };
|
|
46
46
|
|
|
47
47
|
const emailOk = (s) => /^[^\s@]{1,64}@[^\s@]{1,190}\.[^\s@]{2,}$/.test(s);
|
|
48
48
|
/* A deterministic, valid secret name for an account's token: a short slug of the
|
package/server/gitkeeper.mjs
CHANGED
|
@@ -211,9 +211,15 @@ const seeCommits = (name, head, base, n) => (short(head) && short(base) && Numbe
|
|
|
211
211
|
long a finished run is kept for the request that asks again just after. */
|
|
212
212
|
export const CHECK_WAIT_MS = 20_000;
|
|
213
213
|
export const CHECK_KEEP_MS = 60_000;
|
|
214
|
+
/* A send (the push to the remote) runs in the background, like a check: one
|
|
215
|
+
request waits at most this long, then hears { status: 'sending' } and asks
|
|
216
|
+
again (join), so a long push never outruns the proxy. The push itself is
|
|
217
|
+
already bounded (PUSH_MS); a finished send is kept this long for the asking. */
|
|
218
|
+
export const SENDING_WAIT_MS = 20_000;
|
|
219
|
+
export const SENDING_KEEP_MS = 60_000;
|
|
214
220
|
|
|
215
221
|
export class GitKeeper {
|
|
216
|
-
#store; #review; #resources; #checks; #alerts; #now; #tellAgent; #thread; #last; #held = new Map(); #results = new Map(); #running = new Set(); #telling = new Map(); #inFlight = new Map();
|
|
222
|
+
#store; #review; #resources; #checks; #alerts; #now; #tellAgent; #thread; #last; #held = new Map(); #results = new Map(); #running = new Set(); #telling = new Map(); #inFlight = new Map(); #sending = new Map();
|
|
217
223
|
|
|
218
224
|
/* `review`: GitReview (reads, the reference, Send). `checks`: GitChecks.
|
|
219
225
|
`alerts`: what tells the owner's phone. `tellAgent(repository, line,
|
|
@@ -556,7 +562,30 @@ export class GitKeeper {
|
|
|
556
562
|
|
|
557
563
|
/* Send, from the page: as GitReview.push, and refused when the owner
|
|
558
564
|
requires passing checks and none passed for this commit and branch. */
|
|
565
|
+
/* The push runs in the background; the request waits at most SENDING_WAIT_MS,
|
|
566
|
+
then returns { status: 'sending' } and the page asks again with `join: true`
|
|
567
|
+
until it ends -- so a slow push never blocks the request past the proxy's
|
|
568
|
+
patience. The push itself is still bounded (PUSH_MS), so it cannot run on
|
|
569
|
+
for hours. A send already going is joined; one just ended is re-run only
|
|
570
|
+
on a fresh click (no `join`), and re-sending the same commit is a no-op. */
|
|
559
571
|
async send(name, body) {
|
|
572
|
+
const r = this.#repository(name);
|
|
573
|
+
const key = `${r.name}\n${body?.head ?? ''}\n${body?.target ?? ''}`;
|
|
574
|
+
let entry = this.#sending.get(key);
|
|
575
|
+
if (!entry || (entry.done && body?.join !== true)) {
|
|
576
|
+
const made = { done: false, result: undefined, error: undefined };
|
|
577
|
+
made.run = this.#doSend(r.name, body)
|
|
578
|
+
.then((result) => { made.result = result; }, (error) => { made.error = error; })
|
|
579
|
+
.finally(() => { made.done = true; setTimeout(() => { if (this.#sending.get(key) === made) this.#sending.delete(key); }, SENDING_KEEP_MS).unref?.(); });
|
|
580
|
+
entry = made; this.#sending.set(key, made);
|
|
581
|
+
}
|
|
582
|
+
const ms = Number.isFinite(body?.wait) ? Math.max(0, Math.min(body.wait, SENDING_WAIT_MS)) : SENDING_WAIT_MS;
|
|
583
|
+
await Promise.race([entry.run, new Promise((res) => { setTimeout(res, ms).unref?.(); })]);
|
|
584
|
+
if (!entry.done) return { status: 'sending' };
|
|
585
|
+
if (entry.error) throw entry.error;
|
|
586
|
+
return entry.result;
|
|
587
|
+
}
|
|
588
|
+
async #doSend(name, body) {
|
|
560
589
|
const r = this.#repository(name);
|
|
561
590
|
if (this.settings(r.name).requireForSend) {
|
|
562
591
|
const target = body?.target || undefined;
|
package/server/oauth.mjs
CHANGED
|
@@ -73,15 +73,17 @@ export const PROVIDERS = {
|
|
|
73
73
|
pkce: true,
|
|
74
74
|
consentExtra: {},
|
|
75
75
|
offlineScope: 'offline_access',
|
|
76
|
-
/*
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
/* Microsoft over Graph: GNOME Online Accounts' client is a Graph client,
|
|
77
|
+
so mail, calendar and contacts all go through graph.microsoft.com (the
|
|
78
|
+
mail connector uses its Graph path for Microsoft). mail.send is needed
|
|
79
|
+
to send. GOA's client is verified for all of these. */
|
|
79
80
|
scopes: {
|
|
80
|
-
mail: '
|
|
81
|
-
|
|
81
|
+
mail: 'mail.readwrite mail.send',
|
|
82
|
+
calendar: 'calendars.readwrite',
|
|
83
|
+
contacts: 'contacts.readwrite',
|
|
82
84
|
},
|
|
83
85
|
thunderbird: {
|
|
84
|
-
clientId: '
|
|
86
|
+
clientId: 'b155a604-3c31-4079-93b0-6bb6aa9d5464',
|
|
85
87
|
clientSecret: null,
|
|
86
88
|
},
|
|
87
89
|
},
|
package/web/app.js
CHANGED
|
@@ -3815,7 +3815,16 @@
|
|
|
3815
3815
|
for (const r of p) {
|
|
3816
3816
|
r.sending = true; paint();
|
|
3817
3817
|
try {
|
|
3818
|
-
|
|
3818
|
+
/* The push runs in the background: the first request starts it, and
|
|
3819
|
+
while it says "sending" the page asks again (join) until it ends --
|
|
3820
|
+
a long push never looks like a failure or a restart. */
|
|
3821
|
+
let sent;
|
|
3822
|
+
for (let first = true; ; first = false) {
|
|
3823
|
+
sent = await post(`${API}/git/${r.name}/push`, first
|
|
3824
|
+
? { head: r.out.head, target: r.out.target, ...(r.out.guards?.confirm ? { sure: true } : {}) }
|
|
3825
|
+
: { head: r.out.head, target: r.out.target, join: true });
|
|
3826
|
+
if (sent?.status !== 'sending') break;
|
|
3827
|
+
}
|
|
3819
3828
|
r.sent = { ok: true, text: sent.already ? `✓ Already in ${sent.branch}` : sent.commits > 0 ? `✓ Sent to ${sent.branch}` : `✓ Made ${sent.branch}` };
|
|
3820
3829
|
} catch (error) { r.sent = { ok: false, text: /^Not sent/.test(error.message) ? error.message : `Not sent: ${error.message}` }; }
|
|
3821
3830
|
r.sending = false; paint();
|
|
@@ -6166,6 +6175,8 @@
|
|
|
6166
6175
|
a live Connexion (dynamic connector, token kept on the server): this jumps
|
|
6167
6176
|
straight to adding one. */
|
|
6168
6177
|
const MAILBOX_PROVIDER = { google: 'Google', microsoft: 'Microsoft' };
|
|
6178
|
+
/* Which kinds each provider can be connected for (from the server). */
|
|
6179
|
+
let accountSupported = { google: ['mail', 'calendar', 'contacts'], microsoft: ['mail'] };
|
|
6169
6180
|
$('mailbox-to-connexion').addEventListener('click', () => { assetsAdding = 'connexion'; void paintAssets(); });
|
|
6170
6181
|
/* CONNECT AN ACCOUNT (Connexions): a live link through Tether. The person signs
|
|
6171
6182
|
in in their own browser; the token is kept on the server, never in a machine.
|
|
@@ -6174,16 +6185,15 @@
|
|
|
6174
6185
|
const form = $('connexion-new');
|
|
6175
6186
|
form.dataset.provider = provider;
|
|
6176
6187
|
for (const b of $('connexion-provider').querySelectorAll('button')) b.setAttribute('aria-pressed', String(b.dataset.provider === provider));
|
|
6177
|
-
const
|
|
6178
|
-
for (const id of ['connexion-calendar', 'connexion-contacts']) { const c = $(id); if (!
|
|
6179
|
-
$('connexion-calendar-label').classList.toggle('off', !google);
|
|
6180
|
-
$('connexion-contacts-label').classList.toggle('off', !google);
|
|
6188
|
+
const kinds = accountSupported[provider] ?? ['mail'];
|
|
6189
|
+
for (const [id, k] of [['connexion-calendar', 'calendar'], ['connexion-contacts', 'contacts']]) { const c = $(id); const ok = kinds.includes(k); if (!ok) c.checked = false; c.disabled = !ok; $(`${id}-label`).classList.toggle('off', !ok); }
|
|
6181
6190
|
$('connexion-paste').hidden = true;
|
|
6182
6191
|
$('connexion-error').hidden = true;
|
|
6183
6192
|
const who = MAILBOX_PROVIDER[provider];
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6193
|
+
const all = kinds.includes('calendar') && kinds.includes('contacts');
|
|
6194
|
+
$('connexion-notice').textContent = provider === 'google'
|
|
6195
|
+
? `Clavarium signs in with GNOME Online Accounts' app — that is what Google sees.${all ? ' Mail, calendar and contacts can be connected together.' : ''}`
|
|
6196
|
+
: `Clavarium signs in with GNOME Online Accounts' app — that is what Microsoft sees.${all ? ' Mail, calendar and contacts together, over Microsoft Graph.' : ''}`;
|
|
6187
6197
|
$('connexion-open').textContent = `Open the ${who} sign-in page`;
|
|
6188
6198
|
};
|
|
6189
6199
|
for (const b of $('connexion-provider').querySelectorAll('button')) b.addEventListener('click', () => setConnexionProvider(b.dataset.provider));
|
|
@@ -6214,6 +6224,7 @@
|
|
|
6214
6224
|
await paintAssets();
|
|
6215
6225
|
});
|
|
6216
6226
|
setConnexionProvider('google');
|
|
6227
|
+
getJson('/accounts', null).then((d) => { if (d?.supported) { accountSupported = d.supported; setConnexionProvider($('connexion-new').dataset.provider || 'google'); } });
|
|
6217
6228
|
$('list-new').addEventListener('submit', async (event) => {
|
|
6218
6229
|
event.preventDefault();
|
|
6219
6230
|
$('assets-error').hidden = true;
|
package/web/style.css
CHANGED
|
@@ -1122,8 +1122,10 @@ header .ic, #folders .ic { width: 18px; height: 18px; fill: none; stroke: curren
|
|
|
1122
1122
|
.as-group-name { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; justify-content: flex-start; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 3px 6px; }
|
|
1123
1123
|
.as-group-name:hover { border-color: var(--line); }
|
|
1124
1124
|
.as-group-name[aria-current="true"] { background: var(--panel); border-color: var(--line); }
|
|
1125
|
-
.as-gear { flex: 0 0 auto; width: 30px; height: 30px; min-width: 0 !important; min-height: 0 !important; padding: 0; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--ink2); font-size: 1rem; opacity:
|
|
1126
|
-
|
|
1125
|
+
.as-gear { flex: 0 0 auto; width: 30px; height: 30px; min-width: 0 !important; min-height: 0 !important; padding: 0; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--ink2); font-size: 1rem; opacity: 1; }
|
|
1126
|
+
/* On a mouse, keep it quiet until the group is hovered or open; on touch (no
|
|
1127
|
+
hover) it must stay visible, or it can never be reached. */
|
|
1128
|
+
@media (hover: hover) { .as-gear { opacity: 0; } .as-group-head:hover .as-gear, .as-group-name[aria-current="true"] + .as-gear { opacity: 1; } }
|
|
1127
1129
|
.as-gear:hover { border-color: var(--line); color: var(--ink); }
|
|
1128
1130
|
.as-group-members { display: flex; flex-direction: column; gap: 2px; }
|
|
1129
1131
|
/* Give the group: a block per conversation, a row per asset at its own level. */
|