@capyclaw/rsp-suite 0.0.0-stage → 0.1.1
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/README.md +84 -2
- package/cordis.patch.yml +8 -0
- package/dsh-suite.json +91 -0
- package/node_modules/@capyclaw/foundation/README.md +51 -0
- package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +88 -0
- package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
- package/node_modules/@capyclaw/foundation/abi/index.mjs +50 -0
- package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +352 -0
- package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +258 -0
- package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
- package/node_modules/@capyclaw/foundation/abi/version.mjs +140 -0
- package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -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 +72 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +120 -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 +38 -0
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +88 -0
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +54 -0
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +187 -0
- package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +195 -0
- package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +115 -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 +198 -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 +72 -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 +132 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +60 -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/ledger.mjs +151 -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 +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -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 +57 -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 +664 -0
- package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
- package/node_modules/@capyclaw/rsp-skill-remote-screen/README.md +7 -0
- package/node_modules/@capyclaw/rsp-skill-remote-screen/contract/rsp-contract.json +478 -0
- package/node_modules/@capyclaw/rsp-skill-remote-screen/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/rsp-skill-remote-screen/package.json +33 -0
- package/node_modules/@capyclaw/rsp-skill-remote-screen/plugin.mjs +15 -0
- package/node_modules/@capyclaw/rsp-skill-remote-screen/skills/remote-screen/SKILL.md +131 -0
- package/node_modules/@capyclaw/rsp-workbench/contract/capabilities.json +203 -0
- package/node_modules/@capyclaw/rsp-workbench/lib/client.mjs +681 -0
- package/node_modules/@capyclaw/rsp-workbench/lib/descriptors.mjs +28 -0
- package/node_modules/@capyclaw/rsp-workbench/lib/host.mjs +51 -0
- package/node_modules/@capyclaw/rsp-workbench/lib/manager.mjs +333 -0
- package/node_modules/@capyclaw/rsp-workbench/lib/session-mode.mjs +68 -0
- package/node_modules/@capyclaw/rsp-workbench/lib/tools.mjs +485 -0
- package/node_modules/@capyclaw/rsp-workbench/lib/workbench.mjs +184 -0
- package/node_modules/@capyclaw/rsp-workbench/package.json +47 -0
- package/node_modules/@capyclaw/rsp-workbench/plugin.mjs +17 -0
- package/node_modules/@capyclaw/rsp-workbench/ui/index.html +578 -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 +597 -0
- package/node_modules/@capyclaw/service-host/src/tuning.mjs +63 -0
- package/node_modules/@capyclaw/suite-kit/README.md +289 -0
- package/node_modules/@capyclaw/suite-kit/bin/dsh-domain.mjs +98 -0
- package/node_modules/@capyclaw/suite-kit/bin/dsh-suite.mjs +174 -0
- package/node_modules/@capyclaw/suite-kit/client/embed.js +35 -0
- package/node_modules/@capyclaw/suite-kit/domain.schema.json +129 -0
- package/node_modules/@capyclaw/suite-kit/package.json +58 -0
- package/node_modules/@capyclaw/suite-kit/src/activation-registry.mjs +184 -0
- package/node_modules/@capyclaw/suite-kit/src/artifacts.mjs +131 -0
- package/node_modules/@capyclaw/suite-kit/src/capability.mjs +181 -0
- package/node_modules/@capyclaw/suite-kit/src/compose.mjs +201 -0
- package/node_modules/@capyclaw/suite-kit/src/domain.mjs +138 -0
- package/node_modules/@capyclaw/suite-kit/src/embed.mjs +81 -0
- package/node_modules/@capyclaw/suite-kit/src/host.mjs +251 -0
- package/node_modules/@capyclaw/suite-kit/src/index.mjs +24 -0
- package/node_modules/@capyclaw/suite-kit/src/manifest.mjs +263 -0
- package/node_modules/@capyclaw/suite-kit/src/orchestration.mjs +100 -0
- package/node_modules/@capyclaw/suite-kit/src/profile.mjs +584 -0
- package/node_modules/@capyclaw/suite-kit/src/surface.mjs +28 -0
- package/node_modules/@capyclaw/suite-kit/suite.schema.json +128 -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 +46 -0
- package/node_modules/@capyclaw/tool-host/package.json +59 -0
- package/node_modules/@capyclaw/tool-host/src/admit-images.mjs +80 -0
- package/node_modules/@capyclaw/tool-host/src/caller-session.mjs +25 -0
- package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +166 -0
- package/node_modules/@capyclaw/tool-host/src/index.mjs +461 -0
- package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +272 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +539 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +142 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +751 -0
- package/node_modules/ws/lib/sender.js +610 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +562 -0
- package/node_modules/ws/lib/websocket.js +1440 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +53 -4
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP 小工具的唯一实现:MIME 表、HTML 转义、loopback 判定、常量时间比较。
|
|
3
|
+
*
|
|
4
|
+
* 这几件事原本在服务宿主、编辑器宿主、网关和若干插件里各抄了一份(MIME 表 8 份、
|
|
5
|
+
* loopback 判定 7 份、escapeHtml 4 份、token 比较 4 份),抄出来的行为还不完全一致
|
|
6
|
+
* (比如 .json 有的带 charset 有 的不带、loopback 有的放行 localhost 有的不放行)。
|
|
7
|
+
* 统一放这里,谁要用谁 import,改一处全仓生效。
|
|
8
|
+
*
|
|
9
|
+
* 只依赖 node 内置模块,不 import 本包其它文件,因此不会被任何模块反向依赖成环。
|
|
10
|
+
*/
|
|
11
|
+
import path from 'node:path'
|
|
12
|
+
import { timingSafeEqual } from 'node:crypto'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 扩展名 → Content-Type。取全仓并集,统一带 charset。
|
|
16
|
+
* 键一律小写带点(`'.html'`),查询时也按小写处理。
|
|
17
|
+
*/
|
|
18
|
+
export const MIME_TYPES = Object.freeze({
|
|
19
|
+
'.html': 'text/html; charset=utf-8',
|
|
20
|
+
'.htm': 'text/html; charset=utf-8',
|
|
21
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
22
|
+
'.mjs': 'text/javascript; charset=utf-8',
|
|
23
|
+
'.cjs': 'text/javascript; charset=utf-8',
|
|
24
|
+
'.css': 'text/css; charset=utf-8',
|
|
25
|
+
'.json': 'application/json; charset=utf-8',
|
|
26
|
+
'.map': 'application/json; charset=utf-8',
|
|
27
|
+
'.txt': 'text/plain; charset=utf-8',
|
|
28
|
+
'.md': 'text/markdown; charset=utf-8',
|
|
29
|
+
'.csv': 'text/csv; charset=utf-8',
|
|
30
|
+
'.xml': 'application/xml; charset=utf-8',
|
|
31
|
+
'.svg': 'image/svg+xml',
|
|
32
|
+
'.png': 'image/png',
|
|
33
|
+
'.jpg': 'image/jpeg',
|
|
34
|
+
'.jpeg': 'image/jpeg',
|
|
35
|
+
'.webp': 'image/webp',
|
|
36
|
+
'.avif': 'image/avif',
|
|
37
|
+
'.gif': 'image/gif',
|
|
38
|
+
'.ico': 'image/x-icon',
|
|
39
|
+
'.woff': 'font/woff',
|
|
40
|
+
'.woff2': 'font/woff2',
|
|
41
|
+
'.ttf': 'font/ttf',
|
|
42
|
+
'.otf': 'font/otf',
|
|
43
|
+
'.pdf': 'application/pdf',
|
|
44
|
+
'.mp4': 'video/mp4',
|
|
45
|
+
'.webm': 'video/webm',
|
|
46
|
+
'.mp3': 'audio/mpeg',
|
|
47
|
+
'.wav': 'audio/wav',
|
|
48
|
+
'.wasm': 'application/wasm',
|
|
49
|
+
'.zip': 'application/zip',
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
export const DEFAULT_MIME = 'application/octet-stream'
|
|
53
|
+
|
|
54
|
+
/** 按扩展名给 Content-Type;认不出来给 octet-stream(不猜内容)。 */
|
|
55
|
+
export function mimeFor(file) {
|
|
56
|
+
return MIME_TYPES[path.extname(String(file ?? '')).toLowerCase()] || DEFAULT_MIME
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** 是否是 HTML:`text/html` 及其带参数的写法。 */
|
|
60
|
+
export function isHtmlMime(mime) {
|
|
61
|
+
return /^text\/html\b/i.test(String(mime ?? ''))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const HTML_ENTITIES = Object.freeze({
|
|
65
|
+
'&': '&',
|
|
66
|
+
'<': '<',
|
|
67
|
+
'>': '>',
|
|
68
|
+
'"': '"',
|
|
69
|
+
"'": ''',
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
/** 往 HTML 里插值前转义五个字符;null/undefined 变空串。 */
|
|
73
|
+
export function escapeHtml(value) {
|
|
74
|
+
return String(value ?? '').replace(/[&<>"']/g, (ch) => HTML_ENTITIES[ch])
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const IPV4_LOOPBACK = /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
|
|
78
|
+
|
|
79
|
+
function bareHost(host) {
|
|
80
|
+
return String(host ?? '').trim().toLowerCase().replace(/^\[|\]$/g, '')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 判定一个「地址字面量」是不是本机回环:`127.x.x.x`、`::1`、
|
|
85
|
+
* `::ffff:127.x.x.x`(IPv4-mapped),以及主机名 `localhost`。
|
|
86
|
+
* 传进来的应该是 `socket.remoteAddress` 或 `url.hostname` 这类值。
|
|
87
|
+
*/
|
|
88
|
+
export function isLoopbackAddress(address) {
|
|
89
|
+
const host = bareHost(address)
|
|
90
|
+
if (!host) return false
|
|
91
|
+
if (host === 'localhost' || host === '::1') return true
|
|
92
|
+
if (host.startsWith('::ffff:')) return IPV4_LOOPBACK.test(host.slice(7))
|
|
93
|
+
return IPV4_LOOPBACK.test(host)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** 判定请求是否来自本机回环(看 `req.socket.remoteAddress`)。 */
|
|
97
|
+
export function isLoopbackRequest(req) {
|
|
98
|
+
return isLoopbackAddress(req?.socket?.remoteAddress)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 判定浏览器 Origin 头是否属于本机页面。
|
|
103
|
+
*
|
|
104
|
+
* 与 `isLoopbackAddress` 语义不同,不能互换:这里接受空 Origin(同源导航、
|
|
105
|
+
* curl 这类非浏览器请求都不带 Origin),也接受 `localhost` 这种主机名。
|
|
106
|
+
* `strict` 时把空 Origin 判为 false,用于「必须证明是同源页面」的写操作。
|
|
107
|
+
*/
|
|
108
|
+
export function isLoopbackOrigin(origin, { strict = false } = {}) {
|
|
109
|
+
if (!origin) return !strict
|
|
110
|
+
try {
|
|
111
|
+
return isLoopbackAddress(new URL(String(origin)).hostname)
|
|
112
|
+
} catch {
|
|
113
|
+
return false
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 常量时间比较两个字符串(token、共享密钥用)。
|
|
119
|
+
* 长度不等直接 false——`timingSafeEqual` 遇到不等长会抛,这里兜住。
|
|
120
|
+
*/
|
|
121
|
+
export function timingSafeEqualText(actual, expected) {
|
|
122
|
+
const left = Buffer.from(String(actual ?? ''), 'utf8')
|
|
123
|
+
const right = Buffer.from(String(expected ?? ''), 'utf8')
|
|
124
|
+
if (!left.length || left.length !== right.length) return false
|
|
125
|
+
try {
|
|
126
|
+
return timingSafeEqual(left, right)
|
|
127
|
+
} catch {
|
|
128
|
+
return false
|
|
129
|
+
}
|
|
130
|
+
}
|