Skip to content
Moku
@moku-labs/ai pages

registry

The task, provider, handler map. It keeps tasks and providers from importing each other.

On this page

What it does

registry is a map from a task and a provider to a handler. Provider plugins fill it in onInit. The runner and the task facades read it. It never looks inside a handler: the owning task plugin or the runner narrows it.

Config

None.

API

Mounted at app.registry, reachable with ctx.require(registryPlugin).

MethodSignatureDescription
register(task: string, provider: string, handler: unknown) => voidAdds a handler. Throws on a duplicate pair.
resolve(task: string, provider: string) => unknownThe handler, or undefined when it is not registered.
providers(task: string) => string[]The providers of a task, in registration order.
tasks() => string[]Every task with at least one provider.
list.ts
import { app } from "./app";

for (const task of app.registry.tasks()) {
  console.log(task, app.registry.providers(task));
}

The first provider of a task is the fallback for a build file item with no provider. To add one, see Add a provider.

Events

Emits

None.

Listens to

None.

Depends on

Nothing. Every task and provider plugin depends on it.