@prismshadow/penguin-server · packages/server/src/mechanisms/plugins.ts:48

PluginModules

interface

PluginModules: a library plugin's server modules, brought along when the plugin is installed on an Agent (PRFC-0031), as services/plugin-modules.ts implements it. Everything it touches survives a re-assembly — the files, the database, the channel hub and the plugin host claimed per call — so a caller may still use it after ensure swapped the App.

API

@Interface()
export abstract class PluginModules {
  abstract status(projectId: string, viewer: ModuleActor): Promise<PluginModuleStatus[]>;
  abstract ensure(
      projectId: string,
      plugins: readonly string[],
      actor: ModuleActor | null,
      ask: "install" | "explicit",
      agentId?: string,
    ): Promise<PluginModuleAction[]>;
  abstract preinstall(projectId: string): Promise<void>;
  abstract askForPackage(
      projectId: string,
      pkg: string,
      actor: ModuleActor,
      agentId: string | null,
    ): Promise<PluginModuleAction[]>;
  abstract requests(): Promise<PluginModuleRequestsResponse>;
  abstract decide(
      pkg: string,
      decision: "enable" | "decline",
      admin: ModuleActor,
    ): Promise<PluginModuleRequestsResponse>;
}

Contract Topology

Static AST wiring across @Module / @Provide / @Use

Members (6)

status

status(projectId: string, viewer: ModuleActor): Promise<PluginModuleStatus[]>

Every library plugin that carries server modules, as it stands here and for this Project.

@paramprojectIdstring
@paramviewerModuleActor
@returnsPromise<PluginModuleStatus[]>

ensure

ensure(projectId: string, plugins: readonly string[], actor: ModuleActor | null, ask: "install" | "explicit", agentId?: string): Promise<PluginModuleAction[]>

Applies the rule (plugin/module-rule.ts) to the named library plugins; a plugin without server modules is passed over. actor null is the system: built-in modules only, and it never asks. It may re-assemble the App, so a caller calls it last: after it, only what survives a swap is still this generation's. Never while the App boots. Never throws for one plugin: what went wrong is that plugin's failed action.

@paramprojectIdstring
@parampluginsreadonly string[]
@paramactorModuleActor | null
@paramask"install" | "explicit"
@paramagentId?string
@returnsPromise<PluginModuleAction[]>

preinstall

preinstall(projectId: string): Promise<void>

Lists the preinstalled built-in modules (PRFC-0030, plugin/preinstall.ts) in this server's own table of a Project just created, by the same rule with the system as the actor: one write for all of them, and a re-assembly only when that changes the closure. A module the administrator stopped is passed over. Called last by the creation, for the reason ensure is. Never throws: what went wrong is a log line, and the Project stands.

@paramprojectIdstring
@returnsPromise<void>

askForPackage

askForPackage(projectId: string, pkg: string, actor: ModuleActor, agentId: string | null): Promise<PluginModuleAction[]>

A member's ask for a package that is not on this server yet (05 「插件库」 「安装模型」): a request for the administrator, whose enable installs it on the server first. A standing request is left as it is.

@paramprojectIdstring
@parampkgstring
@paramactorModuleActor
@paramagentIdstring | null
@returnsPromise<PluginModuleAction[]>

requests

requests(): Promise<PluginModuleRequestsResponse>

The ledger, joined with each module's state.

@returnsPromise<PluginModuleRequestsResponse>

decide

decide(pkg: string, decision: "enable" | "decline", admin: ModuleActor): Promise<PluginModuleRequestsResponse>

The administrator's enable or decline of one package; 404 unknown_request without a row, 409 project_gone for an enable whose Project is gone. Declining an enabled module stops it: it leaves this server's own table of every Project. Enabling a preinstalled module (PRFC-0030) lists it in this server's own table of every Project again, whatever Project its row names.

@parampkgstring
@paramdecision"enable" | "decline"
@paramadminModuleActor
@returnsPromise<PluginModuleRequestsResponse>