@myclaw163/clawclaw-cli 0.8.33 → 0.8.35

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.
@@ -0,0 +1,20 @@
1
+ import { ClawclawReminder, evaluateReminder, type ReminderInput } from '@myclaw163/clawclaw-cli/perception-plugin';
2
+
3
+ /** Requires CCL >= 0.8.34; only other players' wandering speech is notified. */
4
+ export default class SpeechReminder extends ClawclawReminder {
5
+ static readonly manifest = {
6
+ apiVersion: 2,
7
+ kind: 'reminder',
8
+ id: 'reminder.speech',
9
+ name: '附近消息',
10
+ description: '接收或不接收游荡阶段其他玩家的附近发言。',
11
+ topic: 'speech',
12
+ consumes: ['wandering_speech'],
13
+ inputs: [{ id: 'receive', type: 'boolean', description: '是否接收附近发言', default: true }],
14
+ config: { receive: true },
15
+ } as const;
16
+
17
+ update(input: ReminderInput) {
18
+ return evaluateReminder('speech', input);
19
+ }
20
+ }
@@ -16,7 +16,7 @@
16
16
 
17
17
  未装配脚本、脚本失败或 tasks 主题冲突时,不产生任务提醒;当前 State 和原始事实仍保留。没有 CCL 自动补发任务完成通知的兜底,请按需要装配任务提醒。
18
18
 
19
- 以下仍由 CCL 负责:房间/等待、发言、会议、紧急任务生命周期、`emergency_countdown_warning`(跨过 30 秒和 20 秒)、`ability.ready`、`ability.remaining_uses_changed`、`ability.exhausted`。任务脚本不能关闭或冒用这些事件。
19
+ 以下仍由 CCL 负责:房间/等待、会议/投票/死亡发言、会议、紧急任务生命周期、`emergency_countdown_warning`(跨过 30 秒和 20 秒)、`ability.ready`、`ability.remaining_uses_changed`、`ability.exhausted`。任务脚本不能关闭或冒用这些事件。游荡发言通知由独立的 speech 主题感知处理,见下文。
20
20
 
21
21
  ## 安装与单文件脚本
22
22
 
