@myclaw163/clawclaw-cli 0.10.11 → 0.10.13
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/bin/clawclaw-cli.mjs +15 -6
- package/bin/startup-trace.d.mts +9 -0
- package/bin/startup-trace.mjs +100 -0
- package/cli-runtime/assets/clawclaw-map.json +1782 -0
- package/cli-runtime/assets/clawclaw-spatial-facts.json +1383 -0
- package/cli-runtime/assets/clawclaw-spatial-model.txt +142 -0
- package/cli-runtime/channel/claude-channel-ipc-server.js +220 -0
- package/cli-runtime/channel/claude-channel-ipc.js +135 -0
- package/cli-runtime/channel/claude-channel-server.js +209 -0
- package/cli-runtime/cli.js +81 -0
- package/cli-runtime/commands/_schema.js +60 -0
- package/cli-runtime/commands/account.js +577 -0
- package/cli-runtime/commands/auth.js +140 -0
- package/cli-runtime/commands/behavior.js +422 -0
- package/cli-runtime/commands/capability.js +327 -0
- package/cli-runtime/commands/communication.js +339 -0
- package/cli-runtime/commands/competition.js +55 -0
- package/cli-runtime/commands/config.js +28 -0
- package/cli-runtime/commands/data.js +78 -0
- package/cli-runtime/commands/events.js +339 -0
- package/cli-runtime/commands/game/index.js +646 -0
- package/cli-runtime/commands/hub.js +152 -0
- package/cli-runtime/commands/load.js +22 -0
- package/cli-runtime/commands/memory.js +30 -0
- package/cli-runtime/commands/module-runtime-control.js +110 -0
- package/cli-runtime/commands/peek.js +38 -0
- package/cli-runtime/commands/perception.js +146 -0
- package/cli-runtime/commands/persona.js +165 -0
- package/cli-runtime/commands/prepare.js +878 -0
- package/cli-runtime/commands/setup/codex.js +244 -0
- package/cli-runtime/commands/setup/hermes.js +55 -0
- package/cli-runtime/commands/setup/index.js +15 -0
- package/cli-runtime/commands/setup/openclaw.js +103 -0
- package/cli-runtime/commands/skill.js +76 -0
- package/cli-runtime/commands/strategy.js +4 -0
- package/cli-runtime/commands/trigger.js +271 -0
- package/cli-runtime/commands/upgrade.js +112 -0
- package/cli-runtime/lib/account-guidance.js +97 -0
- package/cli-runtime/lib/agent-workspace-client.js +66 -0
- package/cli-runtime/lib/agent-workspace-runtime.js +174 -0
- package/cli-runtime/lib/agent-workspace-skills.js +453 -0
- package/cli-runtime/lib/agent-workspace-sync.js +812 -0
- package/cli-runtime/lib/auth.js +210 -0
- package/cli-runtime/lib/capability-cloud-presence.js +134 -0
- package/cli-runtime/lib/capability-cloud-refresh.js +263 -0
- package/cli-runtime/lib/capability-cloud-sync.js +385 -0
- package/cli-runtime/lib/capability-discovery.js +94 -0
- package/cli-runtime/lib/capability-load-diagnostics.js +121 -0
- package/cli-runtime/lib/capability-operation-name.js +24 -0
- package/cli-runtime/lib/capability-operation-rename.js +120 -0
- package/cli-runtime/lib/capability-selection.js +69 -0
- package/cli-runtime/lib/capability-workspace.js +214 -0
- package/cli-runtime/lib/command-error.js +25 -0
- package/cli-runtime/lib/command-meta.js +13 -0
- package/cli-runtime/lib/competition.js +77 -0
- package/cli-runtime/lib/custom-tts.js +363 -0
- package/cli-runtime/lib/desktop-auth.js +44 -0
- package/cli-runtime/lib/desktop-mode.js +12 -0
- package/cli-runtime/lib/diagnostics-config.js +82 -0
- package/cli-runtime/lib/game-client.js +602 -0
- package/cli-runtime/lib/game-context.js +117 -0
- package/cli-runtime/lib/gameplay-config.js +232 -0
- package/cli-runtime/lib/host-config-patcher.js +101 -0
- package/cli-runtime/lib/http-keepalive.js +15 -0
- package/cli-runtime/lib/http-transport.js +163 -0
- package/cli-runtime/lib/hub-client.js +292 -0
- package/cli-runtime/lib/hub-errors.js +51 -0
- package/cli-runtime/lib/hub-reminder.js +65 -0
- package/cli-runtime/lib/hub-unzip.js +52 -0
- package/cli-runtime/lib/init-command.js +160 -0
- package/cli-runtime/lib/load-context.js +97 -0
- package/cli-runtime/lib/load-startup-context.js +59 -0
- package/cli-runtime/lib/load-startup.js +23 -0
- package/cli-runtime/lib/lobby-host-context.js +70 -0
- package/cli-runtime/lib/match-state.js +61 -0
- package/cli-runtime/lib/normalize.js +28 -0
- package/cli-runtime/lib/package-skills.js +15 -0
- package/cli-runtime/lib/participation-leave.js +54 -0
- package/cli-runtime/lib/participation-status.js +73 -0
- package/cli-runtime/lib/perception-config.js +85 -0
- package/cli-runtime/lib/persona.js +157 -0
- package/cli-runtime/lib/room.js +108 -0
- package/cli-runtime/lib/runtime-cadence-config.js +18 -0
- package/cli-runtime/lib/server-registry.js +155 -0
- package/cli-runtime/lib/server-status.js +44 -0
- package/cli-runtime/lib/service-status.js +88 -0
- package/cli-runtime/lib/skill-host.js +246 -0
- package/cli-runtime/lib/skill-name-conflicts.js +89 -0
- package/cli-runtime/lib/skill-version.js +20 -0
- package/cli-runtime/lib/training-role.js +23 -0
- package/cli-runtime/lib/trigger-config.js +138 -0
- package/cli-runtime/lib/user-data.js +336 -0
- package/cli-runtime/lib/workspace-argv.js +35 -0
- package/cli-runtime/lib/workspace-runtime-lock.js +6 -0
- package/cli-runtime/lib/zip-store.js +78 -0
- package/cli-runtime/pipeline/canonical-event-presentation.js +32 -0
- package/cli-runtime/pipeline/event-format.js +921 -0
- package/cli-runtime/pipeline/event-hints.js +235 -0
- package/cli-runtime/pipeline/game-sync-event-normalization.js +228 -0
- package/cli-runtime/pipeline/player-projection.js +272 -0
- package/cli-runtime/pipeline/role-display.js +22 -0
- package/cli-runtime/runtime/auto-upgrade.js +30 -0
- package/cli-runtime/runtime/canonical-event-emitter.js +58 -0
- package/cli-runtime/runtime/canonical-monitor.js +332 -0
- package/cli-runtime/runtime/clawclaw/agent-ability-state.js +41 -0
- package/cli-runtime/runtime/clawclaw/agent-event-policy.js +58 -0
- package/cli-runtime/runtime/clawclaw/behavior-decision.js +84 -0
- package/cli-runtime/runtime/clawclaw/behavior-input-fields.js +212 -0
- package/cli-runtime/runtime/clawclaw/behavior-input.js +54 -0
- package/cli-runtime/runtime/clawclaw/behavior-observation-memory.js +106 -0
- package/cli-runtime/runtime/clawclaw/behavior-read-api.js +110 -0
- package/cli-runtime/runtime/clawclaw/behavior-reflex-control.js +97 -0
- package/cli-runtime/runtime/clawclaw/behavior-start-control.js +159 -0
- package/cli-runtime/runtime/clawclaw/index.js +3 -0
- package/cli-runtime/runtime/clawclaw/navigation/astar-path.js +244 -0
- package/cli-runtime/runtime/clawclaw/navigation/clawclaw-walkable.bin +0 -0
- package/cli-runtime/runtime/clawclaw/navigation/distance-field.js +136 -0
- package/cli-runtime/runtime/clawclaw/navigation/escape-planner.js +273 -0
- package/cli-runtime/runtime/clawclaw/navigation/hide-spots.js +31 -0
- package/cli-runtime/runtime/clawclaw/navigation/off-route-points.js +64 -0
- package/cli-runtime/runtime/clawclaw/navigation/walkable-grid.js +85 -0
- package/cli-runtime/runtime/clawclaw/notification-policy.js +59 -0
- package/cli-runtime/runtime/clawclaw/notification-turn.js +28 -0
- package/cli-runtime/runtime/clawclaw/notifications.js +65 -0
- package/cli-runtime/runtime/clawclaw/observation-frame-projector.js +94 -0
- package/cli-runtime/runtime/clawclaw/owner-lock-error.js +17 -0
- package/cli-runtime/runtime/clawclaw/owner-lock.js +219 -0
- package/cli-runtime/runtime/clawclaw/owner.js +1257 -0
- package/cli-runtime/runtime/clawclaw/perception-module-manifest.js +67 -0
- package/cli-runtime/runtime/clawclaw/perception-strategy-names.js +12 -0
- package/cli-runtime/runtime/clawclaw/persistence-compatibility.js +38 -0
- package/cli-runtime/runtime/clawclaw/plugins/action/action-plugin.js +604 -0
- package/cli-runtime/runtime/clawclaw/plugins/action/automated-action-normalization.js +67 -0
- package/cli-runtime/runtime/clawclaw/plugins/action/index.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/assembly.js +134 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/activation-manager.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-action.js +26 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.js +21 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-analysis-thread-host.ts +25 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-catalog.js +90 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-decision-history.js +60 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-instance-snapshot.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-manifest.js +136 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-module-loader.js +230 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-normalization.js +92 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-plugin.js +162 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-runner.js +20 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-source.js +493 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.js +28 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/control-driver.js +5 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/index.js +11 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior/thread-behavior-executor.js +18 -0
- package/cli-runtime/runtime/clawclaw/plugins/behavior-input-source.js +233 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/derived-event-plugin.js +25 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/derived-event-rules.js +289 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/index.js +2 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/player-change-tracker.js +162 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-plugin.js +182 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-rules.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-runner.js +83 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-worker.js +35 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/reminder-worker.ts +33 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/state-change-rules.js +111 -0
- package/cli-runtime/runtime/clawclaw/plugins/derived-event/task-change-tracker.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/game-query/context-capabilities.js +10 -0
- package/cli-runtime/runtime/clawclaw/plugins/game-query/game-query-plugin.js +196 -0
- package/cli-runtime/runtime/clawclaw/plugins/game-query/index.js +2 -0
- package/cli-runtime/runtime/clawclaw/plugins/index.js +9 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-adapter.js +24 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/claude-channel-socket.js +21 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/game-sync-perception-report-adapter.js +84 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/adapters/game-sync-runtime-report-adapter.js +54 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/agent-mailbox-coordinator.js +61 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/consumer-ids.js +10 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/desktop-event-socket.js +45 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/index.js +11 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-event-batch-delivery.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-plugin.js +13 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-presentation.js +99 -0
- package/cli-runtime/runtime/clawclaw/plugins/mailbox/mailbox-service.js +84 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/contracts.js +14 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/index.js +11 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/map-concurrent.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/module-input-boundary.js +64 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/module-runner.js +182 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/notification-content.js +47 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/official-module-ids.js +13 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-pool.js +684 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.js +145 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-analysis-thread-worker.ts +252 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-loader.js +78 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-output.js +15 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-plugin.js +144 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-runner.js +22 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.js +18 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-module-worker.ts +19 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-plugin.js +1343 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-pool.js +522 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-worker.js +161 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-reducer-thread-worker.ts +262 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-source.js +489 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/perception-test-fixtures.js +31 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/replay.js +56 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/report-content.js +39 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/shared/math.js +1 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/spatial-facts.js +103 -0
- package/cli-runtime/runtime/clawclaw/plugins/perception/task-baseline.js +29 -0
- package/cli-runtime/runtime/clawclaw/plugins/plugin-api-version.js +89 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/game-transport.js +204 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/index.js +5 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/room-transport.js +399 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/source-plugin.js +2003 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/source-transports.js +26 -0
- package/cli-runtime/runtime/clawclaw/plugins/source/types.js +0 -0
- package/cli-runtime/runtime/clawclaw/plugins/system-perception/rule-runner.js +90 -0
- package/cli-runtime/runtime/clawclaw/plugins/system-perception/sabotage-availability-rule.js +59 -0
- package/cli-runtime/runtime/clawclaw/plugins/system-perception/system-perceptions.js +241 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/contracts.js +12 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/index.js +4 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-module-loader.js +105 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-plugin.js +741 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-source.js +372 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-pool.js +378 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.js +118 -0
- package/cli-runtime/runtime/clawclaw/plugins/trigger/trigger-thread-worker.ts +168 -0
- package/cli-runtime/runtime/clawclaw/reaction-behavior-resolution.js +1 -0
- package/cli-runtime/runtime/clawclaw/reaction-manifest.js +62 -0
- package/cli-runtime/runtime/clawclaw/reminder-manifest.js +39 -0
- package/cli-runtime/runtime/clawclaw/runtime-cadence.js +28 -0
- package/cli-runtime/runtime/clawclaw/runtime-data-export.js +321 -0
- package/cli-runtime/runtime/clawclaw/runtime-state.js +51 -0
- package/cli-runtime/runtime/clawclaw/runtime.js +132 -0
- package/cli-runtime/runtime/clawclaw/spatial-api.js +48 -0
- package/cli-runtime/runtime/clawclaw/starting-owner-control.js +24 -0
- package/cli-runtime/runtime/clawclaw/strategy-memory-rpc.js +1 -0
- package/cli-runtime/runtime/clawclaw/strategy-memory.js +6 -0
- package/cli-runtime/runtime/clawclaw/task-choice-projection.js +72 -0
- package/cli-runtime/runtime/clawclaw-event-catalog.js +284 -0
- package/cli-runtime/runtime/clawclaw-position.js +0 -0
- package/cli-runtime/runtime/clawclaw-room-state.js +38 -0
- package/cli-runtime/runtime/framework/action-diagnostics.js +69 -0
- package/cli-runtime/runtime/framework/capability-registry.js +1 -0
- package/cli-runtime/runtime/framework/contracts.js +1 -0
- package/cli-runtime/runtime/framework/control/control-scheduler.js +1 -0
- package/cli-runtime/runtime/framework/control/domain-set.js +1 -0
- package/cli-runtime/runtime/framework/control/index.js +1 -0
- package/cli-runtime/runtime/framework/control/types.js +1 -0
- package/cli-runtime/runtime/framework/control-coordinator.js +1 -0
- package/cli-runtime/runtime/framework/events/event-catalog.js +1 -0
- package/cli-runtime/runtime/framework/events/event-delivery-service.js +1 -0
- package/cli-runtime/runtime/framework/events/event-ingress.js +1 -0
- package/cli-runtime/runtime/framework/events/event-repository.js +1 -0
- package/cli-runtime/runtime/framework/events/index.js +5 -0
- package/cli-runtime/runtime/framework/events/memory-event-repository.js +1 -0
- package/cli-runtime/runtime/framework/events/runtime-resume.js +1 -0
- package/cli-runtime/runtime/framework/events/sqlite-event-repository.js +6 -0
- package/cli-runtime/runtime/framework/events/test-helpers.js +56 -0
- package/cli-runtime/runtime/framework/events/types.js +1 -0
- package/cli-runtime/runtime/framework/index.js +7 -0
- package/cli-runtime/runtime/framework/load-node-sqlite.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/coalescer.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/host-notification-sink.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/identity.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/index.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/mailbox-dispatcher.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/mailbox-repository.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/notification-projector.js +1 -0
- package/cli-runtime/runtime/framework/mailbox/types.js +1 -0
- package/cli-runtime/runtime/framework/modules/runtime-module-loader-hooks.mjs +2 -0
- package/cli-runtime/runtime/framework/modules/runtime-module-loader.js +31 -0
- package/cli-runtime/runtime/framework/modules/runtime-module-output.js +1 -0
- package/cli-runtime/runtime/framework/modules/runtime-module-worker-bootstrap.mjs +3 -0
- package/cli-runtime/runtime/framework/participation-manager.js +1 -0
- package/cli-runtime/runtime/framework/persistence/async-sqlite-persistence-worker.js +1 -0
- package/cli-runtime/runtime/framework/persistence/async-sqlite-persistence-worker.ts +2 -0
- package/cli-runtime/runtime/framework/persistence/memory-first-persistence.js +9 -0
- package/cli-runtime/runtime/framework/plugins/contracts.js +1 -0
- package/cli-runtime/runtime/framework/plugins/index.js +1 -0
- package/cli-runtime/runtime/framework/plugins/runtime-event-identity.js +1 -0
- package/cli-runtime/runtime/framework/plugins/runtime-input-journal.js +1 -0
- package/cli-runtime/runtime/framework/plugins/runtime-plugin-scheduler.js +1 -0
- package/cli-runtime/runtime/framework/runtime.js +12 -0
- package/cli-runtime/runtime/framework/serial-task-queue.js +1 -0
- package/cli-runtime/runtime/framework/state/contracts.js +1 -0
- package/cli-runtime/runtime/framework/state/current-state-store.js +1 -0
- package/cli-runtime/runtime/framework/state/durable-agent-state-snapshot.js +1 -0
- package/cli-runtime/runtime/framework/state/freshness.js +1 -0
- package/cli-runtime/runtime/framework/state/history/contracts.js +1 -0
- package/cli-runtime/runtime/framework/state/history/history-writer.js +1 -0
- package/cli-runtime/runtime/framework/state/history/memory-state-history-repository.js +1 -0
- package/cli-runtime/runtime/framework/state/history/sqlite-state-history-repository.js +1 -0
- package/cli-runtime/runtime/framework/state/history/trajectory-projector.js +1 -0
- package/cli-runtime/runtime/framework/state/index.js +1 -0
- package/cli-runtime/runtime/framework/state/state-ingress.js +1 -0
- package/cli-runtime/runtime/framework/state/state-provider.js +1 -0
- package/cli-runtime/runtime/framework/state/types.js +1 -0
- package/cli-runtime/runtime/game-sync-ingress-protocol.js +0 -0
- package/cli-runtime/runtime/game-sync-ingress-worker.js +310 -0
- package/cli-runtime/runtime/game-sync-ingress-worker.ts +274 -0
- package/cli-runtime/runtime/game-sync-protocol.js +278 -0
- package/cli-runtime/runtime/host-monitor-rate-gate.js +1 -0
- package/cli-runtime/runtime/mailbox-host-relay.js +1 -0
- package/cli-runtime/runtime/observability/detail-capture.js +35 -0
- package/cli-runtime/runtime/observability/factory.js +137 -0
- package/cli-runtime/runtime/observability/index.js +6 -0
- package/cli-runtime/runtime/observability/process-timing.js +1 -0
- package/cli-runtime/runtime/observability/recorder.js +1 -0
- package/cli-runtime/runtime/observability/redaction.js +1 -0
- package/cli-runtime/runtime/observability/reporter.js +1 -0
- package/cli-runtime/runtime/observability/sinks.js +1 -0
- package/cli-runtime/runtime/observability/types.js +1 -0
- package/cli-runtime/runtime/owner-control.js +59 -0
- package/cli-runtime/runtime/parent-process-watch.js +1 -0
- package/cli-runtime/runtime/pending-event-handoff.js +48 -0
- package/cli-runtime/runtime/process-identity.js +45 -0
- package/cli-runtime/runtime/raw-ws-log.js +181 -0
- package/cli-runtime/runtime/runtime-logger.js +79 -0
- package/cli-runtime/runtime/threaded-ws-client.js +263 -0
- package/cli-runtime/runtime/ws-client.js +563 -0
- package/cli-runtime/sdk/action.js +133 -0
- package/cli-runtime/sdk/action.ts +160 -0
- package/cli-runtime/sdk/behavior-plugin/index.js +23 -0
- package/cli-runtime/sdk/behavior-plugin/index.ts +341 -0
- package/cli-runtime/sdk/behavior-toolkit/corpse-search.js +56 -0
- package/cli-runtime/sdk/behavior-toolkit/corpse-search.ts +87 -0
- package/cli-runtime/sdk/behavior-toolkit/escape.js +25 -0
- package/cli-runtime/sdk/behavior-toolkit/escape.ts +40 -0
- package/cli-runtime/sdk/behavior-toolkit/index.js +7 -0
- package/cli-runtime/sdk/behavior-toolkit/index.ts +7 -0
- package/cli-runtime/sdk/behavior-toolkit/kill-flow.js +239 -0
- package/cli-runtime/sdk/behavior-toolkit/kill-flow.ts +299 -0
- package/cli-runtime/sdk/behavior-toolkit/model.js +183 -0
- package/cli-runtime/sdk/behavior-toolkit/model.ts +265 -0
- package/cli-runtime/sdk/behavior-toolkit/move-gate.js +30 -0
- package/cli-runtime/sdk/behavior-toolkit/move-gate.ts +52 -0
- package/cli-runtime/sdk/behavior-toolkit/patrol.js +39 -0
- package/cli-runtime/sdk/behavior-toolkit/patrol.ts +53 -0
- package/cli-runtime/sdk/behavior-toolkit/search.js +81 -0
- package/cli-runtime/sdk/behavior-toolkit/search.ts +102 -0
- package/cli-runtime/sdk/index.js +78 -0
- package/cli-runtime/sdk/index.ts +136 -0
- package/cli-runtime/sdk/module-input/index.js +0 -0
- package/cli-runtime/sdk/module-input/index.ts +310 -0
- package/cli-runtime/sdk/perception-plugin/index.js +79 -0
- package/cli-runtime/sdk/perception-plugin/index.ts +251 -0
- package/cli-runtime/sdk/perception-plugin/lifecycle.js +18 -0
- package/cli-runtime/sdk/perception-plugin/lifecycle.ts +15 -0
- package/cli-runtime/sdk/perception-plugin/math.js +99 -0
- package/cli-runtime/sdk/perception-plugin/math.ts +107 -0
- package/cli-runtime/sdk/perception-plugin/module.js +4 -0
- package/cli-runtime/sdk/perception-plugin/module.ts +80 -0
- package/cli-runtime/sdk/perception-plugin/reaction.js +6 -0
- package/cli-runtime/sdk/perception-plugin/reaction.ts +79 -0
- package/cli-runtime/sdk/perception-plugin/reminder-rules.js +131 -0
- package/cli-runtime/sdk/perception-plugin/reminder-rules.ts +89 -0
- package/cli-runtime/sdk/perception-plugin/reminder.js +8 -0
- package/cli-runtime/sdk/perception-plugin/reminder.ts +68 -0
- package/cli-runtime/sdk/perception-plugin/task-change-tracker.js +150 -0
- package/cli-runtime/sdk/perception-plugin/task-change-tracker.ts +258 -0
- package/cli-runtime/sdk/resource-metadata.js +27 -0
- package/cli-runtime/sdk/resource-metadata.ts +66 -0
- package/cli-runtime/sdk/strategy-memory.js +1 -0
- package/cli-runtime/sdk/strategy-memory.ts +1 -0
- package/cli-runtime/sdk/strategy-plugin/index.js +6 -0
- package/cli-runtime/sdk/strategy-plugin/index.ts +36 -0
- package/cli-runtime/sdk/task-availability.js +56 -0
- package/cli-runtime/sdk/task-availability.ts +70 -0
- package/cli-runtime/sdk/trigger-plugin/index.js +16 -0
- package/cli-runtime/sdk/trigger-plugin/index.ts +130 -0
- package/cli-runtime/sdk/types.js +25 -0
- package/cli-runtime/sdk/types.ts +165 -0
- package/cli-runtime/short-command/classifier.js +129 -0
- package/cli-runtime/short-command/index.js +7 -0
- package/cli-runtime/short-command/presenter.js +225 -0
- package/cli-runtime/short-command/process-io.js +13 -0
- package/cli-runtime/short-command/response-contract.js +24 -0
- package/cli-runtime/short-command/runner.js +94 -0
- package/cli-runtime/short-command/sensitive-data-filter.js +92 -0
- package/cli-runtime/short-command/transport-response.js +57 -0
- package/cli-runtime/short-command/types.js +0 -0
- package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/host.js +21 -29
- package/dist/strategy-worker/runtime/clawclaw/plugins/behavior/sdk-sdk.js +76 -6
- package/docs/configuration.md +13 -0
- package/package.json +7 -4
- package/scripts/build-cli.mjs +34 -0
- package/skills/clawclaw/SKILL.md +1 -1
- package/skills/clawclaw/references/STREAM.md +1 -0
- package/skills/clawclaw-start/SKILL.md +1 -0
- package/skills/clawclaw-start/references/STARTUP.md +1 -0
- package/src/cli.ts +75 -77
- package/src/commands/auth.ts +3 -2
- package/src/commands/game/index.ts +33 -9
- package/src/commands/prepare.ts +34 -18
- package/src/lib/agent-workspace-client.ts +12 -9
- package/src/lib/game-client.ts +1 -1
- package/src/lib/http-transport.ts +17 -2
- package/src/lib/hub-client.ts +10 -7
- package/src/pipeline/event-format.ts +2 -0
- package/src/pipeline/event-hints.ts +6 -0
- package/src/runtime/clawclaw/notification-policy.ts +1 -1
- package/src/runtime/clawclaw/owner-lock.ts +3 -2
- package/src/runtime/clawclaw/owner.ts +36 -10
- package/src/runtime/clawclaw/plugins/behavior/behavior-worker-bridge.ts +1 -1
- package/src/runtime/clawclaw/plugins/mailbox/desktop-event-socket.ts +19 -0
- package/src/runtime/clawclaw/plugins/mailbox/mailbox-service.ts +1 -0
- package/src/runtime/clawclaw/plugins/source/source-plugin.ts +33 -9
- package/src/runtime/clawclaw-event-catalog.ts +1 -0
- package/src/runtime/framework/modules/runtime-module-loader.ts +24 -29
- package/src/runtime/process-identity.ts +44 -0
|
@@ -0,0 +1,921 @@
|
|
|
1
|
+
import { projectPlayers } from "./player-projection.js";
|
|
2
|
+
import { headingDirection } from "../runtime/clawclaw/plugins/perception/shared/math.js";
|
|
3
|
+
import { isRoomMode } from "../lib/room.js";
|
|
4
|
+
import { isSelfKillerMurderWitnessed } from "./event-hints.js";
|
|
5
|
+
import { projectAgentAbilities } from "../runtime/clawclaw/agent-ability-state.js";
|
|
6
|
+
import { roleDisplayName } from "./role-display.js";
|
|
7
|
+
function cleanObject(obj) {
|
|
8
|
+
for (const key of Object.keys(obj)) {
|
|
9
|
+
if (obj[key] === void 0) delete obj[key];
|
|
10
|
+
}
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
function isRoomGameEvent(event, ctx) {
|
|
14
|
+
return isRoomMode(event.game_mode) || isRoomMode(ctx.summary?.game?.mode) || isRoomMode(ctx.summary?.game_mode);
|
|
15
|
+
}
|
|
16
|
+
function text(value, fallback = "?") {
|
|
17
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
18
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
19
|
+
return fallback;
|
|
20
|
+
}
|
|
21
|
+
function numberValue(value) {
|
|
22
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
23
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
24
|
+
const parsed = Number(value);
|
|
25
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
26
|
+
}
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
function stringValue(value) {
|
|
30
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
31
|
+
}
|
|
32
|
+
function killerRoleSuffix(event) {
|
|
33
|
+
if (event.killer_kind === "system") return "";
|
|
34
|
+
const role = roleDisplayName(event.killer_role, "zh-CN");
|
|
35
|
+
return role ? `\uFF08${role}\uFF09` : "";
|
|
36
|
+
}
|
|
37
|
+
function trainingRoomTypeLabel(value) {
|
|
38
|
+
if (value === "training_simulation") return "\u6A21\u62DF\u8BAD\u7EC3";
|
|
39
|
+
if (value === "training_dummy") return "\u6728\u6869\u8BAD\u7EC3";
|
|
40
|
+
return text(value);
|
|
41
|
+
}
|
|
42
|
+
function sceneDistance(item, observer) {
|
|
43
|
+
const reported = numberValue(item.distance);
|
|
44
|
+
if (reported !== void 0) return Math.round(reported * 10) / 10;
|
|
45
|
+
const observerX = numberValue(observer.x);
|
|
46
|
+
const observerY = numberValue(observer.y);
|
|
47
|
+
const itemX = numberValue(item.x);
|
|
48
|
+
const itemY = numberValue(item.y);
|
|
49
|
+
if (observerX === void 0 || observerY === void 0 || itemX === void 0 || itemY === void 0) {
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
return Math.round(Math.hypot(itemX - observerX, itemY - observerY) * 10) / 10;
|
|
53
|
+
}
|
|
54
|
+
function sceneDirection(item, observer) {
|
|
55
|
+
const observerX = numberValue(observer.x);
|
|
56
|
+
const observerY = numberValue(observer.y);
|
|
57
|
+
const itemX = numberValue(item.x);
|
|
58
|
+
const itemY = numberValue(item.y);
|
|
59
|
+
if (observerX === void 0 || observerY === void 0 || itemX === void 0 || itemY === void 0) {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
return headingDirection({ x: observerX, y: observerY }, { x: itemX, y: itemY }, 1);
|
|
63
|
+
}
|
|
64
|
+
function projectCurrentScene(summary, players) {
|
|
65
|
+
const observer = summary.you && typeof summary.you === "object" ? summary.you : {};
|
|
66
|
+
const seatsByName = new Map(players.filter((player) => player.seat !== void 0).map((player) => [player.name, player.seat]));
|
|
67
|
+
const sceneItem = (raw) => raw && typeof raw === "object" && !Array.isArray(raw) ? raw : null;
|
|
68
|
+
const identity = (item) => {
|
|
69
|
+
const player = item.player && typeof item.player === "object" && !Array.isArray(item.player) ? item.player : {};
|
|
70
|
+
const name = stringValue(player.name);
|
|
71
|
+
const seat = numberValue(player.seat) ?? (name ? seatsByName.get(name) : void 0);
|
|
72
|
+
return { name, seat };
|
|
73
|
+
};
|
|
74
|
+
const location = (item) => cleanObject({
|
|
75
|
+
room: stringValue(item.room),
|
|
76
|
+
relative_direction: sceneDirection(item, observer),
|
|
77
|
+
distance_px: sceneDistance(item, observer)
|
|
78
|
+
});
|
|
79
|
+
const projectPlayer = (raw) => {
|
|
80
|
+
const item = sceneItem(raw);
|
|
81
|
+
if (!item) return null;
|
|
82
|
+
const player = identity(item);
|
|
83
|
+
if (!player.name && player.seat === void 0) return null;
|
|
84
|
+
return cleanObject({ ...player, ...location(item) });
|
|
85
|
+
};
|
|
86
|
+
const projectCorpse = (raw) => {
|
|
87
|
+
const item = sceneItem(raw);
|
|
88
|
+
if (!item) return null;
|
|
89
|
+
const player = identity(item);
|
|
90
|
+
const place = location(item);
|
|
91
|
+
if (!player.name && player.seat === void 0 && Object.keys(place).length === 0) return null;
|
|
92
|
+
return cleanObject({ ...player, ...place });
|
|
93
|
+
};
|
|
94
|
+
const projectList = (raw, project) => {
|
|
95
|
+
if (!Array.isArray(raw)) return void 0;
|
|
96
|
+
const projected = raw.map(project);
|
|
97
|
+
return projected.some((item) => item === null) ? void 0 : projected;
|
|
98
|
+
};
|
|
99
|
+
return cleanObject({
|
|
100
|
+
visible_players: projectList(summary.visible_players, projectPlayer),
|
|
101
|
+
nearby_corpses: projectList(summary.visible_corpses, projectCorpse)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function projectKnownPlayers(raw) {
|
|
105
|
+
if (!Array.isArray(raw)) return void 0;
|
|
106
|
+
const projected = raw.map((entry) => {
|
|
107
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return null;
|
|
108
|
+
const player = entry;
|
|
109
|
+
const name = stringValue(player.name);
|
|
110
|
+
const seat = numberValue(player.seat);
|
|
111
|
+
const knownStatus = player.known_status;
|
|
112
|
+
if (!name || seat === void 0 || !Number.isInteger(seat) || seat < 0 || !knownStatus || typeof knownStatus !== "object" || Array.isArray(knownStatus)) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const status = knownStatus;
|
|
116
|
+
const deathCause = status.death_cause === "killed" || status.death_cause === "exiled" ? status.death_cause : void 0;
|
|
117
|
+
return {
|
|
118
|
+
name,
|
|
119
|
+
seat,
|
|
120
|
+
known_status: cleanObject({
|
|
121
|
+
is_alive: typeof status.is_alive === "boolean" ? status.is_alive : void 0,
|
|
122
|
+
death_cause: deathCause,
|
|
123
|
+
reported_in_current_meeting: typeof status.reported_in_current_meeting === "boolean" ? status.reported_in_current_meeting : void 0
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
return projected.some((player) => player === null) ? void 0 : projected;
|
|
128
|
+
}
|
|
129
|
+
function firstString(event, keys, fallback = "?") {
|
|
130
|
+
for (const key of keys) {
|
|
131
|
+
const value = event[key];
|
|
132
|
+
if (typeof value === "string" && value.length > 0) return value;
|
|
133
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
134
|
+
}
|
|
135
|
+
return fallback;
|
|
136
|
+
}
|
|
137
|
+
function firstNumber(event, keys) {
|
|
138
|
+
for (const key of keys) {
|
|
139
|
+
const value = numberValue(event[key]);
|
|
140
|
+
if (value !== void 0) return value;
|
|
141
|
+
}
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
function truncate(value, maxLength) {
|
|
145
|
+
const raw = text(value, "");
|
|
146
|
+
if (raw.length <= maxLength) return raw;
|
|
147
|
+
return `${raw.slice(0, Math.max(0, maxLength - 1))}\u2026`;
|
|
148
|
+
}
|
|
149
|
+
function seatMapFromSummary(summary, extra) {
|
|
150
|
+
const seats = { ...extra ?? {} };
|
|
151
|
+
const remember = (name, seat) => {
|
|
152
|
+
if (typeof name !== "string" || name.length === 0) return;
|
|
153
|
+
const parsed = numberValue(seat);
|
|
154
|
+
if (parsed !== void 0) seats[name] = parsed;
|
|
155
|
+
};
|
|
156
|
+
const roomState = typeof summary?.phase === "string" && summary.phase.startsWith("room_");
|
|
157
|
+
if (roomState) {
|
|
158
|
+
remember(summary?.you?.name, summary?.you?.seat);
|
|
159
|
+
for (const member of Array.isArray(summary?.room?.members) ? summary.room.members : []) {
|
|
160
|
+
remember(member?.name, member?.seat);
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
remember(summary?.you?.player?.name, summary?.you?.player?.seat);
|
|
164
|
+
for (const player of Array.isArray(summary?.players) ? summary.players : []) {
|
|
165
|
+
remember(player?.name, player?.seat);
|
|
166
|
+
}
|
|
167
|
+
for (const collection of [summary?.visible_players, summary?.visible_corpses]) {
|
|
168
|
+
for (const entry of Array.isArray(collection) ? collection : []) {
|
|
169
|
+
remember(entry?.player?.name, entry?.player?.seat);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
remember(summary?.meeting?.caller?.name, summary?.meeting?.caller?.seat);
|
|
173
|
+
remember(summary?.meeting?.current_speaker?.name, summary?.meeting?.current_speaker?.seat);
|
|
174
|
+
for (const speaker of Array.isArray(summary?.meeting?.speech_order) ? summary.meeting.speech_order : []) {
|
|
175
|
+
remember(speaker?.name, speaker?.seat);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return seats;
|
|
179
|
+
}
|
|
180
|
+
function seatForName(name, ctx) {
|
|
181
|
+
if (typeof name !== "string" || name.length === 0) return void 0;
|
|
182
|
+
return seatMapFromSummary(ctx.summary, ctx.seats)[name];
|
|
183
|
+
}
|
|
184
|
+
function seatLabel(name, seat, ctx) {
|
|
185
|
+
const resolved = numberValue(seat) ?? seatForName(name, ctx);
|
|
186
|
+
return resolved === void 0 ? "?\u53F7" : `${resolved}\u53F7`;
|
|
187
|
+
}
|
|
188
|
+
function playerLabel(name, seat, ctx) {
|
|
189
|
+
return `${seatLabel(name, seat, ctx)}${text(name, "\u672A\u77E5\u73A9\u5BB6")}`;
|
|
190
|
+
}
|
|
191
|
+
function killerLabel(name, seat, kind, ctx) {
|
|
192
|
+
if (kind === "system") return text(name, "\u672A\u77E5\u7CFB\u7EDF\u6765\u6E90");
|
|
193
|
+
return playerLabel(name, seat, ctx);
|
|
194
|
+
}
|
|
195
|
+
function playerObject(name, seat, ctx) {
|
|
196
|
+
if (typeof name !== "string" || name.length === 0) return void 0;
|
|
197
|
+
return cleanObject({
|
|
198
|
+
name,
|
|
199
|
+
seat: numberValue(seat) ?? seatForName(name, ctx)
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function voteTargetLabel(target, ctx) {
|
|
203
|
+
if (target === null || target === void 0) return "skip";
|
|
204
|
+
if (typeof target === "object" && !Array.isArray(target)) {
|
|
205
|
+
const targetObject = target;
|
|
206
|
+
return playerLabel(targetObject.name ?? targetObject.agent_name, targetObject.seat, ctx);
|
|
207
|
+
}
|
|
208
|
+
const raw = text(target, "skip");
|
|
209
|
+
return raw === "skip" ? "skip" : playerLabel(raw, void 0, ctx);
|
|
210
|
+
}
|
|
211
|
+
function formatVotes(votes, ctx) {
|
|
212
|
+
if (Array.isArray(votes)) return structuredClone(votes);
|
|
213
|
+
if (!votes || typeof votes !== "object") return void 0;
|
|
214
|
+
const out = {};
|
|
215
|
+
for (const [voter, target] of Object.entries(votes)) {
|
|
216
|
+
out[playerLabel(voter, void 0, ctx)] = voteTargetLabel(target, ctx);
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
function teammateObjects(event, ctx) {
|
|
221
|
+
const raw = Array.isArray(event.crab_teammates) ? event.crab_teammates : Array.isArray(event.teammates) ? event.teammates : [];
|
|
222
|
+
const teammates = [];
|
|
223
|
+
for (const teammate of raw) {
|
|
224
|
+
const name = typeof teammate === "string" ? teammate : teammate?.name;
|
|
225
|
+
const seat = typeof teammate === "string" ? void 0 : teammate?.seat;
|
|
226
|
+
const normalized = playerObject(name, seat, ctx);
|
|
227
|
+
if (normalized) teammates.push(normalized);
|
|
228
|
+
}
|
|
229
|
+
return teammates;
|
|
230
|
+
}
|
|
231
|
+
function prefix(event) {
|
|
232
|
+
const type = text(event.type, "event");
|
|
233
|
+
const tick = numberValue(event.tick);
|
|
234
|
+
return tick === void 0 ? `tick=null ${type}` : `t${tick} ${type}`;
|
|
235
|
+
}
|
|
236
|
+
function firstReportedCorpse(event) {
|
|
237
|
+
const corpses = event.reported_corpses;
|
|
238
|
+
if (Array.isArray(corpses) && corpses.length > 0 && corpses[0] && typeof corpses[0] === "object") {
|
|
239
|
+
return corpses[0];
|
|
240
|
+
}
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
function playerChangeDeathText(change, ctx) {
|
|
244
|
+
const player = playerLabel(change.name, numberValue(change.seat), ctx);
|
|
245
|
+
if (change.cause === "exiled") return `${player}\u5DF2\u88AB\u653E\u9010`;
|
|
246
|
+
if (change.cause === "self_destruct") return `${player}\u5DF2\u81EA\u7206\u51FA\u5C40`;
|
|
247
|
+
const killer = stringValue(change.killer);
|
|
248
|
+
return `${player}\u5DF2\u88AB\u51FB\u6740${killer ? `\uFF0C\u51F6\u624B${playerLabel(killer, void 0, ctx)}` : "\uFF0C\u51F6\u624B\u672A\u77E5"}`;
|
|
249
|
+
}
|
|
250
|
+
function playersChangedBody(event, ctx) {
|
|
251
|
+
const changes = Array.isArray(event.changes) ? event.changes.filter((change) => !!change && typeof change === "object" && !Array.isArray(change)) : [];
|
|
252
|
+
if (changes.length === 0) return "\u73A9\u5BB6\u4FE1\u606F\u53D1\u751F\u53D8\u5316\u3002";
|
|
253
|
+
const deathsOnly = changes.every((change) => change.change === "died" || change.change === "death_updated");
|
|
254
|
+
const details = changes.map((change) => {
|
|
255
|
+
if (change.change === "discovered") {
|
|
256
|
+
return `\u53D1\u73B0${playerLabel(change.name, numberValue(change.seat), ctx)}`;
|
|
257
|
+
}
|
|
258
|
+
if (change.change === "status_changed") {
|
|
259
|
+
return `${playerLabel(change.name, numberValue(change.seat), ctx)}\u72B6\u6001\u7531${text(change.from_status)}\u53D8\u4E3A${text(change.to_status)}`;
|
|
260
|
+
}
|
|
261
|
+
const death = playerChangeDeathText(change, ctx);
|
|
262
|
+
return change.change === "death_updated" ? `${death}\uFF08\u6B7B\u4EA1\u4FE1\u606F\u66F4\u65B0\uFF09` : death;
|
|
263
|
+
}).join("\uFF1B");
|
|
264
|
+
const meetingCount = numberValue(event.meeting_count);
|
|
265
|
+
if (meetingCount !== void 0 && deathsOnly) return `\u7B2C${meetingCount}\u6B21\u4F1A\u8BAE\u4E2D\u53D1\u73B0${details}\u3002`;
|
|
266
|
+
if (event.meeting === true && deathsOnly) return `\u4F1A\u8BAE\u4E2D\u53D1\u73B0${details}\u3002`;
|
|
267
|
+
return `\u73A9\u5BB6\u4FE1\u606F\u53D8\u5316\uFF1A${details}\u3002`;
|
|
268
|
+
}
|
|
269
|
+
function shortBody(event, ctx) {
|
|
270
|
+
const maxTextLength = ctx.maxTextLength ?? 100;
|
|
271
|
+
switch (event.type) {
|
|
272
|
+
case "service_status": {
|
|
273
|
+
const startsAt = firstString(event.maintenance ?? {}, ["starts_at"], "\u8BA1\u5212\u65F6\u95F4\u672A\u77E5");
|
|
274
|
+
const endsAt = firstString(event.maintenance ?? {}, ["ends_at"], "\u6062\u590D\u65F6\u95F4\u672A\u77E5");
|
|
275
|
+
const description = stringValue(event.maintenance?.description);
|
|
276
|
+
const descriptionText = description ? `\uFF1B\u7EF4\u62A4\u8BF4\u660E\uFF1A${description}` : "";
|
|
277
|
+
if (event.service_status === "maintenance_upcoming") {
|
|
278
|
+
return `\u670D\u52A1\u5668\u8BA1\u5212\u4E8E${startsAt}\u5F00\u59CB\u7EF4\u62A4\uFF0C\u9884\u8BA1${endsAt}\u6062\u590D${descriptionText}\uFF1B\u5F53\u524D\u8BF7\u6C42\u4ECD\u53EF\u7EE7\u7EED\u3002`;
|
|
279
|
+
}
|
|
280
|
+
if (event.service_status === "maintenance_active") {
|
|
281
|
+
return `\u670D\u52A1\u5668\u6B63\u5728\u7EF4\u62A4\uFF0C\u9884\u8BA1${endsAt}\u6062\u590D${descriptionText}\uFF1B\u65B0\u7684\u5339\u914D\u548C\u623F\u95F4\u64CD\u4F5C\u5DF2\u505C\u6B62\u3002`;
|
|
282
|
+
}
|
|
283
|
+
return "\u670D\u52A1\u5668\u7EF4\u62A4\u5DF2\u7ED3\u675F\uFF0C\u670D\u52A1\u6062\u590D\u53EF\u7528\u3002";
|
|
284
|
+
}
|
|
285
|
+
case "game_started": {
|
|
286
|
+
const playerCount = numberValue(event.player_count);
|
|
287
|
+
const countText = playerCount === void 0 ? "\u5BF9\u5C40\u5F00\u59CB" : `\u5BF9\u5C40\u5F00\u59CB\uFF1A${playerCount}\u540D\u73A9\u5BB6`;
|
|
288
|
+
const modeText = event.game_mode === "competition" ? "\u7ADE\u8D5B\u6A21\u5F0F" : event.game_mode === "match" ? "\u666E\u901A\u5339\u914D" : "";
|
|
289
|
+
const prefixText = modeText ? `${countText}\uFF08${modeText}\uFF09` : countText;
|
|
290
|
+
return `${prefixText}\u3002`;
|
|
291
|
+
}
|
|
292
|
+
case "role_assigned": {
|
|
293
|
+
const start = ctx.isFirstVisibleEvent ? "\u5BF9\u5C40\u5F00\u59CB\u3002" : "";
|
|
294
|
+
return `${start}\u8EAB\u4EFD\u5DF2\u5206\u914D\uFF1A\u4F60\u662F${firstString(event, ["role_display_name", "role_display", "role"])}\uFF08${firstString(event, ["faction"])}\uFF09\u3002`;
|
|
295
|
+
}
|
|
296
|
+
case "kill":
|
|
297
|
+
return `\u4F60\u5728${firstString(event, ["room"])}\u51FB\u6740\u4E86${playerLabel(event.target_name, firstNumber(event, ["target_seat", "target_player_seat"]), ctx)}\u3002`;
|
|
298
|
+
case "killed":
|
|
299
|
+
return `\u4F60\u5728${firstString(event, ["room"])}\u88AB${killerLabel(event.killer_name, firstNumber(event, ["killer_seat", "killer_player_seat"]), event.killer_kind, ctx)}${killerRoleSuffix(event)}\u51FB\u6740\u4E86\uFF0C\u4F60\u5DF2\u6B7B\u4EA1\u3002`;
|
|
300
|
+
case "murder_witnessed":
|
|
301
|
+
if (isSelfKillerMurderWitnessed(event, ctx.summary)) {
|
|
302
|
+
return "\u6536\u5230\u4E00\u6761\u4E0E\u81EA\u8EAB\u51FB\u6740\u8EAB\u4EFD\u51B2\u7A81\u7684 murder_witnessed \u4E8B\u4EF6\uFF1B\u8BE5\u4E8B\u4EF6\u5DF2\u964D\u7EA7\u4E3A\u8BCA\u65AD\u4FE1\u606F\uFF0C\u4E0D\u80FD\u636E\u6B64\u5224\u65AD\u4EFB\u4F55\u76EE\u51FB\u8005\u3002";
|
|
303
|
+
}
|
|
304
|
+
return `\u4F60\u5728${firstString(event, ["room"])}\u76EE\u51FB${playerLabel(event.killer_name, firstNumber(event, ["killer_seat", "killer_player_seat"]), ctx)}\u51FB\u6740${playerLabel(event.target_name, firstNumber(event, ["target_seat", "target_player_seat"]), ctx)}\u3002`;
|
|
305
|
+
case "warrior_shrimp_self_destruct":
|
|
306
|
+
return `\u4F60\u8BEF\u6740\u4E86${playerLabel(event.target_name, firstNumber(event, ["target_seat", "target_player_seat"]), ctx)}\uFF0C\u6B66\u58EB\u867E\u81EA\u7206\u51FA\u5C40\u3002`;
|
|
307
|
+
case "task_completed": {
|
|
308
|
+
const fakeNote = event.is_fake_shrimp ? "\uFF08\u4F2A\u88C5\uFF09" : "";
|
|
309
|
+
return `\u4EFB\u52A1\u5B8C\u6210\uFF1A${firstString(event, ["task_name"])}${fakeNote}\u3002`;
|
|
310
|
+
}
|
|
311
|
+
case "task_sabotaged":
|
|
312
|
+
return `\u7834\u574F\u4EFB\u52A1\u5B8C\u6210\uFF1A${firstString(event, ["task_name"])}\uFF08${firstString(event, ["room"])}\uFF09\u3002`;
|
|
313
|
+
case "task_interrupted": {
|
|
314
|
+
const cooldown = numberValue(event.cooldown_remaining_secs);
|
|
315
|
+
const cooldownText = cooldown === void 0 ? "" : `\uFF1B\u5171\u4EAB\u51B7\u5374\u5269\u4F59${cooldown}\u79D2`;
|
|
316
|
+
return `\u7834\u574F\u4EFB\u52A1\u201C${firstString(event, ["task_name"])}\u201D\u56E0\u7D27\u6025\u4EFB\u52A1\u5F00\u59CB\u800C\u4E2D\u65AD\uFF0C\u4EFB\u52A1\u672A\u6D88\u8017${cooldownText}\u3002`;
|
|
317
|
+
}
|
|
318
|
+
case "reminder.task":
|
|
319
|
+
return firstString(event, ["text"], "\u4EFB\u52A1\u63D0\u9192\u3002");
|
|
320
|
+
case "reminder.speech": {
|
|
321
|
+
const actor = event.actor && typeof event.actor === "object" ? event.actor : {};
|
|
322
|
+
const speaker = playerLabel(actor.name ?? event.actor_name, actor.seat ?? event.actor_seat, ctx);
|
|
323
|
+
return `${speaker}\u5728${firstString(event, ["room"])}\u8BF4\uFF1A${truncate(event.text, maxTextLength)}`;
|
|
324
|
+
}
|
|
325
|
+
case "tasks_changed":
|
|
326
|
+
return `\u4EFB\u52A1\u5217\u8868\u5DF2\u66F4\u65B0\uFF08${firstString(event, ["reason"])}\uFF09\u3002`;
|
|
327
|
+
case "players_changed":
|
|
328
|
+
return playersChangedBody(event, ctx);
|
|
329
|
+
case "move_interrupted": {
|
|
330
|
+
const nearby = Array.isArray(event.nearby_players) ? event.nearby_players.map((player) => playerLabel(player?.name, numberValue(player?.seat), ctx)).filter(Boolean) : [];
|
|
331
|
+
const contact = nearby.length > 0 ? `\uFF0C\u9644\u8FD1\u6709${nearby.join("\u3001")}` : "";
|
|
332
|
+
return `\u79FB\u52A8\u5DF2\u4E2D\u65AD${contact}\u3002`;
|
|
333
|
+
}
|
|
334
|
+
case "corpse_spotted":
|
|
335
|
+
return `\u6211\u53D1\u73B0\u4E86${playerLabel(event.corpse_name, firstNumber(event, ["corpse_seat", "corpse_player_seat"]), ctx)}\u7684\u5C38\u4F53\uFF0C\u5728${firstString(event, ["corpse_room", "room"])}\u3002`;
|
|
336
|
+
case "body_dropped":
|
|
337
|
+
return `\u4F60\u542C\u5230${firstString(event, ["room"])}\u9644\u8FD1\u6709\u5C38\u4F53\u5012\u5730\u3002`;
|
|
338
|
+
case "octopus_time_start":
|
|
339
|
+
return "\u7AE0\u9C7C\u65F6\u95F4\u5F00\u59CB\uFF1A\u5B58\u6D3B\u4EBA\u6570\u5DF2\u964D\u81F33\u4EBA\u6216\u66F4\u5C11\uFF0C\u7AE0\u9C7C\u5B58\u6D3B60\u79D2\u5C06\u83B7\u80DC\uFF1B\u4F1A\u8BAE\u5DF2\u7981\u7528\uFF0C\u4F46\u867E\u65B9\u4EFB\u52A1\u5B8C\u6210\u6216\u7D27\u6025\u4EFB\u52A1\u8D85\u65F6\u4ECD\u53EF\u5148\u7ED3\u675F\u672C\u5C40\u3002";
|
|
340
|
+
case "emergency_started": {
|
|
341
|
+
const sabotageCause = event.cause === "sabotage" ? "\u87F9\u521A\u5B8C\u6210\u5BF9\u5E94\u7834\u574F\u4EFB\u52A1\u5E76\u89E6\u53D1\u4E86\u8BE5\u7D27\u6025\u4E8B\u4EF6\uFF1B" : "";
|
|
342
|
+
return `\u7D27\u6025\u4EFB\u52A1\uFF1A${firstString(event, ["task_name"])}\u5728${firstString(event, ["room"])}\uFF0C${sabotageCause}${text(event.timeout_secs, "?")}\u79D2\u5185\u5904\u7406\u3002`;
|
|
343
|
+
}
|
|
344
|
+
case "emergency_countdown_warning":
|
|
345
|
+
return `\u7D27\u6025\u4EFB\u52A1${firstString(event, ["task_name"])}\u53EA\u5269${text(event.remaining_secs, "?")}\u79D2\uFF08${text(event.threshold_secs, "?")}\u79D2\u63D0\u9192\uFF09\u3002`;
|
|
346
|
+
case "emergency_resolved":
|
|
347
|
+
if (event.reason === "meeting_started") {
|
|
348
|
+
return `\u4F1A\u8BAE\u5F00\u59CB\uFF0C\u7D27\u6025\u4EFB\u52A1${firstString(event, ["task_name"])}\u5DF2\u81EA\u52A8\u89E3\u9664\u3002`;
|
|
349
|
+
}
|
|
350
|
+
if (event.resolved_by_self === true) {
|
|
351
|
+
return `\u4F60\u5DF2\u89E3\u51B3\u7D27\u6025\u4EFB\u52A1\uFF1A${firstString(event, ["task_name"])}\u3002`;
|
|
352
|
+
}
|
|
353
|
+
return `\u7D27\u6025\u4EFB\u52A1\u5DF2\u89E3\u51B3\uFF1A${firstString(event, ["task_name"])}\u3002`;
|
|
354
|
+
case "emergency_interrupted":
|
|
355
|
+
return `\u4F60\u5728\u5904\u7406${firstString(event, ["task_name"])}\u65F6\u6B7B\u4EA1\uFF0C\u7D27\u6025\u4EFB\u52A1\u4ECD\u672A\u89E3\u9664\u3002`;
|
|
356
|
+
case "ability.ready":
|
|
357
|
+
if (event.ability_id === "sabotage") return `\u87F9\u9635\u8425\u5171\u4EAB\u7834\u574F\u80FD\u529B\u5DF2\u6062\u590D\u5C31\u7EEA\u3002${event.phase === "meeting" ? "\u5F53\u524D\u4F1A\u8BAE\u4E2D\uFF0C\u7ED3\u675F\u540E\u53EF\u6267\u884C\u3002" : ""}`;
|
|
358
|
+
return `\u80FD\u529B\u201C${firstString(event, ["ability_name", "ability_id"])}\u201D\u73B0\u5728\u53EF\u4EE5\u4F7F\u7528\u3002`;
|
|
359
|
+
case "ability.unavailable":
|
|
360
|
+
if (event.ability_id === "sabotage") return event.status === "emergency_active" ? "\u87F9\u9635\u8425\u5171\u4EAB\u7834\u574F\u80FD\u529B\u6682\u4E0D\u53EF\u7528\uFF1A\u7D27\u6025\u4EFB\u52A1\u6B63\u5728\u8FDB\u884C\u3002" : `\u87F9\u9635\u8425\u5171\u4EAB\u7834\u574F\u80FD\u529B\u8FDB\u5165\u51B7\u5374${typeof event.cooldown_remaining_secs === "number" ? `\uFF0C\u5269\u4F59${event.cooldown_remaining_secs}\u79D2` : ""}\u3002`;
|
|
361
|
+
return `\u80FD\u529B\u201C${firstString(event, ["ability_name", "ability_id"])}\u201D\u6682\u4E0D\u53EF\u7528\u3002`;
|
|
362
|
+
case "ability.remaining_uses_changed":
|
|
363
|
+
return `\u80FD\u529B\u201C${firstString(event, ["ability_name", "ability_id"])}\u201D\u5269\u4F59${text(event.remaining_uses, "?")}\u6B21\u3002`;
|
|
364
|
+
case "ability.exhausted":
|
|
365
|
+
return `\u80FD\u529B\u201C${firstString(event, ["ability_name", "ability_id"])}\u201D\u5DF2\u65E0\u5269\u4F59\u6B21\u6570\u3002`;
|
|
366
|
+
case "meeting_briefing": {
|
|
367
|
+
const callerName = firstString(event, ["meeting_caller_name", "caller", "actor_name"]);
|
|
368
|
+
const caller = playerLabel(callerName, firstNumber(event, ["meeting_caller_seat", "caller_seat", "actor_seat"]), ctx);
|
|
369
|
+
const corpse = firstReportedCorpse(event);
|
|
370
|
+
if (!corpse) return `\u4F1A\u8BAE\u5F00\u59CB\uFF1A${caller}\u53D1\u8D77\u4F1A\u8BAE\u3002`;
|
|
371
|
+
const corpseName = text(corpse.name ?? event.corpse_name, "\u672A\u77E5\u73A9\u5BB6");
|
|
372
|
+
const corpseSeat = numberValue(corpse.seat) ?? firstNumber(event, ["corpse_seat", "corpse_player_seat"]);
|
|
373
|
+
return `\u4F1A\u8BAE\u5F00\u59CB\uFF1A${caller}\u62A5\u544A${playerLabel(corpseName, corpseSeat, ctx)}\u5C38\u4F53\u3002`;
|
|
374
|
+
}
|
|
375
|
+
case "speech":
|
|
376
|
+
return `${playerLabel(event.actor_name, firstNumber(event, ["actor_seat", "seat"]), ctx)}\u4F1A\u8BAE\u53D1\u8A00\uFF1A${truncate(event.text ?? event.message, maxTextLength)}`;
|
|
377
|
+
case "speech_skipped":
|
|
378
|
+
return `${playerLabel(event.actor_name, firstNumber(event, ["actor_seat", "seat"]), ctx)}\u53D1\u8A00\u8D85\u65F6\uFF0C\u88AB\u8DF3\u8FC7\u3002`;
|
|
379
|
+
case "speech_your_turn":
|
|
380
|
+
return "\u8F6E\u5230\u4F60\u53D1\u8A00\u3002";
|
|
381
|
+
case "speech_next_turn":
|
|
382
|
+
return `${playerLabel(event.current_speaker, firstNumber(event, ["current_speaker_seat"]), ctx)}\u6B63\u5728\u53D1\u8A00\uFF0C\u4E0B\u4E00\u4F4D\u8F6E\u5230\u4F60\u3002`;
|
|
383
|
+
case "vote_phase_start":
|
|
384
|
+
return "\u6295\u7968\u9636\u6BB5\u5F00\u59CB\u3002";
|
|
385
|
+
case "vote_cast":
|
|
386
|
+
return `${playerLabel(event.actor_name, firstNumber(event, ["actor_seat", "seat"]), ctx)}\u5DF2\u6295\u7968\u3002`;
|
|
387
|
+
case "vote_speech_phase_ended":
|
|
388
|
+
return "\u6295\u7968\u5F39\u5E55\u7A97\u53E3\u5DF2\u5173\u95ED\u3002";
|
|
389
|
+
case "exile": {
|
|
390
|
+
const exiledName = event.exiled_player?.name ?? event.result_target ?? event.actor_name;
|
|
391
|
+
const exiledSeat = numberValue(event.exiled_player?.seat) ?? firstNumber(event, ["result_target_seat", "actor_seat", "seat"]);
|
|
392
|
+
return `\u4F1A\u8BAE\u7ED3\u675F\uFF1A${playerLabel(exiledName, exiledSeat, ctx)}\u88AB\u653E\u9010\u3002`;
|
|
393
|
+
}
|
|
394
|
+
case "no_exile":
|
|
395
|
+
return "\u4F1A\u8BAE\u7ED3\u675F\uFF1A\u65E0\u4EBA\u88AB\u653E\u9010\u3002";
|
|
396
|
+
case "meeting_ended":
|
|
397
|
+
return "\u4F1A\u8BAE\u7ED3\u675F\u3002";
|
|
398
|
+
case "exile_game_over":
|
|
399
|
+
return `\u653E\u9010\u7ED3\u7B97\u540E\u6E38\u620F\u7ED3\u675F\uFF1A${firstString(event, ["winner"])}\u9635\u8425\u83B7\u80DC\u3002`;
|
|
400
|
+
case "death_speech": {
|
|
401
|
+
const speakerName = event.speaker_name ?? event.actor_name;
|
|
402
|
+
const speakerSeat = firstNumber(event, ["speaker_seat", "actor_seat", "seat"]);
|
|
403
|
+
return `${playerLabel(speakerName, speakerSeat, ctx)}\u6B7B\u4EA1\u5F39\u5E55\uFF1A${truncate(event.text ?? event.message, maxTextLength)}`;
|
|
404
|
+
}
|
|
405
|
+
case "wandering_speech":
|
|
406
|
+
return `${text(event.actor_name, "\u4F60")}\u5728${firstString(event, ["room"])}\u8BF4\uFF1A${truncate(event.text ?? event.message, maxTextLength)}`;
|
|
407
|
+
case "game_over":
|
|
408
|
+
if (isRoomGameEvent(event, ctx)) return "\u672C\u8F6E\u623F\u95F4\u5BF9\u5C40\u7ED3\u675F\u3002";
|
|
409
|
+
return `\u6E38\u620F\u7ED3\u675F\uFF1A${firstString(event, ["winner_name"], "\u672A\u77E5\u73A9\u5BB6")}\u83B7\u80DC\uFF08${firstString(event, ["winner"])}\uFF09\uFF0C\u539F\u56E0 ${firstString(event, ["reason"])}\u3002`;
|
|
410
|
+
case "game_over_recovered":
|
|
411
|
+
if (isRoomGameEvent(event, ctx)) return "GameSync\u7EC8\u5C40\u5E27\u7F3A\u5931\uFF0C\u4F46\u540E\u7AEF\u7ED3\u7B97\u5DF2\u786E\u8BA4\u672C\u8F6E\u623F\u95F4\u5BF9\u5C40\u7ED3\u675F\u3002";
|
|
412
|
+
return `GameSync\u7EC8\u5C40\u5E27\u7F3A\u5931\uFF0C\u4F46\u540E\u7AEF\u7ED3\u7B97\u5DF2\u786E\u8BA4\u6E38\u620F\u7ED3\u675F\uFF1A${firstString(event, ["winner", "winning_faction"])}\u9635\u8425\u83B7\u80DC\uFF0C\u539F\u56E0 ${firstString(event, ["reason", "win_reason"])}\u3002`;
|
|
413
|
+
case "game_terminal_missing":
|
|
414
|
+
return "\u5F53\u524D\u5BF9\u5C40\u5DF2\u4ECE\u540E\u7AEF\u53C2\u4E0E\u72B6\u6001\u4E2D\u6D88\u5931\uFF0C\u4F46\u672A\u6536\u5230\u7EC8\u5C40\u5E27\uFF0C\u4E5F\u6CA1\u6709\u67E5\u5230\u5339\u914D\u7684\u7ED3\u7B97\uFF1B\u672C\u5C40\u7ED3\u679C\u672A\u77E5\u3002";
|
|
415
|
+
case "octopus_time_win":
|
|
416
|
+
return `${playerLabel(event.winner_name ?? event.actor_name, firstNumber(event, ["winner_seat", "actor_seat"]), ctx)}\u4F5C\u4E3A\u7AE0\u9C7C\u5B58\u6D3B\u6EE160\u79D2\u5E76\u83B7\u80DC\u3002`;
|
|
417
|
+
case "win_blocked_by_octopus":
|
|
418
|
+
return `${firstString(event, ["blocked_winner"])}\u5DF2\u6EE1\u8DB3\u80DC\u5229\u6761\u4EF6\uFF0C\u4F46\u7AE0\u9C7C\u4ECD\u5B58\u6D3B\uFF0C\u5F53\u524D\u5C1A\u672A\u83B7\u80DC\uFF08${firstString(event, ["reason"])}\uFF09\u3002`;
|
|
419
|
+
case "user_left_game":
|
|
420
|
+
return "\u7528\u6237\u5DF2\u4ECE\u7F51\u9875\u79BB\u5F00\u672C\u5C40\u3002";
|
|
421
|
+
case "joined":
|
|
422
|
+
return "\u5DF2\u52A0\u5165\u5339\u914D\u961F\u5217\uFF0C\u6E38\u620F\u957F\u6D41\u5DF2\u63A5\u5165\u3002";
|
|
423
|
+
case "room_created":
|
|
424
|
+
return `\u5DF2\u521B\u5EFA\u623F\u95F4 ${firstString(event, ["room_code"])}\uFF0C\u623F\u95F4\u957F\u6D41\u5DF2\u63A5\u5165\u3002`;
|
|
425
|
+
case "room_joined":
|
|
426
|
+
return `\u5DF2\u52A0\u5165\u623F\u95F4 ${firstString(event, ["room_code"])}\uFF0C\u623F\u95F4\u957F\u6D41\u5DF2\u63A5\u5165\u3002`;
|
|
427
|
+
case "session_resumed":
|
|
428
|
+
return "\u5DF2\u91CD\u65B0\u63A5\u5165\u540E\u7AEF\u73B0\u6709\u7684\u5339\u914D\u6216\u5BF9\u5C40\u3002";
|
|
429
|
+
case "session_recovered":
|
|
430
|
+
return "\u521D\u59CB\u8BF7\u6C42\u786E\u8BA4\u7F3A\u5931\u6216\u5931\u8D25\uFF1B\u961F\u5217\u72B6\u6001\u56DE\u67E5\u5DF2\u786E\u8BA4\u5F53\u524D\u53C2\u4E0E\u6709\u6548\uFF0C\u672C\u5730\u7F3A\u5931\u671F\u95F4\u7684\u5386\u53F2\u53EF\u80FD\u4E0D\u5B8C\u6574\u3002";
|
|
431
|
+
case "session_left":
|
|
432
|
+
return "\u540E\u7AEF\u5DF2\u786E\u8BA4\u79BB\u5F00\u5F53\u524D\u5339\u914D\u3001\u5BF9\u5C40\u6216\u623F\u95F4\u3002";
|
|
433
|
+
case "quit_failed":
|
|
434
|
+
return `\u9000\u51FA\u8FDC\u7AEF\u53C2\u4E0E\u5931\u8D25\uFF1A${firstString(event.error ?? event, ["message", "code"], "unknown")}\u3002`;
|
|
435
|
+
case "match_start":
|
|
436
|
+
return "\u5339\u914D\u957F\u6D41\u5DF2\u8FDE\u63A5\uFF0C\u6B63\u5728\u7B49\u5F85\u5206\u914D\u5BF9\u5C40\u3002";
|
|
437
|
+
case "match_waiting":
|
|
438
|
+
return `\u4ECD\u5728\u5339\u914D\u961F\u5217\uFF0C\u5DF2\u7B49\u5F85${text(event.waited_secs, "?")}\u79D2\u3002`;
|
|
439
|
+
case "match_timeout":
|
|
440
|
+
return `\u5339\u914D\u8D85\u65F6\uFF0C\u7D2F\u8BA1\u7B49\u5F85${text(event.waited_secs, "?")}\u79D2\u3002`;
|
|
441
|
+
case "match_exited":
|
|
442
|
+
return event.exit?.reason === "left_queue" ? "\u5DF2\u9000\u51FA\u5339\u914D\u3002" : "\u672C\u6B21\u5339\u914D\u5DF2\u7ED3\u675F\u3002";
|
|
443
|
+
case "not_in_queue":
|
|
444
|
+
return "\u8D26\u53F7\u5DF2\u4E0D\u5728\u5339\u914D\u961F\u5217\uFF0C\u672C\u6B21\u957F\u6D41\u5373\u5C06\u9000\u51FA\u3002";
|
|
445
|
+
case "poll_error":
|
|
446
|
+
return `\u5339\u914D\u72B6\u6001\u67E5\u8BE2\u6682\u65F6\u5931\u8D25\uFF0COwner\u4ECD\u5728\u91CD\u8BD5\uFF08${text(event.consecutive_failures, "?")}\u6B21\uFF09\u3002`;
|
|
447
|
+
case "game_start_failed":
|
|
448
|
+
return `\u542F\u52A8\u5BF9\u5C40\u5931\u8D25\uFF1A${firstString(event.error ?? event, ["message", "code"], "unknown")}\u3002`;
|
|
449
|
+
case "game_stream_disconnected":
|
|
450
|
+
return "GameServer\u957F\u6D41\u5DF2\u65AD\u5F00\uFF0COwner\u6B63\u5728\u91CD\u8FDE\u3002";
|
|
451
|
+
case "game_stream_reconnected":
|
|
452
|
+
return "GameServer\u957F\u6D41\u5DF2\u91CD\u65B0\u8FDE\u63A5\u3002";
|
|
453
|
+
case "quit_requested":
|
|
454
|
+
return "Owner\u5DF2\u63A5\u53D7\u9000\u51FA\u8BF7\u6C42\uFF0C\u6B63\u5728\u7ED3\u675F\u5F53\u524D\u6E38\u620F\u957F\u6D41\u3002";
|
|
455
|
+
case "stop_requested":
|
|
456
|
+
return "Owner\u5DF2\u63A5\u53D7\u505C\u6B62\u8BF7\u6C42\uFF0C\u6B63\u5728\u5173\u95ED\u672C\u5730\u6E38\u620F\u957F\u6D41\u3002";
|
|
457
|
+
case "room.snapshot": {
|
|
458
|
+
const count = Array.isArray(event.members) ? event.members.length : event.member_count;
|
|
459
|
+
const owner = event.is_owner ? "\u4F60\u662F\u623F\u4E3B" : "\u7B49\u5F85\u623F\u4E3B";
|
|
460
|
+
const cooldown = numberValue(event.cooldown_seconds);
|
|
461
|
+
const cooldownText = cooldown && cooldown > 0 ? `\uFF0C\u51B7\u5374${cooldown}\u79D2` : "";
|
|
462
|
+
return `\u623F\u95F4${firstString(event, ["room_code"])}\uFF1A${firstString(event, ["status"])}\uFF0C${text(count, "?")}/10\uFF0C${owner}${cooldownText}\u3002`;
|
|
463
|
+
}
|
|
464
|
+
case "room.member_joined":
|
|
465
|
+
return `${playerLabel(event.name ?? event.agent_id, firstNumber(event, ["seat"]), ctx)}\u52A0\u5165\u623F\u95F4\u3002`;
|
|
466
|
+
case "room.member_status_changed": {
|
|
467
|
+
const status = event.status === "online" ? "\u5728\u7EBF" : event.status === "offline" ? "\u79BB\u7EBF" : event.status === "in_game" ? "\u6E38\u620F\u4E2D" : text(event.status, "\u672A\u77E5");
|
|
468
|
+
return `${playerLabel(event.name ?? event.agent_id, firstNumber(event, ["seat"]), ctx)}\u72B6\u6001\u53D8\u4E3A${status}\u3002`;
|
|
469
|
+
}
|
|
470
|
+
case "room.member_left":
|
|
471
|
+
return `${playerLabel(event.name ?? event.agent_id, firstNumber(event, ["seat"]), ctx)}\u79BB\u5F00\u623F\u95F4\u3002`;
|
|
472
|
+
case "room.owner_changed":
|
|
473
|
+
return `\u623F\u4E3B\u53D8\u66F4\u4E3A${playerLabel(event.name ?? event.agent_id, firstNumber(event, ["seat"]), ctx)}\u3002`;
|
|
474
|
+
case "room.full":
|
|
475
|
+
return "\u623F\u95F4\u4EBA\u6570\u5DF2\u6EE1\u3002";
|
|
476
|
+
case "room.type_changed":
|
|
477
|
+
return `\u8BAD\u7EC3\u623F\u6A21\u5F0F\u5DF2\u88AB\u5176\u4ED6\u65B9\u9762\u4ECE${trainingRoomTypeLabel(event.previous_room_type)}\u5207\u6362\u4E3A${trainingRoomTypeLabel(event.room_type)}\u3002`;
|
|
478
|
+
case "room_ready_to_start":
|
|
479
|
+
return "\u623F\u95F4\u5DF2\u6EE1\u8DB3\u5F00\u5C40\u6761\u4EF6\uFF0C\u4F60\u662F\u623F\u4E3B\u3002";
|
|
480
|
+
case "room.chat":
|
|
481
|
+
return `${playerLabel(event.name ?? event.agent_id, firstNumber(event, ["seat"]), ctx)}\u623F\u95F4\u5F39\u5E55\uFF1A${truncate(event.content ?? event.text ?? event.message, maxTextLength)}`;
|
|
482
|
+
case "room.game_starting":
|
|
483
|
+
return `\u623F\u95F4\u5BF9\u5C40\u5F00\u59CB\u5012\u8BA1\u65F6\uFF1A${text(event.countdown, "?")}\u79D2\u3002`;
|
|
484
|
+
case "room.game_started":
|
|
485
|
+
return "\u623F\u95F4\u5BF9\u5C40\u5DF2\u542F\u52A8\uFF0C\u6B63\u5728\u5207\u6362\u5230 GameServer\u3002";
|
|
486
|
+
case "room.game_start_failed":
|
|
487
|
+
return `\u623F\u95F4\u5F00\u5C40\u5931\u8D25\uFF1A${firstString(event, ["reason"], "unknown")}\u3002`;
|
|
488
|
+
case "room.game_finished":
|
|
489
|
+
return "\u4E0A\u4E00\u8F6E\u623F\u95F4\u5BF9\u5C40\u5DF2\u7ED3\u675F\uFF0C\u6240\u6709\u4EBA\u5DF2\u56DE\u5230\u623F\u95F4\u3002";
|
|
490
|
+
case "room.cooldown":
|
|
491
|
+
return `\u623F\u95F4\u51B7\u5374\u4E2D\uFF1A${text(event.seconds_remaining ?? event.cooldown_seconds, "?")}\u79D2\u3002`;
|
|
492
|
+
case "room.idle_warning":
|
|
493
|
+
return `\u623F\u95F4\u7B49\u5F85\u8D85\u65F6\uFF0C\u5C06\u5728${text(event.seconds_remaining, "?")}\u79D2\u540E\u81EA\u52A8\u9500\u6BC1\u3002`;
|
|
494
|
+
case "room.self_left":
|
|
495
|
+
return "\u5F53\u524D\u8D26\u53F7\u5DF2\u79BB\u5F00\u623F\u95F4\u3002";
|
|
496
|
+
case "room_destroyed":
|
|
497
|
+
if (event.reason === "idle_timeout") return "\u623F\u95F4\u56E0\u7B49\u5F85\u8D85\u65F6\u5DF2\u81EA\u52A8\u9500\u6BC1\u3002";
|
|
498
|
+
if (event.reason === "gm_destroy") return "\u623F\u95F4\u5DF2\u7531\u7BA1\u7406\u5458\u9500\u6BC1\u3002";
|
|
499
|
+
return `\u623F\u95F4\u5DF2\u9500\u6BC1\uFF1A${text(event.reason, "room_destroyed")}\u3002`;
|
|
500
|
+
case "room_returning_to_lobby":
|
|
501
|
+
return "\u623F\u95F4\u5BF9\u5C40\u5DF2\u7ED3\u675F\uFF0C\u6B63\u5728\u91CD\u8FDE Lobby \u623F\u95F4\u957F\u6D41\u3002";
|
|
502
|
+
case "room_attached":
|
|
503
|
+
return "\u623F\u95F4\u957F\u6D41\u5DF2\u8FDE\u63A5\uFF0C\u6B63\u5728\u7B49\u5F85\u623F\u95F4\u66F4\u65B0\u3002";
|
|
504
|
+
case "room_lobby_reconnect_failed":
|
|
505
|
+
return "\u623F\u95F4\u5BF9\u5C40\u5DF2\u7ED3\u675F\uFF0C\u4F46\u91CD\u65B0\u8FDE\u63A5 Lobby \u5931\u8D25\u3002";
|
|
506
|
+
case "room_lobby_missing":
|
|
507
|
+
return "\u623F\u95F4\u5BF9\u5C40\u5DF2\u7ED3\u675F\uFF0C\u4F46\u8D26\u53F7\u5DF2\u4E0D\u5728\u539F\u623F\u95F4\u3002";
|
|
508
|
+
case "room_ping_timeout":
|
|
509
|
+
return "\u623F\u95F4 Lobby \u8FDE\u63A5\u5FC3\u8DF3\u8D85\u65F6\uFF0C\u6B63\u5728\u91CD\u8FDE\u3002";
|
|
510
|
+
case "lobby_connection_replaced":
|
|
511
|
+
return "\u5927\u5385\u8FDE\u63A5\u5DF2\u88AB\u66FF\u6362\u6216\u767B\u8BB0\u5DF2\u5931\u6548\uFF0C\u5DF2\u505C\u6B62\u81EA\u52A8\u91CD\u8FDE\u3002\u9700\u8981\u7EE7\u7EED\u65F6\u8BF7\u660E\u786E\u53D1\u8D77\u63A5\u7EED\u3002";
|
|
512
|
+
case "robot_speak_rule":
|
|
513
|
+
return `\u53D1\u8A00\u63D0\u793A\uFF1A${truncate(event.message ?? event.text, maxTextLength)}`;
|
|
514
|
+
case "strategy_alert":
|
|
515
|
+
return truncate(event.message ?? event.text, maxTextLength);
|
|
516
|
+
case "behavior.started":
|
|
517
|
+
case "behavior.restarted":
|
|
518
|
+
case "behavior.suspended":
|
|
519
|
+
case "behavior.completed":
|
|
520
|
+
case "behavior.failed":
|
|
521
|
+
case "behavior.cancelled":
|
|
522
|
+
case "behavior.replaced": {
|
|
523
|
+
const behavior = text(event.behavior, "behavior");
|
|
524
|
+
const layer = typeof event.layer === "string" && event.layer.length > 0 ? `\uFF08${event.layer}\uFF09` : "";
|
|
525
|
+
const action = event.type === "behavior.started" ? "\u5DF2\u542F\u52A8" : event.type === "behavior.restarted" ? "\u5DF2\u91CD\u65B0\u542F\u52A8" : event.type === "behavior.suspended" ? "\u5DF2\u6682\u505C" : event.type === "behavior.completed" ? "\u5DF2\u5B8C\u6210" : event.type === "behavior.failed" ? "\u6267\u884C\u5931\u8D25" : event.type === "behavior.cancelled" ? "\u5DF2\u53D6\u6D88" : "\u5DF2\u88AB\u66FF\u6362";
|
|
526
|
+
const reason = typeof event.reason === "string" && event.reason.length > 0 ? `\uFF1A${event.reason}` : "";
|
|
527
|
+
return `${behavior}${layer}${action}${reason}`;
|
|
528
|
+
}
|
|
529
|
+
case "game_start":
|
|
530
|
+
return "\u4E8B\u4EF6\u6D41\u5DF2\u8FDE\u63A5\uFF0C\u7B49\u5F85\u8EAB\u4EFD\u5206\u914D\u3002";
|
|
531
|
+
case "heartbeat":
|
|
532
|
+
if (typeof event.message === "string" && event.message.length > 0) return truncate(event.message, maxTextLength);
|
|
533
|
+
return "\u4E8B\u4EF6\u6D41\u6B63\u5E38\uFF0C\u6682\u65E0\u65B0\u4E8B\u4EF6\u3002";
|
|
534
|
+
case "snapshot":
|
|
535
|
+
return "\u5F53\u524D\u72B6\u6001\u5FEB\u7167\u3002";
|
|
536
|
+
case "not_logged_in":
|
|
537
|
+
return "\u672A\u767B\u5F55\u3002";
|
|
538
|
+
case "not_ready":
|
|
539
|
+
return "\u6E38\u620F\u8FD0\u884C\u65F6\u672A\u5C31\u7EEA\u3002";
|
|
540
|
+
case "error":
|
|
541
|
+
return text(event.message ?? event.error, "\u53D1\u751F\u9519\u8BEF\u3002");
|
|
542
|
+
default:
|
|
543
|
+
return truncate(event.message ?? event.text ?? event.type, maxTextLength);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function formatEventMessage(event, ctx = {}) {
|
|
547
|
+
const factual = `${prefix(event)} ${shortBody(event, ctx)}`;
|
|
548
|
+
return typeof event.hint === "string" && event.hint.length > 0 ? `${factual} Hint: ${event.hint}` : factual;
|
|
549
|
+
}
|
|
550
|
+
function taskKindForEvents(task, event) {
|
|
551
|
+
if (typeof task?.kind === "string" && task.kind.length > 0) return task.kind;
|
|
552
|
+
if (typeof task?.task_kind === "string" && task.task_kind.length > 0) return task.task_kind;
|
|
553
|
+
if (task?.is_fake_shrimp === true) return "fake_shrimp";
|
|
554
|
+
if (event.faction === "crab" && task?.is_fake_shrimp === false) return "crab_sabotage";
|
|
555
|
+
return void 0;
|
|
556
|
+
}
|
|
557
|
+
function compactRoleAssignedForEvents(event) {
|
|
558
|
+
const sourceTasks = Array.isArray(event.tasks) ? event.tasks : Array.isArray(event.assigned_tasks) ? event.assigned_tasks : void 0;
|
|
559
|
+
const tasks = Array.isArray(sourceTasks) ? sourceTasks.map((task) => cleanObject({
|
|
560
|
+
task_id: task?.task_id,
|
|
561
|
+
name: task?.name,
|
|
562
|
+
room: task?.room,
|
|
563
|
+
x: task?.x,
|
|
564
|
+
y: task?.y,
|
|
565
|
+
status: task?.status,
|
|
566
|
+
task_note: task?.task_note,
|
|
567
|
+
kind: taskKindForEvents(task, event)
|
|
568
|
+
})) : void 0;
|
|
569
|
+
const taskKinds = Array.isArray(tasks) ? Array.from(new Set(tasks.map((task) => task.kind).filter((kind) => typeof kind === "string"))) : [];
|
|
570
|
+
const useTopLevelTaskKind = taskKinds.length === 1;
|
|
571
|
+
const compactTasks = Array.isArray(tasks) ? tasks.map((task) => {
|
|
572
|
+
if (!useTopLevelTaskKind) return task;
|
|
573
|
+
const { kind: _kind, ...rest } = task;
|
|
574
|
+
return rest;
|
|
575
|
+
}) : void 0;
|
|
576
|
+
const hasFakeTask = taskKinds.includes("fake_shrimp") || event.fake_task_briefing;
|
|
577
|
+
return cleanObject({
|
|
578
|
+
type: text(event.type, "event"),
|
|
579
|
+
tick: numberValue(event.tick) ?? null,
|
|
580
|
+
room: event.room,
|
|
581
|
+
role: event.role,
|
|
582
|
+
role_display: event.role_display_name ?? event.role_display,
|
|
583
|
+
faction: event.faction,
|
|
584
|
+
role_description: event.role_description,
|
|
585
|
+
task_kind: useTopLevelTaskKind ? taskKinds[0] : void 0,
|
|
586
|
+
task_note: hasFakeTask ? "Fake shrimp tasks: disguise only; no lobster progress." : void 0,
|
|
587
|
+
tasks: compactTasks,
|
|
588
|
+
reason: event.reason,
|
|
589
|
+
delta: event.delta
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
function compactVoteCastForEvents(event, ctx) {
|
|
593
|
+
const {
|
|
594
|
+
target: _target,
|
|
595
|
+
target_name: _targetName,
|
|
596
|
+
target_seat: _targetSeat,
|
|
597
|
+
target_player_seat: _targetPlayerSeat,
|
|
598
|
+
...rest
|
|
599
|
+
} = event;
|
|
600
|
+
return cleanObject({
|
|
601
|
+
...rest,
|
|
602
|
+
type: text(rest.type, "event"),
|
|
603
|
+
tick: numberValue(rest.tick) ?? null
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
function compactMeetingResultForEvents(event, ctx) {
|
|
607
|
+
const {
|
|
608
|
+
votes: _votes,
|
|
609
|
+
actor_name: _actorName,
|
|
610
|
+
actor_seat: _actorSeat,
|
|
611
|
+
...rest
|
|
612
|
+
} = event;
|
|
613
|
+
const exiledName = event.type === "exile" ? event.exiled_player?.name ?? event.result_target ?? event.actor_name : void 0;
|
|
614
|
+
const exiledSeat = event.type === "exile" ? numberValue(event.exiled_player?.seat) ?? firstNumber(event, ["result_target_seat", "actor_seat", "seat"]) : void 0;
|
|
615
|
+
return cleanObject({
|
|
616
|
+
...rest,
|
|
617
|
+
type: text(rest.type, "event"),
|
|
618
|
+
tick: numberValue(rest.tick) ?? null,
|
|
619
|
+
meeting_ended: true,
|
|
620
|
+
result: event.type === "exile" ? "exiled" : "no_exile",
|
|
621
|
+
exiled_player: playerObject(exiledName, exiledSeat, ctx),
|
|
622
|
+
votes: formatVotes(event.votes, ctx)
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
function compactPlayersChangedForEvents(event) {
|
|
626
|
+
const changes = Array.isArray(event.changes) ? event.changes.filter((change) => !!change && typeof change === "object" && !Array.isArray(change)).map((change) => cleanObject({
|
|
627
|
+
change: change.change,
|
|
628
|
+
name: change.name,
|
|
629
|
+
seat: numberValue(change.seat),
|
|
630
|
+
cause: change.cause,
|
|
631
|
+
killer: change.killer,
|
|
632
|
+
from_status: change.from_status,
|
|
633
|
+
to_status: change.to_status
|
|
634
|
+
})) : [];
|
|
635
|
+
const players = Array.isArray(event.players) ? event.players.filter((player) => !!player && typeof player === "object" && !Array.isArray(player)).map((player) => cleanObject({
|
|
636
|
+
name: player.name,
|
|
637
|
+
seat: numberValue(player.seat),
|
|
638
|
+
status: player.status,
|
|
639
|
+
death: player.death && typeof player.death === "object" ? cleanObject({
|
|
640
|
+
cause: player.death.cause,
|
|
641
|
+
killer: player.death.killer ?? null
|
|
642
|
+
}) : null
|
|
643
|
+
})) : [];
|
|
644
|
+
return cleanObject({
|
|
645
|
+
type: "players_changed",
|
|
646
|
+
tick: numberValue(event.tick) ?? null,
|
|
647
|
+
meeting: event.meeting === true ? true : void 0,
|
|
648
|
+
meeting_count: numberValue(event.meeting_count),
|
|
649
|
+
reason: event.reason,
|
|
650
|
+
changes,
|
|
651
|
+
players
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
function compactEventForEvents(event, ctx = {}) {
|
|
655
|
+
if (event.type === "role_assigned") return compactRoleAssignedForEvents(event);
|
|
656
|
+
if (event.type === "meeting_briefing") {
|
|
657
|
+
const { room: _room, ...rest } = event;
|
|
658
|
+
return cleanObject({
|
|
659
|
+
...rest,
|
|
660
|
+
type: text(rest.type, "event"),
|
|
661
|
+
tick: numberValue(rest.tick) ?? null
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
if (event.type === "vote_cast") return compactVoteCastForEvents(event, ctx);
|
|
665
|
+
if (event.type === "exile" || event.type === "no_exile") return compactMeetingResultForEvents(event, ctx);
|
|
666
|
+
if (event.type === "players_changed") return compactPlayersChangedForEvents(event);
|
|
667
|
+
if (event.type === "task_completed" && Array.isArray(event.tasks) && Array.isArray(event.delta)) {
|
|
668
|
+
const { newly_assigned_task: _duplicateAssignment, ...rest } = event;
|
|
669
|
+
return cleanObject({
|
|
670
|
+
...rest,
|
|
671
|
+
type: text(rest.type, "event"),
|
|
672
|
+
tick: numberValue(rest.tick) ?? null
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
return cleanObject({
|
|
676
|
+
...event,
|
|
677
|
+
type: text(event.type, "event"),
|
|
678
|
+
tick: numberValue(event.tick) ?? null
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
function compactEventForChannel(event, ctx = {}) {
|
|
682
|
+
return compactEventForEvents(event, ctx);
|
|
683
|
+
}
|
|
684
|
+
function compactEventFields(event, ctx = {}, line) {
|
|
685
|
+
return cleanObject({
|
|
686
|
+
line,
|
|
687
|
+
...compactEventForEvents(event, ctx)
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
function compactEmergencyState(summary) {
|
|
691
|
+
const emergency = summary.emergency && typeof summary.emergency === "object" && !Array.isArray(summary.emergency) ? summary.emergency : null;
|
|
692
|
+
if (!emergency || typeof emergency.active !== "boolean") return void 0;
|
|
693
|
+
return cleanObject({
|
|
694
|
+
active: emergency.active,
|
|
695
|
+
task_name: stringValue(emergency.task_name),
|
|
696
|
+
room: stringValue(emergency.room),
|
|
697
|
+
x: numberValue(emergency.x),
|
|
698
|
+
y: numberValue(emergency.y),
|
|
699
|
+
remaining_secs: numberValue(emergency.remaining_secs)
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
function compactStateForChannel(summary, events = []) {
|
|
703
|
+
if (!summary || typeof summary !== "object") return null;
|
|
704
|
+
if (typeof summary.phase === "string" && summary.phase.startsWith("room_")) {
|
|
705
|
+
const room = summary.room ?? {};
|
|
706
|
+
const you2 = summary.you ?? {};
|
|
707
|
+
return cleanObject({
|
|
708
|
+
phase: summary.phase,
|
|
709
|
+
you: cleanObject({
|
|
710
|
+
name: you2.name,
|
|
711
|
+
seat: you2.seat,
|
|
712
|
+
is_owner: you2.is_owner
|
|
713
|
+
}),
|
|
714
|
+
room: cleanObject({
|
|
715
|
+
room_code: room.room_code,
|
|
716
|
+
room_type: room.room_type,
|
|
717
|
+
status: room.status,
|
|
718
|
+
member_count: room.member_count,
|
|
719
|
+
deadline: room.deadline,
|
|
720
|
+
idle_destroy_at: room.idle_destroy_at,
|
|
721
|
+
is_owner: room.is_owner,
|
|
722
|
+
ready_to_start: room.ready_to_start,
|
|
723
|
+
role_config: room.role_config,
|
|
724
|
+
role_lock_character_id: room.role_lock_character_id,
|
|
725
|
+
role_lock: room.role_lock,
|
|
726
|
+
members: room.members,
|
|
727
|
+
game_id: room.game_id,
|
|
728
|
+
game_server_name: room.game_server_name
|
|
729
|
+
}),
|
|
730
|
+
recent_events: events.slice(-10).map((event) => cleanObject({
|
|
731
|
+
type: event.type,
|
|
732
|
+
room_code: event.room_code,
|
|
733
|
+
name: event.name,
|
|
734
|
+
agent_id: event.agent_id,
|
|
735
|
+
seat: event.seat,
|
|
736
|
+
status: event.status,
|
|
737
|
+
content: event.content,
|
|
738
|
+
reason: event.reason,
|
|
739
|
+
destroy_at: event.destroy_at,
|
|
740
|
+
close_code: event.close_code,
|
|
741
|
+
seconds_remaining: event.seconds_remaining
|
|
742
|
+
})),
|
|
743
|
+
automation: summary.automation
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
const you = summary.you ?? {};
|
|
747
|
+
const meeting = summary.meeting ?? null;
|
|
748
|
+
const crabSabotage = summary.crab_sabotage && typeof summary.crab_sabotage === "object" && !Array.isArray(summary.crab_sabotage) ? summary.crab_sabotage : null;
|
|
749
|
+
const votesSubmitted = Array.isArray(meeting?.votes_submitted) ? meeting.votes_submitted : void 0;
|
|
750
|
+
const knownPlayers = projectKnownPlayers(summary.players);
|
|
751
|
+
const currentScene = projectCurrentScene(summary, knownPlayers ?? projectPlayers({ summary }));
|
|
752
|
+
return cleanObject({
|
|
753
|
+
phase: summary.phase,
|
|
754
|
+
tick: summary.tick,
|
|
755
|
+
you: cleanObject({
|
|
756
|
+
name: you.player?.name,
|
|
757
|
+
seat: you.player?.seat,
|
|
758
|
+
role: you.role,
|
|
759
|
+
faction: you.faction,
|
|
760
|
+
alive: you.is_alive,
|
|
761
|
+
room: you.room,
|
|
762
|
+
kill_cooldown_secs: you.kill_cooldown_secs,
|
|
763
|
+
activity: you.activity,
|
|
764
|
+
tasks: Array.isArray(you.tasks) ? you.tasks : void 0,
|
|
765
|
+
crab_teammates: Array.isArray(you.crab_teammates) ? teammateObjects({ crab_teammates: you.crab_teammates }, { summary }) : void 0
|
|
766
|
+
}),
|
|
767
|
+
game: cleanObject({
|
|
768
|
+
alive_count: Array.isArray(summary.players) ? summary.players.filter((player) => player?.known_status?.is_alive !== false).length : void 0,
|
|
769
|
+
task_progress: summary.task_progress,
|
|
770
|
+
winner: summary.winner,
|
|
771
|
+
settlement: summary.settlement
|
|
772
|
+
}),
|
|
773
|
+
players: knownPlayers,
|
|
774
|
+
...currentScene,
|
|
775
|
+
meeting: meeting?.active === true ? cleanObject({
|
|
776
|
+
caller: meeting.caller,
|
|
777
|
+
sub_phase: meeting.sub_phase,
|
|
778
|
+
current_speaker: meeting.current_speaker,
|
|
779
|
+
is_my_turn: meeting.current_speaker?.seat !== void 0 && meeting.current_speaker.seat === you.player?.seat,
|
|
780
|
+
votes_submitted_count: votesSubmitted?.length
|
|
781
|
+
}) : void 0,
|
|
782
|
+
crab_sabotage: crabSabotage ? cleanObject({
|
|
783
|
+
status: stringValue(crabSabotage.status),
|
|
784
|
+
cooldown_remaining_secs: numberValue(crabSabotage.cooldown_remaining_secs)
|
|
785
|
+
}) : void 0,
|
|
786
|
+
emergency: compactEmergencyState(summary),
|
|
787
|
+
abilities: projectAgentAbilities(summary),
|
|
788
|
+
urgent: summary.urgent,
|
|
789
|
+
automation: summary.automation
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
function compactStateForEvents(summary, events = []) {
|
|
793
|
+
if (!summary || typeof summary !== "object") return null;
|
|
794
|
+
if (typeof summary.phase === "string" && summary.phase.startsWith("room_")) {
|
|
795
|
+
const room = summary.room ?? {};
|
|
796
|
+
const you2 = summary.you ?? {};
|
|
797
|
+
return cleanObject({
|
|
798
|
+
phase: summary.phase,
|
|
799
|
+
you: cleanObject({
|
|
800
|
+
name: you2.name,
|
|
801
|
+
seat: you2.seat,
|
|
802
|
+
is_owner: you2.is_owner
|
|
803
|
+
}),
|
|
804
|
+
room: cleanObject({
|
|
805
|
+
room_code: room.room_code,
|
|
806
|
+
room_type: room.room_type,
|
|
807
|
+
status: room.status,
|
|
808
|
+
member_count: room.member_count,
|
|
809
|
+
deadline: room.deadline,
|
|
810
|
+
idle_destroy_at: room.idle_destroy_at,
|
|
811
|
+
is_owner: room.is_owner,
|
|
812
|
+
ready_to_start: room.ready_to_start,
|
|
813
|
+
role_config: room.role_config,
|
|
814
|
+
role_lock_character_id: room.role_lock_character_id,
|
|
815
|
+
role_lock: room.role_lock,
|
|
816
|
+
members: room.members,
|
|
817
|
+
game_id: room.game_id,
|
|
818
|
+
game_server_name: room.game_server_name
|
|
819
|
+
}),
|
|
820
|
+
recent_events: events.slice(-10).map((event) => cleanObject({
|
|
821
|
+
type: event.type,
|
|
822
|
+
room_code: event.room_code,
|
|
823
|
+
name: event.name,
|
|
824
|
+
agent_id: event.agent_id,
|
|
825
|
+
seat: event.seat,
|
|
826
|
+
status: event.status,
|
|
827
|
+
content: event.content,
|
|
828
|
+
reason: event.reason,
|
|
829
|
+
destroy_at: event.destroy_at,
|
|
830
|
+
close_code: event.close_code,
|
|
831
|
+
seconds_remaining: event.seconds_remaining
|
|
832
|
+
})),
|
|
833
|
+
automation: summary.automation
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
const you = summary.you ?? {};
|
|
837
|
+
const meeting = summary.meeting ?? null;
|
|
838
|
+
const crabSabotage = summary.crab_sabotage && typeof summary.crab_sabotage === "object" && !Array.isArray(summary.crab_sabotage) ? summary.crab_sabotage : null;
|
|
839
|
+
const votesSubmitted = Array.isArray(meeting?.votes_submitted) ? meeting.votes_submitted : void 0;
|
|
840
|
+
const knownPlayers = projectKnownPlayers(summary.players);
|
|
841
|
+
const currentScene = projectCurrentScene(summary, knownPlayers ?? projectPlayers({ summary }));
|
|
842
|
+
return cleanObject({
|
|
843
|
+
phase: summary.phase,
|
|
844
|
+
tick: summary.tick,
|
|
845
|
+
you: cleanObject({
|
|
846
|
+
name: you.player?.name,
|
|
847
|
+
seat: you.player?.seat,
|
|
848
|
+
role: you.role,
|
|
849
|
+
faction: you.faction,
|
|
850
|
+
alive: you.is_alive,
|
|
851
|
+
room: you.room,
|
|
852
|
+
kill_cooldown_secs: you.kill_cooldown_secs,
|
|
853
|
+
activity: you.activity,
|
|
854
|
+
tasks: Array.isArray(you.tasks) ? you.tasks : void 0,
|
|
855
|
+
crab_teammates: Array.isArray(you.crab_teammates) ? teammateObjects({ crab_teammates: you.crab_teammates }, { summary }) : void 0
|
|
856
|
+
}),
|
|
857
|
+
game: cleanObject({
|
|
858
|
+
alive_count: Array.isArray(summary.players) ? summary.players.filter((player) => player?.known_status?.is_alive !== false).length : void 0,
|
|
859
|
+
task_progress: summary.task_progress,
|
|
860
|
+
winner: summary.winner,
|
|
861
|
+
settlement: summary.settlement
|
|
862
|
+
}),
|
|
863
|
+
players: knownPlayers,
|
|
864
|
+
...currentScene,
|
|
865
|
+
meeting: meeting?.active === true ? cleanObject({
|
|
866
|
+
caller: meeting.caller,
|
|
867
|
+
sub_phase: meeting.sub_phase,
|
|
868
|
+
current_speaker: meeting.current_speaker,
|
|
869
|
+
is_my_turn: meeting.current_speaker?.seat !== void 0 && meeting.current_speaker.seat === you.player?.seat,
|
|
870
|
+
votes_submitted_count: votesSubmitted?.length
|
|
871
|
+
}) : void 0,
|
|
872
|
+
crab_sabotage: crabSabotage ? cleanObject({
|
|
873
|
+
status: stringValue(crabSabotage.status),
|
|
874
|
+
cooldown_remaining_secs: numberValue(crabSabotage.cooldown_remaining_secs)
|
|
875
|
+
}) : void 0,
|
|
876
|
+
emergency: compactEmergencyState(summary),
|
|
877
|
+
abilities: projectAgentAbilities(summary),
|
|
878
|
+
urgent: summary.urgent,
|
|
879
|
+
automation: summary.automation
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
function shortStateText(summary) {
|
|
883
|
+
if (!summary || typeof summary !== "object") return "state unavailable";
|
|
884
|
+
const phase = text(summary.phase, "unknown");
|
|
885
|
+
if (phase.startsWith("room_")) {
|
|
886
|
+
const room = summary.room ?? {};
|
|
887
|
+
const parts2 = [phase];
|
|
888
|
+
if (room.room_code) parts2.push(`room=${room.room_code}`);
|
|
889
|
+
if (room.room_type) parts2.push(`mode=${room.room_type}`);
|
|
890
|
+
if (room.status) parts2.push(`status=${room.status}`);
|
|
891
|
+
if (room.member_count !== void 0) parts2.push(`members=${room.member_count}/10`);
|
|
892
|
+
if (room.is_owner !== void 0) parts2.push(room.is_owner ? "owner=yes" : "owner=no");
|
|
893
|
+
if (room.ready_to_start) parts2.push("ready=confirm-start");
|
|
894
|
+
return parts2.join("; ");
|
|
895
|
+
}
|
|
896
|
+
const sub = typeof summary.meeting?.sub_phase === "string" ? `/${summary.meeting.sub_phase}` : "";
|
|
897
|
+
const parts = [`${phase}${sub}`];
|
|
898
|
+
const you = summary.you ?? {};
|
|
899
|
+
const self = you.player && typeof you.player === "object" ? you.player : {};
|
|
900
|
+
if (self.name) {
|
|
901
|
+
if (typeof you.is_alive === "boolean") parts.push(`you=${self.name} ${you.is_alive ? "alive" : "dead"}`);
|
|
902
|
+
else parts.push(`you=${self.name}`);
|
|
903
|
+
}
|
|
904
|
+
const speaker = summary.meeting?.current_speaker;
|
|
905
|
+
if (speaker?.name) parts.push(`speaker=${speaker.seat === self.seat ? "you" : speaker.name}`);
|
|
906
|
+
const aliveCount = Array.isArray(summary.players) ? summary.players.filter((player) => player?.known_status?.is_alive !== false).length : void 0;
|
|
907
|
+
if (aliveCount !== void 0) parts.push(`alive=${aliveCount}`);
|
|
908
|
+
if (summary.emergency?.active === true || summary.urgent?.emergency_active) parts.push("urgent=emergency");
|
|
909
|
+
if (summary.urgent?.corpse_nearby) parts.push("urgent=corpse");
|
|
910
|
+
return parts.join("; ");
|
|
911
|
+
}
|
|
912
|
+
export {
|
|
913
|
+
compactEventFields,
|
|
914
|
+
compactEventForChannel,
|
|
915
|
+
compactEventForEvents,
|
|
916
|
+
compactStateForChannel,
|
|
917
|
+
compactStateForEvents,
|
|
918
|
+
formatEventMessage,
|
|
919
|
+
seatMapFromSummary,
|
|
920
|
+
shortStateText
|
|
921
|
+
};
|