@capyclaw/wall-suite 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +20 -2
- package/composition.lock.json +48 -0
- package/contract/wall-contract.json +8 -0
- package/cordis.patch.yml +6 -0
- package/dsh-suite.json +118 -0
- package/lib/index.mjs +6 -0
- package/node_modules/@capyclaw/asset-service/README.md +48 -0
- package/node_modules/@capyclaw/asset-service/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/asset-service/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/asset-service/lib/host.mjs +14 -0
- package/node_modules/@capyclaw/asset-service/package.json +59 -0
- package/node_modules/@capyclaw/asset-service/src/index.mjs +223 -0
- package/node_modules/@capyclaw/foundation/README.md +51 -0
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +86 -0
- package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
- package/node_modules/@capyclaw/foundation/abi/index.mjs +35 -0
- package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +345 -0
- package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +255 -0
- package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
- package/node_modules/@capyclaw/foundation/abi/version.mjs +82 -0
- package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
- package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +55 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +68 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
- package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
- package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +34 -0
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +85 -0
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +160 -0
- package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +185 -0
- package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +87 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +188 -0
- package/node_modules/@capyclaw/foundation/package.json +53 -0
- package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
- package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
- package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
- package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
- package/node_modules/@capyclaw/plugin-kit/package.json +69 -0
- package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
- package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +129 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +139 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
- package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
- package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +143 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
- package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +41 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
- package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +656 -0
- package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
- package/node_modules/@capyclaw/portal/README.md +70 -0
- package/node_modules/@capyclaw/portal/lib/index.mjs +387 -0
- package/node_modules/@capyclaw/portal/lib/ledger.mjs +194 -0
- package/node_modules/@capyclaw/portal/lib/portal-agent.ps1 +811 -0
- package/node_modules/@capyclaw/portal/lib/portal-darwin.mjs +183 -0
- package/node_modules/@capyclaw/portal/package.json +40 -0
- package/node_modules/@capyclaw/service-broker/README.md +104 -0
- package/node_modules/@capyclaw/service-broker/cordis.patch.yml +8 -0
- package/node_modules/@capyclaw/service-broker/dsh-suite.json +21 -0
- package/node_modules/@capyclaw/service-broker/lib/control.mjs +193 -0
- package/node_modules/@capyclaw/service-broker/lib/discovery.mjs +109 -0
- package/node_modules/@capyclaw/service-broker/lib/engine.mjs +1236 -0
- package/node_modules/@capyclaw/service-broker/lib/host.mjs +182 -0
- package/node_modules/@capyclaw/service-broker/lib/manifest.mjs +249 -0
- package/node_modules/@capyclaw/service-broker/lib/recovery.mjs +325 -0
- package/node_modules/@capyclaw/service-broker/lib/skills-client.mjs +28 -0
- package/node_modules/@capyclaw/service-broker/lib/spec.mjs +78 -0
- package/node_modules/@capyclaw/service-broker/package.json +65 -0
- package/node_modules/@capyclaw/service-broker/server.mjs +81 -0
- package/node_modules/@capyclaw/service-broker/service.schema.json +62 -0
- package/node_modules/@capyclaw/service-broker/services.json +3 -0
- package/node_modules/@capyclaw/service-host/README.md +86 -0
- package/node_modules/@capyclaw/service-host/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/service-host/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/service-host/lib/host.mjs +22 -0
- package/node_modules/@capyclaw/service-host/package.json +60 -0
- package/node_modules/@capyclaw/service-host/src/index.mjs +571 -0
- package/node_modules/@capyclaw/service-host/src/tuning.mjs +63 -0
- package/node_modules/@capyclaw/tool-host/README.md +56 -0
- package/node_modules/@capyclaw/tool-host/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/tool-host/dsh-suite.json +30 -0
- package/node_modules/@capyclaw/tool-host/lib/host.mjs +16 -0
- package/node_modules/@capyclaw/tool-host/package.json +59 -0
- package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +142 -0
- package/node_modules/@capyclaw/tool-host/src/index.mjs +390 -0
- package/node_modules/@capyclaw/wall-workbench/README.md +58 -0
- package/node_modules/@capyclaw/wall-workbench/contract/wall-contract.json +8 -0
- package/node_modules/@capyclaw/wall-workbench/lib/host.mjs +1 -0
- package/node_modules/@capyclaw/wall-workbench/package.json +63 -0
- package/node_modules/@capyclaw/wall-workbench/plugin.mjs +1 -0
- package/node_modules/@capyclaw/wall-workbench/server/constants.mjs +12 -0
- package/node_modules/@capyclaw/wall-workbench/server/contract.mjs +12 -0
- package/node_modules/@capyclaw/wall-workbench/server/embedded-host.mjs +160 -0
- package/node_modules/@capyclaw/wall-workbench/server/infra/http.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/infra/tuning.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/relay.mjs +68 -0
- package/node_modules/@capyclaw/wall-workbench/server/routes/claim.mjs +46 -0
- package/node_modules/@capyclaw/wall-workbench/server/routes/workbench.mjs +29 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/SHARED_MANIFEST.json +70 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/asset-service.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/editor-host.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/editor/lease.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/service/api.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/service/http.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/service/mcp-http.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/tools/validate.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/tuning.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/kit/util/fs-lock.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/service-host.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/tool-host.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/shared/tuning.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/tools/capabilities/index.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/tools/index.mjs +12 -0
- package/node_modules/@capyclaw/wall-workbench/server/tools.mjs +2 -0
- package/node_modules/@capyclaw/wall-workbench/server/workbench-framework.mjs +305 -0
- package/node_modules/@capyclaw/wall-workbench/ui/app.js +142 -0
- package/node_modules/@capyclaw/wall-workbench/ui/index.html +20 -0
- package/node_modules/@capyclaw/wall-workbench/ui/style.css +74 -0
- package/package.json +72 -4
- package/services.json +3 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @capyclaw/wall-workbench
|
|
2
|
+
|
|
3
|
+
展示墙工作台运行时:主区的**空态选择器**。会话还没有绑定工作台模式时,主区舞台摆出这扇墙,列出当前 profile 已注册的工作台类型(ppt / canvas / browser …,类型无关、动态读取);用户点选即**显式认领**会话模式,舞台随后收掉墙、摆出真实工作台。
|
|
4
|
+
|
|
5
|
+
最精简的工作台实例:**零 MCP 工具、零引擎、零文档模型**(`declareBridge({ model: null })`),与 browser 同构但没有 Playwright 面。
|
|
6
|
+
|
|
7
|
+
## 组成
|
|
8
|
+
|
|
9
|
+
- `server/relay.mjs` — `createWorkbench` 业务装配(静态选择器页 + `/claim` 认领端点)。
|
|
10
|
+
- `server/embedded-host.mjs` — cordis 宿主入口(手写精简版):挂宿主路由、`__host__` 自检、活动台账。
|
|
11
|
+
- `server/routes/claim.mjs` — `POST /claim {sid?, kind}`:经 work-store `claimSessionMode(..., { explicit: true })` 认领;底座缺席降级 `skipped`。
|
|
12
|
+
- `ui/` — 选择器页(读 `/__portal_hud__/state` 渲染卡片;支持舞台 retarget 换会话)。
|
|
13
|
+
- `server/workbench-framework.mjs` — 构建期从 `A/build/framework/` 拷入的公共骨架(HTTP/锁/发现/独立入口)。
|
|
14
|
+
|
|
15
|
+
## 快速开始
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# 构建产物(本仓库)
|
|
19
|
+
node build/build-plugin.mjs
|
|
20
|
+
|
|
21
|
+
# standalone(仅开发/调试;无 portal-hud 注册信息,页面降级为提示)
|
|
22
|
+
node artifacts/plugin/capyclaw-wall-workbench/server/relay.mjs --port 39319
|
|
23
|
+
|
|
24
|
+
# 生产:作为 DSH 插件挂进 profile(embedded,不监听端口)
|
|
25
|
+
dsh plugin --profile web add @capyclaw/wall-suite
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 端点
|
|
29
|
+
|
|
30
|
+
| 方法 | 路径 | 说明 |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| GET | `/`(及 `/index.html` `/app.js` `/style.css`) | 选择器页(白名单静态) |
|
|
33
|
+
| POST | `/claim` | 显式认领会话模式,body `{sid?, kind}`;回 `{ok, kind, fresh?, explicit?, skipped?, lockedTo?}` |
|
|
34
|
+
| GET | `/healthz` `/metrics` | 框架内置健康/指标 |
|
|
35
|
+
| GET | `<mount>/__host__` | 宿主自检(embedded) |
|
|
36
|
+
|
|
37
|
+
`/s/<sid>` 会话段由 service-host 剥层:页面从 `location.pathname` 读 sid,认领时放进 body(retarget 后 URL 可能仍是旧会话)。
|
|
38
|
+
|
|
39
|
+
## 配置
|
|
40
|
+
|
|
41
|
+
| 来源 | 说明 |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `config.mountPath` | 挂载前缀,默认 `/capyclaw/wall` |
|
|
44
|
+
| `config.hostDir` / `WALL_BRIDGE_HOME` | 状态目录(embedded 缺省 `~/.dsh/workbenches/wall-workbench`) |
|
|
45
|
+
| `config.strictPort` / `config.allowReuse` | standalone 端口策略 |
|
|
46
|
+
|
|
47
|
+
## 架构
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
plugin.mjs → server/embedded-host.mjs(cordis 入口,inject: webServer)
|
|
51
|
+
→ server/relay.mjs(createWorkbench 业务钩子)
|
|
52
|
+
→ server/workbench-framework.mjs(公共骨架:HTTP/锁/MCP 装配/独立入口)
|
|
53
|
+
→ server/routes/{workbench,claim}.mjs + ui/(选择器页)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 许可证
|
|
57
|
+
|
|
58
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { name, apply } from '../server/embedded-host.mjs'
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capyclaw/wall-workbench",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "展示墙工作台运行时:主区空态选择器(列出已注册工作台类型,点选显式认领会话模式)。零工具、零引擎、零文档模型。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./plugin.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./plugin.mjs",
|
|
9
|
+
"./package.json": "./package.json"
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18",
|
|
13
|
+
"dsh": "^0.2.0-rc.2"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"dsh": {
|
|
19
|
+
"member": true,
|
|
20
|
+
"category": "service",
|
|
21
|
+
"platform": "both",
|
|
22
|
+
"capabilities": {
|
|
23
|
+
"source": "server/tools/capabilities",
|
|
24
|
+
"manifest": "capabilities.json"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"meta": {
|
|
28
|
+
"title": "展示墙工作台运行时",
|
|
29
|
+
"description": "主区空态选择器:会话未绑定模式时列出已注册的工作台类型,点选即显式认领会话模式(挂在 dsh 的 /capyclaw/wall,路由与端口由基建决定)"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"plugin.mjs",
|
|
33
|
+
"lib/",
|
|
34
|
+
"server/",
|
|
35
|
+
"ui/",
|
|
36
|
+
"!server/.relay-instance.lock",
|
|
37
|
+
"contract/",
|
|
38
|
+
"README.md"
|
|
39
|
+
],
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"scripts": {},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@capyclaw/asset-service": "^0.1.4",
|
|
44
|
+
"@capyclaw/foundation": "^0.1.9",
|
|
45
|
+
"@capyclaw/plugin-kit": "^0.2.6",
|
|
46
|
+
"@capyclaw/service-host": "^0.1.5",
|
|
47
|
+
"@capyclaw/tool-host": "^0.2.0"
|
|
48
|
+
},
|
|
49
|
+
"author": {
|
|
50
|
+
"name": "CapyClaw",
|
|
51
|
+
"url": "https://github.com/capyclaw",
|
|
52
|
+
"email": "support@capyclaw.dev"
|
|
53
|
+
},
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "git+https://github.com/Maple496/capyclaw.git",
|
|
57
|
+
"directory": "A/projects/wall/artifacts/plugin/capyclaw-wall-workbench"
|
|
58
|
+
},
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/Maple496/capyclaw/issues"
|
|
61
|
+
},
|
|
62
|
+
"homepage": "https://github.com/Maple496/capyclaw/tree/main/A/projects/wall/artifacts/plugin/capyclaw-wall-workbench#readme"
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { name, inject, apply } from './server/embedded-host.mjs'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** 墙的稳定常量(relay/routes/tests 共用,避免循环 import)。 */
|
|
2
|
+
|
|
3
|
+
/* standalone(仅开发/调试)默认端口;embedded 形态挂宿主路由,不监听端口。 */
|
|
4
|
+
export const DEFAULT_PORT = 39319
|
|
5
|
+
|
|
6
|
+
/** 工作台静态页(白名单,杜绝路径穿越;相对 ui/)。 */
|
|
7
|
+
export const WALL_FILES = {
|
|
8
|
+
'/': ['index.html', 'text/html; charset=utf-8'],
|
|
9
|
+
'/index.html': ['index.html', 'text/html; charset=utf-8'],
|
|
10
|
+
'/app.js': ['app.js', 'text/javascript; charset=utf-8'],
|
|
11
|
+
'/style.css': ['style.css', 'text/css; charset=utf-8'],
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP 工具契约的唯一真源(版本号)。
|
|
3
|
+
*
|
|
4
|
+
* 展示墙零工具:契约面是空数组(tools.mjs),版本号供 suite 清单与巡检对账。
|
|
5
|
+
* 新增能力只改 tools/capabilities/index.mjs(当前为空)。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** 工具契约版本:工具名、参数、返回结构发生不兼容变化时升 major。 */
|
|
9
|
+
export const CONTRACT_VERSION = '1.0.0'
|
|
10
|
+
|
|
11
|
+
/** 工作台包版本。 */
|
|
12
|
+
export const PACKAGE_VERSION = '0.1.0'
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @capyclaw/wall-workbench 宿主插件(cordis 入口,loader 经包名加载本模块)。
|
|
3
|
+
*
|
|
4
|
+
* 承载形态由**基建**决定,业务插件不选端口:
|
|
5
|
+
* - 有 ctx.webServer(生产):挂到宿主 HTTP 路由前缀下,不监听任何端口,
|
|
6
|
+
* 生命周期随 DSH 启停;前缀由基建给(默认 /capyclaw/wall)。
|
|
7
|
+
* - 没有 webServer(开发/测试):才退回独立 loopback 端口。
|
|
8
|
+
*
|
|
9
|
+
* 与 ppt/canvas 的公共 host 模板不同,本文件为手写精简版(照 browser 先例):
|
|
10
|
+
* 展示墙零工具、零引擎、零文档 store/journal/workspace 依赖,装配面只有
|
|
11
|
+
* serviceHost 契约 + workStore 懒解析器 + 静态页/认领路由。
|
|
12
|
+
*/
|
|
13
|
+
import os from 'node:os'
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
import fs from 'node:fs'
|
|
16
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
17
|
+
import { assertServiceApi } from './shared/kit/service/api.mjs'
|
|
18
|
+
|
|
19
|
+
export const name = 'wall-workbench-host'
|
|
20
|
+
/* 依赖倒置:业务等的是「宿主给的 HTTP 路由」,不是端口。 */
|
|
21
|
+
export const inject = ['webServer']
|
|
22
|
+
|
|
23
|
+
function safeGet(ctx, serviceName) {
|
|
24
|
+
// 原生插件里 ctx.get(name) 只对已 inject 的服务放行;可选依赖用 reflect.get
|
|
25
|
+
// 才不会因为「没在 inject 列表里」被拒绝(core 也是这么取依赖的)。
|
|
26
|
+
try {
|
|
27
|
+
if (ctx && ctx.reflect && typeof ctx.reflect.get === 'function') return ctx.reflect.get(serviceName)
|
|
28
|
+
return ctx?.get ? ctx.get(serviceName) : null
|
|
29
|
+
} catch { return null }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function requireApi(service, name) {
|
|
33
|
+
if (service) assertServiceApi(service, { name, major: 1 })
|
|
34
|
+
return service
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** 基建依赖(@capyclaw/portal)不保证在工作台包的依赖树里,按约定位置兜底解析。 */
|
|
38
|
+
async function loadPortal() {
|
|
39
|
+
try {
|
|
40
|
+
return await import('@capyclaw/portal')
|
|
41
|
+
} catch { /* 落到 profile 扫描 */ }
|
|
42
|
+
const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
|
|
43
|
+
const roots = []
|
|
44
|
+
try {
|
|
45
|
+
for (const dir of fs.readdirSync(path.join(home, 'profiles'))) roots.push(path.join(home, 'profiles', dir, 'node_modules'))
|
|
46
|
+
} catch { /* 没有 profiles 目录 */ }
|
|
47
|
+
for (const root of roots) {
|
|
48
|
+
for (const scope of ['core', 'ppt-suite', 'canvas-suite', 'browser-suite', 'wall-suite']) {
|
|
49
|
+
const file = path.join(root, '@capyclaw', scope, 'node_modules', '@capyclaw', 'portal', 'lib', 'index.mjs')
|
|
50
|
+
if (!fs.existsSync(file)) continue
|
|
51
|
+
try {
|
|
52
|
+
return await import(pathToFileURL(file).href)
|
|
53
|
+
} catch { /* 试下一个 */ }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 激活失败的完整栈只留在宿主日志里,插件管理器/Web UI 只显示第一行;
|
|
61
|
+
* 这里把栈落到 hostDir,下次「1 entry did not activate」时能直接看到根因。
|
|
62
|
+
*/
|
|
63
|
+
export async function apply(ctx, config) {
|
|
64
|
+
try {
|
|
65
|
+
return await activate(ctx, config)
|
|
66
|
+
} catch (error) {
|
|
67
|
+
try {
|
|
68
|
+
const fallbackDir = path.join(os.homedir(), '.dsh-wall-bridge')
|
|
69
|
+
const hostDir = (config && config.hostDir) || process.env.WALL_BRIDGE_HOME || fallbackDir
|
|
70
|
+
fs.mkdirSync(hostDir, { recursive: true })
|
|
71
|
+
fs.appendFileSync(
|
|
72
|
+
path.join(hostDir, 'activate-error.log'),
|
|
73
|
+
`[${new Date().toISOString()}] ${(error && error.stack) || error}\n`,
|
|
74
|
+
)
|
|
75
|
+
} catch { /* 诊断写盘失败不能覆盖真正的激活错误 */ }
|
|
76
|
+
throw error
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function activate(ctx, config) {
|
|
81
|
+
const packageDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
82
|
+
const { startRelay } = await import('./relay.mjs')
|
|
83
|
+
const hostDir = (config && config.hostDir)
|
|
84
|
+
|| process.env.WALL_BRIDGE_HOME
|
|
85
|
+
|| path.join(os.homedir(), '.dsh-wall-bridge')
|
|
86
|
+
/* 公共插件 API 契约:存在则校验 major,避免静默不兼容。 */
|
|
87
|
+
const serviceHost = requireApi(safeGet(ctx, 'serviceHost'), 'serviceHost')
|
|
88
|
+
|
|
89
|
+
const webServer = safeGet(ctx, 'webServer')
|
|
90
|
+
const mountPath = (config && config.mountPath) || '/capyclaw/wall'
|
|
91
|
+
const relayOptions = {
|
|
92
|
+
packageDir,
|
|
93
|
+
hostDir,
|
|
94
|
+
serviceHost,
|
|
95
|
+
strictPort: config?.strictPort != null ? !!config.strictPort : false,
|
|
96
|
+
allowReuse: config?.allowReuse != null ? !!config.allowReuse : true,
|
|
97
|
+
/* 会话模式锁的底座懒解析器(works.db 单一真源);底座缺席时认领自动 skipped。 */
|
|
98
|
+
getWorkStore: () => safeGet(ctx, 'workStore'),
|
|
99
|
+
}
|
|
100
|
+
if (webServer) {
|
|
101
|
+
relayOptions.webServer = webServer
|
|
102
|
+
relayOptions.mountPrefix = mountPath
|
|
103
|
+
} else {
|
|
104
|
+
/* 仅开发/测试:没有宿主路由时才自己听一个 loopback 端口。
|
|
105
|
+
端口写 0 = 交给操作系统分配;真实地址由 relay listen 之后给出。 */
|
|
106
|
+
relayOptions.port = (config && Number(config.port)) || 0
|
|
107
|
+
}
|
|
108
|
+
const relay = await startRelay(relayOptions)
|
|
109
|
+
|
|
110
|
+
const disposers = []
|
|
111
|
+
|
|
112
|
+
/* 自检端点:GET <前缀>/__host__。url 给入口地址(与 mount 同址)→
|
|
113
|
+
* 舞台读出 bridgePath='' → 无桥 → 内容闸对墙默认放行(墙是空态占位,不是文档编辑器)。 */
|
|
114
|
+
if (webServer && typeof webServer.register === 'function') {
|
|
115
|
+
const dispose = webServer.register({
|
|
116
|
+
kind: 'exact',
|
|
117
|
+
path: `${mountPath}/__host__`,
|
|
118
|
+
handler: (req, res) => {
|
|
119
|
+
const body = JSON.stringify({
|
|
120
|
+
workbench: 'wall',
|
|
121
|
+
mode: relay.mode,
|
|
122
|
+
url: relay.editorUrl,
|
|
123
|
+
editorUrl: relay.editorUrl,
|
|
124
|
+
mountPath,
|
|
125
|
+
tools: null,
|
|
126
|
+
}, null, 2)
|
|
127
|
+
res.writeHead(200, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
|
|
128
|
+
res.end(body)
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
if (typeof dispose === 'function') disposers.push(dispose)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* 活动台账:embedded 形态没有端口,记 url 即可。注册行没有 title 字段,
|
|
135
|
+
* 主区舞台 /state 的标题靠台账补——这里给墙一个人类可读的名字。 */
|
|
136
|
+
try {
|
|
137
|
+
const portal = await loadPortal()
|
|
138
|
+
if (portal && typeof portal.recordActivity === 'function') {
|
|
139
|
+
portal.recordActivity({
|
|
140
|
+
id: 'wall-workbench',
|
|
141
|
+
url: relay.editorUrl,
|
|
142
|
+
title: (config && config.title) || '展示墙',
|
|
143
|
+
kind: 'service',
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
} catch { /* 台账失败不影响服务 */ }
|
|
147
|
+
|
|
148
|
+
console.log(relay.reused
|
|
149
|
+
? `[wall-workbench] 复用已运行的墙: ${relay.url}`
|
|
150
|
+
: `[wall-workbench] 墙已就绪: ${relay.url}`)
|
|
151
|
+
console.log(`[wall-workbench] 展示墙: ${relay.editorUrl}(${relay.mode === 'embedded' ? '挂在宿主路由,无端口' : '独立端口'})`)
|
|
152
|
+
|
|
153
|
+
return async () => {
|
|
154
|
+
for (const dispose of disposers) {
|
|
155
|
+
try { dispose() } catch { /* 忽略 */ }
|
|
156
|
+
}
|
|
157
|
+
await relay.stop()
|
|
158
|
+
console.log('[wall-workbench] 墙已停止')
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 展示墙 relay:**业务装配**(HTTP/锁/发现/独立入口由 server/workbench-framework.mjs 提供)。
|
|
3
|
+
*
|
|
4
|
+
* 展示墙是主区的空态选择器:列出已注册的工作台类型,用户点选即显式认领
|
|
5
|
+
* 会话模式(POST /claim)。零工具、零引擎、零文档模型——最精简的工作台实例,
|
|
6
|
+
* 与 browser 同构但没有 Playwright 面。
|
|
7
|
+
*
|
|
8
|
+
* 也可脱离 dsh 独立运行:node server/relay.mjs [--port 39319] [--dir <hostDir>]
|
|
9
|
+
* (standalone 形态没有 portal-hud 注册信息,页面降级为提示。)
|
|
10
|
+
*/
|
|
11
|
+
import { declareBridge } from '@capyclaw/foundation/abi'
|
|
12
|
+
import { CONTRACT_VERSION, PACKAGE_VERSION } from './contract.mjs'
|
|
13
|
+
import { DEFAULT_PORT } from './constants.mjs'
|
|
14
|
+
import { createWorkbenchRoutes } from './routes/workbench.mjs'
|
|
15
|
+
import { createClaimRoute } from './routes/claim.mjs'
|
|
16
|
+
import { runIfMain, createWorkbench } from './workbench-framework.mjs'
|
|
17
|
+
|
|
18
|
+
export { DEFAULT_PORT }
|
|
19
|
+
|
|
20
|
+
export const startRelay = createWorkbench({
|
|
21
|
+
id: 'wall-workbench',
|
|
22
|
+
title: 'Wall Workbench',
|
|
23
|
+
packageVersion: PACKAGE_VERSION,
|
|
24
|
+
contractVersion: CONTRACT_VERSION,
|
|
25
|
+
/* 展示墙是桥,但不提供文档模型(它是选择器,不是编辑器)。 */
|
|
26
|
+
bridge: declareBridge({ id: 'wall-workbench', model: null }),
|
|
27
|
+
/* 端口不再由业务决定:embedded 形态挂宿主路由,standalone(仅开发)才用 options.port。 */
|
|
28
|
+
basePath: '',
|
|
29
|
+
homeEnv: 'WALL_BRIDGE_HOME',
|
|
30
|
+
defaultHome: '.dsh-wall-bridge',
|
|
31
|
+
|
|
32
|
+
createStore: () => ({}),
|
|
33
|
+
|
|
34
|
+
/* 静态选择器页 + 显式认领端点。没有 MCP 面(省略 tools 钩子 → relay.tools=null),
|
|
35
|
+
* 也不需要会话缝入:claim 显式带 sid,静态页无会话状态。 */
|
|
36
|
+
routes: (ctx) => [
|
|
37
|
+
...createWorkbenchRoutes({ packageDir: ctx.packageDir }),
|
|
38
|
+
createClaimRoute(ctx),
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
health: (ctx) => ({
|
|
42
|
+
bridge: 'wall-workbench',
|
|
43
|
+
workbench: ctx.editorUrl,
|
|
44
|
+
selector: true,
|
|
45
|
+
injected: {
|
|
46
|
+
serviceHost: !!ctx.serviceHost,
|
|
47
|
+
workStore: !!(typeof ctx.getWorkStore === 'function' && ctx.getWorkStore()),
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
50
|
+
|
|
51
|
+
metrics: () => [
|
|
52
|
+
['wall_workbench_memory_rss_bytes', process.memoryUsage().rss],
|
|
53
|
+
],
|
|
54
|
+
|
|
55
|
+
resultExtras: (ctx) => ({
|
|
56
|
+
workbenchUrl: ctx.editorUrl,
|
|
57
|
+
mountPath: ctx.mountPath,
|
|
58
|
+
}),
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
/* ---- 独立运行入口(无 dsh 也可手动拉起,供调试/演示)---- */
|
|
62
|
+
runIfMain(import.meta.url, async ({ port, dir }) => {
|
|
63
|
+
const relay = await startRelay({
|
|
64
|
+
port: port || DEFAULT_PORT,
|
|
65
|
+
hostDir: dir || process.env.WALL_BRIDGE_HOME || undefined,
|
|
66
|
+
})
|
|
67
|
+
console.log('[wall-workbench] 展示墙:', relay.workbenchUrl, '(浏览器打开即用;standalone 无注册信息,页面降级为提示)')
|
|
68
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 展示墙的显式认领端点:POST /claim {sid?, kind}。
|
|
3
|
+
*
|
|
4
|
+
* 墙自己零工具、不走懒认领写闸;用户在页面上点选类型时由这里代为认领
|
|
5
|
+
* (explicit:true —— 宿主半据此豁免内容闸,全新会话也能立刻摆出真实工作台)。
|
|
6
|
+
*
|
|
7
|
+
* sid 优先取 body:retarget 之后 iframe 的 URL 可能还带着旧会话段,
|
|
8
|
+
* 页面总是把当前 sid 放进 body;URL 的 /s/<sid> 段(u.sessionId)作兜底。
|
|
9
|
+
*
|
|
10
|
+
* work-store 底座缺席时降级 skipped(不启用模式锁),与
|
|
11
|
+
* @capyclaw/document-workbench/session-mode 的 createSessionModeRegistry 同语义。
|
|
12
|
+
* 认领结果原样回给页面:ok:false 带 lockedTo(已固化)也由页面提示,HTTP 仍 200。
|
|
13
|
+
*/
|
|
14
|
+
import { readBody } from '../shared/kit/service/http.mjs'
|
|
15
|
+
|
|
16
|
+
const KIND_RE = /^[a-z0-9][a-z0-9-]{0,63}$/
|
|
17
|
+
|
|
18
|
+
function replyJson(res, code, body) {
|
|
19
|
+
res.writeHead(code, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' })
|
|
20
|
+
res.end(JSON.stringify(body))
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createClaimRoute(ctx) {
|
|
24
|
+
return async (req, res, u) => {
|
|
25
|
+
if (req.method !== 'POST' || u.pathname !== '/claim') return false
|
|
26
|
+
let body
|
|
27
|
+
try {
|
|
28
|
+
body = await readBody(req, 64 * 1024)
|
|
29
|
+
} catch (error) {
|
|
30
|
+
replyJson(res, error && error.code === 'BODY_TOO_LARGE' ? 413 : 400, { ok: false, error: '请求体不是合法 JSON' })
|
|
31
|
+
return true
|
|
32
|
+
}
|
|
33
|
+
const kind = String((body && body.kind) || '')
|
|
34
|
+
if (!KIND_RE.test(kind)) {
|
|
35
|
+
replyJson(res, 400, { ok: false, error: 'kind 必须是 kebab-case 的工作台种类' })
|
|
36
|
+
return true
|
|
37
|
+
}
|
|
38
|
+
const sid = String((body && body.sid) || u.sessionId || '')
|
|
39
|
+
const ws = typeof ctx.getWorkStore === 'function' ? ctx.getWorkStore() : null
|
|
40
|
+
const result = (!ws || typeof ws.claimSessionMode !== 'function')
|
|
41
|
+
? { ok: true, kind, skipped: true }
|
|
42
|
+
: ws.claimSessionMode(sid, kind, 'wall-workbench', { explicit: true })
|
|
43
|
+
replyJson(res, 200, result)
|
|
44
|
+
return true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** 展示墙静态页(白名单路由,杜绝路径穿越)。 */
|
|
2
|
+
import { readFile } from 'node:fs/promises'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { WALL_FILES } from '../constants.mjs'
|
|
6
|
+
|
|
7
|
+
export function createWorkbenchRoutes({ packageDir }) {
|
|
8
|
+
const uiDir = path.join(packageDir, 'ui')
|
|
9
|
+
return [
|
|
10
|
+
async (req, res, u) => {
|
|
11
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') return false
|
|
12
|
+
const entry = WALL_FILES[u.pathname]
|
|
13
|
+
if (!entry) return false
|
|
14
|
+
try {
|
|
15
|
+
const content = await readFile(path.join(uiDir, entry[0]))
|
|
16
|
+
res.writeHead(200, {
|
|
17
|
+
'content-type': entry[1],
|
|
18
|
+
'cache-control': 'no-store',
|
|
19
|
+
'x-content-type-options': 'nosniff',
|
|
20
|
+
})
|
|
21
|
+
res.end(req.method === 'HEAD' ? undefined : content)
|
|
22
|
+
} catch {
|
|
23
|
+
res.writeHead(404, { 'content-type': 'text/plain; charset=utf-8' })
|
|
24
|
+
res.end('Not found')
|
|
25
|
+
}
|
|
26
|
+
return true
|
|
27
|
+
},
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"mode": "re-export",
|
|
4
|
+
"packages": {
|
|
5
|
+
"service-host": {
|
|
6
|
+
"package": "@capyclaw/service-host",
|
|
7
|
+
"version": "0.1.5",
|
|
8
|
+
"apiVersion": "1.0.0",
|
|
9
|
+
"spec": "@capyclaw/service-host/src",
|
|
10
|
+
"sha256": "af0a57d779bfe6a66dc935320178d591ef799a7e037f7a5823cdfa1fe5878eeb"
|
|
11
|
+
},
|
|
12
|
+
"tool-host": {
|
|
13
|
+
"package": "@capyclaw/tool-host",
|
|
14
|
+
"version": "0.2.0",
|
|
15
|
+
"apiVersion": "1.1.0",
|
|
16
|
+
"spec": "@capyclaw/tool-host/src",
|
|
17
|
+
"sha256": "23256dbcd5cbee0b96b33c97e4eb4e74d0e169cbdde52f91d4526f2fc0f60d3e"
|
|
18
|
+
},
|
|
19
|
+
"asset-service": {
|
|
20
|
+
"package": "@capyclaw/asset-service",
|
|
21
|
+
"version": "0.1.4",
|
|
22
|
+
"apiVersion": "1.0.0",
|
|
23
|
+
"spec": "@capyclaw/asset-service/src",
|
|
24
|
+
"sha256": "311a83e95d56dbb69b739d61aced0889b64e85eddd95b883e322e0fa5be8bd6f"
|
|
25
|
+
},
|
|
26
|
+
"editor-host": {
|
|
27
|
+
"package": "@capyclaw/editor-host",
|
|
28
|
+
"version": "0.1.5",
|
|
29
|
+
"apiVersion": "1.0.0",
|
|
30
|
+
"spec": "@capyclaw/editor-host/src",
|
|
31
|
+
"sha256": "c8b80dbd4f1b2bee9ef9001423a013031a21ea9a3b8897b5536fe6e5687f01b3"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"kit": {
|
|
35
|
+
"tuning.mjs": {
|
|
36
|
+
"spec": "@capyclaw/plugin-kit/tuning",
|
|
37
|
+
"sha256": "6dc1d89c97056b03c27d744e6256e0e8d88a772c340acc6e04a3413e9ee5cc8b"
|
|
38
|
+
},
|
|
39
|
+
"service/api.mjs": {
|
|
40
|
+
"spec": "@capyclaw/plugin-kit/service/api",
|
|
41
|
+
"sha256": "336a92237d5575709d421cb8199bad7c56fbd95bfd2b30b5d9b913f719db8402"
|
|
42
|
+
},
|
|
43
|
+
"service/http.mjs": {
|
|
44
|
+
"spec": "@capyclaw/plugin-kit/service/http",
|
|
45
|
+
"sha256": "5839bf8872a208f14a219ba7528e2d19e9884f6e6a2645689d58369952d0476f"
|
|
46
|
+
},
|
|
47
|
+
"service/mcp-http.mjs": {
|
|
48
|
+
"spec": "@capyclaw/plugin-kit/service/mcp-http",
|
|
49
|
+
"sha256": "54bce272839c9477d460a483ee4bce62ca9f61b56174247ed718a7711eec7ee2"
|
|
50
|
+
},
|
|
51
|
+
"tools/validate.mjs": {
|
|
52
|
+
"spec": "@capyclaw/plugin-kit/tools/validate",
|
|
53
|
+
"sha256": "d88424caa66913acfc49a340c6e6eea6fe930a676ee8d32581d6366877f21389"
|
|
54
|
+
},
|
|
55
|
+
"editor/lease.mjs": {
|
|
56
|
+
"spec": "@capyclaw/plugin-kit/editor/lease",
|
|
57
|
+
"sha256": "4b1fe0ea3678d27f5283827a1d658784b915914cb6a0780f9534426ffd66b25f"
|
|
58
|
+
},
|
|
59
|
+
"util/fs-lock.mjs": {
|
|
60
|
+
"spec": "@capyclaw/plugin-kit/util/fs-lock",
|
|
61
|
+
"sha256": "c528e30271d83be2c857c160246598f96e636dacb2561a5e2109337e84d0865b"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"pkgRoot": {
|
|
65
|
+
"capyclaw-service-host/tuning.mjs": {
|
|
66
|
+
"spec": "@capyclaw/service-host/tuning",
|
|
67
|
+
"sha256": "1425851a3bff8c672a58536096faa321c74a4d4333cc0ae9268c1cfe83696492"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 工具组装:展示墙零能力 → 空 registry 面。
|
|
3
|
+
* 保留与 browser/ppt/canvas 同形的导出,流水线与未来扩展都从这里拿工具面。
|
|
4
|
+
*/
|
|
5
|
+
import { CAPABILITIES } from './capabilities/index.mjs'
|
|
6
|
+
|
|
7
|
+
export { CAPABILITIES }
|
|
8
|
+
|
|
9
|
+
export const TOOLS = []
|
|
10
|
+
export const TOOL_IMPL = {}
|
|
11
|
+
export const TOOL_META = {}
|
|
12
|
+
export const FEATURES = []
|