/** * Lark / Feishu Docs skill — read / create / append Lark Docx documents. * * The document-world twin of googleDocs.js + notion.js, but for Lark/Feishu. * It runs on the DEDICATED Lark Docs app (integration `lark_docs`) — the app * carrying the docx (+ wiki/drive) scopes — and falls back to the chat app * (`lark`) so a single-app setup keeps working. Auth: * resolveLarkApp() (shared, larkApp.ts) → { appId, appSecret, host } → * tenant_access_token (cached ~2h) → Bearer on every Docx call. * * Design rules (mirrors notion.js / googleDocs.js): * - resolveLarkApp() is the SINGLE auth chokepoint (via the * larkDocsApi() helper). Don't re-resolve at call sites. It lives in * larkApp.ts because the docs app is also what other tenant-wide Lark * readers (lark-attendance) must use — one decider, not one per skill. * - handleToolCall() dispatches the tools and NEVER throws — any HTTP or * parse failure is returned as { ok:false, error } so a missing/broken * Lark connection can't crash the run. * - Region-aware host: whatever resolveLarkApp() returns as * `host` (open.feishu.cn vs open.larksuite.com) is used verbatim, so the * skill always matches the connected app's region. No baked host, no CLI, * no heavy deps — pure `fetch`. * * Docx v1 API (host-relative): * GET /open-apis/docx/v1/documents/{id} → { document:{title,...} } * GET /open-apis/docx/v1/documents/{id}/raw_content?lang=0 → { content } (plain text) * POST /open-apis/docx/v1/documents → { document:{document_id,title} } * POST /open-apis/docx/v1/documents/{id}/blocks/{block}/children * (block == document_id == the doc root) → append blocks at the end * GET /open-apis/wiki/v2/spaces/get_node?token={t} → { node:{obj_token,obj_type} } * * Wiki v2 API (write support — requires wiki:node:create / wiki:space:read): * GET /open-apis/wiki/v2/spaces?page_size=50[&page_token] → { items:[{space_id,name}], has_more, page_token } * POST /open-apis/wiki/v2/spaces/{space_id}/nodes → { node:{node_token,obj_token,obj_type} } * (obj_type='docx', node_type='origin', optional parent_node_token) */ /** * Every env name the SHARED app-credential resolution can read (→ envKeys). * Re-exported under its historical name; the list is DERIVED from larkApp.ts's * precedence order, never a second hand-kept copy. */ export declare const LARK_DOCS_APP_ENV_KEYS: readonly ("LARK_DOCS_APP_ID" | "LARK_DOCS_APP_SECRET" | "LARK_DOCS_HOST" | "LARK_APP_ID" | "LARK_APP_SECRET" | "LARK_HOST")[]; /** * Derive the human-facing doc web URL from the open-api host + document id. * The open-api host (open.feishu.cn / open.larksuite.com) is region-specific; * the web doc lives on the corresponding product domain. This is a best-effort * canonical URL — a tenant with a vanity subdomain may render its own host, but * the product-domain URL still resolves for the user. */ export declare function docWebUrl(host: any, id: any): string; /** * Derive the human-facing wiki node web URL (same region logic as docWebUrl). * A wiki-resident doc is best shared by its /wiki/ link — opening * it shows the doc in its wiki-space context. */ export declare function wikiWebUrl(host: any, nodeToken: any): string; /** * Parse a Lark/Feishu doc reference (raw token OR URL) into { type, token }. * - .../docx/ → { type:'docx', token } * - .../wiki/ → { type:'wiki', token } (resolved to its docx obj_token) * - bare token → { type:'docx', token } * Returns null when nothing usable can be extracted. Pure + side-effect-free. */ export declare function parseLarkDocRef(ref: any): { type: string; token: string; }; /** * Map a small, common subset of markdown into Lark Docx block objects. * Each block is a single line: headings (#/##/### → heading1/2/3), bullets * (- / *), ordered (1.), everything else a text paragraph. Inline marks are * kept as literal text (content is preserved; we don't emit Lark text-element * styles — honest + robust). Empty lines are skipped (Lark rejects empty text * blocks). Bounded by the caller's chunking to MAX_BLOCK_CHILDREN per request. */ export declare function markdownToLarkBlocks(markdown: any): any[]; export declare const larkDocsSkill: any; export declare function _resetLarkDocsTokenCache(): void;