跳到主要内容

lark-event 标准

Lark/Feishu real-time event listening / subscribing / consuming: stream events as NDJSON via `lark-cli event consume <EventKey>` (covers IM message receive, reactions, chat member changes, etc.). Use for Lark bots, real-time message processing, long-running subscribers, streaming webhook/push handlers. Supports `--max-events` / `--timeout` bounded runs and a stderr ready-marker contract — designed for AI agents running as subprocesses.

在 GitHub 打开

安装方式

cp -r skills/lark-cli/lark-event ~/.claude/skills/lark-event

把该 skill 目录放进客户端 skills 目录。不同客户端的目录可能不同,Claude Code 默认是 ~/.claude/skills/

整仓一次性获取:git clone --depth 1 https://github.com/pengfeiqiao/kunpeng.git

依赖与权限

  • 无需 API Key
  • 需要联网访问外部服务
  • 依赖外部命令:jq convert
  • 以上为按正文与 frontmatter 自动推断的信号,仅供参考;安装前建议先阅读原文。

SKILL.md 正文

来源 pengfeiqiao/kunpeng@bf8a8ac · 许可 MIT · 内容未修改

Lark Events

Prerequisite: Read [../lark-shared/SKILL.md](../lark-shared/SKILL.md) first for authentication, --as user/bot switching, Permission denied handling, and safety rules.

Core commands

CommandPurpose
lark-cli event list [--json]List all subscribable EventKeys
lark-cli event schema <EventKey> [--json]Show an EventKey's params and output schema
lark-cli event consume <EventKey> [flags]Blocking consume; events → stdout NDJSON
lark-cli event status [--json] [--fail-on-orphan]Inspect the local bus daemon status
lark-cli event stop [--all] [--force]Stop the bus daemon

Common flags

FlagDescription
--param key=value / -pBusiness params (repeatable; comma-separated for multi-value). Unknown keys fail with valid names listed inline
--jq <expr>jq expression to filter / transform each event; empty output skips the event
--max-events NExit after N events. Default 0 = unlimited
--timeout DExit after duration D (e.g. 30s, 2m). Default 0 = no timeout. Whichever of --max-events / --timeout fires first wins
--output-dir <dir>Write each event as a file (relative paths only; prevents traversal)
--quietSuppress stderr diagnostics. AI should not use this — it silences the ready marker
`--as user\bot\auto`Identity for the session (see lark-shared)

Examples

# Default: stream every event for the key (no filter, no projection)
lark-cli event consume im.message.receive_v1 --as bot

# Grab one sample event to inspect payload shape
lark-cli event consume im.message.receive_v1 --max-events 1 --timeout 30s --as bot

# Run for 10 minutes then auto-exit
lark-cli event consume im.message.receive_v1 --timeout 10m --as bot

# Consume multiple EventKeys concurrently (one shape per process, no dispatcher)
lark-cli event consume im.message.receive_v1          --as bot > receive.ndjson &
lark-cli event consume im.message.reaction.created_v1 --as bot > reaction.ndjson &
wait

Call flow

  1. lark-cli event list --json → pick a legal key
  2. lark-cli event schema <key> --json → read resolved_output_schema + jq_root_path to determine field paths
  3. lark-cli event consume <key> [--jq '<expr>'] → consume

Subprocess contract

Ready marker

event consume's stderr emits a fixed line [event] ready event_key=<key>. Parent processes should block on stderr until this line appears, then start reading stdout. Do not fall back to sleep.

stdin EOF = graceful exit

event consume treats stdin close as a shutdown signal (wired for AI subprocess callers). < /dev/null / nohup / systemd's default StandardInput=null will cause an immediate graceful exit (stderr reason: signal). To keep running:

  • Feed stdin a source that never EOFs: < <(tail -f /dev/null)
  • Or run bounded: --max-events N / --timeout D

Exit codes & reason

On exit, the last stderr line is [event] exited — received N event(s) in Xs (reason: ...).

exit codereasonTrigger
0reason: limit--max-events reached
0reason: timeout--timeout reached
0reason: signalCtrl+C / SIGTERM / stdin EOF
non-0Error: ... (no exited line)Startup / runtime failure (permissions, network, params, config)

Orchestrators should treat reason: limit/timeout/signal (all exit 0) as "business completion" and non-zero as "failure".

Never kill -9

Avoid kill -9 on consume processes: for EventKeys with a PreConsume hook (those that register server-side subscriptions via OAPI), kill -9 skips the OAPI unsubscribe and leaks server-side subscriptions (symptoms: "subscription already exists" on restart, duplicate event delivery). Prefer SIGTERM or closing stdin.

One consume, one EventKey (multi-key = multi-shell)

