import { runStrategyWorker } from '@myclaw163/game-agent-runtime/strategy/strategy-worker-host.js'; import type { BehaviorInput, BehaviorDecision, BehaviorReadApi } from '../../../../sdk/behavior-plugin/index.js'; import { createBehaviorReadApi } from '../../behavior-read-api.js'; import { normalizeBehaviorDecision } from '../../behavior-decision.js'; import { resolveBehaviorSource, validateClawclawBehaviorModule } from './behavior-module-loader.js'; import { prepareClawclawBehavior } from './behavior-normalization.js'; import type { ResolvedClawclawBehaviorSource } from './behavior-source.js'; import type { ClawclawBehaviorObservationSnapshot } from '../../behavior-observation-memory.js'; // The framework owns Worker protocol, instances, snapshots and memory RPC. // This entry point only adapts the game SDK and verifies the pinned source. await runStrategyWorker({ async load(data) { resolveBehaviorSource(data.source); const module = await import(data.sourceUrl) as Record; resolveBehaviorSource(data.source); const loaded = validateClawclawBehaviorModule(module, data.source); return { execution: loaded.manifest.execution ?? 'parallel', stateMode: loaded.manifest.stateMode, create: () => new loaded.BehaviorClass(), prepare: input => prepareClawclawBehavior(loaded.BehaviorClass, loaded.manifest, input, loaded.source), }; }, createApi: createBehaviorReadApi, normalize: value => normalizeBehaviorDecision(value, {finite:false}) as BehaviorDecision, });