Agent Skillsespressif/esp-claw › http_server_lua_demo

http_server_lua_demo

GitHub

启动Lua HTTP服务器演示,提供Hello World页面及浏览器开关回调功能。异步运行脚本监听状态变更并记录日志,支持自定义应用ID和静态资源路径。

components/lua_modules/lua_module_http_server/skills/http_server_lua_demo/SKILL.md espressif/esp-claw

触发场景

需要快速搭建Lua Web服务 测试Lua与HTTP交互 查看Hello World示例

安装

npx skills add espressif/esp-claw --skill http_server_lua_demo -g -y
更多选项

非标准路径

npx skills add https://github.com/espressif/esp-claw/tree/master/components/lua_modules/lua_module_http_server/skills/http_server_lua_demo -g -y

不安装直接使用

npx skills use espressif/esp-claw@http_server_lua_demo

指定 Agent (Claude Code)

npx skills add espressif/esp-claw --skill http_server_lua_demo -a claude-code -g -y

安装 repo 全部 skill

npx skills add espressif/esp-claw --all -g -y

预览 repo 内 skill

npx skills add espressif/esp-claw --list

SKILL.md

Frontmatter
{
    "name": "http_server_lua_demo",
    "metadata": {
        "cap_groups": [
            "cap_lua"
        ],
        "manage_mode": "readonly"
    },
    "description": "Start a small Lua-hosted web page that shows Hello World and logs switch toggles from the browser."
}

HTTP Server Lua Demo

Use this skill when the user wants a simple Lua HTTP server demo page, a Hello World web UI, or a browser switch that calls back into Lua.

Run exactly one bundled Lua script asynchronously with the Lua script execution capability.

If script execution returns an error, report that error directly to the user.

Script Args Schema

{
  "type": "object",
  "properties": {
    "app_id": {
      "type": "string",
      "description": "Optional URL-safe app id. Defaults to lua_demo."
    },
    "web_root": {
      "type": "string",
      "description": "Optional absolute directory for static web files. Defaults to {CUR_SKILL_DIR}/assets."
    }
  }
}

Tool Call Inputs

Default action:

{
  "path": "{CUR_SKILL_DIR}/scripts/lua_demo_server.lua",
  "args": {
    "app_id": "lua_demo",
    "web_root": "{CUR_SKILL_DIR}/assets"
  }
}

Recommended Flow

Run the bundled Lua script asynchronously so the HTTP callbacks stay alive:

  • Script: {CUR_SKILL_DIR}/scripts/lua_demo_server.lua
  • Capability: lua_run_script_async
  • Timeout: 0
  • Name: http_server_lua_demo
  • Exclusive: http_server_lua_demo
  • Replace: true
  • Args: optional object

Example args:

{
  "app_id": "lua_demo",
  "web_root": "{CUR_SKILL_DIR}/assets"
}

After the script starts, open:

/lua/lua_demo/

Keep the trailing slash. Opening /lua/lua_demo without the trailing slash can make browsers resolve relative assets under /lua/ instead of /lua/lua_demo/. The bundled page uses absolute asset paths for the default lua_demo app id; if app_id is changed, update the HTML asset URLs or keep using the exact trailing-slash URL.

Behavior

The script mounts the bundled assets/ directory with http_server and registers:

  • GET /api/lua/lua_demo/state
  • POST /api/lua/lua_demo/toggle

The page displays "Hello World" and a switch. When the switch changes, the browser posts the new state to Lua, and Lua logs:

[http_server_lua_demo] {"enabled":true,"event":"switch_toggled"}

JSON Usage

The script uses lua_module_json to decode the browser POST body instead of matching JSON text manually. The /toggle handler accepts:

{
  "enabled": true
}

Lua parses the request body with:

local data = json.decode(req.body)

The script also uses json.encode() to print structured switch events.

Stop the async Lua job when the demo page should be closed.

版本历史

  • 06eb576 当前 2026-07-24 19:54

同 Skill 集合

components/claw_capabilities/cap_http_request/skills/cap_http_request/SKILL.md
components/claw_capabilities/cap_im_platform/skills/cap_im_platform/SKILL.md
components/claw_capabilities/cap_router_mgr/skills/cap_router_mgr/SKILL.md
components/claw_capabilities/cap_scheduler/skills/cap_scheduler/SKILL.md
components/claw_capabilities/cap_web_search/skills/cap_web_search/SKILL.md
components/claw_modules/claw_memory/skills/memory_ops/SKILL.md
components/claw_modules/claw_memory/skills/profile_memory_ops/SKILL.md
components/common/skill_builder/skills/skill_creator/SKILL.md
components/common/skill_builder/skills/skills_lab_downloader/SKILL.md
components/common/skill_builder/skills/skills_lab_search/SKILL.md
components/lua_modules/lua_driver_touch/skills/read_touch/SKILL.md
components/lua_modules/lua_module_ble_hid/skills/ble_hid/SKILL.md
components/lua_modules/lua_module_ble/skills/ble/SKILL.md
components/lua_modules/lua_module_camera/skills/take_picture/SKILL.md
components/claw_capabilities/cap_llm_inspect/skills/cap_llm_inspect_image/SKILL.md

元信息

文件数
0
版本
74b1870
Hash
ca45e4c2
收录时间
2026-07-24 19:54

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-16 13:40
浙ICP备14020137号-1 $访客地图$