@@ -138,6 +138,18 @@ return {
138
138
 
139
139
  同一 tasks 主题只装配一个脚本;冲突时 `ccl load` 报 perception_topic_conflict,Runtime 不任意挑选。
140
140
 
141
+ ## 附近消息:接收或不接收
142
+
143
+ 从 CCL 0.8.34 起,speech 主题使用同一 `ClawclawReminder` 输入及普通感知资源管理。单文件示例为 `docs/custom-modules/examples/speech-reminder.ts`,可以直接放到当前账号 `capabilities/perceptions/`,再用 `ccl perception --list` 核对并启用 `reminder.speech`。本地安装和 Hub 上传是独立路径。
144
+
145
+ 该模块只有 `manifest.config.receive` 一个布尔选项,默认 `true`。为 `true` 时,每条其他玩家的游荡发言输出一条 `reminder.speech` 并允许唤醒;为 `false`、未装配、停用或加载失败时不输出。修改配置后重启 Runtime 生效。speech 主题同一时间只装配一个模块,可与 tasks 主题模块同时装配。
146
+
147
+ 原始 `wandering_speech` 作为内部事实保留,Behavior 和 Trigger 仍可读取;它不直接通知 Agent,也不出现在普通 `ccl events` 中。模块只订阅该事件类型,会议 `speech`、投票 `vote_speech`、死亡 `death_speech` 和房间 `room.chat` 均保持原有交付规则。
148
+
149
+ 后端 GameSync 的游荡发言接收者包含说话者本人,默认工具以座位优先、名字兜底过滤自己的回声。正文不分类、不摘要,保留 actor、text、room、tick 和 source_event_id;按源 Event 身份去重,相同文本的两次独立发言仍收到两次。重连历史重放不通知,首次帧和重连帧中的新发言仍正常通知。
150
+
151
+ 自定义 speech 脚本的 `topic` 为 `speech`、`consumes` 只能包含 `wandering_speech`,输出 `type` 固定为 `reminder.speech`。任务模块不能订阅游荡消息,也不能输出消息提醒;消息模块不能冒用任务或其他 CCL 事件。
152
+
141
153
  ## 从 0.8.27 迁移
142
154
 
143
155
  这是对原试用提醒接口的调整:`deliveries` 不再接受,`notify/query/off` 改为 `wake/silent/state_only`。旧 query 的含义是仅 events 查询,并不等于新 silent 的搭便车。请替换为本包新示例或更新自定义代码;只升级 CCL 不会自动覆写本地脚本。任务完成/中断/破坏也必须由新脚本处理。公共 Perception API 仍为 v2,但此 Reminder 接口要求 CCL 0.8.28+。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myclaw163/clawclaw-cli",
3
- "version": "0.8.33",
3
+ "version": "0.8.35",
4
4
  "type": "module",
5
5
  "description": "ClawClaw social deduction game CLI",
6
6
  "bin": {
@@ -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.107
4
+ version: 4.8.109
5
5
  ---
6
6
 
7
7
  # 龙虾杀(ClawClaw)
@@ -136,6 +136,8 @@ ccl load
136
136
 
137
137
  `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` 是首次发现的纯本地资源:先用 `declared_id`、`working_copy_path`、`resource_id` 和作者信息确认玩家指的是哪一项,只询问一次是否装配,再执行返回 guidance 中带 `selection_ref` 的 `ccl capability equip` 或 `ccl capability unequip`,保存后不重复询问。资源展示优先使用英文 metadata,只有中文 metadata 时保留中文原文。本地修改优先使用;普通资源无并发差异时 CCL 自动上传。云端直接 fork 出自己的 B 而原 A 有 B 尚未包含的本地修改时,即使 B 仍是旧版,也保留本地并让玩家选择 `ccl capability resolve ... --use local|cloud|later`。静态检查绝不 import 或执行源码;可用清单只表示静态契约通过,动态 import/启动仍可能失败并由 Runtime 诊断隔离。`participation` 是执行当刻的后端快照;字段缺失时不要猜。
138
138
 
139
+ `capabilities.skills` 列出当前账号已装配的辅助 Skill 名称。先与当前可用 Skill 列表按名称匹配,只对匹配到的 Skill 按宿主正常 Skill 读取流程逐个阅读。不在可用列表中的直接忽略,不尝试读取或自行查找文件;可简短告知玩家,不阻塞开局。
140
+
139
141
  `ccl load` 的同步结果按下面规则处理,不自行扩展状态机:
140
142
 
141
143
  - `changes.skills.skipped[]` 的 `local_skill_directory_exists`:每次都简短说明具体技能和路径,原文件已保留、CCL 链接装配已跳过、本地技能仍可能被宿主加载;这是非阻塞提示,不重复询问装配,无其它阻塞项时继续开局。equip/unequip 返回同类 `skipped[]` 时也如此处理。
@@ -322,6 +324,8 @@ Behavior manifest 中类型为 `player_seat` 或 `player_seats` 的输入只接
322
324
 
323
325
  当前任务列表由 CCL 持续维护,按需读取 `ccl events` 返回的 `state.you.tasks`。任务通知由已装配的任务感知输出 `reminder.task`:开始、进度、完成、中断等可以唤醒、搭便车或不提醒;未装配时没有任务通知。`kind:interrupted` 表示任务被打断,不能据此认定任务已消耗或从本地列表删除。Agent 和所有层的 Behavior 都不要自行请求后端或从零散历史 Event 拼当前列表。
324
326
 
327
+ 游荡阶段其他玩家的附近发言由已装配的消息感知输出 `reminder.speech`;其 `manifest.config.receive` 为 `true` 时接收,为 `false`、未装配或停用时不接收。原始 `wandering_speech` 只供内部模块读取,自己的发言回声不通知 Agent。会议发言、投票弹幕、死亡弹幕和房间聊天沿用各自原有规则。单文件示例及配置见 `references/CUSTOM-REMINDER-DEVELOPMENT.md`。
328
+
325
329
  蟹方破坏任务准入以裸 `ccl events` 查询边界中的 `state.crab_sabotage` 为权威:`ready` 时才可选择当前目录中明确支持执行该任务的 Behavior,并按其 manifest 传参;目录中没有就不能用 Behavior 代办。`cooldown_charged` 按 `cooldown_remaining_secs` 等待,`emergency_active` 停止破坏计划。完成破坏任务会由服务端自动触发对应紧急任务,不存在独立报警动作;若收到私有 `task_interrupted`,立即放弃当前执行状态,保留任务并等待服务端重新变为 `ready`。蟹方队友以 `state.you.crab_teammates` 为准,不等待已移除的 `crab_teammates` Event。
326
330
 
327
331
  **游走决策循环:**
@@ -52,6 +52,8 @@ ccl trigger disable <id> # 禁用并尝试热应用到当前
52
52
 
53
53
  `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 或执行源码;可用清单不代表模块已经运行。
54
54
 
55
+ `capabilities.skills` 每次返回当前账号已装配的辅助 Skill 名称数组,无装配时为 `[]`。先与当前可用 Skill 列表按名称匹配,只对匹配到的 Skill 按宿主正常 Skill 读取流程逐个阅读。不在可用列表中的直接忽略,不尝试读取或自行查找文件;可简短告知玩家,不阻塞开局。
56
+
55
57
  用户提示规则固定为:`conflicts` / `selection_required` 必须说明并等待选择;`warnings` / `failed` 必须说明具体资源和原因,但非必需资源失败不阻塞开局;`workspace_updated` / `downloaded` / `uploaded` 必须简短说明同步结果;`deactivated` 必须说明已停止生效但本地副本保留,`restored` 简短说明恢复;`skipped: local_origin_unrecognized` 必须说明继续使用本地且未上传。
56
58
 
57
59
  `WORKSPACE_SYNC_FAILED` 会说明 Workspace 同步错误及旧快照回退;`WORKSPACE_INVENTORY_UNAVAILABLE` 表示本次无法确认背包,自动云端写入暂停。`uploaded` 和 `failed: equipment` 同时出现表示内容已保存、装配未完成,不应重复创建资源。失败的装配请求不会自动重放覆盖后来的 Hub 选择;重新 equip/unequip 后再次 load。自己的资源自动更新递增 patch 版本,更新说明为“本地修改同步”。
@@ -16,7 +16,7 @@
16
16
 
17
17
  未装配脚本、脚本失败或 tasks 主题冲突时,不产生任务提醒;当前 State 和原始事实仍保留。没有 CCL 自动补发任务完成通知的兜底,请按需要装配任务提醒。
18
18
 
19
- 以下仍由 CCL 负责:房间/等待、发言、会议、紧急任务生命周期、`emergency_countdown_warning`(跨过 30 秒和 20 秒)、`ability.ready`、`ability.remaining_uses_changed`、`ability.exhausted`。任务脚本不能关闭或冒用这些事件。
19
+ 以下仍由 CCL 负责:房间/等待、会议/投票/死亡发言、会议、紧急任务生命周期、`emergency_countdown_warning`(跨过 30 秒和 20 秒)、`ability.ready`、`ability.remaining_uses_changed`、`ability.exhausted`。任务脚本不能关闭或冒用这些事件。游荡发言通知由独立的 speech 主题感知处理,见下文。
20
20
 
21
21
  ## 安装与单文件脚本
22
22
 
@@ -138,6 +138,18 @@ return {
138
138
 
139
139
  同一 tasks 主题只装配一个脚本;冲突时 `ccl load` 报 perception_topic_conflict,Runtime 不任意挑选。
140
140
 
141
+ ## 附近消息:接收或不接收
142
+
143
+ 从 CCL 0.8.34 起,speech 主题使用同一 `ClawclawReminder` 输入及普通感知资源管理。单文件示例为 `docs/custom-modules/examples/speech-reminder.ts`,可以直接放到当前账号 `capabilities/perceptions/`,再用 `ccl perception --list` 核对并启用 `reminder.speech`。本地安装和 Hub 上传是独立路径。
144
+
145
+ 该模块只有 `manifest.config.receive` 一个布尔选项,默认 `true`。为 `true` 时,每条其他玩家的游荡发言输出一条 `reminder.speech` 并允许唤醒;为 `false`、未装配、停用或加载失败时不输出。修改配置后重启 Runtime 生效。speech 主题同一时间只装配一个模块,可与 tasks 主题模块同时装配。
146
+
147
+ 原始 `wandering_speech` 作为内部事实保留,Behavior 和 Trigger 仍可读取;它不直接通知 Agent,也不出现在普通 `ccl events` 中。模块只订阅该事件类型,会议 `speech`、投票 `vote_speech`、死亡 `death_speech` 和房间 `room.chat` 均保持原有交付规则。
148
+
149
+ 后端 GameSync 的游荡发言接收者包含说话者本人,默认工具以座位优先、名字兜底过滤自己的回声。正文不分类、不摘要,保留 actor、text、room、tick 和 source_event_id;按源 Event 身份去重,相同文本的两次独立发言仍收到两次。重连历史重放不通知,首次帧和重连帧中的新发言仍正常通知。
150
+
151
+ 自定义 speech 脚本的 `topic` 为 `speech`、`consumes` 只能包含 `wandering_speech`,输出 `type` 固定为 `reminder.speech`。任务模块不能订阅游荡消息,也不能输出消息提醒;消息模块不能冒用任务或其他 CCL 事件。
152
+
141
153
  ## 从 0.8.27 迁移
142
154
 
143
155
  这是对原试用提醒接口的调整:`deliveries` 不再接受,`notify/query/off` 改为 `wake/silent/state_only`。旧 query 的含义是仅 events 查询,并不等于新 silent 的搭便车。请替换为本包新示例或更新自定义代码;只升级 CCL 不会自动覆写本地脚本。任务完成/中断/破坏也必须由新脚本处理。公共 Perception API 仍为 v2,但此 Reminder 接口要求 CCL 0.8.28+。
@@ -1,5 +1,7 @@
1
1
  # 流与事件查询
2
2
 
3
+ 当前 CCL 的公开任务视图会结合破坏技能状态筛选:蟹的破坏技能未就绪(冷却、紧急任务期间或状态未知)时,未开始的破坏任务不作为 Agent、Behavior 或任务查询的可选项。伪装任务和紧急维修保留;正在执行、已完成的条目用于结果确认,不能当作新任务重做。技能恢复 ready 后,仍分配的未完成破坏任务自动重新出现。后端原始完整分配清单仍保存在 Runtime 数据中,不因这个公开视图过滤而删除。
4
+
3
5
  ## 1. 一条长流、一种 Monitor 输出
4
6
 
5
7
  `ccl start match`、`ccl start room`、`ccl start training`、`ccl join` 和 `ccl join room` 都会启动当前参与的唯一前台 Runtime 长进程。它在同一个进程生命周期中持有后端连接、事件、Behavior 控制栈和通知输出。不要为同一账号重复启动,也不要用轮询代替它。
@@ -60,6 +60,7 @@ import {
60
60
  capabilityWorkspacePath,
61
61
  classifyStrategyLifecycle,
62
62
  pendingCapabilitySelections,
63
+ readCapabilityWorkspaceRegistry,
63
64
  registerDiscoveredCapability,
64
65
  capabilityEntryForPath,
65
66
  capabilityEntryForHubResource,
@@ -897,6 +898,10 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
897
898
  unchanged: cloudChanges?.unchanged ?? [],
898
899
  } : undefined;
899
900
  const selectionRequired = pendingCapabilitySelections(workspaceDir, profile);
901
+ const skills = [...new Set(Object.values(readCapabilityWorkspaceRegistry(workspaceDir, profile).entries)
902
+ .filter((entry) => entry.type === 'skill' && entry.selection === 'equipped'
903
+ && !entry.hub?.cloudStatus && entry.runtimeId !== 'clawclaw')
904
+ .map((entry) => entry.runtimeId))].sort();
900
905
  console.log(JSON.stringify({
901
906
  schema: LOAD_SCHEMA,
902
907
  context: {
@@ -916,6 +921,7 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
916
921
  } : {}),
917
922
  capabilities: {
918
923
  summary: capabilitySummary,
924
+ skills,
919
925
  behaviors: behaviors.map((entry) => {
920
926
  const source = behaviorSourceById.get(entry.id)!;
921
927
  const localized = resolveClawclawResourceMetadata(source, LOAD_DISPLAY_LOCALE);
@@ -418,6 +418,11 @@ function shortBody(event: Record<string, any>, ctx: EventFormatContext): string
418
418
  }
419
419
  case 'reminder.task':
420
420
  return firstString(event, ['text'], '任务提醒。');
421
+ case 'reminder.speech': {
422
+ const actor = event.actor && typeof event.actor === 'object' ? event.actor : {};
423
+ const speaker = playerLabel(actor.name ?? event.actor_name, actor.seat ?? event.actor_seat, ctx);
424
+ return `${speaker}在${firstString(event, ['room'])}说:${truncate(event.text, maxTextLength)}`;
425
+ }
421
426
  case 'tasks_changed':
422
427
  return `任务列表已更新(${firstString(event, ['reason'])})。`;
423
428
  case 'players_changed':
@@ -7,6 +7,7 @@ import type {
7
7
  } from '../../sdk/module-input/index.js';
8
8
  import type { RuntimeEpochPluginInput } from '../framework/plugins/contracts.js';
9
9
  import { isClawclawRuntimeState } from './runtime-state.js';
10
+ import { projectTaskChoiceGameState, projectTaskChoiceEventPayload } from './task-choice-projection.js';
10
11
 
11
12
  function deepFreeze<T>(value: T): T {
12
13
  if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;
@@ -17,13 +18,14 @@ function deepFreeze<T>(value: T): T {
17
18
 
18
19
  function behaviorEvents(
19
20
  input: RuntimeEpochPluginInput<Record<string, any>>,
21
+ gameState: GameState,
20
22
  ): readonly Readonly<GameEvent>[] {
21
23
  return input.pendingEvents.map((event) => ({
22
24
  eventId: event.eventId,
23
25
  ...(event.epochSeq === undefined ? {} : { epochId: event.epochSeq }),
24
26
  type: event.type,
25
27
  occurredAt: event.occurredAt,
26
- payload: structuredClone(event.payload),
28
+ payload: projectTaskChoiceEventPayload(gameState, event.type, event.payload),
27
29
  }));
28
30
  }
29
31
 
@@ -32,7 +34,7 @@ export function createCanonicalGameState(
32
34
  source: Readonly<Record<string, unknown>>,
33
35
  domainTick?: unknown,
34
36
  ): GameState {
35
- const gameState = structuredClone(source) as unknown as GameState;
37
+ const gameState = projectTaskChoiceGameState(source) as unknown as GameState;
36
38
  if (typeof domainTick === 'number' && Number.isFinite(domainTick)) {
37
39
  (gameState as { tick?: number }).tick = domainTick;
38
40
  }
@@ -68,7 +70,7 @@ export function createBehaviorInput<
68
70
  },
69
71
  nowMs: input.frame.observedAtMs ?? input.frame.receivedAtMs,
70
72
  gameState,
71
- events: behaviorEvents(input),
73
+ events: behaviorEvents(input, gameState),
72
74
  input: structuredClone(behaviorInput),
73
75
  // The Owner ring exposes one recursively immutable snapshot. Serial modules
74
76
  // can share it directly; Worker postMessage performs the one required clone.
@@ -21,6 +21,7 @@ import type {
21
21
  RuntimeEpochPluginResult,
22
22
  } from '../../../framework/plugins/index.js';
23
23
  import { isClawclawRuntimeState, type ClawclawRuntimeStage } from '../../runtime-state.js';
24
+ import { sabotageTaskActionBlocked } from '../../task-choice-projection.js';
24
25
 
25
26
  export const CLAWCLAW_ACTION_PLUGIN_ID = 'clawclaw.action';
26
27
  export const CLAWCLAW_ACTION_CAPABILITY = 'clawclaw.action';
@@ -271,6 +272,11 @@ export class ClawclawActionPlugin implements RuntimeEpochPlugin<Record<string, a
271
272
  private connection: 'connected' | 'reconnecting' | 'disconnected' = 'disconnected';
272
273
  private noteAgentActivity?: () => void;
273
274
  private diagnostic?: RuntimeEpochPluginContext<Record<string, any>>['diagnostic'];
275
+ private latestTaskGameState?: {
276
+ scopeKey: string;
277
+ epochSeq: number;
278
+ state: Record<string, any>;
279
+ };
274
280
  private readonly ownedSettlements = new Map<string, Promise<ActionResult>>();
275
281
  /**
276
282
  * Automated callers may receive a queued receipt before HTTP settlement.
@@ -290,6 +296,7 @@ export class ClawclawActionPlugin implements RuntimeEpochPlugin<Record<string, a
290
296
 
291
297
  start(context: RuntimeEpochPluginContext<Record<string, any>>): void {
292
298
  if (this.unregister) throw new Error('Clawclaw Action Plugin is already started.');
299
+ this.latestTaskGameState = undefined;
293
300
  this.stage = context.currentSegment().kind === 'room_lobby' ? 'room' : 'matching';
294
301
  this.diagnostic = context.diagnostic;
295
302
  this.detailCapture = new DetailCapture('actions', context.diagnostic);
@@ -303,9 +310,14 @@ export class ClawclawActionPlugin implements RuntimeEpochPlugin<Record<string, a
303
310
  }
304
311
 
305
312
  update(input: RuntimeEpochPluginInput<Record<string, any>>): RuntimeEpochPluginResult {
313
+ const scopeKey = this.automatedProviderQueueKey(input.epoch.scope);
314
+ if (this.latestTaskGameState?.scopeKey !== scopeKey) this.latestTaskGameState = undefined;
306
315
  if (isClawclawRuntimeState(input.epoch.state)) {
307
316
  this.stage = input.epoch.state.stage;
308
317
  this.connection = input.epoch.state.connection;
318
+ if (input.epoch.state.game_snapshot.status === 'fresh') {
319
+ this.rememberTaskGameState(input.epoch.scope, input.epoch.epochSeq, input.epoch.state.game_snapshot.state);
320
+ }
309
321
  }
310
322
  return { outcome: 'noop', reason: 'no_action_request' };
311
323
  }
@@ -314,6 +326,7 @@ export class ClawclawActionPlugin implements RuntimeEpochPlugin<Record<string, a
314
326
  this.unregister?.();
315
327
  this.unregister = undefined;
316
328
  this.diagnostic = undefined;
329
+ this.latestTaskGameState = undefined;
317
330
  this.automatedProviderStarts.clear();
318
331
  this.automatedProviderQueueDepths.clear();
319
332
  }
@@ -322,6 +335,53 @@ export class ClawclawActionPlugin implements RuntimeEpochPlugin<Record<string, a
322
335
  return `${scope.sessionId}:${scope.segmentId}`;
323
336
  }
324
337
 
338
+ private rememberTaskGameState(scope: ScopeRef, epochSeq: number, state: Record<string, any>): void {
339
+ const scopeKey = this.automatedProviderQueueKey(scope);
340
+ if (this.latestTaskGameState?.scopeKey === scopeKey
341
+ && this.latestTaskGameState.epochSeq > epochSeq) return;
342
+ this.latestTaskGameState = { scopeKey, epochSeq, state: structuredClone(state) };
343
+ }
344
+
345
+ private taskAdmissionRejection(
346
+ request: ClawclawActionRequest,
347
+ scope: ScopeRef,
348
+ actionId: string,
349
+ context: ActionExecutionContext,
350
+ ): ActionResult | undefined {
351
+ if (request.action.action !== 'task') return undefined;
352
+ const scopeKey = this.automatedProviderQueueKey(scope);
353
+ if (this.latestTaskGameState?.scopeKey !== scopeKey) this.latestTaskGameState = undefined;
354
+ const latest = context.latestAcceptedState();
355
+ const runtimeState = latest?.state;
356
+ let game: Record<string, any> | undefined;
357
+ if (isClawclawRuntimeState(runtimeState)) {
358
+ if (runtimeState.game_snapshot.status === 'fresh') {
359
+ game = runtimeState.game_snapshot.state;
360
+ this.rememberTaskGameState(scope, latest!.epochSeq, game);
361
+ } else if (runtimeState.game_snapshot.status === 'not_updated'
362
+ && runtimeState.connection === 'connected') {
363
+ // Control-only epochs retain the last authoritative game observation.
364
+ game = this.latestTaskGameState?.state;
365
+ }
366
+ if (runtimeState.connection !== 'connected') game = undefined;
367
+ } else if (runtimeState) {
368
+ game = runtimeState;
369
+ this.rememberTaskGameState(scope, latest!.epochSeq, game);
370
+ }
371
+ // An unavailable snapshot may retain task identity for rejection, but can
372
+ // never borrow a previous ready status to authorize sabotage.
373
+ if (!game && this.latestTaskGameState) {
374
+ game = { ...this.latestTaskGameState.state, crab_sabotage: undefined };
375
+ }
376
+ if (!sabotageTaskActionBlocked(game, request.action.task_name)) return undefined;
377
+ return actionResult(scope, actionId, 'failure', undefined, {
378
+ error: {
379
+ code: 'SABOTAGE_NOT_READY',
380
+ message: 'The sabotage task requires the current shared sabotage state to be ready.',
381
+ },
382
+ }, { source: 'local', actionOutcome: 'not_submitted' });
383
+ }
384
+
325
385
  private enqueueAutomatedSubmission(
326
386
  request: ClawclawActionRequest,
327
387
  scope: ScopeRef,
@@ -472,6 +532,8 @@ export class ClawclawActionPlugin implements RuntimeEpochPlugin<Record<string, a
472
532
  ): ActionResult | undefined {
473
533
  const stale = this.automationSafetyRejection(request, scope, actionId, caller, context);
474
534
  if (stale) return stale;
535
+ const taskRejected = this.taskAdmissionRejection(request, scope, actionId, context);
536
+ if (taskRejected) return taskRejected;
475
537
  if (caller.kind === 'behavior') {
476
538
  // A queued Behavior Action is owned by its exact activation controller
477
539
  // until the endpoint starts. Suspension, replacement, or restart must
@@ -519,6 +581,8 @@ export class ClawclawActionPlugin implements RuntimeEpochPlugin<Record<string, a
519
581
  }, { source: 'local', actionOutcome: 'not_submitted' });
520
582
  }
521
583
  } else {
584
+ const taskRejected = this.taskAdmissionRejection(request, scope, actionId, context);
585
+ if (taskRejected) return taskRejected;
522
586
  const targetPreparation = prepareActionTarget(action);
523
587
  if ('failure' in targetPreparation) {
524
588
  return actionResult(scope, actionId, 'failure', undefined, {
@@ -4,8 +4,9 @@ import type { ReminderInput, ReminderResult, ReminderTopic, ReminderTaskChange }
4
4
  import type { ResolvedClawclawPerceptionSource } from '../perception/perception-source.js';
5
5
  import { freshClawclawGameState } from '../../runtime-state.js';
6
6
  import { createCanonicalGameState } from '../../behavior-input.js';
7
+ import { projectTaskChoiceEventPayload } from '../../task-choice-projection.js';
7
8
  import { ObservationFrameProjector } from '../../observation-frame-projector.js';
8
- import { REMINDER_EVENT_TYPES, REMINDER_FACT_TYPES, REMINDER_TOPICS } from './reminder-rules.js';
9
+ import { REMINDER_EVENT_TYPES, REMINDER_EVENT_TYPE_BY_TOPIC, REMINDER_FACT_TYPES, REMINDER_TOPICS } from './reminder-rules.js';
9
10
  import { ReminderRunner } from './reminder-runner.js';
10
11
  import { resolveClawclawResourceMetadata } from '../../../../sdk/resource-metadata.js';
11
12
 
@@ -58,7 +59,8 @@ export class ClawclawReminderPlugin implements RuntimeEpochPlugin<Record<string,
58
59
  if (checkpoint?.states) this.checkpoint = structuredClone({
59
60
  gameId: checkpoint.gameId, previousTick: checkpoint.previousTick,
60
61
  previousConnectionId: checkpoint.previousConnectionId,
61
- states: checkpoint.states.tasks ? { tasks: checkpoint.states.tasks } : {},
62
+ states: Object.fromEntries(REMINDER_TOPICS.filter(topic => checkpoint.states[topic])
63
+ .map(topic => [topic, checkpoint.states[topic]])),
62
64
  });
63
65
  }
64
66
  async stop(): Promise<void> { await Promise.all([...this.runners.values()].map(r => r.stop())); this.runners.clear(); }
@@ -89,7 +91,8 @@ export class ClawclawReminderPlugin implements RuntimeEpochPlugin<Record<string,
89
91
  next.previousTick = undefined; next.previousConnectionId = undefined;
90
92
  }
91
93
  next.previousConnectionId = input.epoch.connectionId;
92
- const facts = input.pendingEvents;
94
+ const facts = input.pendingEvents.map(event => ({ ...event,
95
+ payload: projectTaskChoiceEventPayload(game, event.type, event.payload) }));
93
96
  const events: RuntimeEventProposal[] = [];
94
97
  const taskChanges: ReminderTaskChange[] = facts.filter(e => e.type === 'tasks_changed').flatMap(e => {
95
98
  const delta = Array.isArray(e.payload.delta) ? e.payload.delta : [];
@@ -104,8 +107,9 @@ export class ClawclawReminderPlugin implements RuntimeEpochPlugin<Record<string,
104
107
  const previous = next.states[topic];
105
108
  const moduleInput: ReminderInput = {
106
109
  scope: input.epoch.scope, frame, gameState: game, taskChanges, boundary,
107
- facts: facts.map(e => ({ eventId: e.eventId, epochId: e.epochSeq, type: e.type,
108
- occurredAt: e.occurredAt, producer: e.producer, payload: e.payload })),
110
+ facts: facts.filter(e => topic !== 'speech' || !e.replayed)
111
+ .map(e => ({ eventId: e.eventId, epochId: e.epochSeq, type: e.type,
112
+ occurredAt: e.occurredAt, producer: e.producer, replayed: e.replayed, payload: e.payload })),
109
113
  config: selected.reminder!.config ?? {}, state: previous?.provider === selected.id ? previous.value : undefined,
110
114
  nowMs: input.frame.observedAtMs ?? input.frame.receivedAtMs,
111
115
  };
@@ -118,19 +122,20 @@ export class ClawclawReminderPlugin implements RuntimeEpochPlugin<Record<string,
118
122
  const accepted: RuntimeEventProposal[] = [];
119
123
  const keys = new Set<string>();
120
124
  for (const event of result.events ?? []) {
121
- if (!event || event.type !== 'reminder.task' || typeof event.key !== 'string'
125
+ if (!event || event.type !== REMINDER_EVENT_TYPE_BY_TOPIC[topic] || typeof event.key !== 'string'
122
126
  || !event.key.trim() || event.key.length > 512 || keys.has(event.key)
123
127
  || typeof event.wakeAgent !== 'boolean' || !event.payload || Array.isArray(event.payload)
124
128
  || typeof event.payload.text !== 'string' || !event.payload.text.trim()) {
125
- throw new Error('Invalid task reminder event.');
129
+ throw new Error(`Invalid ${topic} reminder event.`);
126
130
  }
127
131
  keys.add(event.key);
128
132
  accepted.push({ type: event.type, dedupeKey: JSON.stringify([selected.id, event.key]),
129
133
  dedupeScope: 'segment', wakeAgent: event.wakeAgent, payload: { ...event.payload },
130
134
  occurredAt: new Date(moduleInput.nowMs).toISOString() });
131
135
  }
132
- // Recovery/initial snapshots establish private state, never replay notices.
133
- if (!boundary && game) events.push(...accepted);
136
+ // Task snapshots establish baselines. Fresh speech remains an occurrence
137
+ // even in the first/reconnected frame; replayed speech is excluded from input.
138
+ if (game && (topic === 'speech' || !boundary)) events.push(...accepted);
134
139
  next.states[topic] = { provider: selected.id, value: structuredClone(result.state) };
135
140
  } catch (error) { this.markFailed(topic, context, error); }
136
141
  }
@@ -11,6 +11,7 @@ import type {
11
11
  RuntimeEpochPluginResult,
12
12
  } from '../../../framework/plugins/index.js';
13
13
  import { isClawclawRuntimeState } from '../../runtime-state.js';
14
+ import { projectTaskChoices, projectTaskChoiceLocations } from '../../task-choice-projection.js';
14
15
  import {
15
16
  CLAWCLAW_MAP_CAPABILITY,
16
17
  CLAWCLAW_PATH_DISTANCE_CAPABILITY,
@@ -63,7 +64,7 @@ export function clawclawTasksFromGameState(
63
64
  gameState: Record<string, any> | null | undefined,
64
65
  ): readonly Record<string, any>[] | null {
65
66
  const tasks = gameState?.you?.tasks;
66
- return Array.isArray(tasks) ? structuredClone(tasks) : null;
67
+ return Array.isArray(tasks) ? structuredClone(projectTaskChoices(gameState, tasks)) : null;
67
68
  }
68
69
 
69
70
  function clawclawPlayersFromGameState(
@@ -84,6 +85,7 @@ export function clawclawMapFromGameState(
84
85
  const tasks = clawclawTasksFromGameState(gameState);
85
86
  return {
86
87
  ...structuredClone(PACKAGED_MAP),
88
+ all_task_locations: structuredClone(projectTaskChoiceLocations(gameState, PACKAGED_MAP.all_task_locations)),
87
89
  all_players: clawclawPlayersFromGameState(gameState),
88
90
  ...(tasks === null ? {} : { your_tasks: tasks }),
89
91
  };
@@ -1,5 +1,5 @@
1
1
  import { REMINDER_PLUGIN_API_VERSION, type ClawclawReminderManifest } from '../../sdk/perception-plugin/reminder.js';
2
- import { REMINDER_FACT_TYPES } from '../../sdk/perception-plugin/reminder-rules.js';
2
+ import { REMINDER_FACT_TYPES_BY_TOPIC, REMINDER_TOPICS } from '../../sdk/perception-plugin/reminder-rules.js';
3
3
  import { hasValidClawclawResourceLocalizations } from '../../sdk/resource-metadata.js';
4
4
  import { normalizeBehaviorInput, normalizeBehaviorInputFields } from './behavior-input-fields.js';
5
5
 
@@ -13,9 +13,9 @@ export function normalizeReminderManifest(value: unknown, requireCurrentVersion
13
13
  || typeof m.description !== 'string' || !m.description.trim()
14
14
  || (m.name !== undefined && (typeof m.name !== 'string' || !m.name.trim()))
15
15
  || !hasValidClawclawResourceLocalizations(m.localizations)
16
- || m.topic !== 'tasks'
16
+ || !REMINDER_TOPICS.includes(m.topic)
17
17
  || !Array.isArray(m.consumes) || new Set(m.consumes).size !== m.consumes.length
18
- || m.consumes.some(type => !(REMINDER_FACT_TYPES as readonly string[]).includes(type))
18
+ || m.consumes.some(type => !(REMINDER_FACT_TYPES_BY_TOPIC[m.topic] as readonly string[]).includes(type))
19
19
  || (m.config !== undefined && (!m.config || typeof m.config !== 'object' || Array.isArray(m.config)))
20
20
  || Object.keys(m).some(key => !['apiVersion', 'kind', 'id', 'name', 'description', 'localizations',
21
21
  'topic', 'consumes', 'inputs', 'config'].includes(key))) throw new Error('Invalid perception reminder manifest.');
@@ -1,3 +1,5 @@
1
+ import { projectTaskChoiceGameState } from './task-choice-projection.js';
2
+
1
3
  export type ClawclawRuntimeStage =
2
4
  | 'matching'
3
5
  | 'room'
@@ -80,9 +82,9 @@ export function isClawclawRuntimeState(value: unknown): value is ClawclawRuntime
80
82
  export function projectClawclawCurrentState(
81
83
  state: Record<string, any>,
82
84
  ): Record<string, any> | null {
83
- if (!isClawclawRuntimeState(state)) return state;
85
+ if (!isClawclawRuntimeState(state)) return projectTaskChoiceGameState(state);
84
86
  if (state.connection !== 'connected') return null;
85
- if (state.game_snapshot.status === 'fresh') return structuredClone(state.game_snapshot.state);
87
+ if (state.game_snapshot.status === 'fresh') return projectTaskChoiceGameState(state.game_snapshot.state);
86
88
  if (state.stage === 'room' && state.room) return structuredClone(state.room);
87
89
  if (state.stage === 'matching' && state.queue) return structuredClone(state.queue);
88
90
  return null;
@@ -0,0 +1,93 @@
1
+ import { loadClawclawMapAsset } from '../../lib/game-context.js';
2
+
3
+ type RecordValue = Readonly<Record<string, any>>;
4
+ const record = (value: unknown): RecordValue => value && typeof value === 'object' && !Array.isArray(value)
5
+ ? value as RecordValue : {};
6
+ const label = (value: unknown): string => typeof value === 'string' ? value.trim().normalize('NFC').toLocaleLowerCase() : '';
7
+ const taskName = (task: RecordValue): string => label(task.name ?? task.task_name);
8
+ const catalog = (loadClawclawMapAsset().tasks ?? []) as readonly RecordValue[];
9
+
10
+ export function isCrabPlayer(game: unknown): boolean {
11
+ const self = record(record(game).you);
12
+ return self.faction === 'crab' || self.role === 'crab_generic';
13
+ }
14
+
15
+ export function crabSabotageReady(game: unknown): boolean {
16
+ const state = record(game), sabotage = record(state.crab_sabotage);
17
+ return sabotage.status === 'ready' && record(state.emergency).active !== true
18
+ && !(typeof sabotage.cooldown_remaining_secs === 'number' && sabotage.cooldown_remaining_secs > 0);
19
+ }
20
+
21
+ function staticTaskType(task: RecordValue): number | undefined {
22
+ const name = taskName(task);
23
+ if (!name) return undefined;
24
+ const matches = catalog.filter(candidate => label(candidate.name) === name);
25
+ const room = label(task.room);
26
+ const selected = matches.find(candidate => room && label(candidate.room) === room) ?? (matches.length === 1 ? matches[0] : undefined);
27
+ return selected ? Number(selected.task_type) : undefined;
28
+ }
29
+
30
+ /** Classify this player's task, not another player's role or a shared coordinate. */
31
+ export function isSabotageTask(game: unknown, value: unknown): boolean {
32
+ if (!isCrabPlayer(game)) return false;
33
+ const task = record(value), emergency = record(record(game).emergency);
34
+ if (task.is_fake_shrimp === true) return false;
35
+ if (emergency.active === true && taskName(task) && taskName(task) === label(emergency.task_name)) return false;
36
+ const type = staticTaskType(task);
37
+ if (type === 0 || type === 2) return false;
38
+ if (type === 1 || task.faction === 'crab' || task.task_type === 1) return true;
39
+ // GameSync's crab assignments are sabotage or fake shrimp, plus active repair.
40
+ // The false marker also covers renamed/localized sabotage names absent from the packaged map.
41
+ return task.is_fake_shrimp === false;
42
+ }
43
+
44
+ function ongoingTask(game: unknown, task: RecordValue): boolean {
45
+ const activity = record(record(record(game).you).activity);
46
+ return activity.kind === 'task' && taskName(task) && taskName(task) === label(activity.task_name) ? true : false;
47
+ }
48
+
49
+ /** Keep execution/completion facts; omit unstarted sabotage choices until authoritative readiness. */
50
+ export function projectTaskChoices<T extends RecordValue>(game: unknown, tasks: readonly T[]): T[] {
51
+ return tasks.flatMap(task => {
52
+ if (!isSabotageTask(game, task) || crabSabotageReady(game)) return [task];
53
+ if (task.status === 'completed' || task.status === 'in_progress') return [task];
54
+ // Activity is an authoritative execution fact even if its task-status update lags.
55
+ if (ongoingTask(game, task)) return [{ ...task, status: 'in_progress' } as T];
56
+ return [];
57
+ });
58
+ }
59
+
60
+ /** A public projection only. Persisted Source snapshots and task-change history remain untouched. */
61
+ export function projectTaskChoiceGameState<T extends Record<string, any>>(source: T): T {
62
+ const game: Record<string, any> = structuredClone(source);
63
+ if (Array.isArray(game.you?.tasks)) game.you.tasks = projectTaskChoices(source, game.you.tasks);
64
+ return game as T;
65
+ }
66
+
67
+ /** Map task locations are not assignments, but must not recreate blocked sabotage choices. */
68
+ export function projectTaskChoiceLocations<T extends RecordValue>(game: unknown, locations: readonly T[]): T[] {
69
+ return locations.filter(task => !isSabotageTask(game, task) || crabSabotageReady(game));
70
+ }
71
+
72
+ /** Current assignment arrays in module input follow the same policy; occurrence facts survive. */
73
+ export function projectTaskChoiceEventPayload(game: unknown, type: string, payload: RecordValue): Record<string, any> {
74
+ const result: Record<string, any> = structuredClone(payload);
75
+ if (type === 'tasks_changed') {
76
+ if (Array.isArray(result.tasks)) result.tasks = projectTaskChoices(game, result.tasks);
77
+ if (Array.isArray(result.delta)) result.delta = result.delta.filter(change =>
78
+ change.change === 'removed' || projectTaskChoices(game, [record(change.task)]).length > 0);
79
+ }
80
+ if (result.newly_assigned_task && projectTaskChoices(game, [record(result.newly_assigned_task)]).length === 0) {
81
+ delete result.newly_assigned_task;
82
+ }
83
+ return result;
84
+ }
85
+
86
+ /** Also reject stale/remembered task names at the Action boundary, before HTTP submission. */
87
+ export function sabotageTaskActionBlocked(game: unknown, name: unknown): boolean {
88
+ if (!isCrabPlayer(game) || crabSabotageReady(game) || !label(name)) return false;
89
+ const state = record(game), tasks = record(state.you).tasks;
90
+ const assigned = Array.isArray(tasks) ? tasks.filter(task => taskName(record(task)) === label(name)) : [];
91
+ if (assigned.length) return assigned.some(task => isSabotageTask(game, task));
92
+ return isSabotageTask(game, { name });
93
+ }
@@ -110,7 +110,6 @@ export const CLAWCLAW_BACKEND_AGENT_EVENT_TYPES = [
110
110
  'no_exile',
111
111
  'vote_speech_phase_ended',
112
112
  'death_speech',
113
- 'wandering_speech',
114
113
  'meeting_briefing',
115
114
  'speech',
116
115
  'speech_skipped',
@@ -181,6 +180,7 @@ export const CLAWCLAW_LOCAL_AGENT_EVENT_TYPES = [
181
180
  'behavior.replaced',
182
181
  'players_changed',
183
182
  'reminder.task',
183
+ 'reminder.speech',
184
184
  'emergency_countdown_warning',
185
185
  'ability.ready',
186
186
  'ability.remaining_uses_changed',
@@ -189,6 +189,7 @@ export const CLAWCLAW_LOCAL_AGENT_EVENT_TYPES = [
189
189
 
190
190
  /** Durable inputs used by projectors, but never sent directly to the Agent. */
191
191
  export const CLAWCLAW_INTERNAL_BACKEND_EVENT_TYPES = [
192
+ 'wandering_speech',
192
193
  'task_completed',
193
194
  'task_interrupted',
194
195
  'task_sabotaged',
@@ -44,6 +44,7 @@ export interface GameSelf {
44
44
  readonly kills_remaining?: number | null;
45
45
  readonly activity?: Readonly<GamePlayerActivity>;
46
46
  readonly crab_teammates?: readonly Readonly<PlayerRef>[];
47
+ /** Current task choices and execution/completion facts. Unstarted crab sabotage is omitted until ready. */
47
48
  readonly tasks?: readonly Readonly<GameTask>[];
48
49
  }
49
50
 
@@ -1,12 +1,18 @@
1
1
  import type { ReminderInput, ReminderMode, ReminderResult, ReminderTopic, ReminderFact, ReminderTaskChange, ReminderEvent } from './reminder.js';
2
2
 
3
- export const REMINDER_FACT_TYPES = [
3
+ export const TASK_REMINDER_FACT_TYPES = [
4
4
  'ability.ready', 'ability.remaining_uses_changed', 'ability.exhausted', 'tasks_changed',
5
5
  'task_started', 'task_progress', 'task_assigned', 'task_completed', 'task_interrupted', 'task_sabotaged',
6
6
  'role_assigned', 'emergency_started', 'emergency_resolved', 'emergency_interrupted', 'meeting_briefing',
7
7
  ] as const;
8
- export const REMINDER_EVENT_TYPES = ['reminder.task'] as const;
9
- export const REMINDER_TOPICS: readonly ReminderTopic[] = ['tasks'];
8
+ export const REMINDER_FACT_TYPES_BY_TOPIC = {
9
+ tasks: TASK_REMINDER_FACT_TYPES,
10
+ speech: ['wandering_speech'],
11
+ } as const;
12
+ export const REMINDER_EVENT_TYPE_BY_TOPIC = { tasks: 'reminder.task', speech: 'reminder.speech' } as const;
13
+ export const REMINDER_FACT_TYPES = [...TASK_REMINDER_FACT_TYPES, 'wandering_speech'] as const;
14
+ export const REMINDER_EVENT_TYPES = ['reminder.task', 'reminder.speech'] as const;
15
+ export const REMINDER_TOPICS: readonly ReminderTopic[] = ['tasks', 'speech'];
10
16
  export function isReminderMode(value: unknown): value is ReminderMode {
11
17
  return value === 'wake' || value === 'silent' || value === 'state_only';
12
18
  }
@@ -61,8 +67,31 @@ function explained(fact: ReminderFact, change: ReminderTaskChange, input: Remind
61
67
  }
62
68
  return false;
63
69
  }
64
- /** Optional task policy: classify individual changes, never re-deliver the whole raw fact. */
70
+ /** Nearby speech is a backend fact; only its Agent notification is optional. */
71
+ export function speechReminder(input: ReminderInput): ReminderResult {
72
+ if (Object.keys(input.config).some(key => key !== 'receive')
73
+ || (input.config.receive !== undefined && typeof input.config.receive !== 'boolean')) {
74
+ throw new Error('Speech reminder config must contain only a boolean receive.');
75
+ }
76
+ if (input.config.receive === false) return { events: [] };
77
+ const self = input.gameState?.you?.player;
78
+ return { events: input.facts.flatMap(fact => {
79
+ if (fact.type !== 'wandering_speech' || fact.replayed) return [];
80
+ const actor = record(fact.payload.actor);
81
+ const seat = actor.seat ?? fact.payload.actor_seat;
82
+ const name = actor.name ?? fact.payload.actor_name;
83
+ // GameSync includes the speaker among the frozen nearby recipients.
84
+ const own = seat !== undefined && self?.seat !== undefined ? seat === self.seat
85
+ : typeof name === 'string' && self?.name !== undefined && name === self.name;
86
+ if (own || typeof fact.payload.text !== 'string' || !fact.payload.text.trim()) return [];
87
+ return [{ type: 'reminder.speech' as const, key: `fact:${fact.eventId}`, wakeAgent: true,
88
+ payload: { ...fact.payload, text: fact.payload.text, source_event_id: fact.eventId } }];
89
+ }) };
90
+ }
91
+
92
+ /** Optional reminder policy; raw facts always remain available to computation plugins. */
65
93
  export function defaultReminder(topic: ReminderTopic, input: ReminderInput): ReminderResult {
94
+ if (topic === 'speech') return speechReminder(input);
66
95
  const config = validateDefaultConfig(topic, input.config);
67
96
  const events: ReminderEvent[] = [];
68
97
  if (input.boundary) return { events };
@@ -3,9 +3,12 @@ import type { BehaviorInputFieldSpec } from '../behavior-plugin/index.js';
3
3
 
4
4
  /** Reminder classes use the same public Perception API version and resource lifecycle. */
5
5
  export const REMINDER_PLUGIN_API_VERSION = 2 as const;
6
- export type ReminderTopic = 'tasks';
6
+ export type ReminderTopic = 'tasks' | 'speech';
7
7
  export type ReminderMode = 'wake' | 'silent' | 'state_only';
8
- export interface ReminderFact extends GameEvent { readonly producer: 'backend_push' | 'local_synth' }
8
+ export interface ReminderFact extends GameEvent {
9
+ readonly producer: 'backend_push' | 'local_synth';
10
+ readonly replayed?: boolean;
11
+ }
9
12
  /** Structural task changes, not Agent notifications or inferred completion facts. */
10
13
  export interface ReminderTaskChange {
11
14
  readonly key: string;
@@ -37,7 +40,7 @@ export interface ReminderResult {
37
40
  readonly events?: readonly ReminderEvent[];
38
41
  }
39
42
  export interface ReminderEvent {
40
- readonly type: 'reminder.task';
43
+ readonly type: 'reminder.task' | 'reminder.speech';
41
44
  /** Stable per occurrence, retained across retry/recovery. */
42
45
  readonly key: string;
43
46
  readonly wakeAgent: boolean;