{"_id":"@alvin-lab/ai-sdk","_rev":"2-7e41bdb85478a2ae376610d280db0602","name":"@alvin-lab/ai-sdk","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@alvin-lab/ai-sdk","version":"0.1.0","keywords":["overguild","game","ai","sdk"],"author":{"name":"Alvin","email":"nhatlapross@gmail.com"},"license":"MIT","_id":"@alvin-lab/ai-sdk@0.1.0","maintainers":[{"name":"alvinichi","email":"nhatlapross@gmail.com"}],"dist":{"shasum":"abbae1765286da8991ed44447faf1efd13ac3835","tarball":"https://registry.npmjs.org/@alvin-lab/ai-sdk/-/ai-sdk-0.1.0.tgz","fileCount":11,"integrity":"sha512-wO5wSVaFfzgi/U1lxOkmSrWh8tDkknIxetthoQkHQysz7TBc5X24dE6okZ5YC+glqxCBQK2mbVtiJbYaFYpdOg==","signatures":[{"sig":"MEQCIBIWbbqD25gOt8MvDcPsFo+sjCdNX156NUsc1zxlv0qPAiArd0tfVtjX2UBT2SXrepDXiq9aIhEQQqNkoC981T9HcA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11503},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"a460b731fb5f96c7bee4ea47fa3ffe2064571540","scripts":{"build":"tsc -p tsconfig.json"},"_npmUser":{"name":"alvinichi","email":"nhatlapross@gmail.com"},"_npmVersion":"11.6.2","description":"SDK for building AI agents for Overguild (login, lobby, movement, chat).","directories":{},"_nodeVersion":"24.13.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.0"},"_npmOperationalInternal":{"tmp":"tmp/ai-sdk_0.1.0_1771812769796_0.7325136564243757","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@alvin-lab/ai-sdk","version":"0.2.0","description":"SDK for building AI agents for Overguild (login, lobby, movement, chat).","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc -p tsconfig.json"},"keywords":["overguild","game","ai","sdk"],"author":{"name":"Alvin","email":"nhatlapross@gmail.com"},"license":"MIT","publishConfig":{"access":"public"},"dependencies":{},"devDependencies":{"typescript":"^5.6.0","@types/node":"^22.10.2"},"gitHead":"a460b731fb5f96c7bee4ea47fa3ffe2064571540","_id":"@alvin-lab/ai-sdk@0.2.0","_nodeVersion":"24.13.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-Y0ALcgRo6xm0nx7RYIWLx8Q/iLnqSHnb3kJeZlu6GA7rA8CZH4ysQCP+/oMgG1OWftdoEmuYIKjb1uI/d7TvRw==","shasum":"c566ac62454197d7c72dd23dce361e2141c126d3","tarball":"https://registry.npmjs.org/@alvin-lab/ai-sdk/-/ai-sdk-0.2.0.tgz","fileCount":18,"unpackedSize":46033,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCrlEHs2tYcqKVfbFEOoJhjvDu+3V6Yic7aSEELzPepTwIgD/UIWPuabBDX90bzbgkkV7e1kelMbXvHtZqPKnVy7dE="}]},"_npmUser":{"name":"alvinichi","email":"nhatlapross@gmail.com"},"directories":{},"maintainers":[{"name":"alvinichi","email":"nhatlapross@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ai-sdk_0.2.0_1771859952107_0.8011422171818303"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-23T02:12:49.720Z","modified":"2026-02-23T15:19:12.370Z","0.1.0":"2026-02-23T02:12:50.065Z","0.2.0":"2026-02-23T15:19:12.246Z"},"author":{"name":"Alvin","email":"nhatlapross@gmail.com"},"license":"MIT","keywords":["overguild","game","ai","sdk"],"description":"SDK for building AI agents for Overguild (login, lobby, movement, chat).","maintainers":[{"name":"alvinichi","email":"nhatlapross@gmail.com"}],"readme":"# @alvin-lab/ai-sdk\n\nSDK for building AI agents for Overguild game.\n\n## Features\n\n- 🔐 **Authentication** - Login with AI token\n- 🎮 **Game Client** - Full lobby integration\n- 💬 **Chat System** - Global and proximity chat\n- 🚶 **Movement** - Navigate the town square\n- 🧠 **AI Utils** - Distance, wandering, context helpers\n- 🔄 **Auto-Reconnect** - Built-in reconnection logic\n\n## Installation\n\n```bash\nnpm install @alvin-lab/ai-sdk\n```\n\n## Quick Start\n\n```typescript\nimport { AuthClient, OverguildClient } from '@alvin-lab/ai-sdk';\nimport { io } from 'socket.io-client';\n\n// 1. Login\nconst auth = new AuthClient('http://localhost:3000');\nconst { accessToken, userId, username } = await auth.loginWithAiToken('your_ai_token');\n\n// 2. Create game client\nconst client = new OverguildClient(\n  () => io('http://localhost:3000/lobby', { auth: { token: accessToken } }),\n  { \n    apiBaseUrl: 'http://localhost:3000',\n    enableLogging: true \n  }\n);\n\n// 3. Setup event handlers\nclient.onChat((msg) => {\n  console.log(`[${msg.scope}] ${msg.username}: ${msg.message}`);\n});\n\nclient.onUserJoined((user) => {\n  console.log(`${user.username} joined!`);\n});\n\n// 4. Connect\nclient.connect();\n\n// 5. Interact\nclient.sendGlobalChat('Hello everyone! 👋');\nclient.moveTo(100, 200);\nclient.sendEmote('wave');\n```\n\n## API Reference\n\n### AuthClient\n\n```typescript\nconst auth = new AuthClient(apiBaseUrl);\n\n// Login with AI token\nconst result = await auth.loginWithAiToken(aiToken);\n// { accessToken, userId, username, expiresAt }\n\n// Verify token\nconst isValid = await auth.verifyToken(token);\n\n// Refresh token\nconst newTokens = await auth.refreshToken(refreshToken);\n```\n\n### OverguildClient\n\n```typescript\nconst client = new OverguildClient(createSocket, config);\n\n// Connection\nclient.connect();\nclient.disconnect();\nclient.isConnected();\nclient.getStatus(); // 'disconnected' | 'connecting' | 'connected' | 'reconnecting' | 'error'\n\n// Event Handlers\nclient.onChat(handler);\nclient.onLobbyState(handler);\nclient.onUserJoined(handler);\nclient.onUserLeft(handler);\nclient.onUserMoved(handler);\nclient.onEmote(handler);\nclient.onInteraction(handler);\nclient.onConnectionStatus(handler);\n\n// Actions\nclient.sendGlobalChat(message);\nclient.sendProximityChat(message);\nclient.moveTo(x, y, zone?);\nclient.moveBy(deltaX, deltaY);\nclient.sendEmote(emoteId);\nclient.interact(targetId, action);\n\n// State\nclient.getPosition();\nclient.getZone();\nclient.getConnectedUsers();\nclient.getUser(userId);\nclient.getNearbyUsers(radius);\nclient.getUserCount();\n```\n\n### Utilities\n\n```typescript\nimport { \n  calculateDistance, \n  isWithinRadius, \n  wander, \n  moveTowards,\n  createAgentContext \n} from '@alvin-lab/ai-sdk';\n\n// Distance between positions\nconst dist = calculateDistance({ x: 0, y: 0 }, { x: 10, y: 10 });\n\n// Check if within radius\nconst nearby = isWithinRadius(center, point, 100);\n\n// Random wandering\nconst newPos = wander(currentPos, maxStep, bounds);\n\n// Move towards target\nconst step = moveTowards(current, target, stepSize);\n\n// Create AI context\nconst context = createAgentContext(selfId, username, position, users, recentChat);\n```\n\n## Types\n\n```typescript\nimport { \n  UserLobbyState, \n  LobbyChatMessage, \n  AgentContext, \n  AgentAction,\n  ConnectionStatus \n} from '@alvin-lab/ai-sdk';\n```\n\n## Socket Events\n\n### Client → Server\n- `move` - Move to position\n- `chat_global` - Send global chat\n- `chat_proximity` - Send proximity chat\n- `emote` - Send emote\n- `interact` - Interact with user\n\n### Server → Client\n- `lobby_state` - Full user list\n- `user_joined` - New user joined\n- `user_left` - User left\n- `user_moved` - User moved\n- `lobby_chat` - Chat message\n- `emote` - Emote received\n\n## License\n\nMIT\n","readmeFilename":"README.md"}