@capyclaw/capyclaw-workbench 0.1.3 → 0.1.4

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/foundation",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "dsh 插件基石层:接口 ABI、插件加载器与内核服务 ctx.os。应用插件只声明接口,不写装配代码。",
5
5
  "type": "module",
6
6
  "main": "./lib/host.mjs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/plugin-kit",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "DSH 插件基础设施标准件:HTTP/MCP、单实例锁、参数校验、技能 provider、journal 存储、编辑器传输与租约。",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
@@ -32,6 +32,7 @@
32
32
  "./tuning": "./src/tuning.mjs",
33
33
  "./util/fs-lock": "./src/util/fs-lock.mjs",
34
34
  "./util/http": "./src/util/http.mjs",
35
+ "./ledger": "./src/ledger.mjs",
35
36
  "./editor/heartbeat-worker": "./src/editor/heartbeat-worker.js"
36
37
  },
37
38
  "bin": {
@@ -0,0 +1,151 @@
1
+ /**
2
+ * @capyclaw/plugin-kit/ledger —— capyclaw 全插件统一操作/状态台账(append-only JSONL)。
3
+ *
4
+ * 设计目标(2026-11-25 用户要求「统一管理、是否工作/工作状态如何都记录」):
5
+ * - 单一存储:每个 profile 一份 `plugin-data/capyclaw/plugin-log.jsonl`,所有底盘
6
+ * (wizard 管理操作、suite-kit 挂载状态、service-host 服务生命周期/运行时错误)
7
+ * 往同一份台账追加,读取面统一查询,不按插件各写各的。
8
+ * - 只记事件不记噪音:管理操作结果、挂载/退让/降级/失败/释放、listen/dispatch 错误。
9
+ * - 永不反噬宿主:所有写盘 try/catch 吞错(台账坏了不能影响插件激活)。
10
+ * - 环形上限:超过 maxBytes(默认 2MB)轮转为 `.1`(保留一代历史),不无限增长。
11
+ * - 去重聚合在读取侧:fingerprint = hash(name + code + 归一化栈顶/消息前三行),
12
+ * 同指纹累加 count/firstAt/lastAt,复发一眼可见;原始行保留审计轨迹。
13
+ * - 纯本地:不上传、不记会话内容;导出由用户手动脱敏。
14
+ *
15
+ * 依赖方向:仅 node 内置模块(fs/path/crypto),任何底盘都可安全 import。
16
+ */
17
+ import fs from 'node:fs'
18
+ import path from 'node:path'
19
+ import crypto from 'node:crypto'
20
+
21
+ /** 台账文件名(profile 的 plugin-data/capyclaw/ 下)。 */
22
+ export const LEDGER_FILENAME = 'plugin-log.jsonl'
23
+
24
+ /** profile 目录 → 台账绝对路径;profileDir 缺席返回 null(调用方降级为不记录)。 */
25
+ export function ledgerFileFor(profileDir) {
26
+ return profileDir ? path.join(profileDir, 'plugin-data', 'capyclaw', LEDGER_FILENAME) : null
27
+ }
28
+
29
+ /**
30
+ * 复发指纹:name + code + 归一化消息/栈顶前三行(数字/地址抹平),
31
+ * 同一缺陷的不同实例(端口号、时间戳、pid 不同)归到同一指纹。
32
+ */
33
+ export function fingerprintOf({ name, code, message, stackTop } = {}) {
34
+ const head = String(stackTop || message || '')
35
+ .split('\n').slice(0, 3).join('|')
36
+ .replace(/0x[0-9a-f]+/gi, '')
37
+ .replace(/\d+/g, '#')
38
+ const basis = `${name || ''}::${code || ''}::${head}`
39
+ return crypto.createHash('sha1').update(basis).digest('hex').slice(0, 12)
40
+ }
41
+
42
+ const clip = (v, n) => (typeof v === 'string' && v.length > n ? `${v.slice(0, n)}\n…(truncated)` : v)
43
+
44
+ /** 归一化一条台账记录:补 at/pid/fingerprint,截断超长 message/stackTop。 */
45
+ export function normalizeEntry(entry = {}) {
46
+ const e = {
47
+ at: typeof entry.at === 'number' ? entry.at : Date.now(),
48
+ pid: process.pid,
49
+ source: entry.source || 'unknown',
50
+ name: entry.name || null,
51
+ suite: entry.suite || null,
52
+ version: entry.version || null,
53
+ specKind: entry.specKind || null,
54
+ phase: entry.phase || 'runtime',
55
+ action: entry.action || null,
56
+ ok: entry.ok !== false,
57
+ degraded: entry.degraded === true,
58
+ code: entry.code || null,
59
+ message: clip(entry.message || null, 2000),
60
+ stackTop: clip(entry.stackTop || null, 1200),
61
+ mountPath: entry.mountPath || null,
62
+ url: entry.url || null,
63
+ jobId: entry.jobId || null,
64
+ }
65
+ e.fingerprint = entry.fingerprint || fingerprintOf(e)
66
+ return e
67
+ }
68
+
69
+ /**
70
+ * 追加一条记录(best-effort,绝不抛错)。超 maxBytes 先轮转 `.1`。
71
+ * @returns {object|null} 归一化后的记录;file 缺席或写失败返回 null。
72
+ */
73
+ export function appendLedger(entry, { file, maxBytes = 2 * 1024 * 1024 } = {}) {
74
+ if (!file) return null
75
+ try {
76
+ const e = normalizeEntry(entry)
77
+ fs.mkdirSync(path.dirname(file), { recursive: true })
78
+ try {
79
+ const st = fs.statSync(file)
80
+ if (st.size > maxBytes) { try { fs.renameSync(file, `${file}.1`) } catch { /* 轮转失败继续追加 */ } }
81
+ } catch { /* 新文件 */ }
82
+ fs.appendFileSync(file, `${JSON.stringify(e)}\n`)
83
+ return e
84
+ } catch {
85
+ return null
86
+ }
87
+ }
88
+
89
+ /**
90
+ * 读取台账(坏行跳过)。filter:since(epoch ms)/name(匹配 name 或 suite)/source/
91
+ * errorsOnly(ok===false)/degradedOnly;limit 上限 2000,返回时间序尾部。
92
+ */
93
+ export function readLedger({ file, since = 0, name = null, source = null, errorsOnly = false, degradedOnly = false, limit = 200 } = {}) {
94
+ if (!file) return []
95
+ let raw = ''
96
+ try { raw = fs.readFileSync(file, 'utf8') } catch { return [] }
97
+ const out = []
98
+ for (const line of raw.split('\n')) {
99
+ if (!line.trim()) continue
100
+ try {
101
+ const e = JSON.parse(line)
102
+ if (e && typeof e === 'object') out.push(e)
103
+ } catch { /* 坏行跳过 */ }
104
+ }
105
+ let rows = out.filter((e) => (e.at || 0) >= since)
106
+ if (name) rows = rows.filter((e) => e.name === name || e.suite === name)
107
+ if (source) rows = rows.filter((e) => e.source === source)
108
+ if (errorsOnly) rows = rows.filter((e) => e.ok === false)
109
+ if (degradedOnly) rows = rows.filter((e) => e.degraded === true)
110
+ const n = Math.max(1, Math.min(Number(limit) || 200, 2000))
111
+ return rows.slice(-n)
112
+ }
113
+
114
+ /** 按指纹聚合:复发计数 + 首末时间 + 最近一条样本(count 降序)。 */
115
+ export function aggregateLedger(entries = []) {
116
+ const groups = new Map()
117
+ for (const e of entries) {
118
+ const key = e.fingerprint || fingerprintOf(e)
119
+ const g = groups.get(key) || { fingerprint: key, name: e.name, code: e.code, count: 0, firstAt: e.at, lastAt: e.at, message: e.message, stackTop: e.stackTop }
120
+ g.count += 1
121
+ g.firstAt = Math.min(g.firstAt, e.at || g.firstAt)
122
+ if ((e.at || 0) >= g.lastAt) { g.lastAt = e.at || g.lastAt; g.message = e.message; g.stackTop = e.stackTop }
123
+ groups.set(key, g)
124
+ }
125
+ return [...groups.values()].sort((a, b) => b.count - a.count || b.lastAt - a.lastAt)
126
+ }
127
+
128
+ /**
129
+ * 健康摘要:窗口内(默认 24h)按 name 汇总 events/errors/degraded/lastAction,
130
+ * 外加 top 指纹(默认 5 条),供 capyclaw_health 一眼看出「谁没在工作/谁在复发」。
131
+ */
132
+ export function summarizeLedger(entries = [], { windowMs = 24 * 3600 * 1000, top = 5, now = Date.now() } = {}) {
133
+ const rows = entries.filter((e) => (e.at || 0) >= now - windowMs)
134
+ const per = new Map()
135
+ for (const e of rows) {
136
+ const key = e.name || e.suite || e.source || '?'
137
+ const p = per.get(key) || { name: key, events: 0, errors: 0, degraded: 0, lastAt: 0, lastAction: null, lastOk: null }
138
+ p.events += 1
139
+ if (e.ok === false) p.errors += 1
140
+ if (e.degraded === true) p.degraded += 1
141
+ if ((e.at || 0) >= p.lastAt) { p.lastAt = e.at || p.lastAt; p.lastAction = e.action; p.lastOk = e.ok }
142
+ per.set(key, p)
143
+ }
144
+ return {
145
+ windowMs,
146
+ events: rows.length,
147
+ errors: rows.filter((e) => e.ok === false).length,
148
+ per: [...per.values()].sort((a, b) => b.errors - a.errors || b.lastAt - a.lastAt),
149
+ top: aggregateLedger(rows.filter((e) => e.ok === false)).slice(0, top),
150
+ }
151
+ }
@@ -7,7 +7,7 @@
7
7
  "packages": {
8
8
  "@capyclaw/service-host": {
9
9
  "role": "provider",
10
- "version": "^0.1.7",
10
+ "version": "^0.1.9",
11
11
  "path": ".",
12
12
  "provides": {
13
13
  "services": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/service-host",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "DSH 公共服务宿主插件:统一 HTTP 路由、健康检查、指标、单实例锁、端口复用与静态资源,向插件提供 ctx.serviceHost。",
5
5
  "type": "module",
6
6
  "main": "./lib/host.mjs",
@@ -45,7 +45,7 @@
45
45
  "test": "node --test test/*.test.mjs"
46
46
  },
47
47
  "dependencies": {
48
- "@capyclaw/plugin-kit": "^0.2.0",
48
+ "@capyclaw/plugin-kit": "^0.2.9",
49
49
  "@capyclaw/foundation": "^0.1.1"
50
50
  },
51
51
  "repository": {
@@ -20,6 +20,7 @@ import { listen, send, sendText, readBody } from '@capyclaw/plugin-kit/service/h
20
20
  import { createServiceApi } from '@capyclaw/plugin-kit/service/api'
21
21
  import { isLoopbackOrigin as sharedIsLoopbackOrigin, mimeFor } from '@capyclaw/plugin-kit/util/http'
22
22
  import { safeJoin, cleanStaticPrefix, staticPrefixHit, staticRelRaw, decodeStaticRel, staticFileHit, staticHitNameType, staticBaseHeaders } from '@capyclaw/plugin-kit/service/static'
23
+ import { appendLedger, ledgerFileFor } from '@capyclaw/plugin-kit/ledger'
23
24
  import { tuning } from './tuning.mjs'
24
25
 
25
26
  function slugOf(id) {
@@ -166,6 +167,11 @@ export function createServiceApp(options = {}) {
166
167
  let closed = false
167
168
  let workdir = ''
168
169
 
170
+ /* 统一台账(2026-11-25):服务生命周期/运行时错误追加到 profile 台账,best-effort
171
+ * 绝不反噬服务;listenOptions.ledgerFile 可覆盖(suite-kit 传自己解析的路径)。 */
172
+ const defaultLedgerFile = ledgerFileFor(process.env.DSH_PROFILE_DIR || null)
173
+ const record = (action, ok, extra = {}, file = defaultLedgerFile) => appendLedger({ source: 'service-host', name: id, version, phase: 'runtime', action, ok, ...extra }, { file })
174
+
169
175
  const app = {
170
176
  id,
171
177
  title,
@@ -361,13 +367,25 @@ export function createServiceApp(options = {}) {
361
367
  const webServer = listenOptions.webServer
362
368
  if (webServer && typeof webServer.register === 'function') {
363
369
  const prefix = basePath || `/plugins/${id}`
364
- embeddedDispose = webServer.register({
365
- kind: 'prefix',
366
- path: prefix,
367
- handler: (req, res) => app.dispatch(req, res, prefix),
368
- })
370
+ try {
371
+ embeddedDispose = webServer.register({
372
+ kind: 'prefix',
373
+ path: prefix,
374
+ handler: (req, res) => Promise.resolve(app.dispatch(req, res, prefix)).catch((error) => {
375
+ record('dispatch-error', false, { code: 'dispatch-error', message: String((error && error.message) || error), stackTop: (error && error.stack) || null, url: req.url }, listenOptions.ledgerFile)
376
+ try {
377
+ if (!res.headersSent) send(req, res, 500, { ok: false, error: String((error && error.message) || error) })
378
+ else res.destroy()
379
+ } catch { /* 连接已断开 */ }
380
+ }),
381
+ })
382
+ } catch (error) {
383
+ record('listen-error', false, { code: 'register-conflict', message: String((error && error.message) || error), stackTop: (error && error.stack) || null, mountPath: prefix }, listenOptions.ledgerFile)
384
+ throw error
385
+ }
369
386
  listeningPort = Number(webServer.port) || 0
370
387
  url = `http://127.0.0.1:${listeningPort}${prefix}`
388
+ record('listen', true, { mode: 'embedded', url, mountPath: prefix }, listenOptions.ledgerFile)
371
389
  return { url, port: listeningPort, reused: false, mode: 'embedded', stop: app.close }
372
390
  }
373
391
 
@@ -390,10 +408,12 @@ export function createServiceApp(options = {}) {
390
408
  if (existing && sameContract && sameVersion && sameWorkdir) {
391
409
  listeningPort = port
392
410
  url = `http://127.0.0.1:${port}${publicBasePath}`
411
+ record('listen', true, { mode: 'standalone', reused: true, url, port }, listenOptions.ledgerFile)
393
412
  return { url, port, reused: true, mode: 'standalone', stop: async () => {} }
394
413
  }
395
414
  if (existing && !(sameContract && sameVersion && sameWorkdir)) {
396
415
  const old = `pid ${existing.pid || '?'},version ${existing.version || '?'},contract ${existing.contractVersion || '?'},workdir ${existing.workdir || '?'}`
416
+ record('listen-error', false, { code: 'identity-conflict', message: `端口 ${port} 被不同身份实例占用(${old})`, mountPath: publicBasePath }, listenOptions.ledgerFile)
397
417
  throw new Error(
398
418
  `${id} 端口 ${port} 被不同身份的实例占用(${old};当前 ${version} / ${contractVersion} / ${workdir})。` +
399
419
  `为避免“新套件 + 旧进程”或“同版本 + 错数据目录”的假启动,已拒绝复用:请结束 ${existing.pid || '该'} 进程或重启 DSH 后再启动。`,
@@ -403,6 +423,7 @@ export function createServiceApp(options = {}) {
403
423
 
404
424
  const lock = await acquireLock(lockFile, { healthPath, id })
405
425
  if (!lock) {
426
+ record('listen-error', false, { code: 'lock-held', message: `已有另一个实例在运行: ${lockFile}` }, listenOptions.ledgerFile)
406
427
  throw new Error(`${id} 已有另一个实例在运行;如确认没有,请删除锁文件: ${lockFile}`)
407
428
  }
408
429
 
@@ -421,12 +442,14 @@ export function createServiceApp(options = {}) {
421
442
  lastError = error
422
443
  if (port === 0 || strictPort || attempt === scanLimit) {
423
444
  releaseLock(lock)
445
+ record('listen-error', false, { code: 'port-unavailable', message: `端口 ${tryPort} 不可用: ${(error && error.message) || error}` }, listenOptions.ledgerFile)
424
446
  throw new Error(`端口 ${tryPort} 不可用${strictPort ? '(strictPort)' : ''}: ${(error && error.message) || error}`)
425
447
  }
426
448
  }
427
449
  }
428
450
  if (!server) {
429
451
  releaseLock(lock)
452
+ record('listen-error', false, { code: 'port-unavailable', message: String((lastError && lastError.message) || lastError || '无法监听端口') }, listenOptions.ledgerFile)
430
453
  throw lastError || new Error('无法监听端口')
431
454
  }
432
455
 
@@ -436,6 +459,7 @@ export function createServiceApp(options = {}) {
436
459
  try { server.close() } catch { /* 忽略 */ }
437
460
  server = null
438
461
  releaseLock(lock)
462
+ record('listen-error', false, { code: 'write-lock-failed', message: String((error && error.message) || error), stackTop: (error && error.stack) || null }, listenOptions.ledgerFile)
439
463
  throw error
440
464
  }
441
465
  listeningPort = actualPort
@@ -443,6 +467,7 @@ export function createServiceApp(options = {}) {
443
467
 
444
468
  server.on('request', (req, res) => {
445
469
  Promise.resolve(app.dispatch(req, res, publicBasePath)).catch((error) => {
470
+ record('dispatch-error', false, { code: 'dispatch-error', message: String((error && error.message) || error), stackTop: (error && error.stack) || null, url: req.url })
446
471
  try {
447
472
  if (!res.headersSent) send(req, res, 500, { ok: false, error: String((error && error.message) || error) })
448
473
  else res.destroy()
@@ -464,12 +489,14 @@ export function createServiceApp(options = {}) {
464
489
 
465
490
  app._lock = lock
466
491
  app._discoveryFile = discoveryFile
492
+ record('listen', true, { mode: 'standalone', url, port: actualPort }, listenOptions.ledgerFile)
467
493
  return { url, port: actualPort, reused: false, mode: 'standalone', stop: app.close }
468
494
  },
469
495
 
470
496
  async close() {
471
497
  if (closed) return
472
498
  closed = true
499
+ record('closed', true, { phase: 'dispose', mode: embeddedDispose ? 'embedded' : 'standalone' })
473
500
  if (embeddedDispose) {
474
501
  try { embeddedDispose() } catch { /* 忽略 */ }
475
502
  embeddedDispose = null
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/suite-kit",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "DSH suite/domain 标准件(双重身份:构建期库 + 运行时库,暂不拆包,见 README「双重身份」)。构建期:manifest 校验、compose、profile 生成、domain 解析、artifact 打包;运行时:统一能力描述符、编排闸/授权、嵌入握手与 surface 挂载。",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
@@ -40,7 +40,7 @@
40
40
  "node": ">=18"
41
41
  },
42
42
  "dependencies": {
43
- "@capyclaw/plugin-kit": "^0.2.6"
43
+ "@capyclaw/plugin-kit": "^0.2.9"
44
44
  },
45
45
  "license": "MIT",
46
46
  "publishConfig": {
@@ -19,13 +19,15 @@
19
19
  * 钩子拿到的 push() 把 disposer 压入公共栈,释放顺序与手写时代一致。
20
20
  *
21
21
  * 依赖方向:运行时模块。内部仅 import ./capability.mjs;外部仅
22
- * @capyclaw/plugin-kit/service/api(纯契约断言,无副作用)。不 import 构建期模块。
22
+ * @capyclaw/plugin-kit/service/api(纯契约断言)与 /ledger(统一台账,best-effort)。
23
+ * 不 import 构建期模块。
23
24
  */
24
25
  import fs from 'node:fs'
25
26
  import os from 'node:os'
26
27
  import path from 'node:path'
27
28
  import { assertServiceApi } from '@capyclaw/plugin-kit/service/api'
28
29
  import { validateCapabilityDescriptor } from './capability.mjs'
30
+ import { appendLedger, ledgerFileFor } from '@capyclaw/plugin-kit/ledger'
29
31
 
30
32
  /**
31
33
  * 服务懒解析:cordis 未 inject 的服务直接访问 ctx[name] 可能抛错,
@@ -118,9 +120,19 @@ export function mountSuiteWorkbench(ctx, config = {}, spec) {
118
120
  const mountPath = config.mountPath || spec.mountPath
119
121
  const disposers = []
120
122
  const push = (d) => { if (typeof d === 'function') disposers.push(d) }
123
+ /* 统一台账(2026-11-25):挂载/退让/降级/失败/释放状态追加到 profile 台账,
124
+ * best-effort 绝不反噬挂载;凡走 mountSuiteWorkbench 的套件统一覆盖。 */
125
+ const ledgerFile = ledgerFileFor(safeGet(ctx, 'profileContext')?.dir || process.env.DSH_PROFILE_DIR || null)
126
+ const record = (action, ok, extra = {}) => appendLedger({ source: 'suite-kit', name: ns, suite, version: config.version || null, phase: 'activate', action, ok, mountPath, ...extra }, { file: ledgerFile })
121
127
  // splice(0) 清空栈再逆序:首次释放顺序与手写时代一致,重复释放是真 no-op
122
128
  // (原 disposers.reverse() 原地反转,二次调用会重跑——与「忽略重复释放」注释意图相悖)。
123
- const releaseAll = () => { for (const d of disposers.splice(0).reverse()) { try { d() } catch { /* 忽略重复释放 */ } } }
129
+ let released = false
130
+ const releaseAll = () => {
131
+ if (released) return
132
+ released = true
133
+ record('disposed', true, { phase: 'dispose' })
134
+ for (const d of disposers.splice(0).reverse()) { try { d() } catch { /* 忽略重复释放 */ } }
135
+ }
124
136
  const noop = () => {}
125
137
 
126
138
  try {
@@ -133,6 +145,7 @@ export function mountSuiteWorkbench(ctx, config = {}, spec) {
133
145
  if (!toolHost || !serviceHost) {
134
146
  diag(`${tag} BAIL: missing toolHost/serviceHost`)
135
147
  log.warn(`缺少 toolHost/serviceHost 公共服务,${suite}-suite 未激活(请安装对应基础套件)`)
148
+ record('bail-missing-services', false, { code: 'missing-services', message: '缺少 toolHost/serviceHost 公共服务' })
136
149
  return noop
137
150
  }
138
151
  assertServiceApi(toolHost, { name: 'toolHost', major: 1 })
@@ -143,7 +156,10 @@ export function mountSuiteWorkbench(ctx, config = {}, spec) {
143
156
  let extra = {}
144
157
  if (spec.prepare) {
145
158
  const prepared = spec.prepare(api)
146
- if (prepared === false || (prepared && prepared.bail === true)) return noop
159
+ if (prepared === false || (prepared && prepared.bail === true)) {
160
+ record('bail-prepare', false, { code: 'prepare-bail' })
161
+ return noop
162
+ }
147
163
  if (prepared && typeof prepared === 'object') extra = prepared
148
164
  }
149
165
 
@@ -167,6 +183,7 @@ export function mountSuiteWorkbench(ctx, config = {}, spec) {
167
183
  if (taken) {
168
184
  diag(`${tag} BAIL: prefix ${mountPath} already registered`)
169
185
  log.warn(`${ns}: 路由前缀 ${mountPath} 已被占用,本条目不挂载(不影响其它插件)`)
186
+ record('bail-prefix-taken', false, { code: 'prefix-taken', message: `路由前缀 ${mountPath} 已被占用` })
170
187
  return noop
171
188
  }
172
189
  }
@@ -178,6 +195,7 @@ export function mountSuiteWorkbench(ctx, config = {}, spec) {
178
195
  listening.catch((err) => {
179
196
  diag(`${tag} listen rejected: ${err?.stack || err}`)
180
197
  log.warn(`${ns}: 挂载 ${mountPath} 失败,本条目不生效:`, err?.message || err)
198
+ record('listen-rejected', false, { code: 'listen-rejected', message: String(err?.message || err), stackTop: err?.stack || null })
181
199
  try { workbench.app.close() } catch { /* 忽略 */ }
182
200
  })
183
201
  }
@@ -200,6 +218,7 @@ export function mountSuiteWorkbench(ctx, config = {}, spec) {
200
218
  push(() => { for (const d of descriptors) toolHost.unregisterCapabilityDescriptor?.(d.name) })
201
219
  } else {
202
220
  log.warn(`toolHost 无描述符面(需 >=0.2.0):跳过能力注册,conductor 将无法发现 ${suite}`)
221
+ record('degraded-no-descriptors', true, { degraded: true, code: 'no-descriptor-face', message: 'toolHost 无描述符面,跳过能力注册' })
203
222
  }
204
223
 
205
224
  // 自检端点。
@@ -221,10 +240,12 @@ export function mountSuiteWorkbench(ctx, config = {}, spec) {
221
240
 
222
241
  log.info(`${ns} 已挂载 ${mountPath} → ${workbench.app.url}`)
223
242
  diag(`${tag} MOUNTED ${mountPath} → ${workbench.app.url}`)
243
+ record('mounted', true, { url: workbench.app.url })
224
244
  return releaseAll
225
245
  } catch (err) {
226
246
  diag(`${tag} ERROR: ${err?.stack || err}`)
227
247
  log.warn(`${ns} 激活失败:`, err?.stack || err)
248
+ record('activate-error', false, { code: 'activate-error', message: String(err?.message || err), stackTop: err?.stack || null })
228
249
  return releaseAll
229
250
  }
230
251
  }
@@ -7,7 +7,7 @@
7
7
  "packages": {
8
8
  "@capyclaw/tool-host": {
9
9
  "role": "provider",
10
- "version": "^0.3.2",
10
+ "version": "^0.3.3",
11
11
  "path": ".",
12
12
  "provides": {
13
13
  "services": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/tool-host",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "DSH 公共工具面插件:能力 DSL、工具注册表、参数校验、契约报告、MCP 协议壳与 instructions 模板,向插件提供 ctx.toolHost。",
5
5
  "type": "module",
6
6
  "main": "./lib/host.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capyclaw/capyclaw-workbench",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "CapyClaw 子会话工作台运行时:7 个 capyclaw_* 工具(创建/驱动/查询/关闭 DSH 子会话 + 读写设置)+ 俄罗斯套娃控制台(同源嵌入 DSH GUI)。挂在 dsh 的 /capyclaw/capyclaw。",
5
5
  "type": "module",
6
6
  "main": "./plugin.mjs",