@cat-factory/binary-generators

中文文档
0.3.86发布于 2026/11/06TypeScriptES Module构建来源已验证近 30 天下载 4798

The built-in generative binary integrations (Nano Banana, Google's Gemini image models) plus the authoring seam a deployment defines its own with, written entirely through the public BinaryGeneratorRegistry seam: depends only on @cat-factory/kernel + @cat

原始使用文档
文档目录4 节
  1. Why the platform ships one at all
  2. Using it
  3. The credential
  4. Writing your own

@cat-factory/binary-generators

The generative binary integrations the platform ships, plus the seam a deployment writes its own with. These are the metered vendor APIs a binary-output step calls to produce its artifacts, as opposed to the foundational service the artifacts are then stored through.

idWhat it makesModalities
nano-bananaImages with legible text in them, and conversational editing, up to 4Kimage (image/png, image/jpeg)

Why the platform ships one at all

defaultBinaryGeneratorRegistry() is still empty, and the reasoning that kept it empty still holds: no image API is one every organisation runs, and every one of them is metered. What changed is the Media task type. It ships a generating agent kind, a preset and the storage underneath, and its step selected nothing, so the platform's most demonstrable capability was reachable only by a deployment that first wrote an integration, an OpenAPI document and a credential declaration.

Metered is answered by the credential rather than by the registry. With no key resolved the agent is told the integration is unavailable and reports it as the reason an artifact is missing, so a deployment that ignores this package pays nothing and sees one extra row in a picker.

Using it

Every facade defaults its registry to the shipped set, so nothing is needed to get nano-banana:

await start({/* … */}) // binaryGeneratorRegistry defaults to binaryGeneratorRegistryWithBuiltins()

An injected registry REPLACES the default rather than merging with it, so a deployment adding its own integrations starts from the built-ins:

import { binaryGeneratorRegistryWithBuiltins } from '@cat-factory/node-server'

const binaryGeneratorRegistry = binaryGeneratorRegistryWithBuiltins()
binaryGeneratorRegistry.registerAll(myIntegrations)
await start({ binaryGeneratorRegistry })

That matters more here than for the gate or prompt-fragment registries, because the shipped pl_media preset SELECTS nano-banana by id: a registry without it refuses that pipeline's runs at admission (binary_output_generator_invalid) rather than degrading quietly. Dropping the shipped integration is a legitimate choice; editing that preset's step is the other half of it.

Register once per deployment, on the process that owns the registry. In mothership mode that is the mothership: a node resolves integrations over /internal/binary-generators and consults no registry of its own, so the set the pipeline builder offers and the set admission resolves are one set however far behind the node's build has drifted.

On the Worker the registry is also held process-wide (infrastructure/binaryGenerators.ts), the same way the deployment's binary artifact stores are and for the same reason: that runtime builds a container per entry point, and a binary-output step's dispatch brief is composed on the durable path, which takes no options at all. createWorker({ overrides: { binaryGeneratorRegistry } }) registers on your behalf, so a deployment using the documented seam needs to know none of that. What made this one easy to miss is that an override-less build resolves the SHIPPED set rather than nothing, so an unregistered integration is absent from a brief that otherwise looks populated.

The credential

nano-banana authenticates with GEMINI_API_KEY, an API key from Google AI Studio, sent as the x-goog-api-key header. The name is the vendor's own, so an agent reaching for google-genai finds the value where the library looks.

Set it either as a workspace capability credential (subject binary-generator, id nano-banana, key GEMINI_API_KEY) or in the environment the deployment dispatches runs from. The value travels on the job body alone and is injected into the agent's process for that job; it is never written to the checkout, the prompt or a log.

Do not add it to docs/environment-variables.md: every variable documented there is reserved by check-reserved-env-keys.mjs, which would make this key unresolvable.

Billing must be enabled on the Google project. None of these models has a free tier, so an unbilled key gets FAILED_PRECONDITION on the first call, which the agent reports as the reason nothing was generated.

Writing your own

defineBinaryGenerator is exported for exactly this, and re-exported from each facade so a deployment reaches it from the package it already depends on. It runs the platform's OWN registration rules at import (the definition schema, plus binaryGeneratorDetailIssues: the endpoint policy, the contract-set rules, the media-type classifier, the harness check and the capability-versus-accepted-values pairing), so a definition that would fail a boot fails a test instead:

import { defineBinaryGenerator, openApiContract } from '@cat-factory/binary-generators'

export const acmeImages = defineBinaryGenerator({
  id: 'acme-images',
  name: 'Acme Images',
  summary: 'One line the picker and the agent brief show.',
  description: 'What it is good at, what it is NOT for, and its cost profile.',
  modalities: ['image'],
  mediaTypes: ['image/png'],
  capabilities: ['seed', 'exact-size'],
  endpoint: 'https://api.acme.example',
  credentials: [{ key: 'ACME_IMAGE_API_KEY', usage: 'Authorization: Bearer <value>' }],
  contracts: [
    openApiContract({ contractId: 'acme-api', title: 'Acme API', document: ACME_OPENAPI }),
  ],
  guidance: 'Operating notes folded into the agent’s brief verbatim.',
})

Two rules the seam cannot check for you, both pinned per integration in the tests here:

  • A capability is a claim about the endpoint's REQUEST. Declare one only where the registered contract carries the parameter, or a step is admitted and the agent is left holding an option it cannot send. nano-banana.test.ts names each capability's evidence in the document.
  • An accepts set is a REFUSAL. State one only where the endpoint genuinely enumerates its values, and read it off the contract rather than restating it, so the two cannot drift.

Everything that does not gate an option ("good at pixel art", "cheap below 2K", "rate limited to five a second") stays prose in description and guidance, where a sentence can say what it means.

版本与发布记录

@cat-factory/binary-generators 共发布 92 个版本,首次发布于 2026/08/14;过去 12 个月发布了 92 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.86latest2026/11/062 天前
0.3.852026/11/045 天前
0.3.842026/11/045 天前
0.3.832026/11/045 天前
0.3.822026/11/045 天前
0.3.812026/11/045 天前

关于 @cat-factory/binary-generators 的常见问题

@cat-factory/binary-generators 是什么?

The built-in generative binary integrations (Nano Banana, Google's Gemini image models) plus the authoring seam a deployment defines its own with, written entirely through the public BinaryGeneratorRegistry seam: depends only on @cat-factory/kernel + @cat

如何安装 @cat-factory/binary-generators?

在项目目录运行 npm install @cat-factory/binary-generators,或使用 pnpm add / yarn add / bun add。

@cat-factory/binary-generators 支持 TypeScript 吗?

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

@cat-factory/binary-generators 支持 ESM 还是 CommonJS?

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

@cat-factory/binary-generators 可以商用吗?

@cat-factory/binary-generators 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@cat-factory/binary-generators 的下载量有多少?

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

@cat-factory/binary-generators 还在维护吗?

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