# @crvouga/mockingbird-service-makor-cpg 中文文档

规范地址：https://npmcn.com/package/%40crvouga/mockingbird-service-makor-cpg/

版本：0\.2\.0
npm 元数据更新时间：2026-09-24T03:13:17.623Z
中文译文更新时间：2026-11-11T02:45:57.638Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40crvouga/mockingbird-service-makor-cpg
原文对照：https://npmcn.com/package/%40crvouga/mockingbird-service-makor-cpg/?lang=original
项目主页：https://github.com/crvouga/mockingbird/tree/main/packages/service/makor-cpg#readme
源码仓库：https://github.com/crvouga/mockingbird

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：579 kB，15 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：2 个
- 首次发布：2026-09-22T23:55:32.815Z
- 最新版本发布：2026-09-24T03:13:17.277Z
- 近 30 天下载量：14128（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：2（近 12 个月 2 个）

## 中文简介

对遗留下来的 Makor AI (CPG) API 的显著嘲讽:护理计划,加用户,血活网络hook,订阅,批发命令,AI病人摘要和Aync-review脚本(在模拟时钟上处理~完成),允许浏览器直接使用 CORS

## 安装

```sh
npm install @crvouga/mockingbird-service-makor-cpg
```

也可以使用：`pnpm add @crvouga/mockingbird-service-makor-cpg`、`yarn add @crvouga/mockingbird-service-makor-cpg`、`bun add @crvouga/mockingbird-service-makor-cpg`

## README

# @crvouga/ mockingbird-service-makor-cpg (英语)

真实的嘲弄 **“CPG”)** 测试套房。 它涵盖:

-   照料计划细节和加用户切换(Intercom同步,用户动作队列);
-   血活-结果网点(ODX);
-   订阅和批发顺序;
-   AI病人摘要和同步审查脚本,EMR前端直接从中调出 浏览器.

一代答一时并定. 审查脚本从 `processing` 改为 `complete` 在模拟时钟上,所以EMR面板和后端工作运行时没有铁路中转 服务器,没有 30–50 s LLM 等待.

这是 **没有** 在repo makor-ecosystem网关(`MAKOR_GATEWAY_URL`) (中文(简体) ). 那道门没了 (a) 范围.

-   行动范围: [支助](https://github.com/crvouga/mockingbird/blob/main/packages/service/makor-cpg/SUPPORT.md)
-   销售商没有发布任何信息。 合同`openapi.yaml`由我们手写 消费者的电线形状: `makor-ai.types.ts` 和《欧洲关系报告》 `async-review-script.types.ts` 编号 : `user-summary.service.ts`。 。 。 .

## 安装

```bash
npm install -D @crvouga/mockingbird-service-makor-cpg
```

仅限无害环境管理。 节点 22或 Bun 1.2. 无土生属地. 给它服务 `npx mockingbird-makor-cpg serve`, (中文(简体) ), `createServer` 从 `./server` (节点),或 `createRuntime` 与 任何获取服务器.

## 使用量

```bash
npx mockingbird-makor-cpg serve --port 8806 --processing-ms 2000
```

| 消费者 | 设置 |
| --- | --- |
| 后端 `MakorAiClientService` | `MAKOR_AI_API_URL=http://127.0.0.1:8806`, (中文(简体) ), `MAKOR_AI_API_KEY=<any>`连接 **G-K1级**数字 : `validation.schema.ts` 只接受今天的 https, 所以必须允许回回转 http . |
| EMR 前端( E)`cpg-api.ts`(中文(简体) ) | `NEXT_PUBLIC_MAKOR_API_URL=http://127.0.0.1:8806`, (中文(简体) ), `NEXT_PUBLIC_MAKOR_API_KEY=<any>`。浏览器发送密钥. |

```ts
import { createRuntime } from "@crvouga/mockingbird-service-makor-cpg"

const cpg = createRuntime({ settings: { processingMs: 45_000 } })
const admin = (method: string, path: string, body?: unknown) =>
  cpg.fetch(
    new Request(`http://makor.test/__admin${path}`, {
      method,
      headers: { "content-type": "application/json" },
      ...(body === undefined ? {} : { body: JSON.stringify(body) }),
    }),
  )

