@capyclaw/ppt-suite 2.5.70 → 2.5.71
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/composition.lock.json +27 -27
- package/contract/ppt-contract.json +1 -1
- package/dsh-suite.json +27 -17
- package/node_modules/@capyclaw/asset-service/dsh-suite.json +1 -1
- package/node_modules/@capyclaw/asset-service/package.json +1 -1
- package/node_modules/@capyclaw/asset-service/src/index.mjs +4 -3
- package/node_modules/@capyclaw/document-workbench/package.json +6 -3
- package/node_modules/@capyclaw/document-workbench/src/client/index.mjs +56 -3
- package/node_modules/@capyclaw/document-workbench/src/client/visibility.mjs +112 -0
- package/node_modules/@capyclaw/document-workbench/src/model/manifest.mjs +6 -4
- package/node_modules/@capyclaw/document-workbench/src/model/ops.mjs +7 -2
- package/node_modules/@capyclaw/document-workbench/src/session/index.mjs +8 -0
- package/node_modules/@capyclaw/document-workbench/src/store/file-backend.mjs +17 -10
- package/node_modules/@capyclaw/document-workbench/src/store/projection.mjs +39 -0
- package/node_modules/@capyclaw/document-workbench/src/testing/index.mjs +14 -11
- package/node_modules/@capyclaw/editor-host/dsh-suite.json +1 -1
- package/node_modules/@capyclaw/editor-host/package.json +1 -1
- package/node_modules/@capyclaw/editor-host/src/index.mjs +12 -21
- package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +3 -1
- package/node_modules/@capyclaw/foundation/abi/index.mjs +15 -0
- package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +21 -4
- package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +5 -1
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +5 -2
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +4 -0
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +13 -3
- package/node_modules/@capyclaw/foundation/package.json +1 -1
- package/node_modules/@capyclaw/plugin-kit/package.json +3 -1
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +5 -2
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
- package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +13 -5
- package/node_modules/@capyclaw/portal/package.json +1 -1
- package/node_modules/@capyclaw/ppt-editor/app.js +458 -10
- package/node_modules/@capyclaw/ppt-editor/contract/ppt-contract.json +1 -1
- package/node_modules/@capyclaw/ppt-editor/heartbeat-worker.js +5 -2
- package/node_modules/@capyclaw/ppt-editor/index.html +4 -0
- package/node_modules/@capyclaw/ppt-editor/package.json +2 -2
- package/node_modules/@capyclaw/ppt-skill-api/contract/ppt-contract.json +1 -1
- package/node_modules/@capyclaw/ppt-skill-api/package.json +1 -1
- package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/tool-contract.md +1 -1
- package/node_modules/@capyclaw/ppt-skill-proposal/contract/ppt-contract.json +1 -1
- package/node_modules/@capyclaw/ppt-skill-proposal/package.json +1 -1
- package/node_modules/@capyclaw/ppt-workbench/contract/ppt-contract.json +1 -1
- package/node_modules/@capyclaw/ppt-workbench/core/deck-layout.js +3 -1
- package/node_modules/@capyclaw/ppt-workbench/core/ops/slide.js +9 -3
- package/node_modules/@capyclaw/ppt-workbench/core/text.js +14 -2
- package/node_modules/@capyclaw/ppt-workbench/package.json +10 -8
- package/node_modules/@capyclaw/ppt-workbench/plugin.mjs +13 -1
- package/node_modules/@capyclaw/ppt-workbench/server/contract.mjs +1 -1
- package/node_modules/@capyclaw/ppt-workbench/server/embedded-host.mjs +200 -29
- package/node_modules/@capyclaw/ppt-workbench/server/relay.mjs +10 -7
- package/node_modules/@capyclaw/ppt-workbench/server/shared/SHARED_MANIFEST.json +4 -4
- package/node_modules/@capyclaw/ppt-workbench/server/store/backends/file-backend.mjs +3 -0
- package/node_modules/@capyclaw/ppt-workbench/server/store/checkpoints.mjs +4 -1
- package/node_modules/@capyclaw/ppt-workbench/server/store/index.mjs +4 -0
- package/node_modules/@capyclaw/ppt-workbench/server/store/sessions.mjs +139 -4
- package/node_modules/@capyclaw/ppt-workbench/server/store/shape.mjs +37 -0
- package/node_modules/@capyclaw/service-broker/README.md +1 -1
- package/node_modules/@capyclaw/service-broker/lib/host.mjs +11 -6
- package/node_modules/@capyclaw/service-broker/lib/skills-client.mjs +13 -5
- package/node_modules/@capyclaw/service-broker/package.json +1 -1
- package/node_modules/@capyclaw/service-host/dsh-suite.json +1 -1
- package/node_modules/@capyclaw/service-host/package.json +1 -1
- package/node_modules/@capyclaw/service-host/src/index.mjs +13 -22
- package/node_modules/@capyclaw/skills-service/README.md +42 -10
- package/node_modules/@capyclaw/skills-service/package.json +6 -3
- package/node_modules/@capyclaw/skills-service/server.mjs +129 -51
- 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 +230 -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/dsh-suite.json +1 -1
- package/node_modules/@capyclaw/tool-host/lib/host.mjs +15 -4
- package/node_modules/@capyclaw/tool-host/package.json +1 -1
- package/node_modules/@capyclaw/tool-host/src/index.mjs +19 -5
- package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +71 -3
- package/node_modules/@capyclaw/work-store/README.md +83 -0
- package/node_modules/@capyclaw/work-store/STANDARD.md +263 -0
- package/node_modules/@capyclaw/work-store/cordis.patch.yml +3 -0
- package/node_modules/@capyclaw/work-store/dsh-suite.json +33 -0
- package/node_modules/@capyclaw/work-store/icon.svg +7 -0
- package/node_modules/@capyclaw/work-store/lib/host.mjs +21 -0
- package/node_modules/@capyclaw/work-store/package.json +68 -0
- package/node_modules/@capyclaw/work-store/src/backend.mjs +90 -0
- package/node_modules/@capyclaw/work-store/src/db.mjs +199 -0
- package/node_modules/@capyclaw/work-store/src/envelope.mjs +132 -0
- package/node_modules/@capyclaw/work-store/src/index.mjs +571 -0
- package/node_modules/@capyclaw/work-store/src/interop.mjs +70 -0
- package/node_modules/@capyclaw/work-store/src/refs.mjs +99 -0
- package/node_modules/@capyclaw/work-store/src/routes.mjs +135 -0
- package/package.json +16 -14
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* dsh-suite CLI:
|
|
4
|
+
* dsh-suite validate <suite...>
|
|
5
|
+
* dsh-suite compose <suite...> --out <dir>
|
|
6
|
+
* dsh-suite install <suite...> --profile web [--dsh-home <dir>] [--dry-run] [--no-pnpm]
|
|
7
|
+
* dsh-suite doctor --profile web [--dsh-home <dir>] [--dsh-bin <path>]
|
|
8
|
+
* dsh-suite init <dir> --name <name> [--title <title>]
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'node:fs'
|
|
11
|
+
import path from 'node:path'
|
|
12
|
+
import {
|
|
13
|
+
buildActivationRegistry, composeSuites, composeToDir, doctor, formatReport, installSuites,
|
|
14
|
+
loadSuiteManifest, renderCordisPatch, validateSuiteManifest,
|
|
15
|
+
} from '../src/index.mjs'
|
|
16
|
+
|
|
17
|
+
function parse(argv) {
|
|
18
|
+
const args = []
|
|
19
|
+
const flags = {}
|
|
20
|
+
for (let i = 0; i < argv.length; i++) {
|
|
21
|
+
const item = argv[i]
|
|
22
|
+
if (!item.startsWith('--')) { args.push(item); continue }
|
|
23
|
+
const key = item.slice(2)
|
|
24
|
+
const next = argv[i + 1]
|
|
25
|
+
if (next && !next.startsWith('--')) { flags[key] = next; i++ }
|
|
26
|
+
else flags[key] = true
|
|
27
|
+
}
|
|
28
|
+
return { args, flags }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function fail(message) {
|
|
32
|
+
console.error(`✗ ${message}`)
|
|
33
|
+
process.exit(1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function printValidation(loaded) {
|
|
37
|
+
const result = validateSuiteManifest(loaded.manifest, { baseDir: loaded.dir })
|
|
38
|
+
console.log(`${result.ok ? '✓' : '✗'} ${loaded.manifest.name || loaded.file}`)
|
|
39
|
+
for (const warning of result.warnings) console.log(` ! ${warning}`)
|
|
40
|
+
for (const error of result.errors) console.log(` ✗ ${error}`)
|
|
41
|
+
return result.ok
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function cmdValidate(suitePaths) {
|
|
45
|
+
if (!suitePaths.length) fail('用法: dsh-suite validate <suite...>')
|
|
46
|
+
let ok = true
|
|
47
|
+
for (const input of suitePaths) {
|
|
48
|
+
try {
|
|
49
|
+
ok = printValidation(loadSuiteManifest(input)) && ok
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.log(`✗ ${input}: ${error.message}`)
|
|
52
|
+
ok = false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
process.exit(ok ? 0 : 1)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function cmdCompose(suitePaths, flags) {
|
|
59
|
+
if (!suitePaths.length || !flags.out) fail('用法: dsh-suite compose <suite...> --out <dir>')
|
|
60
|
+
const suites = suitePaths.map((input) => loadSuiteManifest(input))
|
|
61
|
+
const result = composeToDir(suites, path.resolve(flags.out))
|
|
62
|
+
for (const warning of result.warnings) console.log(`! ${warning}`)
|
|
63
|
+
for (const error of result.errors) console.log(`✗ ${error}`)
|
|
64
|
+
console.log(result.ok
|
|
65
|
+
? `✓ 组合 ${suites.length} 个 suite,${result.rows.length} 行 → ${path.resolve(flags.out)}`
|
|
66
|
+
: '✗ 组合存在冲突')
|
|
67
|
+
process.exit(result.ok ? 0 : 1)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function cmdInstall(suitePaths, flags) {
|
|
71
|
+
if (!suitePaths.length) fail('用法: dsh-suite install <suite...> --profile <name>')
|
|
72
|
+
try {
|
|
73
|
+
const plan = installSuites({
|
|
74
|
+
suiteInputs: suitePaths,
|
|
75
|
+
profile: flags.profile,
|
|
76
|
+
dshHome: flags['dsh-home'],
|
|
77
|
+
dryRun: !!flags['dry-run'],
|
|
78
|
+
runPnpm: !flags['no-pnpm'],
|
|
79
|
+
packageSpecs: flags.package ? String(flags.package).split(',') : [],
|
|
80
|
+
rollbackTo: flags['rollback-to'],
|
|
81
|
+
artifactRoot: flags['artifact-root'],
|
|
82
|
+
})
|
|
83
|
+
for (const warning of plan.warnings || []) console.log(`! ${warning}`)
|
|
84
|
+
console.log(`✓ ${plan.dryRun ? 'dry-run ' : ''}suite 安装完成`)
|
|
85
|
+
console.log(JSON.stringify(plan, null, 2))
|
|
86
|
+
} catch (error) {
|
|
87
|
+
fail(error.message)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function cmdRegistry(suitePaths) {
|
|
92
|
+
if (!suitePaths.length) fail('用法: dsh-suite registry <suite...>')
|
|
93
|
+
const suites = suitePaths.map((input) => loadSuiteManifest(input))
|
|
94
|
+
const composed = composeSuites(suites)
|
|
95
|
+
if (!composed.ok) fail('suite 组合冲突:\n- ' + composed.errors.join('\n- '))
|
|
96
|
+
const { registry, warnings } = buildActivationRegistry({ suites, composed })
|
|
97
|
+
for (const warning of warnings) console.error(`! ${warning}`)
|
|
98
|
+
console.log(JSON.stringify(registry, null, 2))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function cmdDoctor(flags) {
|
|
102
|
+
const report = await doctor({
|
|
103
|
+
profile: flags.profile,
|
|
104
|
+
dshHome: flags['dsh-home'],
|
|
105
|
+
dshBin: flags['dsh-bin'],
|
|
106
|
+
})
|
|
107
|
+
console.log(formatReport(report))
|
|
108
|
+
process.exitCode = report.ok ? 0 : 1
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function cmdInit(dir, flags) {
|
|
112
|
+
if (!dir || !flags.name) fail('用法: dsh-suite init <dir> --name <name> [--title <title>]')
|
|
113
|
+
const target = path.resolve(dir)
|
|
114
|
+
if (fs.existsSync(target) && fs.readdirSync(target).length) fail(`目录非空: ${target}`)
|
|
115
|
+
fs.mkdirSync(target, { recursive: true })
|
|
116
|
+
const name = flags.name
|
|
117
|
+
const title = flags.title || name
|
|
118
|
+
const manifest = {
|
|
119
|
+
name,
|
|
120
|
+
version: '0.1.0',
|
|
121
|
+
title,
|
|
122
|
+
description: `${title}(DSH 组合套件)`,
|
|
123
|
+
packages: {
|
|
124
|
+
[name]: { role: 'runtime', version: '^0.1.0', path: '.' },
|
|
125
|
+
},
|
|
126
|
+
rows: [{ id: `${name}-host`, name }],
|
|
127
|
+
checks: [],
|
|
128
|
+
}
|
|
129
|
+
const pkg = {
|
|
130
|
+
name,
|
|
131
|
+
version: '0.1.0',
|
|
132
|
+
description: manifest.description,
|
|
133
|
+
type: 'module',
|
|
134
|
+
main: './lib/index.mjs',
|
|
135
|
+
exports: { '.': './lib/index.mjs', './package.json': './package.json' },
|
|
136
|
+
dsh: { bundle: { patch: './cordis.patch.yml' }, suite: './dsh-suite.json' },
|
|
137
|
+
files: ['lib/', 'dsh-suite.json', 'cordis.patch.yml', 'README.md'],
|
|
138
|
+
license: 'MIT',
|
|
139
|
+
private: true,
|
|
140
|
+
}
|
|
141
|
+
fs.writeFileSync(path.join(target, 'dsh-suite.json'), JSON.stringify(manifest, null, 2) + '\n')
|
|
142
|
+
fs.writeFileSync(path.join(target, 'package.json'), JSON.stringify(pkg, null, 2) + '\n')
|
|
143
|
+
fs.writeFileSync(path.join(target, 'cordis.patch.yml'), renderCordisPatch(manifest.rows))
|
|
144
|
+
fs.mkdirSync(path.join(target, 'lib'))
|
|
145
|
+
fs.writeFileSync(path.join(target, 'lib', 'index.mjs'),
|
|
146
|
+
`export const name = ${JSON.stringify(name)}\nexport function apply() {}\n`)
|
|
147
|
+
fs.writeFileSync(path.join(target, 'README.md'),
|
|
148
|
+
`# ${title}\n\n由 @capyclaw/suite-kit 生成的 DSH 组合套件。\n\n` +
|
|
149
|
+
'```bash\ndsh-suite validate .\ndsh-suite install . --profile web\n```\n')
|
|
150
|
+
console.log(`✓ 已生成 ${target}`)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const { args, flags } = parse(process.argv.slice(2))
|
|
154
|
+
const [command] = args
|
|
155
|
+
if (!command || command === '--help' || command === 'help') {
|
|
156
|
+
console.log(`dsh-suite — DSH 组合标准件
|
|
157
|
+
|
|
158
|
+
validate <suite...> 校验 manifest
|
|
159
|
+
compose <suite...> --out <dir> 组合并生成 cordis.patch.yml
|
|
160
|
+
registry <suite...> 生成 launch-engine 激活注册表(预览)
|
|
161
|
+
install <suite...> --profile web 安装到 profile
|
|
162
|
+
doctor --profile web 运行健康检查
|
|
163
|
+
init <dir> --name <name> 生成新 suite 模板
|
|
164
|
+
`)
|
|
165
|
+
process.exit(0)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (command === 'validate') cmdValidate(args.slice(1))
|
|
169
|
+
else if (command === 'compose') cmdCompose(args.slice(1), flags)
|
|
170
|
+
else if (command === 'registry') cmdRegistry(args.slice(1))
|
|
171
|
+
else if (command === 'install') cmdInstall(args.slice(1), flags)
|
|
172
|
+
else if (command === 'doctor') await cmdDoctor(flags)
|
|
173
|
+
else if (command === 'init') cmdInit(args[1], flags)
|
|
174
|
+
else fail(`未知命令: ${command}`)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 嵌入握手客户端(浏览器侧,无构建、无依赖)。镜像 src/embed.mjs 的协议常量。
|
|
3
|
+
* 套件 UI 以 <script src="./embed.js"> 引入;被父窗以 mode=embedded 打开时隐藏 standalone chrome、
|
|
4
|
+
* 报 ready,并经 CapyclawEmbed.sendEvent 把统一事件转发父窗。控制面不分模式(标准 §C.7)。
|
|
5
|
+
*/
|
|
6
|
+
(function () {
|
|
7
|
+
var VERSION = 1
|
|
8
|
+
var TYPES = { init: 'capyclaw:embed:init', ready: 'capyclaw:embed:ready', event: 'capyclaw:embed:event' }
|
|
9
|
+
var KINDS = ['progress', 'artifact', 'confirm', 'login', 'result', 'error']
|
|
10
|
+
function isLocalOrigin(o) { return typeof o === 'string' && /^http:\/\/(127\.0\.0\.1|localhost)(:\d+)?$/.test(o) }
|
|
11
|
+
var state = { mode: 'standalone', suite: '', sessionId: null, workId: null, parentOrigin: null, embedPath: location.pathname }
|
|
12
|
+
function post(msg) { if (state.parentOrigin && window.parent !== window) window.parent.postMessage(msg, state.parentOrigin) }
|
|
13
|
+
function sendEvent(event) {
|
|
14
|
+
if (!event || KINDS.indexOf(event.kind) === -1) return false
|
|
15
|
+
post({ type: TYPES.event, protocolVersion: VERSION, event: event })
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
function ready() { post({ type: TYPES.ready, protocolVersion: VERSION, suite: state.suite, embedPath: state.embedPath, workId: state.workId }) }
|
|
19
|
+
window.addEventListener('message', function (ev) {
|
|
20
|
+
var msg = ev.data
|
|
21
|
+
if (!msg || msg.type !== TYPES.init || msg.protocolVersion !== VERSION) return
|
|
22
|
+
if (!isLocalOrigin(ev.origin)) return // 只信本地同源,拒外部注入
|
|
23
|
+
if (!msg.sessionId) return
|
|
24
|
+
state.mode = 'embedded'; state.sessionId = msg.sessionId; state.workId = msg.workId || null; state.parentOrigin = ev.origin
|
|
25
|
+
document.body.classList.add('capyclaw-embedded')
|
|
26
|
+
document.dispatchEvent(new CustomEvent('capyclaw:embed:mode', { detail: Object.assign({}, state) }))
|
|
27
|
+
ready()
|
|
28
|
+
})
|
|
29
|
+
window.CapyclawEmbed = {
|
|
30
|
+
get state() { return Object.assign({}, state) },
|
|
31
|
+
setSuite: function (s) { state.suite = s },
|
|
32
|
+
sendEvent: sendEvent,
|
|
33
|
+
isEmbedded: function () { return state.mode === 'embedded' },
|
|
34
|
+
}
|
|
35
|
+
})()
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://dsh.local/schemas/domain.schema.json",
|
|
4
|
+
"title": "DSH Domain Pack Manifest",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["name", "version", "components"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": { "type": "string" },
|
|
10
|
+
"name": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
|
|
11
|
+
"version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$" },
|
|
12
|
+
"title": { "type": "string" },
|
|
13
|
+
"description": { "type": "string" },
|
|
14
|
+
"baseBundles": { "type": "array", "items": { "type": "string" } },
|
|
15
|
+
"components": { "type": "array", "minItems": 1, "items": { "type": "string" } },
|
|
16
|
+
"profile": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"additionalProperties": true,
|
|
19
|
+
"properties": {
|
|
20
|
+
"name": { "type": "string" },
|
|
21
|
+
"port": { "type": "integer" }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"runtime": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"additionalProperties": true,
|
|
27
|
+
"properties": {
|
|
28
|
+
"driver": { "type": "string", "enum": ["node", "jobobject", "docker", "wsl"] },
|
|
29
|
+
"workId": { "type": "string" },
|
|
30
|
+
"ttlSec": { "type": "integer", "minimum": 0 },
|
|
31
|
+
"env": { "type": "object", "additionalProperties": true },
|
|
32
|
+
"bindings": {
|
|
33
|
+
"type": "array",
|
|
34
|
+
"items": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"additionalProperties": false,
|
|
37
|
+
"properties": {
|
|
38
|
+
"row": { "type": "string" },
|
|
39
|
+
"package": { "type": "string" },
|
|
40
|
+
"port": { "type": "string" },
|
|
41
|
+
"config": { "type": "object" }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"urlPort": { "type": "string" },
|
|
46
|
+
"model": {
|
|
47
|
+
"oneOf": [
|
|
48
|
+
{ "type": "boolean" },
|
|
49
|
+
{
|
|
50
|
+
"type": "object",
|
|
51
|
+
"additionalProperties": true,
|
|
52
|
+
"properties": {
|
|
53
|
+
"id": { "type": "string" },
|
|
54
|
+
"plugin": { "type": "string" },
|
|
55
|
+
"apiKeyEnv": { "type": "string" },
|
|
56
|
+
"baseUrlEnv": { "type": "string" },
|
|
57
|
+
"baseURL": { "type": "string" }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"workspaceController": {
|
|
63
|
+
"oneOf": [
|
|
64
|
+
{ "type": "boolean" },
|
|
65
|
+
{ "type": "object", "additionalProperties": true }
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"requires": {
|
|
69
|
+
"type": "object",
|
|
70
|
+
"additionalProperties": true,
|
|
71
|
+
"properties": {
|
|
72
|
+
"tools": { "type": "array", "items": { "type": "string" } },
|
|
73
|
+
"services": { "type": "array", "items": { "type": "string" } },
|
|
74
|
+
"capabilities": { "type": "array", "items": { "type": "string" } }
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"scope": {
|
|
78
|
+
"type": "object",
|
|
79
|
+
"additionalProperties": true,
|
|
80
|
+
"properties": {
|
|
81
|
+
"sessions": { "type": "object" },
|
|
82
|
+
"files": {
|
|
83
|
+
"type": "array",
|
|
84
|
+
"items": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"required": ["path"],
|
|
87
|
+
"properties": {
|
|
88
|
+
"id": { "type": "string" },
|
|
89
|
+
"kind": { "type": "string" },
|
|
90
|
+
"path": { "type": "string" },
|
|
91
|
+
"patterns": { "type": "array", "items": { "type": "string" } }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"workspace": { "type": "object" },
|
|
96
|
+
"network": { "type": "object" },
|
|
97
|
+
"processes": { "type": "object" }
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"ports": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"additionalProperties": true,
|
|
103
|
+
"properties": {
|
|
104
|
+
"harness": { "oneOf": [{ "type": "integer" }, { "type": "object" }] },
|
|
105
|
+
"dsh": { "oneOf": [{ "type": "integer" }, { "type": "object" }] },
|
|
106
|
+
"content": { "oneOf": [{ "type": "integer" }, { "type": "object" }] },
|
|
107
|
+
"services": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"additionalProperties": { "oneOf": [{ "type": "integer" }, { "type": "object" }] }
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"removeRows": { "type": "array", "items": { "type": "string" } },
|
|
116
|
+
"removeDependencies": { "type": "array", "items": { "type": "string" } },
|
|
117
|
+
"rowOverrides": {
|
|
118
|
+
"type": "object",
|
|
119
|
+
"additionalProperties": {
|
|
120
|
+
"type": "object",
|
|
121
|
+
"additionalProperties": false,
|
|
122
|
+
"properties": {
|
|
123
|
+
"config": { "type": "object" },
|
|
124
|
+
"disabled": { "type": "boolean" }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@capyclaw/suite-kit",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "DSH suite/domain 标准件(双重身份:构建期库 + 运行时库,暂不拆包,见 README「双重身份」)。构建期:manifest 校验、compose、profile 生成、domain 解析、artifact 打包;运行时:统一能力描述符、编排闸/授权、嵌入握手与 surface 挂载。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.mjs",
|
|
9
|
+
"./domain": "./src/domain.mjs",
|
|
10
|
+
"./compose": "./src/compose.mjs",
|
|
11
|
+
"./manifest": "./src/manifest.mjs",
|
|
12
|
+
"./capability": "./src/capability.mjs",
|
|
13
|
+
"./orchestration": "./src/orchestration.mjs",
|
|
14
|
+
"./embed": "./src/embed.mjs",
|
|
15
|
+
"./surface": "./src/surface.mjs",
|
|
16
|
+
"./host": "./src/host.mjs",
|
|
17
|
+
"./client/embed.js": "./client/embed.js",
|
|
18
|
+
"./profile": "./src/profile.mjs",
|
|
19
|
+
"./artifacts": "./src/artifacts.mjs",
|
|
20
|
+
"./schema": "./suite.schema.json",
|
|
21
|
+
"./package.json": "./package.json",
|
|
22
|
+
"./domain-schema": "./domain.schema.json"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"dsh-suite": "./bin/dsh-suite.mjs",
|
|
26
|
+
"dsh-domain": "./bin/dsh-domain.mjs"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"test": "node --test test/*.test.mjs"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"README.md",
|
|
33
|
+
"bin/",
|
|
34
|
+
"client/",
|
|
35
|
+
"domain.schema.json",
|
|
36
|
+
"src/",
|
|
37
|
+
"suite.schema.json"
|
|
38
|
+
],
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@capyclaw/plugin-kit": "^0.2.6"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/Maple496/capyclaw.git",
|
|
52
|
+
"directory": "C/packages/capyclaw-suite-kit"
|
|
53
|
+
},
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/Maple496/capyclaw/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/Maple496/capyclaw/tree/main/C/packages/capyclaw-suite-kit#readme"
|
|
58
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从 suite 组合结果编译 launch-engine 的 capability 注册表。
|
|
3
|
+
*
|
|
4
|
+
* 「实现一个功能要注册哪些组件」的唯一事实来源是 dsh-suite.json;
|
|
5
|
+
* 这里把它编译成运行期激活面(@capyclaw/launch-engine)直接消费的注册表,
|
|
6
|
+
* 不再手写第二种「要求 → 组件」映射。映射规则:
|
|
7
|
+
*
|
|
8
|
+
* - 每个包 = 一个激活 capability(name = 包名),条件是它有 row、拥有服务进程、
|
|
9
|
+
* 或是组合内其他包 required capability 的提供方(纯 support 依赖不单独成能力)
|
|
10
|
+
* entries = 该包的 rows(entryId = include:<rowId>)
|
|
11
|
+
* requires = 包 requires.capabilities 解析到的提供方包(组合内)
|
|
12
|
+
* services = 套件 services.json 里 cmd 指向该包 node_modules/<pkg>/ 的条目
|
|
13
|
+
* - 每个套件 = 一个聚合 capability(name = 套件名;bundle 级开关)
|
|
14
|
+
* bundles = [{ name: 套件名 }](installSuites 把套件名写进 dsh.profile.bundles)
|
|
15
|
+
* requires = 该套件下所有已注册的包 capability
|
|
16
|
+
* entries/services = 无法归属到具体包的行与服务
|
|
17
|
+
*
|
|
18
|
+
* services 编译时展开 ${PACKAGE_DIR}(注册表落在 profile 目录,不能依赖
|
|
19
|
+
* broker 清单装载期的展开基准),剥掉 portFrom/dirFrom(那是 runtime
|
|
20
|
+
* 物化期的分配提示,不是激活语义);${PORT} 原样留给 broker 仲裁。
|
|
21
|
+
*/
|
|
22
|
+
import fs from 'node:fs'
|
|
23
|
+
import path from 'node:path'
|
|
24
|
+
|
|
25
|
+
export const ACTIVATION_REGISTRY_FILENAME = 'launch-engine.registry.json'
|
|
26
|
+
const ENTRY_PREFIX = 'include:'
|
|
27
|
+
|
|
28
|
+
function readSuiteServices(suiteDir) {
|
|
29
|
+
const file = path.join(suiteDir, 'services.json')
|
|
30
|
+
if (!fs.existsSync(file)) return []
|
|
31
|
+
try {
|
|
32
|
+
const raw = JSON.parse(fs.readFileSync(file, 'utf8'))
|
|
33
|
+
return Array.isArray(raw?.services) ? raw.services : []
|
|
34
|
+
} catch {
|
|
35
|
+
return []
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function serviceOwnerPackage(service, packageNames) {
|
|
40
|
+
const cmd = Array.isArray(service?.cmd) ? service.cmd.join(' ') : ''
|
|
41
|
+
for (const name of packageNames) {
|
|
42
|
+
const needle = `node_modules/${name}/`
|
|
43
|
+
if (cmd.includes(needle)) return name
|
|
44
|
+
}
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** 展开 services.json 的 ${PACKAGE_DIR}。两种规格:
|
|
49
|
+
* - 新代:cmd 形如 ${PACKAGE_DIR}/node_modules/<pkg>/…——${PACKAGE_DIR} 指
|
|
50
|
+
* 持有 node_modules 的套件根(services.json 所在目录),不是 owner 包自身目录;
|
|
51
|
+
* - 旧代:cmd 形如 ${PACKAGE_DIR}/server/relay.mjs——${PACKAGE_DIR} 指 owner 包目录。 */
|
|
52
|
+
function toActivationService(service, { packageDir, suiteDir }) {
|
|
53
|
+
const joined = (service.cmd || []).join(' ')
|
|
54
|
+
const base = joined.includes('node_modules/') ? suiteDir : packageDir
|
|
55
|
+
const cmd = (service.cmd || []).map((part) => String(part).replaceAll('${PACKAGE_DIR}', base))
|
|
56
|
+
const next = { ...service, cmd }
|
|
57
|
+
delete next.portFrom
|
|
58
|
+
delete next.dirFrom
|
|
59
|
+
return next
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function packageDirOf(pkg) {
|
|
63
|
+
if (!pkg?.dir || !pkg?.entry?.path) return null
|
|
64
|
+
return path.resolve(pkg.dir, pkg.entry.path).replace(/\\/g, '/')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @param {{suites: {dir:string, manifest:object}[], composed: object, requiredCapabilities?: string[]}} input
|
|
69
|
+
* suites 已加载(components 已展开)的套件;composed = composeSuites 输出
|
|
70
|
+
* requiredCapabilities 额外的能力名(如 domain runtime.requires.capabilities),
|
|
71
|
+
* 其提供方也应进入注册表
|
|
72
|
+
* @returns {{registry: {version:1, capabilities:object}, warnings: string[]}}
|
|
73
|
+
*/
|
|
74
|
+
export function buildActivationRegistry({ suites, composed, requiredCapabilities = [] }) {
|
|
75
|
+
const warnings = []
|
|
76
|
+
const capabilities = {}
|
|
77
|
+
const packages = composed?.packages || []
|
|
78
|
+
const packageNames = packages.map((pkg) => pkg.name)
|
|
79
|
+
const capProvider = new Map((composed?.capabilities || []).map((item) => [item.capability, item.package]))
|
|
80
|
+
|
|
81
|
+
/* 组合内被别人 required 的能力的提供方:即使没有 row(纯服务进程形态,
|
|
82
|
+
* 如 capyclaw-ppt-workbench)也必须成为 capability,否则依赖图断链。 */
|
|
83
|
+
const demandedProviders = new Set()
|
|
84
|
+
for (const pkg of packages) {
|
|
85
|
+
for (const capability of Object.keys(pkg.entry.requires?.capabilities || {})) {
|
|
86
|
+
const provider = capProvider.get(capability)
|
|
87
|
+
if (provider) demandedProviders.add(provider)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const capability of requiredCapabilities) {
|
|
91
|
+
const provider = capProvider.get(String(capability).split('@')[0])
|
|
92
|
+
if (provider) demandedProviders.add(provider)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const rowsByPackage = new Map()
|
|
96
|
+
const orphanRowsBySuite = new Map()
|
|
97
|
+
for (const row of composed?.rows || []) {
|
|
98
|
+
if (row.disabled) continue
|
|
99
|
+
if (packageNames.includes(row.name)) {
|
|
100
|
+
rowsByPackage.set(row.name, [...(rowsByPackage.get(row.name) || []), row])
|
|
101
|
+
} else {
|
|
102
|
+
const suite = row._suite || ''
|
|
103
|
+
orphanRowsBySuite.set(suite, [...(orphanRowsBySuite.get(suite) || []), row])
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const packageServices = new Map()
|
|
108
|
+
for (const suite of suites || []) {
|
|
109
|
+
for (const service of readSuiteServices(suite.dir)) {
|
|
110
|
+
const owner = serviceOwnerPackage(service, packageNames)
|
|
111
|
+
if (owner) packageServices.set(owner, [...(packageServices.get(owner) || []), { service, suiteDir: (suite.dir || '').replace(/\\/g, '/') }])
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
for (const pkg of packages) {
|
|
116
|
+
const rows = rowsByPackage.get(pkg.name) || []
|
|
117
|
+
const services = packageServices.get(pkg.name) || []
|
|
118
|
+
if (!rows.length && !services.length && !demandedProviders.has(pkg.name)) continue
|
|
119
|
+
const requires = []
|
|
120
|
+
for (const capability of Object.keys(pkg.entry.requires?.capabilities || {})) {
|
|
121
|
+
const provider = capProvider.get(capability)
|
|
122
|
+
if (!provider || provider === pkg.name || requires.includes(provider)) continue
|
|
123
|
+
if (!packageNames.includes(provider)) continue
|
|
124
|
+
requires.push(provider)
|
|
125
|
+
}
|
|
126
|
+
capabilities[pkg.name] = {
|
|
127
|
+
name: pkg.name,
|
|
128
|
+
title: pkg.name,
|
|
129
|
+
requires,
|
|
130
|
+
bundles: [],
|
|
131
|
+
entries: rows.map((row) => ({ entryId: ENTRY_PREFIX + row.id, enabled: true })),
|
|
132
|
+
services: services.map(({ service, suiteDir }) => toActivationService(service, {
|
|
133
|
+
packageDir: packageDirOf(pkg) || suiteDir,
|
|
134
|
+
suiteDir,
|
|
135
|
+
})),
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for (const suite of suites || []) {
|
|
140
|
+
const name = suite.manifest.name
|
|
141
|
+
const dir = (suite.dir || '').replace(/\\/g, '/')
|
|
142
|
+
if (capabilities[name]) {
|
|
143
|
+
warnings.push(`capability 名冲突: 套件 ${name} 与已有包能力重名,聚合能力改用 suite:<name>`)
|
|
144
|
+
}
|
|
145
|
+
const aggregateName = capabilities[name] ? `suite:${name}` : name
|
|
146
|
+
const unmatched = []
|
|
147
|
+
|
|
148
|
+
for (const service of readSuiteServices(suite.dir)) {
|
|
149
|
+
const owner = serviceOwnerPackage(service, packageNames)
|
|
150
|
+
/* 已在包能力里挂载的服务不重复;只有无主或主人未成能力的才归套件聚合。 */
|
|
151
|
+
if (owner && capabilities[owner]) continue
|
|
152
|
+
unmatched.push(toActivationService(service, { packageDir: dir, suiteDir: dir }))
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const requires = []
|
|
156
|
+
for (const pkg of packages) {
|
|
157
|
+
if (pkg.suite !== name) continue
|
|
158
|
+
if (capabilities[pkg.name] && !requires.includes(pkg.name)) requires.push(pkg.name)
|
|
159
|
+
}
|
|
160
|
+
const orphanRows = orphanRowsBySuite.get(name) || []
|
|
161
|
+
if (orphanRows.length) {
|
|
162
|
+
warnings.push(`${name}: 行 [${orphanRows.map((row) => row.id).join(', ')}] 引用的包不在组合里(外部已安装),归入套件聚合能力`)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
capabilities[aggregateName] = {
|
|
166
|
+
name: aggregateName,
|
|
167
|
+
title: suite.manifest.title || name,
|
|
168
|
+
requires,
|
|
169
|
+
bundles: [{ name, enabled: true }],
|
|
170
|
+
entries: orphanRows.map((row) => ({ entryId: ENTRY_PREFIX + row.id, enabled: true })),
|
|
171
|
+
services: unmatched,
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return { registry: { version: 1, capabilities }, warnings }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** 安装期落盘:<profile>/launch-engine.registry.json。 */
|
|
179
|
+
export function writeActivationRegistry(profileDir, { suites, composed }) {
|
|
180
|
+
const { registry, warnings } = buildActivationRegistry({ suites, composed })
|
|
181
|
+
const file = path.join(profileDir, ACTIVATION_REGISTRY_FILENAME)
|
|
182
|
+
fs.writeFileSync(file, JSON.stringify(registry, null, 2) + '\n')
|
|
183
|
+
return { file, registry, warnings, capabilities: Object.keys(registry.capabilities) }
|
|
184
|
+
}
|