@acedatacloud/skills 2026.702.0 → 2026.703.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -70,6 +70,7 @@ These skills drive third-party connectors users wire up at [auth.acedata.cloud/u
70
70
  | [slack](skills/slack/) | Read Slack channels, messages, and user info via Web API | `slack` |
71
71
  | [wechat-official-account](skills/wechat-official-account/) | Manage WeChat MP — drafts, publishing, materials, user tags | `wechat` (BYOC) |
72
72
  | [personal-wechat](skills/personal-wechat/) | Operate a personal WeChat account through a self-hosted Wisdom service | `personalwechat` (BYOC) |
73
+ | [wecom](skills/wecom/) | WeCom (企业微信) self-built app — contacts, app messages, WeDoc, schedules, meetings | `wecom` (BYOC) |
73
74
 
74
75
  ## Prerequisites
75
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acedatacloud/skills",
3
- "version": "2026.702.0",
3
+ "version": "2026.703.0",
4
4
  "description": "Agent Skills for AceDataCloud AI services — music, image, video generation, LLM chat, web search. Compatible with Claude Code, GitHub Copilot, Gemini CLI, OpenAI Codex, and 30+ AI coding agents.",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -0,0 +1,97 @@
1
+ # 企业微信 (WeCom) Authentication
2
+
3
+ The `wecom` skill talks to the [WeCom server-side API](https://developer.work.weixin.qq.com/document/path/90664)
4
+ (`https://qyapi.weixin.qq.com`) as a **self-built app (企业内部开发 / 自建应用)**.
5
+ Unlike OAuth-bearer connectors, WeCom uses a two-step token flow that is
6
+ identical in shape to the WeChat Official Account API:
7
+
8
+ 1. Exchange `CorpID + Secret` for an `access_token` (TTL 7200s).
9
+ 2. Pass that `access_token` as a **query string parameter** on every other call.
10
+
11
+ ## Create a self-built app & collect three values
12
+
13
+ 1. Sign in to the [WeCom admin console](https://work.weixin.qq.com/wework_admin/) as an
14
+ administrator → **应用管理 (App Management) → 自建 (Self-built) → 创建应用 (Create App)**.
15
+ 2. After the app is created, open it and read off:
16
+ - **CorpID** — 我的企业 (My Company) → 企业信息 (Company Info), at the bottom (`ww...` / `wc...`).
17
+ - **Secret** — the app's own Secret, shown on the app detail page (click "查看"/"获取"; it is
18
+ sent to the admin's WeCom, not displayed inline).
19
+ - **AgentId** — the app's AgentId, shown on the same app detail page.
20
+
21
+ ## Grant the app the permissions the skill needs
22
+
23
+ An app only sees what you grant it. On the app detail page configure:
24
+
25
+ | Capability the skill uses | What to enable on the app |
26
+ |---|---|
27
+ | Read members / departments (通讯录) | **通讯录 (Contacts)** → set the app's "可见范围" (visible scope) to the members/departments it may act on; to read real names/mobiles, grant **通讯录同步/读取** privilege |
28
+ | Send app messages (应用消息) | enabled by default for a self-built app (uses its AgentId) |
29
+ | Docs / smart sheets (文档/智能表格) | **文档 (WeDoc)** interface permission |
30
+ | Schedules (日程) | **日历/日程 (Calendar)** interface permission |
31
+ | Meetings (会议) | **会议 (Meeting)** interface permission |
32
+
33
+ > ⚠️ **Server IP allowlist.** WeCom rejects calls whose source IP is not in the app's
34
+ > **企业可信IP (trusted IP)** list. If you see `errcode 60020` ("not allow to access from your ip"),
35
+ > add the caller's egress IP shown in `errmsg` to the app's trusted-IP list and retry.
36
+
37
+ ## Environment variables
38
+
39
+ The skill reads three variables. On AceDataCloud they are injected automatically for you
40
+ (see below); for local runs, export them yourself.
41
+
42
+ | Variable | Description | Example |
43
+ |---|---|---|
44
+ | `WECOM_CORP_ID` | Enterprise CorpID | `ww1234567890abcdef` |
45
+ | `WECOM_CORP_SECRET` | The self-built app's Secret (sensitive) | `xxxxxxxxxxxxxxxxxxxx` |
46
+ | `WECOM_AGENT_ID` | The self-built app's AgentId | `1000002` |
47
+
48
+ **Local dev — `.env` file**:
49
+
50
+ ```bash
51
+ WECOM_CORP_ID=ww1234567890abcdef
52
+ WECOM_CORP_SECRET=your-app-secret
53
+ WECOM_AGENT_ID=1000002
54
+ ```
55
+
56
+ Load it before running the skill:
57
+
58
+ ```bash
59
+ set -a; source .env; set +a
60
+ ```
61
+
62
+ > ⚠️ **Never commit `.env`** — the Secret is equivalent to full app access. Add it to `.gitignore`.
63
+
64
+ **Agent usage** (Claude / Studio / etc.): install the
65
+ [企业微信 connector](https://auth.acedata.cloud/user/connections) on AceDataCloud once. Your
66
+ CorpID / Secret / AgentId are AES-256-GCM encrypted at rest and injected as the env vars above
67
+ only inside the sandbox while the skill runs — no manual `.env` setup needed. Revoke anytime from
68
+ the connections page.
69
+
70
+ ## Response shape & error handling
71
+
72
+ Every WeCom response is JSON returned with **HTTP 200**; success is `errcode == 0`:
73
+
74
+ ```json
75
+ {"errcode": 0, "errmsg": "ok", "...": "..."}
76
+ ```
77
+
78
+ Any non-zero `errcode` is an error — surface `errmsg` to the user verbatim. Common codes:
79
+
80
+ | errcode | meaning | what to do |
81
+ |---|---|---|
82
+ | `40014` / `42001` | invalid / expired `access_token` | refresh the token (the recipe caches it — delete the cache and retry) |
83
+ | `40056` | invalid AgentId | check `WECOM_AGENT_ID` matches the app whose Secret you used |
84
+ | `48002` | API forbidden — app lacks this interface permission | grant the matching capability (docs/calendar/meeting) to the app |
85
+ | `60011` | no privilege to access this user/department/resource | the target is outside the app's visible scope — widen 可见范围 |
86
+ | `60020` | caller IP not in trusted-IP list | add the egress IP from `errmsg` to 企业可信IP |
87
+ | `301002` | no privilege to read contacts detail | grant 通讯录读取 privilege to the app |
88
+ | `81013` | user not in app scope | add the user to the app's 可见范围 |
89
+
90
+ ## What is intentionally out of scope
91
+
92
+ - **Reading inbound chat history (会话内容存档 / msgaudit).** That is a separate paid
93
+ enterprise capability requiring a dedicated Secret, an RSA private key, and the native
94
+ WeCom Finance SDK — it cannot run inside this stdlib sandbox. The skill can *send* app
95
+ messages but cannot *read* members' private conversations.
96
+ - **A general todo (待办) CRUD.** WeCom's open API exposes no self-built-app todo endpoints;
97
+ use **schedules (日程)** for time-bound reminders instead.
@@ -0,0 +1,287 @@
1
+ ---
2
+ name: wecom
3
+ description: Read your WeCom (企业微信 / WeCom / Work Weixin) contacts, send app & group messages, create and read WeDoc docs/smart sheets, and manage schedules (日程) and meetings (会议) via the WeCom server-side API as a self-built app. Use when the user mentions 企业微信, WeCom, 通讯录成员/部门, 应用消息, 群机器人/应用群聊, 企业微信文档/智能表格, 企业微信日程 or 会议, or a qyapi.weixin.qq.com call.
4
+ when_to_use: |
5
+ Trigger when the user wants to operate their WeCom (企业微信) via a
6
+ self-built app: list departments / members, look up a member's userid,
7
+ send an app message or push to an app group chat, create or read a
8
+ WeDoc document / smart sheet, or create / list / cancel a schedule
9
+ (日程) or meeting (会议).
10
+ connections: [wecom]
11
+ allowed_tools: [Bash]
12
+ license: Apache-2.0
13
+ metadata:
14
+ author: acedatacloud
15
+ version: "1.0"
16
+ ---
17
+
18
+ We drive the [WeCom server-side API](https://developer.work.weixin.qq.com/document/path/90664)
19
+ (`https://qyapi.weixin.qq.com`) with `curl + jq` as a **self-built app (自建应用)**.
20
+
21
+ > **Setup:** see [WeCom authentication](../_shared/wecom.md) for how to create the self-built app,
22
+ > collect **CorpID / Secret / AgentId**, and grant it the contacts / docs / calendar / meeting
23
+ > permissions. The skill reads `WECOM_CORP_ID`, `WECOM_CORP_SECRET` and `WECOM_AGENT_ID` from the
24
+ > environment; on AceDataCloud they are injected automatically by the 企业微信 connector.
25
+
26
+ WeCom uses a two-step token flow (identical in shape to the WeChat MP API):
27
+
28
+ 1. Exchange `CorpID + Secret` for an `access_token` (TTL 7200s).
29
+ 2. Pass that `access_token` as a **query string parameter** on every other call.
30
+
31
+ **Never log or echo `$WECOM_CORP_SECRET`** — treat it like a password.
32
+
33
+ Responses are JSON returned with **HTTP 200**; `errcode == 0` means success. On any non-zero
34
+ `errcode`, show the original `errmsg` to the user verbatim (see the error table in
35
+ [the setup doc](../_shared/wecom.md#response-shape--error-handling)).
36
+
37
+ ## Recipes
38
+
39
+ ### Step 0 — get an access_token (do this first, cache the result)
40
+
41
+ Every recipe below assumes `$AT` holds a valid token from this step.
42
+
43
+ ```sh
44
+ # Fail loudly if credentials are missing/blank. WECOM_AGENT_ID must be a plain
45
+ # integer because message/meeting recipes pass it to jq via --argjson (numeric JSON).
46
+ : "${WECOM_CORP_ID:?WECOM_CORP_ID not set}" "${WECOM_CORP_SECRET:?WECOM_CORP_SECRET not set}"
47
+ case "${WECOM_AGENT_ID:?WECOM_AGENT_ID not set}" in *[!0-9]*|"") echo "WECOM_AGENT_ID must be an integer" >&2; exit 1;; esac
48
+
49
+ # Cache to $TMPDIR so subsequent calls in the same session reuse it (WeCom
50
+ # rate-limits gettoken). Refresh 5 minutes early to avoid edge-of-window failures.
51
+ TOKEN_CACHE="${TMPDIR:-/tmp}/wecom-token-${WECOM_CORP_ID}-${WECOM_AGENT_ID}.json"
52
+ NOW=$(date +%s)
53
+ if [ -f "$TOKEN_CACHE" ] && [ "$(jq -r '.exp_at // 0' "$TOKEN_CACHE")" -gt "$((NOW + 300))" ]; then
54
+ AT=$(jq -r '.access_token' "$TOKEN_CACHE")
55
+ else
56
+ RESP=$(curl -sS "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=${WECOM_CORP_ID}&corpsecret=${WECOM_CORP_SECRET}")
57
+ AT=$(echo "$RESP" | jq -r 'if .errcode == 0 then .access_token else empty end')
58
+ if [ -z "$AT" ]; then
59
+ echo "Failed to fetch access_token: $RESP" >&2
60
+ exit 1
61
+ fi
62
+ EXPIRES=$(echo "$RESP" | jq -r '.expires_in // 7200')
63
+ echo "$RESP" | jq --argjson now "$NOW" --argjson ttl "$EXPIRES" \
64
+ '{access_token, exp_at: ($now + $ttl)}' > "$TOKEN_CACHE"
65
+ chmod 600 "$TOKEN_CACHE"
66
+ fi
67
+ ```
68
+
69
+ A tiny helper keeps the recipes short — GET with the token appended, erroring on non-zero `errcode`:
70
+
71
+ ```sh
72
+ wc_get() { curl -sS "https://qyapi.weixin.qq.com/cgi-bin/$1&access_token=${AT}" \
73
+ | jq 'if .errcode == 0 then . else error("WeCom \(.errcode): \(.errmsg)") end'; }
74
+ wc_post() { curl -sS -X POST "https://qyapi.weixin.qq.com/cgi-bin/$1?access_token=${AT}" \
75
+ -H 'Content-Type: application/json' -d "$2" \
76
+ | jq 'if .errcode == 0 then . else error("WeCom \(.errcode): \(.errmsg)") end'; }
77
+ ```
78
+
79
+ ### 通讯录 Contacts (read)
80
+
81
+ > Reading real names / mobiles requires the app to have **通讯录读取** privilege; otherwise names
82
+ > come back masked. Members outside the app's 可见范围 return `errcode 60011` / `81013`.
83
+
84
+ List the department tree (root department id is `1`):
85
+
86
+ ```sh
87
+ wc_get "department/list?id=1" | jq '[.department[] | {id, name, parentid}]'
88
+ ```
89
+
90
+ **Preferred enumeration — `user/list_id` (cursor).** This is the robust way to list members:
91
+ it works for a self-built app with only its own Secret. `user/simplelist` / `user/list` still
92
+ work *within the app's 可见范围*, but WeCom has been tightening those (the 2022‑08‑15 change blocks
93
+ newly‑added 通讯录同步 IPs from calling them), so lead with `user/list_id` and fall back to
94
+ `simplelist` only if you need names in one shot.
95
+
96
+ ```sh
97
+ wc_post "user/list_id" '{"cursor":"","limit":10000}' \
98
+ | jq '{next_cursor, userids: [.dept_user[] | .userid] | unique}'
99
+ ```
100
+
101
+ Get one member's full profile — this is how you resolve a **name → userid** for messaging:
102
+
103
+ ```sh
104
+ wc_get "user/get?userid=USERID" \
105
+ | jq '{userid, name, department, position, mobile, email, status}'
106
+ ```
107
+
108
+ List members of a department in one call (convenience; needs 通讯录 view on that department —
109
+ if it returns `60011`, use `user/list_id` + `user/get` above instead):
110
+
111
+ ```sh
112
+ wc_get "user/simplelist?department_id=1&fetch_child=1" \
113
+ | jq '[.userlist[] | {userid, name, department}]'
114
+ ```
115
+
116
+ Search by name — robust path (enumerate ids, then read each profile and filter):
117
+
118
+ ```sh
119
+ for uid in $(wc_post "user/list_id" '{"cursor":"","limit":10000}' | jq -r '.dept_user[].userid' | sort -u); do
120
+ wc_get "user/get?userid=${uid}" | jq -c '{userid, name}'
121
+ done | jq -s --arg q "张三" '[.[] | select(.name | contains($q))]'
122
+ ```
123
+
124
+ > Shortcut when `simplelist` is available to the app: `wc_get "user/simplelist?department_id=1&fetch_child=1" | jq --arg q "张三" '[.userlist[] | select(.name | contains($q)) | {userid, name}]'`.
125
+
126
+ ### 应用消息 App messages (send) — GATED
127
+
128
+ `message/send` pushes a notification from your app to members. `agentid` is required and comes from
129
+ `$WECOM_AGENT_ID`. `touser` is a `|`-joined list of **userid**s (use `@all` for everyone in scope);
130
+ `toparty` / `totag` target departments / tags.
131
+
132
+ > Sending fans out to real people. **Always show the exact recipients + content and get explicit
133
+ > user confirmation before running `message/send` / `appchat/send`**, even if the instruction says
134
+ > "just send it".
135
+
136
+ Send a text message to one or more members:
137
+
138
+ ```sh
139
+ wc_post "message/send" "$(jq -nc --arg to "USERID1|USERID2" --argjson agent "${WECOM_AGENT_ID}" \
140
+ --arg content "构建已通过,请查看。" \
141
+ '{touser:$to, msgtype:"text", agentid:$agent, text:{content:$content}, safe:0}')" \
142
+ | jq '{msgid, invaliduser}'
143
+ ```
144
+
145
+ Send a Markdown card (richer formatting, members only):
146
+
147
+ ```sh
148
+ wc_post "message/send" "$(jq -nc --arg to "@all" --argjson agent "${WECOM_AGENT_ID}" \
149
+ --arg md "**发布通知**\n>版本:v1.2.0\n>状态:<font color=\"info\">成功</font>" \
150
+ '{touser:$to, msgtype:"markdown", agentid:$agent, markdown:{content:$md}}')" \
151
+ | jq '{msgid}'
152
+ ```
153
+
154
+ Send a clickable text-card:
155
+
156
+ ```sh
157
+ wc_post "message/send" "$(jq -nc --arg to "USERID1" --argjson agent "${WECOM_AGENT_ID}" \
158
+ '{touser:$to, msgtype:"textcard", agentid:$agent,
159
+ textcard:{title:"周报已生成", description:"点击查看本周汇总", url:"https://example.com/report", btntxt:"详情"}}')" \
160
+ | jq '{msgid}'
161
+ ```
162
+
163
+ ### 应用群聊 App group chat
164
+
165
+ Create a group the app owns, then push messages into it. `chatid` is a custom id you choose (reuse it later).
166
+
167
+ ```sh
168
+ # Create (owner + members are userids). Omit chatid to let WeCom assign one.
169
+ wc_post "appchat/create" '{"name":"项目组","owner":"USERID1","userlist":["USERID1","USERID2","USERID3"],"chatid":"proj_alpha"}' \
170
+ | jq '{chatid}'
171
+
172
+ # Send into it (same GATED confirmation rule as app messages).
173
+ wc_post "appchat/send" '{"chatid":"proj_alpha","msgtype":"text","text":{"content":"今晚 8 点线上同步。"}}' \
174
+ | jq '{errcode, errmsg}'
175
+
176
+ # Inspect a group the app created.
177
+ wc_get "appchat/get?chatid=proj_alpha" | jq '.chat_info | {name, owner, userlist}'
178
+ ```
179
+
180
+ ### 企业微信文档 WeDoc (docs & smart sheets)
181
+
182
+ Requires the app's **文档 (WeDoc)** permission. `doc_type`: `3` = 文档 (document), `4` = 表格 (spreadsheet),
183
+ `10` = 智能表格 (smart sheet).
184
+
185
+ Create a document and get its edit URL:
186
+
187
+ ```sh
188
+ wc_post "wedoc/create_doc" "$(jq -nc --arg name "项目周报 2026-07" \
189
+ '{doc_type:3, doc_name:$name}')" \
190
+ | jq '{docid, url}'
191
+ ```
192
+
193
+ Get a shareable link for an existing doc:
194
+
195
+ ```sh
196
+ wc_post "wedoc/doc_share" '{"docid":"DOCID"}' | jq '{share_url: .share_url}'
197
+ ```
198
+
199
+ Read a document's structured content. WeCom returns a `document` object (keyed by `document_id`,
200
+ not `doc_id`) whose body is a tree of typed blocks, **not** Markdown — inspect the real shape before
201
+ relying on inner field names:
202
+
203
+ ```sh
204
+ wc_post "wedoc/document/get" '{"docid":"DOCID"}' \
205
+ | jq '{document_id: .document.document_id, top_level_keys: (.document | keys)}'
206
+ ```
207
+
208
+ > Smart-sheet (智能表格) sub-tables, fields and records use the `wedoc/smartsheet/*` endpoints
209
+ > (`get_sheet`, `get_fields`, `get_records`, `add_records`, …) — same `wc_post` pattern, keyed by
210
+ > `docid` + `sheet_id`. Reach for them when the user asks to read/write rows of a 智能表格.
211
+
212
+ ### 日程 Schedule (日程)
213
+
214
+ Requires the app's **日历/日程** permission. Times are **epoch seconds**; convert with GNU `date`:
215
+
216
+ ```sh
217
+ START=$(date -d "2026-07-10 15:00" +%s); END=$(date -d "2026-07-10 16:00" +%s)
218
+ ```
219
+
220
+ Create a schedule (organizer + attendees are userids):
221
+
222
+ ```sh
223
+ wc_post "oa/schedule/add" "$(jq -nc --arg org "USERID1" --argjson s "$START" --argjson e "$END" \
224
+ '{schedule:{organizer:$org, start_time:$s, end_time:$e, summary:"项目评审",
225
+ description:"评审 v1.2 需求", location:"会议室 A",
226
+ attendees:[{userid:"USERID2"},{userid:"USERID3"}],
227
+ reminders:{is_remind:1, remind_before_event_secs:900}}}')" \
228
+ | jq '{schedule_id}'
229
+ ```
230
+
231
+ Read schedules by id, and cancel one:
232
+
233
+ ```sh
234
+ wc_post "oa/schedule/get" '{"schedule_id_list":["SCHEDULE_ID"]}' \
235
+ | jq '[.schedule_list[] | {schedule_id, summary, start_time, end_time, organizer}]'
236
+
237
+ wc_post "oa/schedule/del" '{"schedule_id":"SCHEDULE_ID"}' | jq '{errcode, errmsg}'
238
+ ```
239
+
240
+ > To *list* a member's upcoming schedules you need their calendar id (`cal_id`) and
241
+ > `oa/schedule/get_by_calendar` — create/query calendars via the `oa/calendar/*` endpoints first.
242
+
243
+ ### 会议 Meeting (会议)
244
+
245
+ Requires the app's **会议** permission. `meeting_start` is epoch seconds, `meeting_duration` is seconds.
246
+
247
+ Create a scheduled meeting:
248
+
249
+ ```sh
250
+ wc_post "meeting/create" "$(jq -nc --arg admin "USERID1" --argjson start "$(date -d '2026-07-11 10:00' +%s)" \
251
+ '{admin_userid:$admin, title:"周例会", meeting_start:$start, meeting_duration:3600,
252
+ description:"同步本周进展", invitees:{userid:["USERID2","USERID3"]}}')" \
253
+ | jq '{meetingid}'
254
+ ```
255
+
256
+ List a member's meetings, read details, and cancel (`get_user_meetingid` is a **POST** with a
257
+ cursor body, mirroring WeCom's other `get_user_*_id` list endpoints):
258
+
259
+ ```sh
260
+ wc_post "meeting/get_user_meetingid" '{"userid":"USERID1","cursor":"","limit":100}' \
261
+ | jq '{meetingid_list, next_cursor}'
262
+
263
+ wc_post "meeting/get_info" '{"meetingid":"MEETINGID"}' \
264
+ | jq '.meeting_info | {title, meeting_start, meeting_duration, state}'
265
+
266
+ wc_post "meeting/cancel" '{"meetingid":"MEETINGID"}' | jq '{errcode, errmsg}'
267
+ ```
268
+
269
+ ## Safety rules
270
+
271
+ - **Never print `$WECOM_CORP_SECRET`.** It is equivalent to full app access.
272
+ - **Confirm before anything outward-facing** — `message/send`, `appchat/send`, `oa/schedule/add`
273
+ and `meeting/create` all notify real colleagues. Show the exact recipients / attendees and the
274
+ content, get explicit approval, *then* run the call. Never infer consent from vague wording.
275
+ - Messaging / schedules / meetings act on **userids**, not display names — resolve a name to a
276
+ userid with the contact recipes first, and confirm the person if the name is ambiguous.
277
+ - On `errcode 48002` (API forbidden) or `60011` / `301002` (no privilege), the app is missing a
278
+ permission or the target is outside its 可见范围 — tell the user which capability to grant rather
279
+ than retrying blindly.
280
+
281
+ ## Not supported here
282
+
283
+ - **Reading inbound chat history** (会话内容存档 / msgaudit) — a separate paid capability needing a
284
+ dedicated Secret, an RSA key and the native WeCom Finance SDK; it can't run in this sandbox. The
285
+ skill *sends* messages but can't *read* members' private conversations.
286
+ - **A generic todo (待办) CRUD** — WeCom's open API exposes none for self-built apps; use
287
+ **schedules (日程)** for time-bound reminders instead.