Skip to content

Capability Runtime

Header: claw_cap.h

claw_cap is the capability runtime: anything “callable as a capability”—whether exposed to the model as a tool, to the console as cap call, or invoked from the Event Router via call_cap—is registered with metadata and executed through one entry point.

claw_cap_descriptor_t describes a single capability. Key fields:

  • id / name: identifiers and display names (call path depends on implementation).
  • family: logical grouping (shown in listings).
  • description, input_schema_json: human- and model-facing docs and parameter schema.
  • kind: e.g. CALLABLE, EVENT_SOURCE, HYBRID for call-only vs event-emitting vs both.
  • cap_flags: e.g. CLAW_CAP_FLAG_CALLABLE_BY_LLM, lifecycle support, etc.
  • init / start / stop: optional lifecycle hooks.
  • execute: receives JSON input string and call context claw_cap_call_context_t (session, channel, caller, …); output goes to caller-provided buffers.

Related descriptors can be grouped in claw_cap_group_t and registered with claw_cap_register_group for unified start/stop and per-group enable/disable.

Typical call paths:

  1. Agent: claw_core → configured call_capclaw_cap_call_from_core (maps claw_core_request_t to claw_cap_call_context_t).
  2. Console: cap call <name> <json> (see Console usage).
  3. Event Router: rule action call_cap (see Dataflow and automation).

claw_cap_call_context_t.caller distinguishes SYSTEM / AGENT / CONSOLE so implementations can branch.

claw_cap_build_llm_tools_json builds the tool list for the current context; claw_cap_tools_provider supplies it as TOOLS context to claw_core.

claw_cap_set_llm_visible_groups applies a group id allow-list. basic_demo defaults to exposing cap_files, cap_skill, cap_system, and cap_lua to the LLM, and full structured-memory mode also exposes claw_memory; see BASIC_DEMO_LLM_VISIBLE_GROUPS in app_claw.c.

  • claw_cap_list / claw_cap_list_groups: enumerate caps and groups.
  • claw_cap_enable_group / claw_cap_disable_group: enable or disable by group.
  • claw_cap_unregister_group / claw_cap_unregister: unload (waits for active calls with timeout).