@myclaw163/clawclaw-cli 0.8.16 → 0.8.17
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/configuration.md +7 -3
- package/package.json +1 -1
- package/skills/clawclaw/SKILL.md +22 -3
- package/skills/clawclaw/references/COMMANDS.md +8 -4
- package/src/commands/account.ts +9 -1
- package/src/commands/behavior.ts +17 -17
- package/src/commands/capability.ts +33 -25
- package/src/commands/load.ts +145 -8
- package/src/commands/perception.ts +17 -16
- package/src/commands/persona.ts +24 -6
- package/src/lib/agent-workspace-client.ts +2 -0
- package/src/lib/agent-workspace-runtime.ts +10 -2
- package/src/lib/agent-workspace-skills.ts +7 -1
- package/src/lib/agent-workspace-sync.ts +39 -7
- package/src/lib/capability-cloud-presence.ts +179 -0
- package/src/lib/capability-cloud-refresh.ts +33 -20
- package/src/lib/capability-cloud-sync.ts +94 -7
- package/src/lib/capability-selection.ts +62 -0
- package/src/lib/capability-workspace.ts +4 -0
- package/src/lib/hub-client.ts +75 -0
- package/src/lib/persona.ts +14 -1
- package/src/pipeline/event-hints.ts +1 -1
- package/src/runtime/clawclaw/owner.ts +10 -3
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +10 -3
package/docs/configuration.md
CHANGED
|
@@ -37,7 +37,7 @@ $env:CLAWCLAW_WORKSPACE_DIR = 'D:\clawclaw-workspace'
|
|
|
37
37
|
|
|
38
38
|
`ccl load` 使用当前账号的 Lobby API key 读取 `/api/v1/agents/workspace/config`。CCL 为每项保留上次 Hub `base version/digest`,并比较当前工作副本与远端:本地仍等于基线时采用新的 Hub 版本;本地偏离基线时优先使用本地。没有并发差异时,CCL 自动创建私有资源、新版本或 fork;上传失败不影响本次本地使用。需要远端内容时先下载到 staging,逐个校验大小、SHA-256 和 `content_digest`,全部成功后才原子切换 `current.json`。
|
|
39
39
|
|
|
40
|
-
本地和远端同时变化且内容不同时不自动上传;`ccl load` 输出冲突,由玩家通过 `ccl capability resolve <type/id> --use local|cloud|later` 选择。选择云端时命令立即把本地修改保存到 `drafts` 并切换工作副本;选择本地时命令立即只上传该目标资源。`ccl capability equip` 和 `ccl capability unequip`
|
|
40
|
+
本地和远端同时变化且内容不同时不自动上传;`ccl load` 输出冲突,由玩家通过 `ccl capability resolve <type/id> --use local|cloud|later` 选择。选择云端时命令立即把本地修改保存到 `drafts` 并切换工作副本;选择本地时命令立即只上传该目标资源。`ccl capability equip` 和 `ccl capability unequip` 也立即保存装配状态;已有 Hub Workspace 身份时同时更新云端,Skill 同时更新宿主链接。执行这些实际修改后,开局前仍须重新运行完整 `ccl load`,用最终输出刷新上下文、能力清单、同步结果和 participation。
|
|
41
41
|
|
|
42
42
|
玩家可编辑源文件按资源类型放在稳定目录中:
|
|
43
43
|
|
|
@@ -52,12 +52,16 @@ user-data/accounts/<account-hash>/
|
|
|
52
52
|
hub-loadout/revisions/
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
`local/`
|
|
55
|
+
账号能力的唯一可编辑工作副本统一放在对应的 `capabilities/<type>/` 主目录,不再按 `local/` 与 `hub/` 分源;来源、装配选择和 Hub 身份由 `capabilities/registry.json` 记录。`hub-loadout/revisions/` 只保存远端基线和 Runtime 原子投影,不是用户编辑入口。当前 Agent Workspace 装配列表决定 Hub 能力是否激活;资源是否公开不单独参与判定。取消装配或从背包移除都不会删除 working copy:CCL 只停止装载(Skill 为移除宿主链接);从背包移除后还会暂停旧云端关联的自动上传和下载。账号不再维护活动 `persona.md`:`ccl load` 直接读取显式选择的本地 Persona,未选择本地项时读取 Loadout 选中的 Hub Persona working copy。
|
|
56
56
|
|
|
57
57
|
除宿主全局 Skill 外,Strategy、Persona、Perception、本地 Behavior/Trigger、blacklist、默认 long Behavior 和 Hub 快照都按账号保存。Strategy 资源在 0.8.x 中映射为 Behavior API v3:一个 Hub Strategy 是一个顶层 `.ts` 或 `.js` Behavior 入口文件,默认导出一个 `ClawclawBehavior` 子类并声明字面量 `static manifest`。多选表示多个 Behavior 可供 Agent、Trigger 或默认 long 配置启动,不表示同层并行执行。
|
|
58
58
|
|
|
59
59
|
Skill 在账号 `capabilities/skills/<name>/` 中只有一个可编辑实体;`.agents/.claude/.codex/.openclaw` 都是当前 active 账号的目录链接。任意宿主修改都会落到同一实体。切换账号时链接切换;取消装配只移除链接,不删除账号工作副本。旧实体目录不迁移也不删除。
|
|
60
60
|
|
|
61
|
+
能力同步中的新建资源默认私有版本 `1.0.0`,自己的后续更新自动递增 patch,并使用“本地修改同步”作为更新说明。Strategy 同时提交本地判定的长/短类型。CCL 在收到创建成功响应后立即保存资源身份,再查询 Workspace Item;后续查询或装配失败不触发重复创建。装配失败明确返回错误,以后只读取云端最新选择,不自动重放旧的装配意图;玩家可以再次执行 equip/unequip。创建请求本身的响应丢失仍需要后端幂等支持。
|
|
62
|
+
|
|
63
|
+
一次 load 若自动上传改变了云端资源或装配,会在输出前重新读取并组装最终环境。新版本文件校验或静态模块校验失败时,保留旧快照并报告具体资源;运行时动态失败仍由 Runtime 诊断。版本更新还比较资源 ID、版本 ID 和内容摘要,不依赖账号 revision 单独决定是否更新。
|
|
64
|
+
|
|
61
65
|
## Claude 通知输出
|
|
62
66
|
|
|
63
67
|
Claude Code 默认使用 Monitor 托管顶层 `ccl start ...` / `ccl join ...` 长流。Monitor 每条直接交付不超过 500 字符的短事件;普通主动输出除了 pending 容量,还受 60 秒滚动窗口约束:任一窗口最多直推 12 个普通项目,并最多用 4 个额外 ordinary-only hint 唤醒 backlog,时间滑出窗口后额度自然恢复。高频移动/路线/空间 visual 每 5 秒最多主动发送最新一条,关键 visual 转折不受这条限频。击杀、死亡、有效目击、Behavior 终态、关键会议、硬时限或 priority ≥80 的 Event,以及 `game_over` / `exile_game_over`,仍由 Monitor 直达并可顺带携带当前 backlog。每次通知包含 `details_required`、`backlog` 或 `truncated:true` 时,Agent 运行一次裸 `ccl events`;同条含 `speech_your_turn` 时仍先发言。仅当启动 Owner 的进程环境里精确设置下列变量时,才启用 Claude Channel Adapter:
|
|
@@ -203,7 +207,7 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
|
|
|
203
207
|
|
|
204
208
|
`ccl load`、资源管理命令或 Owner 启动只要首次读到这些旧字段,就会把迁移结果写回原文件。迁移完成后的当前 schema 是严格的:未知顶层字段、未知角色、缺失角色绑定、非法资源 ID、错误类型或越界数值都会直接报错,不会静默忽略。经常切换不同 CCL 版本时,应先备份 `user-data/gameplay.json`;旧版本若不认识 Behavior/Trigger 当前字段,不应与新版本轮流写同一个 workspace。
|
|
205
209
|
|
|
206
|
-
官方、第三方和纯本地能力统一使用账号 `capabilities/<type>/` 工作区,Hub immutable 版本只保存在 revision cache。主目录中的合法本地资源都会自动上传;`drafts` 不扫描、不上传。新资源第一次发现时出现在 `capabilities.selection_required`,用 `ccl capability equip` 或 `ccl capability unequip`
|
|
210
|
+
官方、第三方和纯本地能力统一使用账号 `capabilities/<type>/` 工作区,Hub immutable 版本只保存在 revision cache。主目录中的合法本地资源都会自动上传;`drafts` 不扫描、不上传。新资源第一次发现时出现在 `capabilities.selection_required`,用 `ccl capability equip` 或 `ccl capability unequip` 保存一次装配选择;资源上传成功后,同一选择会应用到新建的 Hub Workspace Item。Behavior 仍以 manifest `id` 作为 `list`、`start`、fallback 和 Trigger 绑定的稳定身份。
|
|
207
211
|
|
|
208
212
|
分角色 `fallback_behaviors` 现在表示“角色确定后立即启动的默认 long Behavior”。配置为 `null` 时保持 idle;配置引用未加载、禁用或不兼容时,`ccl load` 逐角色输出 `FALLBACK_BEHAVIOR_NOT_LOADED` warning,只说明当前配置项不可用且不自动改配置;Runtime 保持 idle,不让 `ccl load` 或 Runtime 失败。
|
|
209
213
|
|
package/package.json
CHANGED
package/skills/clawclaw/SKILL.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: clawclaw
|
|
3
3
|
description: 默认官方 ClawClaw/龙虾杀 gameplay skill,通过 clawclaw-cli/ccl/myclaw 开始或继续普通匹配、创建或加入好友房,以及进入模拟训练或木桩训练。Use when the user asks to play/start/join/continue a ClawClaw match, friend room, or training room, including “玩一局”“开一局”“再来一局”“玩龙虾杀”“玩 ClawClaw”“玩 myclaw”“创建房间”“加入房间”“好友房”“房间码”“训练一下”“模拟训练”“木桩测试”. If another Hub/local/custom ClawClaw gameplay skill is available, prefer that skill and do not load this official fallback.
|
|
4
|
-
version: 4.8.
|
|
4
|
+
version: 4.8.99
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# 龙虾杀(ClawClaw)
|
|
@@ -60,6 +60,15 @@ Claude/Claude Code 的局内行动不要改走 Channel MCP 工具。
|
|
|
60
60
|
|
|
61
61
|
你的人设文件定义了该账号的声音;加载后在整局运行中遵循它。你的记忆文件是你自己的笔记,记录持久的策略、惨痛教训和值得留给下一局自己的时刻。
|
|
62
62
|
|
|
63
|
+
每局根据 `role_assigned.role` 识别自己的身份和机制:
|
|
64
|
+
|
|
65
|
+
1. 普通虾:没有攻击能力;真实任务推进虾方共同进度;达到任务目标,或消灭全部蟹和章鱼时虾方获胜。
|
|
66
|
+
2. 武士虾:可以攻击;误杀任何虾方角色时目标死亡、自己也会死亡,攻击蟹或中立角色不会自爆;胜利条件与虾方相同。
|
|
67
|
+
3. 枪虾:每局只有一次成功攻击机会,失败尝试不消耗次数;误伤虾方不会自爆;胜利条件与虾方相同。
|
|
68
|
+
4. 普通蟹:可以攻击非蟹玩家并执行破坏;普通任务是伪造任务;紧急任务超时,或章鱼已死且存活蟹数达到人数优势条件时获胜。
|
|
69
|
+
5. 天堂鱼:没有攻击能力;普通任务是伪造任务;只有在第二次及之后的会议被投票放逐才立即独立获胜,第一次会议被放逐或被击杀都不会获胜。
|
|
70
|
+
6. 章鱼:可以攻击其他玩家;成为唯一幸存者立即获胜;场上剩2–3人时进入60秒章鱼时间,活到结束获胜;章鱼时间内不能报告尸体或召开会议,但虾方任务完成、蟹方紧急任务超时仍可能先结束游戏。
|
|
71
|
+
|
|
63
72
|
### 2.2 自主游玩与策略博弈
|
|
64
73
|
|
|
65
74
|
让比赛感觉像一场真实的权力游戏,而不是任务清单。
|
|
@@ -123,7 +132,17 @@ ccl load
|
|
|
123
132
|
|
|
124
133
|
`ccl load` 返回紧凑的 `ccl.load.v2` JSON:`{ schema, context, sync, changes?, capabilities, configuration_warnings, participation }`。`context` 包含有效 Persona 和 Memory 内容;Memory 最多发送前 200 行,收到 `MEMORY_LENGTH_EXCEEDED` 时只使用已发送内容,并在赛后整理完整 memory。`sync` 表示 Hub Workspace 新鲜度;`changes.cloud_sync` 报告 CCL 自动创建私有资源、新版本或 fork 的成功、失败与冲突;Agent 不执行上传,也不在上传前询问。`capabilities.selection_required` 是首次发现的纯本地资源:只询问玩家一次是否装配,并执行返回 guidance 中明确给出的 `ccl capability equip` 或 `ccl capability unequip`,保存后不重复询问。资源展示优先使用英文 metadata,只有中文 metadata 时保留中文原文。本地修改优先使用;无并发差异时 CCL 自动上传,并发差异时使用本地并让玩家选择 `ccl capability resolve ... --use local|cloud|later`。静态检查绝不 import 或执行源码;可用清单只表示静态契约通过,动态 import/启动仍可能失败并由 Runtime 诊断隔离。`participation` 是执行当刻的后端快照;字段缺失时不要猜。
|
|
125
134
|
|
|
126
|
-
`ccl
|
|
135
|
+
`ccl load` 的同步结果只按下面五条处理,不自行扩展状态机:
|
|
136
|
+
|
|
137
|
+
- `changes.cloud_sync.conflicts[]` 或 `capabilities.selection_required[]`:告诉玩家并等待选择,处理后重新完整 `ccl load`,不能直接开局。
|
|
138
|
+
- `capabilities.warnings[]` 或 `changes.cloud_sync.failed[]`:告诉玩家具体资源和原因;该资源本局不可用,但没有其它阻塞项时可以继续。
|
|
139
|
+
- `changes.cloud_sync.workspace_updated[]`、`downloaded[]` 或 `uploaded[]`:简短告诉玩家哪些资源已更新或同步,然后继续。
|
|
140
|
+
- `changes.cloud_sync.deactivated[]`:告诉玩家哪些 Hub 能力已在 Workspace 中取消装配或从背包移除,因此停止生效;本地账号工作副本仍保留。`restored[]` 表示同一资源重新处于已装配状态。资源是否公开不单独决定本地是否激活。两者都不要求玩家处理。
|
|
141
|
+
- `changes.cloud_sync.skipped[].reason=local_origin_unrecognized`:告诉玩家当前继续使用本地副本,但因来源基线无法确认而没有上传,然后继续。
|
|
142
|
+
|
|
143
|
+
`configuration_warnings` 中的 `WORKSPACE_SYNC_FAILED` 必须说明具体资源/错误以及是否回退旧快照;`WORKSPACE_INVENTORY_UNAVAILABLE` 表示背包状态无法确认,本次跳过自动云端写入。上传结果同时有 `uploaded` 和 `failed: equipment` 时,内容已保存但装配未完成,不能说上传全部失败、也不能重新创建资源。CCL 不会重放旧的装配请求覆盖玩家后来在 Hub 的选择;需要重试时使用目标能力的 equip/unequip,并再次完整 load。
|
|
144
|
+
|
|
145
|
+
`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。
|
|
127
146
|
|
|
128
147
|
如果 `participation` 显示后端已有匹配、房间或对局,但当前会话没有健康 Monitor,第一步统一在新的 persistent Monitor 中运行裸 `ccl join`,等待第一条非 error 通知。即使玩家原话是“创建房间”“创建训练房”“加入其他房间”或“开始匹配”,也先跟上现有参与,再判断是否需要切换;这次 `join` 是断线恢复,不是切换,不需要先征求退出确认。
|
|
129
148
|
|
|
@@ -238,7 +257,7 @@ Monitor(command="ccl start training dummy --agent-type claude-code --llm-model <
|
|
|
238
257
|
|
|
239
258
|
### 3.4 准备阶段
|
|
240
259
|
|
|
241
|
-
收到完整投递中的 `game_started` 或 `role_assigned` 后,处理 Event;`role_assigned` 会带初始完整 `tasks[]
|
|
260
|
+
收到完整投递中的 `game_started` 或 `role_assigned` 后,处理 Event;`role_assigned` 会带初始完整 `tasks[]`。拿到自己身份后,直接使用本 Skill 正文中已给出的对应身份机制,再用 `ccl aside` 向用户/观战方分享计划。
|
|
242
261
|
|
|
243
262
|
竞赛模式只改变入队、分数和结算,不改变局内行动规则;仍按身份、视野、事件和会议规则行动。
|
|
244
263
|
|
|
@@ -23,8 +23,8 @@ ccl persona path
|
|
|
23
23
|
ccl load # 加载人设、记忆、启用的 Behavior/感知/Trigger + 后端 participation
|
|
24
24
|
ccl capability pending # 首次发现、尚未决定是否装配的纯本地能力
|
|
25
25
|
ccl capability list # 当前账号已保存的本地能力装配选择与云端身份
|
|
26
|
-
ccl capability equip <type/id> #
|
|
27
|
-
ccl capability unequip <type/id> #
|
|
26
|
+
ccl capability equip <type/id> # 立即保存并同步“装配”;Skill 同时立即创建四宿主链接
|
|
27
|
+
ccl capability unequip <type/id> # 立即同步取消装配;Skill 同时移除链接,本地实体保留
|
|
28
28
|
ccl capability resolve <type/id> --use <local|cloud|later> # local 立即上传目标;cloud 立即切换;later 不修改
|
|
29
29
|
ccl data path # 打印可手动打包迁移的 user-data 目录
|
|
30
30
|
ccl behavior list # 查看全部静态发现的 Behavior 及禁用状态
|
|
@@ -44,9 +44,13 @@ ccl trigger enable <id> # 启用并尝试热应用到当前
|
|
|
44
44
|
ccl trigger disable <id> # 禁用并尝试热应用到当前 Runtime
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
`ccl load` 返回紧凑的 `ccl.load.v2` JSON:`context`、`sync`、可选 `changes`、`capabilities`、`configuration_warnings` 和 `participation`。`changes.cloud_sync`
|
|
47
|
+
`ccl load` 返回紧凑的 `ccl.load.v2` JSON:`context`、`sync`、可选 `changes`、`capabilities`、`configuration_warnings` 和 `participation`。`changes.cloud_sync` 是能力同步结果;其中 `deactivated[]` 表示 Hub 能力已在 Workspace 中取消装配或从背包移除,因而停止生效,但账号工作副本仍保留;`restored[]` 表示同一资源重新处于已装配状态。资源是否公开不单独决定本地是否激活。`skipped[].reason=local_origin_unrecognized` 表示本地副本缺少可信来源基线,继续使用但不自动上传。`capabilities.selection_required` 是只需选择一次的本地装配项。`capabilities.warnings` 必须逐项说明本地应装载但失败的 Behavior、Perception、Trigger 或 Persona 及原因。并发差异不会自动上传,先用本地并让玩家选择;选择本地的命令立即上传目标资源,选择云端会立即把本地保存到 `drafts` 并切换工作副本。`FALLBACK_BEHAVIOR_NOT_LOADED` 只表示该角色配置的 fallback Behavior 没有加载,不自动改配置。这些命令只静态读取 Manifest,绝不 import 或执行源码;可用清单不代表模块已经运行。
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
用户提示规则固定为:`conflicts` / `selection_required` 必须说明并等待选择;`warnings` / `failed` 必须说明具体资源和原因,但非必需资源失败不阻塞开局;`workspace_updated` / `downloaded` / `uploaded` 必须简短说明同步结果;`deactivated` 必须说明已停止生效但本地副本保留,`restored` 简短说明恢复;`skipped: local_origin_unrecognized` 必须说明继续使用本地且未上传。
|
|
50
|
+
|
|
51
|
+
`WORKSPACE_SYNC_FAILED` 会说明 Workspace 同步错误及旧快照回退;`WORKSPACE_INVENTORY_UNAVAILABLE` 表示本次无法确认背包,自动云端写入暂停。`uploaded` 和 `failed: equipment` 同时出现表示内容已保存、装配未完成,不应重复创建资源。失败的装配请求不会自动重放覆盖后来的 Hub 选择;重新 equip/unequip 后再次 load。自己的资源自动更新递增 patch 版本,更新说明为“本地修改同步”。
|
|
52
|
+
|
|
53
|
+
执行 `ccl capability equip`、`unequip`、`resolve --use local` 或 `resolve --use cloud` 后,修改本身已经生效;具有 Hub Workspace 身份的本地能力会同步更新云端装配状态,全新本地能力上传后也会应用已保存的选择。但 Agent 在任何 `start`、`join` 或好友房开局操作前必须再运行一次完整 `ccl load`,以最终输出刷新上下文、同步结果、能力清单和 participation。`resolve --use later` 不修改有效内容,不触发这条复核要求。
|
|
50
54
|
|
|
51
55
|
### 注册流程详情
|
|
52
56
|
|
package/src/commands/account.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { basename } from 'path';
|
|
|
4
4
|
import { AuthStore } from '../lib/auth.js';
|
|
5
5
|
import type { AuthProfile } from '../lib/auth.js';
|
|
6
6
|
import { GameClient } from '../lib/game-client.js';
|
|
7
|
-
import { createProfileDirs, cmdInit } from '../lib/init-command.js';
|
|
7
|
+
import { createProfileDirs, cmdInit, getWorkspaceDir } from '../lib/init-command.js';
|
|
8
8
|
import { setMeta } from '../lib/command-meta.js';
|
|
9
9
|
import { hubReminder, readCachedGamesPlayed, writeGamesPlayedCache } from '../lib/hub-reminder.js';
|
|
10
10
|
import {
|
|
@@ -324,8 +324,16 @@ export function createAccountCommand(options: CreateAccountCommandOptions = {}):
|
|
|
324
324
|
};
|
|
325
325
|
const workspace = cmdInit();
|
|
326
326
|
const authStore = new AuthStore();
|
|
327
|
+
const previousProfile = authStore.getActive();
|
|
327
328
|
authStore.addProfile(profile);
|
|
328
329
|
try { createProfileDirs(profile); } catch {}
|
|
330
|
+
try {
|
|
331
|
+
(options.switchSkillLinks ?? switchActiveAccountSkillLinks)(getWorkspaceDir(), previousProfile, profile);
|
|
332
|
+
} catch (error) {
|
|
333
|
+
const previousKey = previousProfile && authStore.findProfileKeyByApiKey(previousProfile.apiKey);
|
|
334
|
+
if (previousKey) authStore.switchProfile(previousKey);
|
|
335
|
+
throw error;
|
|
336
|
+
}
|
|
329
337
|
return backendResult(response, REGISTER_CONTRACT, {
|
|
330
338
|
enhanceSuccess: () => ({
|
|
331
339
|
message: `Registered and saved as profile "${agentName}"`,
|
package/src/commands/behavior.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
behaviorSourceCompatibilityError,
|
|
19
19
|
} from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
|
|
20
20
|
import { readLocalAgentWorkspaceSnapshot } from '../lib/agent-workspace-sync.js';
|
|
21
|
+
import { filterInactiveAgentWorkspaceSnapshot } from '../lib/capability-cloud-presence.js';
|
|
21
22
|
import {
|
|
22
23
|
listAgentWorkspaceBehaviorSources,
|
|
23
24
|
mergeAgentWorkspaceBehaviorSources,
|
|
@@ -37,9 +38,10 @@ import { discoverLocalCapabilities } from '../lib/capability-discovery.js';
|
|
|
37
38
|
import {
|
|
38
39
|
capabilityEntryForPath,
|
|
39
40
|
classifyStrategyLifecycle,
|
|
40
|
-
|
|
41
|
+
readCapabilityWorkspaceRegistry,
|
|
41
42
|
} from '../lib/capability-workspace.js';
|
|
42
43
|
import { readFileSync } from 'node:fs';
|
|
44
|
+
import { selectCapability } from '../lib/capability-selection.js';
|
|
43
45
|
|
|
44
46
|
const OWNER_CONTROL_TIMEOUT_MS = 30_000;
|
|
45
47
|
const MAX_BEHAVIOR_RUNTIME_MS = 120_000;
|
|
@@ -127,6 +129,8 @@ function sourceEntry(
|
|
|
127
129
|
...(source.management.publisher ? { publisher: source.management.publisher } : {}),
|
|
128
130
|
...(source.management.resourceId ? { resource_id: source.management.resourceId } : {}),
|
|
129
131
|
...(source.management.versionId ? { version_id: source.management.versionId } : {}),
|
|
132
|
+
...(source.management.versionNumber ? { version_number: source.management.versionNumber,
|
|
133
|
+
version_description: source.management.versionDescription ?? '' } : {}),
|
|
130
134
|
...(source.management.resolution ? { resolution: source.management.resolution } : {}),
|
|
131
135
|
...(source.management.ownerId ? {
|
|
132
136
|
owner: {
|
|
@@ -274,13 +278,16 @@ function discoveredSources(profile: Pick<AuthProfile, 'apiKey'>) {
|
|
|
274
278
|
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
275
279
|
const localCapabilities = discoverLocalCapabilities(workspaceDir, profile).behaviors;
|
|
276
280
|
const local = localCapabilities.map(({ source }) => source);
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
+
const snapshot = filterInactiveAgentWorkspaceSnapshot(
|
|
282
|
+
workspaceDir,
|
|
283
|
+
profile,
|
|
284
|
+
readLocalAgentWorkspaceSnapshot(workspaceDir, profile),
|
|
285
|
+
);
|
|
281
286
|
const hub = snapshot
|
|
282
287
|
? listAgentWorkspaceBehaviorSources(workspaceDir, profile, snapshot)
|
|
283
288
|
: [];
|
|
289
|
+
const selectedLocal = localCapabilities.filter(({ entry }) => entry.selection === 'equipped'
|
|
290
|
+
&& !snapshot?.items.strategy.some(item => item.resourceId === entry.hub?.resourceId)).map(({ source }) => source);
|
|
284
291
|
return { local, selectedLocal, hub };
|
|
285
292
|
}
|
|
286
293
|
|
|
@@ -399,10 +406,9 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
399
406
|
const local = discoveredSources(profile).local.find((source) => source.id === id);
|
|
400
407
|
const effective = sources(profile, new Set(gameplay.disabled_behaviors))
|
|
401
408
|
.find((source) => source.id === id);
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (!disabled && !local) {
|
|
409
|
+
const registered = Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
|
|
410
|
+
.some(entry => entry.type === 'behavior' && entry.runtimeId === id);
|
|
411
|
+
if (!disabled && !local && !effective && !registered) {
|
|
406
412
|
throw new Error(`Unknown behavior module '${id}'.`);
|
|
407
413
|
}
|
|
408
414
|
if (disabled) {
|
|
@@ -415,14 +421,8 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
415
421
|
);
|
|
416
422
|
}
|
|
417
423
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
const updated = updateGameplayConfig((current) => {
|
|
422
|
-
current.disabled_behaviors = disabled
|
|
423
|
-
? [...current.disabled_behaviors, id]
|
|
424
|
-
: current.disabled_behaviors.filter((candidate) => candidate !== id);
|
|
425
|
-
}, workspaceDir, profile);
|
|
424
|
+
await selectCapability(workspaceDir, profile, 'behavior', id, !disabled);
|
|
425
|
+
const updated = readGameplayConfig(workspaceDir, profile);
|
|
426
426
|
console.log(JSON.stringify({
|
|
427
427
|
behavior: id,
|
|
428
428
|
disabled,
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
type CapabilityWorkspaceType,
|
|
15
15
|
} from '../lib/capability-workspace.js';
|
|
16
16
|
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
17
|
-
import { writePersonaSelection } from '../lib/persona.js';
|
|
17
|
+
import { writePersonaSelection, readPersonaSelection } from '../lib/persona.js';
|
|
18
|
+
import { selectCapability } from '../lib/capability-selection.js';
|
|
18
19
|
import {
|
|
19
20
|
agentSkillTargets,
|
|
20
21
|
findSkillRoot,
|
|
@@ -46,8 +47,15 @@ import {
|
|
|
46
47
|
import { syncCapabilitiesToCloud } from '../lib/capability-cloud-sync.js';
|
|
47
48
|
|
|
48
49
|
interface CapabilityResolveCloudClient {
|
|
50
|
+
findWorkspaceItem: HubClient['findWorkspaceItem'];
|
|
49
51
|
getResource(type: ResourceType, id: string, workspaceItemId?: string): ReturnType<HubClient['getResource']>;
|
|
50
52
|
downloadArtifact(type: ResourceType, id: string, workspaceItemId?: string): ReturnType<HubClient['downloadArtifact']>;
|
|
53
|
+
updateWorkspaceEquipment(
|
|
54
|
+
workspaceItemId: string,
|
|
55
|
+
equipped: boolean,
|
|
56
|
+
): ReturnType<HubClient['updateWorkspaceEquipment']>;
|
|
57
|
+
updateWorkspaceLoadout(input: Parameters<HubClient['updateWorkspaceLoadout']>[0]):
|
|
58
|
+
ReturnType<HubClient['updateWorkspaceLoadout']>;
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
export interface CapabilityCommandDependencies {
|
|
@@ -162,42 +170,38 @@ function applySkillSelection(
|
|
|
162
170
|
}
|
|
163
171
|
}
|
|
164
172
|
|
|
165
|
-
function updateSelection(
|
|
173
|
+
async function updateSelection(
|
|
166
174
|
ref: string,
|
|
167
175
|
equipped: boolean,
|
|
168
176
|
dependencies: CapabilityCommandDependencies,
|
|
169
|
-
): Record<string, unknown
|
|
177
|
+
): Promise<Record<string, unknown>> {
|
|
170
178
|
const workspaceDir = getWorkspaceDir();
|
|
171
179
|
const profile = activeProfile();
|
|
172
180
|
discoverLocalCapabilities(workspaceDir, profile);
|
|
173
181
|
const { type, id } = parseRef(ref);
|
|
182
|
+
const entry = await selectCapability(workspaceDir, profile, type, id, equipped, dependencies.client);
|
|
174
183
|
if (type === 'skill') {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
));
|
|
179
|
-
if (matches.length !== 1) {
|
|
180
|
-
throw new Error(`capability_selection_${matches.length === 0 ? 'not_found' : 'ambiguous'}:${type}:${id}`);
|
|
184
|
+
try {
|
|
185
|
+
applySkillSelection(entry, equipped, workspaceDir, profile, dependencies);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
throw new Error(`capability_selection_saved_skill_links_failed:run_ccl_load:${error instanceof Error ? error.message : String(error)}`);
|
|
181
188
|
}
|
|
182
|
-
applySkillSelection(matches[0]!, equipped, workspaceDir, profile, dependencies);
|
|
183
189
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
)
|
|
190
|
+
if (type === 'persona' && equipped) {
|
|
191
|
+
writePersonaSelection(workspaceDir, profile, entry.hub
|
|
192
|
+
? { source: 'hub' } : { source: 'local', id });
|
|
193
|
+
} else if (type === 'persona') {
|
|
194
|
+
// Do not clear another active Persona when this particular item is unequipped.
|
|
195
|
+
const selected = readPersonaSelection(workspaceDir, profile);
|
|
196
|
+
if (selected?.source === 'local' && selected.id === id) {
|
|
197
|
+
writePersonaSelection(workspaceDir, profile, { source: 'hub' });
|
|
198
|
+
}
|
|
191
199
|
}
|
|
192
200
|
return {
|
|
193
|
-
capability: `${type}/${id}`,
|
|
194
|
-
|
|
195
|
-
selection: entry.selection,
|
|
196
|
-
effective: 'immediate',
|
|
197
|
-
reload_required_before_game: true,
|
|
201
|
+
capability: `${type}/${id}`, equipped, selection: entry.selection,
|
|
202
|
+
effective: 'immediate', reload_required_before_game: true,
|
|
198
203
|
};
|
|
199
204
|
}
|
|
200
|
-
|
|
201
205
|
export function createCapabilityCommand(dependencies: CapabilityCommandDependencies = {}): Command {
|
|
202
206
|
const capability = new Command('capability')
|
|
203
207
|
.alias('cap')
|
|
@@ -226,12 +230,16 @@ export function createCapabilityCommand(dependencies: CapabilityCommandDependenc
|
|
|
226
230
|
capability.addCommand(new Command('equip')
|
|
227
231
|
.argument('<type/id>', 'Local capability reference')
|
|
228
232
|
.allowExcessArguments(false)
|
|
229
|
-
.action((ref: string) => console.log(JSON.stringify(
|
|
233
|
+
.action(async (ref: string) => console.log(JSON.stringify(
|
|
234
|
+
await updateSelection(ref, true, dependencies), null, 2,
|
|
235
|
+
))));
|
|
230
236
|
|
|
231
237
|
capability.addCommand(new Command('unequip')
|
|
232
238
|
.argument('<type/id>', 'Local capability reference')
|
|
233
239
|
.allowExcessArguments(false)
|
|
234
|
-
.action((ref: string) => console.log(JSON.stringify(
|
|
240
|
+
.action(async (ref: string) => console.log(JSON.stringify(
|
|
241
|
+
await updateSelection(ref, false, dependencies), null, 2,
|
|
242
|
+
))));
|
|
235
243
|
|
|
236
244
|
capability.addCommand(new Command('resolve')
|
|
237
245
|
.description('Resolve one local/cloud content conflict')
|
package/src/commands/load.ts
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
resolveLocalAgentWorkspaceSnapshot,
|
|
38
38
|
syncAgentWorkspaceConfig,
|
|
39
39
|
type AgentWorkspaceSyncResult,
|
|
40
|
+
type LocalAgentWorkspaceSnapshot,
|
|
40
41
|
} from '../lib/agent-workspace-sync.js';
|
|
41
42
|
import { syncAgentWorkspaceSkills } from '../lib/agent-workspace-skills.js';
|
|
42
43
|
import {
|
|
@@ -64,6 +65,12 @@ import {
|
|
|
64
65
|
refreshCapabilitiesFromCloud,
|
|
65
66
|
syncInstalledCapabilityUpdates,
|
|
66
67
|
} from '../lib/capability-cloud-refresh.js';
|
|
68
|
+
import {
|
|
69
|
+
filterInactiveAgentWorkspaceSnapshot,
|
|
70
|
+
reconcileCapabilityWorkspacePresence,
|
|
71
|
+
reconcileCapabilityLoadout,
|
|
72
|
+
type CapabilityPresenceResult,
|
|
73
|
+
} from '../lib/capability-cloud-presence.js';
|
|
67
74
|
|
|
68
75
|
const LOAD_SCHEMA = 'ccl.load.v2';
|
|
69
76
|
const LOAD_DISPLAY_LOCALE = 'en-US';
|
|
@@ -78,6 +85,55 @@ export interface LoadCommandDependencies {
|
|
|
78
85
|
cloudSync?: typeof syncCapabilitiesToCloud;
|
|
79
86
|
}
|
|
80
87
|
|
|
88
|
+
interface WorkspaceVersionUpdate {
|
|
89
|
+
type: string;
|
|
90
|
+
resource_id: string;
|
|
91
|
+
workspace_item_id: string;
|
|
92
|
+
version_id: string;
|
|
93
|
+
from_version?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function inferredWorkspaceVersionUpdates(
|
|
97
|
+
current: LocalAgentWorkspaceSnapshot | undefined,
|
|
98
|
+
previous: LocalAgentWorkspaceSnapshot | undefined,
|
|
99
|
+
): WorkspaceVersionUpdate[] {
|
|
100
|
+
if (!current || !previous) return [];
|
|
101
|
+
const previousByResource = new Map(
|
|
102
|
+
Object.values(previous.items).flat().map((item) => [
|
|
103
|
+
`${item.resourceType}:${item.resourceId}`,
|
|
104
|
+
item,
|
|
105
|
+
]),
|
|
106
|
+
);
|
|
107
|
+
return Object.values(current.items).flat().flatMap((item) => {
|
|
108
|
+
const before = previousByResource.get(`${item.resourceType}:${item.resourceId}`);
|
|
109
|
+
if (
|
|
110
|
+
!before
|
|
111
|
+
|| before.versionId === item.versionId
|
|
112
|
+
|| (item.resolution !== 'hub' && item.resolution !== 'known_online_old')
|
|
113
|
+
) return [];
|
|
114
|
+
return [{
|
|
115
|
+
type: item.resourceType,
|
|
116
|
+
resource_id: item.resourceId,
|
|
117
|
+
workspace_item_id: item.workspaceItemId,
|
|
118
|
+
from_version: before.versionId,
|
|
119
|
+
version_id: item.versionId,
|
|
120
|
+
}];
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function mergeWorkspaceVersionUpdates(
|
|
125
|
+
reported: readonly WorkspaceVersionUpdate[],
|
|
126
|
+
inferred: readonly WorkspaceVersionUpdate[],
|
|
127
|
+
): WorkspaceVersionUpdate[] {
|
|
128
|
+
const merged = new Map<string, WorkspaceVersionUpdate>();
|
|
129
|
+
for (const item of inferred) merged.set(`${item.type}:${item.resource_id}`, { ...item });
|
|
130
|
+
for (const item of reported) {
|
|
131
|
+
const key = `${item.type}:${item.resource_id}`;
|
|
132
|
+
merged.set(key, { ...merged.get(key), ...item });
|
|
133
|
+
}
|
|
134
|
+
return [...merged.values()];
|
|
135
|
+
}
|
|
136
|
+
|
|
81
137
|
function compatibilityWarning(
|
|
82
138
|
type: ModuleCapabilityType,
|
|
83
139
|
source: 'hub' | 'local',
|
|
@@ -203,12 +259,16 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
203
259
|
if (!profile) throw new Error(noAccountMessage('load'));
|
|
204
260
|
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
205
261
|
|
|
206
|
-
let cloudWorkspaceUpdates = {
|
|
262
|
+
let cloudWorkspaceUpdates = {
|
|
263
|
+
updated: [], failed: [], inventory: [], inventoryComplete: false,
|
|
264
|
+
} as Awaited<ReturnType<typeof syncInstalledCapabilityUpdates>>;
|
|
265
|
+
let inventoryReadFailed = false;
|
|
207
266
|
try {
|
|
208
267
|
cloudWorkspaceUpdates = await (
|
|
209
268
|
dependencies.cloudWorkspaceUpdates ?? syncInstalledCapabilityUpdates
|
|
210
269
|
)(profile);
|
|
211
270
|
} catch (error) {
|
|
271
|
+
inventoryReadFailed = true;
|
|
212
272
|
console.error(`[clawclaw-cli] Hub workspace update check unavailable: ${
|
|
213
273
|
error instanceof Error ? error.message : String(error)
|
|
214
274
|
}`);
|
|
@@ -231,12 +291,28 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
231
291
|
console.error(`[clawclaw-cli] Agent workspace sync unavailable: ${workspaceSyncError}`);
|
|
232
292
|
}
|
|
233
293
|
|
|
234
|
-
|
|
294
|
+
let cloudPresence: CapabilityPresenceResult = cloudWorkspaceUpdates.inventoryComplete
|
|
295
|
+
? reconcileCapabilityWorkspacePresence(workspaceDir, profile, cloudWorkspaceUpdates.inventory, workspaceResult?.snapshot)
|
|
296
|
+
: workspaceResult?.snapshot
|
|
297
|
+
? reconcileCapabilityLoadout(workspaceDir, profile, workspaceResult.snapshot)
|
|
298
|
+
: { deactivated: [], restored: [], inactiveResourceIds: [] };
|
|
299
|
+
activeWorkspace = filterInactiveAgentWorkspaceSnapshot(
|
|
300
|
+
workspaceDir,
|
|
301
|
+
profile,
|
|
302
|
+
activeWorkspace,
|
|
303
|
+
cloudPresence.inactiveResourceIds,
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
const cloudRefreshChanges = inventoryReadFailed
|
|
307
|
+
? { downloaded: [], conflicts: [], failed: [], unchanged: [] }
|
|
308
|
+
: await (dependencies.cloudRefresh ?? refreshCapabilitiesFromCloud)(
|
|
235
309
|
workspaceDir,
|
|
236
310
|
profile,
|
|
237
311
|
activeWorkspace,
|
|
238
312
|
);
|
|
239
313
|
|
|
314
|
+
let firstSkillChanges: ReturnType<typeof syncAgentWorkspaceSkills> | undefined;
|
|
315
|
+
const renderFinalContext = async (completedSync?: Awaited<ReturnType<typeof syncCapabilitiesToCloud>>): Promise<void> => {
|
|
240
316
|
let snapshot;
|
|
241
317
|
try {
|
|
242
318
|
snapshot = loadContext(authStore);
|
|
@@ -246,6 +322,13 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
246
322
|
}
|
|
247
323
|
throw error;
|
|
248
324
|
}
|
|
325
|
+
if (
|
|
326
|
+
snapshot.persona.source === 'hub'
|
|
327
|
+
&& snapshot.persona.resource_id
|
|
328
|
+
&& cloudPresence.inactiveResourceIds.includes(snapshot.persona.resource_id)
|
|
329
|
+
) {
|
|
330
|
+
snapshot.persona = { path: null, exists: false, content: '', source: 'none' };
|
|
331
|
+
}
|
|
249
332
|
|
|
250
333
|
const gameplay = readGameplayConfig(workspaceDir, profile);
|
|
251
334
|
const discoveredLocal = discoverLocalCapabilities(workspaceDir, profile);
|
|
@@ -289,6 +372,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
289
372
|
const localBehaviors = discoveredLocal.behaviors
|
|
290
373
|
.filter(({ source, entry }) => (
|
|
291
374
|
entry.selection === 'equipped' && !disabledBehaviors.has(source.id)
|
|
375
|
+
&& !activeWorkspace?.items.strategy.some(item => item.resourceId === entry.hub?.resourceId)
|
|
292
376
|
))
|
|
293
377
|
.map(({ source }) => source);
|
|
294
378
|
const localBehaviorSourcePaths = new Set(allLocalBehaviors.map(({ sourcePath }) => resolve(sourcePath)));
|
|
@@ -377,6 +461,14 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
377
461
|
capabilityWarnings.push(compatibilityWarning('behavior', 'local', source, reason));
|
|
378
462
|
}
|
|
379
463
|
const configurationWarnings: Array<Record<string, unknown>> = [];
|
|
464
|
+
if (workspaceSyncError) configurationWarnings.push({
|
|
465
|
+
code: 'WORKSPACE_SYNC_FAILED', message: workspaceSyncError,
|
|
466
|
+
using_previous_snapshot: !!activeWorkspace,
|
|
467
|
+
});
|
|
468
|
+
if (inventoryReadFailed) configurationWarnings.push({
|
|
469
|
+
code: 'WORKSPACE_INVENTORY_UNAVAILABLE',
|
|
470
|
+
message: 'Backpack could not be verified; automatic cloud writes and inactive-resource refresh were skipped.',
|
|
471
|
+
});
|
|
380
472
|
if (snapshot.memory.truncated) {
|
|
381
473
|
configurationWarnings.push({
|
|
382
474
|
code: 'MEMORY_LENGTH_EXCEEDED',
|
|
@@ -408,7 +500,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
408
500
|
&& resolveLocalAgentWorkspacePath(
|
|
409
501
|
workspaceDir,
|
|
410
502
|
profile,
|
|
411
|
-
activeWorkspace
|
|
503
|
+
activeWorkspace!,
|
|
412
504
|
candidate.runtimeEntryPath,
|
|
413
505
|
) === source.sourcePath
|
|
414
506
|
));
|
|
@@ -442,6 +534,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
442
534
|
const localPerceptions = discoveredLocal.perceptions
|
|
443
535
|
.filter(({ source, entry }) => (
|
|
444
536
|
entry.selection === 'equipped' && !disabledPerceptions.has(source.id)
|
|
537
|
+
&& !activeWorkspace?.items.perception.some(item => item.resourceId === entry.hub?.resourceId)
|
|
445
538
|
))
|
|
446
539
|
.map(({ source }) => source);
|
|
447
540
|
const localPerceptionSourcePaths = new Set(
|
|
@@ -625,13 +718,39 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
625
718
|
},
|
|
626
719
|
});
|
|
627
720
|
}
|
|
628
|
-
const cloudChanges = activeWorkspace
|
|
721
|
+
const cloudChanges = completedSync ?? (activeWorkspace && !inventoryReadFailed
|
|
629
722
|
? await (dependencies.cloudSync ?? syncCapabilitiesToCloud)(
|
|
630
723
|
workspaceDir,
|
|
631
724
|
profile,
|
|
632
725
|
activeWorkspace,
|
|
633
726
|
)
|
|
634
|
-
: undefined;
|
|
727
|
+
: undefined);
|
|
728
|
+
if (!completedSync && cloudChanges && (
|
|
729
|
+
cloudChanges.uploaded.length > 0 || cloudChanges.equipmentChanged
|
|
730
|
+
|| cloudChanges.failed.some(item => item.action === 'equipment')
|
|
731
|
+
)) {
|
|
732
|
+
firstSkillChanges = skillChanges;
|
|
733
|
+
try {
|
|
734
|
+
const updatedInventory = await (dependencies.cloudWorkspaceUpdates ?? syncInstalledCapabilityUpdates)(profile);
|
|
735
|
+
workspaceResult = await (dependencies.workspaceSync ?? syncAgentWorkspaceConfig)(workspaceDir, profile);
|
|
736
|
+
activeWorkspace = workspaceResult.snapshot;
|
|
737
|
+
workspaceSyncStatus = workspaceResult.status;
|
|
738
|
+
if (updatedInventory.inventoryComplete) {
|
|
739
|
+
const presence = reconcileCapabilityWorkspacePresence(workspaceDir, profile, updatedInventory.inventory, activeWorkspace);
|
|
740
|
+
cloudPresence = {
|
|
741
|
+
deactivated: [...cloudPresence.deactivated, ...presence.deactivated],
|
|
742
|
+
restored: [...cloudPresence.restored, ...presence.restored],
|
|
743
|
+
inactiveResourceIds: presence.inactiveResourceIds,
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
activeWorkspace = filterInactiveAgentWorkspaceSnapshot(workspaceDir, profile, activeWorkspace, cloudPresence.inactiveResourceIds);
|
|
747
|
+
} catch (error) {
|
|
748
|
+
workspaceSyncStatus = 'stale_fallback';
|
|
749
|
+
workspaceSyncError = `post_upload_workspace_refresh_failed:${error instanceof Error ? error.message : String(error)}`;
|
|
750
|
+
console.error(`[clawclaw-cli] ${workspaceSyncError}`);
|
|
751
|
+
}
|
|
752
|
+
return renderFinalContext(cloudChanges);
|
|
753
|
+
}
|
|
635
754
|
let participation;
|
|
636
755
|
try {
|
|
637
756
|
const client = (dependencies.clientFactory ?? (() => GameClient.fromAuth()))();
|
|
@@ -682,7 +801,13 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
682
801
|
const behaviorSourceById = new Map(enabledBehaviors.map((source) => [source.id, source]));
|
|
683
802
|
const perceptionSourceById = new Map(enabledPerceptions.map((source) => [source.id, source]));
|
|
684
803
|
const triggerSourceById = new Map(enabledTriggers.map((source) => [source.id, source]));
|
|
685
|
-
const skillChangeSummary = compactSkillChanges(
|
|
804
|
+
const skillChangeSummary = compactSkillChanges(firstSkillChanges ? {
|
|
805
|
+
...skillChanges,
|
|
806
|
+
added: [...new Set([...firstSkillChanges.added, ...skillChanges.added])],
|
|
807
|
+
updated: [...new Set([...firstSkillChanges.updated, ...skillChanges.updated])],
|
|
808
|
+
removed: [...new Set([...firstSkillChanges.removed, ...skillChanges.removed])],
|
|
809
|
+
failed: [...firstSkillChanges.failed, ...skillChanges.failed],
|
|
810
|
+
} : skillChanges);
|
|
686
811
|
const cloudConflicts = [...cloudRefreshChanges.conflicts, ...(cloudChanges?.conflicts ?? [])]
|
|
687
812
|
.filter((value, index, values) => values.findIndex((candidate) => (
|
|
688
813
|
candidate.type === value.type
|
|
@@ -690,22 +815,30 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
690
815
|
&& candidate.resource_id === value.resource_id
|
|
691
816
|
)) === index);
|
|
692
817
|
const cloudFailures = [...cloudRefreshChanges.failed, ...(cloudChanges?.failed ?? [])];
|
|
818
|
+
const workspaceVersionUpdates = mergeWorkspaceVersionUpdates(
|
|
819
|
+
cloudWorkspaceUpdates.updated,
|
|
820
|
+
inferredWorkspaceVersionUpdates(activeWorkspace, workspaceResult?.previous),
|
|
821
|
+
);
|
|
693
822
|
const cloudChangeSummary = (
|
|
694
|
-
|
|
823
|
+
workspaceVersionUpdates.length > 0
|
|
695
824
|
|| cloudWorkspaceUpdates.failed.length > 0
|
|
696
825
|
|| cloudRefreshChanges.downloaded.length > 0
|
|
697
826
|
|| (cloudChanges?.uploaded.length ?? 0) > 0
|
|
698
827
|
|| (cloudChanges?.skipped.length ?? 0) > 0
|
|
699
828
|
|| cloudConflicts.length > 0
|
|
700
829
|
|| cloudFailures.length > 0
|
|
830
|
+
|| cloudPresence.deactivated.length > 0
|
|
831
|
+
|| cloudPresence.restored.length > 0
|
|
701
832
|
) ? {
|
|
702
|
-
workspace_updated:
|
|
833
|
+
workspace_updated: workspaceVersionUpdates,
|
|
703
834
|
workspace_update_failed: cloudWorkspaceUpdates.failed,
|
|
704
835
|
downloaded: cloudRefreshChanges.downloaded,
|
|
705
836
|
uploaded: cloudChanges?.uploaded ?? [],
|
|
706
837
|
skipped: cloudChanges?.skipped ?? [],
|
|
707
838
|
conflicts: cloudConflicts,
|
|
708
839
|
failed: cloudFailures,
|
|
840
|
+
deactivated: cloudPresence.deactivated,
|
|
841
|
+
restored: cloudPresence.restored,
|
|
709
842
|
unchanged: cloudChanges?.unchanged ?? [],
|
|
710
843
|
} : undefined;
|
|
711
844
|
const selectionRequired = pendingCapabilitySelections(workspaceDir, profile);
|
|
@@ -737,6 +870,8 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
737
870
|
description: localized.description,
|
|
738
871
|
source: entry.source,
|
|
739
872
|
strategy_type: classifyStrategyLifecycle(readFileSync(source.sourcePath, 'utf8')),
|
|
873
|
+
...(source.management.versionNumber ? { version_number: source.management.versionNumber,
|
|
874
|
+
version_description: source.management.versionDescription ?? '' } : {}),
|
|
740
875
|
};
|
|
741
876
|
}),
|
|
742
877
|
perceptions: perceptions.map((entry) => {
|
|
@@ -771,5 +906,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
771
906
|
configuration_warnings: compactConfigurationWarnings(configurationWarnings),
|
|
772
907
|
participation: compactParticipation(participation),
|
|
773
908
|
}, null, 2));
|
|
909
|
+
};
|
|
910
|
+
await renderFinalContext();
|
|
774
911
|
});
|
|
775
912
|
}
|