nervur 0.21.4 → 0.22.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/README.md +215 -158
- package/dist/browser.js +4 -3
- package/dist/cli.js +16 -0
- package/dist/{being → core/being}/being.js +10 -0
- package/dist/{being → core/being}/faculty.js +5 -2
- package/dist/{being → core/being}/index.d.ts +1 -1
- package/dist/{being → core/being}/index.js +1 -1
- package/dist/{being → core/being}/kind.d.ts +2 -0
- package/dist/{being → core/being}/kind.js +6 -0
- package/dist/{being → core/being}/types.js +1 -1
- package/dist/{browser → core/browser}/index.d.ts +6 -5
- package/dist/{browser → core/browser}/index.js +10 -10
- package/dist/{browser → core/browser}/worker.d.ts +2 -3
- package/dist/{browser → core/browser}/worker.js +8 -11
- package/dist/{cli → core/cli}/command.d.ts +4 -4
- package/dist/{cli → core/cli}/command.js +116 -66
- package/dist/{cli → core/cli}/edge.js +4 -2
- package/dist/core/cli/harbor.d.ts +25 -0
- package/dist/{cli → core/cli}/harbor.js +45 -33
- package/dist/{contract → core/contract}/index.d.ts +6 -5
- package/dist/{contract → core/contract}/index.js +8 -9
- package/dist/core/contract/link.d.ts +4 -0
- package/dist/core/contract/link.js +45 -0
- package/dist/{crypto → core/crypto}/ed25519.js +22 -14
- package/dist/core/crypto/subtle.d.ts +3 -0
- package/dist/core/crypto/subtle.js +11 -0
- package/dist/core/crypto/x25519.js +24 -0
- package/dist/core/edge/index.d.ts +164 -0
- package/dist/core/edge/index.js +739 -0
- package/dist/core/edge/kit.d.ts +2 -0
- package/dist/core/edge/kit.js +2 -0
- package/dist/core/git/http.d.ts +6 -0
- package/dist/core/git/http.js +102 -0
- package/dist/core/git/index.d.ts +5 -0
- package/dist/core/git/index.js +10 -0
- package/dist/core/git/object.d.ts +40 -0
- package/dist/core/git/object.js +103 -0
- package/dist/core/git/pack.d.ts +9 -0
- package/dist/core/git/pack.js +171 -0
- package/dist/core/git/store.d.ts +23 -0
- package/dist/core/git/store.js +120 -0
- package/dist/core/git/zlib.d.ts +6 -0
- package/dist/core/git/zlib.js +210 -0
- package/dist/core/harbor/carrying.d.ts +51 -0
- package/dist/core/harbor/carrying.js +69 -0
- package/dist/core/harbor/catalogue.d.ts +33 -0
- package/dist/core/harbor/catalogue.js +365 -0
- package/dist/core/harbor/dna.d.ts +13 -0
- package/dist/core/harbor/dna.js +120 -0
- package/dist/{harbor → core/harbor}/dock.d.ts +22 -13
- package/dist/core/harbor/dock.js +381 -0
- package/dist/core/harbor/harbor.d.ts +16 -0
- package/dist/core/harbor/harbor.js +438 -0
- package/dist/core/harbor/index.d.ts +11 -0
- package/dist/{harbor → core/harbor}/index.js +5 -5
- package/dist/core/harbor/memory.d.ts +10 -0
- package/dist/core/harbor/memory.js +25 -0
- package/dist/{harbor → core/harbor}/package.d.ts +0 -1
- package/dist/{harbor → core/harbor}/package.js +9 -9
- package/dist/core/harbor/probe.d.ts +22 -0
- package/dist/core/harbor/probe.js +15 -0
- package/dist/core/harbor/registry.d.ts +15 -0
- package/dist/{harbor → core/harbor}/registry.js +26 -10
- package/dist/core/harbor/root-line.d.ts +7 -0
- package/dist/core/harbor/root-line.js +9 -0
- package/dist/{harbor → core/harbor}/terrain.d.ts +9 -6
- package/dist/{harbor → core/harbor}/terrain.js +5 -4
- package/dist/core/http/index.d.ts +2 -0
- package/dist/{http → core/http}/index.js +3 -5
- package/dist/{line → core/line}/answer.d.ts +2 -2
- package/dist/{line → core/line}/frame.d.ts +0 -5
- package/dist/{line → core/line}/frame.js +0 -4
- package/dist/core/line/ground.js +7 -0
- package/dist/core/line/index.d.ts +4 -0
- package/dist/core/line/index.js +8 -0
- package/dist/core/line/web.d.ts +12 -0
- package/dist/{line → core/line}/web.js +13 -77
- package/dist/{node → core/node}/index.d.ts +2 -15
- package/dist/core/node/index.js +124 -0
- package/dist/{pointer → core/pointer}/bodies.d.ts +7 -5
- package/dist/core/pointer/bodies.js +118 -0
- package/dist/core/pointer/index.d.ts +2 -0
- package/dist/{pointer → core/pointer}/index.js +1 -1
- package/dist/{pointer → core/pointer}/world.d.ts +13 -9
- package/dist/{pointer → core/pointer}/world.js +31 -16
- package/dist/{proof → core/proof}/contracts.d.ts +6 -2
- package/dist/{proof → core/proof}/contracts.js +11 -10
- package/dist/core/proof/index.d.ts +3 -0
- package/dist/{proof → core/proof}/index.js +2 -2
- package/dist/core/proof/law.d.ts +25 -0
- package/dist/core/proof/law.js +715 -0
- package/dist/{tcp → core/tcp}/index.d.ts +7 -4
- package/dist/{tcp → core/tcp}/index.js +11 -62
- package/dist/{ward/ward.d.ts → core/ward/house.d.ts} +24 -10
- package/dist/core/ward/house.js +473 -0
- package/dist/core/ward/index.d.ts +5 -0
- package/dist/core/ward/index.js +7 -0
- package/dist/{ward → core/ward}/partition.d.ts +1 -0
- package/dist/{ward → core/ward}/stance.d.ts +2 -2
- package/dist/{ward → core/ward}/stance.js +5 -2
- package/dist/{ward/ward-being.d.ts → core/ward/ward.d.ts} +14 -6
- package/dist/core/ward/ward.js +140 -0
- package/dist/core.d.ts +10 -0
- package/dist/core.js +19 -0
- package/dist/defaults/dock/index.d.ts +4 -0
- package/dist/defaults/dock/index.js +11 -0
- package/dist/defaults/index.d.ts +5 -0
- package/dist/defaults/index.js +10 -0
- package/dist/defaults/memory/index.d.ts +12 -0
- package/dist/defaults/memory/index.js +39 -0
- package/dist/defaults/tcp/index.d.ts +16 -0
- package/dist/defaults/tcp/index.js +82 -0
- package/dist/defaults/ward/index.d.ts +4 -0
- package/dist/defaults/ward/index.js +11 -0
- package/dist/defaults/web/index.d.ts +15 -0
- package/dist/defaults/web/index.js +90 -0
- package/dist/edge.js +4 -3
- package/dist/index.d.ts +1 -8
- package/dist/index.js +13 -18
- package/dist/kit.d.ts +4 -0
- package/dist/kit.js +12 -0
- package/dist/node.js +4 -3
- package/package.json +23 -18
- package/src/browser.ts +4 -3
- package/src/cli.ts +15 -0
- package/src/{being → core/being}/being.ts +4 -0
- package/src/{being → core/being}/faculty.ts +5 -2
- package/src/{being → core/being}/index.ts +1 -1
- package/src/{being → core/being}/kind.ts +7 -0
- package/src/{being → core/being}/types.ts +1 -1
- package/src/{browser → core/browser}/index.ts +16 -13
- package/src/{browser → core/browser}/worker.ts +11 -14
- package/src/{cli → core/cli}/command.ts +113 -66
- package/src/{cli → core/cli}/edge.ts +4 -2
- package/src/{cli → core/cli}/harbor.ts +48 -31
- package/src/{contract → core/contract}/index.ts +14 -14
- package/src/core/contract/link.ts +58 -0
- package/src/{crypto → core/crypto}/ed25519.ts +22 -14
- package/src/core/crypto/subtle.ts +13 -0
- package/src/core/crypto/x25519.ts +23 -0
- package/src/core/edge/index.ts +865 -0
- package/src/core/git/http.ts +103 -0
- package/src/core/git/index.ts +10 -0
- package/src/core/git/object.ts +116 -0
- package/src/core/git/pack.ts +147 -0
- package/src/core/git/store.ts +122 -0
- package/src/core/git/zlib.ts +197 -0
- package/src/core/harbor/carrying.ts +124 -0
- package/src/core/harbor/catalogue.ts +386 -0
- package/src/core/harbor/dna.ts +116 -0
- package/src/core/harbor/dock.ts +420 -0
- package/src/core/harbor/harbor.ts +433 -0
- package/src/core/harbor/index.ts +14 -0
- package/src/core/harbor/memory.ts +31 -0
- package/src/{harbor → core/harbor}/package.ts +15 -15
- package/src/core/harbor/probe.ts +39 -0
- package/src/{harbor → core/harbor}/registry.ts +28 -11
- package/src/core/harbor/root-line.ts +19 -0
- package/src/{harbor → core/harbor}/terrain.ts +14 -7
- package/src/{http → core/http}/index.ts +5 -8
- package/src/{line → core/line}/answer.ts +3 -2
- package/src/{line → core/line}/frame.ts +0 -5
- package/src/core/line/ground.ts +18 -0
- package/src/core/line/index.ts +8 -0
- package/src/{line → core/line}/web.ts +1 -105
- package/src/core/node/index.ts +139 -0
- package/src/core/pointer/bodies.ts +122 -0
- package/src/core/pointer/index.ts +4 -0
- package/src/{pointer → core/pointer}/world.ts +45 -21
- package/src/{proof → core/proof}/contracts.ts +18 -13
- package/src/{proof → core/proof}/index.ts +3 -3
- package/src/core/proof/law.ts +742 -0
- package/src/{stand → core/stand}/stand.ts +2 -2
- package/src/{tcp → core/tcp}/index.ts +17 -74
- package/src/core/ward/house.ts +524 -0
- package/src/core/ward/index.ts +7 -0
- package/src/{ward → core/ward}/partition.ts +5 -1
- package/src/{ward → core/ward}/stance.ts +5 -2
- package/src/core/ward/ward.ts +166 -0
- package/src/core.ts +55 -0
- package/src/defaults/dock/index.ts +12 -0
- package/src/defaults/index.ts +10 -0
- package/src/defaults/memory/index.ts +50 -0
- package/src/defaults/tcp/index.ts +89 -0
- package/src/defaults/ward/index.ts +12 -0
- package/src/defaults/web/index.ts +97 -0
- package/src/edge.ts +4 -3
- package/src/index.ts +13 -50
- package/src/kit.ts +15 -0
- package/src/node.ts +4 -3
- package/dist/cli/harbor.d.ts +0 -16
- package/dist/cli/main.js +0 -14
- package/dist/crypto/subtle.d.ts +0 -10
- package/dist/crypto/subtle.js +0 -29
- package/dist/crypto/x25519.js +0 -21
- package/dist/edge/index.d.ts +0 -81
- package/dist/edge/index.js +0 -400
- package/dist/harbor/carrying.d.ts +0 -17
- package/dist/harbor/carrying.js +0 -38
- package/dist/harbor/catalogue.d.ts +0 -28
- package/dist/harbor/catalogue.js +0 -109
- package/dist/harbor/dock.js +0 -236
- package/dist/harbor/harbor.d.ts +0 -45
- package/dist/harbor/harbor.js +0 -347
- package/dist/harbor/index.d.ts +0 -11
- package/dist/harbor/probe.d.ts +0 -18
- package/dist/harbor/probe.js +0 -15
- package/dist/harbor/registry.d.ts +0 -10
- package/dist/harbor/relay.d.ts +0 -15
- package/dist/harbor/relay.js +0 -406
- package/dist/harbor/root-line.d.ts +0 -9
- package/dist/harbor/root-line.js +0 -38
- package/dist/harbor/store.d.ts +0 -13
- package/dist/harbor/store.js +0 -53
- package/dist/http/index.d.ts +0 -4
- package/dist/line/ground.js +0 -9
- package/dist/line/index.d.ts +0 -5
- package/dist/line/index.js +0 -9
- package/dist/line/push.d.ts +0 -7
- package/dist/line/push.js +0 -92
- package/dist/line/web.d.ts +0 -30
- package/dist/node/index.js +0 -236
- package/dist/pointer/bodies.js +0 -80
- package/dist/pointer/index.d.ts +0 -2
- package/dist/proof/index.d.ts +0 -3
- package/dist/proof/law.d.ts +0 -90
- package/dist/proof/law.js +0 -591
- package/dist/tcp/frame.d.ts +0 -25
- package/dist/tcp/frame.js +0 -64
- package/dist/ward/index.d.ts +0 -6
- package/dist/ward/index.js +0 -8
- package/dist/ward/pilot.d.ts +0 -8
- package/dist/ward/pilot.js +0 -50
- package/dist/ward/ward-being.js +0 -82
- package/dist/ward/ward.js +0 -290
- package/src/cli/main.ts +0 -13
- package/src/crypto/subtle.ts +0 -33
- package/src/crypto/x25519.ts +0 -21
- package/src/edge/index.ts +0 -490
- package/src/harbor/carrying.ts +0 -56
- package/src/harbor/catalogue.ts +0 -134
- package/src/harbor/dock.ts +0 -265
- package/src/harbor/harbor.ts +0 -381
- package/src/harbor/index.ts +0 -14
- package/src/harbor/probe.ts +0 -34
- package/src/harbor/relay.ts +0 -418
- package/src/harbor/root-line.ts +0 -39
- package/src/harbor/store.ts +0 -69
- package/src/line/ground.ts +0 -19
- package/src/line/index.ts +0 -9
- package/src/line/push.ts +0 -112
- package/src/node/index.ts +0 -241
- package/src/pointer/bodies.ts +0 -82
- package/src/pointer/index.ts +0 -4
- package/src/proof/law.ts +0 -591
- package/src/ward/index.ts +0 -8
- package/src/ward/pilot.ts +0 -50
- package/src/ward/ward-being.ts +0 -103
- package/src/ward/ward.ts +0 -328
- /package/dist/{cli/main.d.ts → cli.d.ts} +0 -0
- /package/dist/{being → core/being}/being.d.ts +0 -0
- /package/dist/{being → core/being}/digest.d.ts +0 -0
- /package/dist/{being → core/being}/digest.js +0 -0
- /package/dist/{being → core/being}/faculty.d.ts +0 -0
- /package/dist/{being → core/being}/types.d.ts +0 -0
- /package/dist/{being → core/being}/words.d.ts +0 -0
- /package/dist/{being → core/being}/words.js +0 -0
- /package/dist/{cli → core/cli}/edge.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/aes.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/aes.js +0 -0
- /package/dist/{crypto → core/crypto}/bytes.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/bytes.js +0 -0
- /package/dist/{crypto → core/crypto}/ed25519.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/hash.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/hash.js +0 -0
- /package/dist/{crypto → core/crypto}/index.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/index.js +0 -0
- /package/dist/{crypto → core/crypto}/json.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/json.js +0 -0
- /package/dist/{crypto → core/crypto}/mlkem.d.ts +0 -0
- /package/dist/{crypto → core/crypto}/mlkem.js +0 -0
- /package/dist/{crypto → core/crypto}/x25519.d.ts +0 -0
- /package/dist/{folder → core/folder}/index.d.ts +0 -0
- /package/dist/{folder → core/folder}/index.js +0 -0
- /package/dist/{http → core/http}/websocket.d.ts +0 -0
- /package/dist/{http → core/http}/websocket.js +0 -0
- /package/dist/{line → core/line}/answer.js +0 -0
- /package/dist/{line → core/line}/ground.d.ts +0 -0
- /package/dist/{proof → core/proof}/expect.d.ts +0 -0
- /package/dist/{proof → core/proof}/expect.js +0 -0
- /package/dist/{quo → core/quo}/address.d.ts +0 -0
- /package/dist/{quo → core/quo}/address.js +0 -0
- /package/dist/{quo → core/quo}/door.d.ts +0 -0
- /package/dist/{quo → core/quo}/door.js +0 -0
- /package/dist/{quo → core/quo}/index.d.ts +0 -0
- /package/dist/{quo → core/quo}/index.js +0 -0
- /package/dist/{quo → core/quo}/invitation.d.ts +0 -0
- /package/dist/{quo → core/quo}/invitation.js +0 -0
- /package/dist/{quo → core/quo}/keys.d.ts +0 -0
- /package/dist/{quo → core/quo}/keys.js +0 -0
- /package/dist/{quo → core/quo}/payload.d.ts +0 -0
- /package/dist/{quo → core/quo}/payload.js +0 -0
- /package/dist/{quo → core/quo}/relations.d.ts +0 -0
- /package/dist/{quo → core/quo}/relations.js +0 -0
- /package/dist/{quo → core/quo}/reply.d.ts +0 -0
- /package/dist/{quo → core/quo}/reply.js +0 -0
- /package/dist/{quo → core/quo}/seal.d.ts +0 -0
- /package/dist/{quo → core/quo}/seal.js +0 -0
- /package/dist/{quo → core/quo}/standing.d.ts +0 -0
- /package/dist/{quo → core/quo}/standing.js +0 -0
- /package/dist/{ward → core/ward}/allowance.d.ts +0 -0
- /package/dist/{ward → core/ward}/allowance.js +0 -0
- /package/dist/{ward → core/ward}/cells.d.ts +0 -0
- /package/dist/{ward → core/ward}/cells.js +0 -0
- /package/dist/{ward → core/ward}/partition.js +0 -0
- /package/src/{being → core/being}/digest.ts +0 -0
- /package/src/{being → core/being}/words.ts +0 -0
- /package/src/{crypto → core/crypto}/aes.ts +0 -0
- /package/src/{crypto → core/crypto}/bytes.ts +0 -0
- /package/src/{crypto → core/crypto}/hash.ts +0 -0
- /package/src/{crypto → core/crypto}/index.ts +0 -0
- /package/src/{crypto → core/crypto}/json.ts +0 -0
- /package/src/{crypto → core/crypto}/mlkem.ts +0 -0
- /package/src/{folder → core/folder}/index.ts +0 -0
- /package/src/{http → core/http}/websocket.ts +0 -0
- /package/src/{proof → core/proof}/expect.ts +0 -0
- /package/src/{quo → core/quo}/address.ts +0 -0
- /package/src/{quo → core/quo}/door.ts +0 -0
- /package/src/{quo → core/quo}/index.ts +0 -0
- /package/src/{quo → core/quo}/invitation.ts +0 -0
- /package/src/{quo → core/quo}/keys.ts +0 -0
- /package/src/{quo → core/quo}/payload.ts +0 -0
- /package/src/{quo → core/quo}/relations.ts +0 -0
- /package/src/{quo → core/quo}/reply.ts +0 -0
- /package/src/{quo → core/quo}/seal.ts +0 -0
- /package/src/{quo → core/quo}/standing.ts +0 -0
- /package/src/{stand → core/stand}/main.ts +0 -0
- /package/src/{ward → core/ward}/allowance.ts +0 -0
- /package/src/{ward → core/ward}/cells.ts +0 -0
|
@@ -1,47 +1,56 @@
|
|
|
1
|
-
import { type Asker, type AskSpec, type Blueprint, type Invitation, type JsonObject } from '../being/index.ts';
|
|
2
|
-
import {
|
|
1
|
+
import { type Asker, type AskSpec, type Blueprint, type Invitation, type JsonObject, type Stance } from '../being/index.ts';
|
|
2
|
+
import { Ward, type Lender, type WardStance } from '../ward/index.ts';
|
|
3
3
|
export interface Hosting {
|
|
4
|
-
host(name: string, invitation: Invitation, seed?: string,
|
|
4
|
+
host(name: string, invitation: Invitation, seed?: string, memory?: string, kind?: string, registry?: string): Promise<string | null>;
|
|
5
|
+
stand(hosted: Hosted): Promise<boolean>;
|
|
5
6
|
move(name: string, seed: string, from: string | undefined, to: string | undefined): Promise<string | null>;
|
|
6
|
-
release(name: string,
|
|
7
|
+
release(name: string, memory: string | undefined): Promise<void>;
|
|
7
8
|
route(pk: string, at: readonly string[] | null): boolean;
|
|
9
|
+
reached(pk: string, at: readonly string[]): void;
|
|
8
10
|
keep(): Promise<boolean>;
|
|
9
11
|
failures(): Failures;
|
|
10
12
|
readonly foreground: boolean;
|
|
11
13
|
sweep(): Promise<string[]>;
|
|
12
|
-
grounds(kind: string): boolean;
|
|
13
14
|
awaken(key: string): Promise<void>;
|
|
15
|
+
rouse(key: string): Promise<void>;
|
|
14
16
|
lull(key: string): Promise<void>;
|
|
17
|
+
listening(): string[];
|
|
18
|
+
heard(): Promise<void>;
|
|
15
19
|
}
|
|
16
20
|
export type Hosted = {
|
|
17
21
|
ward: string;
|
|
18
22
|
seed: string;
|
|
19
|
-
|
|
23
|
+
memory?: string;
|
|
24
|
+
registry?: string;
|
|
20
25
|
};
|
|
21
26
|
export type Failures = {
|
|
22
27
|
wards: Record<string, string>;
|
|
23
28
|
routes: Record<string, string>;
|
|
24
29
|
};
|
|
25
30
|
export declare const BOX = "box";
|
|
26
|
-
export
|
|
31
|
+
export type DockStance = WardStance & {
|
|
32
|
+
readonly ground: Hosting;
|
|
33
|
+
};
|
|
34
|
+
export declare const hostable: (C: unknown) => boolean;
|
|
35
|
+
export declare abstract class Dock extends Ward implements Lender {
|
|
27
36
|
#private;
|
|
28
37
|
static readonly kind: string;
|
|
29
38
|
static cells: JsonObject;
|
|
30
39
|
static asks: Record<string, AskSpec>;
|
|
31
|
-
constructor(stance:
|
|
40
|
+
constructor(stance: Stance);
|
|
41
|
+
stand(): Promise<JsonObject | undefined>;
|
|
32
42
|
describe(asker: Asker): Blueprint;
|
|
43
|
+
heard(): Promise<JsonObject>;
|
|
33
44
|
get hosted(): Hosted[];
|
|
34
45
|
get routes(): Record<string, string[]>;
|
|
35
46
|
get addresses(): string[];
|
|
36
47
|
route(args: JsonObject): JsonObject;
|
|
37
48
|
reach(args: JsonObject): JsonObject;
|
|
49
|
+
hold(args: JsonObject): Promise<JsonObject>;
|
|
38
50
|
learn(ward: string, at: readonly string[]): Promise<void>;
|
|
39
|
-
|
|
51
|
+
become(args: JsonObject): JsonObject;
|
|
52
|
+
boot(): Promise<JsonObject>;
|
|
40
53
|
unboot(args: JsonObject): Promise<JsonObject>;
|
|
41
|
-
standCarriers(opens: readonly {
|
|
42
|
-
key: string;
|
|
43
|
-
kind: string;
|
|
44
|
-
}[]): Promise<void>;
|
|
45
54
|
open(args: JsonObject): Promise<JsonObject>;
|
|
46
55
|
sweep(): Promise<JsonObject>;
|
|
47
56
|
host(args: JsonObject): Promise<JsonObject>;
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// The dock: the contract of the box ward's ward. Beside the root's asks of
|
|
3
|
+
// every ward, she opens faculties, hosts wards, and lends each contract a
|
|
4
|
+
// faculty fulfils to the wards she hosts. The core names no class of it:
|
|
5
|
+
// the terrain hands the harbor the one that stands at genesis. She is born
|
|
6
|
+
// of her stance alone, which carries her harbor as `ground`.
|
|
7
|
+
//
|
|
8
|
+
// She stands once the harbor has booted: its seed, its memory, the
|
|
9
|
+
// catalogue and every registry the catalogue resolves stand, and her class
|
|
10
|
+
// resolved through the registry her row names. The harbor hands her the
|
|
11
|
+
// door and is done; from there everything is an ask. Her `stand` is the
|
|
12
|
+
// second level, hers alone, asked by whoever holds the harbor or pilots
|
|
13
|
+
// it: every other faculty of the box, each once the registry it names
|
|
14
|
+
// stands, registries first, then memory faculties, then the rest; then
|
|
15
|
+
// every hosted ward, her house unpacked and her ward stood. A being of a
|
|
16
|
+
// hosted ward stands nowhere: she is born for the asks that reach her. It
|
|
17
|
+
// answers what stood, or silence where everything already stands. A
|
|
18
|
+
// faculty names its class and its registry, and keeps its cells in the box
|
|
19
|
+
// ward. A hosted ward names its class, its registry and the memory that
|
|
20
|
+
// keeps it.
|
|
21
|
+
//
|
|
22
|
+
// stand every faculty and hosted ward that does
|
|
23
|
+
// not stand yet, stood
|
|
24
|
+
// open { key, class, a faculty stands in the box ward, her class
|
|
25
|
+
// registry? } resolved through the registry faculty named
|
|
26
|
+
// or the catalogue, and the dock holds a
|
|
27
|
+
// standing on her under her key
|
|
28
|
+
// host { ward, seed?, a hosted ward stands under the seed named,
|
|
29
|
+
// memory?, class?, or a drawn one, of the ward class named or
|
|
30
|
+
// registry? } the default one, resolved with every class
|
|
31
|
+
// of the ward through the registry faculty
|
|
32
|
+
// named or the catalogue, holding a standing
|
|
33
|
+
// on the dock; the dock keeps its name, its
|
|
34
|
+
// seed, its registry and the memory faculty
|
|
35
|
+
// that keeps its place, or none for the root
|
|
36
|
+
// memory
|
|
37
|
+
// move { ward, memory } a hosted ward's place carried whole to
|
|
38
|
+
// another keeper, a memory faculty's key or
|
|
39
|
+
// null for the root memory, and forgotten
|
|
40
|
+
// where it was
|
|
41
|
+
// lend { contract } asked by a hosted ward: an offer from a
|
|
42
|
+
// faculty that fulfils the contract
|
|
43
|
+
// retract { contract, heir } an offer that was not taken
|
|
44
|
+
// route { ward, at } where a ward pk is reached, addresses in the
|
|
45
|
+
// order they are tried, or null to forget
|
|
46
|
+
// it; the dock keeps it and the harbor hands
|
|
47
|
+
// it to its carrier
|
|
48
|
+
// hold { name, invitation, a far being held as the ward's `hold`
|
|
49
|
+
// at? } holds it, its ward routed at the address
|
|
50
|
+
// named first
|
|
51
|
+
// reach { at } where this harbor is reached, the
|
|
52
|
+
// addresses every invitation it gives carries
|
|
53
|
+
// heard a push heard, told to every carrier faculty,
|
|
54
|
+
// so one that collects for this harbor
|
|
55
|
+
// collects
|
|
56
|
+
//
|
|
57
|
+
// Her census adds, for whoever pilots, what her cells keep, each hosted
|
|
58
|
+
// ward by name with its keeper and registry but never its seed, the routes
|
|
59
|
+
// and the reach; what did not stand; and every address the harbor's
|
|
60
|
+
// carriers listen at.
|
|
61
|
+
//
|
|
62
|
+
// A take of an invitation that carries `at` teaches the dock that ward's
|
|
63
|
+
// route, where the root set none.
|
|
64
|
+
import { Faculty, ships, WARD } from '../being/index.js';
|
|
65
|
+
import { Catalogue, CATALOGUE } from './catalogue.js';
|
|
66
|
+
import { MEMORY, MemoryFaculty } from './memory.js';
|
|
67
|
+
import { registers } from './registry.js';
|
|
68
|
+
import { readAt, readInvitation } from '../quo/index.js';
|
|
69
|
+
import { ownerAsk, pilots, rootAsk, Ward } from '../ward/index.js';
|
|
70
|
+
export const BOX = 'box';
|
|
71
|
+
const text = (v) => typeof v === 'string';
|
|
72
|
+
// A list of addresses, each a URI with a scheme, and at least one.
|
|
73
|
+
const addresses = (v) => Array.isArray(v) && v.length > 0 && readAt(v).length === v.length;
|
|
74
|
+
const hosted = (_, notes) => notes?.hosted === true;
|
|
75
|
+
// Whether a class is the catalogue's, which stands under `catalogue` alone.
|
|
76
|
+
const catalogues = (C) => C === Catalogue || (typeof C === 'function' && C.prototype instanceof Catalogue);
|
|
77
|
+
// Whether a class may be a hosted ward's: a ward, and no dock.
|
|
78
|
+
export const hostable = (C) => Ward.fulfils(C) && !Dock.fulfils(C);
|
|
79
|
+
export class Dock extends Ward {
|
|
80
|
+
static kind = 'org.nervur.dock';
|
|
81
|
+
static {
|
|
82
|
+
ships(this);
|
|
83
|
+
}
|
|
84
|
+
static cells = { hosted: [], routes: {}, reach: [] };
|
|
85
|
+
static asks = {
|
|
86
|
+
...Ward.asks,
|
|
87
|
+
stand: ownerAsk('every faculty and hosted ward that does not stand yet, stood; silence where everything stands'),
|
|
88
|
+
open: ownerAsk('a faculty of this harbor', { required: ['key', 'class'] }),
|
|
89
|
+
host: ownerAsk('a ward this harbor hosts, kept by the root memory or by the memory faculty named', { required: ['ward'] }),
|
|
90
|
+
move: ownerAsk('a hosted ward carried to a memory faculty, or to the root memory with null', { required: ['ward', 'memory'] }),
|
|
91
|
+
hold: ownerAsk('an owner invitation on a far being, held under a name from now on, at the address named', { required: ['name', 'invitation'] }),
|
|
92
|
+
route: ownerAsk('where a ward is reached, addresses in order, or null', { required: ['ward', 'at'] }),
|
|
93
|
+
reach: ownerAsk('where this harbor is reached, the addresses every invitation carries', { required: ['at'] }),
|
|
94
|
+
sweep: rootAsk('every place of the memory this harbor does not name, gone'),
|
|
95
|
+
heard: ownerAsk('a push heard, told to every carrier, so one that collects for this harbor collects'),
|
|
96
|
+
lend: { description: 'an offer from a faculty fulfilling a contract', input: { type: 'object', required: ['contract'] }, for: hosted },
|
|
97
|
+
retract: { description: 'an offer that was not taken', input: { type: 'object', required: ['contract', 'heir'] }, for: hosted },
|
|
98
|
+
};
|
|
99
|
+
#hosting;
|
|
100
|
+
constructor(stance) {
|
|
101
|
+
super(stance);
|
|
102
|
+
this.#hosting = stance.ground;
|
|
103
|
+
}
|
|
104
|
+
// The second level: every faculty of the box that does not stand yet,
|
|
105
|
+
// each once the registry she names stands, registries first, then
|
|
106
|
+
// memory faculties, then the rest; every route handed to the carrier;
|
|
107
|
+
// then every hosted ward and her ward. Asked once the harbor boots, and
|
|
108
|
+
// again whenever the code that runs moves, so it stands only what does
|
|
109
|
+
// not stand yet, and answers silence where everything already stands.
|
|
110
|
+
async stand() {
|
|
111
|
+
const stood = [...(await this.#standFaculties(registers)), ...(await this.#standFaculties((C) => C.prototype instanceof MemoryFaculty)), ...(await this.#standFaculties(() => true))];
|
|
112
|
+
for (const [pk, at] of Object.entries(this.routes))
|
|
113
|
+
this.#hosting.reached(pk, at);
|
|
114
|
+
const wards = [];
|
|
115
|
+
for (const row of this.hosted)
|
|
116
|
+
if (await this.#hosting.stand(row))
|
|
117
|
+
wards.push(row.ward);
|
|
118
|
+
return stood.length + wards.length > 0 ? { stood, wards } : undefined;
|
|
119
|
+
}
|
|
120
|
+
// The absent faculties whose class resolves now and fits, stood, again
|
|
121
|
+
// and again while one more stands, since a registry stood makes the
|
|
122
|
+
// classes named through it resolve.
|
|
123
|
+
async #standFaculties(fits) {
|
|
124
|
+
const stood = [];
|
|
125
|
+
for (let more = true; more;) {
|
|
126
|
+
more = false;
|
|
127
|
+
for (const [key, being] of Object.entries(this.steward.beings())) {
|
|
128
|
+
const C = being.absent ? this.steward.classOf(being.class, being.registry) : undefined;
|
|
129
|
+
if (!C || !fits(C) || this.steward.stand(key) !== 'booted')
|
|
130
|
+
continue;
|
|
131
|
+
more = true;
|
|
132
|
+
stood.push(key);
|
|
133
|
+
await this.#hosting.rouse(key);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return stood;
|
|
137
|
+
}
|
|
138
|
+
// The census adds what did not stand, for whoever pilots, and whether
|
|
139
|
+
// the harbor lives only as long as a screen.
|
|
140
|
+
describe(asker) {
|
|
141
|
+
const blueprint = super.describe(asker);
|
|
142
|
+
if (!pilots(asker, this.notes(asker)))
|
|
143
|
+
return blueprint;
|
|
144
|
+
const notes = blueprint.notes;
|
|
145
|
+
notes.wards = Object.fromEntries(this.hosted.map(({ ward, memory, registry }) => [ward, { ...(memory === undefined ? {} : { memory }), ...(registry === undefined ? {} : { registry }) }]));
|
|
146
|
+
notes.routes = this.routes;
|
|
147
|
+
notes.reach = this.addresses;
|
|
148
|
+
notes.failed = this.#hosting.failures();
|
|
149
|
+
notes.listening = this.#hosting.listening();
|
|
150
|
+
if (this.#hosting.foreground)
|
|
151
|
+
notes.foreground = true;
|
|
152
|
+
return blueprint;
|
|
153
|
+
}
|
|
154
|
+
async heard() {
|
|
155
|
+
await this.#hosting.heard();
|
|
156
|
+
return { heard: true };
|
|
157
|
+
}
|
|
158
|
+
get hosted() {
|
|
159
|
+
return this.cells.hosted.map(({ ward, seed, memory, registry }) => ({
|
|
160
|
+
ward,
|
|
161
|
+
seed,
|
|
162
|
+
...(memory === undefined ? {} : { memory }),
|
|
163
|
+
...(registry === undefined ? {} : { registry }),
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
// Whether a key names a memory faculty the dock opened.
|
|
167
|
+
#memory(key) {
|
|
168
|
+
return text(key) && this.#fulfilling(MEMORY).includes(key);
|
|
169
|
+
}
|
|
170
|
+
// The registry an ask names: none for the catalogue, the key of a
|
|
171
|
+
// registry faculty standing in the box, or no registry at all.
|
|
172
|
+
#registry(named) {
|
|
173
|
+
if (named === undefined || named === null || named === CATALOGUE)
|
|
174
|
+
return { registry: undefined };
|
|
175
|
+
if (!text(named))
|
|
176
|
+
return null;
|
|
177
|
+
const being = this.steward.beings()[named];
|
|
178
|
+
const C = being && !being.absent ? this.steward.classOf(being.class, being.registry) : undefined;
|
|
179
|
+
return registers(C) ? { registry: named } : null;
|
|
180
|
+
}
|
|
181
|
+
get routes() {
|
|
182
|
+
return Object.fromEntries(Object.entries(this.cells.routes).map(([pk, at]) => [pk, [...at]]));
|
|
183
|
+
}
|
|
184
|
+
// Where this harbor is reached, in the order a caller tries it.
|
|
185
|
+
get addresses() {
|
|
186
|
+
return [...this.cells.reach];
|
|
187
|
+
}
|
|
188
|
+
route(args) {
|
|
189
|
+
const { ward } = args;
|
|
190
|
+
const at = typeof args.at === 'string' ? [args.at] : args.at;
|
|
191
|
+
if (!text(ward) || (at !== null && !addresses(at)) || !this.#hosting.route(ward, at))
|
|
192
|
+
return { error: 'not routed' };
|
|
193
|
+
const routes = this.cells.routes;
|
|
194
|
+
if (at === null)
|
|
195
|
+
delete routes[ward];
|
|
196
|
+
else
|
|
197
|
+
routes[ward] = [...at];
|
|
198
|
+
return { routed: ward };
|
|
199
|
+
}
|
|
200
|
+
reach(args) {
|
|
201
|
+
if (!addresses(args.at))
|
|
202
|
+
return { error: 'at is a list of addresses' };
|
|
203
|
+
this.cells.reach = [...args.at];
|
|
204
|
+
return { reach: [...args.at] };
|
|
205
|
+
}
|
|
206
|
+
// A far ward held at the address named is routed there first, so the
|
|
207
|
+
// take reaches it where its invitation says nothing.
|
|
208
|
+
async hold(args) {
|
|
209
|
+
if (args.at !== undefined) {
|
|
210
|
+
if (!addresses([args.at]))
|
|
211
|
+
return { error: 'at is an address' };
|
|
212
|
+
const ward = readInvitation(args.invitation)?.ward;
|
|
213
|
+
if (ward === undefined)
|
|
214
|
+
return { error: 'no invitation' };
|
|
215
|
+
const routed = this.route({ ward, at: [args.at] });
|
|
216
|
+
if (routed.error !== undefined)
|
|
217
|
+
return routed;
|
|
218
|
+
}
|
|
219
|
+
return super.hold(args);
|
|
220
|
+
}
|
|
221
|
+
// A route learned from an invitation's `at`, where the root set none,
|
|
222
|
+
// and where the carrier dials one of its addresses.
|
|
223
|
+
async learn(ward, at) {
|
|
224
|
+
const routes = this.cells.routes;
|
|
225
|
+
if (Object.hasOwn(routes, ward) || !this.#hosting.route(ward, at))
|
|
226
|
+
return;
|
|
227
|
+
routes[ward] = [...at];
|
|
228
|
+
await this.#hosting.keep();
|
|
229
|
+
}
|
|
230
|
+
// The dock born again of a class, resolved through the catalogue or a
|
|
231
|
+
// registry the catalogue stands, since she stands before any other.
|
|
232
|
+
become(args) {
|
|
233
|
+
if (!text(args.class))
|
|
234
|
+
return { error: 'class is text' };
|
|
235
|
+
const through = this.#registry(args.registry);
|
|
236
|
+
if (through === null)
|
|
237
|
+
return { error: 'no such registry faculty' };
|
|
238
|
+
const { registry } = through;
|
|
239
|
+
if (registry !== undefined && this.steward.beings()[registry].registry !== undefined)
|
|
240
|
+
return { error: 'the dock stands through the catalogue or a registry it stands' };
|
|
241
|
+
const refused = this.steward.become(args.class, registry);
|
|
242
|
+
return refused === null ? { became: args.class } : { error: refused };
|
|
243
|
+
}
|
|
244
|
+
// The box ward holds faculties alone, and a faculty stands by `open`,
|
|
245
|
+
// which takes a standing on her.
|
|
246
|
+
boot() {
|
|
247
|
+
return Promise.resolve({ error: 'a faculty is opened, and nothing else stands in the box ward' });
|
|
248
|
+
}
|
|
249
|
+
// A faculty that goes stops listening first, and a memory faculty
|
|
250
|
+
// keeping a ward's place does not go.
|
|
251
|
+
async unboot(args) {
|
|
252
|
+
if (this.hosted.some((h) => h.memory !== undefined && h.memory === args.being))
|
|
253
|
+
return { error: 'a ward is kept by this memory faculty' };
|
|
254
|
+
if (typeof args.being === 'string')
|
|
255
|
+
await this.#hosting.lull(args.being);
|
|
256
|
+
return super.unboot(args);
|
|
257
|
+
}
|
|
258
|
+
// A faculty of any class the registry named resolves: a kit faculty
|
|
259
|
+
// resolves only where this ground ships it. The catalogue is the core's,
|
|
260
|
+
// and no ask opens one.
|
|
261
|
+
async open(args) {
|
|
262
|
+
if (!text(args.key) || !text(args.class))
|
|
263
|
+
return { error: 'key and class are text' };
|
|
264
|
+
const through = this.#registry(args.registry);
|
|
265
|
+
if (through === null)
|
|
266
|
+
return { error: 'no such registry faculty' };
|
|
267
|
+
const { registry } = through;
|
|
268
|
+
const C = this.steward.classOf(args.class, registry);
|
|
269
|
+
if (!Faculty.fulfils(C) || catalogues(C))
|
|
270
|
+
return { error: 'no such faculty' };
|
|
271
|
+
if ((await this.steward.boot(args.key, args.class, registry)) !== 'booted')
|
|
272
|
+
return { error: 'not opened' };
|
|
273
|
+
const invitation = await this.steward.invite(args.key, WARD, {});
|
|
274
|
+
if (invitation === null || (await this.stance.standings.take(args.key, invitation)) === null) {
|
|
275
|
+
this.steward.unboot(args.key);
|
|
276
|
+
return { error: 'not opened' };
|
|
277
|
+
}
|
|
278
|
+
await this.#hosting.awaken(args.key);
|
|
279
|
+
return { opened: args.key };
|
|
280
|
+
}
|
|
281
|
+
async sweep() {
|
|
282
|
+
return { swept: await this.#hosting.sweep() };
|
|
283
|
+
}
|
|
284
|
+
async host(args) {
|
|
285
|
+
const name = args.ward;
|
|
286
|
+
if (!text(name))
|
|
287
|
+
return { error: 'ward is text' };
|
|
288
|
+
if (name === BOX)
|
|
289
|
+
return { error: 'box is the box ward' };
|
|
290
|
+
if (this.hosted.some((h) => h.ward === name))
|
|
291
|
+
return { error: `${name} is hosted already` };
|
|
292
|
+
if (args.seed !== undefined && !text(args.seed))
|
|
293
|
+
return { error: 'seed is text' };
|
|
294
|
+
const memory = args.memory ?? undefined;
|
|
295
|
+
if (memory !== undefined && !this.#memory(memory))
|
|
296
|
+
return { error: 'no such memory faculty' };
|
|
297
|
+
const through = this.#registry(args.registry);
|
|
298
|
+
if (through === null)
|
|
299
|
+
return { error: 'no such registry faculty' };
|
|
300
|
+
const { registry } = through;
|
|
301
|
+
const kind = args.class ?? undefined;
|
|
302
|
+
if (kind !== undefined && (!text(kind) || !hostable(this.steward.classOf(kind, registry))))
|
|
303
|
+
return { error: 'no such ward class' };
|
|
304
|
+
const invitation = await this.stance.occupants.invite(name, { hosted: true });
|
|
305
|
+
if (invitation === null)
|
|
306
|
+
return { error: 'not hosted' };
|
|
307
|
+
const seed = await this.#hosting.host(name, invitation, args.seed, memory, kind, registry);
|
|
308
|
+
if (seed === null) {
|
|
309
|
+
this.stance.occupants.remove(name);
|
|
310
|
+
return { error: 'not hosted' };
|
|
311
|
+
}
|
|
312
|
+
this.cells.hosted.push({ ward: name, seed, ...(memory === undefined ? {} : { memory }), ...(registry === undefined ? {} : { registry }) });
|
|
313
|
+
return { hosted: name };
|
|
314
|
+
}
|
|
315
|
+
// The place is written where it goes before the dock's cells say so, and
|
|
316
|
+
// forgotten where it was only once they are kept, so a cut at any step
|
|
317
|
+
// leaves the ward whole under the keeper the cells name.
|
|
318
|
+
async move(args) {
|
|
319
|
+
const rows = this.cells.hosted;
|
|
320
|
+
const row = rows.find((h) => h.ward === args.ward);
|
|
321
|
+
if (!row)
|
|
322
|
+
return { error: 'no such ward' };
|
|
323
|
+
const to = args.memory ?? undefined;
|
|
324
|
+
if (to !== undefined && !this.#memory(to))
|
|
325
|
+
return { error: 'no such memory faculty' };
|
|
326
|
+
const from = row.memory;
|
|
327
|
+
if (from === to)
|
|
328
|
+
return { error: `${row.ward} is kept there already` };
|
|
329
|
+
const refused = await this.#hosting.move(row.ward, row.seed, from, to);
|
|
330
|
+
if (refused !== null)
|
|
331
|
+
return { error: refused };
|
|
332
|
+
const set = (memory) => {
|
|
333
|
+
if (memory === undefined)
|
|
334
|
+
delete row.memory;
|
|
335
|
+
else
|
|
336
|
+
row.memory = memory;
|
|
337
|
+
};
|
|
338
|
+
set(to);
|
|
339
|
+
if (!(await this.#hosting.keep())) {
|
|
340
|
+
set(from);
|
|
341
|
+
await this.#hosting.move(row.ward, row.seed, to, from);
|
|
342
|
+
return { error: 'not kept' };
|
|
343
|
+
}
|
|
344
|
+
await this.#hosting.release(row.ward, from);
|
|
345
|
+
return { moved: row.ward, memory: to ?? null };
|
|
346
|
+
}
|
|
347
|
+
async lend(args) {
|
|
348
|
+
if (!text(args.contract))
|
|
349
|
+
return { error: 'contract is text' };
|
|
350
|
+
const invitation = await this.offer(args.contract);
|
|
351
|
+
return invitation ? { invitation } : { error: 'nothing lent' };
|
|
352
|
+
}
|
|
353
|
+
async retract(args) {
|
|
354
|
+
if (!text(args.contract) || !text(args.heir))
|
|
355
|
+
return { error: 'contract and heir are text' };
|
|
356
|
+
await this.withdraw(args.contract, args.heir);
|
|
357
|
+
return { retracted: args.heir };
|
|
358
|
+
}
|
|
359
|
+
// Lender: the first standing faculty that fulfils the contract offers.
|
|
360
|
+
async offer(contract) {
|
|
361
|
+
for (const key of this.#fulfilling(contract)) {
|
|
362
|
+
const out = await this.stance.standings.get(key)?.ask('offer');
|
|
363
|
+
const invitation = readInvitation(out?.invitation);
|
|
364
|
+
if (invitation)
|
|
365
|
+
return invitation;
|
|
366
|
+
}
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
async withdraw(contract, heir) {
|
|
370
|
+
for (const key of this.#fulfilling(contract))
|
|
371
|
+
await this.stance.standings.get(key)?.ask('retract', { heir });
|
|
372
|
+
}
|
|
373
|
+
#fulfilling(contract) {
|
|
374
|
+
const beings = this.steward.beings();
|
|
375
|
+
return this.stance.standings.ids().filter((key) => {
|
|
376
|
+
const being = beings[key];
|
|
377
|
+
const C = being && !being.absent ? this.steward.classOf(being.class, being.registry) : undefined;
|
|
378
|
+
return Faculty.fulfils(C) && Faculty.contracts(C).includes(contract);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type JsonObject } from '../being/index.ts';
|
|
2
|
+
import { type Cataloguing } from './catalogue.ts';
|
|
3
|
+
import { type Ground } from './carrying.ts';
|
|
4
|
+
import { type Hosting } from './dock.ts';
|
|
5
|
+
import { type Probing } from './probe.ts';
|
|
6
|
+
import { Terrain } from './terrain.ts';
|
|
7
|
+
export type HarborGround = Hosting & Cataloguing & Ground;
|
|
8
|
+
export declare class Harbor {
|
|
9
|
+
#private;
|
|
10
|
+
private constructor();
|
|
11
|
+
static open(from?: Terrain | Probing): Promise<Harbor>;
|
|
12
|
+
ask(value: unknown): Promise<JsonObject>;
|
|
13
|
+
arrive(pk: string, bytes: Uint8Array): Promise<Uint8Array | null>;
|
|
14
|
+
holds(pk: string): boolean;
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
}
|