@zibby/skills 0.1.68 → 0.1.70
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/dist/index.d.ts +4 -1
- package/dist/index.js +148 -136
- package/dist/larkDocs.d.ts +212 -0
- package/dist/larkDocs.js +11 -0
- package/dist/notion.d.ts +50 -0
- package/dist/notion.js +8 -6
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive the human-facing doc web URL from the open-api host + document id.
|
|
3
|
+
* The open-api host (open.feishu.cn / open.larksuite.com) is region-specific;
|
|
4
|
+
* the web doc lives on the corresponding product domain. This is a best-effort
|
|
5
|
+
* canonical URL — a tenant with a vanity subdomain may render its own host, but
|
|
6
|
+
* the product-domain URL still resolves for the user.
|
|
7
|
+
*/
|
|
8
|
+
export function docWebUrl(host: any, id: any): string;
|
|
9
|
+
/**
|
|
10
|
+
* Parse a Lark/Feishu doc reference (raw token OR URL) into { type, token }.
|
|
11
|
+
* - .../docx/<token> → { type:'docx', token }
|
|
12
|
+
* - .../wiki/<token> → { type:'wiki', token } (resolved to its docx obj_token)
|
|
13
|
+
* - bare token → { type:'docx', token }
|
|
14
|
+
* Returns null when nothing usable can be extracted. Pure + side-effect-free.
|
|
15
|
+
*/
|
|
16
|
+
export function parseLarkDocRef(ref: any): {
|
|
17
|
+
type: string;
|
|
18
|
+
token: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Map a small, common subset of markdown into Lark Docx block objects.
|
|
22
|
+
* Each block is a single line: headings (#/##/### → heading1/2/3), bullets
|
|
23
|
+
* (- / *), ordered (1.), everything else a text paragraph. Inline marks are
|
|
24
|
+
* kept as literal text (content is preserved; we don't emit Lark text-element
|
|
25
|
+
* styles — honest + robust). Empty lines are skipped (Lark rejects empty text
|
|
26
|
+
* blocks). Bounded by the caller's chunking to MAX_BLOCK_CHILDREN per request.
|
|
27
|
+
*/
|
|
28
|
+
export function markdownToLarkBlocks(markdown: any): {
|
|
29
|
+
[x: string]: number | {
|
|
30
|
+
elements: {
|
|
31
|
+
text_run: {
|
|
32
|
+
content: string;
|
|
33
|
+
};
|
|
34
|
+
}[];
|
|
35
|
+
style: {};
|
|
36
|
+
};
|
|
37
|
+
block_type: number;
|
|
38
|
+
}[];
|
|
39
|
+
export function _resetLarkDocsTokenCache(): void;
|
|
40
|
+
export namespace larkDocsSkill {
|
|
41
|
+
let id: string;
|
|
42
|
+
let serverName: string;
|
|
43
|
+
let allowedTools: string[];
|
|
44
|
+
let requiresIntegration: "lark";
|
|
45
|
+
let description: string;
|
|
46
|
+
let envKeys: any[];
|
|
47
|
+
let promptFragment: string;
|
|
48
|
+
/**
|
|
49
|
+
* Spawn the GENERIC skill MCP server (bin/mcp-skill.mjs) pointing at this
|
|
50
|
+
* module's larkDocsSkill export, so the AGENT gets real mcp__larkdocs__*
|
|
51
|
+
* tools. Auth flows through the INHERITED env (PROJECT_API_TOKEN →
|
|
52
|
+
* resolveIntegrationToken('lark')), so no provider-specific env keys are
|
|
53
|
+
* needed here. When unconnected, handleToolCall returns { ok:false, error }.
|
|
54
|
+
*/
|
|
55
|
+
function resolve(): {
|
|
56
|
+
type: string;
|
|
57
|
+
command: string;
|
|
58
|
+
args: any[];
|
|
59
|
+
env: {};
|
|
60
|
+
description: string;
|
|
61
|
+
alwaysLoad: boolean;
|
|
62
|
+
};
|
|
63
|
+
function handleToolCall(name: any, args: any): Promise<string>;
|
|
64
|
+
let tools: ({
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
input_schema: {
|
|
68
|
+
type: string;
|
|
69
|
+
properties: {
|
|
70
|
+
documentId: {
|
|
71
|
+
type: string;
|
|
72
|
+
description: string;
|
|
73
|
+
};
|
|
74
|
+
title?: undefined;
|
|
75
|
+
markdown?: undefined;
|
|
76
|
+
text?: undefined;
|
|
77
|
+
folderToken?: undefined;
|
|
78
|
+
fileType?: undefined;
|
|
79
|
+
commentId?: undefined;
|
|
80
|
+
};
|
|
81
|
+
required: string[];
|
|
82
|
+
};
|
|
83
|
+
} | {
|
|
84
|
+
name: string;
|
|
85
|
+
description: string;
|
|
86
|
+
input_schema: {
|
|
87
|
+
type: string;
|
|
88
|
+
properties: {
|
|
89
|
+
title: {
|
|
90
|
+
type: string;
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
markdown: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
text: {
|
|
98
|
+
type: string;
|
|
99
|
+
description: string;
|
|
100
|
+
};
|
|
101
|
+
folderToken: {
|
|
102
|
+
type: string;
|
|
103
|
+
description: string;
|
|
104
|
+
};
|
|
105
|
+
documentId?: undefined;
|
|
106
|
+
fileType?: undefined;
|
|
107
|
+
commentId?: undefined;
|
|
108
|
+
};
|
|
109
|
+
required: string[];
|
|
110
|
+
};
|
|
111
|
+
} | {
|
|
112
|
+
name: string;
|
|
113
|
+
description: string;
|
|
114
|
+
input_schema: {
|
|
115
|
+
type: string;
|
|
116
|
+
properties: {
|
|
117
|
+
documentId: {
|
|
118
|
+
type: string;
|
|
119
|
+
description: string;
|
|
120
|
+
};
|
|
121
|
+
markdown: {
|
|
122
|
+
type: string;
|
|
123
|
+
description: string;
|
|
124
|
+
};
|
|
125
|
+
text: {
|
|
126
|
+
type: string;
|
|
127
|
+
description: string;
|
|
128
|
+
};
|
|
129
|
+
title?: undefined;
|
|
130
|
+
folderToken?: undefined;
|
|
131
|
+
fileType?: undefined;
|
|
132
|
+
commentId?: undefined;
|
|
133
|
+
};
|
|
134
|
+
required: string[];
|
|
135
|
+
};
|
|
136
|
+
} | {
|
|
137
|
+
name: string;
|
|
138
|
+
description: string;
|
|
139
|
+
input_schema: {
|
|
140
|
+
type: string;
|
|
141
|
+
properties: {
|
|
142
|
+
documentId: {
|
|
143
|
+
type: string;
|
|
144
|
+
description: string;
|
|
145
|
+
};
|
|
146
|
+
fileType: {
|
|
147
|
+
type: string;
|
|
148
|
+
description: string;
|
|
149
|
+
};
|
|
150
|
+
title?: undefined;
|
|
151
|
+
markdown?: undefined;
|
|
152
|
+
text?: undefined;
|
|
153
|
+
folderToken?: undefined;
|
|
154
|
+
commentId?: undefined;
|
|
155
|
+
};
|
|
156
|
+
required: string[];
|
|
157
|
+
};
|
|
158
|
+
} | {
|
|
159
|
+
name: string;
|
|
160
|
+
description: string;
|
|
161
|
+
input_schema: {
|
|
162
|
+
type: string;
|
|
163
|
+
properties: {
|
|
164
|
+
documentId: {
|
|
165
|
+
type: string;
|
|
166
|
+
description: string;
|
|
167
|
+
};
|
|
168
|
+
text: {
|
|
169
|
+
type: string;
|
|
170
|
+
description: string;
|
|
171
|
+
};
|
|
172
|
+
fileType: {
|
|
173
|
+
type: string;
|
|
174
|
+
description: string;
|
|
175
|
+
};
|
|
176
|
+
title?: undefined;
|
|
177
|
+
markdown?: undefined;
|
|
178
|
+
folderToken?: undefined;
|
|
179
|
+
commentId?: undefined;
|
|
180
|
+
};
|
|
181
|
+
required: string[];
|
|
182
|
+
};
|
|
183
|
+
} | {
|
|
184
|
+
name: string;
|
|
185
|
+
description: string;
|
|
186
|
+
input_schema: {
|
|
187
|
+
type: string;
|
|
188
|
+
properties: {
|
|
189
|
+
documentId: {
|
|
190
|
+
type: string;
|
|
191
|
+
description: string;
|
|
192
|
+
};
|
|
193
|
+
commentId: {
|
|
194
|
+
type: string;
|
|
195
|
+
description: string;
|
|
196
|
+
};
|
|
197
|
+
text: {
|
|
198
|
+
type: string;
|
|
199
|
+
description: string;
|
|
200
|
+
};
|
|
201
|
+
fileType: {
|
|
202
|
+
type: string;
|
|
203
|
+
description: string;
|
|
204
|
+
};
|
|
205
|
+
title?: undefined;
|
|
206
|
+
markdown?: undefined;
|
|
207
|
+
folderToken?: undefined;
|
|
208
|
+
};
|
|
209
|
+
required: string[];
|
|
210
|
+
};
|
|
211
|
+
})[];
|
|
212
|
+
}
|
package/dist/larkDocs.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{existsSync as b}from"fs";import{fileURLToPath as S}from"url";import{dirname as v,resolve as R}from"path";import{resolveIntegrationToken as A}from"@zibby/core/backend-client.js";var g=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),C=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},google:{id:"google",name:"Google Docs",connectPath:"/integrations?provider=google"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin_personal:{id:"linkedin_personal",name:"LinkedIn (Personal)",connectPath:"/integrations?provider=linkedin_personal"},linkedin_business:{id:"linkedin_business",name:"LinkedIn (Business)",connectPath:"/integrations?provider=linkedin_business"},discord:{id:"discord",name:"Discord",connectPath:"/integrations?provider=discord"}});function N(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let t=v(S(import.meta.url)),e=R(t,"..","bin","mcp-skill.mjs");return b(e)?e:null}var I=2e4,x=50,O=6e3*1e3,u=null;async function E(){let{appId:t,appSecret:e,host:n}=await A("lark");if(u&&u.appId===t&&u.expiresAt>Date.now())return{token:u.token,host:n};let o=await(await fetch(`${n}/open-apis/auth/v3/tenant_access_token/internal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({app_id:t,app_secret:e})})).json();if(o.code!==0)throw new Error(`Lark tenant_access_token failed: ${o.msg||o.code}`);return u={token:o.tenant_access_token,expiresAt:Date.now()+O,appId:t},{token:o.tenant_access_token,host:n}}async function l(t,e,n){let{token:r,host:o}=await E(),i={method:t,headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json; charset=utf-8"}};t!=="GET"&&n!==void 0&&(i.body=JSON.stringify(n));let c=await(await fetch(`${o}${e}`,i)).json();if(c.code!==0)throw new Error(`Lark Docx API ${e} error: ${c.msg||c.code}`);return{data:c.data||{},host:o}}function h(t,e){return String(t||"").includes("feishu")?`https://feishu.cn/docx/${e}`:`https://www.larksuite.com/docx/${e}`}function m(t){if(!t||typeof t!="string")return null;let e=t.trim();if(!e)return null;let n=e.match(/\/(docx|wiki)\/([A-Za-z0-9]+)/);return n?{type:n[1],token:n[2]}:/^[A-Za-z0-9]{10,}$/.test(e)?{type:"docx",token:e}:null}async function k(t){let e=typeof t=="string"?m(t):t;if(!e)throw new Error("A valid Lark doc id or URL is required");if(e.type==="docx")return e.token;let{data:n}=await l("GET",`/open-apis/wiki/v2/spaces/get_node?token=${encodeURIComponent(e.token)}`),r=n?.node||{};if(r.obj_type!=="docx"||!r.obj_token)throw new Error(`Wiki node is not a docx document (obj_type=${r.obj_type||"unknown"})`);return r.obj_token}function L(t){let e=String(t??"").replace(/\r\n/g,`
|
|
2
|
+
`),n=[];for(let r of e.split(`
|
|
3
|
+
`)){let o=r.replace(/\s+$/,"");if(!o.trim())continue;let i=/^(#{1,3})\s+(.*)$/.exec(o),s=/^\s*[-*]\s+(.*)$/.exec(o),c=/^\s*\d+[.)]\s+(.*)$/.exec(o),a,d,p;if(i){let _=i[1].length;a=`heading${_}`,d=2+_,p=i[2]}else s?(a="bullet",d=12,p=s[1]):c?(a="ordered",d=13,p=c[1]):(a="text",d=2,p=o);n.push({block_type:d,[a]:{elements:[{text_run:{content:p}}],style:{}}})}return n}function f(t){let e=typeof t?.markdown=="string"?t.markdown:null,n=typeof t?.text=="string"?t.text:null;return e??n}async function w(t,e){let n;for(let r=0;r<e.length;r+=x){let o=e.slice(r,r+x);n=(await l("POST",`/open-apis/docx/v1/documents/${t}/blocks/${t}/children?document_revision_id=-1`,{children:o})).host}return n}var P="docx",U=50;function T(t){return[{type:"text_run",text_run:{text:String(t??"")}}]}function D(t){return Array.isArray(t)?t.map(e=>e?.text_run?.text??e?.docs_link?.url??(e?.person?`@${e.person.user_id||""}`:"")).join(""):""}function $(t){let e=Array.isArray(t?.reply_list?.replies)?t.reply_list.replies:[];return{commentId:t?.comment_id||"",resolved:!!t?.is_solved,replies:e.map(n=>({replyId:n?.reply_id||"",author:n?.user_id||"",text:D(n?.content?.elements),createTime:n?.create_time||""}))}}function y(t){return typeof t?.fileType=="string"&&t.fileType.trim()?t.fileType.trim():P}var M={id:"lark-docs",serverName:"larkdocs",allowedTools:["mcp__larkdocs__*"],requiresIntegration:g.LARK,description:"Lark / Feishu Docs \u2014 read, create, and append Lark documents (docx).",envKeys:[],promptFragment:`## Lark Docs (connected)
|
|
4
|
+
You can read, create, and append Lark/Feishu documents (docx). This reuses the same connected Lark app as messaging.
|
|
5
|
+
- larkdoc_get: pass a Lark doc id OR a full doc URL (a /docx/ or /wiki/ link); returns { ok, documentId, title, url, text } where text is the doc as plain text (truncated to ~20k chars). Use it as reference context.
|
|
6
|
+
- larkdoc_create: create a new doc from a title + markdown/text (#/##/### headings, - bullets, 1. ordered supported); returns { ok, documentId, url }. Share the url.
|
|
7
|
+
- larkdoc_append: append markdown/text to the end of an existing doc (pass the documentId or doc URL).
|
|
8
|
+
- larkdoc_list_comments: list the comment threads on a doc (pass the documentId or doc URL); returns { ok, comments:[{ commentId, replies:[{ replyId, author, text }] }] }. Use to read the thread you are replying to.
|
|
9
|
+
- larkdoc_reply_comment: reply INSIDE an existing comment thread \u2014 pass { documentId, commentId, text }. Use this to answer a user who @mentioned Zibby in a doc comment (reply in the SAME commentId).
|
|
10
|
+
- larkdoc_add_comment: post a NEW top-level comment on a doc \u2014 pass { documentId, text }.
|
|
11
|
+
These tools return { ok:false, error } on failure \u2014 treat an unavailable Lark connection as "cannot read/deliver to Lark Docs" and continue rather than blocking the task.`,resolve(){let t=N();return t?{type:"stdio",command:"node",args:[t,"../dist/larkDocs.js","larkDocsSkill"],env:{},description:this.description,alwaysLoad:!0}:null},async handleToolCall(t,e){try{switch(t){case"larkdoc_get":{let n=e?.documentId||e?.url||e?.id,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=await k(r),i="";try{i=(await l("GET",`/open-apis/docx/v1/documents/${o}`)).data?.document?.title||""}catch{}let{data:s,host:c}=await l("GET",`/open-apis/docx/v1/documents/${o}/raw_content?lang=0`),a=String(s?.content||""),d=!1;return a.length>I&&(a=a.slice(0,I),d=!0),JSON.stringify({ok:!0,documentId:o,title:i,url:h(c,o),text:a,...d?{truncated:!0}:{}})}case"larkdoc_create":{let n=typeof e?.title=="string"&&e.title.trim()?e.title.trim():null;if(!n)return JSON.stringify({ok:!1,error:"title is required"});let{data:r,host:o}=await l("POST","/open-apis/docx/v1/documents",{title:n,...e?.folderToken?{folder_token:String(e.folderToken)}:{}}),i=r?.document?.document_id;if(!i)return JSON.stringify({ok:!1,error:"Lark Docs create returned no document_id"});let s=f(e);if(s&&s.trim()){let c=L(s);c.length&&await w(i,c)}return JSON.stringify({ok:!0,documentId:i,title:n,url:h(o,i)})}case"larkdoc_append":{let n=e?.documentId||e?.url||e?.id,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=f(e);if(!o||!o.trim())return JSON.stringify({ok:!1,error:"markdown or text content is required"});let i=await k(r),s=L(o);if(!s.length)return JSON.stringify({ok:!1,error:"no non-empty content to append"});let c=await w(i,s);return JSON.stringify({ok:!0,documentId:i,url:h(c,i)})}case"larkdoc_list_comments":{let n=e?.documentId||e?.url||e?.id||e?.fileToken,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=await k(r),i=y(e),s=new URLSearchParams({file_type:i,page_size:String(U)}),{data:c}=await l("GET",`/open-apis/drive/v1/files/${o}/comments?${s.toString()}`),d=(Array.isArray(c?.items)?c.items:[]).map($);return JSON.stringify({ok:!0,documentId:o,count:d.length,comments:d})}case"larkdoc_add_comment":{let n=e?.documentId||e?.url||e?.id||e?.fileToken,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=f({text:e?.text??e?.body});if(!o||!o.trim())return JSON.stringify({ok:!1,error:"text is required"});let i=await k(r),s=y(e),{data:c}=await l("POST",`/open-apis/drive/v1/files/${i}/comments?file_type=${encodeURIComponent(s)}`,{reply_list:{replies:[{content:{elements:T(o)}}]}});return JSON.stringify({ok:!0,documentId:i,commentId:c?.comment_id||""})}case"larkdoc_reply_comment":{let n=e?.documentId||e?.url||e?.id||e?.fileToken,r=m(n);if(!r)return JSON.stringify({ok:!1,error:"A valid Lark doc id or URL is required"});let o=e?.commentId||e?.comment_id;if(!o)return JSON.stringify({ok:!1,error:"commentId is required"});let i=f({text:e?.text??e?.body});if(!i||!i.trim())return JSON.stringify({ok:!1,error:"text is required"});let s=await k(r),c=y(e),{data:a}=await l("POST",`/open-apis/drive/v1/files/${s}/comments/${encodeURIComponent(o)}/replies?file_type=${encodeURIComponent(c)}`,{content:{elements:T(i)}});return JSON.stringify({ok:!0,documentId:s,commentId:String(o),replyId:a?.reply_id||""})}default:return JSON.stringify({ok:!1,error:`Unknown tool: ${t}`})}}catch(n){return JSON.stringify({ok:!1,error:n.message})}},tools:[{name:"larkdoc_get",description:"Read a Lark/Feishu document (docx) as plain text, for use as reference context. Accepts a raw doc id OR a full Lark doc URL (a /docx/ or /wiki/ link \u2014 wiki links are resolved to their backing docx). Returns { ok, documentId, title, url, text }. Text is truncated to ~20k chars.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL (/docx/\u2026 or /wiki/\u2026)."}},required:["documentId"]}},{name:"larkdoc_create",description:"Create a new Lark/Feishu document (docx) with a title and optional content (markdown: #/##/### headings, - bullets, 1. ordered; or plain text). Returns { ok, documentId, url } \u2014 share the url with the user.",input_schema:{type:"object",properties:{title:{type:"string",description:"Document title."},markdown:{type:"string",description:"Document body as markdown (preferred)."},text:{type:"string",description:"Document body as plain text (used when markdown is absent)."},folderToken:{type:"string",description:"Optional Lark drive folder token to create the doc in. Absent = the app root."}},required:["title"]}},{name:"larkdoc_append",description:"Append markdown/text content to the END of an existing Lark/Feishu document (docx). Accepts a documentId or a full Lark doc URL. Returns { ok, documentId, url }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL."},markdown:{type:"string",description:"Content to append, as markdown (preferred)."},text:{type:"string",description:"Content to append, as plain text (used when markdown is absent)."}},required:["documentId"]}},{name:"larkdoc_list_comments",description:"List the comment threads on a Lark/Feishu document. Accepts a documentId or full doc URL. Returns { ok, comments:[{ commentId, replies:[{ replyId, author, text }] }] }. Use to read the thread you are replying to.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL."},fileType:{type:"string",description:"Drive file type \u2014 defaults to 'docx'. Only change for non-docx files (doc/sheet/bitable/file/slides)."}},required:["documentId"]}},{name:"larkdoc_add_comment",description:"Post a NEW top-level comment on a Lark/Feishu document. Accepts a documentId or full doc URL plus text. Returns { ok, documentId, commentId }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL."},text:{type:"string",description:"The comment body (plain text)."},fileType:{type:"string",description:"Drive file type \u2014 defaults to 'docx'."}},required:["documentId","text"]}},{name:"larkdoc_reply_comment",description:"Reply INSIDE an existing comment thread on a Lark/Feishu document. Pass { documentId, commentId, text }. Use to answer a user who @mentioned Zibby in a doc comment (reply in the same commentId). Returns { ok, documentId, commentId, replyId }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL."},commentId:{type:"string",description:"The comment_id of the thread to reply into (from larkdoc_list_comments or the webhook event)."},text:{type:"string",description:"The reply body (plain text)."},fileType:{type:"string",description:"Drive file type \u2014 defaults to 'docx'."}},required:["documentId","commentId","text"]}}]};function K(){u=null}export{K as _resetLarkDocsTokenCache,h as docWebUrl,M as larkDocsSkill,L as markdownToLarkBlocks,m as parseLarkDocRef};
|
package/dist/notion.d.ts
CHANGED
|
@@ -63,6 +63,9 @@ export namespace notionSkill {
|
|
|
63
63
|
databaseId?: undefined;
|
|
64
64
|
filter?: undefined;
|
|
65
65
|
maxResults?: undefined;
|
|
66
|
+
blockId?: undefined;
|
|
67
|
+
discussionId?: undefined;
|
|
68
|
+
text?: undefined;
|
|
66
69
|
};
|
|
67
70
|
required: string[];
|
|
68
71
|
};
|
|
@@ -86,6 +89,53 @@ export namespace notionSkill {
|
|
|
86
89
|
description: string;
|
|
87
90
|
};
|
|
88
91
|
pageId?: undefined;
|
|
92
|
+
blockId?: undefined;
|
|
93
|
+
discussionId?: undefined;
|
|
94
|
+
text?: undefined;
|
|
95
|
+
};
|
|
96
|
+
required: string[];
|
|
97
|
+
};
|
|
98
|
+
} | {
|
|
99
|
+
name: string;
|
|
100
|
+
description: string;
|
|
101
|
+
input_schema: {
|
|
102
|
+
type: string;
|
|
103
|
+
properties: {
|
|
104
|
+
blockId: {
|
|
105
|
+
type: string;
|
|
106
|
+
description: string;
|
|
107
|
+
};
|
|
108
|
+
pageId?: undefined;
|
|
109
|
+
databaseId?: undefined;
|
|
110
|
+
filter?: undefined;
|
|
111
|
+
maxResults?: undefined;
|
|
112
|
+
discussionId?: undefined;
|
|
113
|
+
text?: undefined;
|
|
114
|
+
};
|
|
115
|
+
required: string[];
|
|
116
|
+
};
|
|
117
|
+
} | {
|
|
118
|
+
name: string;
|
|
119
|
+
description: string;
|
|
120
|
+
input_schema: {
|
|
121
|
+
type: string;
|
|
122
|
+
properties: {
|
|
123
|
+
discussionId: {
|
|
124
|
+
type: string;
|
|
125
|
+
description: string;
|
|
126
|
+
};
|
|
127
|
+
pageId: {
|
|
128
|
+
type: string;
|
|
129
|
+
description: string;
|
|
130
|
+
};
|
|
131
|
+
text: {
|
|
132
|
+
type: string;
|
|
133
|
+
description: string;
|
|
134
|
+
};
|
|
135
|
+
databaseId?: undefined;
|
|
136
|
+
filter?: undefined;
|
|
137
|
+
maxResults?: undefined;
|
|
138
|
+
blockId?: undefined;
|
|
89
139
|
};
|
|
90
140
|
required: string[];
|
|
91
141
|
};
|
package/dist/notion.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
${
|
|
3
|
-
\`\`\``;break}case"divider":
|
|
4
|
-
`)}async function
|
|
5
|
-
`)}function k(
|
|
1
|
+
import{existsSync as x}from"fs";import{fileURLToPath as R}from"url";import{dirname as w,resolve as O}from"path";import{resolveIntegrationToken as S,clearTokenCache as A}from"@zibby/core/backend-client.js";var _=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",FIGMA:"figma",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),j=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},google:{id:"google",name:"Google Docs",connectPath:"/integrations?provider=google"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},open_design:{id:"open_design",name:"OpenDesign",connectPath:"/integrations?provider=open_design"},linkedin_personal:{id:"linkedin_personal",name:"LinkedIn (Personal)",connectPath:"/integrations?provider=linkedin_personal"},linkedin_business:{id:"linkedin_business",name:"LinkedIn (Business)",connectPath:"/integrations?provider=linkedin_business"},discord:{id:"discord",name:"Discord",connectPath:"/integrations?provider=discord"}});function $(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let n=w(R(import.meta.url)),t=O(n,"..","bin","mcp-skill.mjs");return x(t)?t:null}var L="2022-06-28",P="https://api.notion.com/v1",g=2e4,b=25,v=25;function h(n){if(!n||typeof n!="string")return null;let o=n.trim().split(/[?#]/)[0],e=o.match(/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/);if(e)return e[0].toLowerCase();let i=o.match(/[0-9a-fA-F]{32}/g);if(i&&i.length){let s=i[i.length-1].toLowerCase();return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20)}`}return null}async function m(n,t={}){let o=async()=>{let{token:e}=await S("notion");if(typeof e!="string"||!e)throw new Error(`Invalid notion token type: ${typeof e}`);let i=await fetch(`${P}${n}`,{method:t.method||"GET",headers:{Authorization:`Bearer ${e}`,"Notion-Version":L,Accept:"application/json",...t.body?{"Content-Type":"application/json"}:{},...t.headers},body:t.body?JSON.stringify(t.body):void 0});if(!i.ok){let a=await i.text().catch(()=>"");throw new Error(`Notion API ${i.status}: ${a.slice(0,300)}`)}let s=await i.text().catch(()=>"");if(!s||!s.trim())return{};try{return JSON.parse(s)}catch{return{raw:s}}};try{return await o()}catch(e){let i=String(e?.message||e||"").toLowerCase();if(!(i.includes("token")||i.includes("401")||i.includes("unauthorized")))throw e;return A("notion"),o()}}function u(n){if(!Array.isArray(n))return"";let t="";for(let o of n){let e=o?.plain_text??o?.text?.content??"";if(!e)continue;let i=o.annotations||{};i.code&&(e=`\`${e}\``),i.bold&&(e=`**${e}**`),i.italic&&(e=`_${e}_`),i.strikethrough&&(e=`~~${e}~~`);let s=o?.href||o?.text?.link?.url;s&&(e=`[${e}](${s})`),t+=e}return t}function T(n,t,o){let e=n?.type,i=n?.[e]||{},s=" ".repeat(Math.max(0,t)),a=(c="rich_text")=>u(i[c]),r;switch(e){case"paragraph":r=a();break;case"heading_1":r=`# ${a()}`;break;case"heading_2":r=`## ${a()}`;break;case"heading_3":r=`### ${a()}`;break;case"bulleted_list_item":r=`${s}- ${a()}`;break;case"numbered_list_item":r=`${s}1. ${a()}`;break;case"to_do":r=`${s}- [${i.checked?"x":" "}] ${a()}`;break;case"toggle":r=`${s}- ${a()}`;break;case"quote":r=`> ${a()}`;break;case"callout":{r=`> ${i.icon?.emoji?`${i.icon.emoji} `:""}${a()}`;break}case"code":{r=`\`\`\`${i.language||""}
|
|
2
|
+
${a()}
|
|
3
|
+
\`\`\``;break}case"divider":r="---";break;case"child_page":r=`[child page: ${i.title||""}]`;break;case"child_database":r=`[child database: ${i.title||""}]`;break;case"bookmark":case"embed":case"link_preview":r=i.url?`<${i.url}>`:"";break;case"equation":r=i.expression?`$${i.expression}$`:"";break;case"table":case"column_list":case"column":r="";break;case"table_row":{let c=(i.cells||[]).map(l=>u(l).trim());r=`${s}| ${c.join(" | ")} |`;break}default:r=a();break}let d=[];return r&&r.trim()&&d.push(r),o&&o.trim()&&d.push(o),d.join(`
|
|
4
|
+
`)}async function N(n,t,o){let e=[],i,s=0;do{if(o.used>=g)break;let a=new URLSearchParams({page_size:"100"});i&&a.set("start_cursor",i);let r=await m(`/blocks/${n}/children?${a.toString()}`),d=Array.isArray(r.results)?r.results:[];for(let c of d){let l="";c.has_children&&(l=await N(c.id,t+1,o));let p=T(c,t,l);if(p&&(e.push(p),o.used+=p.length+1),o.used>=g)break}i=r.has_more?r.next_cursor:void 0,s+=1}while(i&&s<v);return e.join(`
|
|
5
|
+
`)}function k(n){let t=n?.properties||{};for(let o of Object.values(t))if(o?.type==="title"){let e=u(o.title).trim();if(e)return e}return""}function y(n){let t=String(n??"");if(!t)return[{type:"text",text:{content:""}}];let o=[];for(let e=0;e<t.length;e+=2e3)o.push({type:"text",text:{content:t.slice(e,e+2e3)}});return o}function U(n){return{id:n?.id||"",discussionId:n?.discussion_id||"",text:u(n?.rich_text).trim(),author:n?.created_by?.id||"",createdTime:n?.created_time||""}}function E(n){if(!n||!n.type)return"";switch(n.type){case"title":return u(n.title).trim();case"rich_text":return u(n.rich_text).trim();case"number":return n.number==null?"":String(n.number);case"select":return n.select?.name||"";case"status":return n.status?.name||"";case"multi_select":return(n.multi_select||[]).map(o=>o.name).join(", ");case"checkbox":return n.checkbox?"true":"false";case"url":return n.url||"";case"email":return n.email||"";case"phone_number":return n.phone_number||"";case"date":return n.date?.start||"";case"people":return(n.people||[]).map(o=>o.name||o.id).join(", ");default:return""}}var B={id:"notion",serverName:"notion",allowedTools:["mcp__notion__*"],requiresIntegration:_.NOTION,description:"Notion read-only context (pull a page/database as markdown)",promptFragment:`## Notion (connected, read-only context)
|
|
6
6
|
You can pull a referenced Notion page in as extra context. This is OPTIONAL \u2014 only use it when the task references a Notion page/URL (e.g. an engineering-standards or design doc to review against).
|
|
7
7
|
- notion_get_page: pass a Notion page id OR a full Notion URL; returns { id, title, url, text } where text is the page flattened to markdown (truncated to ~20k chars). Use the text as reference context.
|
|
8
8
|
- notion_query_database: pass a database id/URL; returns a small list of rows ({ id, title, url, props }). Use to find a specific page, then notion_get_page it.
|
|
9
|
-
|
|
9
|
+
- notion_list_comments: pass a page/block id OR URL; returns the open comment discussions on it ({ id, discussionId, text, author }). Use to read the comment thread you are replying to.
|
|
10
|
+
- notion_add_comment: post a comment. To REPLY in an existing discussion pass { discussionId, text }; to start a NEW top-level comment on a page pass { pageId, text }. Returns { ok, id, discussionId }. Use this to answer a user who @mentioned Zibby in a Notion comment \u2014 reply in the SAME discussionId.
|
|
11
|
+
Do not block the task if Notion is unavailable \u2014 these tools return { ok:false, error } on failure; treat a missing page as "no extra context" and continue.`,resolve(){let n=$();return n?{type:"stdio",command:"node",args:[n,"../dist/notion.js","notionSkill"],env:{},description:this.description,alwaysLoad:!0}:null},async handleToolCall(n,t){try{switch(n){case"notion_get_page":{let o=t?.pageId||t?.page||t?.url||t?.id,e=h(o);if(!e)return JSON.stringify({ok:!1,error:"A valid Notion page id or URL is required"});let i=await m(`/pages/${e}`),s=k(i),a=i?.url||`https://www.notion.so/${e.replace(/-/g,"")}`,d=await N(e,0,{used:0}),c=!1;return d.length>g&&(d=d.slice(0,g),c=!0),JSON.stringify({ok:!0,id:e,title:s,url:a,text:d,...c?{truncated:!0}:{}})}case"notion_query_database":{let o=t?.databaseId||t?.database||t?.url||t?.id,e=h(o);if(!e)return JSON.stringify({ok:!1,error:"A valid Notion database id or URL is required"});let s={page_size:Math.max(1,Math.min(Number(t?.maxResults)||b,b))};t?.filter&&typeof t.filter=="object"&&(s.filter=t.filter);let a=await m(`/databases/${e}/query`,{method:"POST",body:s}),d=(Array.isArray(a.results)?a.results:[]).map(c=>{let l={};for(let[p,I]of Object.entries(c.properties||{})){let f=E(I);f&&(l[p]=f)}return{id:c.id,title:k(c),url:c.url||`https://www.notion.so/${String(c.id||"").replace(/-/g,"")}`,props:l}});return JSON.stringify({ok:!0,id:e,count:d.length,hasMore:!!a.has_more,rows:d})}case"notion_list_comments":{let o=t?.blockId||t?.pageId||t?.block||t?.page||t?.url||t?.id,e=h(o);if(!e)return JSON.stringify({ok:!1,error:"A valid Notion page/block id or URL is required"});let i=new URLSearchParams({block_id:e,page_size:"100"}),s=await m(`/comments?${i.toString()}`),r=(Array.isArray(s.results)?s.results:[]).map(U);return JSON.stringify({ok:!0,id:e,count:r.length,comments:r})}case"notion_add_comment":{let o=typeof t?.text=="string"?t.text:typeof t?.body=="string"?t.body:"";if(!o||!o.trim())return JSON.stringify({ok:!1,error:"text is required"});let e=t?.discussionId||t?.discussion_id||null,i;if(e)i={discussion_id:String(e),rich_text:y(o)};else{let a=t?.pageId||t?.page||t?.url||t?.id,r=h(a);if(!r)return JSON.stringify({ok:!1,error:"Either discussionId (to reply) or a valid pageId (to start a comment) is required"});i={parent:{page_id:r},rich_text:y(o)}}let s=await m("/comments",{method:"POST",body:i});return JSON.stringify({ok:!0,id:s?.id||"",discussionId:s?.discussion_id||e||""})}default:return JSON.stringify({ok:!1,error:`Unknown tool: ${n}`})}}catch(o){return JSON.stringify({ok:!1,error:o.message})}},tools:[{name:"notion_get_page",description:"Fetch a Notion page and its content flattened to markdown, for use as read-only context. Accepts a raw page id OR a full Notion URL. Returns { ok, id, title, url, text }. Text is truncated to ~20k chars.",input_schema:{type:"object",properties:{pageId:{type:"string",description:"Notion page id (dashed UUID or 32-char) OR a full Notion page URL."}},required:["pageId"]}},{name:"notion_query_database",description:"Query a Notion database and return a bounded list of rows (id, title, url, key props). Accepts a database id OR full Notion URL. Optional Notion filter object. Returns at most 25 rows.",input_schema:{type:"object",properties:{databaseId:{type:"string",description:"Notion database id (dashed UUID or 32-char) OR a full Notion database URL."},filter:{type:"object",description:"Optional Notion filter object (Notion query filter syntax).",additionalProperties:!0},maxResults:{type:"number",description:"Max rows to return (default 25, max 25)."}},required:["databaseId"]}},{name:"notion_list_comments",description:"List the open comment discussions on a Notion page/block. Accepts a page/block id OR a full Notion URL. Returns { ok, comments:[{ id, discussionId, text, author }] }. Use to read the comment thread you are replying to.",input_schema:{type:"object",properties:{blockId:{type:"string",description:"Notion page or block id (dashed UUID or 32-char) OR a full Notion URL."}},required:["blockId"]}},{name:"notion_add_comment",description:"Post a comment on Notion. To REPLY within an existing discussion, pass { discussionId, text }. To start a NEW top-level comment on a page, pass { pageId, text }. Returns { ok, id, discussionId }. Use this to answer a user who @mentioned Zibby in a Notion comment (reply in the same discussionId).",input_schema:{type:"object",properties:{discussionId:{type:"string",description:"The discussion_id to reply into (from notion_list_comments). Preferred for replies."},pageId:{type:"string",description:"Page id/URL to start a NEW top-level comment on (used when discussionId is absent)."},text:{type:"string",description:"The comment body (plain text)."}},required:["text"]}}]};export{m as notionApi,B as notionSkill,h as parseNotionId};
|
package/dist/package.json
CHANGED