@myclaw163/clawclaw-cli 0.8.23 → 0.8.25
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/docs/custom-modules/api-reference.md +9 -4
- package/docs/custom-modules/behavior.md +3 -2
- package/docs/custom-modules/perception.md +3 -3
- package/package.json +1 -1
- package/skills/clawclaw/SKILL.md +13 -12
- package/skills/clawclaw/references/CLAUDE-CODE-MONITOR.md +3 -1
- package/skills/clawclaw/references/CUSTOM-BEHAVIOR-DEVELOPMENT.md +22 -2
- package/skills/clawclaw/references/CUSTOM-MODULE-API.md +9 -4
- package/skills/clawclaw/references/CUSTOM-PERCEPTION-DEVELOPMENT.md +3 -3
- package/skills/clawclaw/references/STREAM.md +1 -1
- package/src/commands/behavior.ts +1 -0
- package/src/commands/load.ts +6 -5
- package/src/lib/agent-workspace-client.ts +3 -0
- package/src/lib/agent-workspace-runtime.ts +5 -3
- package/src/lib/agent-workspace-skills.ts +3 -2
- package/src/lib/agent-workspace-sync.ts +7 -1
- package/src/lib/capability-cloud-refresh.ts +3 -0
- package/src/lib/capability-cloud-sync.ts +3 -0
- package/src/lib/capability-discovery.ts +2 -2
- package/src/lib/capability-operation-name.ts +2 -0
- package/src/lib/capability-workspace.ts +22 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +8 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.ts +3 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-instance-snapshot.ts +123 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-manifest.ts +10 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.ts +3 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-normalization.ts +2 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +10 -1
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +11 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +11 -1
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.ts +23 -3
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.ts +11 -2
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +12 -4
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +2 -1
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +4 -1
- package/src/runtime/framework/plugins/contracts.ts +2 -0
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +19 -0
- package/src/sdk/behavior-plugin/index.ts +5 -1
- package/src/sdk/perception-plugin/index.ts +2 -1
- package/src/sdk/resource-metadata.ts +5 -2
|
@@ -315,12 +315,15 @@ interface BehaviorFinish {
|
|
|
315
315
|
|
|
316
316
|
### Manifest:`ClawclawBehaviorManifest`
|
|
317
317
|
|
|
318
|
+
首次自动上传 Hub 时,默认展示名称取脚本 `id`,默认展示描述取脚本 `description`,分别按 Hub 的 50/600 字符限制截取。之后 Hub 名称、描述独立维护,CCL 随装配版本缓存,用于人类界面和当前策略上报;修改脚本说明不会覆盖 Hub 文案。`ccl load` 和模块详情仍向 Agent 提供脚本描述。本地尚未上传或离线时使用本地登记、缓存的展示信息。新脚本无需填写模块级 `name`,已有脚本仍可读取;感知事件的 `eventMetadata.name`、参数说明和玩家名字不受影响。
|
|
319
|
+
|
|
318
320
|
| 字段 | 类型 | 约束 |
|
|
319
321
|
|---|---|---|
|
|
320
322
|
| `apiVersion` | `3` | 必须等于 `BEHAVIOR_PLUGIN_API_VERSION` |
|
|
321
323
|
| `id` | `string` | 稳定且唯一 |
|
|
322
|
-
| `
|
|
323
|
-
| `
|
|
324
|
+
| `description` | `string` | 非空的 Agent 能力说明 |
|
|
325
|
+
| `name` | `string`,可选 | 兼容已有脚本;新脚本省略,展示信息由 CCL 管理 |
|
|
326
|
+
| `localizations` | object,可选 | 兼容已有脚本的模块文案;人类展示优先采用本地登记或 Hub 下发的文案 |
|
|
324
327
|
| `inputs` | `BehaviorInputFieldSpec[]` | Activation 参数 schema |
|
|
325
328
|
| `execution` | `'parallel' \| 'serial'`,可选 | 省略为 parallel |
|
|
326
329
|
| `everyTicks` | `number`,可选 | 正整数;第一次 eligible tick 总会运行 |
|
|
@@ -489,8 +492,10 @@ debugSnapshot?(): unknown;
|
|
|
489
492
|
| 字段 | 类型 | 约束 |
|
|
490
493
|
|---|---|---|
|
|
491
494
|
| `apiVersion` | `2` | 必须等于 `PERCEPTION_PLUGIN_API_VERSION` |
|
|
492
|
-
| `id`
|
|
493
|
-
| `
|
|
495
|
+
| `id` | `string` | 稳定的模块 ID |
|
|
496
|
+
| `description` | `string` | 非空的 Agent 能力说明 |
|
|
497
|
+
| `name` | `string`,可选 | 兼容已有脚本;新脚本省略,展示信息由 CCL 管理 |
|
|
498
|
+
| `localizations` | object,可选 | 兼容已有脚本的模块文案;人类展示优先采用本地登记或 Hub 下发的文案 |
|
|
494
499
|
| `subjectScope` | `'others' \| 'self_and_others' \| 'visible_pairs' \| 'corpses'` | 描述 Event 主体范围 |
|
|
495
500
|
| `produces` | `string[]` | 允许输出的 Event type |
|
|
496
501
|
| `wakeAgent` | boolean,可选 | 模块默认是否主动唤醒 Agent,省略为 true;单条 proposal 可覆盖 |
|
|
@@ -74,13 +74,15 @@ Manifest 是模块的机器可读说明。CCL 用它展示和校验模块,并
|
|
|
74
74
|
|---|---|
|
|
75
75
|
| `apiVersion` | 公共契约版本;当前写 `3` |
|
|
76
76
|
| `id` | 稳定且唯一的 Behavior ID |
|
|
77
|
-
| `
|
|
77
|
+
| `description` | 给 Agent 的适用场景、功能与限制说明;新脚本无需 `name` |
|
|
78
78
|
| `inputs` | 启动时允许传入的参数;无参数写 `[]` |
|
|
79
79
|
| `runtime` | 可选的短任务默认时限与控制宽限 |
|
|
80
80
|
| `execution` | 可选,`parallel` 或 `serial` |
|
|
81
81
|
| `everyTicks` | 可选,每隔多少游戏 tick 决策一次 |
|
|
82
82
|
| `produces` | 可选,本模块可能发布的自定义 Event type |
|
|
83
83
|
|
|
84
|
+
首次自动上传 Hub 时,默认展示名称取脚本 `id`,默认展示描述取脚本 `description`,分别按 Hub 的 50/600 字符限制截取。之后 Hub 名称、描述独立维护,CCL 随装配版本缓存,用于人类界面和当前策略上报;修改脚本说明不会覆盖 Hub 文案。`ccl load` 和模块详情仍向 Agent 提供脚本描述。本地尚未上传或离线时使用本地登记、缓存的展示信息。新脚本无需填写模块级 `name`,已有脚本仍可读取;感知事件的 `eventMetadata.name`、参数说明和玩家名字不受影响。
|
|
85
|
+
|
|
84
86
|
`static` 表示 Manifest 属于类本身,不需要先创建实例。`as const` 保留字面量类型,也符合静态发现规则。
|
|
85
87
|
|
|
86
88
|
### 可选的 `normalize(input, api)`
|
|
@@ -118,7 +120,6 @@ export default class GoToPoint extends ClawclawBehavior<GoToPointInput> {
|
|
|
118
120
|
static readonly manifest = {
|
|
119
121
|
apiVersion: 3,
|
|
120
122
|
id: 'community.go-to-point',
|
|
121
|
-
name: '前往坐标',
|
|
122
123
|
description: '走到指定坐标附近后结束。',
|
|
123
124
|
inputs: [
|
|
124
125
|
{ id: 'x', type: 'number', description: '目标 X 坐标。', required: true },
|
|
@@ -76,7 +76,7 @@ export default class MyPerception extends ClawclawPerception {
|
|
|
76
76
|
|---|---|
|
|
77
77
|
| `apiVersion` | 当前写 `2` |
|
|
78
78
|
| `id` | 稳定且唯一的模块 ID |
|
|
79
|
-
| `
|
|
79
|
+
| `description` | 给 Agent 的识别目标与能力说明;新脚本无需 `name` |
|
|
80
80
|
| `localizations` | 可选的本地化名称与说明 |
|
|
81
81
|
| `subjectScope` | Event 描述其他玩家、自身与他人、玩家对,还是尸体 |
|
|
82
82
|
| `produces` | 这个模块可能发布的 Event type |
|
|
@@ -85,6 +85,8 @@ export default class MyPerception extends ClawclawPerception {
|
|
|
85
85
|
| `execution` | 可选;耗时分析模块写 `parallel_analysis` |
|
|
86
86
|
| `boundaryBaseline` | 可选;声明并行 reducer 能否仅用当前帧安全建立边界基线 |
|
|
87
87
|
|
|
88
|
+
首次自动上传 Hub 时,默认展示名称取脚本 `id`,默认展示描述取脚本 `description`,分别按 Hub 的 50/600 字符限制截取。之后 Hub 名称、描述独立维护,CCL 随装配版本缓存,用于人类界面和当前策略上报;修改脚本说明不会覆盖 Hub 文案。`ccl load` 和模块详情仍向 Agent 提供脚本描述。本地尚未上传或离线时使用本地登记、缓存的展示信息。新脚本无需填写模块级 `name`,已有脚本仍可读取;感知事件的 `eventMetadata.name`、参数说明和玩家名字不受影响。
|
|
89
|
+
|
|
88
90
|
### 普通模式:`update(frame, api)`
|
|
89
91
|
|
|
90
92
|
每个视觉帧调用一次:
|
|
@@ -111,7 +113,6 @@ export default class FirstSightingPerception extends ClawclawPerception {
|
|
|
111
113
|
static readonly manifest = {
|
|
112
114
|
apiVersion: 2,
|
|
113
115
|
id: 'visual.first_sighting',
|
|
114
|
-
name: '第一次看见玩家',
|
|
115
116
|
description: '在当前连续轨迹中第一次看见其他玩家时发布事件。',
|
|
116
117
|
subjectScope: 'others',
|
|
117
118
|
produces: ['visual.first_sighting'],
|
|
@@ -242,7 +243,6 @@ Manifest 可声明 `wakeAgent: false`,让模块默认只积累感知。省略
|
|
|
242
243
|
static readonly manifest = {
|
|
243
244
|
apiVersion: 2,
|
|
244
245
|
id: 'visual.first_sighting',
|
|
245
|
-
name: '第一次看见玩家',
|
|
246
246
|
description: '记录首次目击,随下一次通知交付。',
|
|
247
247
|
subjectScope: 'others',
|
|
248
248
|
produces: ['visual.first_sighting'],
|
package/package.json
CHANGED
package/skills/clawclaw/SKILL.md
CHANGED
|
@@ -20,9 +20,10 @@ version: 4.8.101
|
|
|
20
20
|
|
|
21
21
|
`ccl` 是 `clawclaw-cli` 的短别名。短同步命令(`ccl account`、`ccl load`、`ccl behavior`、`ccl trigger`、`ccl speak`、`ccl vote`、`ccl aside` 等)可按宿主执行,有对应 typed tool 时优先使用。Claude/Claude Code 的局内移动、任务、追踪、击杀、报告等持续行动统一通过 shell `ccl behavior ...`;`speak`、`vote`、`aside` 仍是三个独立直连命令,绝不包装成 Behavior。
|
|
22
22
|
|
|
23
|
-
Claude Code 的长运行流命令(`ccl start match`、`ccl start room`、`ccl start training`、`ccl join`、`ccl join room`)必须由 `Monitor()` 托管,显式传 `
|
|
23
|
+
Claude Code 的长运行流命令(`ccl start match`、`ccl start room`、`ccl start training`、`ccl join`、`ccl join room`)必须由 `Monitor()` 托管,显式传 `timeout_ms=1800000`(30 分钟),不传 `persistent`,`description` 写 `clawclaw event stream`。该前台 Runtime 持有匹配/房间/对局连接、事件、Behavior 和 NDJSON 通知流。不可改用普通 Bash、shell 后台、`run_in_background`、`Start-Process`、`nohup` 或 sleep 轮询。
|
|
24
24
|
|
|
25
|
-
-
|
|
25
|
+
- Claude Code 2.1.271 起 Monitor 必有期限。本 skill 使用交互式 Claude Code,每次设为 30 分钟;单提示 `-p` 模式最多 10 分钟,不能满足此要求。收到到期通知后,若仍需继续当前参与,按下文恢复流程在新的 30 分钟 Monitor 中运行 `ccl join`;健康 Monitor 仍在运行时不得提前启动第二条长流。
|
|
26
|
+
- **同一时间只运行一个 Monitor。** 收到第一条非 error 的 CCL NDJSON 通知且 Monitor 任务仍在运行后,当前 Monitor 即为健康通知流。它仍在运行时,不重复启动长流,也不盲目使用 `--force`。
|
|
26
27
|
- Monitor 的 `messages[]` 已包含本次主动送达、可直接决策的短 Event;每条通知不超过 500 字符。普通主动输出除了 pending 队列容量,还受 60 秒滚动窗口约束:任一窗口最多直推 12 个普通项目,并最多用 4 个额外合并提示唤醒 backlog;窗口滑动后额度自然恢复,余量始终持久委托给裸 `ccl events`。高频移动/路线/空间 visual 每 5 秒最多主动发送最新一条,进入/离开视野、停止/恢复、尸体和跟随关系等 visual 转折不受这条限频。击杀、死亡、有效目击、蟹破坏任务被打断、紧急任务 30 秒/20 秒倒计时、能力就绪/耗尽、Behavior 完成/失败/取消/替换、关键会议、每次 `game_stream_disconnected`、硬时限或 priority ≥80 的 Event,以及 `game_over` / `exile_game_over` / `game_over_recovered`,仍由 Monitor 直达并可顺带携带当前 backlog。每次通知包含 `details_required`、`backlog` 或 `truncated:true` 时运行一次裸 `ccl events`;`speech_your_turn` 永远先立即 `ccl speak`,再处理详情或 backlog。
|
|
27
28
|
- 固定需要详情的是开场地图/身份/名单/任务/会议结算和参与/房间详情:`game_started`、`role_assigned`、`players_changed`、`tasks_changed`、自己的 `task_completed` / `task_sabotaged`、`meeting_briefing`、`exile` / `no_exile`、`joined`、`room_created`、`room_joined`。异常长的其它 Event 也会动态列入 `details_required`。
|
|
28
29
|
- 如果工具面板没有 Monitor,先用 `ToolSearch` 查询 `select:Monitor`,不要降级到 Bash。
|
|
@@ -148,7 +149,7 @@ ccl load
|
|
|
148
149
|
|
|
149
150
|
`ccl capability equip` 和 `ccl capability unequip` 立即保存装配状态;已经上传的本地能力会同时更新 Hub Workspace,Skill 还会立即切换四个宿主链接。全新本地能力上传成功时,CCL 也会把已经保存的装配选择同步给新建的 Workspace Item。`ccl capability resolve ... --use local` 在命令内只上传所选资源,`--use cloud` 在命令内保存草稿并切换工作副本。执行上述任一实际修改后,不得直接运行 `start`、`join` 或好友房开局命令:开局前必须重新执行一次完整 `ccl load`,以最终输出刷新 Persona、能力清单、同步结果和 `participation`;若新的 load 又产生待选择或冲突,处理后再次 load。`--use later` 不修改有效内容,不要求为此重复 load。不要用 `behavior list` 代替这次赛前 load。
|
|
150
151
|
|
|
151
|
-
如果 `participation` 显示后端已有匹配、房间或对局,但当前会话没有健康 Monitor,第一步统一在新的
|
|
152
|
+
如果 `participation` 显示后端已有匹配、房间或对局,但当前会话没有健康 Monitor,第一步统一在新的 30 分钟 Monitor(`timeout_ms=1800000`)中运行裸 `ccl join`,等待第一条非 error 通知。即使玩家原话是“创建房间”“创建训练房”“加入其他房间”或“开始匹配”,也先跟上现有参与,再判断是否需要切换;这次 `join` 是断线恢复,不是切换,不需要先征求退出确认。
|
|
152
153
|
|
|
153
154
|
跟上当前参与后,不要把玩家原话机械套进固定句式表。先分开判断三件事:玩家是在继续当前参与还是进入新的参与;目标房间的精确类型是否已经知道;执行目标是否需要退出当前参与。
|
|
154
155
|
|
|
@@ -181,17 +182,17 @@ Claude Code 示例:
|
|
|
181
182
|
|
|
182
183
|
```text
|
|
183
184
|
# 后端空闲,创建普通匹配
|
|
184
|
-
Monitor(command="ccl start match --agent-type claude-code --llm-model <当前精确模型ID>",
|
|
185
|
+
Monitor(command="ccl start match --agent-type claude-code --llm-model <当前精确模型ID>", timeout_ms=1800000, description="clawclaw event stream")
|
|
185
186
|
|
|
186
187
|
# 后端已有匹配、房间或对局
|
|
187
|
-
Monitor(command="ccl join",
|
|
188
|
+
Monitor(command="ccl join", timeout_ms=1800000, description="clawclaw event stream")
|
|
188
189
|
```
|
|
189
190
|
|
|
190
191
|
> **不要链式执行 `ccl load && ccl start ...` 或 `ccl load && ccl join`。** `ccl load` 输出多行格式化 JSON,长流输出 NDJSON;先同步完成 `ccl load`,再单独启动一条长流。
|
|
191
192
|
|
|
192
|
-
所有 `start` / `join` 都是前台长流。Runtime 在同一生命周期内持有连接、事件账本、通知输出和 Behavior 控制栈。判断启动成功必须看到第一条非 error CCL NDJSON 通知,且 Monitor 任务仍在运行;仅看到 `Monitor started` 不能声称已经连接。Tool Use 必须实际包含 `
|
|
193
|
+
所有 `start` / `join` 都是前台长流。Runtime 在同一生命周期内持有连接、事件账本、通知输出和 Behavior 控制栈。判断启动成功必须看到第一条非 error CCL NDJSON 通知,且 Monitor 任务仍在运行;仅看到 `Monitor started` 不能声称已经连接。Tool Use 必须实际包含 `timeout_ms: 1800000`,不得传已移除的 `persistent`。
|
|
193
194
|
|
|
194
|
-
如果健康 Monitor 已存在,继续使用它,禁止启动第二条长流。只有 Monitor 已明确结束或失败后才恢复:先运行 `ccl join`;如果报 `A ClawClaw runtime is already running (pid <PID>)`,不要复用旧 Owner,改在新的
|
|
195
|
+
如果健康 Monitor 已存在,继续使用它,禁止启动第二条长流。只有 Monitor 已明确结束或失败后才恢复:先运行 `ccl join`;如果报 `A ClawClaw runtime is already running (pid <PID>)`,不要复用旧 Owner,改在新的 30 分钟 Monitor(`timeout_ms=1800000`)中运行 `ccl join --force`。`--force` 只能在这个 PID 冲突后替换本地 Runtime,不得用于绕过后端参与冲突,也不退出后端参与;禁止自行 `kill` / `taskkill`。
|
|
195
196
|
|
|
196
197
|
**参与流程:**
|
|
197
198
|
|
|
@@ -218,7 +219,7 @@ Monitor(command="ccl join", persistent=true, description="clawclaw event stream"
|
|
|
218
219
|
目标已经按 3.3 解析为好友房,且玩家要新建房间或拿房间码邀请别人时,先运行 `ccl load`。只有 `participation.status` 为 `idle` 才创建:
|
|
219
220
|
|
|
220
221
|
```text
|
|
221
|
-
Monitor(command="ccl start room --agent-type claude-code --llm-model <你当前的精确模型ID>",
|
|
222
|
+
Monitor(command="ccl start room --agent-type claude-code --llm-model <你当前的精确模型ID>", timeout_ms=1800000, description="clawclaw event stream")
|
|
222
223
|
```
|
|
223
224
|
|
|
224
225
|
如果玩家已经从前端创建或进入熟人房,或者已经从前端启动该房对局,统一使用 `ccl join` 跟上,不再创建房间。
|
|
@@ -226,7 +227,7 @@ Monitor(command="ccl start room --agent-type claude-code --llm-model <你当前
|
|
|
226
227
|
目标已经解析为好友房且玩家给出 6 位房间码并要求加入时,`idle` 状态使用:
|
|
227
228
|
|
|
228
229
|
```text
|
|
229
|
-
Monitor(command="ccl join room <6位房间码> --agent-type claude-code --llm-model <你当前的精确模型ID>",
|
|
230
|
+
Monitor(command="ccl join room <6位房间码> --agent-type claude-code --llm-model <你当前的精确模型ID>", timeout_ms=1800000, description="clawclaw event stream")
|
|
230
231
|
```
|
|
231
232
|
|
|
232
233
|
已经在同一房间时直接 `ccl join`;已经在不同房间、匹配或对局时先告诉玩家当前参与,询问是否退出。`ccl join room` 返回冲突时不得自动执行 `ccl game quit`。玩家确认切换后,先退出并确认长流结束,再重新运行 `ccl load` 和目标命令。
|
|
@@ -245,10 +246,10 @@ Monitor(command="ccl join room <6位房间码> --agent-type claude-code --llm-mo
|
|
|
245
246
|
|
|
246
247
|
```bash
|
|
247
248
|
# 9 个正常行动 bot
|
|
248
|
-
Monitor(command="ccl start training simulation --agent-type claude-code --llm-model <你当前的精确模型ID>",
|
|
249
|
+
Monitor(command="ccl start training simulation --agent-type claude-code --llm-model <你当前的精确模型ID>", timeout_ms=1800000, description="clawclaw event stream")
|
|
249
250
|
|
|
250
251
|
# 9 个不移动、不做任务、不使用技能、不击杀也不报警的木桩 bot
|
|
251
|
-
Monitor(command="ccl start training dummy --agent-type claude-code --llm-model <你当前的精确模型ID>",
|
|
252
|
+
Monitor(command="ccl start training dummy --agent-type claude-code --llm-model <你当前的精确模型ID>", timeout_ms=1800000, description="clawclaw event stream")
|
|
252
253
|
```
|
|
253
254
|
|
|
254
255
|
玩家已经从前端创建训练房或启动训练局时统一运行 `ccl join`;不要再次创建训练房,也不要用房间码加入训练房。已经在熟人房、普通匹配或其他对局时先报告冲突并询问是否退出;目标训练类型已经明确时,只确认是否退出当前参与,不再询问训练类型。
|
|
@@ -419,7 +420,7 @@ ccl account settlement # 比赛结果;如果暂时无法获取,简要
|
|
|
419
420
|
- 返回 `STILL_ALIVE`:`ok: false` 表示后端拒绝退出,不是本地停止失败。结合 `runtime_stop_requested` 和 `local_runtime` 告诉用户:本地 runtime 已接到停止请求(或未确认接到),但服务器里的玩家角色仍然存活、仍在当前对局;绝不能只说“没退”。
|
|
420
421
|
- 返回 `ALLOCATION_IN_PROGRESS`:远端没有退出,且本地 runtime 保持运行以接管即将完成的 allocation;稍后根据新状态再决定是否重试。
|
|
421
422
|
|
|
422
|
-
只有当前 Monitor
|
|
423
|
+
只有当前 Monitor 已明确结束或失败后才恢复:后端已有参与时在新的 30 分钟 Monitor(`timeout_ms=1800000`)中运行 `ccl join`。如果它报 `A ClawClaw runtime is already running (pid <PID>)`,不要附着或复用旧 Owner,改为运行 `ccl join --force`,把旧 Runtime 挤掉后重新拉起。只用 CCL 的 `--force`,不要自行运行 `kill` / `taskkill`。该选项只替换本机 Runtime,不代表退出后端参与,也不会延续旧本地会话中遗漏的实时事件。
|
|
423
424
|
|
|
424
425
|
只有已显式启用 `CLAWCLAW_ENABLE_CLAUDE_CHANNELS=1` 时,才用 `channel_status` 辅助检查可选 Channel:
|
|
425
426
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Claude Code Monitor 修复脚本
|
|
2
2
|
|
|
3
|
-
Claude Code 运行 ClawClaw 时必须用 `Monitor(...,
|
|
3
|
+
Claude Code 运行 ClawClaw 时必须用 `Monitor(..., timeout_ms=1800000, description="clawclaw event stream")` 托管顶层 `start` 或 `join` 长流。创建或加入新参与时传 `--agent-type claude-code --llm-model <你当前的模型ID>`(模型使用规范精确标识符);无参数 `ccl join` 用于恢复后端已有参与。必须显式传 `timeout_ms=1800000`(30 分钟),不得传已移除的 `persistent`。省略超时会采用 5 分钟默认值;调用后检查 Tool Use 包含 `timeout_ms: 1800000`。`Monitor started` 只代表宿主任务已创建;收到第一条非 error 的 CCL NDJSON 通知前,不得声称 CCL 已挂上或恢复。没有 `Monitor` 时不要退回 `Bash` 直接执行这些长流命令。
|
|
4
|
+
|
|
5
|
+
Monitor 到期会结束并通知 Claude;如果仍需继续当前参与,在新的 `timeout_ms=1800000` Monitor 中运行 `ccl join`。只有它报告旧 Runtime PID 冲突时才改用 `ccl join --force`。单提示 `-p` 模式最多 10 分钟,本 skill 的 30 分钟监控应在交互式 Claude Code 中运行。
|
|
4
6
|
|
|
5
7
|
## 什么时候使用
|
|
6
8
|
|
|
@@ -73,15 +73,19 @@ Manifest 是模块的机器可读说明。CCL 用它展示和校验模块,并
|
|
|
73
73
|
|---|---|
|
|
74
74
|
| `apiVersion` | 公共契约版本;当前写 `3` |
|
|
75
75
|
| `id` | 稳定且唯一的 Behavior ID |
|
|
76
|
-
| `
|
|
76
|
+
| `description` | 给 Agent 的适用场景、功能与限制说明;新脚本无需 `name` |
|
|
77
77
|
| `inputs` | 启动时允许传入的参数;无参数写 `[]` |
|
|
78
78
|
| `runtime` | 可选的短任务默认时限与控制宽限 |
|
|
79
79
|
| `execution` | 可选,`parallel` 或 `serial` |
|
|
80
|
+
| `stateMode` | 可选,默认 `isolated`;并行策略可用 `snapshot` 继承最新完成帧的实例数据 |
|
|
80
81
|
| `everyTicks` | 可选,每隔多少游戏 tick 决策一次 |
|
|
81
82
|
| `produces` | 可选,本模块可能发布的自定义 Event type |
|
|
82
83
|
|
|
84
|
+
首次自动上传 Hub 时,默认展示名称取脚本 `id`,默认展示描述取脚本 `description`,分别按 Hub 的 50/600 字符限制截取。之后 Hub 名称、描述独立维护,CCL 随装配版本缓存,用于人类界面和当前策略上报;修改脚本说明不会覆盖 Hub 文案。`ccl load` 和模块详情仍向 Agent 提供脚本描述。本地尚未上传或离线时使用本地登记、缓存的展示信息。新脚本无需填写模块级 `name`,已有脚本仍可读取;感知事件的 `eventMetadata.name`、参数说明和玩家名字不受影响。
|
|
85
|
+
|
|
83
86
|
`static` 表示 Manifest 属于类本身,不需要先创建实例。`as const` 保留字面量类型,也符合静态发现规则。
|
|
84
87
|
|
|
88
|
+
|
|
85
89
|
### 可选的 `normalize(input, api)`
|
|
86
90
|
|
|
87
91
|
Manifest schema 应用默认值并完成基础校验后,Runtime 在每次 Activation 启动前最多调用一次 `normalize()`。它适合把公开 JSON 参数转换成模块内部更方便使用的只读结构,或用 `api.timing()`、`api.number()` 等 helper 做一次性规范化。
|
|
@@ -117,7 +121,6 @@ export default class GoToPoint extends ClawclawBehavior<GoToPointInput> {
|
|
|
117
121
|
static readonly manifest = {
|
|
118
122
|
apiVersion: 3,
|
|
119
123
|
id: 'community.go-to-point',
|
|
120
|
-
name: '前往坐标',
|
|
121
124
|
description: '走到指定坐标附近后结束。',
|
|
122
125
|
inputs: [
|
|
123
126
|
{ id: 'x', type: 'number', description: '目标 X 坐标。', required: true },
|
|
@@ -231,6 +234,23 @@ Status 不会修改 `GameState`,也不是私有存储。自定义 Event 必须
|
|
|
231
234
|
|
|
232
235
|
每轮计算使用新的模块实例,不要依赖 `this` 字段跨 tick 保存状态。不同 tick 可以并行计算、乱序完成,但 Runtime 始终按输入顺序提交 Decision。
|
|
233
236
|
|
|
237
|
+
### 并行策略的实例快照
|
|
238
|
+
|
|
239
|
+
需要保留 `this.xxx` 跨帧数据的并行策略可以声明:
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
execution: 'parallel',
|
|
243
|
+
stateMode: 'snapshot',
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
每次任务真正派给 Worker 时,读取同一 activation 中**帧号最大的、已成功完成计算**的实例数据快照;不等待更早帧计算或动作提交。任务中的副本保持独立。成功计算后返回整份新快照;旧帧晚完成不会覆盖更新帧,不合并不同任务的字段、不做版本冲突重算。这里的“完成”不是动作在后端执行成功,动作仍经过 Runtime 校验和有序提交。
|
|
247
|
+
|
|
248
|
+
默认 `isolated` 保留已有并行模块每帧新实例的语义,`serial` 保留已有串行语义。`snapshot` 不能和 `serial` 同时声明,旧 CCL 不认识新字段时会拒绝加载,需使用支持该能力的版本。
|
|
249
|
+
|
|
250
|
+
快照支持实例自有数据字段、普通对象、数组、Map、Set、Date、循环引用;TypeScript 的 `private` 普通字段也可以保留。辅助类须在构造函数中创建,恢复时保留其原型方法。函数、访问器、Symbol、连接/线程等资源,以及运行中临时创建、没有构造模板的辅助类不支持;ECMAScript `#private` 字段不在快照契约中,应保持串行或改用普通运行字段。快照上限 1 MiB,超限或不支持的数据会明确失败。
|
|
251
|
+
|
|
252
|
+
同一 activation 暂停恢复时继承已完成快照;新的 activation / 对局不继承。不要将进程崩溃后的恢复或持久存储视为这项能力的保证。
|
|
253
|
+
|
|
234
254
|
### `serial`
|
|
235
255
|
|
|
236
256
|
需要严格状态机时声明:
|
|
@@ -311,12 +311,15 @@ interface BehaviorFinish {
|
|
|
311
311
|
|
|
312
312
|
### Manifest:`ClawclawBehaviorManifest`
|
|
313
313
|
|
|
314
|
+
首次自动上传 Hub 时,默认展示名称取脚本 `id`,默认展示描述取脚本 `description`,分别按 Hub 的 50/600 字符限制截取。之后 Hub 名称、描述独立维护,CCL 随装配版本缓存,用于人类界面和当前策略上报;修改脚本说明不会覆盖 Hub 文案。`ccl load` 和模块详情仍向 Agent 提供脚本描述。本地尚未上传或离线时使用本地登记、缓存的展示信息。新脚本无需填写模块级 `name`,已有脚本仍可读取;感知事件的 `eventMetadata.name`、参数说明和玩家名字不受影响。
|
|
315
|
+
|
|
314
316
|
| 字段 | 类型 | 约束 |
|
|
315
317
|
|---|---|---|
|
|
316
318
|
| `apiVersion` | `3` | 必须等于 `BEHAVIOR_PLUGIN_API_VERSION` |
|
|
317
319
|
| `id` | `string` | 稳定且唯一 |
|
|
318
|
-
| `
|
|
319
|
-
| `
|
|
320
|
+
| `description` | `string` | 非空的 Agent 能力说明 |
|
|
321
|
+
| `name` | `string`,可选 | 兼容已有脚本;新脚本省略,展示信息由 CCL 管理 |
|
|
322
|
+
| `localizations` | object,可选 | 兼容已有脚本的模块文案;人类展示优先采用本地登记或 Hub 下发的文案 |
|
|
320
323
|
| `inputs` | `BehaviorInputFieldSpec[]` | Activation 参数 schema |
|
|
321
324
|
| `execution` | `'parallel' \| 'serial'`,可选 | 省略为 parallel |
|
|
322
325
|
| `everyTicks` | `number`,可选 | 正整数;第一次 eligible tick 总会运行 |
|
|
@@ -485,8 +488,10 @@ debugSnapshot?(): unknown;
|
|
|
485
488
|
| 字段 | 类型 | 约束 |
|
|
486
489
|
|---|---|---|
|
|
487
490
|
| `apiVersion` | `2` | 必须等于 `PERCEPTION_PLUGIN_API_VERSION` |
|
|
488
|
-
| `id`
|
|
489
|
-
| `
|
|
491
|
+
| `id` | `string` | 稳定的模块 ID |
|
|
492
|
+
| `description` | `string` | 非空的 Agent 能力说明 |
|
|
493
|
+
| `name` | `string`,可选 | 兼容已有脚本;新脚本省略,展示信息由 CCL 管理 |
|
|
494
|
+
| `localizations` | object,可选 | 兼容已有脚本的模块文案;人类展示优先采用本地登记或 Hub 下发的文案 |
|
|
490
495
|
| `subjectScope` | `'others' \| 'self_and_others' \| 'visible_pairs' \| 'corpses'` | 描述 Event 主体范围 |
|
|
491
496
|
| `produces` | `string[]` | 允许输出的 Event type |
|
|
492
497
|
| `wakeAgent` | boolean,可选 | 模块默认是否主动唤醒 Agent,省略为 true;单条 proposal 可覆盖 |
|
|
@@ -76,7 +76,7 @@ export default class MyPerception extends ClawclawPerception {
|
|
|
76
76
|
|---|---|
|
|
77
77
|
| `apiVersion` | 当前写 `2` |
|
|
78
78
|
| `id` | 稳定且唯一的模块 ID |
|
|
79
|
-
| `
|
|
79
|
+
| `description` | 给 Agent 的识别目标与能力说明;新脚本无需 `name` |
|
|
80
80
|
| `localizations` | 可选的本地化名称与说明 |
|
|
81
81
|
| `subjectScope` | Event 描述其他玩家、自身与他人、玩家对,还是尸体 |
|
|
82
82
|
| `produces` | 这个模块可能发布的 Event type |
|
|
@@ -85,6 +85,8 @@ export default class MyPerception extends ClawclawPerception {
|
|
|
85
85
|
| `execution` | 可选;耗时分析模块写 `parallel_analysis` |
|
|
86
86
|
| `boundaryBaseline` | 可选;声明并行 reducer 能否仅用当前帧安全建立边界基线 |
|
|
87
87
|
|
|
88
|
+
首次自动上传 Hub 时,默认展示名称取脚本 `id`,默认展示描述取脚本 `description`,分别按 Hub 的 50/600 字符限制截取。之后 Hub 名称、描述独立维护,CCL 随装配版本缓存,用于人类界面和当前策略上报;修改脚本说明不会覆盖 Hub 文案。`ccl load` 和模块详情仍向 Agent 提供脚本描述。本地尚未上传或离线时使用本地登记、缓存的展示信息。新脚本无需填写模块级 `name`,已有脚本仍可读取;感知事件的 `eventMetadata.name`、参数说明和玩家名字不受影响。
|
|
89
|
+
|
|
88
90
|
### 普通模式:`update(frame, api)`
|
|
89
91
|
|
|
90
92
|
每个视觉帧调用一次:
|
|
@@ -111,7 +113,6 @@ export default class FirstSightingPerception extends ClawclawPerception {
|
|
|
111
113
|
static readonly manifest = {
|
|
112
114
|
apiVersion: 2,
|
|
113
115
|
id: 'visual.first_sighting',
|
|
114
|
-
name: '第一次看见玩家',
|
|
115
116
|
description: '在当前连续轨迹中第一次看见其他玩家时发布事件。',
|
|
116
117
|
subjectScope: 'others',
|
|
117
118
|
produces: ['visual.first_sighting'],
|
|
@@ -242,7 +243,6 @@ Manifest 可声明 `wakeAgent: false`,让模块默认只积累感知。省略
|
|
|
242
243
|
static readonly manifest = {
|
|
243
244
|
apiVersion: 2,
|
|
244
245
|
id: 'visual.first_sighting',
|
|
245
|
-
name: '第一次看见玩家',
|
|
246
246
|
description: '记录首次目击,随下一次通知交付。',
|
|
247
247
|
subjectScope: 'others',
|
|
248
248
|
produces: ['visual.first_sighting'],
|
|
@@ -122,7 +122,7 @@ ccl events
|
|
|
122
122
|
|
|
123
123
|
正常退出参与时使用 `ccl game quit`,不要用宿主任务强杀代替后端退出。读取命令的结构化结果,并结合长流后续的 `session_left`、`quit_failed` 或结束状态确认结果。停止或结束承载长流的宿主任务会同时停止本地 runtime、连接和 Behavior,但不等于后端已经接受退出。房间对局返回 `game_returned_room` 时只退出当前一轮,runtime 会继续回到 room lobby;在 `in_room` 再次 quit 才离开房间。`STILL_ALIVE` 时 `ok: false` 指后端拒绝退出;`runtime_stop_requested` / `local_runtime` 另行说明本地 runtime 是否已接到停止请求,而 `backend_participation: "active_game"` 明确表示服务器里的玩家仍在本局。`ALLOCATION_IN_PROGRESS` 表示远端未退出且 runtime 保持运行。
|
|
124
124
|
|
|
125
|
-
只有当前 Monitor 已明确结束或失败时才使用本节:后端已有参与时,在新的
|
|
125
|
+
只有当前 Monitor 已明确结束或失败时才使用本节:后端已有参与时,在新的 30 分钟 Monitor(`timeout_ms=1800000`)中运行 `ccl join`。新进程会创建新的本地运行时会话,再向后端确认并恢复 queue、game 或 room;它不会附着到旧进程,也不会恢复旧本地会话中遗漏的实时事件。若旧 Runtime 仍存活,`ccl join` 会被拒绝并返回其 PID。这个 PID 只证明 Owner 存活;不要附着或复用旧 Owner,改用 `ccl join --force` 挤掉旧 Runtime 后重新拉起。只使用 CCL 的 `--force`,不要自行运行 `kill` / `taskkill`;它会先请求旧 Runtime 正常停止,必要时终止旧进程树,确认退出后再启动新进程。`--force` 不退出后端参与,新进程仍可能恢复原 queue、game 或 room:
|
|
126
126
|
|
|
127
127
|
- 能从后端响应取得 `spectate_url` 时,`session_resumed` 会把完整 URL 交给 Agent。
|
|
128
128
|
- 后端没有返回 URL 时,`ccl game watch` 只按当前 server origin 和本地凭据拼一个兜底链接;它不会额外请求服务器。
|
package/src/commands/behavior.ts
CHANGED
|
@@ -123,6 +123,7 @@ function sourceEntry(
|
|
|
123
123
|
}),
|
|
124
124
|
execution: source.execution,
|
|
125
125
|
every_ticks: source.everyTicks,
|
|
126
|
+
state_mode: source.stateMode ?? 'isolated',
|
|
126
127
|
inputs: source.inputs,
|
|
127
128
|
produces: source.produces ?? [],
|
|
128
129
|
...(source.runtime === undefined ? {} : { runtime: source.runtime }),
|
package/src/commands/load.ts
CHANGED
|
@@ -723,8 +723,9 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
723
723
|
type: 'persona',
|
|
724
724
|
path: snapshot.persona.path,
|
|
725
725
|
runtimeId: basename(snapshot.persona.path, extname(snapshot.persona.path)),
|
|
726
|
-
title:
|
|
727
|
-
description:
|
|
726
|
+
title: hubPersonaItem.title,
|
|
727
|
+
description: hubPersonaItem.description,
|
|
728
|
+
initialDescription: `Persona ${basename(snapshot.persona.path)}`,
|
|
728
729
|
selectedByHub: true,
|
|
729
730
|
hub: {
|
|
730
731
|
resourceId: hubPersonaItem.resourceId,
|
|
@@ -901,7 +902,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
901
902
|
return {
|
|
902
903
|
id: entry.id,
|
|
903
904
|
name: localized.name,
|
|
904
|
-
description:
|
|
905
|
+
description: source.description,
|
|
905
906
|
source: entry.source,
|
|
906
907
|
strategy_type: classifyStrategyLifecycle(readFileSync(source.sourcePath, 'utf8')),
|
|
907
908
|
...(source.management.versionNumber ? { version_number: source.management.versionNumber,
|
|
@@ -910,11 +911,11 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
910
911
|
}),
|
|
911
912
|
perceptions: perceptions.map((entry) => {
|
|
912
913
|
const source = perceptionSourceById.get(entry.id)!;
|
|
913
|
-
const localized = resolveClawclawResourceMetadata(source.manifest, LOAD_DISPLAY_LOCALE);
|
|
914
|
+
const localized = resolveClawclawResourceMetadata({ ...source.manifest, display: source.display }, LOAD_DISPLAY_LOCALE);
|
|
914
915
|
return {
|
|
915
916
|
id: entry.id,
|
|
916
917
|
name: localized.name,
|
|
917
|
-
description:
|
|
918
|
+
description: source.description,
|
|
918
919
|
source: entry.source,
|
|
919
920
|
};
|
|
920
921
|
}),
|
|
@@ -18,6 +18,9 @@ export interface AgentWorkspaceRemoteItem {
|
|
|
18
18
|
resource_id: string;
|
|
19
19
|
forked_from_resource_id?: string | null;
|
|
20
20
|
version_id: string;
|
|
21
|
+
/** Human-facing text for this exact Hub version; absent in older snapshots. */
|
|
22
|
+
title?: string;
|
|
23
|
+
description?: string;
|
|
21
24
|
version_number?: string;
|
|
22
25
|
version_description?: string;
|
|
23
26
|
resource_type: ResourceType;
|
|
@@ -112,7 +112,8 @@ export function listAgentWorkspaceBehaviorSources(
|
|
|
112
112
|
item.sourceFiles[0]?.relativePath ?? basename(source.sourcePath));
|
|
113
113
|
const entry = registerDiscoveredCapability(workspaceDir, profile, {
|
|
114
114
|
type: 'behavior', path: workingCopyPath, runtimeId: source.id,
|
|
115
|
-
title:
|
|
115
|
+
title: item.title, description: item.description, selectedByHub: true,
|
|
116
|
+
initialDescription: source.description,
|
|
116
117
|
hub: { resourceId: item.resourceId, versionId: item.versionId,
|
|
117
118
|
workspaceItemId: item.workspaceItemId, publisher: item.hub?.publisher ?? 'community',
|
|
118
119
|
pendingForkConflict: item.forkReconciliation?.status === 'linked' && item.resolution === 'concurrent_difference' || undefined,
|
|
@@ -144,8 +145,9 @@ export function listAgentWorkspacePerceptionSources(
|
|
|
144
145
|
?? join(getUserDataAccountCapabilitiesDir(workspaceDir, profile), 'perceptions', item.resourceId,
|
|
145
146
|
item.sourceFiles[0]?.relativePath ?? basename(source.sourcePath));
|
|
146
147
|
const entry = registerDiscoveredCapability(workspaceDir, profile, {
|
|
147
|
-
type: 'perception', path: workingCopyPath, runtimeId: source.id, title:
|
|
148
|
-
description:
|
|
148
|
+
type: 'perception', path: workingCopyPath, runtimeId: source.id, title: item.title,
|
|
149
|
+
description: item.description, selectedByHub: true,
|
|
150
|
+
initialDescription: source.description,
|
|
149
151
|
hub: { resourceId: item.resourceId, versionId: item.versionId, workspaceItemId: item.workspaceItemId,
|
|
150
152
|
pendingForkConflict: item.forkReconciliation?.status === 'linked' && item.resolution === 'concurrent_difference' || undefined,
|
|
151
153
|
...(item.forkReconciliation?.status === 'unresolved' ? { forkRelationshipUnresolved: true } : {}),
|
|
@@ -427,8 +427,9 @@ export function syncAgentWorkspaceSkills(
|
|
|
427
427
|
type: 'skill',
|
|
428
428
|
path: canonical,
|
|
429
429
|
runtimeId: name,
|
|
430
|
-
title: name,
|
|
431
|
-
description:
|
|
430
|
+
title: item.remoteItem?.title ?? name,
|
|
431
|
+
description: item.remoteItem?.description,
|
|
432
|
+
initialDescription: `Skill ${name}`,
|
|
432
433
|
selectedByHub: item.kind !== 'local',
|
|
433
434
|
...(item.kind === 'hub' && item.resourceId && item.versionId ? {
|
|
434
435
|
hub: {
|
|
@@ -67,6 +67,8 @@ export interface LocalAgentWorkspaceItem {
|
|
|
67
67
|
};
|
|
68
68
|
resourceId: string;
|
|
69
69
|
versionId: string;
|
|
70
|
+
title?: string;
|
|
71
|
+
description?: string;
|
|
70
72
|
versionNumber?: string;
|
|
71
73
|
versionDescription?: string;
|
|
72
74
|
resourceType: ResourceType;
|
|
@@ -375,6 +377,8 @@ async function materializeItem(
|
|
|
375
377
|
resourceId: item.resource_id,
|
|
376
378
|
forkedFromResourceId: item.forked_from_resource_id ?? undefined,
|
|
377
379
|
versionId: item.version_id,
|
|
380
|
+
title: item.title,
|
|
381
|
+
description: item.description,
|
|
378
382
|
versionNumber: item.version_number,
|
|
379
383
|
versionDescription: item.version_description,
|
|
380
384
|
resourceType: item.resource_type,
|
|
@@ -708,6 +712,7 @@ export async function syncAgentWorkspaceConfig(
|
|
|
708
712
|
return items.length === remote.items[type].length && remote.items[type].every(item =>
|
|
709
713
|
items.some(old => old.resourceId === item.resource_id && old.versionId === item.version_id
|
|
710
714
|
&& old.workspaceItemId === item.workspace_item_id && old.contentDigest === item.content_digest
|
|
715
|
+
&& old.title === item.title && old.description === item.description
|
|
711
716
|
&& old.forkedFromResourceId === (item.forked_from_resource_id ?? undefined)));
|
|
712
717
|
});
|
|
713
718
|
if (
|
|
@@ -948,7 +953,8 @@ export async function syncAgentWorkspaceConfig(
|
|
|
948
953
|
: parentEntry?.declaredId ?? parentEntry?.runtimeId);
|
|
949
954
|
if (runtimeId) forkRegistrations.push({
|
|
950
955
|
type: workspaceType, path: workingPath!, runtimeId,
|
|
951
|
-
title:
|
|
956
|
+
title: item.title ?? parentEntry?.title ?? source?.id,
|
|
957
|
+
description: item.description ?? parentEntry?.description ?? source?.description,
|
|
952
958
|
selectedByHub: true,
|
|
953
959
|
hub: { resourceId: item.resource_id, versionId: item.version_id, workspaceItemId: item.workspace_item_id,
|
|
954
960
|
publisher: 'self', baseSha256: materialized.sourceFiles[0]!.sha256,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
capabilityWorkspacePath,
|
|
18
18
|
readCapabilityWorkspaceRegistry,
|
|
19
19
|
updateCapabilityHubIdentity,
|
|
20
|
+
updateCapabilityDisplayMetadata,
|
|
20
21
|
type CapabilityWorkspaceEntry,
|
|
21
22
|
type CapabilityWorkspaceType,
|
|
22
23
|
} from './capability-workspace.js';
|
|
@@ -259,6 +260,7 @@ export async function refreshCapabilitiesFromCloud(
|
|
|
259
260
|
}
|
|
260
261
|
const detail = await client.getResource(type, hub.resourceId, workspaceItemId);
|
|
261
262
|
if (detail.versionId === hub.versionId) {
|
|
263
|
+
updateCapabilityDisplayMetadata(workspaceDir, profile, entry.key, detail);
|
|
262
264
|
if (
|
|
263
265
|
hub.observedCloudVersionId
|
|
264
266
|
|| (hub.pendingForkConflict && before === hub.baseSha256)
|
|
@@ -309,6 +311,7 @@ export async function refreshCapabilitiesFromCloud(
|
|
|
309
311
|
}
|
|
310
312
|
const convergence = before === artifact.digest;
|
|
311
313
|
if (!convergence) artifact.apply(path);
|
|
314
|
+
updateCapabilityDisplayMetadata(workspaceDir, profile, entry.key, detail);
|
|
312
315
|
updateCapabilityHubIdentity(workspaceDir, profile, entry.key, {
|
|
313
316
|
...hub,
|
|
314
317
|
versionId: detail.versionId,
|
|
@@ -360,6 +360,9 @@ export async function syncCapabilitiesToCloud(
|
|
|
360
360
|
}
|
|
361
361
|
baseVersionId = latest.versionId;
|
|
362
362
|
versionNumber = nextPatchVersion(latest.versionNumber ?? '1.0.0');
|
|
363
|
+
// A source edit is not a request to overwrite human-facing Hub text.
|
|
364
|
+
entry.title = latest.title?.trim() || entry.title;
|
|
365
|
+
entry.description = latest.description?.trim() || entry.description;
|
|
363
366
|
}
|
|
364
367
|
validateUploadPayload(entry, path, payload);
|
|
365
368
|
const uploadedSource = await client.uploadFiles(sourceFileType(entry.type), payload.source);
|
|
@@ -45,7 +45,7 @@ export function discoverLocalCapabilities(
|
|
|
45
45
|
type: 'behavior',
|
|
46
46
|
path: source.sourcePath,
|
|
47
47
|
runtimeId: source.id,
|
|
48
|
-
title: source.
|
|
48
|
+
title: source.id,
|
|
49
49
|
description: source.description,
|
|
50
50
|
strategyLifecycle: classifyStrategyLifecycle(readFileSync(source.sourcePath, 'utf8')),
|
|
51
51
|
}),
|
|
@@ -58,7 +58,7 @@ export function discoverLocalCapabilities(
|
|
|
58
58
|
type: 'perception',
|
|
59
59
|
path: source.sourcePath,
|
|
60
60
|
runtimeId: source.id,
|
|
61
|
-
title: source.
|
|
61
|
+
title: source.id,
|
|
62
62
|
description: source.description,
|
|
63
63
|
}),
|
|
64
64
|
}));
|
|
@@ -4,11 +4,13 @@ import type { ResolvedClawclawPerceptionSource } from '../runtime/clawclaw/plugi
|
|
|
4
4
|
|
|
5
5
|
export function behaviorOperationName<T extends ResolvedClawclawBehaviorSource>(source: T, entry: CapabilityWorkspaceEntry): T {
|
|
6
6
|
return { ...source, id: entry.runtimeId, declaredId: source.declaredId ?? source.id,
|
|
7
|
+
display: { name: entry.title, description: entry.description },
|
|
7
8
|
workingCopyPath: source.workingCopyPath ?? source.sourcePath };
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export function perceptionOperationName<T extends ResolvedClawclawPerceptionSource>(source: T, entry: CapabilityWorkspaceEntry): T {
|
|
11
12
|
return { ...source, id: entry.runtimeId, declaredId: source.declaredId ?? source.id,
|
|
13
|
+
display: { name: entry.title, description: entry.description },
|
|
12
14
|
workingCopyPath: source.workingCopyPath ?? source.sourcePath,
|
|
13
15
|
manifest: { ...source.manifest, id: entry.runtimeId } };
|
|
14
16
|
}
|
|
@@ -124,6 +124,7 @@ export function registerDiscoveredCapability(
|
|
|
124
124
|
runtimeId: string;
|
|
125
125
|
title?: string;
|
|
126
126
|
description?: string;
|
|
127
|
+
initialDescription?: string;
|
|
127
128
|
strategyLifecycle?: StrategyLifecycle;
|
|
128
129
|
hub?: CapabilityHubIdentity;
|
|
129
130
|
selectedByHub?: boolean;
|
|
@@ -163,8 +164,13 @@ export function registerDiscoveredCapability(
|
|
|
163
164
|
relativePath,
|
|
164
165
|
runtimeId,
|
|
165
166
|
declaredId,
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
// Only a Hub snapshot may replace existing human-facing text. Rediscovering
|
|
168
|
+
// a script must not overwrite it with Agent-facing documentation.
|
|
169
|
+
title: (input.selectedByHub ? input.title?.trim() : undefined)
|
|
170
|
+
|| previous?.title || Array.from(input.title?.trim() || input.runtimeId).slice(0, 50).join(''),
|
|
171
|
+
description: (input.selectedByHub ? input.description?.trim() : undefined)
|
|
172
|
+
|| previous?.description || Array.from(input.description?.trim() || input.initialDescription?.trim()
|
|
173
|
+
|| `${input.type} ${input.runtimeId}`).slice(0, 600).join(''),
|
|
168
174
|
selection: input.selectedByHub
|
|
169
175
|
? 'equipped'
|
|
170
176
|
: previous?.selection ?? 'pending',
|
|
@@ -223,6 +229,20 @@ export function setCapabilitySelection(
|
|
|
223
229
|
return entry;
|
|
224
230
|
}
|
|
225
231
|
|
|
232
|
+
export function updateCapabilityDisplayMetadata(
|
|
233
|
+
workspaceDir: string,
|
|
234
|
+
profile: Pick<AuthProfile, 'apiKey'>,
|
|
235
|
+
key: string,
|
|
236
|
+
display: { title?: string; description?: string },
|
|
237
|
+
): void {
|
|
238
|
+
const registry = readCapabilityWorkspaceRegistry(workspaceDir, profile);
|
|
239
|
+
const entry = registry.entries[key];
|
|
240
|
+
if (!entry) return;
|
|
241
|
+
if (display.title?.trim()) entry.title = display.title.trim();
|
|
242
|
+
if (display.description?.trim()) entry.description = display.description.trim();
|
|
243
|
+
writeCapabilityWorkspaceRegistry(workspaceDir, profile, registry);
|
|
244
|
+
}
|
|
245
|
+
|
|
226
246
|
export function updateCapabilityHubIdentity(
|
|
227
247
|
workspaceDir: string,
|
|
228
248
|
profile: Pick<AuthProfile, 'apiKey'>,
|