@fortrip/agent-contract

中文文档
6.0.0发布于 2026/11/14Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 7071

The contract of Fortrip's agent API (https://api.fortrip.ai/v1) and its MCP server: limits, paths, request and response schemas, error codes and field rules.

原始使用文档

@fortrip/agent-contract

The contract of Fortrip API v1 (https://api.fortrip.ai/v1) and its MCP server (https://mcp.fortrip.ai/): the limits, paths, request and response schemas, error codes and field rules that the Fortrip CLI (fortrip), the hosted MCP server and the store listings all share, so they cannot drift apart.

It has one peer dependency, zod (^4.4.0), and runs anywhere ES2023 does. Its major version changes when the contract breaks, not with the API: 6.x serves Fortrip API v1.

import { API, LIMITS, PUBLIC_ORIGINS, containsCardNumber } from "@fortrip/agent-contract";

PUBLIC_ORIGINS.api + API.hotelSearch; // "https://api.fortrip.ai/v1/hotels/search"
LIMITS.rooms; // 8

It exports:

  • API, PUBLIC_ORIGINS, MCP_PATH, LIMITS, ERROR_CODES, SEARCH_SORTS and FILTERABLE_AMENITIES: paths, hosts, limits, error codes and vocabularies;
  • searchHotelsInput, getHotelInput, hotelOffersInput, createOrderInput, getOrderInput, listOrdersInput, cancelOrderInput and payOrderInput, the zod schemas of the requests, with offersPerHotel(limitPerHotel, hotelsWithOffers), the offers each hotel of an offers call gets, and misplacedKeys(schema, issues, sent), where a key sent at the wrong depth belongs, with misplacedKeyHint(key), what to tell the caller about it, and searchResult, hotel, hotelOffersResult, order, orderList, paymentHandler and errorEnvelope, the open schemas of the responses, with ERROR_DETAILS, each error code's details, and parseOpen, a parser that keeps unknown fields and values;
  • COMMANDS, COMMAND_GROUPS and GLOBAL_FLAGS, the CLI's commands, the groups they are typed after and its flags, commandInvocation(spec), a command as it is typed (fortrip hotels search), TOOLS, the MCP tools, and SERVER_INFO, what an MCP server for Fortrip says of itself;
  • renderToolResult(tool, data, surface?) and renderError(envelope, status?, surface?), the whole text of a result or an error, naming tools ("mcp", the default) or commands and flags ("cli"): an MCP result is this one text block, with nothing added. The rules a result ends with are exported too (ORDER_NEXT_STEP, CANCEL_NEXT_STEP, PAY_NEXT_STEP, PRESENTATION_HINT, and cancelNextStep(surface) and payNextStep(surface), which word two of them for "mcp" or "cli"), and renderGuide(surface, topic), the agent guide as Markdown for "mcp", "claude-skill" or "cli";
  • field rules such as containsCardNumber, the guest-name rule and the date helpers, and CONTRACT_VERSION.

Browser code that only needs the guest-name rule (GUEST_NAME_PATTERN, GUEST_NAME_TITLE, GUEST_NAME_MESSAGE, guestNameRe, normalizeGuestName) can import it from @fortrip/agent-contract/guest-name. That module imports no package, so it does not pull in zod or the schemas the root entry builds at load. The root entry exports the same names.

Apache License 2.0 (versions before 2.0.0: MIT). Copyright 2026 FortripAI, Inc. "Fortrip" is a trademark of FortripAI, Inc. The license does not grant permission to use the trade names, trademarks, service marks or product names of FortripAI, Inc., except as required for reasonable and customary use in describing the origin of the software and reproducing the content of the NOTICE file (section 6). Source: https://github.com/FortripEngineering/fortrip/tree/main/packages/contract.

版本与发布记录

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

版本发布日期距今
6.0.0latest2026/11/141 天前
6.0.0-rc.1next2026/11/141 天前
6.0.0-rc.02026/11/141 天前
5.3.02026/11/132 天前
5.3.0-rc.02026/11/132 天前
5.2.02026/11/105 天前

关于 @fortrip/agent-contract 的常见问题

@fortrip/agent-contract 是什么?

The contract of Fortrip's agent API (https://api.fortrip.ai/v1) and its MCP server: limits, paths, request and response schemas, error codes and field rules.

如何安装 @fortrip/agent-contract?

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

@fortrip/agent-contract 支持 TypeScript 吗?

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

@fortrip/agent-contract 支持 ESM 还是 CommonJS?

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

@fortrip/agent-contract 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fortrip/agent-contract 可以商用吗?

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

@fortrip/agent-contract 的下载量有多少?

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

@fortrip/agent-contract 还在维护吗?

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