npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ckool-model-contract

v0.1.1

Published

AKOOL model-config contract: media_input_schema types, three-layer config validator, and the input-plan compiler shared by landing / akool-admin-web / agi-content / management-backend.

Readme

ckool-model-contract

AKOOL 模型配置契约的唯一真源:media_input_schema 类型定义、模型配置三层校验器、上传输入编译器。四端(landing / akool-admin-web / agi-content / management-backend)共用同一份实现——admin 保存时拦的、后端入库时拒的、前台渲染画的、预览显示的,物理上是同一个函数。

迁移说明(2026-08-11):本包由 landing/lib/model-contract/ 迁出。契约规范正文暂在 landing docs/image-to-video-input-schema.md;治理背景见 landing docs/technical-designs/2026-08-04-model-config-governance-plan.md。

API

import { validateModelConfig, compileInputPlan } from 'ckool-model-contract';

// 1. 配置写入闸门:结构 / 交叉引用 / 准入策略 三层校验
const { ok, errors, warnings } = validateModelConfig(doc, {
  requireMediaInputSchema: true,   // 新建契约家族模型必须带 schema(create 场景开)
  rejectLegacyFields: true,        // 拒收已废弃 legacy 字段
});
// errors: [{ severity, path, code, message }]

// 2. 输入编译器:(media_input_schema, params) → 上传框计划
const plan = compileInputPlan(schema, params /*, hints — 仅 landing 过渡期传 */);
// plan.slots: [{ id, role, mediaTypes, bindings: [{ param, maxItems, required }], maxCount }]

另导出全部契约类型(MediaInputSchema / MediaInputSlot / ParamsRule / ValidationIssue …)与常量(CONTRACT_MODEL_TYPES / LEGACY_DB_FIELDS …)。

机器可读 JSON Schema(admin Monaco 补全/红线用):

import mediaInputSchema from 'ckool-model-contract/json-schema/media-input-schema.schema.json';
import paramsRulesSchema from 'ckool-model-contract/json-schema/params-rules.schema.json';

消费方

| 仓库 | 用途 | |---|---| | landing | schema-plan.ts 渲染/提交/回填的编译入口;decode fail-closed | | akool-admin-web | 保存前校验(error 阻断)、Monaco Schema、表单实时预览(compileInputPlan) | | management-backend | aiModelConfig create/update/import 写入口服务端闸门 | | agi-content | 导入/回填脚本入库校验、validate:ai-model-config 全量体检、媒体总量校验中间件(CJS 用 dist/index.cjs) |

开发

npm install
npm test          # vitest,36 用例(契约文档 8 个标准示例做用例)
npm run build     # dist/:index.cjs + index.mjs + *.d.ts(esbuild + tsc)
npm run typecheck

零运行时依赖;prepublishOnly 强制先测试后构建。

发布与消费(过渡期说明)

  • 发布:publishConfig.access: public,发公共 npm registry(npm publish 即可);也可用 git 依赖:"ckool-model-contract": "git+https://gitlab.akool.io/frontend/model-contract.git#v0.1.0";
  • 过渡期:四个仓当前仍使用 vendored 副本(各带 VENDOR_MANIFEST.json + 漂移校验脚本)。切换到本包依赖前,vendored 副本继续以 landing 侧 scripts/vendor-model-contract.mjs 分发;切换后删除 vendored 目录与该脚本;
  • 契约变更流程:改本仓 → 升版本(语义化:校验规则收紧 = minor,破坏性结构变更 = major)→ 各消费方升级依赖。校验错误码(code 字段)是对外契约的一部分,重命名视为破坏性变更。