diff --git a/services/minecraft/src/cognitive/conscious/js-planner.ts b/services/minecraft/src/cognitive/conscious/js-planner.ts index 31640617e..10737fba1 100644 --- a/services/minecraft/src/cognitive/conscious/js-planner.ts +++ b/services/minecraft/src/cognitive/conscious/js-planner.ts @@ -229,6 +229,7 @@ export class JavaScriptPlanner { { name: 'query', kind: 'object', readonly: true }, { name: 'query.self', kind: 'function', readonly: true }, { name: 'query.snapshot', kind: 'function', readonly: true }, + { name: 'query.gaze', kind: 'function', readonly: true }, { name: 'bot', kind: 'object', readonly: true }, { name: 'mineflayer', kind: 'object', readonly: true }, { name: 'mem', kind: 'object', readonly: false }, diff --git a/services/minecraft/src/cognitive/conscious/query-dsl.ts b/services/minecraft/src/cognitive/conscious/query-dsl.ts index 33ab8a8a2..927ca14d1 100644 --- a/services/minecraft/src/cognitive/conscious/query-dsl.ts +++ b/services/minecraft/src/cognitive/conscious/query-dsl.ts @@ -5,6 +5,8 @@ import type { Mineflayer } from '../../libs/mineflayer' import { Vec3 } from 'vec3' +import { computeNearbyPlayerGaze } from '../perception/gaze' + import * as world from '../../skills/world' interface BlockRecord { @@ -388,5 +390,11 @@ export function createQueryRuntime(mineflayer: Mineflayer) { entities: () => new EntityQueryChain(mineflayer), inventory: () => new InventoryQueryChain(mineflayer), craftable: () => new NameQueryChain(world.getCraftableItems(mineflayer)), + gaze: (options?: { range?: number }) => { + return computeNearbyPlayerGaze(mineflayer.bot, { + maxDistance: 32, + nearbyDistance: options?.range ?? 16, + }) + }, } } diff --git a/services/minecraft/src/cognitive/index.ts b/services/minecraft/src/cognitive/index.ts index c2552cc16..83b08d374 100644 --- a/services/minecraft/src/cognitive/index.ts +++ b/services/minecraft/src/cognitive/index.ts @@ -5,7 +5,6 @@ import { DebugService } from '../debug' import { McpReplServer } from '../debug/mcp-repl-server' import { ChatMessageHandler } from '../libs/mineflayer' import { createAgentContainer } from './container' -import { computeNearbyPlayerGaze } from './reflex/gaze' export function CognitiveEngine(options: CognitiveEngineOptions): MineflayerPlugin { let container: ReturnType @@ -91,15 +90,7 @@ export function CognitiveEngine(options: CognitiveEngineOptions): MineflayerPlug if (tickCount % 5 !== 0) return - const gaze = computeNearbyPlayerGaze(bot.bot, { maxDistance: 32, nearbyDistance: 16 }) - reflexManager.updateEnvironment({ - nearbyPlayersGaze: gaze.map(g => ({ - name: g.playerName, - distanceToSelf: g.distanceToSelf, - lookPoint: g.lookPoint, - hitBlock: g.hitBlock, - })), - }) + // Other periodic updates can go here }) // Resolve EventBus for message handling diff --git a/services/minecraft/src/cognitive/reflex/gaze.test.ts b/services/minecraft/src/cognitive/perception/gaze.test.ts similarity index 100% rename from services/minecraft/src/cognitive/reflex/gaze.test.ts rename to services/minecraft/src/cognitive/perception/gaze.test.ts diff --git a/services/minecraft/src/cognitive/reflex/gaze.ts b/services/minecraft/src/cognitive/perception/gaze.ts similarity index 100% rename from services/minecraft/src/cognitive/reflex/gaze.ts rename to services/minecraft/src/cognitive/perception/gaze.ts diff --git a/services/minecraft/src/cognitive/reflex/context.ts b/services/minecraft/src/cognitive/reflex/context.ts index 5c43cee0e..fbc3d911b 100644 --- a/services/minecraft/src/cognitive/reflex/context.ts +++ b/services/minecraft/src/cognitive/reflex/context.ts @@ -11,12 +11,6 @@ export interface ReflexEnvironmentState { time: string weather: 'clear' | 'rain' | 'thunder' nearbyPlayers: Array<{ name: string, distance?: number, holding?: string | null }> - nearbyPlayersGaze: Array<{ - name: string - distanceToSelf: number - lookPoint: { x: number, y: number, z: number } - hitBlock: null | { name: string, pos: { x: number, y: number, z: number } } - }> nearbyEntities: Array<{ name: string, distance?: number, kind?: string }> lightLevel: number } @@ -75,7 +69,6 @@ export class ReflexContext { time: 'SOMETHING WENT WRONG, YOU SHOULD NOTIFY THE USER OF THIS', weather: 'clear', nearbyPlayers: [], - nearbyPlayersGaze: [], nearbyEntities: [], lightLevel: 15, }, @@ -113,16 +106,6 @@ export class ReflexContext { environment: { ...this.state.environment, nearbyPlayers: this.state.environment.nearbyPlayers.map(p => ({ ...p })), - nearbyPlayersGaze: this.state.environment.nearbyPlayersGaze.map(p => ({ - ...p, - lookPoint: { ...p.lookPoint }, - hitBlock: p.hitBlock - ? { - ...p.hitBlock, - pos: { ...p.hitBlock.pos }, - } - : null, - })), nearbyEntities: this.state.environment.nearbyEntities.map(e => ({ ...e })), }, social: {