agentworkshop 0.7.50 → 0.7.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/912eb5bb-670e-4cc8-b21d-7fc097723466.json +1 -0
- package/.output/server/chunks/_/nitro.mjs +957 -957
- package/.output/server/package.json +1 -1
- package/README-zh.md +829 -829
- package/README.md +839 -839
- package/config.yml +1 -1
- package/docs/cli.en.md +447 -447
- package/docs/cli.md +412 -412
- package/docs/mcp.en.md +27 -0
- package/docs/mcp.md +108 -0
- package/docs/plugins.en.md +1 -1
- package/docs/plugins.md +1 -1
- package/docs/sdk.en.md +1 -1
- package/docs/sdk.md +1 -1
- package/mcp/aw-mcp-server.mjs +796 -0
- package/mcp/discovery.mjs +227 -0
- package/package.json +4 -1
- package/.output/public/_nuxt/builds/meta/08ba670b-7512-426b-a0ae-b10cbeb1c985.json +0 -1
package/docs/mcp.en.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# aw Industrial MCP Server (mcp/)
|
|
2
|
+
|
|
3
|
+
> Integration entry for external skills / MCP clients / engineer workbenches: exposes the
|
|
4
|
+
> platform's key REST methods as first-class MCP tools and **auto-discovers the port of the
|
|
5
|
+
> running local instance** — mount it and it just works, no manual port wiring.
|
|
6
|
+
|
|
7
|
+
See [docs/mcp.md](../mcp.md) (Chinese, authoritative) for the full reference. Summary:
|
|
8
|
+
|
|
9
|
+
- **Launch**: `aw mcp` (stdio) · `aw mcp --doctor` (diagnose) · `aw mcp --print-config`
|
|
10
|
+
- **Port discovery priority**: `AW_BASE_URL` → `AW_PORT` → `.runtime/aw.lock` lock files
|
|
11
|
+
(explicit `AW_HOME` wins over implicit cwd/home discovery) → `PORT`/`NUXT_PORT` →
|
|
12
|
+
`config.yml` `server.dev.port`/`server.prod.port` → defaults 3000/3001.
|
|
13
|
+
Health gate: `GET /api/health` must return `data.status === 'ok'`.
|
|
14
|
+
- **Self-healing**: network failures invalidate the cached base and trigger one re-discovery +
|
|
15
|
+
retry; 401 clears the token and lazy-relogins once. Bad credentials fail fast (no re-discovery).
|
|
16
|
+
- **Auth**: `AW_TOKEN`, or `AW_EMAIL` + `AW_PASSWORD` (lazy login), or the `aw_login` tool.
|
|
17
|
+
- **Tool surface (35)**: connection (`aw_status`, `aw_login`); lines/products/recipes
|
|
18
|
+
(`aw_line_*`, `aw_product_create`, `aw_recipe_create`); DCW nodes & parameter map
|
|
19
|
+
(`aw_dcw_*`, `aw_param_*`); DAQ (`aw_daq_*`); optimization channels
|
|
20
|
+
(`aw_channel_*`, `aw_channel_template_instantiate`, `aw_team_provision`,
|
|
21
|
+
`aw_agent_tool_bind/invoke`, `aw_twin_profile_get/patch`, `aw_task_*`, `aw_model_*`,
|
|
22
|
+
`aw_optimization_judge`); plugins (`aw_plugin_list`, `aw_plugin_toggle`);
|
|
23
|
+
escape hatch (`aw_request`, `/api/` prefix only).
|
|
24
|
+
- **Skills**: `skills/aw-node-bind`, `skills/aw-opt-channel`, `skills/aw-plugin-dev` are built
|
|
25
|
+
on top of this server (`npm run test:skills` validates cross-references).
|
|
26
|
+
- **Tests**: `npm run test:mcp` (unit, 12 test groups) · `npm run test:mcp-live`
|
|
27
|
+
(isolated-instance e2e, 34 assertions).
|
package/docs/mcp.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# aw 工业 MCP 服务(mcp/)
|
|
2
|
+
|
|
3
|
+
> 面向外部 skill / MCP 客户端 / 工程师工作台的集成入口:把平台关键 REST 方法暴露为
|
|
4
|
+
> 一等 MCP 工具,并**自动发现本机运行实例的端口**——挂上就能用,不要求手填端口。
|
|
5
|
+
|
|
6
|
+
## 一、它解决什么
|
|
7
|
+
|
|
8
|
+
平台已有两个 MCP 面,分工如下:
|
|
9
|
+
|
|
10
|
+
| MCP 面 | 位置 | 面向 | 鉴权 |
|
|
11
|
+
| --- | --- | --- | --- |
|
|
12
|
+
| **aw 工业 MCP**(本文) | `mcp/aw-mcp-server.mjs`(stdio) | 外部 skill、桌面 MCP 客户端、CI 脚本 | 用户 token(AW_TOKEN 或 AW_EMAIL/AW_PASSWORD) |
|
|
13
|
+
| host tools 回程桥 | `server/harness/aw-mcp-bridge.mjs`(stdio) | 频道内 harness 引擎(codex/dsh/opencode…) | agent 实例 token |
|
|
14
|
+
| Workshop MCP(Streamable HTTP) | `POST /api/mcp/workshop` | 平台侧任务/消息/设备孪生 | Bearer token |
|
|
15
|
+
|
|
16
|
+
工业 MCP 暴露的是**工程操作面**(产线/节点绑定/参数映射/配方/优化闭环频道/插件),
|
|
17
|
+
与频道内 agent 的 host tool 面(`.AgentWorkShop/prompts/host-tools.json`)互补。
|
|
18
|
+
|
|
19
|
+
## 二、快速开始
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
aw mcp --doctor # 诊断:自动发现过程 → 健康 → 鉴权,一次讲清
|
|
23
|
+
aw mcp --print-config # 打印 MCP 客户端配置 JSON
|
|
24
|
+
aw mcp # 启动 stdio 服务(由 MCP 客户端作为子进程拉起)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
客户端配置(claude_desktop_config.json / codex config.toml 通用形态):
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{ "mcpServers": { "aw": { "command": "node", "args": ["<仓库>/mcp/aw-mcp-server.mjs"], "env": {} } } }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 三、端口自动发现(核心机制)
|
|
34
|
+
|
|
35
|
+
发现优先级(逐级 `GET /api/health` 探活,`data.status==='ok'` 才算命中;全失败才报错):
|
|
36
|
+
|
|
37
|
+
1. `AW_BASE_URL` —— 显式平台地址
|
|
38
|
+
2. `AW_PORT` —— 多实例并存时钉住端口
|
|
39
|
+
3. 锁文件 `<configRoot>/.runtime/aw.lock`(`{pid,port,mode}`,`aw start` 端口顺延后回写,
|
|
40
|
+
是实例真实端口的唯一权威记录):
|
|
41
|
+
- 显式 `AW_HOME` 时:先 `AW_HOME/.runtime/aw.lock` 与 `AW_HOME/.AgentWorkShop/.runtime/aw.lock`,
|
|
42
|
+
再 cwd 向上找 repo 锁(**显式 AW_HOME 压过隐式发现,且不回落全局 home 锁**——多实例隔离语义)
|
|
43
|
+
- 未设 `AW_HOME` 时:cwd 向上找 `.AgentWorkShop/.runtime/aw.lock`,再 `~/.AgentWorkShop/.runtime/aw.lock`
|
|
44
|
+
4. `PORT` / `NUXT_PORT`(启动惯例变量)
|
|
45
|
+
5. `config.yml` 的 `server.dev.port` / `server.prod.port`(零依赖轻量解析)
|
|
46
|
+
6. 默认端口 3000(dev)/ 3001(prod)
|
|
47
|
+
|
|
48
|
+
**确保连接**:会话内缓存发现结果;任何工具调用遇到网络层失败,自动作废缓存重发现一次再重试
|
|
49
|
+
(实例顺延换端口后下一发即自愈)。401 时作废 token 懒重登录一次。
|
|
50
|
+
登录失败(凭据错误)不触发重发现,直接报错。
|
|
51
|
+
|
|
52
|
+
## 四、鉴权
|
|
53
|
+
|
|
54
|
+
- `AW_TOKEN`:直接携带(优先)。
|
|
55
|
+
- `AW_EMAIL` + `AW_PASSWORD`:首次鉴权调用时懒登录 `POST /api/users/login`,token 会话内缓存。
|
|
56
|
+
- 都没有:工具返回带补救指引的错误;客户端也可在会话里调 `aw_login` 工具显式登录。
|
|
57
|
+
- 实例从未初始化管理员:先走 Web `/setup` 注册(首注册即 admin),MCP 不代注册。
|
|
58
|
+
|
|
59
|
+
## 四点五、集成开关(系统设置)
|
|
60
|
+
|
|
61
|
+
- 设置项:`系统设置 → MCP 集成 → 启动 MCP 集成`(`mcp.enabled`,live 键,默认**停用**)。
|
|
62
|
+
也可用环境变量 `AW_MCP_ENABLED=true` 覆盖(CI/无人值守场景)。
|
|
63
|
+
- 语义:停用期间,除 `aw_status`(自诊断)外的**所有 MCP 工具调用被拒绝**,返回指引文本;
|
|
64
|
+
平台 REST 与频道内 agent 的 host tools 不受影响。切换 ≤3s 传导到 MCP 服务,无需重启。
|
|
65
|
+
- 三个项目 skill(`skills/`)的前置步骤 0 都会检查该开关(`aw_status` 的 `mcpEnabled` 字段)。
|
|
66
|
+
- 注意:设置页出现「MCP 集成」分组需要实例运行带该描述符的构建(`shared/config/schema.json`,
|
|
67
|
+
2026-09-27 加入);文件路径(写 `<configRoot>/runtime-settings.json`)与 env 路径不依赖构建。
|
|
68
|
+
|
|
69
|
+
## 五、工具面(35 个)
|
|
70
|
+
|
|
71
|
+
| 分组 | 工具 |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| 连接 | `aw_status`(发现+健康+鉴权状态)、`aw_login` |
|
|
74
|
+
| 产线/产品/配方 | `aw_line_list/create/start/stop`、`aw_product_create`、`aw_recipe_create` |
|
|
75
|
+
| DCW 节点与参数映射 | `aw_dcw_snapshot/create/write/read`、`aw_param_list/write/read` |
|
|
76
|
+
| DAQ 数采 | `aw_daq_create`、`aw_daq_controller`、`aw_daq_samples` |
|
|
77
|
+
| 优化闭环频道 | `aw_channel_list/create`、`aw_channel_template_list/instantiate`、`aw_team_provision`(组合:建 agent→team→成员→deploy)、`aw_agent_tool_bind/invoke`、`aw_twin_profile_get/patch`、`aw_task_create/list`、`aw_model_list/promote`、`aw_optimization_judge` |
|
|
78
|
+
| 插件 | `aw_plugin_list`、`aw_plugin_toggle` |
|
|
79
|
+
| 逃生舱 | `aw_request`(通用 REST,path 必须以 `/api/` 开头) |
|
|
80
|
+
|
|
81
|
+
`aw_agent_tool_invoke` 可调用频道成员实例的全部宿主工具面
|
|
82
|
+
(`optimization_explore` / `mpc_optimize` / `twin_*` / `dcw_control` / `param_control` / `daq_query` 等),
|
|
83
|
+
是探索/寻优闭环的执行通道。
|
|
84
|
+
|
|
85
|
+
## 六、与 skills 的集成
|
|
86
|
+
|
|
87
|
+
三个项目级 skill 以本服务为执行底座(`skills/` 目录):
|
|
88
|
+
|
|
89
|
+
- `skills/aw-node-bind/` —— 真实场景节点参数绑定(建线→绑执行点→参数映射→配方开跑→回环验收)
|
|
90
|
+
- `skills/aw-opt-channel/` —— 场景优化闭环频道(模板实例化→剧组→探索→AML 门禁→绑定→投用)
|
|
91
|
+
- `skills/aw-plugin-dev/` —— 插件开发(脚手架→setup(ctx)→热重载验证→发布清单)
|
|
92
|
+
|
|
93
|
+
规范校验:`npm run test:skills`(含"skill 引用的工具必须真实存在于 MCP 工具面"的一致性检查)。
|
|
94
|
+
|
|
95
|
+
## 七、测试
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npm run test:mcp # 单测(12 断言组):锁解析/发现优先级/RPC 面/懒登录/断线重发现/逃生舱守卫
|
|
99
|
+
npm run test:mcp-live # 真实实例 e2e(34 断言):隔离 home 实例 + 零端口提示自发现 + 全链业务
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
live e2e 的隔离纪律:临时 `AW_HOME` + 端口 3461,结束 `taskkill //T` 清场,不碰真实库。
|
|
103
|
+
|
|
104
|
+
## 八、已知边界(有意为之)
|
|
105
|
+
|
|
106
|
+
- `GET /api/workshop/plugins` 等少数端点是裸 `defineEventHandler`(无统一信封),服务端已做信封嗅探兼容。
|
|
107
|
+
- MCP 不代理模拟器 REST(presets/export);skill 流程里对模拟器的访问走直连(默认 `http://127.0.0.1:4010`)。
|
|
108
|
+
- `aw_request` 限制 method 白名单与 `/api/` 前缀,不代理任意外网。
|
package/docs/plugins.en.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
>
|
|
10
10
|
> Applies to: plugin system v2 has been available since **v0.7.29** (frontend component
|
|
11
11
|
> injection / plugin settings / plugin i18n / runtime services surface); this document
|
|
12
|
-
> describes **v0.7.
|
|
12
|
+
> describes **v0.7.51**. `ctx.sdkVersion` is currently `0.3.0`.
|
|
13
13
|
|
|
14
14
|
## 1. Folder layout & quick start
|
|
15
15
|
|
package/docs/plugins.md
CHANGED
package/docs/sdk.en.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
**SDK version constants**: server-side `SDK_VERSION = '0.3.0'`, browser-side `CLIENT_SDK_VERSION = '0.3.0'`.
|
|
9
9
|
These two constants are the **interface version of the SDK itself** and evolve **independently**
|
|
10
|
-
from the npm package version (the `version` field in `package.json`, currently 0.7.
|
|
10
|
+
from the npm package version (the `version` field in `package.json`, currently 0.7.51) —
|
|
11
11
|
them being out of sync is expected. Never use `SDK_VERSION` to infer the package version, or the reverse.
|
|
12
12
|
**Module format**: ESM only (only `import` / `export`; there is no CJS entry).
|
|
13
13
|
**Types**: `sdk/index.d.mts` and `sdk/client.d.mts` ship with the package, so TypeScript projects
|
package/docs/sdk.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
> 零第三方运行时依赖,Node ≥ 23.4 与现代浏览器双端可用。
|
|
6
6
|
|
|
7
7
|
**SDK 版本常量**:服务端 `SDK_VERSION = '0.3.0'`,浏览器端 `CLIENT_SDK_VERSION = '0.3.0'`。
|
|
8
|
-
这两个常量是 **SDK 自身接口的版本号**,与 npm 包版本(`package.json` 的 `version`,当前 0.7.
|
|
8
|
+
这两个常量是 **SDK 自身接口的版本号**,与 npm 包版本(`package.json` 的 `version`,当前 0.7.51)
|
|
9
9
|
**各自独立演进** —— 常数不同步是预期行为,不要拿 `SDK_VERSION` 去推断包版本,反之亦然。
|
|
10
10
|
**模块形态**:ESM only(只有 `import` / `export`,没有 CJS 入口)。
|
|
11
11
|
**类型**:`sdk/index.d.mts`、`sdk/client.d.mts` 随包发布,TS 项目零配置获得提示(覆盖范围见 §7)。
|