@zibby/skills 0.1.71 → 0.1.73
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/assets/fonts/NotoSans-Bold.ttf +0 -0
- package/assets/fonts/NotoSans-Regular.ttf +0 -0
- package/assets/fonts/OFL.txt +94 -0
- package/dist/chartRender.d.ts +57 -0
- package/dist/chartRender.js +7 -0
- package/dist/googleDocs.d.ts +40 -8
- package/dist/googleDocs.js +16 -6
- package/dist/index.d.ts +4 -2
- package/dist/index.js +165 -152
- package/dist/larkDocs.d.ts +49 -0
- package/dist/larkDocs.js +4 -3
- package/dist/memory.js +2 -13
- package/dist/notion.d.ts +163 -0
- package/dist/notion.js +12 -7
- package/dist/package.json +4 -1
- package/dist/report.d.ts +24 -0
- package/dist/report.js +12 -11
- package/dist/sentry.d.ts +14 -1
- package/dist/sentry.js +2 -2
- package/package.json +4 -1
package/dist/larkDocs.d.ts
CHANGED
|
@@ -75,6 +75,9 @@ export namespace larkDocsSkill {
|
|
|
75
75
|
markdown?: undefined;
|
|
76
76
|
text?: undefined;
|
|
77
77
|
folderToken?: undefined;
|
|
78
|
+
imagePath?: undefined;
|
|
79
|
+
width?: undefined;
|
|
80
|
+
height?: undefined;
|
|
78
81
|
fileType?: undefined;
|
|
79
82
|
commentId?: undefined;
|
|
80
83
|
};
|
|
@@ -103,6 +106,9 @@ export namespace larkDocsSkill {
|
|
|
103
106
|
description: string;
|
|
104
107
|
};
|
|
105
108
|
documentId?: undefined;
|
|
109
|
+
imagePath?: undefined;
|
|
110
|
+
width?: undefined;
|
|
111
|
+
height?: undefined;
|
|
106
112
|
fileType?: undefined;
|
|
107
113
|
commentId?: undefined;
|
|
108
114
|
};
|
|
@@ -128,6 +134,40 @@ export namespace larkDocsSkill {
|
|
|
128
134
|
};
|
|
129
135
|
title?: undefined;
|
|
130
136
|
folderToken?: undefined;
|
|
137
|
+
imagePath?: undefined;
|
|
138
|
+
width?: undefined;
|
|
139
|
+
height?: undefined;
|
|
140
|
+
fileType?: undefined;
|
|
141
|
+
commentId?: undefined;
|
|
142
|
+
};
|
|
143
|
+
required: string[];
|
|
144
|
+
};
|
|
145
|
+
} | {
|
|
146
|
+
name: string;
|
|
147
|
+
description: string;
|
|
148
|
+
input_schema: {
|
|
149
|
+
type: string;
|
|
150
|
+
properties: {
|
|
151
|
+
documentId: {
|
|
152
|
+
type: string;
|
|
153
|
+
description: string;
|
|
154
|
+
};
|
|
155
|
+
imagePath: {
|
|
156
|
+
type: string;
|
|
157
|
+
description: string;
|
|
158
|
+
};
|
|
159
|
+
width: {
|
|
160
|
+
type: string;
|
|
161
|
+
description: string;
|
|
162
|
+
};
|
|
163
|
+
height: {
|
|
164
|
+
type: string;
|
|
165
|
+
description: string;
|
|
166
|
+
};
|
|
167
|
+
title?: undefined;
|
|
168
|
+
markdown?: undefined;
|
|
169
|
+
text?: undefined;
|
|
170
|
+
folderToken?: undefined;
|
|
131
171
|
fileType?: undefined;
|
|
132
172
|
commentId?: undefined;
|
|
133
173
|
};
|
|
@@ -151,6 +191,9 @@ export namespace larkDocsSkill {
|
|
|
151
191
|
markdown?: undefined;
|
|
152
192
|
text?: undefined;
|
|
153
193
|
folderToken?: undefined;
|
|
194
|
+
imagePath?: undefined;
|
|
195
|
+
width?: undefined;
|
|
196
|
+
height?: undefined;
|
|
154
197
|
commentId?: undefined;
|
|
155
198
|
};
|
|
156
199
|
required: string[];
|
|
@@ -176,6 +219,9 @@ export namespace larkDocsSkill {
|
|
|
176
219
|
title?: undefined;
|
|
177
220
|
markdown?: undefined;
|
|
178
221
|
folderToken?: undefined;
|
|
222
|
+
imagePath?: undefined;
|
|
223
|
+
width?: undefined;
|
|
224
|
+
height?: undefined;
|
|
179
225
|
commentId?: undefined;
|
|
180
226
|
};
|
|
181
227
|
required: string[];
|
|
@@ -205,6 +251,9 @@ export namespace larkDocsSkill {
|
|
|
205
251
|
title?: undefined;
|
|
206
252
|
markdown?: undefined;
|
|
207
253
|
folderToken?: undefined;
|
|
254
|
+
imagePath?: undefined;
|
|
255
|
+
width?: undefined;
|
|
256
|
+
height?: undefined;
|
|
208
257
|
};
|
|
209
258
|
required: string[];
|
|
210
259
|
};
|
package/dist/larkDocs.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as v,statSync as A,readFileSync as R}from"fs";import{fileURLToPath as P}from"url";import{basename as E,dirname as U,resolve as $}from"path";import{resolveIntegrationToken as D}from"@zibby/core/backend-client.js";var x=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"}),z=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 j(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let t=U(P(import.meta.url)),e=$(t,"..","bin","mcp-skill.mjs");return v(e)?e:null}var L=2e4,w=50,C=10*1024*1024,J=6e3*1e3,f=null;async function N(){let{appId:t,appSecret:e,host:n}=await D("lark");if(f&&f.appId===t&&f.expiresAt>Date.now())return{token:f.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 f={token:o.tenant_access_token,expiresAt:Date.now()+J,appId:t},{token:o.tenant_access_token,host:n}}async function l(t,e,n){let{token:r,host:o}=await N(),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 a=await(await fetch(`${o}${e}`,i)).json();if(a.code!==0)throw new Error(`Lark Docx API ${e} error: ${a.msg||a.code}`);return{data:a.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 b(t){let e=String(t??"").replace(/\r\n/g,`
|
|
2
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),
|
|
3
|
+
`)){let o=r.replace(/\s+$/,"");if(!o.trim())continue;let i=/^(#{1,3})\s+(.*)$/.exec(o),c=/^\s*[-*]\s+(.*)$/.exec(o),a=/^\s*\d+[.)]\s+(.*)$/.exec(o),s,d,p;if(i){let u=i[1].length;s=`heading${u}`,d=2+u,p=i[2]}else c?(s="bullet",d=12,p=c[1]):a?(s="ordered",d=13,p=a[1]):(s="text",d=2,p=o);n.push({block_type:d,[s]:{elements:[{text_run:{content:p}}],style:{}}})}return n}function y(t){let e=typeof t?.markdown=="string"?t.markdown:null,n=typeof t?.text=="string"?t.text:null;return e??n}async function S(t,e){let n;for(let r=0;r<e.length;r+=w){let o=e.slice(r,r+w);n=(await l("POST",`/open-apis/docx/v1/documents/${t}/blocks/${t}/children?document_revision_id=-1`,{children:o})).host}return n}function F(t){let e=typeof t=="string"?t.trim():"";if(!e)throw new Error("imagePath is required");if(!v(e)||!A(e).isFile())throw new Error(`imagePath not found (or not a file): ${e}`);if(!/\.(png|jpe?g)$/i.test(e))throw new Error("imagePath must be a .png or .jpg/.jpeg file");let n=R(e);if(n.length>C)throw new Error(`image is ${(n.length/(1024*1024)).toFixed(1)}MB \u2014 max 10MB`);return n}async function q({fileName:t,parentNode:e,bytes:n}){let{token:r,host:o}=await N(),i=new FormData;i.set("file_name",t),i.set("parent_type","docx_image"),i.set("parent_node",e),i.set("size",String(n.length)),i.set("file",new Blob([n]),t);let a=await(await fetch(`${o}/open-apis/drive/v1/medias/upload_all`,{method:"POST",headers:{Authorization:`Bearer ${r}`},body:i})).json();if(a.code!==0)throw new Error(`Lark media upload_all error: ${a.msg||a.code}`);let s=a.data?.file_token;if(!s)throw new Error("Lark media upload_all returned no file_token");return s}var B="docx",G=50;function T(t){return[{type:"text_run",text_run:{text:String(t??"")}}]}function M(t){return Array.isArray(t)?t.map(e=>e?.text_run?.text??e?.docs_link?.url??(e?.person?`@${e.person.user_id||""}`:"")).join(""):""}function K(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:M(n?.content?.elements),createTime:n?.create_time||""}))}}function I(t){return typeof t?.fileType=="string"&&t.fileType.trim()?t.fileType.trim():B}var V={id:"lark-docs",serverName:"larkdocs",allowedTools:["mcp__larkdocs__*"],requiresIntegration:x.LARK,description:"Lark / Feishu Docs \u2014 read, create, append, and insert images into Lark documents (docx).",envKeys:[],promptFragment:`## Lark Docs (connected)
|
|
4
4
|
You can read, create, and append Lark/Feishu documents (docx). This reuses the same connected Lark app as messaging.
|
|
5
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
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
7
|
- larkdoc_append: append markdown/text to the end of an existing doc (pass the documentId or doc URL).
|
|
8
|
+
- larkdoc_insert_image: append a LOCAL image file (png/jpg, \u226410MB) to the end of a doc \u2014 pass { documentId, imagePath, width?, height? } (width/height in px, optional). Returns { ok, documentId, blockId, url }. Use this to deliver a rendered chart/report image into the doc.
|
|
8
9
|
- 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
10
|
- 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
11
|
- 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=
|
|
12
|
+
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=j();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:c,host:a}=await l("GET",`/open-apis/docx/v1/documents/${o}/raw_content?lang=0`),s=String(c?.content||""),d=!1;return s.length>L&&(s=s.slice(0,L),d=!0),JSON.stringify({ok:!0,documentId:o,title:i,url:h(a,o),text:s,...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 c=y(e);if(c&&c.trim()){let a=b(c);a.length&&await S(i,a)}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=y(e);if(!o||!o.trim())return JSON.stringify({ok:!1,error:"markdown or text content is required"});let i=await k(r),c=b(o);if(!c.length)return JSON.stringify({ok:!1,error:"no non-empty content to append"});let a=await S(i,c);return JSON.stringify({ok:!0,documentId:i,url:h(a,i)})}case"larkdoc_insert_image":{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"});if(!e?.imagePath||typeof e.imagePath!="string"||!e.imagePath.trim())return JSON.stringify({ok:!1,error:"imagePath is required"});let o=await k(r),i=e.imagePath.trim(),c=F(i),a=E(i),d=(await l("POST",`/open-apis/docx/v1/documents/${o}/blocks/${o}/children?document_revision_id=-1`,{children:[{block_type:27,image:{}}]})).data?.children?.[0]?.block_id;if(!d)return JSON.stringify({ok:!1,error:"Lark image block create returned no block_id"});let p=await q({fileName:a,parentNode:d,bytes:c}),u={token:p},g=Number(e?.width),_=Number(e?.height);Number.isFinite(g)&&g>0&&(u.width=Math.round(g)),Number.isFinite(_)&&_>0&&(u.height=Math.round(_));let{host:O}=await l("PATCH",`/open-apis/docx/v1/documents/${o}/blocks/${d}?document_revision_id=-1`,{replace_image:u});return JSON.stringify({ok:!0,documentId:o,blockId:d,fileToken:p,url:h(O,o)})}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=I(e),c=new URLSearchParams({file_type:i,page_size:String(G)}),{data:a}=await l("GET",`/open-apis/drive/v1/files/${o}/comments?${c.toString()}`),d=(Array.isArray(a?.items)?a.items:[]).map(K);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=y({text:e?.text??e?.body});if(!o||!o.trim())return JSON.stringify({ok:!1,error:"text is required"});let i=await k(r),c=I(e),{data:a}=await l("POST",`/open-apis/drive/v1/files/${i}/comments?file_type=${encodeURIComponent(c)}`,{reply_list:{replies:[{content:{elements:T(o)}}]}});return JSON.stringify({ok:!0,documentId:i,commentId:a?.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=y({text:e?.text??e?.body});if(!i||!i.trim())return JSON.stringify({ok:!1,error:"text is required"});let c=await k(r),a=I(e),{data:s}=await l("POST",`/open-apis/drive/v1/files/${c}/comments/${encodeURIComponent(o)}/replies?file_type=${encodeURIComponent(a)}`,{content:{elements:T(i)}});return JSON.stringify({ok:!0,documentId:c,commentId:String(o),replyId:s?.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_insert_image",description:"Append a LOCAL image file (png/jpg, max 10MB) to the END of an existing Lark/Feishu document (docx). Accepts a documentId or full doc URL plus a local file path. Optional width/height in pixels. Returns { ok, documentId, blockId, fileToken, url }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Lark doc id (docx token) OR a full Lark/Feishu doc URL."},imagePath:{type:"string",description:"Local filesystem path to a .png or .jpg/.jpeg image (max 10MB)."},width:{type:"number",description:"Optional display width in pixels."},height:{type:"number",description:"Optional display height in pixels."}},required:["documentId","imagePath"]}},{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 ee(){f=null}export{ee as _resetLarkDocsTokenCache,h as docWebUrl,V as larkDocsSkill,b as markdownToLarkBlocks,m as parseLarkDocRef};
|
package/dist/memory.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as s}from"module";import{execFileSync as n}from"child_process";import{join as o}from"path";import{existsSync as a}from"fs";var c=s(import.meta.url);function
|
|
1
|
+
import{createRequire as s}from"module";import{execFileSync as n}from"child_process";import{join as o}from"path";import{existsSync as a}from"fs";var c=s(import.meta.url);function l(){if(process.env.MCP_MEMORY_PATH)return process.env.MCP_MEMORY_PATH;try{return c.resolve("@zibby/ui-memory/mcp-server")}catch{return null}}var d={id:"memory",serverName:"memory",allowedTools:["mcp__memory__*"],envKeys:[],description:"Zibby Memory MCP Server (test history, selectors, page model)",async middleware(){try{let{createMemoryMiddleware:e}=await import("@zibby/ui-memory");return e()}catch{return null}},promptFragment:`BEFORE executing browser actions:
|
|
2
2
|
- Review any test memory/history above. Prefer selectors proven to work.
|
|
3
3
|
- If a previous run failed, avoid the same approach.
|
|
4
4
|
- After setup/login completes, navigate directly to the target page instead of clicking through menus.
|
|
@@ -10,15 +10,4 @@ DURING execution \u2014 when a selector fails and you switch to a fallback:
|
|
|
10
10
|
AFTER completing the test, you MUST call memory_save_insight at least once:
|
|
11
11
|
- Save any useful finding: reliable selectors, timing quirks, navigation patterns, workarounds.
|
|
12
12
|
- Category: selector_tip | timing | navigation | workaround | flaky | general
|
|
13
|
-
- Be specific \u2014 future runs will read your insights.`,resolve(){let e=
|
|
14
|
-
|
|
15
|
-
Install @zibby/ui-memory:
|
|
16
|
-
npm install @zibby/ui-memory`);let r=o(process.cwd(),".zibby","memory");if(!a(o(r,".dolt")))throw new Error(`\u274C Memory database not initialized
|
|
17
|
-
|
|
18
|
-
Run:
|
|
19
|
-
zibby init --mem`);try{let t=n("dolt",["sql","-q","SELECT COUNT(*) AS cnt FROM test_runs","-r","json"],{cwd:r,encoding:"utf-8",timeout:5e3}),i=JSON.parse(t.trim()).rows||[];if(!i[0]||i[0].cnt===0)return console.log("[memory] Database empty \u2014 memory tools activate after first completed run"),null}catch(t){throw new Error(`\u274C Dolt not found or memory database error
|
|
20
|
-
|
|
21
|
-
Install Dolt:
|
|
22
|
-
https://docs.dolthub.com/introduction/installation
|
|
23
|
-
|
|
24
|
-
Error: ${t.message}`,{cause:t})}return{command:"node",args:[e,"--db-path",r],description:this.description}},tools:[{name:"memory_get_test_history",description:"Query recent test runs with pass/fail results and timing",input_schema:{type:"object",properties:{specPath:{type:"string",description:"Filter by spec path (substring match)"},limit:{type:"number",description:"Max results (default 10)"}}}},{name:"memory_get_selectors",description:"Query known selectors for a page with stability metrics",input_schema:{type:"object",properties:{pageUrl:{type:"string",description:"Filter by page URL (substring match)"},limit:{type:"number",description:"Max results (default 20)"}}}},{name:"memory_get_page_model",description:"Query page structure \u2014 elements, roles, selectors",input_schema:{type:"object",properties:{url:{type:"string",description:"Filter by page URL (substring match)"},limit:{type:"number",description:"Max results (default 20)"}}}},{name:"memory_get_navigation",description:"Query known page-to-page transitions",input_schema:{type:"object",properties:{fromUrl:{type:"string",description:"Filter by source URL (substring match)"},limit:{type:"number",description:"Max results (default 20)"}}}},{name:"memory_save_insight",description:"Save a useful observation for future runs (selector tips, timing, workarounds)",input_schema:{type:"object",properties:{category:{type:"string",enum:["selector_tip","timing","navigation","workaround","flaky","general"],description:"Type of insight"},content:{type:"string",description:"The insight text \u2014 be specific and actionable"},specPath:{type:"string",description:"Related spec path"},sessionId:{type:"string",description:"Current session ID"}},required:["category","content"]}}]};export{d as memorySkill};
|
|
13
|
+
- Be specific \u2014 future runs will read your insights.`,resolve(){let e=l();if(!e)return console.warn("[memory] @zibby/ui-memory not found \u2014 memory tools disabled for this run"),null;let t=o(process.cwd(),".zibby","memory");if(!a(o(t,".dolt")))return console.warn("[memory] DB/dolt unavailable \u2014 memory tools disabled for this run"),null;try{let r=n("dolt",["sql","-q","SELECT COUNT(*) AS cnt FROM test_runs","-r","json"],{cwd:t,encoding:"utf-8",timeout:5e3}),i=JSON.parse(r.trim()).rows||[];if(!i[0]||i[0].cnt===0)return console.log("[memory] Database empty \u2014 memory tools activate after first completed run"),null}catch(r){return console.warn(`[memory] DB/dolt unavailable \u2014 memory tools disabled for this run (${r.message})`),null}return{command:"node",args:[e,"--db-path",t],description:this.description}},tools:[{name:"memory_get_test_history",description:"Query recent test runs with pass/fail results and timing",input_schema:{type:"object",properties:{specPath:{type:"string",description:"Filter by spec path (substring match)"},limit:{type:"number",description:"Max results (default 10)"}}}},{name:"memory_get_selectors",description:"Query known selectors for a page with stability metrics",input_schema:{type:"object",properties:{pageUrl:{type:"string",description:"Filter by page URL (substring match)"},limit:{type:"number",description:"Max results (default 20)"}}}},{name:"memory_get_page_model",description:"Query page structure \u2014 elements, roles, selectors",input_schema:{type:"object",properties:{url:{type:"string",description:"Filter by page URL (substring match)"},limit:{type:"number",description:"Max results (default 20)"}}}},{name:"memory_get_navigation",description:"Query known page-to-page transitions",input_schema:{type:"object",properties:{fromUrl:{type:"string",description:"Filter by source URL (substring match)"},limit:{type:"number",description:"Max results (default 20)"}}}},{name:"memory_save_insight",description:"Save a useful observation for future runs (selector tips, timing, workarounds)",input_schema:{type:"object",properties:{category:{type:"string",enum:["selector_tip","timing","navigation","workaround","flaky","general"],description:"Type of insight"},content:{type:"string",description:"The insight text \u2014 be specific and actionable"},specPath:{type:"string",description:"Related spec path"},sessionId:{type:"string",description:"Current session ID"}},required:["category","content"]}}]};export{d as memorySkill};
|
package/dist/notion.d.ts
CHANGED
|
@@ -18,8 +18,30 @@ export function parseNotionId(ref: any): string;
|
|
|
18
18
|
* header, retries once on transient auth errors, and returns parsed JSON.
|
|
19
19
|
*
|
|
20
20
|
* Keep this the single auth chokepoint — don't resolve tokens at call sites.
|
|
21
|
+
* `opts.formData`: a FormData body (the file-upload send endpoint is
|
|
22
|
+
* multipart/form-data, not JSON) — fetch sets the multipart boundary itself,
|
|
23
|
+
* so no Content-Type is set for it.
|
|
21
24
|
*/
|
|
22
25
|
export function notionApi(path: any, opts?: {}): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Map a small, common subset of markdown into Notion block objects.
|
|
28
|
+
* Each block is a single line: headings (#/##/### → heading_1/2/3), bullets
|
|
29
|
+
* (- / *), ordered (1.) — everything else a paragraph. Inline marks are kept
|
|
30
|
+
* as literal text (content preserved; no annotation parsing — honest +
|
|
31
|
+
* robust). Empty lines are skipped. Mirrors larkDocs.js markdownToLarkBlocks.
|
|
32
|
+
*/
|
|
33
|
+
export function markdownToNotionBlocks(markdown: any): {
|
|
34
|
+
[x: string]: string | {
|
|
35
|
+
rich_text: {
|
|
36
|
+
type: string;
|
|
37
|
+
text: {
|
|
38
|
+
content: string;
|
|
39
|
+
};
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
object: string;
|
|
43
|
+
type: string;
|
|
44
|
+
}[];
|
|
23
45
|
export namespace notionSkill {
|
|
24
46
|
let id: string;
|
|
25
47
|
let serverName: string;
|
|
@@ -63,6 +85,13 @@ export namespace notionSkill {
|
|
|
63
85
|
databaseId?: undefined;
|
|
64
86
|
filter?: undefined;
|
|
65
87
|
maxResults?: undefined;
|
|
88
|
+
parentPageId?: undefined;
|
|
89
|
+
title?: undefined;
|
|
90
|
+
markdown?: undefined;
|
|
91
|
+
blocks?: undefined;
|
|
92
|
+
imagePath?: undefined;
|
|
93
|
+
imageUrl?: undefined;
|
|
94
|
+
caption?: undefined;
|
|
66
95
|
blockId?: undefined;
|
|
67
96
|
discussionId?: undefined;
|
|
68
97
|
text?: undefined;
|
|
@@ -89,6 +118,126 @@ export namespace notionSkill {
|
|
|
89
118
|
description: string;
|
|
90
119
|
};
|
|
91
120
|
pageId?: undefined;
|
|
121
|
+
parentPageId?: undefined;
|
|
122
|
+
title?: undefined;
|
|
123
|
+
markdown?: undefined;
|
|
124
|
+
blocks?: undefined;
|
|
125
|
+
imagePath?: undefined;
|
|
126
|
+
imageUrl?: undefined;
|
|
127
|
+
caption?: undefined;
|
|
128
|
+
blockId?: undefined;
|
|
129
|
+
discussionId?: undefined;
|
|
130
|
+
text?: undefined;
|
|
131
|
+
};
|
|
132
|
+
required: string[];
|
|
133
|
+
};
|
|
134
|
+
} | {
|
|
135
|
+
name: string;
|
|
136
|
+
description: string;
|
|
137
|
+
input_schema: {
|
|
138
|
+
type: string;
|
|
139
|
+
properties: {
|
|
140
|
+
parentPageId: {
|
|
141
|
+
type: string;
|
|
142
|
+
description: string;
|
|
143
|
+
};
|
|
144
|
+
databaseId: {
|
|
145
|
+
type: string;
|
|
146
|
+
description: string;
|
|
147
|
+
};
|
|
148
|
+
title: {
|
|
149
|
+
type: string;
|
|
150
|
+
description: string;
|
|
151
|
+
};
|
|
152
|
+
markdown: {
|
|
153
|
+
type: string;
|
|
154
|
+
description: string;
|
|
155
|
+
};
|
|
156
|
+
blocks: {
|
|
157
|
+
type: string;
|
|
158
|
+
description: string;
|
|
159
|
+
items: {
|
|
160
|
+
type: string;
|
|
161
|
+
additionalProperties: boolean;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
pageId?: undefined;
|
|
165
|
+
filter?: undefined;
|
|
166
|
+
maxResults?: undefined;
|
|
167
|
+
imagePath?: undefined;
|
|
168
|
+
imageUrl?: undefined;
|
|
169
|
+
caption?: undefined;
|
|
170
|
+
blockId?: undefined;
|
|
171
|
+
discussionId?: undefined;
|
|
172
|
+
text?: undefined;
|
|
173
|
+
};
|
|
174
|
+
required: string[];
|
|
175
|
+
};
|
|
176
|
+
} | {
|
|
177
|
+
name: string;
|
|
178
|
+
description: string;
|
|
179
|
+
input_schema: {
|
|
180
|
+
type: string;
|
|
181
|
+
properties: {
|
|
182
|
+
pageId: {
|
|
183
|
+
type: string;
|
|
184
|
+
description: string;
|
|
185
|
+
};
|
|
186
|
+
markdown: {
|
|
187
|
+
type: string;
|
|
188
|
+
description: string;
|
|
189
|
+
};
|
|
190
|
+
blocks: {
|
|
191
|
+
type: string;
|
|
192
|
+
description: string;
|
|
193
|
+
items: {
|
|
194
|
+
type: string;
|
|
195
|
+
additionalProperties: boolean;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
databaseId?: undefined;
|
|
199
|
+
filter?: undefined;
|
|
200
|
+
maxResults?: undefined;
|
|
201
|
+
parentPageId?: undefined;
|
|
202
|
+
title?: undefined;
|
|
203
|
+
imagePath?: undefined;
|
|
204
|
+
imageUrl?: undefined;
|
|
205
|
+
caption?: undefined;
|
|
206
|
+
blockId?: undefined;
|
|
207
|
+
discussionId?: undefined;
|
|
208
|
+
text?: undefined;
|
|
209
|
+
};
|
|
210
|
+
required: string[];
|
|
211
|
+
};
|
|
212
|
+
} | {
|
|
213
|
+
name: string;
|
|
214
|
+
description: string;
|
|
215
|
+
input_schema: {
|
|
216
|
+
type: string;
|
|
217
|
+
properties: {
|
|
218
|
+
pageId: {
|
|
219
|
+
type: string;
|
|
220
|
+
description: string;
|
|
221
|
+
};
|
|
222
|
+
imagePath: {
|
|
223
|
+
type: string;
|
|
224
|
+
description: string;
|
|
225
|
+
};
|
|
226
|
+
imageUrl: {
|
|
227
|
+
type: string;
|
|
228
|
+
description: string;
|
|
229
|
+
};
|
|
230
|
+
caption: {
|
|
231
|
+
type: string;
|
|
232
|
+
description: string;
|
|
233
|
+
};
|
|
234
|
+
databaseId?: undefined;
|
|
235
|
+
filter?: undefined;
|
|
236
|
+
maxResults?: undefined;
|
|
237
|
+
parentPageId?: undefined;
|
|
238
|
+
title?: undefined;
|
|
239
|
+
markdown?: undefined;
|
|
240
|
+
blocks?: undefined;
|
|
92
241
|
blockId?: undefined;
|
|
93
242
|
discussionId?: undefined;
|
|
94
243
|
text?: undefined;
|
|
@@ -109,6 +258,13 @@ export namespace notionSkill {
|
|
|
109
258
|
databaseId?: undefined;
|
|
110
259
|
filter?: undefined;
|
|
111
260
|
maxResults?: undefined;
|
|
261
|
+
parentPageId?: undefined;
|
|
262
|
+
title?: undefined;
|
|
263
|
+
markdown?: undefined;
|
|
264
|
+
blocks?: undefined;
|
|
265
|
+
imagePath?: undefined;
|
|
266
|
+
imageUrl?: undefined;
|
|
267
|
+
caption?: undefined;
|
|
112
268
|
discussionId?: undefined;
|
|
113
269
|
text?: undefined;
|
|
114
270
|
};
|
|
@@ -135,6 +291,13 @@ export namespace notionSkill {
|
|
|
135
291
|
databaseId?: undefined;
|
|
136
292
|
filter?: undefined;
|
|
137
293
|
maxResults?: undefined;
|
|
294
|
+
parentPageId?: undefined;
|
|
295
|
+
title?: undefined;
|
|
296
|
+
markdown?: undefined;
|
|
297
|
+
blocks?: undefined;
|
|
298
|
+
imagePath?: undefined;
|
|
299
|
+
imageUrl?: undefined;
|
|
300
|
+
caption?: undefined;
|
|
138
301
|
blockId?: undefined;
|
|
139
302
|
};
|
|
140
303
|
required: string[];
|
package/dist/notion.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
${
|
|
3
|
-
\`\`\``;break}case"divider":
|
|
4
|
-
`)}async function
|
|
5
|
-
`)}function
|
|
6
|
-
|
|
1
|
+
import{existsSync as P,statSync as S,readFileSync as L}from"fs";import{fileURLToPath as $}from"url";import{basename as U,dirname as T,resolve as v}from"path";import{resolveIntegrationToken as j,clearTokenCache as E}from"@zibby/core/backend-client.js";var y=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"}),X=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 q(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let i=T($(import.meta.url)),e=v(i,"..","bin","mcp-skill.mjs");return P(e)?e:null}var C="2022-06-28",B="https://api.notion.com/v1",h=2e4,I=25,D=25,b=100,N=500,J=20*1024*1024;function u(i){if(!i||typeof i!="string")return null;let t=i.trim().split(/[?#]/)[0],n=t.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(n)return n[0].toLowerCase();let o=t.match(/[0-9a-fA-F]{32}/g);if(o&&o.length){let r=o[o.length-1].toLowerCase();return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}return null}async function p(i,e={}){let t=async()=>{let{token:n}=await j("notion");if(typeof n!="string"||!n)throw new Error(`Invalid notion token type: ${typeof n}`);let o=await fetch(`${B}${i}`,{method:e.method||"GET",headers:{Authorization:`Bearer ${n}`,"Notion-Version":C,Accept:"application/json",...e.body&&!e.formData?{"Content-Type":"application/json"}:{},...e.headers},body:e.formData?e.formData:e.body?JSON.stringify(e.body):void 0});if(!o.ok){let s=await o.text().catch(()=>"");throw new Error(`Notion API ${o.status}: ${s.slice(0,300)}`)}let r=await o.text().catch(()=>"");if(!r||!r.trim())return{};try{return JSON.parse(r)}catch{return{raw:r}}};try{return await t()}catch(n){let o=String(n?.message||n||"").toLowerCase();if(!(o.includes("token")||o.includes("401")||o.includes("unauthorized")))throw n;return E("notion"),t()}}function g(i){if(!Array.isArray(i))return"";let e="";for(let t of i){let n=t?.plain_text??t?.text?.content??"";if(!n)continue;let o=t.annotations||{};o.code&&(n=`\`${n}\``),o.bold&&(n=`**${n}**`),o.italic&&(n=`_${n}_`),o.strikethrough&&(n=`~~${n}~~`);let r=t?.href||t?.text?.link?.url;r&&(n=`[${n}](${r})`),e+=n}return e}function M(i,e,t){let n=i?.type,o=i?.[n]||{},r=" ".repeat(Math.max(0,e)),s=(c="rich_text")=>g(o[c]),a;switch(n){case"paragraph":a=s();break;case"heading_1":a=`# ${s()}`;break;case"heading_2":a=`## ${s()}`;break;case"heading_3":a=`### ${s()}`;break;case"bulleted_list_item":a=`${r}- ${s()}`;break;case"numbered_list_item":a=`${r}1. ${s()}`;break;case"to_do":a=`${r}- [${o.checked?"x":" "}] ${s()}`;break;case"toggle":a=`${r}- ${s()}`;break;case"quote":a=`> ${s()}`;break;case"callout":{a=`> ${o.icon?.emoji?`${o.icon.emoji} `:""}${s()}`;break}case"code":{a=`\`\`\`${o.language||""}
|
|
2
|
+
${s()}
|
|
3
|
+
\`\`\``;break}case"divider":a="---";break;case"child_page":a=`[child page: ${o.title||""}]`;break;case"child_database":a=`[child database: ${o.title||""}]`;break;case"bookmark":case"embed":case"link_preview":a=o.url?`<${o.url}>`:"";break;case"equation":a=o.expression?`$${o.expression}$`:"";break;case"table":case"column_list":case"column":a="";break;case"table_row":{let c=(o.cells||[]).map(l=>g(l).trim());a=`${r}| ${c.join(" | ")} |`;break}default:a=s();break}let d=[];return a&&a.trim()&&d.push(a),t&&t.trim()&&d.push(t),d.join(`
|
|
4
|
+
`)}async function A(i,e,t){let n=[],o,r=0;do{if(t.used>=h)break;let s=new URLSearchParams({page_size:"100"});o&&s.set("start_cursor",o);let a=await p(`/blocks/${i}/children?${s.toString()}`),d=Array.isArray(a.results)?a.results:[];for(let c of d){let l="";c.has_children&&(l=await A(c.id,e+1,t));let m=M(c,e,l);if(m&&(n.push(m),t.used+=m.length+1),t.used>=h)break}o=a.has_more?a.next_cursor:void 0,r+=1}while(o&&r<D);return n.join(`
|
|
5
|
+
`)}function w(i){let e=i?.properties||{};for(let t of Object.values(e))if(t?.type==="title"){let n=g(t.title).trim();if(n)return n}return""}function f(i){let e=String(i??"");if(!e)return[{type:"text",text:{content:""}}];let t=[];for(let n=0;n<e.length;n+=2e3)t.push({type:"text",text:{content:e.slice(n,n+2e3)}});return t}function G(i){return{id:i?.id||"",discussionId:i?.discussion_id||"",text:g(i?.rich_text).trim(),author:i?.created_by?.id||"",createdTime:i?.created_time||""}}function F(i){if(!i||!i.type)return"";switch(i.type){case"title":return g(i.title).trim();case"rich_text":return g(i.rich_text).trim();case"number":return i.number==null?"":String(i.number);case"select":return i.select?.name||"";case"status":return i.status?.name||"";case"multi_select":return(i.multi_select||[]).map(t=>t.name).join(", ");case"checkbox":return i.checkbox?"true":"false";case"url":return i.url||"";case"email":return i.email||"";case"phone_number":return i.phone_number||"";case"date":return i.date?.start||"";case"people":return(i.people||[]).map(t=>t.name||t.id).join(", ");default:return""}}function k(i){return`https://www.notion.so/${String(i||"").replace(/-/g,"")}`}function z(i){let e=String(i??"").replace(/\r\n/g,`
|
|
6
|
+
`),t=[];for(let n of e.split(`
|
|
7
|
+
`)){let o=n.replace(/\s+$/,"");if(!o.trim())continue;let r=/^(#{1,3})\s+(.*)$/.exec(o),s=/^\s*[-*]\s+(.*)$/.exec(o),a=/^\s*\d+[.)]\s+(.*)$/.exec(o),d,c;r?(d=`heading_${r[1].length}`,c=r[2]):s?(d="bulleted_list_item",c=s[1]):a?(d="numbered_list_item",c=a[1]):(d="paragraph",c=o),t.push({object:"block",type:d,[d]:{rich_text:f(c)}})}return t}function x(i){return Array.isArray(i?.blocks)&&i.blocks.length?i.blocks.slice(0,N):typeof i?.markdown=="string"&&i.markdown.trim()?z(i.markdown).slice(0,N):null}async function R(i,e){for(let t=0;t<e.length;t+=b)await p(`/blocks/${i}/children`,{method:"PATCH",body:{children:e.slice(t,t+b)}})}function H(i){let e=typeof i=="string"?i.trim():"";if(!e)throw new Error("imagePath is required");if(!P(e)||!S(e).isFile())throw new Error(`imagePath not found (or not a file): ${e}`);if(!/\.(png|jpe?g)$/i.test(e))throw new Error("imagePath must be a .png or .jpg/.jpeg file");let t=L(e);if(t.length>J)throw new Error(`image is ${(t.length/(1024*1024)).toFixed(1)}MB \u2014 max 20MB (Notion single_part upload cap)`);return t}async function K(i){let e=H(i),t=U(i.trim()),n=/\.png$/i.test(t)?"image/png":"image/jpeg",r=(await p("/file_uploads",{method:"POST",body:{mode:"single_part",filename:t}}))?.id;if(!r)throw new Error("Notion file upload create returned no id");let s=new FormData;return s.set("file",new Blob([e],{type:n}),t),await p(`/file_uploads/${r}/send`,{method:"POST",formData:s}),r}var te={id:"notion",serverName:"notion",allowedTools:["mcp__notion__*"],requiresIntegration:y.NOTION,description:"Notion \u2014 read pages/databases as context + create pages, append blocks, and insert images",promptFragment:`## Notion (connected)
|
|
8
|
+
You can read Notion content as context AND write to Notion (create pages, append blocks, insert images).
|
|
7
9
|
- 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
10
|
- 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.
|
|
11
|
+
- notion_create_page: create a page under a parent page ({ parentPageId, title, markdown }) or in a database ({ databaseId, title, markdown }) \u2014 one parent is required. Body from markdown (#/##/### headings, - bullets, 1. ordered) or raw Notion blocks. Returns { ok, pageId, url } \u2014 share the url.
|
|
12
|
+
- notion_append_blocks: append markdown (or raw blocks) to the end of an existing page \u2014 pass { pageId, markdown }. Returns { ok, pageId, url }.
|
|
13
|
+
- notion_insert_image: append an image block to a page. Pass { pageId, imagePath } for a LOCAL png/jpg file (\u226420MB, uploaded via Notion's File Upload API) or { pageId, imageUrl } for an external, publicly reachable image URL. Optional caption. Returns { ok, pageId, url }.
|
|
9
14
|
- 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
15
|
- 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
|
|
16
|
+
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" / "cannot deliver to Notion" and continue.`,resolve(){let i=q();return i?{type:"stdio",command:"node",args:[i,"../dist/notion.js","notionSkill"],env:{},description:this.description,alwaysLoad:!0}:null},async handleToolCall(i,e){try{switch(i){case"notion_get_page":{let t=e?.pageId||e?.page||e?.url||e?.id,n=u(t);if(!n)return JSON.stringify({ok:!1,error:"A valid Notion page id or URL is required"});let o=await p(`/pages/${n}`),r=w(o),s=o?.url||`https://www.notion.so/${n.replace(/-/g,"")}`,d=await A(n,0,{used:0}),c=!1;return d.length>h&&(d=d.slice(0,h),c=!0),JSON.stringify({ok:!0,id:n,title:r,url:s,text:d,...c?{truncated:!0}:{}})}case"notion_query_database":{let t=e?.databaseId||e?.database||e?.url||e?.id,n=u(t);if(!n)return JSON.stringify({ok:!1,error:"A valid Notion database id or URL is required"});let r={page_size:Math.max(1,Math.min(Number(e?.maxResults)||I,I))};e?.filter&&typeof e.filter=="object"&&(r.filter=e.filter);let s=await p(`/databases/${n}/query`,{method:"POST",body:r}),d=(Array.isArray(s.results)?s.results:[]).map(c=>{let l={};for(let[m,O]of Object.entries(c.properties||{})){let _=F(O);_&&(l[m]=_)}return{id:c.id,title:w(c),url:c.url||`https://www.notion.so/${String(c.id||"").replace(/-/g,"")}`,props:l}});return JSON.stringify({ok:!0,id:n,count:d.length,hasMore:!!s.has_more,rows:d})}case"notion_create_page":{let t=typeof e?.title=="string"&&e.title.trim()?e.title.trim():null;if(!t)return JSON.stringify({ok:!1,error:"title is required"});let n=e?.databaseId?u(e.databaseId):null,o=e?.parentPageId?u(e.parentPageId):u(e?.parent||e?.pageId);if(!n&&!o)return JSON.stringify({ok:!1,error:"A valid parentPageId or databaseId is required"});let r=n?{database_id:n}:{page_id:o},s={title:{title:f(t)}},a=x(e)||[],d=a.slice(0,b),c=await p("/pages",{method:"POST",body:{parent:r,properties:s,...d.length?{children:d}:{}}}),l=c?.id;if(!l)return JSON.stringify({ok:!1,error:"Notion page create returned no id"});let m=a.slice(b);return m.length&&await R(l,m),JSON.stringify({ok:!0,pageId:l,url:c?.url||k(l)})}case"notion_append_blocks":{let t=u(e?.pageId||e?.blockId||e?.url||e?.id);if(!t)return JSON.stringify({ok:!1,error:"A valid Notion page id or URL is required"});let n=x(e);return!n||!n.length?JSON.stringify({ok:!1,error:"markdown or blocks content is required"}):(await R(t,n),JSON.stringify({ok:!0,pageId:t,url:k(t)}))}case"notion_insert_image":{let t=u(e?.pageId||e?.url||e?.id);if(!t)return JSON.stringify({ok:!1,error:"A valid Notion page id or URL is required"});let n=typeof e?.caption=="string"&&e.caption.trim()?f(e.caption.trim()):null,o,r;if(typeof e?.imagePath=="string"&&e.imagePath.trim())r=await K(e.imagePath),o={type:"file_upload",file_upload:{id:r}};else if(typeof e?.imageUrl=="string"&&e.imageUrl.trim())o={type:"external",external:{url:e.imageUrl.trim()}};else return JSON.stringify({ok:!1,error:"imagePath (local png/jpg) or imageUrl is required"});return n&&(o.caption=n),await p(`/blocks/${t}/children`,{method:"PATCH",body:{children:[{object:"block",type:"image",image:o}]}}),JSON.stringify({ok:!0,pageId:t,url:k(t),...r?{fileUploadId:r}:{}})}case"notion_list_comments":{let t=e?.blockId||e?.pageId||e?.block||e?.page||e?.url||e?.id,n=u(t);if(!n)return JSON.stringify({ok:!1,error:"A valid Notion page/block id or URL is required"});let o=new URLSearchParams({block_id:n,page_size:"100"}),r=await p(`/comments?${o.toString()}`),a=(Array.isArray(r.results)?r.results:[]).map(G);return JSON.stringify({ok:!0,id:n,count:a.length,comments:a})}case"notion_add_comment":{let t=typeof e?.text=="string"?e.text:typeof e?.body=="string"?e.body:"";if(!t||!t.trim())return JSON.stringify({ok:!1,error:"text is required"});let n=e?.discussionId||e?.discussion_id||null,o;if(n)o={discussion_id:String(n),rich_text:f(t)};else{let s=e?.pageId||e?.page||e?.url||e?.id,a=u(s);if(!a)return JSON.stringify({ok:!1,error:"Either discussionId (to reply) or a valid pageId (to start a comment) is required"});o={parent:{page_id:a},rich_text:f(t)}}let r=await p("/comments",{method:"POST",body:o});return JSON.stringify({ok:!0,id:r?.id||"",discussionId:r?.discussion_id||n||""})}default:return JSON.stringify({ok:!1,error:`Unknown tool: ${i}`})}}catch(t){return JSON.stringify({ok:!1,error:t.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_create_page",description:"Create a new Notion page under a parent page (parentPageId) OR in a database (databaseId) \u2014 exactly one parent is required. Body from markdown (#/##/### headings, - bullets, 1. ordered lists; inline marks kept as literal text) or raw Notion block objects. Long bodies are chunked automatically (Notion caps 100 blocks/request). Returns { ok, pageId, url } \u2014 share the url with the user.",input_schema:{type:"object",properties:{parentPageId:{type:"string",description:"Parent PAGE id/URL to create the page under (used when databaseId is absent)."},databaseId:{type:"string",description:"Parent DATABASE id/URL to create the page in (title goes into the title property)."},title:{type:"string",description:"Page title."},markdown:{type:"string",description:"Page body as markdown (preferred)."},blocks:{type:"array",description:"Raw Notion block objects (advanced; used instead of markdown, max 500).",items:{type:"object",additionalProperties:!0}}},required:["title"]}},{name:"notion_append_blocks",description:"Append markdown (or raw Notion blocks) to the END of an existing Notion page. Accepts a page id or full Notion URL. Chunks automatically at Notion's 100-blocks-per-request cap. Returns { ok, pageId, url }.",input_schema:{type:"object",properties:{pageId:{type:"string",description:"Notion page id (dashed UUID or 32-char) OR a full Notion page URL."},markdown:{type:"string",description:"Content to append, as markdown (preferred)."},blocks:{type:"array",description:"Raw Notion block objects (advanced; used instead of markdown, max 500).",items:{type:"object",additionalProperties:!0}}},required:["pageId"]}},{name:"notion_insert_image",description:"Append an image block to a Notion page. Pass imagePath for a LOCAL .png/.jpg file (max 20MB \u2014 uploaded via Notion's File Upload API, stored by Notion) or imageUrl for an external publicly-reachable image URL. Optional caption. Returns { ok, pageId, url }.",input_schema:{type:"object",properties:{pageId:{type:"string",description:"Notion page id (dashed UUID or 32-char) OR a full Notion page URL."},imagePath:{type:"string",description:"Local filesystem path to a .png or .jpg/.jpeg image (max 20MB). Preferred for locally rendered charts."},imageUrl:{type:"string",description:"External image URL (must be publicly reachable; used when imagePath is absent)."},caption:{type:"string",description:"Optional image caption."}},required:["pageId"]}},{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{z as markdownToNotionBlocks,p as notionApi,te as notionSkill,u as parseNotionId};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zibby/skills",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.73",
|
|
4
4
|
"description": "Built-in skill definitions for the Zibby agent-workflow framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"files": [
|
|
105
105
|
"dist/",
|
|
106
106
|
"bin/",
|
|
107
|
+
"assets/",
|
|
107
108
|
"docs/",
|
|
108
109
|
"README.md",
|
|
109
110
|
"LICENSE"
|
|
@@ -113,7 +114,9 @@
|
|
|
113
114
|
},
|
|
114
115
|
"dependencies": {
|
|
115
116
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
117
|
+
"@resvg/resvg-js": "^2.6.2",
|
|
116
118
|
"@zibby/agent-workflow": "^0.4.0",
|
|
119
|
+
"echarts": "^6.1.0",
|
|
117
120
|
"mem0ai": "npm:@zibby/mem0ai@^3.0.5",
|
|
118
121
|
"zod": "^3.23.0 || ^4.0.0"
|
|
119
122
|
},
|
package/dist/report.d.ts
CHANGED
|
@@ -48,6 +48,30 @@ export function reportToNotionBlocks(report: z.infer<typeof reportObjectSchema>)
|
|
|
48
48
|
title: string;
|
|
49
49
|
icon?: string;
|
|
50
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Convert a report-object → a single markdown string.
|
|
53
|
+
*
|
|
54
|
+
* This is the SHARED path for the document channels (Google Docs / Lark
|
|
55
|
+
* Docs / Notion via their create/append tools, which all accept markdown):
|
|
56
|
+
* one renderer, three destinations, each destination's own
|
|
57
|
+
* markdown-to-native converter does the final mapping. Layout mirrors the
|
|
58
|
+
* chat-card renderers 1:1 so a report reads the same everywhere:
|
|
59
|
+
* - title as `#`, subtitle as a plain line under it
|
|
60
|
+
* - headline: bold primary + delta arrow + severity emoji + summary
|
|
61
|
+
* - trend: fenced code block with the same unicodeBar lines
|
|
62
|
+
* - table: a real markdown pipe table
|
|
63
|
+
* - callouts: severity-emoji bullets
|
|
64
|
+
* - breakdown: bold-label bullets
|
|
65
|
+
* - paragraph: text as-is
|
|
66
|
+
* - footer: markdown links
|
|
67
|
+
*
|
|
68
|
+
* Pure function: input → output, no I/O. Throws on invalid input
|
|
69
|
+
* (zod parse error) — same contract as the other renderers.
|
|
70
|
+
*
|
|
71
|
+
* @param {z.infer<typeof reportObjectSchema>} report
|
|
72
|
+
* @returns {string} full markdown document
|
|
73
|
+
*/
|
|
74
|
+
export function reportToMarkdown(report: z.infer<typeof reportObjectSchema>): string;
|
|
51
75
|
export const SEVERITIES: readonly ["ok", "info", "warn", "critical"];
|
|
52
76
|
export const reportObjectSchema: z.ZodObject<{
|
|
53
77
|
title: z.ZodString;
|