@aglyn/plugins-ai

中文文档
1.19.0发布于 2026/11/07Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 9880

The AI plugin for Aglyn: the in-console assistant, the Besigner copy assistant, generative building and automation jobs, and the usage metering and access controls around them. It is provider-generic: every feature talks to a provider contract, and vendor

原始使用文档
文档目录5 节
  1. Install
  2. What's in it
  3. Usage
  4. How it fits
  5. License

@aglyn/plugins-ai

The AI plugin for Aglyn: the in-console assistant, the Besigner copy assistant, generative building and automation jobs, and the usage metering and access controls around them. It is provider-generic: every feature talks to a provider contract, and vendor specifics live only under src/lib/providers. Install it if you run the Aglyn console and want AI features in it; it is a first-party plugin, not a standalone library.

Published to npm from the Aglyn monorepo. Versions follow semantic versioning.

Install

npm install @aglyn/plugins-ai

Peer dependencies: react, next, @mui/material, @mui/x-data-grid, firebase, and firebase-admin for the server entries.

What's in it

On a published site. Nothing. The plugin has no site registrar, and the tenant runtime loads no server surface of it, so nothing that serves a published site can reach a provider. What a job builds (a page, a component, a form) is saved as ordinary Aglyn documents.

Console (registerAiConsole, the console and staff registrar in plugins.config.json). The plugin adds no nav item. Everything is mounted through zones the console shell and other plugins host, so no console page imports it:

  • The assistant, drawn in the console dock (consoleDock) and a provider the shell mounts around every console page for the Besigner copy assistant, with controls in the besignerToolbar and besignerInspector slots.
  • The AI jobs indicator in the console's top bar (consoleTopBar): what the workspace's jobs are doing, and the way to them.
  • "Create with AI" entry points and cards on a site's pages list and its components, layouts, templates, forms, email templates, products, theme, SEO, automations and Functions & Variables pages (hostScreens, hostComponents, hostLayouts, hostTemplates, hostForms, hostEmailTemplates, productsCreate, hostTheme, hostSeo, seoFields, hostAutomations, automationEditor, automationRun, hostLogic, logicFunctionEditor, logicReferenceIssue, hostFirstRun, orgSites).
  • Cards in zones other plugins host: product copy, import and the products hub (productEditor, productImport, productsHub), record insights, email drafts and import column matching (recordInsights, recordEmail, importMapping), A/B test variants and results (experimentVariants, experimentResult), overlay copy and new overlays on the Marketing page (overlayEditor, hostOverlays), a campaign from a brief on its Campaigns section (hostCampaigns), the figures in words on its Conversions section and campaign reports (marketingInsights), and a funnel drafted from a description and its results explained (funnelsCreate, funnelInsight).
  • Usage and access: credit and usage cards on billing (orgBillingUsage), per-member cards and columns (orgMember, orgMembersListColumn, hostMembers), and staff cards, columns and one staff page (staffOrg, staffUser, staffOrgsListColumn, staffOrgUsageColumn).

Server (registerAiConsoleApi, the consoleApi registrar, exported from @aglyn/plugins-ai/server). It registers the first-party providers, every job kind, and the routes under the ai and assist prefixes with registerPluginApiRoute:

  • Assistant: assist/chat, assist/feedback, assist/edit-applied, ai/assist.
  • Jobs: ai/jobs, ai/jobs/batch, ai/jobs/:jobId/cancel, ai/jobs/:jobId/resume, ai/jobs/:jobId/events, the scheduled jobs beat, ai/insights/:jobId, ai/crm/:jobId, ai/seo/apply, ai/experiments/versions, ai/generate/component.
  • Usage and access: ai/usage, ai/allotments, ai/models, ai/host-permissions, ai/billing/credits, ai/billing/overage.
  • Staff: ai/admin/org, ai/admin/orgs-spend, ai/admin/user, ai/admin/signals, ai/admin/overage, ai/admin/credits.

Declarations. Three light entries the core reads before any surface loads:

  • registerAiDeclarations (@aglyn/plugins-ai/declarations, also exported from .): the plugin's entitlements, its config schema and its activity codes. Idempotent.
  • registerAiServerDeclarations (@aglyn/plugins-ai/declarations.server): platform event subscriptions, the account-erasure sweep for a person's AI usage, and the usage alert contributor.
  • aiSubprocessors (@aglyn/plugins-ai/subprocessors): the third-party hosts the registered providers send data to, for the subprocessor inventory.

