Custom Power
Build a custom Power with Actions, Hooks, System, Lifecycle, and a City module.
Custom Power contracts come from @downcity/city/power. City owns one Power instance per Power ID
and automatically exposes every registered Power to every Agent.
import {
Power,
create_action,
} from "@downcity/city/power";
class NotesPower extends Power {
readonly name = "notes";
readonly title = "Notes Helper";
readonly description = "Adds note-related actions.";
readonly actions = {
status: create_action({
execute: async ({ context }) => ({
success: true,
data: {
workspace_path: context.workspace.path,
storage_path: context.storage.path,
session_id: context.session?.id ?? null,
},
}),
}),
};
}
const city = new City({ powers: [new NotesPower()], workspaces: [workspace] });
city.agents.add(agent);Implement only the Actions, Hooks, Resolves, System, Availability, HTTP, or Lifecycle behavior the
domain actually needs. Use initialize/dispose for Power-owned resources and derive any internal
resource key from real domain ownership, not Workspace entry. Do not hide long-lived resources inside Hooks.
See Power Development for the complete module, manifest, Context, and testing model.