@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CapyClaw
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @capyclaw/wall-suite
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
展示墙工作台套件:主区空态选择器。会话未绑定工作台模式时,主区舞台摆出选择器,列出已注册的工作台类型,点选即显式认领会话模式(`explicit`,豁免内容闸,全新会话也能立刻摆出真实工作台)。
|
|
4
|
+
|
|
5
|
+
## 组成
|
|
6
|
+
|
|
7
|
+
- `@capyclaw/wall-workbench`(runtime)— 选择器页 + `/claim` 认领端点;零工具零技能。注册行带 `config.idleDefault: true`(空态兜底标记,portal-hud 单一真源)。
|
|
8
|
+
- components:`capyclaw-service-host` / `capyclaw-tool-host` / `capyclaw-asset-service`(能力图:`host.http` / `tools.registry` / `assets.store`)。
|
|
9
|
+
- support:`@capyclaw/plugin-kit`、`@capyclaw/foundation`、`@capyclaw/service-broker`。
|
|
10
|
+
|
|
11
|
+
公共基建(os / toolHost / serviceHost / assets / serviceBroker)由 `@capyclaw/core` 统一提供,本套件只依赖不重复声明行;需同一 profile 启用 core。
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
dsh plugin --profile web add @capyclaw/wall-suite
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 许可证
|
|
20
|
+
|
|
21
|
+
MIT
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"suite": "capyclaw-wall-suite",
|
|
3
|
+
"suiteVersion": "0.1.0",
|
|
4
|
+
"packages": {
|
|
5
|
+
"@capyclaw/asset-service": {
|
|
6
|
+
"version": "0.1.4",
|
|
7
|
+
"apiVersion": "1.0.0",
|
|
8
|
+
"path": "..\\..\\..\\..\\..\\..\\C\\packages\\capyclaw-asset-service",
|
|
9
|
+
"sha256": "a3fe6f1b0a37514a396d91f06dee214f18ea19fb4ecebfb994cf59a16420853d"
|
|
10
|
+
},
|
|
11
|
+
"@capyclaw/foundation": {
|
|
12
|
+
"version": "0.1.9",
|
|
13
|
+
"apiVersion": "1.0.0",
|
|
14
|
+
"path": "../../../../../../C/packages/capyclaw-foundation",
|
|
15
|
+
"sha256": "5e7bab76caa09bee0a94a03650b2447cc880d743231c73695f49b7a92077d5fa"
|
|
16
|
+
},
|
|
17
|
+
"@capyclaw/plugin-kit": {
|
|
18
|
+
"version": "0.2.6",
|
|
19
|
+
"apiVersion": null,
|
|
20
|
+
"path": "../../../../../../C/packages/capyclaw-plugin-kit",
|
|
21
|
+
"sha256": "02f74f615cd6baea890f768a141167d5623e8b8cfe4c50ab8639046231c98d33"
|
|
22
|
+
},
|
|
23
|
+
"@capyclaw/service-broker": {
|
|
24
|
+
"version": "0.2.25",
|
|
25
|
+
"apiVersion": "1.0.0",
|
|
26
|
+
"path": "../../../../../../C/packages/capyclaw-service-broker",
|
|
27
|
+
"sha256": "0efd962a02fb2d6213cba67778b5e34ec2f57b8e9f50b4c94374e02d1dc9b6c5"
|
|
28
|
+
},
|
|
29
|
+
"@capyclaw/service-host": {
|
|
30
|
+
"version": "0.1.5",
|
|
31
|
+
"apiVersion": "1.0.0",
|
|
32
|
+
"path": "..\\..\\..\\..\\..\\..\\C\\packages\\capyclaw-service-host",
|
|
33
|
+
"sha256": "be7ef447a8c2dc6005edb0b28d0b171c7bc5c773185ad971811896bb9c6388ba"
|
|
34
|
+
},
|
|
35
|
+
"@capyclaw/tool-host": {
|
|
36
|
+
"version": "0.2.0",
|
|
37
|
+
"apiVersion": "1.1.0",
|
|
38
|
+
"path": "..\\..\\..\\..\\..\\..\\C\\packages\\capyclaw-tool-host",
|
|
39
|
+
"sha256": "93e6fe760f2d421c0767058bec55fc735f82453285e81be905d9fb0fdd103647"
|
|
40
|
+
},
|
|
41
|
+
"@capyclaw/wall-workbench": {
|
|
42
|
+
"version": "0.1.0",
|
|
43
|
+
"apiVersion": null,
|
|
44
|
+
"path": "../capyclaw-wall-workbench",
|
|
45
|
+
"sha256": "d8ee17ed863b9f581bfb5b8f63a9db4accbeda5774be814cb260b651af8edd86"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
package/cordis.patch.yml
ADDED
package/dsh-suite.json
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../../../C/packages/capyclaw-suite-kit/suite.schema.json",
|
|
3
|
+
"name": "capyclaw-wall-suite",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"title": "展示墙工作台套件",
|
|
6
|
+
"description": "主区空态选择器(挂在 dsh 的 /capyclaw/wall,路由与端口由基建决定):会话未绑定模式时列出已注册的工作台类型,点选即显式认领会话模式;零工具零技能。公共基建(os / toolHost / serviceHost / assets / serviceBroker)由 @capyclaw/core 统一提供,需同一 profile 启用它。",
|
|
7
|
+
"packages": {
|
|
8
|
+
"@capyclaw/foundation": {
|
|
9
|
+
"role": "runtime",
|
|
10
|
+
"version": "^0.1.9",
|
|
11
|
+
"path": "./node_modules/@capyclaw/foundation"
|
|
12
|
+
},
|
|
13
|
+
"@capyclaw/plugin-kit": {
|
|
14
|
+
"role": "support",
|
|
15
|
+
"version": "^0.2.6",
|
|
16
|
+
"path": "./node_modules/@capyclaw/plugin-kit"
|
|
17
|
+
},
|
|
18
|
+
"@capyclaw/service-broker": {
|
|
19
|
+
"role": "runtime",
|
|
20
|
+
"version": "^0.2.25",
|
|
21
|
+
"path": "./node_modules/@capyclaw/service-broker",
|
|
22
|
+
"provides": {
|
|
23
|
+
"services": [
|
|
24
|
+
"serviceBroker"
|
|
25
|
+
],
|
|
26
|
+
"capabilities": {
|
|
27
|
+
"service.broker": "1.0.0"
|
|
28
|
+
},
|
|
29
|
+
"ports": []
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"@capyclaw/wall-workbench": {
|
|
33
|
+
"role": "runtime",
|
|
34
|
+
"version": "^0.1.0",
|
|
35
|
+
"path": "./node_modules/@capyclaw/wall-workbench",
|
|
36
|
+
"requires": {
|
|
37
|
+
"capabilities": {
|
|
38
|
+
"host.http": "^1.0.0",
|
|
39
|
+
"tools.registry": "^1.0.0",
|
|
40
|
+
"assets.store": "^1.0.0"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"provides": {
|
|
44
|
+
"tools": [
|
|
45
|
+
"wall_*"
|
|
46
|
+
],
|
|
47
|
+
"capabilities": {
|
|
48
|
+
"editor.bridge": "1.0.0",
|
|
49
|
+
"wall.runtime": "1.0.0",
|
|
50
|
+
"wall.tools": "1.0.0"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"@capyclaw/service-host": {
|
|
55
|
+
"role": "provider",
|
|
56
|
+
"version": "^0.1.5",
|
|
57
|
+
"path": "./node_modules/@capyclaw/service-host",
|
|
58
|
+
"provides": {
|
|
59
|
+
"services": [
|
|
60
|
+
"serviceHost"
|
|
61
|
+
],
|
|
62
|
+
"capabilities": {
|
|
63
|
+
"host.http": "1.0.0"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"@capyclaw/tool-host": {
|
|
68
|
+
"role": "provider",
|
|
69
|
+
"version": "^0.2.0",
|
|
70
|
+
"path": "./node_modules/@capyclaw/tool-host",
|
|
71
|
+
"provides": {
|
|
72
|
+
"services": [
|
|
73
|
+
"toolHost"
|
|
74
|
+
],
|
|
75
|
+
"capabilities": {
|
|
76
|
+
"tools.registry": "1.0.0",
|
|
77
|
+
"tools.descriptors": "1.1.0"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"@capyclaw/asset-service": {
|
|
82
|
+
"role": "provider",
|
|
83
|
+
"version": "^0.1.4",
|
|
84
|
+
"path": "./node_modules/@capyclaw/asset-service",
|
|
85
|
+
"provides": {
|
|
86
|
+
"services": [
|
|
87
|
+
"assets"
|
|
88
|
+
],
|
|
89
|
+
"capabilities": {
|
|
90
|
+
"assets.store": "1.0.0"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"rows": [
|
|
96
|
+
{
|
|
97
|
+
"id": "service-host",
|
|
98
|
+
"name": "@capyclaw/service-host"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "tool-host",
|
|
102
|
+
"name": "@capyclaw/tool-host"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"id": "asset-service",
|
|
106
|
+
"name": "@capyclaw/asset-service"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "wall-workbench",
|
|
110
|
+
"name": "@capyclaw/wall-workbench",
|
|
111
|
+
"config": {
|
|
112
|
+
"mountPath": "/capyclaw/wall",
|
|
113
|
+
"idleDefault": true
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
"checks": []
|
|
118
|
+
}
|
package/lib/index.mjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @capyclaw/asset-service
|
|
2
|
+
|
|
3
|
+
DSH 公共资产插件。功能插件通过 `ctx.assets` 获得统一的 sha256 对象仓库和 `/assets` 路由。
|
|
4
|
+
|
|
5
|
+
## 使用
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
export const inject = ['assets']
|
|
9
|
+
|
|
10
|
+
export function apply(ctx) {
|
|
11
|
+
const app = ctx.serviceHost.createApp({ id: 'my-plugin' })
|
|
12
|
+
app.use(ctx.assets.routes())
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 或在插件内部写入
|
|
16
|
+
const asset = await ctx.assets.put(buffer, 'image/png')
|
|
17
|
+
// { id, key, url: '/assets/<sha256>', size, contentType }
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
独立运行或测试:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { createFileAssetStore, createAssetRoutes } from '@capyclaw/asset-service/src'
|
|
24
|
+
const store = createFileAssetStore({ dir: './assets' })
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 路由归属
|
|
28
|
+
|
|
29
|
+
多个插件共用一个 service-host app 时,用 `ctx.assets.mount(app)` 只挂一次 `/assets`:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
ctx.assets.mount(app, { store: assetStore })
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
重复 mount 会被忽略;不要再手写 `app.use(ctx.assets.routes())`。
|
|
36
|
+
|
|
37
|
+
## 提供什么
|
|
38
|
+
|
|
39
|
+
- `createWorkspaceAssetStore({ storeClient, workId })`:资产归当前 work
|
|
40
|
+
- `createFileAssetStore({ dir })`:本地目录后端
|
|
41
|
+
- `createAssetRoutes({ assetStore, basePath })`:GET/HEAD `/assets/<id>`、POST `<basePath>/assets`
|
|
42
|
+
- `ctx.assets.put/get`:默认 store 快捷方法
|
|
43
|
+
|
|
44
|
+
## 契约
|
|
45
|
+
|
|
46
|
+
- 资产按 sha256 去重,不可变
|
|
47
|
+
- url 固定为 `/assets/<id>`,可长期缓存
|
|
48
|
+
- 内容类型由上传方声明,读取时原样返回
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../capyclaw-suite-kit/suite.schema.json",
|
|
3
|
+
"name": "dsh-asset-service-suite",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"title": "Asset Service",
|
|
6
|
+
"description": "通用对象资产:sha256 仓库、/assets 路由、上传。",
|
|
7
|
+
"packages": {
|
|
8
|
+
"@capyclaw/asset-service": {
|
|
9
|
+
"role": "provider",
|
|
10
|
+
"version": "^0.1.4",
|
|
11
|
+
"path": ".",
|
|
12
|
+
"provides": {
|
|
13
|
+
"services": [
|
|
14
|
+
"assets"
|
|
15
|
+
],
|
|
16
|
+
"capabilities": {
|
|
17
|
+
"assets.store": "1.0.0"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"rows": [
|
|
23
|
+
{
|
|
24
|
+
"id": "asset-service",
|
|
25
|
+
"name": "@capyclaw/asset-service"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"checks": []
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @capyclaw/asset-service 插件:向同进程插件提供 ctx.assets。 */
|
|
2
|
+
import { defineDriver } from '@capyclaw/foundation/abi'
|
|
3
|
+
import { createAssetHost } from '../src/index.mjs'
|
|
4
|
+
|
|
5
|
+
export const { name, inject, apply } = defineDriver({
|
|
6
|
+
name: 'asset-service',
|
|
7
|
+
service: 'assets',
|
|
8
|
+
apply(ctx, config = {}) {
|
|
9
|
+
const service = createAssetHost(config)
|
|
10
|
+
const dispose = ctx.provide('assets', service)
|
|
11
|
+
console.log('[asset-service] ready')
|
|
12
|
+
return () => { if (typeof dispose === 'function') dispose() }
|
|
13
|
+
},
|
|
14
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capyclaw/asset-service",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "DSH 公共资产插件:sha256 对象仓库、/assets 路由、base64 上传与 content-type,向插件提供 ctx.assets。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./lib/host.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./lib/host.mjs",
|
|
9
|
+
"./src": "./src/index.mjs",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18",
|
|
14
|
+
"dsh": "^0.2.0-rc.2"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"dsh": {
|
|
20
|
+
"bundle": {
|
|
21
|
+
"patch": "./cordis.patch.yml"
|
|
22
|
+
},
|
|
23
|
+
"suite": "./dsh-suite.json",
|
|
24
|
+
"apiVersion": "1.0.0",
|
|
25
|
+
"category": "service",
|
|
26
|
+
"platform": "both",
|
|
27
|
+
"driver": {
|
|
28
|
+
"service": "assets"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"meta": {
|
|
32
|
+
"title": "公共资产服务",
|
|
33
|
+
"description": "sha256 对象仓库、/assets 路由、base64 上传与 content-type,向插件提供 ctx.assets"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"lib/",
|
|
37
|
+
"src/",
|
|
38
|
+
"cordis.patch.yml",
|
|
39
|
+
"dsh-suite.json",
|
|
40
|
+
"README.md"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"scripts": {
|
|
44
|
+
"test": "node --test test/*.test.mjs"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@capyclaw/plugin-kit": "^0.2.0",
|
|
48
|
+
"@capyclaw/foundation": "^0.1.1"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/Maple496/capyclaw.git",
|
|
53
|
+
"directory": "C/packages/capyclaw-asset-service"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/Maple496/capyclaw/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://github.com/Maple496/capyclaw/tree/main/C/packages/capyclaw-asset-service#readme"
|
|
59
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @capyclaw/asset-service —— 通用对象资产仓库。
|
|
3
|
+
*
|
|
4
|
+
* 功能插件不再各自实现 `/assets/<sha256>`、base64 上传、content-type 与缓存头。
|
|
5
|
+
* 资产按 sha256 去重,url 为 `/assets/<id>`。
|
|
6
|
+
*
|
|
7
|
+
* 两种后端:
|
|
8
|
+
* - workspace:storeClient(ctx.workspace 的 scoped client),资产归当前 work;
|
|
9
|
+
* - file:本地目录,适合无 workspace 的独立运行/测试。
|
|
10
|
+
*/
|
|
11
|
+
import crypto from 'node:crypto'
|
|
12
|
+
import fs from 'node:fs'
|
|
13
|
+
import path from 'node:path'
|
|
14
|
+
import { send, readBody } from '@capyclaw/plugin-kit/service/http'
|
|
15
|
+
import { createServiceApi } from '@capyclaw/plugin-kit/service/api'
|
|
16
|
+
|
|
17
|
+
function sha256(buffer) {
|
|
18
|
+
return crypto.createHash('sha256').update(buffer).digest('hex')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const ASSET_ID_RE = /^[a-f0-9]{64}$/
|
|
22
|
+
|
|
23
|
+
function validId(id) {
|
|
24
|
+
return ASSET_ID_RE.test(String(id || ''))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeBuffer(value) {
|
|
28
|
+
if (Buffer.isBuffer(value)) return value
|
|
29
|
+
if (value instanceof Uint8Array) return Buffer.from(value)
|
|
30
|
+
throw new Error('asset: 数据必须是 Buffer/Uint8Array')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** 基于 ctx.workspace 的 scoped WorkspaceClient。 */
|
|
34
|
+
export function createWorkspaceAssetStore({ storeClient, workId = 'main' } = {}) {
|
|
35
|
+
if (!storeClient || typeof storeClient.put !== 'function') throw new Error('createWorkspaceAssetStore 需要 storeClient')
|
|
36
|
+
return {
|
|
37
|
+
kind: 'workspace',
|
|
38
|
+
async put(value, contentType = 'application/octet-stream') {
|
|
39
|
+
const buffer = normalizeBuffer(value)
|
|
40
|
+
const id = sha256(buffer)
|
|
41
|
+
const key = `assets/${id}`
|
|
42
|
+
storeClient.put(workId, key, buffer, { contentType })
|
|
43
|
+
return { id, key, url: `/assets/${id}`, size: buffer.length, contentType }
|
|
44
|
+
},
|
|
45
|
+
get(id) {
|
|
46
|
+
if (!validId(id)) return null
|
|
47
|
+
const key = `assets/${id}`
|
|
48
|
+
try {
|
|
49
|
+
const data = storeClient.get(workId, key)
|
|
50
|
+
if (!data) return null
|
|
51
|
+
const meta = storeClient.list(workId).find((item) => item.key === key)
|
|
52
|
+
return { data, contentType: meta?.contentType || 'application/octet-stream' }
|
|
53
|
+
} catch {
|
|
54
|
+
/* 缺失/权限错误按 404 处理,不能把 500 泄漏给资产路由。 */
|
|
55
|
+
return null
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
has(id) {
|
|
59
|
+
if (!validId(id)) return false
|
|
60
|
+
try { return !!storeClient.get(workId, `assets/${id}`) } catch { return false }
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** 本地目录后端:<dir>/<sha256> + <dir>/<sha256>.meta.json。 */
|
|
66
|
+
export function createFileAssetStore({ dir } = {}) {
|
|
67
|
+
if (!dir) throw new Error('createFileAssetStore 需要 dir')
|
|
68
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
69
|
+
return {
|
|
70
|
+
kind: 'file',
|
|
71
|
+
async put(value, contentType = 'application/octet-stream') {
|
|
72
|
+
const buffer = normalizeBuffer(value)
|
|
73
|
+
const id = sha256(buffer)
|
|
74
|
+
const file = path.join(dir, id)
|
|
75
|
+
const metaFile = file + '.meta.json'
|
|
76
|
+
const existingOk = (() => {
|
|
77
|
+
try { return fs.statSync(file).size === buffer.length } catch { return false }
|
|
78
|
+
})()
|
|
79
|
+
if (!existingOk) {
|
|
80
|
+
const tmp = `${file}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`
|
|
81
|
+
fs.writeFileSync(tmp, buffer)
|
|
82
|
+
fs.renameSync(tmp, file)
|
|
83
|
+
}
|
|
84
|
+
const metaTmp = `${metaFile}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`
|
|
85
|
+
fs.writeFileSync(metaTmp, JSON.stringify({ contentType, size: buffer.length }))
|
|
86
|
+
fs.renameSync(metaTmp, metaFile)
|
|
87
|
+
return { id, key: id, url: `/assets/${id}`, size: buffer.length, contentType }
|
|
88
|
+
},
|
|
89
|
+
get(id) {
|
|
90
|
+
if (!validId(id)) return null
|
|
91
|
+
const file = path.join(dir, path.basename(String(id)))
|
|
92
|
+
try {
|
|
93
|
+
const data = fs.readFileSync(file)
|
|
94
|
+
/* 内容寻址仓库必须复核 hash:截断/篡改的对象不能静默返回。 */
|
|
95
|
+
if (sha256(data) !== id) {
|
|
96
|
+
console.error(`[asset-service] 对象校验失败,拒绝返回: ${id}`)
|
|
97
|
+
return null
|
|
98
|
+
}
|
|
99
|
+
let contentType = 'application/octet-stream'
|
|
100
|
+
try { contentType = JSON.parse(fs.readFileSync(file + '.meta.json', 'utf8')).contentType || contentType } catch { /* 默认 */ }
|
|
101
|
+
return { data, contentType }
|
|
102
|
+
} catch {
|
|
103
|
+
return null
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
has(id) {
|
|
107
|
+
if (!validId(id)) return false
|
|
108
|
+
try { return fs.existsSync(path.join(dir, path.basename(String(id)))) } catch { return false }
|
|
109
|
+
},
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** 防止 text/html / svg 在 loopback 同源执行脚本;图片仍按原 MIME 内联。 */
|
|
114
|
+
function safeContentType(type) {
|
|
115
|
+
const base = String(type || '').split(';')[0].trim().toLowerCase() || 'application/octet-stream'
|
|
116
|
+
if (base === 'text/html' || base === 'application/xhtml+xml' || base === 'image/svg+xml') {
|
|
117
|
+
return 'text/plain; charset=utf-8'
|
|
118
|
+
}
|
|
119
|
+
return base
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* service-host 兼容的资产路由。
|
|
124
|
+
* GET/HEAD `/assets/<id>`(同时兼容 `<basePath>/assets/<id>`);
|
|
125
|
+
* POST `/assets` 或 `<basePath>/assets`(JSON: { data: base64, contentType })。
|
|
126
|
+
*/
|
|
127
|
+
export function createAssetRoutes({ assetStore, basePath = '', maxUploadBytes = 10 * 1024 * 1024 } = {}) {
|
|
128
|
+
const prefix = basePath === '/' ? '' : String(basePath || '').replace(/\/+$/, '')
|
|
129
|
+
const getPrefixes = ['/assets/', prefix ? `${prefix}/assets/` : null].filter(Boolean)
|
|
130
|
+
const postPaths = new Set(['/assets', prefix ? `${prefix}/assets` : null].filter(Boolean))
|
|
131
|
+
return async function assetRoutes(req, res, u) {
|
|
132
|
+
const p = u.pathname
|
|
133
|
+
if (req.method === 'GET' || req.method === 'HEAD') {
|
|
134
|
+
const getPrefix = getPrefixes.find((candidate) => p.startsWith(candidate))
|
|
135
|
+
if (getPrefix) {
|
|
136
|
+
if (!assetStore) { send(req, res, 404, { error: 'asset store unavailable' }); return true }
|
|
137
|
+
const id = decodeURIComponent(p.slice(getPrefix.length))
|
|
138
|
+
if (!validId(id)) { send(req, res, 404, { error: 'asset not found' }); return true }
|
|
139
|
+
const asset = assetStore.get(id)
|
|
140
|
+
if (!asset) { send(req, res, 404, { error: 'asset not found' }); return true }
|
|
141
|
+
res.writeHead(200, {
|
|
142
|
+
'content-type': safeContentType(asset.contentType),
|
|
143
|
+
'content-length': asset.data.length,
|
|
144
|
+
'cache-control': 'public, max-age=31536000, immutable',
|
|
145
|
+
'x-content-type-options': 'nosniff',
|
|
146
|
+
'referrer-policy': 'no-referrer',
|
|
147
|
+
})
|
|
148
|
+
res.end(req.method === 'HEAD' ? undefined : asset.data)
|
|
149
|
+
return true
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (postPaths.has(p) && req.method === 'POST') {
|
|
153
|
+
if (!assetStore) { send(req, res, 503, { error: 'asset store unavailable' }); return true }
|
|
154
|
+
let body
|
|
155
|
+
try { body = await readBody(req, maxUploadBytes) } catch (error) {
|
|
156
|
+
const status = error?.code === 'BODY_TOO_LARGE' ? 413 : 400
|
|
157
|
+
send(req, res, status, { error: String(error.message || error) })
|
|
158
|
+
return true
|
|
159
|
+
}
|
|
160
|
+
if (!body || typeof body.data !== 'string' || !body.data) {
|
|
161
|
+
send(req, res, 400, { error: '缺少图片数据' })
|
|
162
|
+
return true
|
|
163
|
+
}
|
|
164
|
+
const buffer = Buffer.from(body.data, 'base64')
|
|
165
|
+
/* 严格 base64:非法字符 / 错误填充 / 非规范编码一律 400,不再宽松解码把损坏
|
|
166
|
+
* 字节静默入库(B 轴 P0-7)。round-trip 比对同时挡住非规范填充位。 */
|
|
167
|
+
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(body.data) || body.data.length % 4 !== 0 || buffer.toString('base64') !== body.data) {
|
|
168
|
+
send(req, res, 400, { error: '图片数据不是合法 base64' })
|
|
169
|
+
return true
|
|
170
|
+
}
|
|
171
|
+
if (!buffer.length) { send(req, res, 400, { error: '图片数据为空' }); return true }
|
|
172
|
+
const asset = await assetStore.put(buffer, body.contentType || 'application/octet-stream')
|
|
173
|
+
send(req, res, 200, { ok: true, ...asset })
|
|
174
|
+
return true
|
|
175
|
+
}
|
|
176
|
+
return false
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function createAssetHost(config = {}) {
|
|
181
|
+
const defaultStore = config.storeClient
|
|
182
|
+
? createWorkspaceAssetStore({ storeClient: config.storeClient, workId: config.workId })
|
|
183
|
+
: config.dir
|
|
184
|
+
? createFileAssetStore({ dir: config.dir })
|
|
185
|
+
: null
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
api: createServiceApi('assets', '1.0.0', ['workspace-store', 'file-store', 'routes', 'sha256', 'mount']),
|
|
189
|
+
version: '0.1.0',
|
|
190
|
+
createStore: createWorkspaceAssetStore,
|
|
191
|
+
createFileStore: createFileAssetStore,
|
|
192
|
+
routes: createAssetRoutes,
|
|
193
|
+
store: defaultStore,
|
|
194
|
+
/**
|
|
195
|
+
* 每个 service-host app 只挂一次资产路由,避免多个插件重复争抢 /assets。
|
|
196
|
+
* @param {object} hostApp createServiceApp() 返回值
|
|
197
|
+
* @param {{ store?: object, basePath?: string }} options
|
|
198
|
+
*/
|
|
199
|
+
mount(hostApp, { store = defaultStore, basePath = '' } = {}) {
|
|
200
|
+
if (!hostApp || typeof hostApp.use !== 'function') throw new Error('assets.mount 需要 service-host app')
|
|
201
|
+
if (!store) throw new Error('assets.mount: 没有可用 store')
|
|
202
|
+
if (hostApp.__dshAssetsMounted) return () => {}
|
|
203
|
+
hostApp.__dshAssetsMounted = true
|
|
204
|
+
const unuse = hostApp.use(createAssetRoutes({ assetStore: store, basePath }))
|
|
205
|
+
let disposed = false
|
|
206
|
+
return () => {
|
|
207
|
+
if (disposed) return
|
|
208
|
+
disposed = true
|
|
209
|
+
/* 真正卸载路由;否则热重载后旧 store 仍会抢答 /assets。 */
|
|
210
|
+
if (typeof unuse === 'function') unuse()
|
|
211
|
+
hostApp.__dshAssetsMounted = false
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
async put(value, contentType) {
|
|
215
|
+
if (!defaultStore) throw new Error('asset-service: 未配置 storeClient/dir')
|
|
216
|
+
return defaultStore.put(value, contentType)
|
|
217
|
+
},
|
|
218
|
+
get(id) {
|
|
219
|
+
if (!defaultStore) throw new Error('asset-service: 未配置 storeClient/dir')
|
|
220
|
+
return defaultStore.get(id)
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @capyclaw/foundation
|
|
2
|
+
|
|
3
|
+
dsh 插件基石层:接口 ABI、插件加载器与内核服务 `ctx.os`。
|
|
4
|
+
|
|
5
|
+
应用插件不再写 `inject` / `apply` / provider 装配,只声明「我实现了哪个接口」:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { createPlugin, skillProvider } from '@capyclaw/foundation/abi'
|
|
9
|
+
|
|
10
|
+
export const { name, inject, apply } = createPlugin({
|
|
11
|
+
name: 'canvas',
|
|
12
|
+
requires: ['canvas.runtime@^1'],
|
|
13
|
+
implements: [skillProvider({ skill: './skills/canvas' })],
|
|
14
|
+
}, import.meta.url)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 四个入口
|
|
18
|
+
|
|
19
|
+
| 入口 | 内容 | 谁用 |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| `.` | Cordis 插件,产出 `ctx.os` | dsh profile |
|
|
22
|
+
| `./abi` | 描述符构建器、加载器、错误码、版本工具 | 应用插件 |
|
|
23
|
+
| `./kit` | plugin-kit 兼容导出,包含 Node/dsh 耦合,非纯函数库 | 兼容调用方 |
|
|
24
|
+
| `./runtime` | `createKernel` 等宿主 API | dsh 之外的宿主(独立技能服务、测试夹具) |
|
|
25
|
+
|
|
26
|
+
## 状态
|
|
27
|
+
|
|
28
|
+
- 包清单当前为 `0.1.6`;0.1.6 修的是「关掉插件再启用撞 E_DUP_PLUGIN」(disposer 未登记 + 失败
|
|
29
|
+
记录占名),详见下面的「生命周期」。
|
|
30
|
+
- 分层:应用插件 → ABI → 内核 → Host 适配器 → 本地 Node.js agent 运行时。
|
|
31
|
+
dsh 服务访问位于 Host 适配层;memory 只是参考实现,不证明第二个真实 agent 兼容。
|
|
32
|
+
HTTP/资源/进程仍有本地 Node 协议约束,详见 `docs/HOST-ADAPTER.md`。
|
|
33
|
+
- ABI v1,六个标准接口 + `host-event@1` + `client-panel@1` + `service-provider@1` +
|
|
34
|
+
`own-server@1` + 可执行 `raw@1`;基建插件使用 `defineDriver` 驱动入口。
|
|
35
|
+
- 能力表按 `ctx` 实际服务探测(见 `lib/kernel.mjs` 的 `detectCapabilities`),不做空头承诺。
|
|
36
|
+
- 当前仓库:27 个插件走标准接口,`raw@1` 当前为空,6 个基建插件走
|
|
37
|
+
`defineDriver` 驱动层;`meta/foundation.allowlist.json` 的模糊豁免为 0。
|
|
38
|
+
详见 `docs/POLICY.md` 与 `docs/spec/plugin-abi.md`。
|
|
39
|
+
|
|
40
|
+
设计规范见 `docs/spec/plugin-abi.md`,强制规则见 `docs/POLICY.md`。
|
|
41
|
+
|
|
42
|
+
## 生命周期(0.1.6 起)
|
|
43
|
+
|
|
44
|
+
`createPlugin().apply` 会把 `os.mount()` 的 disposer 通过 `ctx.effect(() => () => dispose())`
|
|
45
|
+
登记到本次激活的 ctx 上——**不能只靠 apply 的返回值**:Cordis 只认 `ctx.effect` 回调返回的
|
|
46
|
+
disposer,返回值不可靠。漏登记时,关掉插件后内核里的记录不会摘除,再次启用就会撞
|
|
47
|
+
`E_DUP_PLUGIN: 插件 xxx 已挂载`。
|
|
48
|
+
|
|
49
|
+
加载器侧另有两条兜底:`mount()` 遇到 `disposed` / `failed` 的旧记录会先摘掉并尽力回收;
|
|
50
|
+
`start` 失败清理完成后立即让出插件名。两者共同保证「关掉 → 再启用」可重复无数次。
|
|
51
|
+
|