// Member 1652 has an approved plan (the Intercom sync reads it); nobody else does (404, normal).
await admin("PUT", "/care-plans/1652", { status: "Approved", state: "CA" })
// …the EMR generates a review script: it answers `processing` at once…
cpg.clock.advance(45_000)
// …and the next GET /api/async-review-script/1652/<labTestId> answers `complete`.
```

### 路线

每条路线都需要 `x-api-key`。任何非空密钥都被接受,除非 `apiKeys` 已经设定。 错误是 `{error, message, statusCode}`。 。 。 .

| 路线 | 行为 |
| --- | --- |
| `GET /api/care-plans/current-care-plan-details/{userId}` | `{carePlanId, status, pricing{…7 fields}, state}` 为种子计划。 没有计划,它回答404 `{error: "Not Found", message: "No active or approved care plan found for this user"}`。后端将准确的信息视为预期缺失,并将其记录在警告级别. |
| `PATCH /api/care-plans/plus-user/{userId}` | `{plusUser: boolean}` → `{success: true, message}`,或者在没有计划时相同的404. |
| `POST /api/bloodwork/webhook` | `{userId, labResultsId}` → **202 (韩语)** `{message: "Webhook received"}`。识别码被记录下来(`GET /__admin/bloodwork`) (中文(简体) ). |
| `GET /api/subscription/status/{userId}` | `{success: true, data: <subscription row>}` 当种子订阅活动时, 否则 `{success: true, data: {hasActiveSubscription: false, message}}`。 。 。 . |
| `POST /api/subscription/cancel/{userId}` | `{success: true, data: {subscription_id, status: "canceled", message}}`。已取消给定 `data.alreadyCancelled: true`; 无给 `data.success: false`。 。 。 . |
| `GET /api/wholescripts-orders/user/{userId}?page=&count=` | `{data, page, count, total, totalPages}` 超过种子订单。 默认值为第1页和第10倒数. |
| `POST /api/v2/generate-user-summary` | `{user_id, intake_forms?, free_text_entries?, llm_model?}` → `{user_id, summary{general_summary, past_visits, intake_summary}, biomarker_analysis}`,作为用户最近的摘要存储。 它会回答的 **一次**; 真正的服务器需要 30–50 s (参见 `slow_generation`) (中文(简体) ). 内容来自固定的,或者是一个决断的占位符,从未重复输入. |
| `GET /api/v2/user-summary/{cpgUserId}` | `{cpgUserId, summary, isMostRecent: true, createdAt}`,或404 当没有摘要(正常)时. |
| `GET /api/async-review-script/{userId}/{labTestId}` | `{review: {id, labTestId, reviewType, status, scriptContent, errorMessage, metadata, isMostRecent, createdAt, updatedAt}}` 用于最近对该实验室试验的审查,或者在无试验时进行404次(正常). |
| `POST /api/async-review-script/generate` | `{userId, labTestId, intakeForm?, chartingNotes?, demographics?}` → `{message, reviewId, status, reviewType, scriptContent}`它回答问题 **一次**与 `processingMs` 0 (默认) 状态为 `complete` 并包含内容。 否则就是了 `processing` 与 `scriptContent: null`,它变成 `complete` 一次 `processingMs` 模拟时钟已经过去. `reviewType` 实值 `comparative` 当用户已经对另一个实验室测试进行了审查时. |
| `POST /api/async-review-script/regenerate/{userId}/{labTestId}` | 相同,与新版本(保留类型)相同,或404,因为从未产生过任何内容. |

脚本内容出自最具体的固定:用户+实验室测试,然后是用户,然后是实验室测试, 接下来 `*`没有固定的,它是一个决定性的占位符 `ScriptContent`,与每个 `labFindings` 组、营养建议和纤维指导。 输入文本, 图表注释和人口统计经过验证,但从未储存、重复或刊载.

### (简体中文)

EMR 前端称此 API **直接从浏览器**。 。 。 . `cpg-api.ts` 发送 `x-api-key` 财务报告和审定财务报表 `Content-Type: application/json` 从页面,所以每一次通话前都有一个CORS 飞行前。 模拟:

-   回答每个 `OPTIONS` 请求与 **204 (韩语)**,未认证,因为浏览器不会发送自定义 飞行前头;
-   回声 `Origin` 内 `Access-Control-Allow-Origin`,或发送 `*` 当没有 `Origin`· ;
-   允许 `GET, POST, PUT, PATCH, DELETE, OPTIONS`· ;
-   回声 `Access-Control-Request-Headers`,默认为 `content-type, x-api-key, x-mockingbird-namespace, authorization`· ;
-   曝光情况 `x-mockingbird` 组合 `Access-Control-Max-Age: 600`。 。 。 .

上面印着同样的信封 **每个** 答复:供应商,401,故障预设、管理和健康. 被注入的500后作为500而到达页面,而不是作为CORS"网络错误". 这是 故意允许, 因为密钥在浏览器包中是公开的 . `withCors(request, response)` 财务报告和审定财务报表 `CORS_HEADERS` 导出.

### 管理员(超过标准合同)

| 路线 | 效果 |
| --- | --- |
| `PUT /__admin/care-plans/:userId` | 有个计划 `{carePlanId?, status? (default Active), pricing? (merged over defaults), state? (default TX)}`。 。 。 . `GET` 读取(包括 `plusUser`(三); `DELETE` 将取去. |
| `PUT /__admin/subscriptions/:userId` | 种子订阅行. 指定字段在活动默认情况下合并 . |
| `PUT /__admin/wholescripts-orders/:userId` | 种子订单 : `[order, …]` 或者说 `{orders: [...]}`。 。 。 . |
| `GET /__admin/bloodwork` | 血战网友收到(仅限数字). |
| `PUT /__admin/fixtures/summary` | `{userId? (default *), summary, biomarker_analysis?}` 设定世代返回的内容. |
| `PUT /__admin/fixtures/review-script` | `{userId? (*), labTestId? (*), scriptContent}` 设定审查生成结果. |
| `POST /__admin/summaries` | 种子存储摘要 : `{cpgUserId, summary?: {summary, biomarker_analysis}, createdAt?}`。 。 。 . |
| `POST /__admin/reviews` | 种子存储审查 : `{userId, labTestId, status? (complete), scriptContent?, reviewType?, errorMessage?, readyInMs?}`。 。 。 . `GET /__admin/reviews?userId=` 列出他们. |
| `GET/PUT /__admin/settings` | `{apiKeys?: string[], processingMs?: number}` 呼叫的命名空间. |
| `POST /__admin/tick` | 完成现在到期的每一项审查。 读者也懒散地解决了到期审查. |

错误预设( E)`POST /__admin/faults {"preset": "<name>", "count"?: n, "latencyMs"?: ms}`:

| 预设 | 效果 |
| --- | --- |
| `slow_generation` | 三代调用取用40 s:正中为30–50 s,处于EMR50 s摘要超时的边缘. |
| `generation_failed` | 总结答五百. 一个审查脚本回答500 `{status: "failed", errorMessage}` 显示 `errorMessage`。 。 。 . |
| `care_plan_invalid_shape` | 二百块没有 `pricing`。后端的策略检查失败,它记录出错并返回无效. |
| `bloodwork_not_accepted` | 网友回答200而不是202. 后端警告并返回无效 . |
| `route_missing` | 每个路线都回答404 `Cannot GET …`。这是一条错误的路由,后端在错误级别记录,与无计划404不同. |
| `unauthorized` | 每个呼叫都答401. |
| `server_error` | 每召答五百个. |

### 命名空间

-   页:1 `x-mockingbird-namespace` 页眉(EMR的轴实例可以添加);
-   (单位:千美元) `/ns/<name>` 基准 URL 前缀;
-   aPI 密钥 : `PUT /__admin/credentials {"credentials": {"<x-api-key>": "<namespace>"}}`。 。 。 .

请求日记记录了操作ID,状态和用户,实验室测试和审查ID. 这个 从不记录请求尸体.

### 故意不模拟

-   Makor-生态系统网关(`MAKOR_GATEWAY_URL`数字 : `/v1/makor/*`, (中文(简体) ), `/v1/care-team-chat/*`, (中文(简体) ), `/v1/plans/*`) (中文(简体) ). 它不是第三方 而是第三方 它的根部(一个SSE上层)被跟踪 分别.
-   真正的AI输出. 摘要和脚本是固定物或确定性占位符,以及 `biomarker_analysis` 以给定的方式通过.
-   真正的服务器的内部投票。 30-50的后缀只是预设.
-   添加订阅的副作用取消 。 只有存储的行会更改 .
-   审查历史清单`ReviewHistoryResponse`它没有活的呼叫者到达.

## API 密码

| 导出 | 仁爱 | 说明 |
| --- | --- | --- |
| `MakorCpgAPI` | 类 | 进程模拟: `fetch(request)`, (中文(简体) ), `reset()`, (中文(简体) ), `tick()`, (中文(简体) ), `state`选项: `sqlite`, (中文(简体) ), `now`, (中文(简体) ), `namespace`, (中文(简体) ), `settings`。 。 。 . |
| `createRuntime` | 函数 | 配有全套服务合同的模拟器加上CORS(保健、管理、命名空间、证书、预设)。 选项 : `settings`, (中文(简体) ), `clock`, (中文(简体) ), `seed`, (中文(简体) ), `adminKey`, (中文(简体) ), `onLog`, (中文(简体) ), `sqlite`。 。 。 . |
| `MAKOR_CPG_PRESETS` | 对象 | 每个命名的断层预设. |
| `MAKOR_CPG_NAMESPACE` | 字符串 | 服务名称, `"makor-cpg"`。 。 。 . |
| `NO_CARE_PLAN_MESSAGE` | 字符串 | 后端准确的404条信息视为预期缺勤. |
| `CORS_HEADERS`, (中文(简体) ), `withCors` | 数值 | 允许的 CORS 信头, 和帮助他们 贴在回应. |
| `apiKeyCredential` | 函数 | 这个 `x-api-key` 请求带( 命名空间的密钥映射). |
| `defaultScriptContent` | 函数 | 实验室测试的占位符审查脚本. |
| `DEFAULT_SETTINGS` | 对象 | `{apiKeys: [], processingMs: 0}`。 。 。 . |
| `document`, (中文(简体) ), `operationIds`, (中文(简体) ), `supportedOperationIds` | 数值 | 销售商为OpenAPI合同及其业务代号. |
| `createServer`, (中文(简体) ), `serveTarget`, (中文(简体) ), `DEFAULT_PORT` (单位:千美元)`./server`(中文(简体) ) | 节点 | 服务过来 `node:http`; 数据 `serve` CLI目标(`--api-key`, (中文(简体) ), `--processing-ms`; 第8806号口. |

部分 [嘲笑鸟](https://github.com/crvouga/mockingbird)。 。 。 .

## 常见问题

### @crvouga/mockingbird-service-makor-cpg 是什么？

对遗留下来的 Makor AI \(CPG\) API 的显著嘲讽:护理计划,加用户,血活网络hook,订阅,批发命令,AI病人摘要和Aync-review脚本\(在模拟时钟上处理~完成\),允许浏览器直接使用 CORS

### 如何安装 @crvouga/mockingbird-service-makor-cpg？

在项目目录运行 npm install @crvouga/mockingbird-service-makor-cpg，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mockingbird-makor-cpg，可以用 npx mockingbird-makor-cpg 直接运行。

### @crvouga/mockingbird-service-makor-cpg 支持 TypeScript 吗？

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

### @crvouga/mockingbird-service-makor-cpg 支持 ESM 还是 CommonJS？

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

### @crvouga/mockingbird-service-makor-cpg 可以商用吗？

@crvouga/mockingbird-service-makor-cpg 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @crvouga/mockingbird-service-makor-cpg 的下载量有多少？

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

### @crvouga/mockingbird-service-makor-cpg 还在维护吗？

最新版本 0\.2\.0 发布于 2026/09/24（1 个月前）；至今共发布 2 个版本，其中过去 12 个月发布了 2 个；首次发布于 2026/09/23。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