Source layout under src/lib

  • providers/: the provider contract (AiProvider), the registry (AI_PROVIDER_CONTRACT, registerAiProvider), the model catalog, the routing table, and two adapters, anthropic.ts and openai-compatible.ts.
  • runtime/: the one runtime every route calls (runAiRequest), the gate, the answer cache, the palette and the node-tree validator.
  • jobs/: the generation job machine, its steps and the beat.
  • tools/: the tool definitions the job steps hand a provider.
  • usage/ and billing/: the meter every route reserves and records through, per-member allotments, and overage.
  • insights/, activity/, model/: figure readers and the digest, activity codes, and the job and usage shapes the cards and routes share, free of any server dependency.
  • components/: the dock, the cards and the staff page.

Usage

The plugin is loaded through Aglyn's plugin manager: the console's generated loader manifests import the package and call the registrars named in plugins.config.json. An app that wires plugins by hand calls them once at startup:

// console, client side
import { registerAiConsole } from '@aglyn/plugins-ai'
registerAiConsole()

// console, server side
import { registerAiConsoleApi } from '@aglyn/plugins-ai/server'
registerAiConsoleApi()

Adding a provider. Another plugin registers its own adapter against the same contract from its server entry; the first-party adapters register themselves only when no provider is registered yet, so one registered earlier is not displaced:

import { registerAiProvider, type AiProvider } from '@aglyn/plugins-ai/server'

declare const myProvider: AiProvider
registerAiProvider(myProvider, { pluginId: 'my-plugin' })

An AiProvider names the environment variable that carries its key (apiKeyEnv), reads it itself (readApiKey), lists its models, and implements complete and stream. The platform default provider is the one named by the AI_PROVIDER environment variable when it is registered, otherwise the first registered; AI_DEFAULT_MODEL overrides the model for every step kind.

How it fits

A plugin package (scope:plugin). It depends on the core (@aglyn/aglyn), the tenant packages (@aglyn/tenant-runtime, @aglyn/tenant-data-admin, @aglyn/tenant-feature-instance) and generic @aglyn/shared-* packages. It imports no other plugin. Where a job writes another plugin's resource, such as a campaign, an email design or an automation, that plugin registers a draft writer on a core seam and this one calls the seam; where a job reads another plugin's figures or records, that plugin registers a reader. The core never imports this package, and only src/lib/server.* is declared as having side effects.

License

Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/plugins/ai

版本与发布记录

@aglyn/plugins-ai 共发布 162 个版本,首次发布于 2026/09/21;过去 12 个月发布了 162 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.19.0latest2026/11/07今天
1.18.02026/11/07今天
1.17.02026/11/07今天
1.16.02026/11/07今天
1.15.22026/11/061 天前
1.15.12026/11/061 天前

其他发布通道:beta → 1.0.0-beta.296。

关于 @aglyn/plugins-ai 的常见问题

@aglyn/plugins-ai 是什么?

The AI plugin for Aglyn: the in-console assistant, the Besigner copy assistant, generative building and automation jobs, and the usage metering and access controls around them. It is provider-generic: every feature talks to a provider contract, and vendor

如何安装 @aglyn/plugins-ai?

在项目目录运行 npm install @aglyn/plugins-ai,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:next(^16.3.3)、react(^19.2.8)、firebase(^13.0.0)、@mui/material(^9.3.1)、firebase-admin(^14.3.0)、@mui/x-data-grid(^9.12.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aglyn/plugins-ai 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aglyn/plugins-ai 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@aglyn/plugins-ai 可以商用吗?

@aglyn/plugins-ai 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aglyn/plugins-ai 的下载量有多少?

根据 npm 官方下载统计,@aglyn/plugins-ai 在 2026/10/05 – 2026/11/03 这 30 天内被下载 9,880 次,日均约 329 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aglyn/plugins-ai 还在维护吗?

最新版本 1.19.0 发布于 2026/11/07(今天);至今共发布 162 个版本,其中过去 12 个月发布了 162 个;首次发布于 2026/09/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。