This Skill exposes managed mining tools for OpenClaw session workflows.
Automated agents (including OpenClaw workflows) must follow these constraints:
POST /tool/:name on the skill-openclaw service, using the tool names documented below ( set_api_code, check_mining_state, start_managed_mining_loop, etc.). Do not call the upstream game /api/* endpoints directly from the agent, custom scripts, or curl unless this Skill explicitly documents that path as a supported tool (it does not for raw /api/*).skill-openclaw source tree, package.json, or runtime code to “fix” behaviour. Use documented environment variables and this SKILL.md only.cacheKey, timestamps, logs). Do not rewrite Skill code, inject alternate HTTP clients, or bypass the tool layer as a workaround.All mining and stamina APIs require X-Api-Code.
POST /api/startMiningPOST /api/checkMiningStatePOST /api/endMiningPOST /api/setAutoMiningPOST /api/buyStaminaPOST /api/getStamina(Internal round flow still uses POST /api/setAutoMining, POST /api/startMining and POST /api/endMining via the managed loop implementation; they are not exposed as Skill tools.)
Authentication:
X-Api-Code: <apiCode>The Skill does not perform game client login. Users must provide apiCode generated in-game.
check_mining_state returns apiState and miningState. Numeric values map as follows.
apiState
ValueName0ApiInactive1ApiInUse2ApiClosing3ApiActive
miningState
ValueName0MiningIdle1MiningInProgress2MiningRewardPending
Persist an apiCode for later calls.
Inputs:
apiCode (required)cacheKey (optional, default: default)Read the cached apiCode.
Inputs:
cacheKey (optional, default: default)Delete the cached apiCode.
Inputs:
cacheKey (optional, default: default)Query API activation status and mining state. Returns apiState and miningState (see State Codes).
Inputs:
apiCode (optional, falls back to cache)cacheKey (optional, default: default)Buy stamina using diamonds.
Inputs:
apiCode (optional, falls back to cache)cacheKey (optional, default: default)Get stamina and diamonds.
Inputs:
apiCode (optional, falls back to cache)cacheKey (optional, default: default)Start managed loop execution.
Flow:
start_mining — abort on errorestimatedEndAtend_mining — retry on error, round complete on successInputs:
apiCode (optional, falls back to cache)cacheKey (optional, default: default)lang (optional)pollingIntervalMilliseconds (optional)roundIntervalMilliseconds (optional)maxConsecutiveErrorCount (optional)autoBuyStamina (optional)autoBuyStaminaMaxFailures (optional)forceRestart (optional)Same as start_managed_mining_loop with OpenClaw session binding and event stream.
Read incremental session events.
Inputs:
sinceEventId (optional, default: 0)Read lightweight managed loop status.
Read full managed loop status.
Request safe stop for running managed loop.
start_auto_mining (deprecated)stop_auto_mining (deprecated)set_api_code (one-time setup)start_mining_sessionget_mining_quick_status or get_mining_session_events on demand — do not set up automatic periodic polling by defaultstop_managed_mining_loop when neededAll API responses include a code field. 0 means success; non-zero values indicate an error.
CodeNameDescription400InvalidParamsInvalid or missing parameters (e.g. empty X-Api-Code header)401AuthFailedAuthentication failed (invalid apiCode)500InternalServerErrorServer internal error1010NotEnoughResourcesInsufficient resources (diamonds not enough for stamina purchase)
CodeNameDescription2003InsufficientResourcesInsufficient stamina to start mining2008DiamondNotEnoughtInsufficient diamonds2009MiningStateConflictMining state conflict (e.g. calling startMining while already in progress, or endMining when not mining via API)2014MiningApiNotActiveAPI mining feature not activated for this player2018MiningNotFinishedMining not finished yet (current time has not reached estimatedEndAt)
VariableDescriptionGAME_API_BASE_URLOptional API base URL override (default: https://api.km.cocweb3.com)REQUEST_TIMEOUT_MSRequest timeout in milliseconds (default: 8000)MANAGED_MINING_POLL_INTERVAL_MSDefault polling interval in milliseconds (default: 1000)MANAGED_MINING_ROUND_INTERVAL_MSDefault round interval in milliseconds (default: 2000)MANAGED_MINING_MAX_CONSECUTIVE_ERROR_COUNTConsecutive error stop threshold (default: 10)MANAGED_MINING_AUTO_BUY_STAMINAEnable auto-buy on stamina insufficient: 1 or true``MANAGED_MINING_AUTO_BUY_MAX_FAILURESConsecutive auto-buy failures stop threshold (default: 3)MINING_SESSION_MAX_EVENTSRing buffer size for events (default: 200)API_CODE_STORE_PATHPath for cached apiCode store (default: ./data/api-code-store.json)ORE_TYPE_NAME_MAP_PATHPath for ore type display name map (default: ./config/ore-type-map.json)