@ godspideai/ cognate- profile( 缩写)
钴应用的申报成分: defineProfile 指定已注册组件的顺序选择及其配置,以及 resolveProfile 将选择变成贡献。 配置文件不添加内核概念——它们只选择和配置已经注册的软件包.
何时使用此软件包 : 您正在定义一个可重复使用的应用程序组成(“ profile” ),或者将配置解析结果建构登记册。 现成简介包括:
@godspeedai/cognate-profile-harness
财务报告和审定财务报表 @godspeedai/cognate-profile-copilot。 。 。 .
安装
bun add @godspeedai/cognate-profile
要求数 阿宝 >= 1.4.0.
快开始
import { defineProfile, resolveProfile } from "@godspeedai/cognate-profile";
import type { ComponentEntry } from "@godspeedai/cognate-profile";
// A registry: entries a package provides, each producing one contribution.
const registry: ComponentEntry<string[]>[] = [
{
name: "sessions",
package: "@godspeedai/cognate-runtime-bun",
supported: true,
contribute: () => ["sessions"],
},
{
name: "agents",
package: "@godspeedai/cognate-runtime-bun",
supported: true,
contribute: (options) => [`agents:${JSON.stringify(options ?? null)}`],
},
];
// Validate and freeze the profile. Names must be unique and non-empty.
const profile = defineProfile({
name: "research-workbench",
description: "Sessions plus a bounded agent pool",
components: ["sessions", "agents"],
options: { agents: { max: 2 } },
});
const resolved = resolveProfile(profile, registry);
resolved.contributions; // [{ name: "sessions", ... }, { name: "agents", contribution: 'agents:{"max":2}' }]
resolved.unresolved; // every requested name that could not be included, with a reason
resolveProfile 将配置文件的组件按顺序排列,调用 contribute(profile.options[name]) 仅用于支持的条目。 报告姓名不明,原因不明 "unknown component"; 标出条目 supported: false 报告本身的理由。 没有什么是默默地放弃的.
类型保证
defineProfile返回深冻ProfileDefinition: 定义后组件列表和选项不能被变异, 而验证错误抛出ProfileError定义时间,而不是解析时间.ResolvedProfile分离contributions(按配置顺序,每个标记其源包)unresolved(要求但缺席,每个都有原因),所以一个组成可以确切地显示它运行的是什么,以及为什么缺少任何东西.ComponentEntry.supported: false明确记录一个无法读取的组件,并有可人阅读的reason。 。 。 .
限制
- 纯粹的数据:这个软件包验证和解决了——它没有挂载什么,没有开始什么,自己也不知道登记。 打电话者拥有什么
contribute返回,以及解析后的捐款情况. - 选项与此软件包不透明;它们被传递到每个条目的
contribute无所未有.
相关软件包
@godspeedai/cognate-kernel-api——对内核合同剖面进行选择,不作扩展.@godspeedai/cognate-runtime-bun——运行时间构成一般解决.@godspeedai/cognateSDK伞.
许可证
阿帕奇 - 2.0