An open-source, self-hosted system for apps built with web technologies.
Route owned host capabilities
zohayrslileh216362fda5aa
diff --git a/package.json b/package.jsonindex 3b327a7..0244a8e 100644--- a/package.json+++ b/package.json@@ -30,7 +30,7 @@"build": "vite-node scripts/build.ts","start": "node --run build && node dist/server/main.js","pack": "node --run build && vite-node scripts/pack.ts",- "verify:contracts": "vite-node scripts/verify-client-launch.mjs && vite-node scripts/verify-client-surface.mjs && vite-node scripts/verify-window-geometry.mjs && vite-node scripts/verify-readiness.mjs && vite-node scripts/verify-endpoint-services.mjs && vite-node scripts/verify-intake-address.mjs && vite-node scripts/verify-theme.mjs",+ "verify:contracts": "vite-node scripts/verify-client-launch.mjs && vite-node scripts/verify-client-surface.mjs && vite-node scripts/verify-window-geometry.mjs && vite-node scripts/verify-readiness.mjs && vite-node scripts/verify-endpoint-services.mjs && vite-node scripts/verify-host-traffic.mjs && vite-node scripts/verify-intake-address.mjs && vite-node scripts/verify-theme.mjs","verify:distribution": "node scripts/verify-distribution.mjs","verify": "node --run check && node --run verify:contracts && node --run verify:distribution"},diff --git a/scripts/verify-endpoint-services.mjs b/scripts/verify-endpoint-services.mjsindex 333ee75..bee9d08 100644--- a/scripts/verify-endpoint-services.mjs+++ b/scripts/verify-endpoint-services.mjs@@ -15,13 +15,16 @@ const provider = process("provider")const conflicting = process("conflicting")const key = { program: "program", endpoint: "server", name: "counter" }const lifecycle = []+const registry = []const publications = []let disableTransportCompleted = false-assert.equal(services.disabled(key), true)+assert.equal(services.enabled(key), false)+assert.deepEqual(services.list(), [])assert.equal(services.service(provider, "server"), null)services.follow(key, "lifecycle", null, event => lifecycle.push(event))+services.followRegistry(null, (event, service) => registry.push([event, service]))services.follow(key, "lifecycle", "disable", async () => {await Promise.resolve()disableTransportCompleted = true@@ -30,9 +33,12 @@ services.follow(key, "lifecycle", "disable", async () => {await services.enable(provider, "server", { name: "counter", docs: "# Counter" })assert.deepEqual(services.service(provider, "server"), key)-assert.equal(services.disabled(key), false)+assert.equal(services.enabled(key), true)+assert.deepEqual(services.list(), [key])assert.equal(services.docs(key), "# Counter")assert.deepEqual(lifecycle, ["enable"])+assert.deepEqual(registry, [["enable", key]])+await services.waitReady(key, 0)// Subscriptions are future-only: joining after enable does not replay it.const lateLifecycle = []@@ -51,11 +57,14 @@ assert.deepEqual(publications, [2])await services.release(provider, "server")-assert.equal(services.disabled(key), true)+assert.equal(services.enabled(key), false)+assert.deepEqual(services.list(), [])assert.throws(() => services.docs(key), /disabled/)assert.deepEqual(lifecycle, ["enable", "disable"])assert.deepEqual(lateLifecycle, ["disable"])assert.equal(disableTransportCompleted, true)+assert.deepEqual(registry, [["enable", key], ["disable", key]])+await assert.rejects(() => services.waitReady(key, 0), /timeout/)// Once disabled, endpoint output is no longer mirrored into the service.await services.emit(provider, "server", "change", 3)@@ -69,8 +78,8 @@ await services.release(conflicting, "server")// Server and Client are distinct coordinates even under one Program and name.await services.enable(provider, "client", { name: "counter" })-assert.equal(services.disabled({ ...key, endpoint: "client" }), false)-assert.equal(services.disabled(key), true)+assert.equal(services.enabled({ ...key, endpoint: "client" }), true)+assert.equal(services.enabled(key), false)await services.release(provider, "client")await assert.rejects(() => services.enable(provider, "client", { name: "counter", docs: "no" }), /cannot provide/)diff --git a/scripts/verify-host-traffic.mjs b/scripts/verify-host-traffic.mjsnew file mode 100644index 0000000..786d000--- /dev/null+++ b/scripts/verify-host-traffic.mjs@@ -0,0 +1,30 @@+import assert from "node:assert/strict"+import HostTraffic from "../source/server/core/link-manager/auth-manager/process-manager/host-traffic.ts"++const traffic = new HostTraffic()+const hostProgram = []+const ownProgram = []+const hostProcess = []+const programProcess = []++traffic.observe("program", "uninstall", null, (_delivery, event, ...values) => hostProgram.push([event, ...values]))+traffic.observe("program", "uninstall", "program-reference", (_delivery, event, ...values) => ownProgram.push([event, ...values]))+traffic.observe("process", "create", null, (_delivery, event, ...values) => hostProcess.push([event, ...values]))+traffic.observe("process", "create", "program-reference", (_delivery, event, ...values) => programProcess.push([event, ...values]))++const program = { identity: "counter", reference: "program-reference" }+const process = { identity: "worker", reference: "process-reference" }++await traffic.emitHost("program", "uninstall", program.identity, program, true)++assert.deepEqual(hostProgram, [["uninstall", program.identity, program, true]])+assert.deepEqual(ownProgram, [])++await traffic.emitSubject("program", "uninstall", program.reference, true)++assert.deepEqual(ownProgram, [["uninstall", program.reference, true]])++await traffic.emit("process", "create", program.identity, program.reference, process)++assert.deepEqual(hostProcess, [["create", program.identity, process]])+assert.deepEqual(programProcess, [["create", program.reference, process]])diff --git a/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts b/source/client/core/link-manager/auth-manager/process-manager/process-manager.tsindex 2a42604..ea0b536 100644--- a/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts+++ b/source/client/core/link-manager/auth-manager/process-manager/process-manager.ts@@ -100,9 +100,14 @@ export default class ProcessManager extends TheLink {}/** Explicit snapshot for one exact service key. */- public async serviceDisabled(key: ServiceKey) {+ public async serviceEnabled(key: ServiceKey) {- return await this.$outbound.publishFirst("/service/disabled", key) as boolean+ return await this.$outbound.publishFirst("/service/enabled", key) as boolean+ }++ public async waitServiceReady(key: ServiceKey, timeout: number | undefined) {++ await this.$outbound.publishFirst("/service/wait-ready", key, timeout)}public async serviceDocs(key: ServiceKey) {diff --git a/source/client/view/desktop/client-host/announcements.ts b/source/client/view/desktop/client-host/announcements.tsindex 411166e..c16cba7 100644--- a/source/client/view/desktop/client-host/announcements.ts+++ b/source/client/view/desktop/client-host/announcements.ts@@ -145,7 +145,7 @@ export function created(authManager: AuthManager, panes: readonly (readonly [strif (!program) return []- return panes.filter(([, identity]) => identity === process.program).map(([pane]) => [pane, "host-end", "processCreate", program.reference, record(authManager, process)])+ return panes.filter(([, identity]) => identity === process.program).map(([pane]) => [pane, "program-process", "create", program.reference, record(authManager, process)])}// One ending, said to two subjects. A program watching its instances@@ -163,7 +163,7 @@ export function exited(authManager: AuthManager, panes: readonly (readonly [stri// the whole of one.return panes.filter(([, shown]) => shown === process.program).flatMap(([pane]) => [- [pane, "host-end", "processExit", owner(authManager, process).reference, record(authManager, process), code, signal],+ [pane, "program-process", "exit", owner(authManager, process).reference, record(authManager, process), code, signal],[pane, "process-host", "exit", process.reference, code, signal]@@ -176,7 +176,7 @@ export function endpoint(authManager: AuthManager, panes: readonly (readonly [streturn panes.filter(([, shown]) => shown === process.program).flatMap(([pane]) => [- [pane, "host-end", event, owner(authManager, process).reference, processRecord, endpointKind],+ [pane, "program-process", event, owner(authManager, process).reference, processRecord, endpointKind],[pane, "process-host", event, process.reference, processRecord, endpointKind]@@ -201,7 +201,7 @@ function owner(authManager: AuthManager, process: ExitedProcess) {// What comes with it is whether everything the system owned went too.export function uninstalled(panes: readonly (readonly [string, string | undefined])[], program: { identity: string, reference: string }, everythingRemoved: boolean): Offer[] {- return panes.filter(([, shown]) => shown === program.identity).map(([pane]) => [pane, "host-end", "uninstall", program.reference, everythingRemoved])+ return panes.filter(([, shown]) => shown === program.identity).map(([pane]) => [pane, "program-host", "uninstall", program.reference, everythingRemoved])}type ExitedProcess = { reference: string, identity: string, program: string, startedAt: Date, name: string | null, options: Record<string, string>, server: { ready: boolean } | null, client: { window: unknown } | null }diff --git a/source/client/view/desktop/client-host/host.ts b/source/client/view/desktop/client-host/host.tsindex 3c5be45..a63abdc 100644--- a/source/client/view/desktop/client-host/host.ts+++ b/source/client/view/desktop/client-host/host.ts@@ -85,7 +85,7 @@ export default function host(authManager: AuthManager, pane: string, desktop: ()// When it started is a fact about this process, which a pane may// already ask everything else about — it was missing on this side// only because it was added on the other.- if (word === "process") return [record(process())]+ if (word === "current-process") return [record(process())]if (word === "theme") return [authManager.linkManager.theme.value]@@ -152,11 +152,18 @@ export default function host(authManager: AuthManager, pane: string, desktop: ()return [await processManager.endpointService(pane, address(target), args[1])]}- if (word === "service-disabled") {+ if (word === "service-enabled") {if (!isServiceKey(args[0])) throw new Error("A complete service key is required")- return [await processManager.serviceDisabled(args[0])]+ return [await processManager.serviceEnabled(args[0])]+ }++ if (word === "service-wait-ready") {++ if (!isServiceKey(args[0])) throw new Error("A complete service key is required")++ return [await processManager.waitServiceReady(args[0], args[1] as number | undefined)]}if (word === "service-docs") {@@ -241,16 +248,16 @@ export default function host(authManager: AuthManager, pane: string, desktop: ()// Every instance of this pane's program, this one among them: a// program's two halves must not disagree about how many of it// are running. Nothing is named — the program is the frame's.- if (word === "processes") {+ if (word === "program-process-list") {return [scope.processes().map(record)]}// One process of this program by immutable identity or by its// living program-local name. An exact identity always wins.- if (word === "program-process") {+ if (word === "program-process-find") {- const wanted = String(args[1])+ const wanted = String(args[0])const found = scope.findProcess(wanted)@@ -263,16 +270,16 @@ export default function host(authManager: AuthManager, pane: string, desktop: ()// kit's end knows only what the caller could already have// guessed, which is how the process a program starts was the one// process that did not know when it started.- if (word === "create-process") {+ if (word === "program-process-create") {- const started = await programManager.createProcess(process().program, args[1] as Launch, process().identity)+ const started = await programManager.createProcess(process().program, args[0] as Launch, process().identity)return [record(scope.requireProcess(started))]}// Every instance ended, the asker last. One implementation on the// core serves this and a server half both.- if (word === "exit-all") return [await processManager.exitAll(process().program, pane)]+ if (word === "program-process-exit-all") return [await processManager.exitAll(process().program, pane)]if (word === "observe") {@@ -420,7 +427,7 @@ export default function host(authManager: AuthManager, pane: string, desktop: ()// half has no disk, and where the machine put things is not a// program's own word about itself.- if (word === "program") {+ if (word === "current-program") {const program = scope.program()diff --git a/source/server/core/link-manager/auth-manager/process-manager/endpoint-services.ts b/source/server/core/link-manager/auth-manager/process-manager/endpoint-services.tsindex 0f5542a..f70aa11 100644--- a/source/server/core/link-manager/auth-manager/process-manager/endpoint-services.ts+++ b/source/server/core/link-manager/auth-manager/process-manager/endpoint-services.ts@@ -38,7 +38,10 @@ export default class EndpointServices extends TheLink {this.owners.set(owner, identity)- await this.$inbound.publish(this.event(key, "lifecycle", "enable"), "enable", undefined)+ await Promise.all([+ this.$inbound.publish(this.event(key, "lifecycle", "enable"), "enable", undefined),+ this.$inbound.publish(this.registryEvent("enable"), "enable", key)+ ])return key}@@ -67,7 +70,10 @@ export default class EndpointServices extends TheLink {this.bindings.delete(identity)- await this.$inbound.publish(this.event(binding.key, "lifecycle", "disable"), "disable", undefined)+ await Promise.all([+ this.$inbound.publish(this.event(binding.key, "lifecycle", "disable"), "disable", undefined),+ this.$inbound.publish(this.registryEvent("disable"), "disable", binding.key)+ ])return true}@@ -79,9 +85,45 @@ export default class EndpointServices extends TheLink {return identity ? this.bindings.get(identity)?.key ?? null : null}- public disabled(key: unknown) {+ public list() {- return !this.bindings.has(this.identity(this.key(key)))+ return Object.freeze([...this.bindings.values()].map(binding => binding.key))+ }++ public enabled(key: unknown) {++ return this.bindings.has(this.identity(this.key(key)))+ }++ public async waitReady(key: unknown, timeout: unknown = 10_000) {++ const resolved = this.key(key)++ if (typeof timeout !== "number" || !Number.isFinite(timeout) || timeout < 0) throw new Error("A service readiness timeout must be a non-negative finite number")++ if (this.enabled(resolved)) return++ await new Promise<void>((resolve, reject) => {++ let settled = false++ const finish = (complete: () => void) => {++ if (settled) return++ settled = true+ clearTimeout(timer)+ stop()+ complete()+ }+ const stop = this.$inbound.subscribe(this.registryEvent("enable"), (_event, enabled) => {++ if (this.identity(this.key(enabled)) === this.identity(resolved)) finish(resolve)+ })+ const timer = setTimeout(() => finish(() => reject(new Error("The service did not become ready before the timeout"))), timeout)++ if (this.enabled(resolved)) finish(resolve)+ })}public docs(key: unknown) {@@ -132,6 +174,20 @@ export default class EndpointServices extends TheLink {}, prefix)}+ public followRegistry(event: string | null, subscriber: Subscriber) {++ const prefix = "registry/"++ if (event !== null) {++ if (event !== "enable" && event !== "disable") throw new Error("A service registry event must be enable or disable")++ return this.$inbound.subscribe(this.registryEvent(event), (_word, key) => subscriber(event, key))+ }++ return this.$inbound.forwardTo((word, _event, key) => subscriber(decodeURIComponent(word), key), prefix)+ }+private key(value: unknown) {if (!isServiceKey(value)) throw new Error("A complete service key is required")@@ -178,6 +234,11 @@ export default class EndpointServices extends TheLink {return this.prefix(key, scope) + encodeURIComponent(event)}++ private registryEvent(event: string) {++ return `registry/${encodeURIComponent(event)}`+ }}export type ServiceScope = Scopediff --git a/source/server/core/link-manager/auth-manager/process-manager/host-traffic.ts b/source/server/core/link-manager/auth-manager/process-manager/host-traffic.tsindex 5e91fc8..9403350 100644--- a/source/server/core/link-manager/auth-manager/process-manager/host-traffic.ts+++ b/source/server/core/link-manager/auth-manager/process-manager/host-traffic.ts@@ -3,42 +3,51 @@ import TheLink from "@libs/the-link/the-link"/** Host announcements routed only into Process boundaries that requested them. */export default class HostTraffic extends TheLink {- public async emit(event: string, publicSubject: string, scopedSubject: string, ...values: unknown[]) {+ public emitHost(domain: Domain, event: string, subject: string, ...values: unknown[]) {++ return this.$inbound.publish(this.event(domain, null, event), {}, subject, ...values)+ }++ public async emit(domain: Domain, event: string, publicSubject: string, scopedSubject: string, ...values: unknown[]) {const delivery = {}const deliveries = [- this.$inbound.publish(this.event(null, event), delivery, publicSubject, ...values),- this.$inbound.publish(this.event(scopedSubject, event), delivery, scopedSubject, ...values)+ this.$inbound.publish(this.event(domain, null, event), delivery, publicSubject, ...values),+ this.$inbound.publish(this.event(domain, scopedSubject, event), delivery, scopedSubject, ...values)]await Promise.all(deliveries)}- /** Emits a Process-scoped fact without also exposing it as a host event. */- public emitSubject(event: string, subject: string, ...values: unknown[]) {+ /** Emits an entity-scoped fact without also exposing it as a Host-registry event. */+ public emitSubject(domain: Domain, event: string, subject: string, ...values: unknown[]) {- return this.$inbound.publish(this.event(subject, event), {}, subject, ...values)+ return this.$inbound.publish(this.event(domain, subject, event), {}, subject, ...values)}- public observe(event: string | null, subject: string | null, subscriber: Subscriber) {+ public observe(domain: Domain, event: string | null, subject: string | null, subscriber: Subscriber) {- const prefix = this.prefix(subject)+ const prefix = this.prefix(domain, subject)if (event !== null) return this.$inbound.subscribe(prefix + encodeURIComponent(event), (delivery, ...values) => subscriber(delivery as object, event, ...values))return this.$inbound.forwardTo((word, delivery, ...values) => subscriber(delivery as object, decodeURIComponent(word), ...values), prefix)}- private prefix(subject: string | null) {+ private prefix(domain: Domain, subject: string | null) {- return subject === null ? "all/" : `subject/${encodeURIComponent(subject)}/`+ return subject === null ? `${domain}/all/` : `${domain}/subject/${encodeURIComponent(subject)}/`}- private event(subject: string | null, event: string) {+ private event(domain: Domain, subject: string | null, event: string) {- return this.prefix(subject) + encodeURIComponent(event)+ return this.prefix(domain, subject) + encodeURIComponent(event)}}type Subscriber = (delivery: object, event: string, ...values: unknown[]) => unknown++export type HostDomain = Domain++type Domain = "program" | "process" | "window"diff --git a/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts b/source/server/core/link-manager/auth-manager/process-manager/process-manager.tsindex 7bd97be..9a240be 100644--- a/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts+++ b/source/server/core/link-manager/auth-manager/process-manager/process-manager.ts@@ -588,9 +588,9 @@ export default class ProcessManager extends TheLink {await Promise.all([- this.announce(event, process.program.identity, process.program.reference, record, endpoint),+ this.announce("process", event, process.program.identity, process.program.reference, record, endpoint),- this.hostTraffic.emitSubject(event, process.reference, record, endpoint)+ this.hostTraffic.emitSubject("process", event, process.reference, record, endpoint)])}@@ -715,7 +715,7 @@ export default class ProcessManager extends TheLink {//// An unscoped listener — `host` — is built for no subject and so// receives the subject as its first value.- await this.announce("processCreate", program.identity, program.reference, processReference(process))+ await this.announce("process", "create", program.identity, program.reference, processReference(process))await this.$outbound.publish("/created", process.hosted())@@ -776,12 +776,12 @@ export default class ProcessManager extends TheLink {// the process, whole, not an identity a listener would have to look// up. It is already gone, which is what `exited()` answers and// why holding it is legitimate.- await this.announce("processExit", process.program.identity, process.program.reference, processReference(process), code, signal)+ await this.announce("process", "exit", process.program.identity, process.program.reference, processReference(process), code, signal)// The same ending, said to whoever holds this one process rather// than to whoever watches the program. A launcher wants the// second; a program managing its instances wants the first.- await this.hostTraffic.emitSubject("exit", process.reference, code, signal)+ await this.hostTraffic.emitSubject("process", "exit", process.reference, code, signal)// The window that had it is gone, so nobody is told they lost// it — only whoever inherits it is told they have it.@@ -1042,10 +1042,16 @@ export default class ProcessManager extends TheLink {return this.services.service(held, endpoint)}- @Connect("/service/disabled")- protected async serviceDisabled(key: unknown) {+ @Connect("/service/enabled")+ protected async serviceEnabled(key: unknown) {- return this.services.disabled(key)+ return this.services.enabled(key)+ }++ @Connect("/service/wait-ready")+ protected async waitServiceReady(key: unknown, timeout: unknown) {++ await this.services.waitReady(key, timeout)}@Connect("/service/docs")@@ -1160,9 +1166,21 @@ export default class ProcessManager extends TheLink {// Host facts enter only the Process boundaries whose endpoint subscriptions// established a matching the-link route.- public async announce(event: string, publicSubject: string, scopedSubject: string, ...values: unknown[]) {+ public async announce(domain: "program" | "process", event: string, publicSubject: string, scopedSubject: string, ...values: unknown[]) {++ await this.hostTraffic.emit(domain, event, publicSubject, scopedSubject, ...values)+ }++ /** Announces one fact only through an authoritative Host registry. */+ public async announceHost(domain: "program" | "process", event: string, subject: string, ...values: unknown[]) {- await this.hostTraffic.emit(event, publicSubject, scopedSubject, ...values)+ await this.hostTraffic.emitHost(domain, event, subject, ...values)+ }++ /** Announces one fact only to observers of an exact Program or Process subject. */+ public async announceSubject(domain: "program" | "process", event: string, subject: string, ...values: unknown[]) {++ await this.hostTraffic.emitSubject(domain, event, subject, ...values)}/** Reads the effective permission decision for one live Client Process. */@@ -1245,7 +1263,7 @@ export default class ProcessManager extends TheLink {const process = this.processes.get(identity)- if (process?.client) this.hostTraffic.emitSubject(event, process.reference, value).catch(() => undefined)+ if (process?.client) this.hostTraffic.emitSubject("window", event, process.reference, value).catch(() => undefined)this.$outbound.publish("/said", identity, event, value).catch(() => undefined)}@@ -1260,15 +1278,19 @@ export default class ProcessManager extends TheLink {const programManager = this.authManager.programManager- if (word === "programs") return [[...programManager.programs.values()].filter(entry => rest[0] !== true || entry.installed)]+ if (word === "host-program-list") return [[...programManager.programs.values()].filter(entry => rest[0] !== true || entry.installed)]- if (word === "program") {+ if (word === "host-program-find") {- const identity = typeof rest[0] === "string" ? rest[0] : process.program.identity+ const identity = String(rest[0])- return [programManager.find(identity)]+ return [programManager.programs.get(identity) ?? null]}+ if (word === "current-program") return [programManager.find(process.program.identity)]++ if (word === "current-process") return [processReference(process)]+if (word === "icon") {return [await programManager.icon(this.heldProgram(rest[0], process.program).identity, rest[1])]@@ -1281,7 +1303,7 @@ export default class ProcessManager extends TheLink {return [await programManager.startup(program, String(rest[1]), rest[2])]}- if (word === "permissions") {+ if (word === "program-permission") {const program = this.heldProgram(rest[0], process.program)const operation = rest[1]@@ -1312,7 +1334,7 @@ export default class ProcessManager extends TheLink {throw new Error(`The host does not know the permission operation "${String(operation)}"`)}- // Which live process made this one through `program.createProcess()`.+ // Which live process made this one through `program.process.create()`.// The child retains a handle, but the registry remains authoritative:// once the parent disappears that retained handle no longer resolves.if (word === "parent") {@@ -1329,7 +1351,7 @@ export default class ProcessManager extends TheLink {// A program brought into being by a program enters the same// registry and returns the same record shape as every other// program. Its installed flag begins false.- if (word === "create-program") {+ if (word === "host-program-create") {const source = rest[0]@@ -1417,7 +1439,7 @@ export default class ProcessManager extends TheLink {return [await programManager.forget(program, process.identity)]}- if (word === "create-process") {+ if (word === "program-process-create") {const program = this.heldProgram(rest[0])@@ -1430,11 +1452,11 @@ export default class ProcessManager extends TheLink {}// Named, only that program's instances; unnamed, every one.- if (word === "processes") {+ if (word === "host-process-list" || word === "program-process-list") {const living = [...this.processes.values()]- if (rest[0] === undefined) return [living.map(processReference)]+ if (word === "host-process-list") return [living.map(processReference)]// Resolved before it is filtered. Filtering alone answered// an empty list for a program the system does not know,@@ -1447,7 +1469,7 @@ export default class ProcessManager extends TheLink {return [living.filter(entry => entry.program === program).map(processReference)]}- if (word === "program-process") {+ if (word === "program-process-find") {const program = this.heldProgram(rest[0])@@ -1462,11 +1484,16 @@ export default class ProcessManager extends TheLink {return [found ? processReference(found) : null]}- if (word === "process") {+ if (word === "host-process-find") {++ if (typeof rest[0] === "string") {- const target = typeof rest[0] === "string" ? this.find(rest[0]) : this.heldProcess(rest[0], process)+ const target = this.processes.get(rest[0])- return [processReference(target)]+ return [target ? processReference(target) : null]+ }++ return [null]}if (word === "exists") {@@ -1523,7 +1550,11 @@ export default class ProcessManager extends TheLink {return [this.services.service(endpoint, rest[1])]}- if (word === "service-disabled") return [this.services.disabled(rest[0])]+ if (word === "host-service-list") return [this.services.list()]++ if (word === "service-enabled") return [this.services.enabled(rest[0])]++ if (word === "service-wait-ready") return [await this.services.waitReady(rest[0], rest[1])]if (word === "service-docs") return [this.services.docs(rest[0])]@@ -1549,6 +1580,24 @@ export default class ProcessManager extends TheLink {return []}+ if (word === "service-registry-follow") {++ const [subscription, event] = rest++ if (typeof subscription !== "string" || event !== null && typeof event !== "string") return []++ process.server?.followServiceRegistry(this.services, subscription, event)++ return []+ }++ if (word === "service-registry-unfollow") {++ process.server?.unfollowService(String(rest[0]))++ return []+ }+if (word === "service-send") {const [key, event, payload] = rest@@ -1702,7 +1751,7 @@ export default class ProcessManager extends TheLink {return [target.identity]}- if (word === "exit-all") return [await this.exitAll(this.heldProgram(rest[0]).identity, process.identity)]+ if (word === "program-process-exit-all") return [await this.exitAll(this.heldProgram(rest[0]).identity, process.identity)]if (word === "observe") {diff --git a/source/server/core/link-manager/auth-manager/process-manager/process.ts b/source/server/core/link-manager/auth-manager/process-manager/process.tsindex f92b7f2..dceaef6 100644--- a/source/server/core/link-manager/auth-manager/process-manager/process.ts+++ b/source/server/core/link-manager/auth-manager/process-manager/process.ts@@ -71,7 +71,7 @@ export default class Process {// lifetime originate here. Stopping the client destroys this value whole.public client: ClientState | null = null- // The process whose call to `program.createProcess()` created this+ // The process whose call to `program.process.create()` created this// one. Lineage only: keeping this handle neither owns nor prolongs// either life.public readonly parent: Process | nulldiff --git a/source/server/core/link-manager/auth-manager/process-manager/server-process-boundary.ts b/source/server/core/link-manager/auth-manager/process-manager/server-process-boundary.tsindex 4c18441..9bb19e7 100644--- a/source/server/core/link-manager/auth-manager/process-manager/server-process-boundary.ts+++ b/source/server/core/link-manager/auth-manager/process-manager/server-process-boundary.ts@@ -219,6 +219,21 @@ export default class ServerProcessBoundary extends ProcessLink {this.serviceSubscriptions.delete(subscription)}+ /** Follows lifecycle changes across the authoritative service registry. */+ public followServiceRegistry(services: EndpointServices, subscription: string, event: string | null) {++ this.unfollowService(subscription)++ const stop = services.followRegistry(event, (word, key) => {++ const values = event === null ? [word, key] : [key]++ return this.deliver("service-registry-event", subscription, ...values)+ })++ this.serviceSubscriptions.set(subscription, stop)+ }+/** Remove a question whether it is waiting here or inside the SDK. */public forget(question: string) {@@ -337,11 +352,16 @@ export default class ServerProcessBoundary extends ProcessLink {}- if (route === "host-events" || route === "host-end" || route === "process-host") {+ const hostDomain = route === "host-program" || route === "program-host" ? "program"+ : route === "host-process" || route === "program-process" || route === "process-host" ? "process"+ : route === "host-end" ? "window"+ : null++ if (hostDomain) {this.hostSubscriptions.get(subscription)?.()- this.hostSubscriptions.set(subscription, this.hostTraffic.observe(event, subject, (_delivery, word, ...values) => {+ this.hostSubscriptions.set(subscription, this.hostTraffic.observe(hostDomain, event, subject, (_delivery, word, ...values) => {this.deliver(route, word, ...values).catch(() => undefined)}))diff --git a/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts b/source/server/core/link-manager/auth-manager/program-manager/program-manager.tsindex 19855bf..99b50ed 100644--- a/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts+++ b/source/server/core/link-manager/auth-manager/program-manager/program-manager.ts@@ -269,7 +269,7 @@ export default class ProgramManager extends TheLink {// replayed event history, so only runtime registrations use this.private async created(entry: Entry) {- await this.authManager.processManager.announce("programCreate", entry.identity, entry.program.reference, entry)+ await this.authManager.processManager.announceHost("program", "create", entry.identity, entry)await this.$outbound.publish("/create", entry.hosted())}@@ -705,7 +705,7 @@ export default class ProgramManager extends TheLink {if (createdHere) await this.created(entry)- await this.authManager.processManager.announce("programInstall", entry.identity, entry.program.reference, entry)+ await this.authManager.processManager.announceHost("program", "install", entry.identity, entry)// Said to the sessions, though none of them may ask for it.// `@Connect` used to be both the road in and the echo out,@@ -781,9 +781,9 @@ export default class ProgramManager extends TheLink {entry.installed = false- await this.authManager.processManager.announce("programUninstall", entry.identity, entry.program.reference, entry, everything)+ await this.authManager.processManager.announceHost("program", "uninstall", entry.identity, entry, everything)- await this.authManager.processManager.announce("uninstall", entry.identity, entry.program.reference, everything)+ await this.authManager.processManager.announceSubject("program", "uninstall", entry.program.reference, everything)await this.$outbound.publish("/uninstall", entry.hosted(), everything)@@ -812,9 +812,9 @@ export default class ProgramManager extends TheLink {this.programs.delete(entry.identity)- await this.authManager.processManager.announce("programForget", entry.identity, entry.program.reference, entry)+ await this.authManager.processManager.announceHost("program", "forget", entry.identity, entry)- await this.authManager.processManager.announce("forget", entry.identity, entry.program.reference)+ await this.authManager.processManager.announceSubject("program", "forget", entry.program.reference)await this.$outbound.publish("/forget", entry.identity)