@godspeedai/cognate-profile-copilot

中文文档
0.10.0发布于 2026/11/16Apache-2.0ES Module构建来源已验证近 30 天下载 3263

Copilot reference profile: a composition of runtime, runs, continuations, frontend capabilities, state and artifact projections, AG-UI, React, and Astryx (spec §29.1). No kernel additions.

原始使用文档
文档目录6 节
  1. Installation
  2. Quick start
  3. What the profile composes
  4. Limitations
  5. Related packages
  6. License

@godspeedai/cognate-profile-copilot

The Copilot reference profile: a complete interactive chat application composed from existing Cognate packages — a model-and-tool agent loop, human approvals, frontend tools served by the browser, shared state and artifact projections, an AG-UI endpoint, and React/Astryx surfaces. It adds no new kernel or runtime primitives; every piece is a package you can also use separately.

When to use this package: you want a working chat-copilot skeleton (streamed replies, approval-gated backend tools, browser-served tools, generative UI) to run as-is or study before composing your own. For an autonomous, session-and-scheduler style agent instead, see @godspeedai/cognate-profile-harness.

Installation

bun add @godspeedai/cognate-profile-copilot

Requires Bun >= 1.4.0 and React 19.3.0 with react-dom 19.3.0 (both declared as peer dependencies). It builds on @godspeedai/cognate-runtime-bun, @godspeedai/cognate-ag-ui, @godspeedai/cognate-react, and @godspeedai/cognate-ui-astryx; the model connects through @godspeedai/cognate-provider-openai-compatible.

Quick start

import { createClient } from "@godspeedai/cognate-client";
import { openAICompatible } from "@godspeedai/cognate-provider-openai-compatible";
import { COPILOT_AGENT, createCopilotApp, GenerativeSurface } from "@godspeedai/cognate-profile-copilot";
const app = await createCopilotApp({
  store: "./copilot.sqlite",
  model: openAICompatible({
    id: "main",
    baseURL: process.env.MODEL_BASE_URL!,
    model: "my-model",
    apiKey: () => process.env.MODEL_API_KEY!, // read per request, never stored
  }),
  instructions: "You are a support copilot.",
  backendTools: [
    {
      contract: { id: "refund.approve", version: "1.0.0" },
      description: "Issue a refund",
      inputSchema: { type: "object" },
      handler: (input) => ({ refunded: (input as { amount: number }).amount }),
      requiresApproval: true, // pauses the run as a human-approval continuation
      statePatch: (input) => [{ op: "add", path: "/refund", value: { amount: (input as { amount: number }).amount, status: "refunded" } }],
      render: (input) => ({ component: "RefundCard", props: { amount: (input as { amount: number }).amount } }),
      artifact: (input, output) => ({ name: "refund-receipt.json", mediaType: "application/json", content: JSON.stringify({ request: input, result: output }) }),
    },
  ],
  frontendTools: [{ name: "map.focus", description: "Focus the map", inputSchema: { type: "object" } }],
});

// Serve the AG-UI endpoint (SSE) for browser clients:
Bun.serve({ port: 3000, fetch: app.agUi });

A connected client serves map.focus itself and resolves the approval:

import { useCapability } from "@godspeedai/cognate-react";

const caller = { actor: { id: "alice", kind: "user" }, tenant: "tenant-a" };
const client = createClient({ service: app.runtime.service, caller });
client.provideCapability("map.focus", (input) => ({ centered: true }));

// Or per component lifetime:
function MapTool() {
  useCapability("map.focus", (input) => ({ centered: true }));
  return null;
}

// Render a run's generative-UI events with your own component registry:
function Surface({ runId }: { runId: string }) {
  return <GenerativeSurface runId={runId} components={{ RefundCard: (props) => <b>Refund of {String(props.amount)}</b> }} />;
}

An unknown component name renders a placeholder instead of throwing, and the surface works under server-side rendering because the client replays its buffered events into the first subscription.

What the profile composes

ConcernBacking package
runtime, durable runs@godspeedai/cognate-runtime-bun
continuations (approvals)@godspeedai/cognate-continuations
frontend capabilities@godspeedai/cognate-runtime-api
state/artifact projections@godspeedai/cognate-client
AG-UI endpoint@godspeedai/cognate-ag-ui
React bindings@godspeedai/cognate-react
UI surfaces@godspeedai/cognate-ui-astryx

The exported copilotProfile and copilotRegistry declare this composition by name (resolveProfile from @godspeedai/cognate-profile resolves every entry to an existing package), and COPILOT_AGENT is the built-in agent id (agent.copilot).

Inside a run, the copilot agent streams model output as message.delta, invokes approved backend tools through its capability contracts, serves frontend tools to the client as continuations, and publishes state.changed, ui.render, and artifact events that the client folds into shared state, generative UI, and the artifact list. A run survives a full application restart: waiting continuations resume where they left off.

Limitations

  • The built-in AG-UI endpoint authenticates with the development Bearer <tenant>:<user> token convention — bring your own authenticate (compose createAgUiHandler from @godspeedai/cognate-ag-ui directly) for anything real.
  • One copilot agent per app instance; multi-agent routing is yours to add.
  • requiresApproval gates on a human decision only — there is no auto-approve or delegation policy built in.

License

Apache-2.0

版本与发布记录

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

版本发布日期距今
0.10.0latest2026/11/16今天
0.9.22026/11/152 天前
0.9.12026/11/143 天前
0.9.02026/11/0610 天前
0.8.02026/10/2720 天前
0.7.12026/10/2523 天前

关于 @godspeedai/cognate-profile-copilot 的常见问题

@godspeedai/cognate-profile-copilot 是什么?

Copilot reference profile: a composition of runtime, runs, continuations, frontend capabilities, state and artifact projections, AG-UI, React, and Astryx (spec §29.1). No kernel additions.

如何安装 @godspeedai/cognate-profile-copilot?

在项目目录运行 npm install @godspeedai/cognate-profile-copilot,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(19.3.0)、react-dom(19.3.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@godspeedai/cognate-profile-copilot 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/godspeedai__cognate-profile-copilot 是否存在。

@godspeedai/cognate-profile-copilot 支持 ESM 还是 CommonJS?

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

@godspeedai/cognate-profile-copilot 可以商用吗?

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

@godspeedai/cognate-profile-copilot 的下载量有多少?

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

@godspeedai/cognate-profile-copilot 还在维护吗?

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