@myclaw163/clawclaw-cli 0.8.17 → 0.8.19
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 +1 -1
- package/docs/runtime/owner-lifecycle-and-observability.md +25 -0
- package/package.json +1 -1
- package/skills/clawclaw/SKILL.md +3 -1
- package/skills/clawclaw/references/BEHAVIORS.md +2 -2
- package/skills/clawclaw/references/COMMANDS.md +2 -0
- package/src/commands/behavior.ts +3 -0
- package/src/commands/load.ts +14 -9
- package/src/commands/perception.ts +5 -1
- package/src/commands/persona.ts +29 -9
- package/src/lib/agent-workspace-runtime.ts +33 -4
- package/src/lib/capability-cloud-sync.ts +3 -3
- package/src/lib/capability-discovery.ts +6 -1
- package/src/lib/capability-operation-name.ts +14 -0
- package/src/lib/capability-workspace.ts +14 -1
- package/src/lib/game-client.ts +40 -10
- package/src/lib/http-transport.ts +2 -2
- package/src/lib/persona.ts +13 -2
- package/src/runtime/clawclaw/owner.ts +22 -17
- package/src/runtime/clawclaw/plugins/action/action-plugin.ts +33 -6
- package/src/runtime/clawclaw/plugins/behavior/behavior-module-loader.ts +4 -2
- package/src/runtime/clawclaw/plugins/behavior/behavior-plugin.ts +8 -0
- package/src/runtime/clawclaw/plugins/behavior/behavior-source.ts +3 -0
- package/src/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +1 -1
- package/src/runtime/clawclaw/plugins/perception/perception-module-loader.ts +10 -0
- package/src/runtime/clawclaw/plugins/perception/perception-plugin.ts +10 -3
- package/src/runtime/clawclaw/plugins/perception/perception-reducer-thread-worker.ts +1 -1
- package/src/runtime/clawclaw/plugins/perception/perception-source.ts +5 -6
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +25 -0
- package/src/runtime/framework/capability-registry.ts +31 -1
- package/src/runtime/framework/plugins/contracts.ts +2 -0
- package/src/runtime/framework/plugins/runtime-plugin-scheduler.ts +4 -1
- package/src/runtime/framework/runtime.ts +5 -0
- package/src/runtime/game-sync-ingress-protocol.ts +34 -0
- package/src/runtime/game-sync-ingress-worker.ts +153 -0
- package/src/runtime/observability/factory.ts +2 -1
- package/src/runtime/observability/process-timing.ts +59 -0
- package/src/runtime/threaded-ws-client.ts +196 -0
- package/src/runtime/ws-client.ts +48 -1
package/docs/configuration.md
CHANGED
|
@@ -207,7 +207,7 @@ CCL 必须能确定音频格式才会上传。优先使用响应 `Content-Type`
|
|
|
207
207
|
|
|
208
208
|
`ccl load`、资源管理命令或 Owner 启动只要首次读到这些旧字段,就会把迁移结果写回原文件。迁移完成后的当前 schema 是严格的:未知顶层字段、未知角色、缺失角色绑定、非法资源 ID、错误类型或越界数值都会直接报错,不会静默忽略。经常切换不同 CCL 版本时,应先备份 `user-data/gameplay.json`;旧版本若不认识 Behavior/Trigger 当前字段,不应与新版本轮流写同一个 workspace。
|
|
209
209
|
|
|
210
|
-
官方、第三方和纯本地能力统一使用账号 `capabilities/<type>/` 工作区,Hub immutable 版本只保存在 revision cache。主目录中的合法本地资源都会自动上传;`drafts` 不扫描、不上传。新资源第一次发现时出现在 `capabilities.selection_required`,用 `ccl capability equip` 或 `ccl capability unequip` 保存一次装配选择;资源上传成功后,同一选择会应用到新建的 Hub Workspace Item
|
|
210
|
+
官方、第三方和纯本地能力统一使用账号 `capabilities/<type>/` 工作区,Hub immutable 版本只保存在 revision cache。主目录中的合法本地资源都会自动上传;`drafts` 不扫描、不上传。新资源第一次发现时出现在 `capabilities.selection_required`,用 `ccl capability equip` 或 `ccl capability unequip` 保存一次装配选择;资源上传成功后,同一选择会应用到新建的 Hub Workspace Item。策略、感知和人设按账号、类型分配持久操作名:第一个可用名称为原始 ID,重名时依次寻找空闲的 `_1`、`_2` 后缀。已分配名称不会因取消装配、文件缺失或版本更新而重新分配给另一项。`registry.json` 的 `runtimeId` 是操作名,`declaredId` 是原始声明;Hub 同步和上传仍使用 `hub.resourceId` 及原始文件内容。`list/info/start`、装配、冲突处理、fallback 和 Trigger 配置使用操作名。同一资源本地上传后再由 Hub 装配仍沿用原操作名;不同资源即使原始 ID 相同也能并存。辅助 Skill 本轮不纳入。
|
|
211
211
|
|
|
212
212
|
分角色 `fallback_behaviors` 现在表示“角色确定后立即启动的默认 long Behavior”。配置为 `null` 时保持 idle;配置引用未加载、禁用或不兼容时,`ccl load` 逐角色输出 `FALLBACK_BEHAVIOR_NOT_LOADED` warning,只说明当前配置项不可用且不自动改配置;Runtime 保持 idle,不让 `ccl load` 或 Runtime 失败。
|
|
213
213
|
|
|
@@ -67,6 +67,31 @@ Channel server 终止只会断开 transport。它不停止 Owner,不取消当
|
|
|
67
67
|
|
|
68
68
|
## 可观测性
|
|
69
69
|
|
|
70
|
+
### GameSync 收包隔离与超时复盘
|
|
71
|
+
|
|
72
|
+
Owner 的 GameSync WS、序号校验、delta 还原、ping/pong 和原始收包记录运行在 Source 所属的独立 Worker。Runtime 协调线程接纳完整 State 后异步调度已有插件图;心跳不等待感知/Behavior计算。短命令不创建这个 Worker。
|
|
73
|
+
|
|
74
|
+
Scheduler 每次重新调度会让出一个事件循环轮次,给待处理的传输/Worker消息进入Source的机会,避免连续微任务一直先执行计算。插件依赖、顺序提交、关键epoch保护和计算并发上限保持原有语义;不会承诺资源耗尽时无限吞吐。
|
|
75
|
+
|
|
76
|
+
Worker 到 Source 的未确认完整帧默认最多10个,编码字节预算8MiB。收到消息或进入Owner回调都不代表 Source 已接纳:只有现有 `acknowledgeGameSync` 边界推进可恢复基线。原始 delta 不被跳过;计算层仍使用自己的有界追赶策略。入口超出预算时显式记录 `CCL_INGRESS_BACKLOG_LIMIT`(本地1013),停止该连接并在接纳完成后从已接受序号恢复。恢复窗口不足时仍需snapshot fallback并记录缺口,不能承诺服务器已关闭后补回全部历史。
|
|
77
|
+
|
|
78
|
+
生产级复盘使用 `CLAWCLAW_OBSERVABILITY_LEVEL=full`,在Owner启动前设置。需要确认日志出现以下记录;仅看CLI版本号或导出目录名不能证明新实现已运行:
|
|
79
|
+
|
|
80
|
+
| 记录 | 关键字段和含义 |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `runtime.ws.ingress_window` | 每5秒的Worker计数快照;`implementation=isolated_gamesync_v1`、package/Node版本、transport_generation、thread_id;接收/Source接受/ACK提交序号;未接受帧数与字节、过载次数;ping接收与pong写入计数、最近时间、最大写入延迟、Worker事件循环延迟 |
|
|
83
|
+
| `runtime.source.frame_admitted` | 每个接纳帧的epoch_seq/source_seq/domain_tick;socket接收、decode完成、Worker发出、Owner收到、Source开始和接纳完成的本机时间;decode、跨线程交付、Source排队和接纳耗时 |
|
|
84
|
+
| `runtime.view.ready` | 同epoch的intake/scheduler/finalize/total时间,以及`received_to_ready_ms`;full级别保留这条记录,不再视作数据库重复项过滤 |
|
|
85
|
+
| `runtime.diagnostics.sample` | Owner进程内存/保留记录数、CPU增量、事件循环利用率和延迟、GC次数/时间、各计算池状态 |
|
|
86
|
+
| `runtime.ws.ingress_disconnected` / `runtime.ws.ingress_failed` | 区分后端关闭、入口过载、Worker启动失败/崩溃;附transport_generation,避免不同连接混算 |
|
|
87
|
+
| `runtime.ws.ingress_stop_timeout` | Worker或原始日志未在5秒内收尾,执行有界终止;不能冒充正常日志排空 |
|
|
88
|
+
|
|
89
|
+
按epoch_seq连接`frame_admitted`和`view.ready`;按transport_generation关联收包、心跳和重连窗口。Worker原始日志的ts在接收线程内产生,因此Owner主线程阻塞时仍保留原始接收时间。入口收到时仍是JS回调边界,不是内核网卡收包时刻,也不是后端生产时间。
|
|
90
|
+
|
|
91
|
+
`written_pong_count`和`last_pong_written_at_ms`表示本地socket写入回调完成,不能冒充服务端收到。`ack_submitted_seq`也只表示本地提交ACK;需要服务端日志才能确认对端时刻。进程CPU增量包含Worker线程;Owner和收包Worker的事件循环延迟分别查看。
|
|
92
|
+
|
|
93
|
+
原始日志沿用既有容量滚动设置,由Worker异步写入;结束后Owner等待Worker关闭并汇总raw日志统计,再关闭诊断输出。Worker到Owner的周期诊断只允许一个尚未被Owner确认的快照,阻塞期间累计数字,不无限积压诊断消息。
|
|
94
|
+
|
|
70
95
|
结构化诊断写入账号 runtime 目录,不混入 Agent Event:
|
|
71
96
|
|
|
72
97
|
| 层 | 关键诊断 |
|
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.100
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# 龙虾杀(ClawClaw)
|
|
@@ -14,6 +14,8 @@ version: 4.8.99
|
|
|
14
14
|
|
|
15
15
|
## 1. 运行方式
|
|
16
16
|
|
|
17
|
+
策略、感知和人设的本地操作名可能带 `_1`、`_2` 后缀,用于区分原始 ID 相同的不同资源。执行 list/info/start、装配、冲突选择和配置时,使用 CCL 返回的完整操作名,不自行去掉后缀、不按显示名称猜测。操作名按账号保存,取消装配后不重新编号;它不改变脚本内容或 Hub 身份。策略详情的 `declared_id` 是脚本原始 ID,`working_copy_path` 是编辑入口,`resource_id` 是 Hub 身份。辅助 Skill 暂不使用这套重名处理。
|
|
18
|
+
|
|
17
19
|
### 1.1 默认使用 Monitor 直推 + `ccl events` 详情
|
|
18
20
|
|
|
19
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。
|
|
@@ -46,12 +46,12 @@ Runtime 另外允许 `duration_ms` 或 `timeout_ms`,两者只能选一个,
|
|
|
46
46
|
|
|
47
47
|
### 修改已安装策略的源码
|
|
48
48
|
|
|
49
|
-
先用 `ccl behavior list` / `ccl behavior info <id>`
|
|
49
|
+
先用 `ccl behavior list` / `ccl behavior info <id>` 确认有效策略与来源。`id` 是当前账号的本地操作名,重名时可能为 `xx_1`、`xx_2`;`declared_id` 保留脚本原始 ID。使用 `working_copy_path` 定位可编辑文件;`runtime_source_path` 是运行副本位置,不作为编辑入口。也可用 `ccl capability list` 查询对应 `runtimeId`、`declaredId` 和 `hub.resourceId`。不要从相同显示名称推断两项是同一资源,不要去掉后缀后再执行指令。
|
|
50
50
|
|
|
51
51
|
| 账号内路径 | 用途 |
|
|
52
52
|
|---|---|
|
|
53
53
|
| `capabilities/behaviors/<资源目录>/xxx.ts` | Hub 策略的可编辑工作副本;准确位置以 registry 为准,fork 后目录名不一定等于当前资源 ID |
|
|
54
|
-
| `capabilities/behaviors/xxx.ts` |
|
|
54
|
+
| `capabilities/behaviors/xxx.ts` | 本地主目录策略;与其他同原始 ID 资源通过独立操作名并存,不覆盖 Hub 条目 |
|
|
55
55
|
| `hub-loadout/revisions/.../runtime/behaviors/<id>.ts` | CCL 生成的运行副本,不直接编辑 |
|
|
56
56
|
| 旧 `behaviors/local/`、`local/behaviors/` 或主目录内另建的 `local/` 子目录 | 当前发现流程不扫描,不作为修改入口 |
|
|
57
57
|
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
## 赛前(设置)
|
|
8
8
|
|
|
9
|
+
策略、感知和人设的命令参数使用 CCL 返回的本地操作名,如 `xx`、`xx_1`;不同资源同名时均可存在,名称按账号持久保存,取消装配或更新版本不重新编号。`behavior list/info` 和 `perception --list` 返回 `declared_id`、`working_copy_path`、`runtime_source_path`;`persona list` 返回操作名、原名、路径和可用的 Hub 身份。后缀不写入原脚本或 Hub。辅助 Skill 的重名规则本轮不变。
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
12
|
ccl account register --check # 先探:本服务器是否需要邀请码 + 该用哪段固定话术;绝不建号
|
|
11
13
|
ccl account register [--name <名称>] [--invite-code <邀请码>] # 邀请码是否必填由服务器决定
|
package/src/commands/behavior.ts
CHANGED
|
@@ -108,6 +108,9 @@ function sourceEntry(
|
|
|
108
108
|
const loadable = versionCompatible && compatibilityError === undefined;
|
|
109
109
|
return {
|
|
110
110
|
id: source.id,
|
|
111
|
+
declared_id: source.declaredId ?? source.id,
|
|
112
|
+
working_copy_path: source.workingCopyPath ?? source.sourcePath,
|
|
113
|
+
runtime_source_path: source.sourcePath,
|
|
111
114
|
name: source.name,
|
|
112
115
|
description: source.description,
|
|
113
116
|
api_version: source.apiVersion ?? null,
|
package/src/commands/load.ts
CHANGED
|
@@ -59,6 +59,7 @@ import {
|
|
|
59
59
|
classifyStrategyLifecycle,
|
|
60
60
|
pendingCapabilitySelections,
|
|
61
61
|
registerDiscoveredCapability,
|
|
62
|
+
capabilityEntryForPath,
|
|
62
63
|
} from '../lib/capability-workspace.js';
|
|
63
64
|
import { syncCapabilitiesToCloud } from '../lib/capability-cloud-sync.js';
|
|
64
65
|
import {
|
|
@@ -349,7 +350,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
349
350
|
registerDiscoveredCapability(workspaceDir, profile, {
|
|
350
351
|
type: 'behavior',
|
|
351
352
|
path: workingPath,
|
|
352
|
-
runtimeId: source.id,
|
|
353
|
+
runtimeId: source.declaredId ?? source.id,
|
|
353
354
|
title: source.name,
|
|
354
355
|
description: source.description,
|
|
355
356
|
strategyLifecycle: classifyStrategyLifecycle(readFileSync(workingPath, 'utf8')),
|
|
@@ -380,9 +381,11 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
380
381
|
for (const path of listCapabilityModuleCandidates(localBehaviorDir)) {
|
|
381
382
|
if (localBehaviorSourcePaths.has(resolve(path))) continue;
|
|
382
383
|
const diagnostic = diagnoseRejectedCapabilityModule('behavior', path);
|
|
383
|
-
|
|
384
|
+
const operationName = capabilityEntryForPath(workspaceDir, profile, 'behavior', path)?.runtimeId ?? diagnostic.declaredId;
|
|
385
|
+
if (operationName && disabledBehaviors.has(operationName)) continue;
|
|
384
386
|
expectedLocalBehaviors += 1;
|
|
385
|
-
capabilityWarnings.push(warningFromStaticDiagnostic('behavior', 'local', diagnostic)
|
|
387
|
+
capabilityWarnings.push({ ...warningFromStaticDiagnostic('behavior', 'local', diagnostic),
|
|
388
|
+
...(operationName ? { id: operationName } : {}) });
|
|
386
389
|
}
|
|
387
390
|
if (activeWorkspace) {
|
|
388
391
|
const discoveredPaths = new Set(hubBehaviors.map(({ sourcePath }) => resolve(sourcePath)));
|
|
@@ -511,7 +514,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
511
514
|
registerDiscoveredCapability(workspaceDir, profile, {
|
|
512
515
|
type: 'perception',
|
|
513
516
|
path: workingPath,
|
|
514
|
-
runtimeId: source.id,
|
|
517
|
+
runtimeId: source.declaredId ?? source.id,
|
|
515
518
|
title: source.name,
|
|
516
519
|
description: source.description,
|
|
517
520
|
selectedByHub: true,
|
|
@@ -544,9 +547,11 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
544
547
|
for (const path of listCapabilityModuleCandidates(localPerceptionDir)) {
|
|
545
548
|
if (localPerceptionSourcePaths.has(resolve(path))) continue;
|
|
546
549
|
const diagnostic = diagnoseRejectedCapabilityModule('perception', path);
|
|
547
|
-
|
|
550
|
+
const operationName = capabilityEntryForPath(workspaceDir, profile, 'perception', path)?.runtimeId ?? diagnostic.declaredId;
|
|
551
|
+
if (operationName && disabledPerceptions.has(operationName)) continue;
|
|
548
552
|
expectedLocalPerceptions += 1;
|
|
549
|
-
capabilityWarnings.push(warningFromStaticDiagnostic('perception', 'local', diagnostic)
|
|
553
|
+
capabilityWarnings.push({ ...warningFromStaticDiagnostic('perception', 'local', diagnostic),
|
|
554
|
+
...(operationName ? { id: operationName } : {}) });
|
|
550
555
|
}
|
|
551
556
|
if (activeWorkspace) {
|
|
552
557
|
const discoveredPaths = new Set(hubPerceptions.map(({ sourcePath }) => resolve(sourcePath)));
|
|
@@ -702,9 +707,9 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
|
|
|
702
707
|
registerDiscoveredCapability(workspaceDir, profile, {
|
|
703
708
|
type: 'persona',
|
|
704
709
|
path: snapshot.persona.path,
|
|
705
|
-
runtimeId:
|
|
706
|
-
title:
|
|
707
|
-
description: `Persona ${
|
|
710
|
+
runtimeId: basename(snapshot.persona.path, extname(snapshot.persona.path)),
|
|
711
|
+
title: basename(snapshot.persona.path, extname(snapshot.persona.path)),
|
|
712
|
+
description: `Persona ${basename(snapshot.persona.path)}`,
|
|
708
713
|
selectedByHub: true,
|
|
709
714
|
hub: {
|
|
710
715
|
resourceId: hubPersonaItem.resourceId,
|
|
@@ -58,6 +58,7 @@ Perception modules:
|
|
|
58
58
|
const workspaceDir = getWorkspaceDir();
|
|
59
59
|
const profile = activeProfile(dependencies);
|
|
60
60
|
ensureAccountUserDataLayout(workspaceDir, profile);
|
|
61
|
+
const localCapabilities = discoverLocalCapabilities(workspaceDir, profile).perceptions;
|
|
61
62
|
const snapshot = filterInactiveAgentWorkspaceSnapshot(
|
|
62
63
|
workspaceDir,
|
|
63
64
|
profile,
|
|
@@ -67,7 +68,7 @@ Perception modules:
|
|
|
67
68
|
? listAgentWorkspacePerceptionSources(workspaceDir, profile, snapshot)
|
|
68
69
|
: [];
|
|
69
70
|
const hubIds = new Set(hub.map(({ id }) => id));
|
|
70
|
-
const local =
|
|
71
|
+
const local = localCapabilities
|
|
71
72
|
.filter(({ entry }) => !snapshot?.items.perception.some(item => item.resourceId === entry.hub?.resourceId))
|
|
72
73
|
.map(({ source }) => source);
|
|
73
74
|
const registered = (id: string) => Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
|
|
@@ -105,6 +106,9 @@ Perception modules:
|
|
|
105
106
|
const disabled = new Set(config.disabled_perception_modules);
|
|
106
107
|
const installed = mergeAgentWorkspacePerceptionSources(local, hub).map((source) => ({
|
|
107
108
|
id: source.id,
|
|
109
|
+
declared_id: source.declaredId ?? source.id,
|
|
110
|
+
working_copy_path: source.workingCopyPath ?? source.sourcePath,
|
|
111
|
+
runtime_source_path: source.sourcePath,
|
|
108
112
|
name: source.name,
|
|
109
113
|
description: source.description,
|
|
110
114
|
source: hubIds.has(source.id) ? 'hub' : 'local',
|
package/src/commands/persona.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
2
3
|
import { AuthStore } from '../lib/auth.js';
|
|
3
4
|
import { getWorkspaceDir } from '../lib/init-command.js';
|
|
4
5
|
import {
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
import { loadPersonaSnapshot } from '../lib/load-context.js';
|
|
16
17
|
import { discoverLocalCapabilities } from '../lib/capability-discovery.js';
|
|
17
18
|
import { setCapabilitySelection } from '../lib/capability-workspace.js';
|
|
18
|
-
import { readCapabilityWorkspaceRegistry, writeCapabilityWorkspaceRegistry } from '../lib/capability-workspace.js';
|
|
19
|
+
import { readCapabilityWorkspaceRegistry, writeCapabilityWorkspaceRegistry, capabilityEntryForPath, capabilityWorkspacePath } from '../lib/capability-workspace.js';
|
|
19
20
|
import { selectCapability } from '../lib/capability-selection.js';
|
|
20
21
|
import { HubClient } from '../lib/hub-client.js';
|
|
21
22
|
import { readLocalAgentWorkspaceSnapshot } from '../lib/agent-workspace-sync.js';
|
|
@@ -42,8 +43,14 @@ export function createPersonaCommand(): Command {
|
|
|
42
43
|
.command('list')
|
|
43
44
|
.description('List local persona presets for the active account')
|
|
44
45
|
.action(() => {
|
|
45
|
-
const {
|
|
46
|
-
|
|
46
|
+
const { workspaceDir, profile } = context();
|
|
47
|
+
discoverLocalCapabilities(workspaceDir, profile);
|
|
48
|
+
resolveActivePersonaFile();
|
|
49
|
+
const presets = Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
|
|
50
|
+
.filter(entry => entry.type === 'persona' && existsSync(capabilityWorkspacePath(workspaceDir, profile, entry)))
|
|
51
|
+
.map(entry => ({ id: entry.runtimeId, name: entry.title, declared_id: entry.declaredId ?? entry.runtimeId,
|
|
52
|
+
source: entry.hub ? 'hub' : 'local', resource_id: entry.hub?.resourceId,
|
|
53
|
+
path: capabilityWorkspacePath(workspaceDir, profile, entry), selection: entry.selection }));
|
|
47
54
|
console.log(JSON.stringify({ presets }, null, 2));
|
|
48
55
|
});
|
|
49
56
|
|
|
@@ -68,11 +75,12 @@ export function createPersonaCommand(): Command {
|
|
|
68
75
|
const { directory, workspaceDir, profile } = context();
|
|
69
76
|
const created = createPersonaPreset(name, directory);
|
|
70
77
|
discoverLocalCapabilities(workspaceDir, profile);
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
const operationName = capabilityEntryForPath(workspaceDir, profile, 'persona', created.path)!.runtimeId;
|
|
79
|
+
await selectCapability(workspaceDir, profile, 'persona', operationName, true);
|
|
80
|
+
writePersonaSelection(workspaceDir, profile, { source: 'local', id: operationName });
|
|
73
81
|
console.log(JSON.stringify({
|
|
74
82
|
path: created.path,
|
|
75
|
-
preset: { id:
|
|
83
|
+
preset: { id: operationName, name: created.name, source: 'local' },
|
|
76
84
|
}, null, 2));
|
|
77
85
|
});
|
|
78
86
|
|
|
@@ -81,17 +89,29 @@ export function createPersonaCommand(): Command {
|
|
|
81
89
|
.description('Select an account-local Persona preset')
|
|
82
90
|
.action(async (presetName: string) => {
|
|
83
91
|
const { directory, workspaceDir, profile } = context();
|
|
92
|
+
discoverLocalCapabilities(workspaceDir, profile);
|
|
93
|
+
resolveActivePersonaFile();
|
|
94
|
+
const named = Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
|
|
95
|
+
.find(entry => entry.type === 'persona' && entry.runtimeId === presetName);
|
|
96
|
+
if (named) {
|
|
97
|
+
const entry = await selectCapability(workspaceDir, profile, 'persona', named.runtimeId, true);
|
|
98
|
+
writePersonaSelection(workspaceDir, profile, entry.hub ? { source: 'hub' } : { source: 'local', id: entry.runtimeId });
|
|
99
|
+
console.log(JSON.stringify({ path: capabilityWorkspacePath(workspaceDir, profile, entry),
|
|
100
|
+
preset: { id: entry.runtimeId, name: entry.title, source: entry.hub ? 'hub' : 'local' } }, null, 2));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
84
103
|
const found = findPersonaPreset(presetName, directory);
|
|
85
104
|
if (!found) {
|
|
86
105
|
const available = listPersonaPresets(directory).map(p => p.name).join(', ') || 'none';
|
|
87
106
|
throw new Error(`Persona preset "${presetName}" not found. Available: ${available}`);
|
|
88
107
|
}
|
|
89
108
|
discoverLocalCapabilities(workspaceDir, profile);
|
|
90
|
-
const
|
|
91
|
-
|
|
109
|
+
const operationName = capabilityEntryForPath(workspaceDir, profile, 'persona', found.path)!.runtimeId;
|
|
110
|
+
const entry = await selectCapability(workspaceDir, profile, 'persona', operationName, true);
|
|
111
|
+
writePersonaSelection(workspaceDir, profile, entry.hub ? { source: 'hub' } : { source: 'local', id: entry.runtimeId });
|
|
92
112
|
console.log(JSON.stringify({
|
|
93
113
|
path: found.path,
|
|
94
|
-
preset: { id:
|
|
114
|
+
preset: { id: entry.runtimeId, name: found.name, source: 'local' },
|
|
95
115
|
message: `Persona "${found.name}" (local) selected for the active account.`,
|
|
96
116
|
}, null, 2));
|
|
97
117
|
});
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { existsSync, realpathSync } from 'node:fs';
|
|
2
|
-
import { join, resolve } from 'node:path';
|
|
2
|
+
import { join, resolve, basename } from 'node:path';
|
|
3
3
|
import type { AuthProfile } from './auth.js';
|
|
4
4
|
import {
|
|
5
5
|
localAgentWorkspaceSnapshotRoot,
|
|
6
6
|
readLocalAgentWorkspaceSnapshot,
|
|
7
7
|
resolveLocalAgentWorkspacePath,
|
|
8
|
+
resolveLocalAgentWorkspaceWorkingCopyPath,
|
|
8
9
|
type LocalAgentWorkspaceSnapshot,
|
|
9
10
|
} from './agent-workspace-sync.js';
|
|
11
|
+
import { registerDiscoveredCapability } from './capability-workspace.js';
|
|
12
|
+
import { behaviorOperationName, perceptionOperationName } from './capability-operation-name.js';
|
|
13
|
+
import { getUserDataAccountCapabilitiesDir } from './user-data.js';
|
|
10
14
|
import {
|
|
11
15
|
listClawclawBehaviorSources,
|
|
12
16
|
type ResolvedClawclawBehaviorSource,
|
|
@@ -84,7 +88,7 @@ export function listAgentWorkspaceBehaviorSources(
|
|
|
84
88
|
&& item.resolution !== 'local_modified'
|
|
85
89
|
&& item.resolution !== 'concurrent_difference'
|
|
86
90
|
&& item.resolution !== 'local_origin_unrecognized';
|
|
87
|
-
|
|
91
|
+
const managed = {
|
|
88
92
|
...source,
|
|
89
93
|
...(trusted ? { trustedSourceSha256: item.sourceFiles[0]!.sha256 } : {}),
|
|
90
94
|
management: {
|
|
@@ -101,6 +105,17 @@ export function listAgentWorkspaceBehaviorSources(
|
|
|
101
105
|
...(item.hub ? { ownerName: item.hub.ownerName } : {}),
|
|
102
106
|
},
|
|
103
107
|
} satisfies ManagedClawclawBehaviorSource;
|
|
108
|
+
const workingCopyPath = resolveLocalAgentWorkspaceWorkingCopyPath(workspaceDir, profile, item)
|
|
109
|
+
?? join(getUserDataAccountCapabilitiesDir(workspaceDir, profile), 'behaviors', item.resourceId,
|
|
110
|
+
item.sourceFiles[0]?.relativePath ?? basename(source.sourcePath));
|
|
111
|
+
const entry = registerDiscoveredCapability(workspaceDir, profile, {
|
|
112
|
+
type: 'behavior', path: workingCopyPath, runtimeId: source.id,
|
|
113
|
+
title: source.name, description: source.description, selectedByHub: true,
|
|
114
|
+
hub: { resourceId: item.resourceId, versionId: item.versionId,
|
|
115
|
+
workspaceItemId: item.workspaceItemId, publisher: item.hub?.publisher ?? 'community',
|
|
116
|
+
baseSha256: item.sourceFiles[0]?.sha256 },
|
|
117
|
+
});
|
|
118
|
+
return behaviorOperationName({ ...managed, workingCopyPath }, entry);
|
|
104
119
|
});
|
|
105
120
|
assertUniqueBehaviorIds(sources, 'hub');
|
|
106
121
|
return sources;
|
|
@@ -118,12 +133,26 @@ export function listAgentWorkspacePerceptionSources(
|
|
|
118
133
|
.map(item => resolveLocalAgentWorkspacePath(workspaceDir, profile, active, item.runtimeEntryPath!)));
|
|
119
134
|
const sources = existsSync(root) ? listClawclawPerceptionSourcesInDirectory(root)
|
|
120
135
|
.filter(source => selectedPaths.has(source.sourcePath)) : [];
|
|
136
|
+
const namedSources = sources.map(source => {
|
|
137
|
+
const item = active.items.perception.find(item => item.runtimeEntryPath
|
|
138
|
+
&& resolveLocalAgentWorkspacePath(workspaceDir, profile, active, item.runtimeEntryPath) === source.sourcePath)!;
|
|
139
|
+
const workingCopyPath = resolveLocalAgentWorkspaceWorkingCopyPath(workspaceDir, profile, item)
|
|
140
|
+
?? join(getUserDataAccountCapabilitiesDir(workspaceDir, profile), 'perceptions', item.resourceId,
|
|
141
|
+
item.sourceFiles[0]?.relativePath ?? basename(source.sourcePath));
|
|
142
|
+
const entry = registerDiscoveredCapability(workspaceDir, profile, {
|
|
143
|
+
type: 'perception', path: workingCopyPath, runtimeId: source.id, title: source.name,
|
|
144
|
+
description: source.description, selectedByHub: true,
|
|
145
|
+
hub: { resourceId: item.resourceId, versionId: item.versionId, workspaceItemId: item.workspaceItemId,
|
|
146
|
+
publisher: item.hub?.publisher ?? 'community', baseSha256: item.sourceFiles[0]?.sha256 },
|
|
147
|
+
});
|
|
148
|
+
return perceptionOperationName({ ...source, workingCopyPath }, entry);
|
|
149
|
+
});
|
|
121
150
|
const ids = new Set<string>();
|
|
122
|
-
for (const source of
|
|
151
|
+
for (const source of namedSources) {
|
|
123
152
|
if (ids.has(source.id)) throw new Error(`AGENT_RESOURCE_ID_CONFLICT:perception:${source.id}`);
|
|
124
153
|
ids.add(source.id);
|
|
125
154
|
}
|
|
126
|
-
return
|
|
155
|
+
return namedSources;
|
|
127
156
|
}
|
|
128
157
|
|
|
129
158
|
export function mergeAgentWorkspaceBehaviorSources(
|
|
@@ -201,7 +201,7 @@ function validateUploadPayload(
|
|
|
201
201
|
}
|
|
202
202
|
if (entry.type === 'behavior') {
|
|
203
203
|
const source = inspectClawclawBehaviorSource(path, dirname(path));
|
|
204
|
-
if (!source || source.id !== entry.runtimeId) {
|
|
204
|
+
if (!source || source.id !== (entry.declaredId ?? entry.runtimeId)) {
|
|
205
205
|
throw new Error('capability_validation_failed:behavior_invalid');
|
|
206
206
|
}
|
|
207
207
|
return;
|
|
@@ -210,7 +210,7 @@ function validateUploadPayload(
|
|
|
210
210
|
const resolvedPath = realpathSync(path);
|
|
211
211
|
const source = listClawclawPerceptionSourcesInDirectory(dirname(path))
|
|
212
212
|
.find((candidate) => realpathSync(candidate.sourcePath) === resolvedPath);
|
|
213
|
-
if (!source || source.id !== entry.runtimeId) {
|
|
213
|
+
if (!source || source.id !== (entry.declaredId ?? entry.runtimeId)) {
|
|
214
214
|
throw new Error('capability_validation_failed:perception_invalid');
|
|
215
215
|
}
|
|
216
216
|
return;
|
|
@@ -221,7 +221,7 @@ function validateUploadPayload(
|
|
|
221
221
|
}
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
|
-
if (readSkillName(path) !== entry.runtimeId) {
|
|
224
|
+
if (readSkillName(path) !== (entry.declaredId ?? entry.runtimeId)) {
|
|
225
225
|
throw new Error('capability_validation_failed:skill_invalid');
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from './capability-workspace.js';
|
|
9
9
|
import { listPersonaPresets } from './persona.js';
|
|
10
10
|
import { readSkillName } from './skill-host.js';
|
|
11
|
+
import { behaviorOperationName, perceptionOperationName } from './capability-operation-name.js';
|
|
11
12
|
import {
|
|
12
13
|
ensureAccountUserDataLayout,
|
|
13
14
|
getUserDataAccountBehaviorsDir,
|
|
@@ -90,5 +91,9 @@ export function discoverLocalCapabilities(
|
|
|
90
91
|
})] : [];
|
|
91
92
|
})
|
|
92
93
|
: [];
|
|
93
|
-
return {
|
|
94
|
+
return {
|
|
95
|
+
behaviors: behaviors.map(({ source, entry }) => ({ source: behaviorOperationName(source, entry), entry })),
|
|
96
|
+
perceptions: perceptions.map(({ source, entry }) => ({ source: perceptionOperationName(source, entry), entry })),
|
|
97
|
+
personas, skills,
|
|
98
|
+
};
|
|
94
99
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CapabilityWorkspaceEntry } from './capability-workspace.js';
|
|
2
|
+
import type { ResolvedClawclawBehaviorSource } from '../runtime/clawclaw/plugins/behavior/behavior-source.js';
|
|
3
|
+
import type { ResolvedClawclawPerceptionSource } from '../runtime/clawclaw/plugins/perception/perception-source.js';
|
|
4
|
+
|
|
5
|
+
export function behaviorOperationName<T extends ResolvedClawclawBehaviorSource>(source: T, entry: CapabilityWorkspaceEntry): T {
|
|
6
|
+
return { ...source, id: entry.runtimeId, declaredId: source.declaredId ?? source.id,
|
|
7
|
+
workingCopyPath: source.workingCopyPath ?? source.sourcePath };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function perceptionOperationName<T extends ResolvedClawclawPerceptionSource>(source: T, entry: CapabilityWorkspaceEntry): T {
|
|
11
|
+
return { ...source, id: entry.runtimeId, declaredId: source.declaredId ?? source.id,
|
|
12
|
+
workingCopyPath: source.workingCopyPath ?? source.sourcePath,
|
|
13
|
+
manifest: { ...source.manifest, id: entry.runtimeId } };
|
|
14
|
+
}
|
|
@@ -43,6 +43,8 @@ export interface CapabilityWorkspaceEntry {
|
|
|
43
43
|
origin: 'local' | 'hub';
|
|
44
44
|
relativePath: string;
|
|
45
45
|
runtimeId: string;
|
|
46
|
+
/** Original source identity. runtimeId is the account-local operation name. */
|
|
47
|
+
declaredId?: string;
|
|
46
48
|
title: string;
|
|
47
49
|
description: string;
|
|
48
50
|
selection: CapabilitySelection;
|
|
@@ -141,12 +143,23 @@ export function registerDiscoveredCapability(
|
|
|
141
143
|
const key = existingByResource?.key ?? registryKey(input.type, relativePath);
|
|
142
144
|
const now = new Date().toISOString();
|
|
143
145
|
const previous = registry.entries[key];
|
|
146
|
+
const declaredId = input.runtimeId;
|
|
147
|
+
const occupied = new Set(Object.values(registry.entries)
|
|
148
|
+
.filter(entry => entry.type === input.type && entry.key !== key).map(entry => entry.runtimeId));
|
|
149
|
+
let runtimeId = previous?.runtimeId ?? declaredId;
|
|
150
|
+
// Keep retired/unselected entries in the registry: their operation names must
|
|
151
|
+
// never silently point to a different script after the next load.
|
|
152
|
+
for (let suffix = 1; input.type !== 'skill' && occupied.has(runtimeId); suffix++) {
|
|
153
|
+
const tail = `_${suffix}`;
|
|
154
|
+
runtimeId = `${declaredId.slice(0, 255 - tail.length)}${tail}`;
|
|
155
|
+
}
|
|
144
156
|
const entry: CapabilityWorkspaceEntry = {
|
|
145
157
|
key,
|
|
146
158
|
type: input.type,
|
|
147
159
|
origin: previous?.origin ?? (input.selectedByHub ? 'hub' : 'local'),
|
|
148
160
|
relativePath,
|
|
149
|
-
runtimeId
|
|
161
|
+
runtimeId,
|
|
162
|
+
declaredId,
|
|
150
163
|
title: input.title?.trim() || previous?.title || input.runtimeId,
|
|
151
164
|
description: input.description?.trim() || previous?.description || `${input.type} ${input.runtimeId}`,
|
|
152
165
|
selection: input.selectedByHub
|
package/src/lib/game-client.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type GameSyncResumeState,
|
|
13
13
|
} from '../runtime/ws-client.js';
|
|
14
14
|
import { RuntimeLogger } from '../runtime/runtime-logger.js';
|
|
15
|
+
import { ThreadedWsClient, type ThreadedWsClientConfig } from '../runtime/threaded-ws-client.js';
|
|
15
16
|
import type { RawWsMessageSink } from '../runtime/raw-ws-log.js';
|
|
16
17
|
import type { GameSyncPerceptionReport } from '../runtime/game-sync-protocol.js';
|
|
17
18
|
import type { QueueMode } from './competition.js';
|
|
@@ -36,6 +37,8 @@ export interface GameClientConfig {
|
|
|
36
37
|
rawWsMessageSink?: RawWsMessageSink;
|
|
37
38
|
/** Cancels owner-scoped HTTP work before Action authority is released. */
|
|
38
39
|
signal?: AbortSignal;
|
|
40
|
+
/** Owner-only Source transport isolation. Ephemeral clients do not start an ingress Worker. */
|
|
41
|
+
gameSyncIngress?: Omit<ThreadedWsClientConfig, 'url' | 'apiKey' | 'resumeState'>;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
export interface GameServerDiscoveryResult {
|
|
@@ -69,7 +72,10 @@ function agentMetadataHeaders(options: RoomEntryMetadata): Record<string, string
|
|
|
69
72
|
|
|
70
73
|
export class GameClient {
|
|
71
74
|
private http: HttpTransport;
|
|
72
|
-
private ws: WsClient | null = null;
|
|
75
|
+
private ws: Pick<WsClient, keyof WsClient> | null = null;
|
|
76
|
+
private readonly gameSyncIngress?: GameClientConfig['gameSyncIngress'];
|
|
77
|
+
private readonly closingIngress = new Set<Promise<void>>();
|
|
78
|
+
private transportGeneration = 0;
|
|
73
79
|
/** Last continuously reduced v2 baseline, retained across failed socket replacements. */
|
|
74
80
|
private gameSyncResumeState?: GameSyncResumeState;
|
|
75
81
|
/** Queue/room-owned game identity that the retained baseline must belong to. */
|
|
@@ -111,6 +117,7 @@ export class GameClient {
|
|
|
111
117
|
this.apiKey = config.apiKey;
|
|
112
118
|
this.enableWs = config.enableWs ?? false;
|
|
113
119
|
this.rawWsMessageSink = config.rawWsMessageSink;
|
|
120
|
+
this.gameSyncIngress = config.gameSyncIngress;
|
|
114
121
|
this.registry = new ServerRegistry({
|
|
115
122
|
lobbyUrl: config.lobbyUrl,
|
|
116
123
|
gameServerUrl: config.gameServerUrl,
|
|
@@ -196,8 +203,8 @@ export class GameClient {
|
|
|
196
203
|
}
|
|
197
204
|
|
|
198
205
|
/** Irreversible confirmed Action endpoint; input must already be prepared. */
|
|
199
|
-
async submitPreparedActionConfirmed(action: GameActionRequest): Promise<TransportResponse> {
|
|
200
|
-
return this.http.postRaw('/api/v1/game/action', action);
|
|
206
|
+
async submitPreparedActionConfirmed(action: GameActionRequest, signal?: AbortSignal): Promise<TransportResponse> {
|
|
207
|
+
return this.http.postRaw('/api/v1/game/action', action, undefined, signal);
|
|
201
208
|
}
|
|
202
209
|
|
|
203
210
|
private async prepareAction(action: GameActionRequest): Promise<GameActionRequest> {
|
|
@@ -469,11 +476,11 @@ export class GameClient {
|
|
|
469
476
|
if (resumeState) this.gameSyncResumeState = resumeState;
|
|
470
477
|
if (this.ws) {
|
|
471
478
|
this.ws.clearHandlers();
|
|
472
|
-
this.ws
|
|
479
|
+
await this.stopWs(this.ws);
|
|
473
480
|
this.markWsHandlersDetached();
|
|
474
481
|
}
|
|
475
482
|
|
|
476
|
-
const newWs =
|
|
483
|
+
const newWs = this.createWs({
|
|
477
484
|
url: wsUrl,
|
|
478
485
|
apiKey: this.apiKey,
|
|
479
486
|
rawMessageSink: this.rawWsMessageSink,
|
|
@@ -487,7 +494,7 @@ export class GameClient {
|
|
|
487
494
|
} catch {
|
|
488
495
|
this.rememberGameSyncResumeState(newWs.resumeState);
|
|
489
496
|
this.log.warn('WS_CONNECT', 'GameSync WebSocket connection failed; runtime will retry');
|
|
490
|
-
|
|
497
|
+
await this.stopWs(newWs);
|
|
491
498
|
this.ws = null;
|
|
492
499
|
this.markWsHandlersDetached();
|
|
493
500
|
return false;
|
|
@@ -500,7 +507,7 @@ export class GameClient {
|
|
|
500
507
|
this.rememberGameSyncResumeState(this.ws?.resumeState);
|
|
501
508
|
}
|
|
502
509
|
if (this.ws) {
|
|
503
|
-
this.ws
|
|
510
|
+
this.stopWs(this.ws);
|
|
504
511
|
this.ws = null;
|
|
505
512
|
}
|
|
506
513
|
if (!options.preserveGameSyncResumeState) {
|
|
@@ -559,11 +566,11 @@ export class GameClient {
|
|
|
559
566
|
if (resumeState) this.gameSyncResumeState = resumeState;
|
|
560
567
|
if (this.ws) {
|
|
561
568
|
this.ws.clearHandlers();
|
|
562
|
-
this.ws
|
|
569
|
+
await this.stopWs(this.ws);
|
|
563
570
|
this.markWsHandlersDetached();
|
|
564
571
|
}
|
|
565
572
|
|
|
566
|
-
const newWs =
|
|
573
|
+
const newWs = this.createWs({
|
|
567
574
|
url: wsUrl,
|
|
568
575
|
apiKey: this.apiKey,
|
|
569
576
|
rawMessageSink: this.rawWsMessageSink,
|
|
@@ -577,7 +584,7 @@ export class GameClient {
|
|
|
577
584
|
} catch {
|
|
578
585
|
this.rememberGameSyncResumeState(newWs.resumeState);
|
|
579
586
|
this.log.warn('WS_RECONNECT', 'GameSync WebSocket reconnect failed; runtime will retry');
|
|
580
|
-
|
|
587
|
+
await this.stopWs(newWs);
|
|
581
588
|
this.ws = null;
|
|
582
589
|
this.markWsHandlersDetached();
|
|
583
590
|
}
|
|
@@ -700,6 +707,29 @@ export class GameClient {
|
|
|
700
707
|
for (const entry of this.wsRecoveryStartedHandlers) entry.unsubscribe = undefined;
|
|
701
708
|
}
|
|
702
709
|
|
|
710
|
+
private createWs(config: ConstructorParameters<typeof WsClient>[0]): Pick<WsClient, keyof WsClient> {
|
|
711
|
+
if (!this.gameSyncIngress) return new WsClient(config);
|
|
712
|
+
const { rawMessageSink: _sink, ...options } = config;
|
|
713
|
+
return new ThreadedWsClient({ ...options, ...this.gameSyncIngress, transportGeneration: ++this.transportGeneration });
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
private stopWs(ws: Pick<WsClient, keyof WsClient>): Promise<void> {
|
|
717
|
+
ws.disconnect();
|
|
718
|
+
if (ws instanceof ThreadedWsClient) {
|
|
719
|
+
const closing = ws.close();
|
|
720
|
+
this.closingIngress.add(closing);
|
|
721
|
+
void closing.finally(() => this.closingIngress.delete(closing));
|
|
722
|
+
return closing;
|
|
723
|
+
}
|
|
724
|
+
return Promise.resolve();
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/** Drain Source-owned ingress and raw journals before Owner telemetry closes. */
|
|
728
|
+
async closeGameSyncTransports(): Promise<void> {
|
|
729
|
+
this.disconnectWs();
|
|
730
|
+
await Promise.allSettled([...this.closingIngress]);
|
|
731
|
+
}
|
|
732
|
+
|
|
703
733
|
private rememberGameSyncResumeState(candidate: GameSyncResumeState | undefined): void {
|
|
704
734
|
if (!candidate) return;
|
|
705
735
|
const expected = this.expectedGameSyncGameId;
|
|
@@ -135,8 +135,8 @@ export class HttpTransport {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
async postRaw(path: string, body?: any, perRequestHeaders?: Record<string, string
|
|
139
|
-
return this.requestRaw('POST', path, body, perRequestHeaders);
|
|
138
|
+
async postRaw(path: string, body?: any, perRequestHeaders?: Record<string, string>, requestSignal?: AbortSignal): Promise<TransportResponse> {
|
|
139
|
+
return this.requestRaw('POST', path, body, perRequestHeaders, requestSignal);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/** GET with one fast retry for transient network failures. */
|
package/src/lib/persona.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
type LocalAgentWorkspaceSnapshot,
|
|
17
17
|
} from './agent-workspace-sync.js';
|
|
18
18
|
import { filterInactiveAgentWorkspaceSnapshot } from './capability-cloud-presence.js';
|
|
19
|
-
import { capabilityEntryForPath, readCapabilityWorkspaceRegistry, capabilityWorkspacePath } from './capability-workspace.js';
|
|
19
|
+
import { capabilityEntryForPath, readCapabilityWorkspaceRegistry, capabilityWorkspacePath, registerDiscoveredCapability } from './capability-workspace.js';
|
|
20
20
|
|
|
21
21
|
export interface PersonaPreset {
|
|
22
22
|
id: string;
|
|
@@ -136,7 +136,12 @@ function hubPersona(
|
|
|
136
136
|
working = join(getUserDataAccountHubPersonasDir(workspaceDir, profile), item.resourceId, sourcePath);
|
|
137
137
|
}
|
|
138
138
|
if (working && existsSync(working)) {
|
|
139
|
-
|
|
139
|
+
const entry = registerDiscoveredCapability(workspaceDir, profile, {
|
|
140
|
+
type: 'persona', path: working, runtimeId: basename(working, '.md'), selectedByHub: true,
|
|
141
|
+
hub: { resourceId: item.resourceId, versionId: item.versionId, workspaceItemId: item.workspaceItemId,
|
|
142
|
+
publisher: item.hub?.publisher ?? 'community', baseSha256: item.sourceFiles[0]?.sha256 },
|
|
143
|
+
});
|
|
144
|
+
return { path: working, source: 'hub', resourceId: item.resourceId, id: entry.runtimeId };
|
|
140
145
|
}
|
|
141
146
|
if (item.runtimeEntryPath) {
|
|
142
147
|
const runtime = resolveLocalAgentWorkspacePath(workspaceDir, profile, snapshot!, item.runtimeEntryPath);
|
|
@@ -159,6 +164,12 @@ export function resolveActivePersonaFile(authStore = new AuthStore()): ResolvedP
|
|
|
159
164
|
const selection = readPersonaSelection(workspaceDir, profile)
|
|
160
165
|
?? (selectedHub ? { source: 'hub' as const } : { source: 'none' as const });
|
|
161
166
|
if (selection?.source === 'local') {
|
|
167
|
+
const selectedEntry = Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
|
|
168
|
+
.find(entry => entry.type === 'persona' && entry.runtimeId === selection.id);
|
|
169
|
+
if (selectedEntry) {
|
|
170
|
+
if (selectedEntry.hub || selectedEntry.selection !== 'equipped') return selectedHub ?? { path: null, source: 'none' };
|
|
171
|
+
return { path: capabilityWorkspacePath(workspaceDir, profile, selectedEntry), source: 'local', id: selectedEntry.runtimeId };
|
|
172
|
+
}
|
|
162
173
|
const preset = findPersonaPreset(selection.id, getUserDataAccountPersonasDir(workspaceDir, profile));
|
|
163
174
|
const entry = preset ? capabilityEntryForPath(workspaceDir, profile, 'persona', preset.path) : undefined;
|
|
164
175
|
if (entry?.hub) return selectedHub ?? { path: null, source: 'none' };
|