diff options
| author | Adam Malczewski <[email protected]> | 2026-06-05 01:22:21 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-05 01:22:21 +0900 |
| commit | 977ca522736bba53172e010494de5ac59fdb2a4a (patch) | |
| tree | b4e4a34fe7319e050e231e3bd7a840dc32562838 /packages/kernel/src/host/host.ts | |
| parent | 64e9688cc27ceea6eba442d156868d82d7aafb75 (diff) | |
| download | dispatch-977ca522736bba53172e010494de5ac59fdb2a4a.tar.gz dispatch-977ca522736bba53172e010494de5ac59fdb2a4a.zip | |
refactor(host): expose getHostAPI(); host-bin drops duplicate adapter; storage-sqlite manifest honesty
host CR-1: createHost.getHostAPI() returns the canonical post-activation HostAPI
(registration closed) via a single builder — host-bin deletes its
buildPostActivationHostAPI duplicate and calls host.getHostAPI().
storage-sqlite CR-2: remove false contributes.services:["storage"] (backend is a
kernel bootstrap dep injected as HostDeps.storageFactory, not a bus service);
document the intentional no-op activate.
typecheck clean, 218 tests pass, biome clean; live boot + curl verified.
Diffstat (limited to 'packages/kernel/src/host/host.ts')
| -rw-r--r-- | packages/kernel/src/host/host.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/kernel/src/host/host.ts b/packages/kernel/src/host/host.ts index 8592a16..dd61f9f 100644 --- a/packages/kernel/src/host/host.ts +++ b/packages/kernel/src/host/host.ts @@ -54,6 +54,7 @@ export interface Host { readonly getScheduledJobs: () => readonly ScheduledJob[]; readonly getMigrations: () => readonly string[]; readonly getDisabled: () => readonly DisabledExtension[]; + readonly getHostAPI: () => HostAPI; } export function createHost(extensions: readonly Extension[], deps: HostDeps): Host { @@ -95,15 +96,19 @@ export function createHost(extensions: readonly Extension[], deps: HostDeps): Ho } } - function buildHostAPI(): HostAPI { + function buildHostAPI(opts?: { readonly registrationClosed?: boolean }): HostAPI { + const closed = opts?.registrationClosed ?? false; return { defineTool(tool: ToolContract) { + if (closed) throw new Error("Registration not available after activation"); tools.set(tool.name, tool); }, defineProvider(provider: ProviderContract) { + if (closed) throw new Error("Registration not available after activation"); providers.set(provider.id, provider); }, defineAuth(auth: AuthContract) { + if (closed) throw new Error("Registration not available after activation"); authProviders.set(auth.id, auth); }, on<TPayload>(hook: EventHookDescriptor<TPayload>, handler: EventHandler<TPayload>) { @@ -201,5 +206,8 @@ export function createHost(extensions: readonly Extension[], deps: HostDeps): Ho getDisabled() { return disabled; }, + getHostAPI() { + return buildHostAPI({ registrationClosed: true }); + }, }; } |
