@nervur-org/dock 0.3.0
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/GETTING_STARTED.md +128 -0
- package/LICENSE +202 -0
- package/NOTICE +6 -0
- package/README.md +37 -0
- package/api/quo-api.md +196 -0
- package/api/route.ts +227 -0
- package/beings/GLOSSARY.md +118 -0
- package/beings/WORLDS.md +567 -0
- package/beings/avatar.ts +101 -0
- package/beings/carry.ts +159 -0
- package/beings/clock.ts +552 -0
- package/beings/courier.ts +107 -0
- package/beings/desk.ts +128 -0
- package/beings/doorbell.ts +129 -0
- package/beings/envoy.ts +218 -0
- package/beings/index.ts +16 -0
- package/beings/join.ts +51 -0
- package/beings/link.ts +104 -0
- package/beings/look.ts +139 -0
- package/beings/porter.ts +43 -0
- package/beings/presence.ts +39 -0
- package/beings/quo-app-bells.md +280 -0
- package/beings/quo-dock.md +1942 -0
- package/beings/setup.ts +45 -0
- package/beings/side.ts +60 -0
- package/beings/user.ts +459 -0
- package/beings/way.ts +65 -0
- package/cli/bundles.ts +20 -0
- package/cli/client.ts +73 -0
- package/cli/daemon.ts +581 -0
- package/cli/estate/Caddyfile +33 -0
- package/cli/estate/quo.service +35 -0
- package/cli/estate/systems.quo.plist +44 -0
- package/cli/estate.ts +48 -0
- package/cli/folder.ts +27 -0
- package/cli/oauth.ts +32 -0
- package/cli/pilot.ts +38 -0
- package/cli/quo-dock.md +1942 -0
- package/cli/quo.ts +203 -0
- package/cli/stand.ts +160 -0
- package/dist/api/route.d.ts +21 -0
- package/dist/api/route.js +193 -0
- package/dist/beings/avatar.d.ts +32 -0
- package/dist/beings/avatar.js +100 -0
- package/dist/beings/carry.d.ts +12 -0
- package/dist/beings/carry.js +174 -0
- package/dist/beings/clock.d.ts +161 -0
- package/dist/beings/clock.js +528 -0
- package/dist/beings/courier.d.ts +50 -0
- package/dist/beings/courier.js +96 -0
- package/dist/beings/desk.d.ts +53 -0
- package/dist/beings/desk.js +135 -0
- package/dist/beings/doorbell.d.ts +78 -0
- package/dist/beings/doorbell.js +133 -0
- package/dist/beings/envoy.d.ts +54 -0
- package/dist/beings/envoy.js +211 -0
- package/dist/beings/index.d.ts +14 -0
- package/dist/beings/index.js +16 -0
- package/dist/beings/join.d.ts +15 -0
- package/dist/beings/join.js +42 -0
- package/dist/beings/link.d.ts +14 -0
- package/dist/beings/link.js +91 -0
- package/dist/beings/look.d.ts +30 -0
- package/dist/beings/look.js +104 -0
- package/dist/beings/porter.d.ts +14 -0
- package/dist/beings/porter.js +41 -0
- package/dist/beings/presence.d.ts +8 -0
- package/dist/beings/presence.js +21 -0
- package/dist/beings/setup.d.ts +3 -0
- package/dist/beings/setup.js +39 -0
- package/dist/beings/side.d.ts +32 -0
- package/dist/beings/side.js +37 -0
- package/dist/beings/user.d.ts +315 -0
- package/dist/beings/user.js +462 -0
- package/dist/beings/way.d.ts +19 -0
- package/dist/beings/way.js +28 -0
- package/dist/cli/bundles.d.ts +5 -0
- package/dist/cli/bundles.js +17 -0
- package/dist/cli/client.d.ts +15 -0
- package/dist/cli/client.js +58 -0
- package/dist/cli/daemon.d.ts +50 -0
- package/dist/cli/daemon.js +584 -0
- package/dist/cli/estate/Caddyfile +33 -0
- package/dist/cli/estate/quo.service +35 -0
- package/dist/cli/estate/systems.quo.plist +44 -0
- package/dist/cli/estate.d.ts +5 -0
- package/dist/cli/estate.js +50 -0
- package/dist/cli/folder.d.ts +2 -0
- package/dist/cli/folder.js +25 -0
- package/dist/cli/oauth.d.ts +2 -0
- package/dist/cli/oauth.js +32 -0
- package/dist/cli/pilot.d.ts +5 -0
- package/dist/cli/pilot.js +22 -0
- package/dist/cli/quo.d.ts +2 -0
- package/dist/cli/quo.js +201 -0
- package/dist/cli/stand.d.ts +37 -0
- package/dist/cli/stand.js +110 -0
- package/dist/dock/agents.d.ts +102 -0
- package/dist/dock/agents.js +105 -0
- package/dist/dock/apns.d.ts +27 -0
- package/dist/dock/apns.js +98 -0
- package/dist/dock/console.d.ts +6 -0
- package/dist/dock/console.js +20 -0
- package/dist/dock/dialers.d.ts +56 -0
- package/dist/dock/dialers.js +75 -0
- package/dist/dock/faculty.d.ts +24 -0
- package/dist/dock/faculty.js +142 -0
- package/dist/dock/fcm.d.ts +13 -0
- package/dist/dock/fcm.js +77 -0
- package/dist/dock/grants.d.ts +41 -0
- package/dist/dock/grants.js +99 -0
- package/dist/dock/http2.d.ts +4 -0
- package/dist/dock/http2.js +68 -0
- package/dist/dock/index.d.ts +41 -0
- package/dist/dock/index.js +113 -0
- package/dist/dock/local.d.ts +13 -0
- package/dist/dock/local.js +44 -0
- package/dist/dock/location.d.ts +19 -0
- package/dist/dock/location.js +11 -0
- package/dist/dock/notifications.d.ts +38 -0
- package/dist/dock/notifications.js +60 -0
- package/dist/dock/push.d.ts +79 -0
- package/dist/dock/push.js +132 -0
- package/dist/dock/service.d.ts +4 -0
- package/dist/dock/service.js +107 -0
- package/dist/dock/timer.d.ts +52 -0
- package/dist/dock/timer.js +149 -0
- package/dist/dock/webpush.d.ts +12 -0
- package/dist/dock/webpush.js +144 -0
- package/dist/harbor/browser.d.ts +15 -0
- package/dist/harbor/browser.js +82 -0
- package/dist/harbor/capacitor.d.ts +28 -0
- package/dist/harbor/capacitor.js +218 -0
- package/dist/harbor/disk.d.ts +27 -0
- package/dist/harbor/disk.js +249 -0
- package/dist/harbor/edge/alarm.d.ts +10 -0
- package/dist/harbor/edge/alarm.js +38 -0
- package/dist/harbor/edge/edge.d.ts +54 -0
- package/dist/harbor/edge/edge.js +370 -0
- package/dist/harbor/edge/exercise.d.ts +7 -0
- package/dist/harbor/edge/exercise.js +232 -0
- package/dist/harbor/edge/given.d.ts +26 -0
- package/dist/harbor/edge/given.js +42 -0
- package/dist/harbor/edge/platform.d.ts +39 -0
- package/dist/harbor/edge/storage.d.ts +30 -0
- package/dist/harbor/edge/storage.js +180 -0
- package/dist/harbor/edge/worker.d.ts +17 -0
- package/dist/harbor/edge/worker.js +67 -0
- package/dist/harbor/files.d.ts +15 -0
- package/dist/harbor/files.js +220 -0
- package/dist/harbor/http.d.ts +19 -0
- package/dist/harbor/http.js +177 -0
- package/dist/harbor/idb.d.ts +15 -0
- package/dist/harbor/idb.js +0 -0
- package/dist/harbor/quo.d.ts +10 -0
- package/dist/harbor/quo.js +42 -0
- package/dist/harbor/resolve.d.ts +16 -0
- package/dist/harbor/resolve.js +17 -0
- package/dist/harbor/seal.d.ts +3 -0
- package/dist/harbor/seal.js +25 -0
- package/dist/harbor/sealed.d.ts +35 -0
- package/dist/harbor/sealed.js +162 -0
- package/dist/harbor/tauri.d.ts +16 -0
- package/dist/harbor/tauri.js +59 -0
- package/dist/harbor/ward.d.ts +9 -0
- package/dist/harbor/ward.js +15 -0
- package/dist/human/app.d.ts +32 -0
- package/dist/human/app.js +527 -0
- package/dist/human/apps.d.ts +10 -0
- package/dist/human/apps.js +29 -0
- package/dist/human/dom.d.ts +2 -0
- package/dist/human/dom.js +15 -0
- package/dist/human/door.d.ts +19 -0
- package/dist/human/door.js +92 -0
- package/dist/human/guest.d.ts +3 -0
- package/dist/human/guest.js +33 -0
- package/dist/human/html.d.ts +55 -0
- package/dist/human/html.js +451 -0
- package/dist/human/local.d.ts +7 -0
- package/dist/human/local.js +10 -0
- package/dist/human/mark.d.ts +8 -0
- package/dist/human/mark.js +47 -0
- package/dist/human/move.d.ts +17 -0
- package/dist/human/move.js +90 -0
- package/dist/human/screen.d.ts +19 -0
- package/dist/human/screen.js +119 -0
- package/dist/human/style.d.ts +2 -0
- package/dist/human/style.js +60 -0
- package/dist/human/tab.bundle.txt +4775 -0
- package/dist/human/tab.d.ts +15 -0
- package/dist/human/tab.js +409 -0
- package/dist/human/tree.d.ts +50 -0
- package/dist/human/tree.js +157 -0
- package/dist/human/wake.d.ts +34 -0
- package/dist/human/wake.js +179 -0
- package/dist/human/web.d.ts +33 -0
- package/dist/human/web.js +184 -0
- package/dist/human/worker.bundle.txt +3868 -0
- package/dist/human/worker.d.ts +1 -0
- package/dist/human/worker.js +81 -0
- package/dist/human/worlds.d.ts +24 -0
- package/dist/human/worlds.js +99 -0
- package/dist/mcp/agent.d.ts +10 -0
- package/dist/mcp/agent.js +78 -0
- package/dist/mcp/allow.d.ts +20 -0
- package/dist/mcp/allow.js +88 -0
- package/dist/mcp/http.d.ts +27 -0
- package/dist/mcp/http.js +92 -0
- package/dist/mcp/oauth.d.ts +91 -0
- package/dist/mcp/oauth.js +241 -0
- package/dist/mcp/route.d.ts +15 -0
- package/dist/mcp/route.js +42 -0
- package/dist/mcp/runner.d.ts +45 -0
- package/dist/mcp/runner.js +99 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.js +102 -0
- package/dock/agents.ts +121 -0
- package/dock/apns.ts +138 -0
- package/dock/console.ts +23 -0
- package/dock/dialers.ts +85 -0
- package/dock/faculty.ts +148 -0
- package/dock/fcm.ts +103 -0
- package/dock/grants.ts +111 -0
- package/dock/http2.ts +70 -0
- package/dock/index.ts +133 -0
- package/dock/local.ts +48 -0
- package/dock/location.ts +22 -0
- package/dock/notifications.ts +67 -0
- package/dock/push.ts +161 -0
- package/dock/quo-app-bells.md +280 -0
- package/dock/quo-dock.md +1942 -0
- package/dock/service.ts +100 -0
- package/dock/timer.ts +174 -0
- package/dock/webpush.ts +182 -0
- package/harbor/browser.ts +97 -0
- package/harbor/capacitor.ts +223 -0
- package/harbor/disk.ts +237 -0
- package/harbor/edge/alarm.ts +48 -0
- package/harbor/edge/edge.ts +407 -0
- package/harbor/edge/exercise.ts +241 -0
- package/harbor/edge/given.ts +106 -0
- package/harbor/edge/platform.d.ts +39 -0
- package/harbor/edge/storage.ts +179 -0
- package/harbor/edge/text.d.ts +15 -0
- package/harbor/edge/worker.ts +70 -0
- package/harbor/edge/wrangler.toml +30 -0
- package/harbor/files.ts +221 -0
- package/harbor/http.ts +188 -0
- package/harbor/idb.ts +0 -0
- package/harbor/quo-harbor.md +850 -0
- package/harbor/quo.ts +44 -0
- package/harbor/resolve.ts +31 -0
- package/harbor/seal.ts +26 -0
- package/harbor/sealed.ts +183 -0
- package/harbor/tauri.ts +79 -0
- package/harbor/ward.ts +28 -0
- package/human/app.ts +580 -0
- package/human/apps.ts +47 -0
- package/human/dom.ts +21 -0
- package/human/door.ts +113 -0
- package/human/guest.ts +34 -0
- package/human/html.ts +490 -0
- package/human/local.ts +30 -0
- package/human/mark.ts +53 -0
- package/human/move.ts +122 -0
- package/human/quo-human.md +1042 -0
- package/human/screen.ts +136 -0
- package/human/style.ts +63 -0
- package/human/tab.bundle.txt +4775 -0
- package/human/tab.ts +446 -0
- package/human/tree.ts +217 -0
- package/human/wake.ts +191 -0
- package/human/web.ts +259 -0
- package/human/worker.bundle.txt +3868 -0
- package/human/worker.ts +124 -0
- package/human/worlds.ts +127 -0
- package/mcp/agent.ts +94 -0
- package/mcp/allow.ts +131 -0
- package/mcp/http.ts +92 -0
- package/mcp/oauth.ts +270 -0
- package/mcp/quo-mcp.md +343 -0
- package/mcp/route.ts +45 -0
- package/mcp/runner.ts +136 -0
- package/mcp/server.ts +101 -0
- package/package.json +121 -0
package/beings/carry.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// A carrier: a being who shows the asks of the standings she holds as asks
|
|
3
|
+
// of her own, and forwards. Whoever she carries for sees, in one describe,
|
|
4
|
+
// what she can be asked and what every being she holds can be asked, each
|
|
5
|
+
// under that standing's name; asking one is an ask on that standing, in her
|
|
6
|
+
// name, so the far being sees her and never who is behind her. A user being
|
|
7
|
+
// carries acme for the human's devices; a house being could carry its
|
|
8
|
+
// rooms; nothing here knows what she is.
|
|
9
|
+
//
|
|
10
|
+
// A carried ask is `<id>-<name>`, and the mapping back is kept in her cells
|
|
11
|
+
// and never parsed from the name, so an id with a dash in it is no trouble.
|
|
12
|
+
// The notes say which asks are whose, `standings: { id: { asks, look? } }`,
|
|
13
|
+
// so a screen draws one section per standing and a model side keeps the
|
|
14
|
+
// flat list it needs. Her own asks come first and are never shadowed: a
|
|
15
|
+
// carried name that collides with one of hers is dropped.
|
|
16
|
+
//
|
|
17
|
+
// She asks a standing's describe again when its digest moved, and its
|
|
18
|
+
// `look` once per digest, and keeps both in her cells. So a describe of
|
|
19
|
+
// hers may cost one ask per stale standing, which is the price of a page
|
|
20
|
+
// that is never more than one ask behind.
|
|
21
|
+
import { Being, isSilence, isWord, wordOf } from '@nervur-org/nervur';
|
|
22
|
+
import type { Asker, Blueprint, JsonObject, OccupantRecord, Reply } from '@nervur-org/nervur';
|
|
23
|
+
import { sanitise, type Look } from './look.ts';
|
|
24
|
+
|
|
25
|
+
type Carried = Record<string, { id: string; ask: string }>;
|
|
26
|
+
type Looks = Record<string, { digest: string | null; look: Look }>;
|
|
27
|
+
|
|
28
|
+
// The names a far being carries, read off her notes: every ask her
|
|
29
|
+
// `standings` groups name, and each group's page. Empty when she carries
|
|
30
|
+
// nothing, which a bare avatar does not.
|
|
31
|
+
function carriedBy(bp: Blueprint): Set<string> {
|
|
32
|
+
const out = new Set<string>();
|
|
33
|
+
const notes = bp.notes;
|
|
34
|
+
const groups = notes !== null && typeof notes === 'object' && !Array.isArray(notes) ? (notes as { standings?: unknown }).standings : undefined;
|
|
35
|
+
if (!groups || typeof groups !== 'object' || Array.isArray(groups)) return out;
|
|
36
|
+
for (const g of Object.values(groups as Record<string, { asks?: unknown; page?: unknown }>)) {
|
|
37
|
+
if (Array.isArray(g?.asks)) for (const n of g.asks) if (typeof n === 'string') out.add(n);
|
|
38
|
+
if (typeof g?.page === 'string') out.add(g.page);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class Carrier extends Being {
|
|
44
|
+
// Who sees what she carries. Nobody, until a subclass says who.
|
|
45
|
+
static carries(_occupant: OccupantRecord | undefined, _asker: Asker): boolean {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
// Standings that are plumbing: their own asks are never carried, and
|
|
49
|
+
// what they carry is. A way back to a device is one, by the dock's own
|
|
50
|
+
// convention, so a bare avatar's inbox never shows on her and a presence
|
|
51
|
+
// being's faculties do, under `to:<id>-<name>`, which is how home carries
|
|
52
|
+
// her phone. A subclass may name more.
|
|
53
|
+
static hidden(id: string): boolean {
|
|
54
|
+
return id.startsWith('to:');
|
|
55
|
+
}
|
|
56
|
+
// Standings she never reads for carrying at all: a presence being's
|
|
57
|
+
// standing at her own user being is one, since carrying it would carry
|
|
58
|
+
// the user being's carrying of her, and round. None, until a subclass
|
|
59
|
+
// says which.
|
|
60
|
+
static skips(_id: string): boolean {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// Which of the standings she carries this asker may see. Every one,
|
|
64
|
+
// until a subclass keeps some for fewer: a user being shows her own door
|
|
65
|
+
// to a device that may mint and to nobody else.
|
|
66
|
+
static shows(_id: string, _occupant: OccupantRecord | undefined, _asker: Asker): boolean {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private get carried(): Carried {
|
|
71
|
+
return ((this.cells.carried as Carried | undefined) ??= {});
|
|
72
|
+
}
|
|
73
|
+
private get looks(): Looks {
|
|
74
|
+
return ((this.cells.looks as Looks | undefined) ??= {});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Her describe with her standings carried into it, for an asker who may
|
|
78
|
+
// see them. Every other asker gets her describe alone.
|
|
79
|
+
async blueprint(asker: Asker): Promise<Blueprint> {
|
|
80
|
+
const C = this.constructor as typeof Carrier;
|
|
81
|
+
const bp = this.describe(asker);
|
|
82
|
+
if (!C.carries(this.occupant(asker), asker)) return bp;
|
|
83
|
+
const own = new Set(bp.asks.map((a) => a.name));
|
|
84
|
+
const carried: Carried = {};
|
|
85
|
+
const groups: Record<string, { asks: string[]; look?: Look }> = {};
|
|
86
|
+
const occ = this.occupant(asker);
|
|
87
|
+
// By id, and never in the order she happened to take them. Her cells keep
|
|
88
|
+
// standings in the order they were taken, which is the order a lend
|
|
89
|
+
// answered, a device came back or a relation was dropped and taken again:
|
|
90
|
+
// history, and no fact about her. Carried into her blueprint in that
|
|
91
|
+
// order, her shape would come out differently on two runs that made her
|
|
92
|
+
// the same way, and her digest with it. The digest is how everyone
|
|
93
|
+
// holding a standing on her learns she changed, so a shape that follows
|
|
94
|
+
// history says she changed when nothing about her did, and a watcher
|
|
95
|
+
// refreshes or walks away over the order two lends came back in.
|
|
96
|
+
for (const [id, rec] of [...Object.entries(this.cells.standings)].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
|
|
97
|
+
if (C.skips(id)) continue;
|
|
98
|
+
const st = this.standings[id];
|
|
99
|
+
if (!st) continue;
|
|
100
|
+
if (!rec.blueprint || rec.seen !== rec.digest) await st.ask(); // her ward writes the record
|
|
101
|
+
if (!rec.blueprint) continue;
|
|
102
|
+
// plumbing carries what it carries and nothing of its own: the names
|
|
103
|
+
// the far being's notes group under her standings, or none
|
|
104
|
+
const through = C.hidden(id) ? carriedBy(rec.blueprint) : null;
|
|
105
|
+
if (through && through.size === 0) continue;
|
|
106
|
+
// The mapping is written for every standing she carries, whoever is
|
|
107
|
+
// asking: it is one map in her cells, and the last describe must not
|
|
108
|
+
// decide what the next asker may call. Who sees a standing is decided
|
|
109
|
+
// here and again at answer, by `shows`.
|
|
110
|
+
const shown = C.shows(id, occ, asker);
|
|
111
|
+
// her look is kept here once per digest and never carried as an ask;
|
|
112
|
+
// her page follows every call, so it is carried as one and named in
|
|
113
|
+
// the notes, where every side finds it and none takes it for a form
|
|
114
|
+
const names: string[] = [];
|
|
115
|
+
const group: { asks: string[]; look?: Look; page?: string } = { asks: names };
|
|
116
|
+
for (const a of rec.blueprint.asks) {
|
|
117
|
+
if (a.name === 'look') continue;
|
|
118
|
+
if (through && !through.has(a.name)) continue;
|
|
119
|
+
const name = `${id}-${a.name}`;
|
|
120
|
+
if (own.has(name)) continue;
|
|
121
|
+
carried[name] = { id, ask: a.name };
|
|
122
|
+
if (!shown) continue;
|
|
123
|
+
bp.asks.push({ ...a, name });
|
|
124
|
+
if (a.name === 'page') group.page = name;
|
|
125
|
+
else names.push(name);
|
|
126
|
+
}
|
|
127
|
+
if (!shown) continue;
|
|
128
|
+
if (rec.blueprint.asks.some((a) => a.name === 'look')) {
|
|
129
|
+
const kept = this.looks[id];
|
|
130
|
+
if (!kept || kept.digest !== rec.digest) {
|
|
131
|
+
const l = await st.ask('look');
|
|
132
|
+
this.looks[id] = { digest: rec.digest, look: isSilence(l) || isWord(l) ? {} : sanitise(l) };
|
|
133
|
+
}
|
|
134
|
+
group.look = this.looks[id].look;
|
|
135
|
+
}
|
|
136
|
+
groups[id] = group;
|
|
137
|
+
}
|
|
138
|
+
for (const id of Object.keys(this.looks)) if (!(id in groups)) delete this.looks[id];
|
|
139
|
+
this.cells.carried = carried;
|
|
140
|
+
const notes = bp.notes !== null && typeof bp.notes === 'object' && !Array.isArray(bp.notes) ? bp.notes : {};
|
|
141
|
+
return { asks: bp.asks, notes: { ...notes, standings: groups as unknown as JsonObject } };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
override async answer(asker: Asker, method?: string, args: JsonObject = {}): Promise<Reply> {
|
|
145
|
+
if (method === undefined) return this.blueprint(asker);
|
|
146
|
+
const C = this.constructor as typeof Carrier;
|
|
147
|
+
const to = Object.hasOwn(this.carried, method) ? this.carried[method] : undefined;
|
|
148
|
+
const occ = this.occupant(asker);
|
|
149
|
+
if (to && C.carries(occ, asker) && C.shows(to.id, occ, asker)) {
|
|
150
|
+
const st = this.standings[to.id];
|
|
151
|
+
if (!st) return { error: 'unknown ask' };
|
|
152
|
+
const out = await st.ask(to.ask, args);
|
|
153
|
+
if (isSilence(out)) return out;
|
|
154
|
+
if (isWord(out)) return { error: wordOf(out) };
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
return super.answer(asker, method, args);
|
|
158
|
+
}
|
|
159
|
+
}
|