@myclaw163/clawclaw-cli 0.9.1 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/QUICKSTART_OTHER.md +5 -5
- package/README.md +7 -8
- package/bin/clawclaw-channel.mjs +2 -2
- package/bin/clawclaw-cli.mjs +2 -2
- package/docs/configuration.md +25 -99
- package/docs/custom-modules/README.md +27 -40
- package/docs/custom-modules/api-reference.md +132 -273
- package/docs/custom-modules/behavior.md +185 -75
- package/docs/custom-modules/examples/auto-escape.ts +41 -0
- package/docs/custom-modules/examples/go-to-point.ts +11 -11
- package/docs/custom-modules/examples/nearby-reflex.ts +22 -0
- package/docs/custom-modules/examples/task-reminder.ts +4 -5
- package/docs/custom-modules/perception.md +46 -806
- package/docs/custom-modules/skill.md +1 -1
- package/docs/desktop-event-push.md +3 -3
- package/docs/runtime/README.md +18 -19
- package/docs/runtime/agent-notifications.md +31 -12
- package/docs/runtime/behavior-runtime.md +54 -48
- package/docs/runtime/components-and-boundaries.md +87 -137
- package/docs/runtime/events-and-state.md +52 -17
- package/docs/runtime/framework-package.md +73 -0
- package/docs/runtime/official-perception-modules.md +5 -5
- package/docs/runtime/owner-lifecycle-and-observability.md +6 -6
- package/docs/runtime/short-commands-and-capabilities.md +8 -9
- package/docs/user-guide/README.md +12 -9
- package/docs/user-guide/api-reference.md +132 -180
- package/docs/user-guide/behavior.md +175 -65
- package/docs/user-guide/installation.md +7 -7
- package/docs/user-guide/perception.md +46 -789
- package/docs/user-guide/skill.md +1 -1
- package/package.json +24 -9
- package/scripts/check-framework-boundaries.mjs +27 -0
- package/scripts/check-skill-command-surface.mjs +9 -14
- package/scripts/install-local-runtime.mjs +35 -0
- package/scripts/qa-install.mjs +105 -0
- package/skills/clawclaw/SKILL.md +50 -48
- package/skills/clawclaw/references/BEHAVIORS.md +45 -65
- package/skills/clawclaw/references/CHANNELS.md +2 -2
- package/skills/clawclaw/references/COMMANDS.md +65 -87
- package/skills/clawclaw/references/CUSTOM-BEHAVIOR-DEVELOPMENT.md +185 -75
- package/skills/clawclaw/references/CUSTOM-MODULE-API.md +145 -198
- package/skills/clawclaw/references/CUSTOM-MODULES.md +28 -29
- package/skills/clawclaw/references/CUSTOM-PERCEPTION-DEVELOPMENT.md +46 -811
- package/skills/clawclaw/references/CUSTOM-SKILL-DEVELOPMENT.md +1 -1
- package/skills/clawclaw/references/HUB.md +1 -1
- package/skills/clawclaw/references/STREAM.md +8 -8
- package/skills/clawclaw/references/TACTICS.md +1 -1
- package/src/channel/claude-channel-ipc-server.ts +1 -0
- package/src/cli.ts +4 -2
- package/src/commands/behavior.ts +49 -104
- package/src/commands/capability.ts +3 -3
- package/src/commands/load.ts +18 -25
- package/src/commands/module-runtime-control.ts +113 -0
- package/src/commands/perception.ts +23 -4
- package/src/commands/strategy.ts +2 -0
- package/src/commands/trigger.ts +1 -1
- package/src/lib/capability-load-diagnostics.ts +3 -3
- package/src/lib/perception-config.ts +18 -6
- package/src/lib/runtime-cadence-config.ts +16 -0
- package/src/lib/workspace-runtime-lock.ts +3 -46
- package/src/pipeline/canonical-event-presentation.ts +23 -124
- package/src/pipeline/event-format.ts +12 -21
- package/src/pipeline/event-hints.ts +6 -6
- package/src/pipeline/game-sync-event-normalization.ts +57 -63
- package/src/runtime/clawclaw/behavior-decision.ts +7 -3
- package/src/runtime/clawclaw/behavior-input.ts +8 -4
- package/src/runtime/clawclaw/behavior-observation-memory.ts +3 -2
- package/src/runtime/clawclaw/behavior-read-api.ts +4 -0
- package/src/runtime/clawclaw/behavior-reflex-control.ts +74 -0
- package/src/runtime/clawclaw/notification-policy.ts +42 -0
- package/src/runtime/clawclaw/notification-turn.ts +19 -0
- package/src/runtime/clawclaw/observation-frame-projector.ts +3 -3
- package/src/runtime/clawclaw/owner.ts +67 -8
- package/src/runtime/clawclaw/perception-module-manifest.ts +22 -8
- package/src/runtime/clawclaw/perception-strategy-names.ts +17 -0
- package/src/runtime/clawclaw/persistence-compatibility.ts +36 -0
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +3 -3
- package/src/runtime/clawclaw/plugins/assembly.ts +29 -41
- package/src/runtime/clawclaw/plugins/behavior/activation-manager.ts +1 -482
- package/src/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +17 -186
- package/src/runtime/clawclaw/plugins/behavior/behavior-catalog.ts +2 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-instance-snapshot.ts +1 -123
- package/src/runtime/clawclaw/plugins/behavior/behavior-normalization.ts +3 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +126 -1707
- package/src/runtime/clawclaw/plugins/behavior/behavior-runner.ts +13 -271
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +2 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.ts +8 -0
- package/src/runtime/clawclaw/plugins/behavior/control-driver.ts +3 -180
- package/src/runtime/clawclaw/plugins/behavior/thread-behavior-executor.ts +13 -960
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-plugin.ts +9 -107
- package/src/runtime/clawclaw/plugins/derived-event/derived-event-rules.ts +5 -4
- package/src/runtime/clawclaw/plugins/derived-event/reminder-plugin.ts +27 -17
- package/src/runtime/clawclaw/plugins/derived-event/reminder-runner.ts +1 -0
- package/src/runtime/clawclaw/plugins/derived-event/state-change-rules.ts +84 -0
- package/src/runtime/clawclaw/plugins/derived-event/task-change-tracker.ts +1 -0
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +4 -4
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.ts +9 -97
- package/src/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.ts +8 -343
- package/src/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.ts +60 -572
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +6 -434
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.ts +1 -266
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-plugin.ts +6 -161
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-presentation.ts +4 -23
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +49 -752
- package/src/runtime/clawclaw/plugins/perception/map-concurrent.ts +1 -0
- package/src/runtime/clawclaw/plugins/perception/notification-content.ts +60 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-plugin.ts +136 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-runner.ts +13 -0
- package/src/runtime/clawclaw/plugins/perception/perception-module-worker.ts +13 -24
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +19 -8
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +23 -15
- package/src/runtime/clawclaw/plugins/perception/task-baseline.ts +29 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +8 -103
- package/src/runtime/clawclaw/plugins/system-perception/rule-runner.ts +107 -0
- package/src/runtime/clawclaw/plugins/system-perception/system-perceptions.ts +107 -0
- package/src/runtime/clawclaw/plugins/trigger/contracts.ts +3 -1
- package/src/runtime/clawclaw/plugins/trigger/trigger-module-loader.ts +5 -2
- package/src/runtime/clawclaw/plugins/trigger/trigger-plugin.ts +69 -13
- package/src/runtime/clawclaw/plugins/trigger/trigger-thread-pool.ts +13 -1
- package/src/runtime/clawclaw/plugins/trigger/trigger-thread-worker.ts +4 -0
- package/src/runtime/clawclaw/reaction-behavior-resolution.ts +1 -23
- package/src/runtime/clawclaw/reaction-manifest.ts +18 -12
- package/src/runtime/clawclaw/reminder-manifest.ts +5 -2
- package/src/runtime/clawclaw/runtime-cadence.ts +24 -0
- package/src/runtime/clawclaw/runtime-state.ts +12 -1
- package/src/runtime/clawclaw/runtime.ts +11 -3
- package/src/runtime/clawclaw/strategy-memory-rpc.ts +1 -0
- package/src/runtime/clawclaw/strategy-memory.ts +1 -0
- package/src/runtime/clawclaw-event-catalog.ts +17 -17
- package/src/runtime/framework/action-diagnostics.ts +3 -83
- package/src/runtime/framework/capability-registry.ts +2 -395
- package/src/runtime/framework/contracts.ts +2 -144
- package/src/runtime/framework/control/control-scheduler.ts +2 -1268
- package/src/runtime/framework/control/domain-set.ts +2 -81
- package/src/runtime/framework/control/index.ts +1 -3
- package/src/runtime/framework/control/types.ts +2 -191
- package/src/runtime/framework/control-coordinator.ts +2 -11
- package/src/runtime/framework/events/event-catalog.ts +2 -74
- package/src/runtime/framework/events/event-delivery-service.ts +2 -200
- package/src/runtime/framework/events/event-ingress.ts +2 -99
- package/src/runtime/framework/events/event-repository.ts +2 -82
- package/src/runtime/framework/events/index.ts +2 -7
- package/src/runtime/framework/events/memory-event-repository.ts +2 -1100
- package/src/runtime/framework/events/runtime-resume.ts +2 -20
- package/src/runtime/framework/events/sqlite-event-repository.ts +5 -2280
- package/src/runtime/framework/events/test-helpers.ts +1 -1
- package/src/runtime/framework/events/types.ts +2 -312
- package/src/runtime/framework/index.ts +3 -7
- package/src/runtime/framework/load-node-sqlite.ts +2 -17
- package/src/runtime/framework/mailbox/coalescer.ts +2 -83
- package/src/runtime/framework/mailbox/host-notification-sink.ts +2 -44
- package/src/runtime/framework/mailbox/identity.ts +2 -38
- package/src/runtime/framework/mailbox/index.ts +1 -7
- package/src/runtime/framework/mailbox/mailbox-dispatcher.ts +2 -282
- package/src/runtime/framework/mailbox/mailbox-repository.ts +2 -44
- package/src/runtime/framework/mailbox/notification-projector.ts +2 -65
- package/src/runtime/framework/mailbox/types.ts +2 -145
- package/src/runtime/framework/modules/runtime-module-loader-hooks.mjs +2 -154
- package/src/runtime/framework/modules/runtime-module-loader.ts +7 -51
- package/src/runtime/framework/modules/runtime-module-output.ts +2 -24
- package/src/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +3 -23
- package/src/runtime/framework/participation-manager.ts +2 -253
- package/src/runtime/framework/persistence/async-sqlite-persistence-worker.ts +2 -77
- package/src/runtime/framework/persistence/memory-first-persistence.ts +4 -489
- package/src/runtime/framework/plugins/contracts.ts +2 -388
- package/src/runtime/framework/plugins/index.ts +1 -4
- package/src/runtime/framework/plugins/runtime-event-identity.ts +2 -17
- package/src/runtime/framework/plugins/runtime-input-journal.ts +2 -866
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +2 -2060
- package/src/runtime/framework/runtime.ts +5 -1843
- package/src/runtime/framework/serial-task-queue.ts +2 -14
- package/src/runtime/framework/state/contracts.ts +2 -49
- package/src/runtime/framework/state/current-state-store.ts +2 -184
- package/src/runtime/framework/state/durable-agent-state-snapshot.ts +2 -209
- package/src/runtime/framework/state/freshness.ts +2 -72
- package/src/runtime/framework/state/history/contracts.ts +2 -158
- package/src/runtime/framework/state/history/history-writer.ts +2 -194
- package/src/runtime/framework/state/history/memory-state-history-repository.ts +2 -230
- package/src/runtime/framework/state/history/sqlite-state-history-repository.ts +2 -648
- package/src/runtime/framework/state/history/trajectory-projector.ts +2 -209
- package/src/runtime/framework/state/index.ts +1 -13
- package/src/runtime/framework/state/state-ingress.ts +2 -95
- package/src/runtime/framework/state/state-provider.ts +2 -62
- package/src/runtime/framework/state/types.ts +2 -155
- package/src/runtime/host-monitor-rate-gate.ts +1 -123
- package/src/runtime/mailbox-host-relay.ts +1 -326
- package/src/runtime/observability/detail-capture.ts +4 -108
- package/src/runtime/observability/process-timing.ts +2 -59
- package/src/runtime/observability/recorder.ts +2 -238
- package/src/runtime/observability/redaction.ts +2 -181
- package/src/runtime/observability/reporter.ts +2 -154
- package/src/runtime/observability/sinks.ts +2 -135
- package/src/runtime/observability/types.ts +2 -92
- package/src/runtime/owner-control.ts +45 -315
- package/src/runtime/parent-process-watch.ts +1 -51
- package/src/runtime/process-identity.ts +1 -72
- package/src/sdk/behavior-plugin/index.ts +13 -4
- package/src/sdk/index.ts +44 -3
- package/src/sdk/module-input/index.ts +5 -0
- package/src/sdk/perception-plugin/index.ts +9 -5
- package/src/sdk/perception-plugin/module.ts +25 -6
- package/src/sdk/perception-plugin/reaction.ts +1 -1
- package/src/sdk/perception-plugin/reminder-rules.ts +8 -42
- package/src/sdk/perception-plugin/reminder.ts +2 -1
- package/src/{runtime/clawclaw/plugins/source → sdk/perception-plugin}/task-change-tracker.ts +1 -2
- package/src/sdk/strategy-memory.ts +1 -0
- package/src/sdk/strategy-plugin/index.ts +36 -0
- package/src/sdk/trigger-plugin/index.ts +4 -3
- package/docs/custom-modules/examples/nearby-escape.ts +0 -56
- package/docs/custom-modules/examples/nearby-notice.ts +0 -36
- package/docs/custom-modules/trigger.md +0 -295
- package/src/runtime/clawclaw/behavior-activation-capability.ts +0 -21
- package/src/runtime/clawclaw/plugins/perception/reaction-plugin.ts +0 -233
- package/src/runtime/clawclaw/plugins/perception/reaction-runner.ts +0 -49
- package/src/runtime/clawclaw/plugins/perception/reaction-worker.ts +0 -26
- /package/src/runtime/clawclaw/plugins/{source → derived-event}/player-change-tracker.ts +0 -0
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
只有 `SKILL.md` 是必需的;附属目录按需创建。正文通过相对路径引用资料。脚本不是自动执行入口,必须说明用途、参数、依赖及何时运行。
|
|
19
19
|
|
|
20
|
-
先用 `ccl workspace` 确认工作目录。通过当前账号 `ccl
|
|
20
|
+
先用 `ccl workspace` 确认工作目录。通过当前账号 `ccl strategy list` 或 `ccl perception --list` 返回的 `working_copy_path` 定位同一账号的 `capabilities` 根目录;已有技能也可用 `ccl capability list` 查看登记信息。不能把其他账号的目录当作当前账号,不能猜测 account-hash;没有可确认的账号路径时,先确认路径再写入。`ccl data path` 只返回总 user-data 目录,不是当前账号技能目录。
|
|
21
21
|
|
|
22
22
|
不要直接在 `.agents/skills`、`.claude/skills`、`.codex/skills` 或 `.openclaw/skills` 下创建游戏技能实体。这些宿主入口由 CCL 建立目录链接,指向账号工作副本。不要修改 Hub revision cache,也不要覆盖官方 `clawclaw` 技能。修改现有技能应找到原工作副本,不另建同名副本。
|
|
23
23
|
|
|
@@ -29,7 +29,7 @@ ccl hub sync <type>/<resource-id> --json
|
|
|
29
29
|
|
|
30
30
|
## 0.8.x Strategy
|
|
31
31
|
|
|
32
|
-
Hub 对外仍叫 Strategy,CCL 内部按
|
|
32
|
+
Hub 对外仍叫 Strategy,CCL 内部按 Strategy API v3 加载。一个 Hub Strategy 是一个顶层 `.ts` 或 `.js` 文件:默认导出一个 `ClawclawStrategy` 子类,`static manifest.apiVersion` 必须为 `3`。多选表示多个 Strategy 可用;实际运行仍由 Agent 或默认 long 配置按 long/short/reflex 控制层启动。角色确定后默认 long 立即启动;缺失时只 warning 并 idle。
|
|
33
33
|
|
|
34
34
|
## Skill 更新
|
|
35
35
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# 流与事件查询
|
|
2
2
|
|
|
3
|
-
当前 CCL 的公开任务视图会结合破坏技能状态筛选:蟹的破坏技能未就绪(冷却、紧急任务期间或状态未知)时,未开始的破坏任务不作为 Agent、
|
|
3
|
+
当前 CCL 的公开任务视图会结合破坏技能状态筛选:蟹的破坏技能未就绪(冷却、紧急任务期间或状态未知)时,未开始的破坏任务不作为 Agent、Strategy 或任务查询的可选项。伪装任务和紧急维修保留;正在执行、已完成的条目用于结果确认,不能当作新任务重做。技能恢复 ready 后,仍分配的未完成破坏任务自动重新出现。后端原始完整分配清单仍保存在 Runtime 数据中,不因这个公开视图过滤而删除。
|
|
4
4
|
|
|
5
5
|
## 1. 一条长流、一种 Monitor 输出
|
|
6
6
|
|
|
7
|
-
`ccl start match`、`ccl start room`、`ccl start training`、`ccl join` 和 `ccl join room` 都会启动当前参与的唯一前台 Runtime 长进程。它在同一个进程生命周期中持有后端连接、事件、
|
|
7
|
+
`ccl start match`、`ccl start room`、`ccl start training`、`ccl join` 和 `ccl join room` 都会启动当前参与的唯一前台 Runtime 长进程。它在同一个进程生命周期中持有后端连接、事件、Strategy 控制栈和通知输出。不要为同一账号重复启动,也不要用轮询代替它。
|
|
8
8
|
|
|
9
9
|
收到第一条非 error 的 CCL NDJSON 通知且持久 Monitor 任务仍在运行后,当前 Monitor 即为健康通知流。后续主动通知和有界 backlog 唤醒都来自同一个 Monitor;普通事件受 60 秒滚动窗口约束,余量仍持久留给裸 `ccl events`,不是长流失效。等待下一次唤醒时不要再次调用 Monitor,也不要再次运行任何匹配/房间长流启动命令或加 `--force`。只有当前 Monitor 已明确结束或失败时才启动恢复流程。
|
|
10
10
|
|
|
11
|
-
Monitor 每条 stdout 通知最多 500 个字符,使用 `events:string[]`、`messages:string[]`、可选 `details_required:string[]` / `game_mode` / `backlog` / `guidance` / `truncated`,不重复投影批次级 `state` 或 `self`。每条 message 是可直接决策的事实;对应 Event 有 CCL-owned `hint` 时,再原样追加同一份 hint。多个短 Event 先拆成完整通知。普通主动输出有两个互不替代的边界:pending/claimed 容量限制瞬时积压,60 秒滚动窗口限制持续输出;任一窗口最多 12 个普通直推项目,余量转给裸 `ccl events` 的 durable consumer,并最多用 4 个额外 ordinary-only 提示唤醒 backlog。高频移动/路线/空间 visual 每 5 秒只主动保留最新一条,关键 visual 转折不受这条限频。击杀、死亡、有效目击、紧急任务 30 秒/20 秒倒计时、能力就绪/耗尽、
|
|
11
|
+
Monitor 每条 stdout 通知最多 500 个字符,使用 `events:string[]`、`messages:string[]`、可选 `details_required:string[]` / `game_mode` / `backlog` / `guidance` / `truncated`,不重复投影批次级 `state` 或 `self`。每条 message 是可直接决策的事实;对应 Event 有 CCL-owned `hint` 时,再原样追加同一份 hint。多个短 Event 先拆成完整通知。普通主动输出有两个互不替代的边界:pending/claimed 容量限制瞬时积压,60 秒滚动窗口限制持续输出;任一窗口最多 12 个普通直推项目,余量转给裸 `ccl events` 的 durable consumer,并最多用 4 个额外 ordinary-only 提示唤醒 backlog。高频移动/路线/空间 visual 每 5 秒只主动保留最新一条,关键 visual 转折不受这条限频。击杀、死亡、有效目击、紧急任务 30 秒/20 秒倒计时、能力就绪/耗尽、Strategy 终态(`behavior.completed` / `failed` / `cancelled` / `replaced`)、每次 `game_stream_disconnected` 和关键会议等 priority ≥80 的 Event,以及 `game_over` / `exile_game_over` / `game_over_recovered`,始终由 Monitor 直达且可顺带携带当前 backlog,不消耗普通预算。通知没有 `details_required`、`backlog` 或 `truncated:true` 时直接处理;每次出现任一标记时运行一次裸 `ccl events`。
|
|
12
12
|
|
|
13
13
|
Monitor 只负责“有事发生时唤醒 Agent”。内部 heartbeat、PID、HTTP 审计和诊断日志不会作为游戏通知推给 Agent。
|
|
14
14
|
|
|
@@ -48,7 +48,7 @@ Monitor 字段如下:
|
|
|
48
48
|
- `emergency_countdown_warning`:紧急任务剩余时间首次跨过 30 秒或 20 秒;同一任务每档一次,立即结合当前目标处理。
|
|
49
49
|
- `ability.ready` / `ability.remaining_uses_changed` / `ability.exhausted`:状态型能力刚变为可用、有限次数变化或耗尽;当前完整状态仍以随后查询边界的 `state.abilities[]` 为准。
|
|
50
50
|
|
|
51
|
-
生命周期和游戏事件走同一个 Event Repository,再由各 Mailbox Adapter 独立选择和确认。Monitor 与 Channels 接收 Agent 可见实时事实;裸 `ccl events` 的未读批次选择需要完整对象的 Event,也选择 Monitor 因瞬时队列压力、滚动窗口或高频 visual 限频而委托的 durable 普通/visual Event。Monitor 已完整发送的普通短 Event 不会在该批次中再次返回。Canonical Event Ledger 仍保留全部事实,`ccl events <事件名>` 也仍可按类型复查最新一条。Mailbox 按来源和 type 为登记过的 backend 或 CCL lifecycle/derived Event 增加可选英文模板 `hint`。未登记就没有 `hint`,普通
|
|
51
|
+
生命周期和游戏事件走同一个 Event Repository,再由各 Mailbox Adapter 独立选择和确认。Monitor 与 Channels 接收 Agent 可见实时事实;裸 `ccl events` 的未读批次选择需要完整对象的 Event,也选择 Monitor 因瞬时队列压力、滚动窗口或高频 visual 限频而委托的 durable 普通/visual Event。Monitor 已完整发送的普通短 Event 不会在该批次中再次返回。Canonical Event Ledger 仍保留全部事实,`ccl events <事件名>` 也仍可按类型复查最新一条。Mailbox 按来源和 type 为登记过的 backend 或 CCL lifecycle/derived Event 增加可选英文模板 `hint`。未登记就没有 `hint`,普通 Strategy 自定义输出和 Perception/Visual Event 不由这张表补 hint。Event 输出没有 `notice`,也没有批次 `next_step` 或 gameplay `guidance`;Monitor backlog 通知自带的 `guidance` 是该 Adapter 的有界委托提示。
|
|
52
52
|
|
|
53
53
|
## 3. `ccl events` v5
|
|
54
54
|
|
|
@@ -81,9 +81,9 @@ ccl events <事件名>
|
|
|
81
81
|
| `known_status.death_cause` | 已公开死因:`killed` 为被击杀,`exiled` 为会议放逐 |
|
|
82
82
|
| `known_status.reported_in_current_meeting` | 会议中为 `true` 表示此人是触发本次会议的被报告尸体;`false` 表示已知死亡但不是本次被报告尸体;缺失表示后端没有公开该判断 |
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
内置玩家感知在这些已知事实变化时生成 `players_changed`:Monitor 使用一句短摘要并列入 `details_required`,`ccl events` 详情给出本批 `changes[]` 和变化后的完整 `players[]`,整体替换此前玩家表。当前画面以持续收到的 visual Event 为准。
|
|
85
85
|
|
|
86
|
-
`state.emergency` 持续给出 `active`;激活时还可能给出 `task_name`、`room`、`x`、`y` 和实时 `remaining_secs`。倒计时本身保留在 State,不会每帧生成 Event。剩余时间首次跨过 30 秒、20
|
|
86
|
+
`state.emergency` 持续给出 `active`;激活时还可能给出 `task_name`、`room`、`x`、`y` 和实时 `remaining_secs`。倒计时本身保留在 State,不会每帧生成 Event。剩余时间首次跨过 30 秒、20 秒时,内置紧急任务感知各生成一次高优 `emergency_countdown_warning`;收到后立即按当前 State 和任务列表调整目标。
|
|
87
87
|
|
|
88
88
|
`state.abilities[]` 当前只包含权威 State 能完整描述的状态型能力;蟹破坏任务准入不再投影为独立能力:
|
|
89
89
|
|
|
@@ -108,7 +108,7 @@ Source 在这些已知事实变化时生成 `players_changed`:Monitor 使用
|
|
|
108
108
|
|
|
109
109
|
不要在紧急任务结束时本地清除冷却;始终等待下一次服务端 `state.crab_sabotage`。原始 `task_interrupted` 供模块读取,表示自己的破坏任务被队友触发紧急任务打断,任务未消耗。任务感知可生成 `reminder.task`(kind:interrupted)通知 Agent;任务现状以 State 为准。
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
原始 `task_*` 供内部模块读取,不再生产公共 `tasks_changed`;Agent 的 `reminder.task` 来自内置任务感知或已装配的社区任务感知。提醒偏好不会影响 State:需要当前任务列表时,读取 `ccl events` 返回的 `state.you.tasks`。Agent 和 Strategy 不自行发 HTTP,也不从零散历史事件拼当前任务列表。
|
|
112
112
|
|
|
113
113
|
`ccl events --backlog` 不新建查询边界,只读取调用时已经 ready 的未读详情和 Monitor 委托余量。旧 participation session 不补发。
|
|
114
114
|
|
|
@@ -122,7 +122,7 @@ ccl events
|
|
|
122
122
|
|
|
123
123
|
## 4. 退出与崩溃恢复
|
|
124
124
|
|
|
125
|
-
正常退出参与时使用 `ccl game quit`,不要用宿主任务强杀代替后端退出。读取命令的结构化结果,并结合长流后续的 `session_left`、`quit_failed` 或结束状态确认结果。停止或结束承载长流的宿主任务会同时停止本地 runtime、连接和
|
|
125
|
+
正常退出参与时使用 `ccl game quit`,不要用宿主任务强杀代替后端退出。读取命令的结构化结果,并结合长流后续的 `session_left`、`quit_failed` 或结束状态确认结果。停止或结束承载长流的宿主任务会同时停止本地 runtime、连接和 Strategy,但不等于后端已经接受退出。房间对局返回 `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 保持运行。
|
|
126
126
|
|
|
127
127
|
只有当前 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:
|
|
128
128
|
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
|
|
59
59
|
目击凶案且决定报告时,优先报尸再在会议中发言;是否报告仍按身份目标和风险判断:
|
|
60
60
|
|
|
61
|
-
1. 使用本次参与有效的 `ccl
|
|
61
|
+
1. 使用本次参与有效的 `ccl strategy list`,尚未查询或清单失效时先刷新;若存在明确支持报告尸体且 loadable 的模块,按已返回的准确输入字段启动 short,缺少详情时再查 `strategy info`,座位参数从本局玩家表填 1-10 的 JSON 数字。目录没有合适模块就不能用 Strategy 代办。启动返回 `accepted` 不表示已报告;只有后续 `behavior.completed` 加权威会议 Event 才证明报告成功(wander speech 不算正式报尸)
|
|
62
62
|
2. 会议中 **斩钉截铁+完整逻辑链** 指认凶手
|
|
63
63
|
3. 例:"我亲眼看见X号在Y房间杀了Z。当时我正好在隔壁做任务,听到动静过去一看——X号正对Z动手。X号在之前的发言里说自己没去过Y房间?那他为什么会在现场?"
|
|
64
64
|
|
package/src/cli.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from './commands/communication.js';
|
|
16
16
|
import { createEventsCommand } from './commands/events.js';
|
|
17
17
|
import { createBehaviorCommand } from './commands/behavior.js';
|
|
18
|
+
import { createStrategyCommand } from './commands/strategy.js';
|
|
18
19
|
import { createTriggerCommand } from './commands/trigger.js';
|
|
19
20
|
import { createAccountCommand } from './commands/account.js';
|
|
20
21
|
import { createPeekCommand } from './commands/peek.js';
|
|
@@ -52,8 +53,9 @@ program.addCommand(createSpeakCommand());
|
|
|
52
53
|
program.addCommand(createVoteCommand());
|
|
53
54
|
program.addCommand(createAsideCommand());
|
|
54
55
|
program.addCommand(createEventsCommand());
|
|
55
|
-
program.addCommand(
|
|
56
|
-
program.addCommand(
|
|
56
|
+
program.addCommand(createStrategyCommand());
|
|
57
|
+
program.addCommand(createBehaviorCommand(), { hidden: true });
|
|
58
|
+
program.addCommand(createTriggerCommand(), { hidden: true });
|
|
57
59
|
program.addCommand(createStartCommand());
|
|
58
60
|
program.addCommand(createJoinCommand());
|
|
59
61
|
program.addCommand(createGameCommand());
|
package/src/commands/behavior.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runOwnerCommand } from './module-runtime-control.js';
|
|
1
2
|
import { Command, InvalidArgumentError, Option } from 'commander';
|
|
2
3
|
import { AuthStore, type AuthProfile } from '../lib/auth.js';
|
|
3
4
|
import {
|
|
@@ -148,102 +149,6 @@ function sourceEntry(
|
|
|
148
149
|
};
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
function ownerFailure(
|
|
152
|
-
response: OwnerControlResponse | null,
|
|
153
|
-
code: string,
|
|
154
|
-
fallbackMessage: string,
|
|
155
|
-
): ShortCommandOperationResult {
|
|
156
|
-
return {
|
|
157
|
-
kind: 'local_failure',
|
|
158
|
-
source: 'owner',
|
|
159
|
-
error: {
|
|
160
|
-
code: String(response?.code ?? response?.error ?? code),
|
|
161
|
-
message: String(response?.message ?? response?.error ?? fallbackMessage),
|
|
162
|
-
...(response?.details === undefined ? {} : { details: response.details }),
|
|
163
|
-
},
|
|
164
|
-
presentation: { guidance: response === null ? OWNER_RUNTIME_GUIDANCE : undefined },
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async function runOwnerCommand(
|
|
169
|
-
command: string,
|
|
170
|
-
type: OwnerControlType,
|
|
171
|
-
payload: Readonly<Record<string, unknown>>,
|
|
172
|
-
scoped: boolean,
|
|
173
|
-
dependencies: BehaviorCommandDependencies,
|
|
174
|
-
): Promise<void> {
|
|
175
|
-
const runner = new ShortCommandRunner();
|
|
176
|
-
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
177
|
-
const send = dependencies.sendOwnerControlRequest ?? sendProfileOwnerControlRequest;
|
|
178
|
-
const io = dependencies.io ?? processIo;
|
|
179
|
-
await runner.run({
|
|
180
|
-
descriptor: {
|
|
181
|
-
command,
|
|
182
|
-
service: 'clawclaw-game-owner',
|
|
183
|
-
operation: type,
|
|
184
|
-
sensitivePolicy: {
|
|
185
|
-
sensitiveValues: profile ? [profile.apiKey] : [],
|
|
186
|
-
sensitiveFieldNames: ['api_key', 'apiKey', 'token', 'authorization'],
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
io,
|
|
190
|
-
operation: async (): Promise<ShortCommandOperationResult> => {
|
|
191
|
-
if (!profile) {
|
|
192
|
-
return {
|
|
193
|
-
kind: 'local_failure',
|
|
194
|
-
source: 'local',
|
|
195
|
-
error: {
|
|
196
|
-
code: 'NO_ACTIVE_ACCOUNT',
|
|
197
|
-
message: 'No active account. Run `ccl account register` or switch accounts first.',
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
let requestPayload: Record<string, unknown> = { ...payload };
|
|
202
|
-
if (scoped) {
|
|
203
|
-
let snapshot: OwnerControlResponse | null;
|
|
204
|
-
try {
|
|
205
|
-
snapshot = await send(profile, 'snapshot');
|
|
206
|
-
} catch (error) {
|
|
207
|
-
return {
|
|
208
|
-
kind: 'transport_failure',
|
|
209
|
-
error: {
|
|
210
|
-
code: 'OWNER_UNAVAILABLE',
|
|
211
|
-
message: error instanceof Error ? error.message : String(error),
|
|
212
|
-
},
|
|
213
|
-
presentation: { guidance: OWNER_RUNTIME_GUIDANCE },
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
if (!snapshot?.ok || snapshot.scope === undefined) {
|
|
217
|
-
return ownerFailure(snapshot, 'NO_GAME_START_OWNER', OWNER_RUNTIME_GUIDANCE);
|
|
218
|
-
}
|
|
219
|
-
requestPayload = { expected_scope: snapshot.scope, ...requestPayload };
|
|
220
|
-
}
|
|
221
|
-
let response: OwnerControlResponse | null;
|
|
222
|
-
try {
|
|
223
|
-
response = await send(profile, type, requestPayload, OWNER_CONTROL_TIMEOUT_MS);
|
|
224
|
-
} catch (error) {
|
|
225
|
-
return {
|
|
226
|
-
kind: 'transport_failure',
|
|
227
|
-
error: {
|
|
228
|
-
code: 'OWNER_UNAVAILABLE',
|
|
229
|
-
message: error instanceof Error ? error.message : String(error),
|
|
230
|
-
},
|
|
231
|
-
presentation: { guidance: OWNER_RUNTIME_GUIDANCE },
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
if (!response?.ok) {
|
|
235
|
-
return ownerFailure(response, `${type.toUpperCase()}_REJECTED`, `The owner rejected ${type}.`);
|
|
236
|
-
}
|
|
237
|
-
const { ok: _ok, type: _type, ...value } = response;
|
|
238
|
-
return {
|
|
239
|
-
kind: 'local_success',
|
|
240
|
-
source: 'owner',
|
|
241
|
-
value: Object.keys(value).length > 0 ? value : { status: 'ok' },
|
|
242
|
-
};
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
152
|
async function tryApplyRuntimeConfig(
|
|
248
153
|
type: 'behavior_fallback' | 'behavior_idle',
|
|
249
154
|
payload: Readonly<Record<string, unknown>>,
|
|
@@ -337,8 +242,13 @@ function inventorySources(
|
|
|
337
242
|
}
|
|
338
243
|
|
|
339
244
|
export function createBehaviorCommand(dependencies: BehaviorCommandDependencies = {}): Command {
|
|
340
|
-
|
|
341
|
-
|
|
245
|
+
return createStrategyControlCommand('behavior', dependencies);
|
|
246
|
+
}
|
|
247
|
+
export function createStrategyCommand(dependencies: BehaviorCommandDependencies = {}): Command {
|
|
248
|
+
return createStrategyControlCommand('strategy', dependencies);
|
|
249
|
+
}
|
|
250
|
+
function createStrategyControlCommand(commandName: 'behavior' | 'strategy', dependencies: BehaviorCommandDependencies): Command {
|
|
251
|
+
const behavior = new Command(commandName)
|
|
342
252
|
.description('Discover, configure, and run long or short Behaviors')
|
|
343
253
|
.addHelpText('after', () => {
|
|
344
254
|
const workspaceDir = getWorkspaceDir();
|
|
@@ -346,7 +256,7 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
346
256
|
const directory = profile
|
|
347
257
|
? getUserDataAccountBehaviorsDir(workspaceDir, profile)
|
|
348
258
|
: '<active-account>/capabilities/behaviors';
|
|
349
|
-
return `\
|
|
259
|
+
return `\n${commandName === 'strategy' ? 'Strategy' : 'Behavior'} modules:\n Place .ts or .js files in ${directory}\n Discovery reads static manifests without executing module code.\n`;
|
|
350
260
|
});
|
|
351
261
|
behavior.addCommand(new Command('rename')
|
|
352
262
|
.description('Rename one equipped Behavior operation for the active account')
|
|
@@ -475,7 +385,7 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
475
385
|
if (!hub && gameplay.disabled_behaviors.includes(id)) {
|
|
476
386
|
throw new Error(`Behavior '${id}' is disabled in user-data/gameplay.json.`);
|
|
477
387
|
}
|
|
478
|
-
await runOwnerCommand(
|
|
388
|
+
await runOwnerCommand(`ccl ${commandName} start`, 'behavior_start', {
|
|
479
389
|
behavior: id,
|
|
480
390
|
layer: opts.layer,
|
|
481
391
|
input: opts.input,
|
|
@@ -484,9 +394,11 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
484
394
|
}));
|
|
485
395
|
|
|
486
396
|
behavior.addCommand(new Command('status')
|
|
487
|
-
.description('Show
|
|
488
|
-
.
|
|
489
|
-
|
|
397
|
+
.description('Show execution stack and background watches, optionally for one Behavior')
|
|
398
|
+
.argument('[id]', 'Optional Behavior operation name')
|
|
399
|
+
.allowExcessArguments(false)
|
|
400
|
+
.action(async (id?: string) => {
|
|
401
|
+
await runOwnerCommand(`ccl ${commandName} status`, 'behavior_status', id ? { behavior: id } : {}, false, dependencies);
|
|
490
402
|
}));
|
|
491
403
|
|
|
492
404
|
behavior.addCommand(new Command('cancel')
|
|
@@ -494,7 +406,7 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
494
406
|
.argument('[activation-id]', 'Activation id')
|
|
495
407
|
.allowExcessArguments(false)
|
|
496
408
|
.action(async (activationId?: string) => {
|
|
497
|
-
await runOwnerCommand(
|
|
409
|
+
await runOwnerCommand(`ccl ${commandName} cancel`, 'behavior_cancel', {
|
|
498
410
|
...(activationId === undefined ? {} : { activation_id: activationId }),
|
|
499
411
|
}, true, dependencies);
|
|
500
412
|
}));
|
|
@@ -598,5 +510,38 @@ export function createBehaviorCommand(dependencies: BehaviorCommandDependencies
|
|
|
598
510
|
.action((opts: { role: ClawclawRoleId }) => removeFallback(opts.role, 'none')));
|
|
599
511
|
behavior.addCommand(fallback);
|
|
600
512
|
|
|
513
|
+
behavior.addCommand(new Command('watch')
|
|
514
|
+
.description('Re-enable automatic activation by equipped paired Perceptions in the current game (enabled by default)')
|
|
515
|
+
.argument('<id>', 'Equipped Behavior operation name')
|
|
516
|
+
.option('--input <json>', 'Optional execution parameter patch; perception parameters use perception update', value => parseJsonObject(value), {})
|
|
517
|
+
.allowExcessArguments(false).action(async (id: string, opts: { input: Record<string, unknown> }) => {
|
|
518
|
+
await runOwnerCommand(`ccl ${commandName} watch`, 'behavior_watch', { behavior: id, input: opts.input }, true, dependencies);
|
|
519
|
+
}));
|
|
520
|
+
behavior.addCommand(new Command('unwatch')
|
|
521
|
+
.description('Block automatic activation and cancel associated Reflex; perceptions keep observing and notifying')
|
|
522
|
+
.argument('<id>', 'Equipped Behavior operation name')
|
|
523
|
+
.allowExcessArguments(false).action(async (id: string) => {
|
|
524
|
+
await runOwnerCommand(`ccl ${commandName} unwatch`, 'behavior_unwatch', { behavior: id }, true, dependencies);
|
|
525
|
+
}));
|
|
526
|
+
behavior.addCommand(new Command('update')
|
|
527
|
+
.description('Patch this Behavior\'s match-local parameters and current executions; keep its watch switch')
|
|
528
|
+
.argument('<id>', 'Behavior operation name; with --activation, one activation ID')
|
|
529
|
+
.option('--activation', 'Update only the specified execution, without changing shared parameters')
|
|
530
|
+
.requiredOption('--input <json>', 'Parameter patch JSON object', value => parseJsonObject(value))
|
|
531
|
+
.allowExcessArguments(false).action(async (id: string, opts: { activation?: boolean; input: Record<string, unknown> }) => {
|
|
532
|
+
await runOwnerCommand(`ccl ${commandName} update`, 'behavior_update',
|
|
533
|
+
opts.activation ? { activation_id: id, input: opts.input } : { behavior: id, input: opts.input }, true, dependencies);
|
|
534
|
+
}));
|
|
535
|
+
if (commandName === 'behavior') behavior.alias('beh');
|
|
536
|
+
if (commandName === 'strategy') {
|
|
537
|
+
const present = (value: string) => value.replace(/Behaviors/g, 'Strategies').replace(/Behavior/g, 'Strategy');
|
|
538
|
+
const visit = (command: Command): void => {
|
|
539
|
+
command.description(present(command.description()));
|
|
540
|
+
for (const argument of command.registeredArguments) argument.description = present(argument.description);
|
|
541
|
+
for (const option of command.options) option.description = present(option.description);
|
|
542
|
+
for (const child of command.commands) visit(child);
|
|
543
|
+
};
|
|
544
|
+
visit(behavior);
|
|
545
|
+
}
|
|
601
546
|
return behavior;
|
|
602
547
|
}
|
|
@@ -136,11 +136,11 @@ function activeProfile(): AuthProfile {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
function parseRef(value: string): { type: CapabilityWorkspaceType; id: string } {
|
|
139
|
-
const match = /^(behavior|perception|persona|skill)\/(\S.{0,254})$/u.exec(value);
|
|
139
|
+
const match = /^(strategy|behavior|perception|persona|skill)\/(\S.{0,254})$/u.exec(value);
|
|
140
140
|
if (!match) {
|
|
141
|
-
throw new InvalidArgumentError('expected <
|
|
141
|
+
throw new InvalidArgumentError('expected <strategy|perception|persona|skill>/<id>');
|
|
142
142
|
}
|
|
143
|
-
const parsed = { type: match[1] as CapabilityWorkspaceType, id: match[2]! };
|
|
143
|
+
const parsed = { type: (match[1] === 'strategy' ? 'behavior' : match[1]) as CapabilityWorkspaceType, id: match[2]! };
|
|
144
144
|
if (parsed.type === 'skill' && parsed.id === 'clawclaw') {
|
|
145
145
|
throw new InvalidArgumentError('The official clawclaw Skill is managed by the installed CCL package');
|
|
146
146
|
}
|
package/src/commands/load.ts
CHANGED
|
@@ -613,34 +613,29 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
613
613
|
source: hubPerceptionIds.has(source.id) ? 'hub' : 'local', stage: 'selection', id: source.id,
|
|
614
614
|
reason: `perception_topic_conflict:${source.reminder!.topic}:${reminderTopics.get(source.reminder!.topic)!.join(',')}` });
|
|
615
615
|
}
|
|
616
|
+
const reflexBindings = enabledPerceptions.filter(isSupportedPerceptionSource).flatMap(source =>
|
|
617
|
+
Object.entries(source.module?.behaviors ?? {}).map(([key,binding]) => {
|
|
618
|
+
const id = resolveReactionBehavior(binding,behaviorEntries.map(entry => ({ id: entry.id,
|
|
619
|
+
declaredId: enabledBehaviors.find(source => source.id === entry.id)?.declaredId,
|
|
620
|
+
resourceId: entry.resource_id, loadable: entry.loadable })));
|
|
621
|
+
if (!id) configurationWarnings.push({ code: 'PERCEPTION_BEHAVIOR_NOT_LOADED',
|
|
622
|
+
perception_id: source.id, binding: key, behavior_name: binding.name,
|
|
623
|
+
message: `Equip the paired strategy ${binding.name}; perception observation and notifications remain available.` });
|
|
624
|
+
return { perception_id: source.id, binding: key, behavior_id: id ?? binding.name,
|
|
625
|
+
available: !!id, default_enabled: false,
|
|
626
|
+
...(id ? {} : { reason: 'behavior_not_loaded' }) };
|
|
627
|
+
}));
|
|
616
628
|
const perceptionEntry = (source: typeof enabledPerceptions[number]) => ({
|
|
617
629
|
id: source.id,
|
|
618
630
|
name: source.name,
|
|
619
631
|
description: source.description,
|
|
620
632
|
source: hubPerceptionIds.has(source.id) ? 'hub' : 'workspace',
|
|
621
633
|
...pluginApiVersionStatus('perception', expectedPerceptionApiVersion(source), source.apiVersion),
|
|
634
|
+
...(source.compatibilityError ? { loadable: false, compatibility_error: source.compatibilityError } : {}),
|
|
622
635
|
});
|
|
623
636
|
const perceptions = enabledPerceptions
|
|
624
637
|
.filter(source => isSupportedPerceptionSource(source) && !conflictingPerceptions.has(source.id))
|
|
625
638
|
.map(perceptionEntry);
|
|
626
|
-
const behaviorDependencies = new Map<string, Array<Record<string, unknown>>>();
|
|
627
|
-
const availableBehaviorIdsForReactions = new Set(behaviors.map(entry => entry.id));
|
|
628
|
-
const reactionCandidates = enabledBehaviors.map(source => ({ id: source.id, declaredId: source.declaredId,
|
|
629
|
-
resourceId: source.resourceId, loadable: availableBehaviorIdsForReactions.has(source.id) }));
|
|
630
|
-
for (const source of enabledPerceptions.filter(source => (source.reaction || source.module) && isSupportedPerceptionSource(source))) {
|
|
631
|
-
const bindings = Object.entries((source.module ?? source.reaction)!.behaviors ?? {}).map(([key, binding]) => {
|
|
632
|
-
const resolved = resolveReactionBehavior(binding, reactionCandidates);
|
|
633
|
-
if (!resolved) configurationWarnings.push({ code: 'PERCEPTION_BEHAVIOR_UNAVAILABLE',
|
|
634
|
-
perception_id: source.id, binding: key, behavior_name: binding.name,
|
|
635
|
-
...(binding.resourceId ? { preferred_resource_id: binding.resourceId } : {}),
|
|
636
|
-
reason: 'no_loaded_matching_behavior',
|
|
637
|
-
message: `Perception ${source.id} cannot activate ${binding.name}: no matching Behavior is loaded. Only this reaction is unavailable; other perception output and CCL continue. Equip a matching Behavior and run ccl load again; changes take effect in the next Runtime.` });
|
|
638
|
-
return { binding: key, name: binding.name, layer: binding.layer ?? 'reflex', available: !!resolved,
|
|
639
|
-
...(binding.resourceId ? { preferred_resource_id: binding.resourceId } : {}),
|
|
640
|
-
...(resolved ? { behavior_id: resolved } : {}) };
|
|
641
|
-
});
|
|
642
|
-
behaviorDependencies.set(source.id, bindings);
|
|
643
|
-
}
|
|
644
639
|
const incompatiblePerceptions = enabledPerceptions
|
|
645
640
|
.filter(source => !isSupportedPerceptionSource(source))
|
|
646
641
|
.map(perceptionEntry);
|
|
@@ -650,7 +645,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
650
645
|
'perception',
|
|
651
646
|
hubPerceptionIds.has(source.id) ? 'hub' : 'local',
|
|
652
647
|
source,
|
|
653
|
-
`perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? 'missing'}`,
|
|
648
|
+
source.compatibilityError ?? `perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? 'missing'}`,
|
|
654
649
|
));
|
|
655
650
|
}
|
|
656
651
|
const selectedLocalPerceptionPaths = new Set(localPerceptions.map(({ sourcePath }) => resolve(sourcePath)));
|
|
@@ -663,15 +658,13 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
663
658
|
'perception',
|
|
664
659
|
'local',
|
|
665
660
|
source,
|
|
666
|
-
`perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? 'missing'}`,
|
|
661
|
+
source.compatibilityError ?? `perception_api_version_unsupported:expected=${expectedPerceptionApiVersion(source)}:received=${source.apiVersion ?? 'missing'}`,
|
|
667
662
|
));
|
|
668
663
|
}
|
|
669
664
|
const disabledTriggers = new Set(gameplay.disabled_triggers);
|
|
670
665
|
const localTriggerDir = getUserDataAccountTriggersDir(workspaceDir, profile);
|
|
671
666
|
const triggerSources = listClawclawTriggerSources(localTriggerDir);
|
|
672
|
-
const enabledTriggers = triggerSources.filter((source) => !disabledTriggers.has(source.id)
|
|
673
|
-
&& !enabledPerceptions.some(perception => (perception.reaction || perception.module) && isSupportedPerceptionSource(perception)
|
|
674
|
-
&& (perception.declaredId ?? perception.id) === source.id));
|
|
667
|
+
const enabledTriggers = triggerSources.filter((source) => !disabledTriggers.has(source.id));
|
|
675
668
|
const triggerSourcePaths = new Set(triggerSources.map(({ sourcePath }) => resolve(sourcePath)));
|
|
676
669
|
let expectedLocalTriggers = enabledTriggers.length;
|
|
677
670
|
for (const path of listCapabilityModuleCandidates(localTriggerDir)) {
|
|
@@ -967,8 +960,8 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
967
960
|
name: localized.name,
|
|
968
961
|
description: source.description,
|
|
969
962
|
source: entry.source,
|
|
970
|
-
...(
|
|
971
|
-
|
|
963
|
+
...(reflexBindings.some(binding => binding.perception_id === entry.id)
|
|
964
|
+
? { reflex_bindings: reflexBindings.filter(binding => binding.perception_id === entry.id) } : {}),
|
|
972
965
|
};
|
|
973
966
|
}),
|
|
974
967
|
triggers: triggers.map((entry) => {
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { AuthStore, type AuthProfile } from '../lib/auth.js';
|
|
2
|
+
import { InvalidArgumentError } from 'commander';
|
|
3
|
+
import { sendProfileOwnerControlRequest, type OwnerControlResponse, type OwnerControlType } from '../runtime/owner-control.js';
|
|
4
|
+
import { ShortCommandRunner, type CommandIo, type ShortCommandOperationResult } from '../short-command/runner.js';
|
|
5
|
+
export interface ModuleRuntimeCommandDependencies {
|
|
6
|
+
activeProfile?: () => AuthProfile | null;
|
|
7
|
+
sendOwnerControlRequest?: typeof sendProfileOwnerControlRequest;
|
|
8
|
+
io?: CommandIo;
|
|
9
|
+
}
|
|
10
|
+
const OWNER_CONTROL_TIMEOUT_MS = 30000;
|
|
11
|
+
const OWNER_RUNTIME_GUIDANCE = 'Attach the foreground game Runtime with ccl join before changing runtime module settings.';
|
|
12
|
+
const processIo: CommandIo = { writeStdout: text => { process.stdout.write(text); }, setExitCode: code => { process.exitCode = code; } };
|
|
13
|
+
export function parseModuleInput(value: string): Record<string, unknown> {
|
|
14
|
+
let input: unknown;
|
|
15
|
+
try { input = JSON.parse(value); } catch { throw new InvalidArgumentError('input must be a JSON object'); }
|
|
16
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) throw new InvalidArgumentError('input must be a JSON object');
|
|
17
|
+
return input as Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
function ownerFailure(
|
|
20
|
+
response: OwnerControlResponse | null,
|
|
21
|
+
code: string,
|
|
22
|
+
fallbackMessage: string,
|
|
23
|
+
): ShortCommandOperationResult {
|
|
24
|
+
return {
|
|
25
|
+
kind: 'local_failure',
|
|
26
|
+
source: 'owner',
|
|
27
|
+
error: {
|
|
28
|
+
code: String(response?.code ?? response?.error ?? code),
|
|
29
|
+
message: String(response?.message ?? response?.error ?? fallbackMessage),
|
|
30
|
+
...(response?.details === undefined ? {} : { details: response.details }),
|
|
31
|
+
},
|
|
32
|
+
presentation: { guidance: response === null ? OWNER_RUNTIME_GUIDANCE : undefined },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function runOwnerCommand(
|
|
37
|
+
command: string,
|
|
38
|
+
type: OwnerControlType,
|
|
39
|
+
payload: Readonly<Record<string, unknown>>,
|
|
40
|
+
scoped: boolean,
|
|
41
|
+
dependencies: ModuleRuntimeCommandDependencies,
|
|
42
|
+
): Promise<void> {
|
|
43
|
+
const runner = new ShortCommandRunner();
|
|
44
|
+
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
45
|
+
const send = dependencies.sendOwnerControlRequest ?? sendProfileOwnerControlRequest;
|
|
46
|
+
const io = dependencies.io ?? processIo;
|
|
47
|
+
await runner.run({
|
|
48
|
+
descriptor: {
|
|
49
|
+
command,
|
|
50
|
+
service: 'clawclaw-game-owner',
|
|
51
|
+
operation: type,
|
|
52
|
+
sensitivePolicy: {
|
|
53
|
+
sensitiveValues: profile ? [profile.apiKey] : [],
|
|
54
|
+
sensitiveFieldNames: ['api_key', 'apiKey', 'token', 'authorization'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
io,
|
|
58
|
+
operation: async (): Promise<ShortCommandOperationResult> => {
|
|
59
|
+
if (!profile) {
|
|
60
|
+
return {
|
|
61
|
+
kind: 'local_failure',
|
|
62
|
+
source: 'local',
|
|
63
|
+
error: {
|
|
64
|
+
code: 'NO_ACTIVE_ACCOUNT',
|
|
65
|
+
message: 'No active account. Run `ccl account register` or switch accounts first.',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
let requestPayload: Record<string, unknown> = { ...payload };
|
|
70
|
+
if (scoped) {
|
|
71
|
+
let snapshot: OwnerControlResponse | null;
|
|
72
|
+
try {
|
|
73
|
+
snapshot = await send(profile, 'snapshot');
|
|
74
|
+
} catch (error) {
|
|
75
|
+
return {
|
|
76
|
+
kind: 'transport_failure',
|
|
77
|
+
error: {
|
|
78
|
+
code: 'OWNER_UNAVAILABLE',
|
|
79
|
+
message: error instanceof Error ? error.message : String(error),
|
|
80
|
+
},
|
|
81
|
+
presentation: { guidance: OWNER_RUNTIME_GUIDANCE },
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (!snapshot?.ok || snapshot.scope === undefined) {
|
|
85
|
+
return ownerFailure(snapshot, 'NO_GAME_START_OWNER', OWNER_RUNTIME_GUIDANCE);
|
|
86
|
+
}
|
|
87
|
+
requestPayload = { expected_scope: snapshot.scope, ...requestPayload };
|
|
88
|
+
}
|
|
89
|
+
let response: OwnerControlResponse | null;
|
|
90
|
+
try {
|
|
91
|
+
response = await send(profile, type, requestPayload, OWNER_CONTROL_TIMEOUT_MS);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
kind: 'transport_failure',
|
|
95
|
+
error: {
|
|
96
|
+
code: 'OWNER_UNAVAILABLE',
|
|
97
|
+
message: error instanceof Error ? error.message : String(error),
|
|
98
|
+
},
|
|
99
|
+
presentation: { guidance: OWNER_RUNTIME_GUIDANCE },
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (!response?.ok) {
|
|
103
|
+
return ownerFailure(response, `${type.toUpperCase()}_REJECTED`, `The owner rejected ${type}.`);
|
|
104
|
+
}
|
|
105
|
+
const { ok: _ok, type: _type, ...value } = response;
|
|
106
|
+
return {
|
|
107
|
+
kind: 'local_success',
|
|
108
|
+
source: 'owner',
|
|
109
|
+
value: Object.keys(value).length > 0 ? value : { status: 'ok' },
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { BUILTIN_PERCEPTION_NAMES } from '../runtime/clawclaw/plugins/system-perception/system-perceptions.js';
|
|
2
|
+
import { BUILTIN_PERCEPTION_PREFIX } from '../runtime/clawclaw/notification-policy.js';
|
|
3
|
+
import { runOwnerCommand, parseModuleInput, type ModuleRuntimeCommandDependencies } from './module-runtime-control.js';
|
|
1
4
|
import { Command } from 'commander';
|
|
2
5
|
import { AuthStore, type AuthProfile } from '../lib/auth.js';
|
|
3
6
|
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
@@ -23,9 +26,7 @@ import { capabilityEntryForPath, readCapabilityWorkspaceRegistry } from '../lib/
|
|
|
23
26
|
import { selectCapability } from '../lib/capability-selection.js';
|
|
24
27
|
import { renameCapabilityOperationWhenIdle } from '../lib/capability-operation-rename.js';
|
|
25
28
|
|
|
26
|
-
export interface PerceptionCommandDependencies {
|
|
27
|
-
activeProfile?: () => AuthProfile | null;
|
|
28
|
-
}
|
|
29
|
+
export interface PerceptionCommandDependencies extends ModuleRuntimeCommandDependencies {}
|
|
29
30
|
|
|
30
31
|
function activeProfile(dependencies: PerceptionCommandDependencies): AuthProfile {
|
|
31
32
|
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|
|
@@ -112,13 +113,14 @@ Perception modules:
|
|
|
112
113
|
runtime_source_path: source.sourcePath,
|
|
113
114
|
name: source.name,
|
|
114
115
|
description: source.description,
|
|
115
|
-
...(source.
|
|
116
|
+
...(source.module?.behaviors ? { behaviors: source.module.behaviors } : {}),
|
|
116
117
|
source: hubIds.has(source.id) ? 'hub' : 'local',
|
|
117
118
|
...pluginApiVersionStatus(
|
|
118
119
|
'perception',
|
|
119
120
|
expectedPerceptionApiVersion(source),
|
|
120
121
|
source.apiVersion,
|
|
121
122
|
),
|
|
123
|
+
...(source.compatibilityError ? { loadable: false, compatibility_error: source.compatibilityError } : {}),
|
|
122
124
|
disabled: hubIds.has(source.id)
|
|
123
125
|
? false
|
|
124
126
|
: disabled.has(source.id)
|
|
@@ -131,6 +133,8 @@ Perception modules:
|
|
|
131
133
|
}));
|
|
132
134
|
console.log(JSON.stringify({
|
|
133
135
|
perception_modules: installed,
|
|
136
|
+
builtin_perceptions: Object.entries(BUILTIN_PERCEPTION_NAMES).map(([id, name]) => ({
|
|
137
|
+
id: `${BUILTIN_PERCEPTION_PREFIX}${id}`, name, mandatory: true, configurable: false })),
|
|
134
138
|
ignored_disabled_ids: config.disabled_perception_modules
|
|
135
139
|
.filter((id) => !local.some((module) => module.id === id)),
|
|
136
140
|
}, null, 2));
|
|
@@ -138,6 +142,21 @@ Perception modules:
|
|
|
138
142
|
}
|
|
139
143
|
cmd.help();
|
|
140
144
|
});
|
|
145
|
+
cmd.addCommand(new Command('update')
|
|
146
|
+
.description('Patch an equipped perception configuration in the current game; observing and notifying continue')
|
|
147
|
+
.argument('<perception-id>')
|
|
148
|
+
.requiredOption('--input <json>', 'Configuration patch as a JSON object', parseModuleInput)
|
|
149
|
+
.allowExcessArguments(false)
|
|
150
|
+
.action(async (id: string, opts: { input: Record<string, unknown> }) => {
|
|
151
|
+
await runOwnerCommand('ccl perception update','perception_update',{ perception: id, input: opts.input },true,dependencies);
|
|
152
|
+
}));
|
|
153
|
+
cmd.addCommand(new Command('status')
|
|
154
|
+
.description('Inspect current perception configuration, observation health and strategy bindings')
|
|
155
|
+
.argument('[perception-id]')
|
|
156
|
+
.allowExcessArguments(false)
|
|
157
|
+
.action(async (id?: string) => {
|
|
158
|
+
await runOwnerCommand('ccl perception status','perception_status',id ? { perception: id } : {},false,dependencies);
|
|
159
|
+
}));
|
|
141
160
|
cmd.addCommand(new Command('rename')
|
|
142
161
|
.description('Rename one equipped Perception operation for the active account')
|
|
143
162
|
.argument('<current-id>', 'Current CCL operation name')
|
package/src/commands/trigger.ts
CHANGED
|
@@ -223,7 +223,7 @@ async function updateTrigger(
|
|
|
223
223
|
export function createTriggerCommand(dependencies: TriggerCommandDependencies = {}): Command {
|
|
224
224
|
const trigger = new Command('trigger')
|
|
225
225
|
.alias('trg')
|
|
226
|
-
.description('
|
|
226
|
+
.description('Configure legacy standalone Reflex triggers; new automatic reflexes use paired Perception and Behavior resources.')
|
|
227
227
|
.addHelpText('after', () => {
|
|
228
228
|
const workspaceDir = getWorkspaceDir();
|
|
229
229
|
const profile = (dependencies.activeProfile ?? (() => new AuthStore().getActive()))();
|