# @appduct/web 中文文档

规范地址：https://npmcn.com/package/%40appduct/web/

版本：0\.16\.0
npm 元数据更新时间：2026-10-21T20:04:10.289Z
中文译文更新时间：2026-11-06T11:25:55.984Z
软件包许可：MIT

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

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

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

- 包体积（解压后）：117 kB，28 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：1 个
- peer 依赖：react \*
- 首次发布：2026-10-12T06:39:32.571Z
- 最新版本发布：2026-10-21T20:04:09.770Z
- 近 30 天下载量：6591（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：5（近 12 个月 5 个）

## 中文简介

Web SDK for Appution:注册工具 一个代理,测试或终端可以在您运行的网络应用中调用.

## 安装

```sh
npm install @appduct/web
```

也可以使用：`pnpm add @appduct/web`、`yarn add @appduct/web`、`bun add @appduct/web`

## README

[![Appduct by Callstack. Your app is an MCP server now: your agent calls its functions over MCP, on iOS, Android, React Native, Flutter and web.](https://raw.githubusercontent.com/callstackincubator/appduct/main/.github/assets/readme-banner.png)](https://callstackincubator.github.io/appduct/)

# Web 应用程序

从终端、测试跑道或AI代理调用运行中的网页中的功能。 注册工具 `@appduct/web`;只有您注册的工具才能到达。 使用任意框架或平版JavaScript工作.

## 所需资源

-   与Apptution CLI相同的计算机上的浏览器.
-   本地开发页面, 例如 `http://localhost:5173/`对于 HTTPS 页面,请检查 [浏览器和运输指南](https://callstackincubator.github.io/appduct/guides/web-pages/)。 。 。 .
-   这个 `appduct` CLI: 爱丽丝 `npm install -g appduct` (节点20或更新.

## 开始

安装 SDK :

```bash
npm install @appduct/web
```

在您的页面启动代码中注册一个工具 :

```ts
import { registerTool } from "@appduct/web";

registerTool({
  name: "seed_cart",
  description: "Fill the cart with test items.",
  inputSchema: {
    type: "object",
    properties: { items: { type: "number" } },
    required: ["items"],
  },
  handler: async ({ items }) => ({ added: items }),
});
```

运行您的开发服务器, 然后使用它的 URL 连接页面 :

```bash
appduct sessions link --open web http://localhost:5173/
```

打开浏览器中的 URL 打印, 然后 :

```bash
appduct tools ls
appduct tools call seed_cart --input '{"items":3}'
```

工具返回 `{"added":3}`。 。 。 .

## 事情要知道这一点

-   **重新装入会话恢复; 新标签没有 .** 页面在声称后会从地址栏中删除连接链接.
-   **原始计划不能验证论证.** 检查处理器中的输入, 或使用 [支持的计划库](https://callstackincubator.github.io/appduct/guides/writing-tools/#choose-a-schema-form)。 。 。 .
-   **反应有钩入.** 导入 `useAppductTool` 从 `@appduct/web/react` 在组件挂起时注册工具.
-   **一个代理可以不重新装入连接.** `appduct_connect` 返回可在页面中运行的脚本。 DevTools 和 Playwright 连接包含在 [驱动网页](https://callstackincubator.github.io/appduct/guides/web-pages/)。 。 。 .
-   **如果没有连接, 请检查建筑 .** 默认导入需要您的捆绑器 `development` 条件。 否则它使用惰性条目;见 [网络设置](https://callstackincubator.github.io/appduct/install/web/)。 。 。 .

## 发行构建

默认条目位于 `development` 导出条件: 它没有注册, 没有打开连接, 没有定义 `window.__APPDUCT__`。要将“应用程序”包括在中转建筑中,请导入允许的条目:

```ts
import { registerTool } from "@appduct/web/enabled";
```

只用在构建你的控制。 网页不会给守护进程按键钉上钉子; 审查 [网络安全](https://callstackincubator.github.io/appduct/guides/security/#web-pages),包括允许的出处,然后启用主机页面。 见 [构建变体](https://callstackincubator.github.io/appduct/guides/build-variants/#web-production-builds)。 。 。 .

## 学多点

-   [网络设置](https://callstackincubator.github.io/appduct/install/web/)
-   [驱动网页](https://callstackincubator.github.io/appduct/guides/web-pages/): 浏览器支持、 DevTools 和 Playwright
-   [写入工具](https://callstackincubator.github.io/appduct/guides/writing-tools/)计划、超时、团体和活动
-   [连接代理](https://callstackincubator.github.io/appduct/guides/agents/) 超过 MCP
-   [网络操场](https://github.com/callstackincubator/appduct/blob/main/playground-web/README.md): 可运行的示例

## 由 Calltack 制作

`appduct` 是一个开源项目,将永远自由使用。 如果你觉得这很酷,请 显示它. [调用](https://callstack.com/?utm_source=github.com&utm_medium=referral&utm_campaign=appduct&utm_term=readme-with-love) 一群反动和反动的本地怪人 联系我们 [你好@ callstack.com](mailto:hello@callstack.com) 如果你需要帮忙的话 或者只是想打个招呼!

喜欢这个项目吗 [加入队伍吧](https://callstack.com/careers/?utm_campaign=Senior_RN&utm_source=github&utm_medium=readme) 谁为客户做惊人的事情 驱动 React Independent Open Source

## 常见问题

### @appduct/web 是什么？

Web SDK for Appution:注册工具 一个代理,测试或终端可以在您运行的网络应用中调用\.

### 如何安装 @appduct/web？

在项目目录运行 npm install @appduct/web，或使用 pnpm add / yarn add / bun add。

### @appduct/web 支持 TypeScript 吗？

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

### @appduct/web 支持 ESM 还是 CommonJS？

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

### @appduct/web 可以商用吗？

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

### @appduct/web 的下载量有多少？

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

### @appduct/web 还在维护吗？

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