The command takes exactly one positional argument; k1,k2 and wildcards are unsupported. Listening to N keys means N subprocesses — this is intentional:

  • One shape per process stdout; no dispatcher logic required in the AI
  • Fault isolation (one key failing doesn't affect others)
  • Independent --as / --jq / --max-events / --timeout per key

All N consumers share a single bus daemon (UDS local IPC), so the overhead is small

Writing jq via schema

event schema <key> --json is the source of truth for writing --jq. Four things to look at:

(1) Where fields start — see jq_root_path

  • Value "." → fields are at the top level, write .chat_id
  • Value ".event" → fields are inside a V2 envelope, write .event.chat_id

(2) Field list and types — see resolved_output_schema.properties.<name>

Each field carries type / description, and some also have format. Snippet (from event schema im.message.receive_v1 --json):

{
  "chat_id":     {"type":"string", "format":"chat_id",      "description":"Chat ID, prefixed with oc_"},
  "sender_id":   {"type":"string", "format":"open_id",      "description":"Sender open_id, prefixed with ou_"},
  "create_time": {"type":"string", "format":"timestamp_ms", "description":"Send time as ms-epoch string"}
}

(3) Field semantics — see the format tag

Lark-defined semantic tags (not JSON Schema's standard format). Common values: open_id / chat_id / message_id / timestamp_ms / email. Purpose: distinguish "same string type, different meanings" fields so you can reverse-lookup via API or convert formats.

(4) Decoded state — read the field's description

event consume runs Process hooks that may pre-decode some payload fields (flattening V2 envelopes, rendering .content to plain text, etc.) — behavior differs from raw OAPI. Always read the field's description before writing jq, especially for generic field names like content / data / body / payload.

Why it matters: blindly applying fromjson to an already-decoded text field makes jq error on every event and silently drop it — the consumer looks alive but emits nothing, with only a single WARN line buried on stderr. (This is the general behavior: any jq runtime error skips the event with a one-line WARN; the loop does not abort.)

Don't shortcut the schema: when projecting event schema --json with jq, do not strip .description from properties — that's the field that tells you whether a field is already decoded. Dump the full property objects, not just keys.


Aside: --param's valid parameters also live in the schema — the params section lists name / type / required / enum / default / description; section missing = this key accepts no --param.

Topic index

TopicReferenceCoverage
IM[references/lark-event-im.md](references/lark-event-im.md)Catalog of 11 IM EventKeys + shape notes (flat vs V2 envelope) + im.message.receive_v1 field gotchas (sender_id is open_id only; .content is plain text except for interactive cards) + common jq recipes (filter by chat_type / message_type / sender)

质量与来源

所属仓库
pengfeiqiao/kunpeng
仓库星标
99
最近更新
2 天前
采集时间
今天
commit
bf8a8ac8c6d3
内容指纹
sha256:eb15efa01cc308a
文件路径
skills/lark-cli/lark-event/SKILL.md

同仓库其它 Skill

查看全部 49 个
anchor-frame-production
建立参考分工、锚定图变体、局部核验与版本记录,用于普通对话、画布和工坊的连续镜头创作。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
blender-clay-previz
用户提到白模/白膜/运镜预演/previs 时使用。调用本机 Blender 无界面渲染极简白模场景与运镜视频,用于验证构图遮挡、空间调度与动作时机,也可作为 AI 视频生成的全能参考。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
blender-modeling
在 Blender 中新建或修改可编辑模型、材质、灯光及场景工程。适用于产品建模、场景搭建、已有 blend 修改与渲染;纯白模运镜使用 blender-clay-previz。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
canvas-project-manager
画布能力由 canvas 工具契约提供,本文件仅保留操作顺序和数据安全约束。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
car-commercial-storyboard
汽车TVC、品牌片、汽车文案剧本、车辆资产与图片/视频提示词、分镜及Blender白模运镜。按人物叙事、生活观察、产品演示、造型光影等意图选择方法,维护车型身份与驾驶安全带连续性;不处理购车行情或维修问答。
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端
car-model-generation
专业的汽车3D模型图片生成技能,使用Gemini API生成高质量汽车展示图片,并通过豆包AI进行质量分析和优化。 使用场景:汽车品牌宣传片、车型展示、汽车广告素材生成。 关键词:汽车模型、车型图、汽车展示图、AI生图、Gemini
pengfeiqiao/kunpeng 99 原文
Codex CLIMCP 客户端

相似 Skill

更多「办公」
opencli-adapter-author
Use when writing an OpenCLI adapter for a new site or adding a new command to an existing site. Guides end-to-end from first recon through field decoding, adapter coding, and verify. Replaces opencli-oneshot / opencli-explorer. For ad-hoc browser driving (no adapter), see opencli-browser instead; for a top-level orientation to opencli, see opencli-usage.
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
opencli-autofix
Automatically fix broken OpenCLI adapters when commands fail. Load this skill when an opencli command fails — it guides you through collecting a trace artifact, patching the adapter, retrying, and filing an upstream GitHub issue after a verified fix. Works with any AI agent.
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
opencli-browser
Use when an agent needs to drive a real Chrome window via opencli — inspect a page, fill forms, click through logged-in flows, or extract data ad-hoc. Covers the selector-first target contract, compound form fields, stale-ref handling, network capture, and the agent-native envelopes the CLI returns. Not for writing adapters — see opencli-adapter-author for that.
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
opencli-usage
Use at the start of any OpenCLI session — this is the top-level map of what `opencli` can do, how to discover adapters, what flags and output formats are universal, and which specialized skill to load next. Point here when an agent asks "what can opencli do?" or "how do I find the right command?".
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
smart-search
基于 opencli 命令的智能搜索路由器。当用户想要使用 OpenCLI、CLI 或 API 搜索、查询、查找或研究信息时,尤其是涉及指定网站、社交媒体、技术资料、新闻、购物、旅游、求职、金融或中文内容时,务必使用此 skill
精选 jackwener/OpenCLI 3.0 万 原文
Gemini CLI
deeptutor-cli
终身个性化辅导系统:根据学习者情况持续调整教学方式。
精选 HKUDS/DeepTutor 4.1 万 仓库简介
Codex CLIMCP 客户端