Worm Commander is a browser-based snake game that doubles as a multi-modal, multi-agent demo. You can steer with the keyboard, point-and-click/tap, or issue natural language commands through the GuideAnts chat component. The game also exposes in-browser tools so the guide can read game state and control the worm.
This repository is a standalone sample intended for GitHub: it includes the full TypeScript source, assets, and a simple build + static serve workflow.
- Multi-modal control: keyboard, mouse/touch, and voice commands
- A tool-based agent loop: the guide reads worm senses and issues actions
- Autopilot behaviors: eat, survive, hunt, avoid
- Real-time, reactive gameplay under pressure
The worm is a classical agent:
- Perception:
getWormSenses()reports position, heading, food, threats, and a polar world view - Decision-making:
applyAutopilot()evaluates candidate actions and scores them by alignment, clearance, and risk - Autonomy: autopilot can run without direct user control
- Reactivity: decision cadence increases when danger is close
- Proactiveness: selects targets and balances pursuit with safety
- Social ability: avoids, intercepts, and evaluates other snakes
The guide (LLM + chat UI) is an agent:
- Perception: receives worm senses via
setContextProvider() - Decision-making: resolves commands, handles ambiguity, and sequences tool calls
- Action: invokes tools like ExecuteIntent, Turn, Pause, Resume
- Reactivity: refreshes senses after each tool call and adapts
The human is part of the control hierarchy:
- Perception: sees the game state
- Decision-making: chooses direct control vs. delegation
- Action: keyboard, UI buttons, voice commands, or autopilot
- Keyboard: Arrow keys or A/D to turn, R to restart, Space to toggle voice
- Mouse/touch: click or tap in the play area to steer
- Voice: phrases like "turn left", "pause", "eat and grow", "hunt"
npm install
npm run build
npm run startnpm run start serves public/ and hosts the game locally.
src/TypeScript sourcepublic/static assets andworm-commander.jspublic/sounds/voice-snakes/audio + artwork
- Voice requires a microphone and browser permission.
- The guide uses the GuideAnts chat component (see
src/voice-snakes.ts). - This sample is preconfigured to use a published guide in GuideAnts Notebooks. Its source is in
WormCommander\Guide.
The GuideAnts Chat Component is a framework-agnostic web component for embedding conversations from published GuideAnts Notebooks into any page. It is driven by a required pub-id (the published guide ID) plus optional configuration like api-base-url, speech-to-text-enabled, and input labeling.
- Source repository: https://github.com/Elumenotion/GuideAntsChat
- The component is registered by bundling
guideantsinWormCommander\Game\src\voice-snakes.ts. - The UI is declared in
WormCommander\Game\public\index.htmlwith the GuideAnts API endpoint, published guide ID, and microphone enabled. - The game bridges state and tools via
setContextProvider(...)andregisterTool(...)inWormCommander\Game\src\voice-snakes\speech.ts.
<guideants-chat
id="worm-commander-chat"
class="theme-elumenotion"
api-base-url="https://api.guideants.ai"
pub-id="a64e4f78-a486-4747-87fa-42a5655e88c6"
speech-to-text-enabled="true"
input-label
input-placeholder="Say: left, right, pause, resume, restart"
></guideants-chat>- Update
pub-idto point at your published guide. - Adjust
api-base-urlif you want to target a different GuideAnts API host. - Toggle
speech-to-text-enabledand tweakinput-label/input-placeholderto match your UI.
The guide calls tools that execute inside the browser. This is a client-side tool loop: the published guide uses an OpenAPI spec, and the game registers matching tool handlers on the <guideants-chat> element.
- Tool definitions live in
WormCommander\Guide\OpenAPI\Web Connector.json.
This OpenAPI spec uses theclient://worm-commander-clientserver URL and declares operations such asStart,Pause,Resume,Turn,HoldTurn,ExecuteIntent,SetAutopilot,Status, andEnableMusic. - Tool handlers are registered in
WormCommander\Game\src\voice-snakes\speech.ts.
The chat element is discovered andregisterTool(...)is called for each operation. Each handler executes game logic and returns aToolResultpayload with updated senses. - Senses/context are sent from the game to the guide via
setContextProvider(...)inWormCommander\Game\src\voice-snakes\speech.ts.
This provides the guide with current worm senses for decision‑making.
WormCommander\Guide\OpenAPI\Web Connector.jsonWormCommander\Game\src\voice-snakes\speech.tsWormCommander\Game\src\voice-snakes\index.tsWormCommander\Game\src\voice-snakes.ts
Use the exported guide package in WormCommander\Guide\guide-Worm Commander-1768599131865.zip to copy the guide into your team and customize the guide in GuideAnts Notebooks.
- Open GuideAnts Notebooks and navigate to the project where you want the guide.
- In the left sidebar, open Team Guides (project owners only).
- Click Import Guide.
- Select
guide-Worm Commander-1768599131865.zip. - Review the preview:
- Confirm the guide name and description.
- Check crew members and any custom assistants included.
- Resolve any name conflicts (rename, skip, or overwrite if allowed).
- Confirm the import.
- Open the newly imported guide and review:
- Instructions and Home Page content.
- Model and parameters (temperature, top‑p, reasoning effort).
- Tools and any custom OpenAPI tools.
- Context options.
- Update authentication as needed:
- Re-enter API keys or OAuth settings (secrets are not included in exports).
- Save, then run a quick test conversation.
- If a global assistant referenced in the guide is missing in your environment, replace it with a similar assistant during import or after.
- If you plan to publish the customized guide, configure its publish settings after import.