@agenticprimitives/orchestration-openai-compat

中文文档
0.0.0-alpha.15发布于 2026/10/16MITTypeScriptES Module零依赖近 30 天下载 3220

OpenAI-compatible chat-completions binding for the @agenticprimitives/orchestration Planner / AnswerComposer ports (the in-repo adapter, chain-state-viem pattern). Vendor-neutral: the consumer supplies baseUrl + model (Groq, Ollama, OpenRouter, …). create

原始使用文档
文档目录7 节
  1. Install
  2. Quick start (Groq)
  3. What else is here
  4. OpenAiCompatLike
  5. Wire notes
  6. Boundaries
  7. License

@agenticprimitives/orchestration-openai-compat

Part of Agentic Primitives — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. Developer kit · All packages

The OpenAI-compatible LLM binding for the @agenticprimitives/orchestration Planner and AnswerComposer ports — the in-repo adapter (the chain-state / chain-state-viem pattern), sibling to orchestration-anthropic. The pure orchestration core stays vendor-free; the chat-completions translation lives here.

Vendor-neutral. This package names no host and no model. Groq, Ollama, OpenRouter, a self-hosted vLLM: each is a baseUrl + model you supply.

Install

pnpm add @agenticprimitives/orchestration-openai-compat @agenticprimitives/orchestration

Quick start (Groq)

import { runIntent, type ToolSpec } from '@agenticprimitives/orchestration';
import { createOpenAiCompatPlanner, createFetchOpenAiCompatClient } from '@agenticprimitives/orchestration-openai-compat';

const tools: ToolSpec[] = [
  { id: 'get_vault_record', description: 'Read a vault record by recordType.', inputSchema: { type: 'object', properties: { recordType: { type: 'string' } }, required: ['recordType'] } },
  { id: 'get_pii', description: 'Read the principal’s PII (high sensitivity).' },
];

// Dependency-free client — works in a Cloudflare Worker (no SDK, no node shims). The host is YOUR choice.
const client = createFetchOpenAiCompatClient({ apiKey: env.GROQ_API_KEY, baseUrl: 'https://api.groq.com/openai/v1' });
const planner = createOpenAiCompatPlanner({ client, model: 'openai/gpt-oss-120b', label: 'groq' });

const result = await runIntent(
  { goal: 'show me my profile' },
  { planner, tools, invoke: async (toolId, args) => myDelegatedMcpCall(toolId, args) },
);

The model chooses which tool fits the goal; the chosen call still rides the task's on-chain delegation at the invoker (ADR-0041). The model never gains authority by being asked.

What else is here

  • createOpenAiCompatComposer({ client, model }) — turns what the tools returned into a grounded sentence.
  • createOpenAiCompatStructuredCall({ client, model }) — one forced single-tool call (a query, a selection).
  • OpenAiCompatHttpError — thrown on a non-OK response with status and, on a 429, retryAfterSeconds. Say it to the person; never route to another vendor because of it.

OpenAiCompatLike

Every factory takes a structural OpenAiCompatLike client (the minimal chat.completions.create surface). Pass either createFetchOpenAiCompatClient({ apiKey, baseUrl }) or the official new OpenAI({ apiKey, baseURL }) — it satisfies the same shape. This keeps the adapter unit-testable with a fake and avoids a hard SDK dependency.

Wire notes

  • Tool arguments arrive as a JSON string; the adapter parses them. Unparseable → planner_failed.
  • tool_choice: 'required' is a request; a prose-only reply is no_plan.
  • The client is non-streaming. Fine for planning / answering budgets; a very long generation may hit an intermediary timeout until streaming lands.

Boundaries

Imports only @agenticprimitives/orchestration (+ types). See spec.md + capability.manifest.json.

License

MIT

版本与发布记录

@agenticprimitives/orchestration-openai-compat 共发布 15 个版本,首次发布于 2026/09/12;过去 12 个月发布了 15 个版本。

版本发布日期距今
0.0.0-alpha.15latest2026/10/1623 天前
0.0.0-alpha.142026/10/1523 天前
0.0.0-alpha.132026/10/1226 天前
0.0.0-alpha.122026/10/1127 天前
0.0.0-alpha.112026/10/1028 天前
0.0.0-alpha.102026/10/0929 天前

关于 @agenticprimitives/orchestration-openai-compat 的常见问题

@agenticprimitives/orchestration-openai-compat 是什么?

OpenAI-compatible chat-completions binding for the @agenticprimitives/orchestration Planner / AnswerComposer ports (the in-repo adapter, chain-state-viem pattern). Vendor-neutral: the consumer supplies baseUrl + model (Groq, Ollama, OpenRouter, …). create

如何安装 @agenticprimitives/orchestration-openai-compat?

在项目目录运行 npm install @agenticprimitives/orchestration-openai-compat,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@agenticprimitives/orchestration(^0.0.0-alpha.17)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@agenticprimitives/orchestration-openai-compat 支持 TypeScript 吗?

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

@agenticprimitives/orchestration-openai-compat 支持 ESM 还是 CommonJS?

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

@agenticprimitives/orchestration-openai-compat 可以商用吗?

@agenticprimitives/orchestration-openai-compat 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agenticprimitives/orchestration-openai-compat 的下载量有多少?

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

@agenticprimitives/orchestration-openai-compat 还在维护吗?

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