@zibby/skills 2.0.5 → 2.0.7
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/artifact.js +7 -7
- package/dist/chat-notify.js +4 -4
- package/dist/chatProgress.js +4 -4
- package/dist/datasetStore.js +2 -2
- package/dist/discord.js +3 -3
- package/dist/figma.js +2 -2
- package/dist/git-write.js +9 -9
- package/dist/github.js +5 -5
- package/dist/gitlab.js +5 -5
- package/dist/googleDocs.js +9 -9
- package/dist/hubspot.js +1 -1
- package/dist/index.js +179 -181
- package/dist/jira.d.ts +19 -9
- package/dist/jira.js +22 -20
- package/dist/kvMemory.js +2 -2
- package/dist/lark.js +2 -2
- package/dist/larkAttendance.js +1 -1
- package/dist/larkDocs.js +3 -3
- package/dist/lib/http-deadline.d.ts +117 -0
- package/dist/lib/http-deadline.js +1 -0
- package/dist/lib/markup.d.ts +158 -0
- package/dist/lib/markup.js +22 -0
- package/dist/linear.js +15 -15
- package/dist/linkedin.js +2 -2
- package/dist/llm-billing.js +1 -1
- package/dist/notion.js +7 -7
- package/dist/opendesign.js +2 -2
- package/dist/package.json +6 -5
- package/dist/report.d.ts +42 -42
- package/dist/review.js +4 -4
- package/dist/reviewMemoryIo.js +1 -1
- package/dist/sentry.js +2 -2
- package/dist/skill-installer.js +3 -3
- package/dist/slack.js +2 -2
- package/dist/trackers/github-adapter.js +5 -5
- package/dist/trackers/index.js +46 -44
- package/dist/trackers/jira-adapter.js +24 -22
- package/dist/trackers/linear-adapter.js +19 -19
- package/dist/trackers/plane-adapter.js +1 -1
- package/dist/triggerAgent.js +1 -1
- package/dist/vikunja.d.ts +8 -1
- package/dist/vikunja.js +22 -7
- package/docs/templates/catalog-metadata.md +1 -1
- package/package.json +6 -5
package/dist/googleDocs.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
`);if(!t.trim())return{requests:[],endIndex:e};let
|
|
3
|
-
`),
|
|
4
|
-
`,
|
|
1
|
+
import{existsSync as A,statSync as $,readFileSync as C}from"fs";import{fileURLToPath as U}from"url";import{basename as j,dirname as K,resolve as F}from"path";import{resolveIntegrationToken as J,clearTokenCache as q}from"@zibby/core/backend-client.js";var O=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",LARK_DOCS:"lark_docs",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",VIKUNJA:"vikunja",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),ie=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 Chat",connectPath:"/integrations?provider=lark"},lark_docs:{id:"lark_docs",name:"Lark App",connectPath:"/integrations?provider=lark_docs"},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"},vikunja:{id:"vikunja",name:"Vikunja",connectPath:"/integrations?provider=vikunja"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},hubspot:{id:"hubspot",name:"HubSpot",connectPath:"/integrations?provider=hubspot"},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"}});var b={api:{knob:"SKILL_API_TIMEOUT_MS",fallback:3e4},transfer:{knob:"SKILL_TRANSFER_TIMEOUT_MS",fallback:12e4},job:{knob:"SKILL_JOB_TIMEOUT_MS",fallback:3e5}};function R(n,e,t=process.env){let o=Number(t?.[n]);return Number.isFinite(o)&&o>0?Math.min(6e5,Math.max(1e3,Math.floor(o))):e}function D(n="api",e=process.env){let t=b[n]||b.api;return R(t.knob,t.fallback,e)}function M(n){return n?.name==="TimeoutError"||n?.name==="AbortError"}function G(n){try{return new URL(String(n?.url??n)).host||"unknown host"}catch{return"unknown host"}}function B(n,e){if(!n)return e;let t=new AbortController,o=a=>{t.signal.aborted||t.abort(a)},r=()=>o(n.reason),i=()=>o(e.reason);return t.signal.addEventListener("abort",()=>{n.removeEventListener("abort",r),e.removeEventListener("abort",i)},{once:!0}),n.aborted?o(n.reason):e.aborted?o(e.reason):(n.addEventListener("abort",r,{once:!0}),e.addEventListener("abort",i,{once:!0})),t.signal}async function E(n,e={},t={}){let o=t.kind||"api",r=(b[o]||b.api).knob,i=t.timeoutMs?Math.min(6e5,Math.max(1e3,Math.floor(t.timeoutMs))):D(o),a=e?.signal;if(a?.aborted)throw a.reason??new DOMException("This operation was aborted","AbortError");let l=AbortSignal.timeout(i),c=B(a,l);try{return await fetch(n,{...e,signal:c})}catch(d){throw l.aborted&&M(d)?new Error(`${t.what||"request"} TIMED OUT after ${i}ms against ${G(n)} (${r})`):d}}function Y(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let n=K(U(import.meta.url)),e=F(n,"..","bin","mcp-skill.mjs");return A(e)?e:null}var h="https://docs.googleapis.com/v1",x="https://www.googleapis.com/drive/v3",H="https://www.googleapis.com/upload/drive/v3",Z=5*1024*1024;function z(){let n=String(process.env.ZIBBY_INJECTED_GOOGLE_TOKEN||"").trim();if(!n)return null;let e=String(process.env.ZIBBY_INJECTED_GOOGLE_EMAIL||"").trim();return{token:n,email:e}}function V(){return String(process.env.ZIBBY_SENDER_IS_NON_OWNER||"").trim()==="1"}function W(){return String(process.env.ZIBBY_CHAT_STRICT_PERSONAL||"").trim()==="1"}var X="You haven't connected your own Google account \u2014 connect it at https://studio.zibby.dev/integrations (Google Docs). For privacy, I can't use anyone else's Google (including the project owner's) on your behalf.",w=2e4,Q=25;function T(n){if(!n||typeof n!="string")return null;let e=n.trim(),t=e.match(/\/document\/(?:u\/\d+\/)?d\/([a-zA-Z0-9_-]+)/);return t?t[1]:/^[a-zA-Z0-9_-]{20,}$/.test(e)?e:null}async function ee(){let n,e=z();if(e)n=e.token;else{if(W()||V())throw new Error(X);({token:n}=await J("google"))}if(typeof n!="string"||!n)throw new Error(`Invalid google token type: ${typeof n}`);return n}async function p(n,e={}){let t=async()=>{let o=await ee(),r=await E(n,{method:e.method||"GET",headers:{Authorization:`Bearer ${o}`,Accept:"application/json",...e.rawBody&&e.contentType?{"Content-Type":e.contentType}:e.body?{"Content-Type":"application/json"}:{},...e.headers},body:e.rawBody?e.rawBody:e.body?JSON.stringify(e.body):void 0},{kind:e.rawBody?"transfer":"api",what:`Google ${e.method||"GET"} ${String(n).split("?")[0]}`});if(!r.ok){let a=await r.text().catch(()=>"");throw new Error(`Google API ${r.status}: ${a.slice(0,300)}`)}let i=await r.text().catch(()=>"");if(!i||!i.trim())return{};try{return JSON.parse(i)}catch{return{raw:i}}};try{return await t()}catch(o){let r=String(o?.message||o||"").toLowerCase();if(!(r.includes("token")||r.includes("401")||r.includes("unauthorized")))throw o;return q("google"),t()}}function te(n){let e=[],t="",o=0;for(;o<n.length;){let r=/^\[([^\]]+)\]\(([^)\s]+)\)/.exec(n.slice(o));if(r){e.push({start:t.length,end:t.length+r[1].length,link:r[2]}),t+=r[1],o+=r[0].length;continue}let i=/^\*\*([^*]+)\*\*/.exec(n.slice(o));if(i){e.push({start:t.length,end:t.length+i[1].length,bold:!0}),t+=i[1],o+=i[0].length;continue}let a=/^`([^`]+)`/.exec(n.slice(o));if(a){e.push({start:t.length,end:t.length+a[1].length,code:!0}),t+=a[1],o+=a[0].length;continue}t+=n[o],o+=1}return{text:t,styles:e}}function N(n,e){let t=String(n??"").replace(/\r\n/g,`
|
|
2
|
+
`);if(!t.trim())return{requests:[],endIndex:e};let o=t.split(`
|
|
3
|
+
`),r="",i=[],a=[];for(let s of o){let u=s,_=null,I=null,f=/^(#{1,3})\s+(.*)$/.exec(u),g=/^\s*[-*]\s+(.*)$/.exec(u),m=/^\s*\d+[.)]\s+(.*)$/.exec(u);f?(_=`HEADING_${f[1].length}`,u=f[2]):g?(I="BULLET_DISC_CIRCLE_SQUARE",u=g[1]):m&&(I="NUMBERED_DECIMAL_ALPHA_ROMAN",u=m[1]);let{text:v,styles:P}=te(u),k=e+r.length;for(let S of P)a.push({...S,start:k+S.start,end:k+S.end});r+=`${v}
|
|
4
|
+
`,i.push({start:k,end:e+r.length,named:_,bullet:I})}if(!r)return{requests:[],endIndex:e};let l=[{insertText:{location:{index:e},text:r}}];for(let s of i)s.named&&l.push({updateParagraphStyle:{range:{startIndex:s.start,endIndex:s.end},paragraphStyle:{namedStyleType:s.named},fields:"namedStyleType"}});let c=null,d=()=>{c&&(l.push({createParagraphBullets:{range:{startIndex:c.start,endIndex:c.end},bulletPreset:c.preset}}),c=null)};for(let s of i)s.bullet?c&&c.preset===s.bullet?c.end=s.end:(d(),c={start:s.start,end:s.end,preset:s.bullet}):d();d();for(let s of a)s.end<=s.start||(s.bold?l.push({updateTextStyle:{range:{startIndex:s.start,endIndex:s.end},textStyle:{bold:!0},fields:"bold"}}):s.link?l.push({updateTextStyle:{range:{startIndex:s.start,endIndex:s.end},textStyle:{link:{url:s.link}},fields:"link"}}):s.code&&l.push({updateTextStyle:{range:{startIndex:s.start,endIndex:s.end},textStyle:{weightedFontFamily:{fontFamily:"Courier New"}},fields:"weightedFontFamily"}}));return{requests:l,endIndex:e+r.length}}function ne(n){let e="",t=o=>{for(let r of Array.isArray(o)?o:[]){if(e.length>=w)return;if(r.paragraph)for(let i of r.paragraph.elements||[])e+=i?.textRun?.content||"";else if(r.table)for(let i of r.table.tableRows||[])for(let a of i.tableCells||[])t(a.content);else r.tableOfContents&&t(r.tableOfContents.content)}};return t(n?.content),e.slice(0,w)}var y=n=>`https://docs.google.com/document/d/${n}/edit`;function oe(n){let e=typeof n=="string"?n.trim():"";if(!e)throw new Error("imagePath is required");if(!A(e)||!$(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=C(e);if(t.length>Z)throw new Error(`image is ${(t.length/(1024*1024)).toFixed(1)}MB \u2014 max 5MB (Drive multipart upload cap)`);return{bytes:t,fileName:j(e),mimeType:/\.png$/i.test(e)?"image/png":"image/jpeg"}}function re(n,e,t){let o=`zibby-gdocs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;return{rawBody:Buffer.concat([Buffer.from(`--${o}\r
|
|
5
5
|
Content-Type: application/json; charset=UTF-8\r
|
|
6
6
|
\r
|
|
7
7
|
${JSON.stringify(n)}\r
|
|
8
|
-
--${
|
|
8
|
+
--${o}\r
|
|
9
9
|
Content-Type: ${t}\r
|
|
10
10
|
\r
|
|
11
11
|
`,"utf8"),e,Buffer.from(`\r
|
|
12
|
-
--${
|
|
13
|
-
`,"utf8")]),contentType:`multipart/related; boundary=${
|
|
12
|
+
--${o}--\r
|
|
13
|
+
`,"utf8")]),contentType:`multipart/related; boundary=${o}`}}var L=n=>{let e=typeof n?.markdown=="string"?n.markdown:null,t=typeof n?.text=="string"?n.text:null;return e??t},me={id:"google-docs",callsBackend:!0,serverName:"gdocs",allowedTools:["mcp__gdocs__*"],requiresIntegration:O.GOOGLE,description:"Google Docs \u2014 create, append to, insert images into, and read Google Docs (drive.file scoped)",promptFragment:`## Google Docs
|
|
14
14
|
You can create and edit Google Docs for the user. IMPORTANT visibility caveat: the integration uses Google's per-file drive.file scope, so you can only see docs this app CREATED (or the user explicitly picked) \u2014 not the user's whole Drive.
|
|
15
15
|
Docs access is PER-USER: each teammate connects their OWN Google account (Integrations \u2192 Google Docs). In shared-chat contexts the runtime routes these tools to the SENDER's own Google; a teammate who hasn't connected their own Google gets { ok:false } with connect instructions \u2014 for privacy the project owner's Google is NEVER used on someone else's behalf. Relay those instructions rather than retrying.
|
|
16
16
|
- gdocs_create_doc: create a new Google Doc from a title + markdown (headings/bold/bullets/links supported) or plain text; returns { documentId, url }. Share the url with the user.
|
|
@@ -18,5 +18,5 @@ Docs access is PER-USER: each teammate connects their OWN Google account (Integr
|
|
|
18
18
|
- gdocs_insert_image: append a LOCAL image file (png/jpg, \u22645MB) to the end of a doc \u2014 pass { documentId, imagePath, width?, height? } (width/height in PT, optional). The image is uploaded to the user's Drive and made link-readable (anyone with the link) so Docs can render it. Returns { ok, documentId, fileId, url }.
|
|
19
19
|
- gdocs_get: read a doc back as plain text (works for app-created/user-picked docs only; to read an arbitrary pre-existing doc the user must PICK it once first via the Google Picker \u2014 drive.file has no access to un-picked files).
|
|
20
20
|
- gdocs_list_created: list the Google Docs visible to this app (drive.file \u2192 only docs it created or the user picked).
|
|
21
|
-
These tools return { ok:false, error } on failure \u2014 treat an unavailable Google connection as "cannot deliver to Docs" and report it rather than blocking the task.`,resolve(){let n=
|
|
22
|
-
`}}),s=
|
|
21
|
+
These tools return { ok:false, error } on failure \u2014 treat an unavailable Google connection as "cannot deliver to Docs" and report it rather than blocking the task.`,resolve(){let n=Y();if(!n)return null;let e={};for(let t of["PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV","ZIBBY_INJECTED_GOOGLE_TOKEN","ZIBBY_INJECTED_GOOGLE_EMAIL","ZIBBY_SENDER_IS_NON_OWNER","ZIBBY_CHAT_STRICT_PERSONAL"])process.env[t]&&(e[t]=process.env[t]);return{type:"stdio",command:"node",args:[n,"../dist/googleDocs.js","googleDocsSkill"],env:e,description:this.description,alwaysLoad:!0}},async handleToolCall(n,e){try{switch(n){case"gdocs_create_doc":{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 r=(await p(`${h}/documents`,{method:"POST",body:{title:t}}))?.documentId;if(!r)return JSON.stringify({ok:!1,error:"Google Docs create returned no documentId"});let i=L(e);if(i&&i.trim()){let{requests:a}=N(i,1);a.length&&await p(`${h}/documents/${r}:batchUpdate`,{method:"POST",body:{requests:a}})}return JSON.stringify({ok:!0,documentId:r,title:t,url:y(r)})}case"gdocs_append":{let t=T(e?.documentId||e?.url||e?.id);if(!t)return JSON.stringify({ok:!1,error:"A valid Google Docs documentId or URL is required"});let o=L(e);if(!o||!o.trim())return JSON.stringify({ok:!1,error:"markdown or text content is required"});let i=(await p(`${h}/documents/${t}`))?.body,a=Array.isArray(i?.content)?i.content:[],l=a.length&&a[a.length-1].endIndex||2,c=Math.max(1,l-1),d=[],s=c;c>1&&(d.push({insertText:{location:{index:c},text:`
|
|
22
|
+
`}}),s=c+1);let u=N(o,s);return d.push(...u.requests),await p(`${h}/documents/${t}:batchUpdate`,{method:"POST",body:{requests:d}}),JSON.stringify({ok:!0,documentId:t,url:y(t)})}case"gdocs_insert_image":{let t=T(e?.documentId||e?.url||e?.id);if(!t)return JSON.stringify({ok:!1,error:"A valid Google Docs documentId or URL is required"});if(!e?.imagePath||typeof e.imagePath!="string"||!e.imagePath.trim())return JSON.stringify({ok:!1,error:"imagePath is required"});let{bytes:o,fileName:r,mimeType:i}=oe(e.imagePath),{rawBody:a,contentType:l}=re({name:r,mimeType:i},o,i),d=(await p(`${H}/files?uploadType=multipart&fields=id`,{method:"POST",rawBody:a,contentType:l}))?.id;if(!d)return JSON.stringify({ok:!1,error:"Drive upload returned no file id"});await p(`${x}/files/${d}/permissions`,{method:"POST",body:{role:"reader",type:"anyone"}});let s=await p(`${h}/documents/${t}`),u=Array.isArray(s?.body?.content)?s.body.content:[],_=u.length&&u[u.length-1].endIndex||2,f={location:{index:Math.max(1,_-1)},uri:`https://drive.google.com/uc?export=download&id=${d}`},g=Number(e?.width),m=Number(e?.height);return(Number.isFinite(g)&&g>0||Number.isFinite(m)&&m>0)&&(f.objectSize={...Number.isFinite(g)&&g>0?{width:{magnitude:g,unit:"PT"}}:{},...Number.isFinite(m)&&m>0?{height:{magnitude:m,unit:"PT"}}:{}}),await p(`${h}/documents/${t}:batchUpdate`,{method:"POST",body:{requests:[{insertInlineImage:f}]}}),JSON.stringify({ok:!0,documentId:t,fileId:d,url:y(t)})}case"gdocs_get":{let t=T(e?.documentId||e?.url||e?.id);if(!t)return JSON.stringify({ok:!1,error:"A valid Google Docs documentId or URL is required"});let o=await p(`${h}/documents/${t}`),r=ne(o?.body);return JSON.stringify({ok:!0,documentId:t,title:o?.title||"",url:y(t),text:r,...r.length>=w?{truncated:!0}:{}})}case"gdocs_list_created":{let t=new URLSearchParams({q:"'me' in owners and mimeType='application/vnd.google-apps.document' and trashed=false",fields:"files(id,name,modifiedTime,webViewLink)",pageSize:String(Q),orderBy:"modifiedTime desc"}),o=await p(`${x}/files?${t.toString()}`),r=(Array.isArray(o?.files)?o.files:[]).map(i=>({documentId:i.id,title:i.name,modifiedTime:i.modifiedTime,url:i.webViewLink||y(i.id)}));return JSON.stringify({ok:!0,count:r.length,files:r})}default:return JSON.stringify({ok:!1,error:`Unknown tool: ${n}`})}}catch(t){return JSON.stringify({ok:!1,error:t.message})}},tools:[{name:"gdocs_create_doc",description:"Create a new Google Doc with a title and optional content (markdown: #/##/### headings, - bullets, 1. numbered lists, **bold**, [links](url), `code`; 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)."}},required:["title"]}},{name:"gdocs_append",description:"Append markdown/text content to the END of an existing Google Doc. Only works on docs this app created or the user explicitly picked (drive.file scope). Accepts a documentId or a full docs.google.com URL. Returns { ok, documentId, url }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Google Docs documentId OR a full https://docs.google.com/document/d/... 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:"gdocs_insert_image",description:"Append a LOCAL image file (png/jpg, max 5MB) to the END of an existing Google Doc. The image is uploaded to the user's Drive, made link-readable (role reader / type anyone \u2014 required: the Docs API only renders publicly fetchable image URIs, <2KB URI length, image <50MB and <25 megapixels), then inserted inline. Optional width/height in points (PT). Returns { ok, documentId, fileId, url }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Google Docs documentId OR a full https://docs.google.com/document/d/... URL."},imagePath:{type:"string",description:"Local filesystem path to a .png or .jpg/.jpeg image (max 5MB)."},width:{type:"number",description:"Optional display width in points (PT)."},height:{type:"number",description:"Optional display height in points (PT)."}},required:["documentId","imagePath"]}},{name:"gdocs_get",description:"Read a Google Doc back as plain text (truncated to ~20k chars). The drive.file scope grants access ONLY to docs this app created or the user explicitly picked; to read an arbitrary pre-existing doc the user must PICK it once first via the Google Picker (drive.file cannot see un-picked files). Returns { ok, documentId, title, url, text }.",input_schema:{type:"object",properties:{documentId:{type:"string",description:"Google Docs documentId OR a full https://docs.google.com/document/d/... URL."}},required:["documentId"]}},{name:"gdocs_list_created",description:"List the Google Docs visible to this integration, newest first (max 25). NOTE: under the drive.file scope this lists ONLY docs the app created or the user explicitly picked \u2014 it is NOT a full Drive search. Returns { ok, count, files:[{ documentId, title, modifiedTime, url }] }.",input_schema:{type:"object",properties:{}}}]};export{X as NON_OWNER_REFUSAL,W as chatStrictPersonal,ne as extractPlainText,p as googleApi,me as googleDocsSkill,z as injectedGoogleToken,N as markdownToRequests,T as parseDocId,te as parseInlineMarkdown,V as senderIsNonOwner};
|
package/dist/hubspot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as h}from"fs";import{fileURLToPath as g}from"url";import{dirname as f,resolve as _}from"path";import{resolveIntegrationToken as T}from"@zibby/core/backend-client.js";var y=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",LARK_DOCS:"lark_docs",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",VIKUNJA:"vikunja",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),I=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 Chat",connectPath:"/integrations?provider=lark"},lark_docs:{id:"lark_docs",name:"Lark App",connectPath:"/integrations?provider=lark_docs"},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"},vikunja:{id:"vikunja",name:"Vikunja",connectPath:"/integrations?provider=vikunja"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},hubspot:{id:"hubspot",name:"HubSpot",connectPath:"/integrations?provider=hubspot"},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 i=f(g(import.meta.url)),s=_(i,"..","bin","mcp-skill.mjs");return h(s)?s:null}async function p(i,s={}){let{token:e}=await T("hubspot");if(!e)throw new Error("HubSpot not connected \u2014 Connect HubSpot in Integrations.");let t=i.startsWith("https://")?i:`https://api.hubapi.com${i}`,r={Authorization:`Bearer ${e}`,Accept:"application/json",...s.body?{"Content-Type":"application/json"}:{}},o=await fetch(t,{method:s.method||"GET",headers:r,body:s.body?JSON.stringify(s.body):void 0});if(!o.ok){let a=await o.text().catch(()=>""),c=o.status===401||o.status===403?" \u2014 token invalid/expired or missing the required Private App scope for this object":"";throw new Error(`HubSpot API ${o.status}${c}: ${a.slice(0,300)}`)}let n=await o.text().catch(()=>"");if(!n)return{};try{return JSON.parse(n)}catch{return{raw:n}}}function d(i){return typeof i!="string"?null:i.trim()||null}function m(i,s={}){let e=new URLSearchParams;if(i!=null){let r=Array.isArray(i)?i.join(","):String(i);r&&e.set("properties",r)}for(let[r,o]of Object.entries(s))o!=null&&o!==""&&e.set(r,String(o));let t=e.toString();return t?`?${t}`:""}var u="The CRM object type \u2014 one of the common values `contacts`, `companies`, `deals`, `tickets`, `notes`, `tasks`, `feedback_submissions` (customer feedback: NPS/CSAT/CES), or any custom object name/id.",R={id:"hubspot",callsBackend:!0,serverName:"hubspot",allowedTools:["mcp__hubspot__*"],requiresIntegration:y.HUBSPOT,envKeys:["PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV"],description:"HubSpot CRM \u2014 search/read/create/update contacts, companies, deals, tickets, notes and feedback submissions via the HubSpot REST API.",promptFragment:"## HubSpot CRM\nYou have access to the user's HubSpot CRM via the HubSpot REST API (OAuth \u2014 the user connects HubSpot in Integrations; the token is resolved and auto-refreshed for you). The connected app grants the CRM scopes for the objects you touch.\n\nHubSpot's object model is **uniform** \u2014 nearly every tool takes an `objectType` (`contacts`, `companies`, `deals`, `tickets`, `notes`, `tasks`, `feedback_submissions`, or a custom object). Records are `{ id, properties }`; you set/read named properties.\n\n**Before you create/update/search, call `hubspot_list_properties` to learn the valid property names for that object type** (they're not guessable). `feedback_submissions` is where NPS/CSAT/CES customer-feedback survey responses live.\n\n### Identity\n- hubspot_whoami: Confirm the token works \u2014 returns the portal (hub) id, account type, time zone, UI domain.\n\n### Schema\n- hubspot_list_properties: List the defined properties (name, label, type, fieldType) for an objectType. Do this first so you use real property names.\n\n### Read\n- hubspot_search: Search an objectType by full-text `query` OR structured `filters` (array of {propertyName, operator, value}). Returns { total, results:[{id, properties}] }.\n- hubspot_get_object: Fetch one record by id (optionally selecting specific properties).\n- hubspot_list_objects: Page through all records of an objectType (limit + after cursor).\n\n### Write\n- hubspot_create_object: Create a record from a `properties` object.\n- hubspot_update_object: Patch a record's `properties` by id.\n- hubspot_create_note: Convenience \u2014 log a note (hs_note_body) and optionally associate it to a contact/company/deal/ticket.\n- hubspot_associate: Associate two records (fromType/fromId \u2194 toType/toId) with the default association type.",resolve(){let i=j();if(!i)return{command:null,args:[],env:{},description:this.description};let s={};for(let e of this.envKeys)process.env[e]&&(s[e]=process.env[e]);return{type:"stdio",command:"node",args:[i,"../dist/hubspot.js","hubspotSkill"],env:s,description:this.description,alwaysLoad:!0}},async handleToolCall(i,s){try{let e=s||{};switch(i){case"hubspot_whoami":{let t=await p("/account-info/v3/details");return JSON.stringify({portalId:t.portalId,accountType:t.accountType,timeZone:t.timeZone,uiDomain:t.uiDomain,companyCurrency:t.companyCurrency})}case"hubspot_list_properties":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required (e.g. contacts, companies, deals, tickets, feedback_submissions)"});let o=((await p(`/crm/v3/properties/${encodeURIComponent(t)}`)).results||[]).map(n=>({name:n.name,label:n.label,type:n.type,fieldType:n.fieldType}));return JSON.stringify({objectType:t,count:o.length,properties:o})}case"hubspot_search":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});let o={limit:Number.isFinite(Number(e.limit))&&Number(e.limit)>0?Math.trunc(Number(e.limit)):20};e.query&&(o.query=String(e.query)),Array.isArray(e.filters)&&e.filters.length&&(o.filterGroups=[{filters:e.filters}]),e.properties!=null&&(o.properties=Array.isArray(e.properties)?e.properties:String(e.properties).split(",").map(a=>a.trim()).filter(Boolean));let n=await p(`/crm/v3/objects/${encodeURIComponent(t)}/search`,{method:"POST",body:o});return JSON.stringify({total:n.total??(n.results?n.results.length:0),results:(n.results||[]).map(a=>({id:a.id,properties:a.properties}))})}case"hubspot_get_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.id)return JSON.stringify({error:"id is required"});let r=m(e.properties,{associations:e.associations}),o=await p(`/crm/v3/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.id)}${r}`);return JSON.stringify({id:o.id,properties:o.properties,...o.associations?{associations:o.associations}:{}})}case"hubspot_list_objects":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});let r=Number.isFinite(Number(e.limit))&&Number(e.limit)>0?Math.trunc(Number(e.limit)):20,o=m(e.properties,{limit:r,after:e.after}),n=await p(`/crm/v3/objects/${encodeURIComponent(t)}${o}`);return JSON.stringify({results:(n.results||[]).map(a=>({id:a.id,properties:a.properties})),paging:n.paging||null})}case"hubspot_create_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.properties||typeof e.properties!="object"||Array.isArray(e.properties))return JSON.stringify({error:"properties is required (an object of { propertyName: value } \u2014 call hubspot_list_properties first for valid names)"});let r=await p(`/crm/v3/objects/${encodeURIComponent(t)}`,{method:"POST",body:{properties:e.properties}});return JSON.stringify({id:r.id,properties:r.properties})}case"hubspot_update_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.id)return JSON.stringify({error:"id is required"});if(!e.properties||typeof e.properties!="object"||Array.isArray(e.properties))return JSON.stringify({error:"properties is required (an object of { propertyName: value })"});let r=await p(`/crm/v3/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.id)}`,{method:"PATCH",body:{properties:e.properties}});return JSON.stringify({id:r.id,properties:r.properties})}case"hubspot_create_note":{if(!e.body||typeof e.body!="string")return JSON.stringify({error:"body is required (the note text)"});let t=typeof e.timestamp=="string"&&e.timestamp?e.timestamp:null;if(!t)try{t=new Date().toISOString()}catch{t=null}if(!t)return JSON.stringify({error:"timestamp is required (pass an ISO 8601 string, e.g. 2026-01-01T00:00:00.000Z)"});let r=await p("/crm/v3/objects/notes",{method:"POST",body:{properties:{hs_note_body:e.body,hs_timestamp:t}}}),o=r.id,n=[["contacts",e.contactId],["companies",e.companyId],["deals",e.dealId],["tickets",e.ticketId]].filter(([,c])=>c!=null&&c!==""),a=[];for(let[c,l]of n)try{await p(`/crm/v4/objects/notes/${encodeURIComponent(o)}/associations/default/${c}/${encodeURIComponent(l)}`,{method:"PUT"}),a.push({toType:c,toId:String(l)})}catch(b){a.push({toType:c,toId:String(l),error:b.message})}return JSON.stringify({id:o,properties:r.properties,associatedTo:a})}case"hubspot_associate":{let t=d(e.fromType),r=d(e.toType);return!t||!e.fromId||!r||!e.toId?JSON.stringify({error:"fromType, fromId, toType and toId are all required"}):(await p(`/crm/v4/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.fromId)}/associations/default/${encodeURIComponent(r)}/${encodeURIComponent(e.toId)}`,{method:"PUT"}),JSON.stringify({ok:!0}))}default:return JSON.stringify({error:`Unknown tool: ${i}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"hubspot_whoami",description:"Confirm the HubSpot token works: returns the portal (hub) id, account type, time zone and UI domain.",input_schema:{type:"object",properties:{}}},{name:"hubspot_list_properties",description:"List the defined properties (name, label, type, fieldType) for a CRM object type. Call this FIRST so you use valid property names when creating/updating/searching.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u}},required:["objectType"]}},{name:"hubspot_search",description:"Search a CRM object type. Pass a full-text `query` OR structured `filters` (array of {propertyName, operator, value}, e.g. operator EQ/CONTAINS_TOKEN/GT/\u2026). Returns { total, results:[{id, properties}] }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},query:{type:"string",description:"Optional full-text search string."},filters:{type:"array",description:"Optional structured filters (ANDed). Each: { propertyName, operator, value }. Operators: EQ, NEQ, LT, LTE, GT, GTE, CONTAINS_TOKEN, HAS_PROPERTY, IN, \u2026",items:{type:"object",properties:{propertyName:{type:"string"},operator:{type:"string"},value:{type:"string"}}}},properties:{type:"array",items:{type:"string"},description:"Optional: property names to return on each result."},limit:{type:"number",description:"Max results (default 20)."}},required:["objectType"]}},{name:"hubspot_get_object",description:"Fetch one CRM record by id. Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},id:{type:"string",description:"The record id."},properties:{type:"array",items:{type:"string"},description:"Optional: specific property names to return."},associations:{type:"string",description:'Optional: comma-separated object types to also return associations for (e.g. "companies,deals").'}},required:["objectType","id"]}},{name:"hubspot_list_objects",description:"Page through records of a CRM object type. Returns { results, paging } \u2014 pass paging.next.after back as `after` for the next page.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},properties:{type:"array",items:{type:"string"},description:"Optional: property names to return on each record."},limit:{type:"number",description:"Page size (default 20)."},after:{type:"string",description:"Optional paging cursor from a previous response (paging.next.after)."}},required:["objectType"]}},{name:"hubspot_create_object",description:"Create a CRM record. Pass `properties` as an object of { propertyName: value } (call hubspot_list_properties first for valid names). Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},properties:{type:"object",description:"Object of { propertyName: value } to set on the new record."}},required:["objectType","properties"]}},{name:"hubspot_update_object",description:"Update (PATCH) a CRM record by id. Pass `properties` as an object of { propertyName: value }. Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:u},id:{type:"string",description:"The record id to update."},properties:{type:"object",description:"Object of { propertyName: value } to change."}},required:["objectType","id","properties"]}},{name:"hubspot_create_note",description:"Log a note (hs_note_body) and optionally associate it to a contact/company/deal/ticket. Returns { id, associatedTo }.",input_schema:{type:"object",properties:{body:{type:"string",description:"The note text (stored as hs_note_body)."},contactId:{type:"string",description:"Optional: associate the note to this contact id."},companyId:{type:"string",description:"Optional: associate the note to this company id."},dealId:{type:"string",description:"Optional: associate the note to this deal id."},ticketId:{type:"string",description:"Optional: associate the note to this ticket id."},timestamp:{type:"string",description:"Optional ISO 8601 timestamp for the note (defaults to now)."}},required:["body"]}},{name:"hubspot_associate",description:"Associate two CRM records with the default association type (e.g. a contact to a company). Returns { ok:true }.",input_schema:{type:"object",properties:{fromType:{type:"string",description:"Source object type (e.g. contacts)."},fromId:{type:"string",description:"Source record id."},toType:{type:"string",description:"Target object type (e.g. companies)."},toId:{type:"string",description:"Target record id."}},required:["fromType","fromId","toType","toId"]}}]};export{R as hubspotSkill};
|
|
1
|
+
import{existsSync as O}from"fs";import{fileURLToPath as j}from"url";import{dirname as N,resolve as k}from"path";import{resolveIntegrationToken as v}from"@zibby/core/backend-client.js";var m=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",LARK_DOCS:"lark_docs",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",GOOGLE:"google",PLANE:"plane",LINEAR:"linear",VIKUNJA:"vikunja",FIGMA:"figma",HUBSPOT:"hubspot",OPEN_DESIGN:"open_design",LINKEDIN_PERSONAL:"linkedin_personal",LINKEDIN_BUSINESS:"linkedin_business",DISCORD:"discord"}),E=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 Chat",connectPath:"/integrations?provider=lark"},lark_docs:{id:"lark_docs",name:"Lark App",connectPath:"/integrations?provider=lark_docs"},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"},vikunja:{id:"vikunja",name:"Vikunja",connectPath:"/integrations?provider=vikunja"},figma:{id:"figma",name:"Figma",connectPath:"/integrations?provider=figma"},hubspot:{id:"hubspot",name:"HubSpot",connectPath:"/integrations?provider=hubspot"},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"}});var b={api:{knob:"SKILL_API_TIMEOUT_MS",fallback:3e4},transfer:{knob:"SKILL_TRANSFER_TIMEOUT_MS",fallback:12e4},job:{knob:"SKILL_JOB_TIMEOUT_MS",fallback:3e5}};function g(o,i,e=process.env){let t=Number(e?.[o]);return Number.isFinite(t)&&t>0?Math.min(6e5,Math.max(1e3,Math.floor(t))):i}function _(o="api",i=process.env){let e=b[o]||b.api;return g(e.knob,e.fallback,i)}function T(o){return o?.name==="TimeoutError"||o?.name==="AbortError"}function I(o){try{return new URL(String(o?.url??o)).host||"unknown host"}catch{return"unknown host"}}function S(o,i){if(!o)return i;let e=new AbortController,t=s=>{e.signal.aborted||e.abort(s)},n=()=>t(o.reason),r=()=>t(i.reason);return e.signal.addEventListener("abort",()=>{o.removeEventListener("abort",n),i.removeEventListener("abort",r)},{once:!0}),o.aborted?t(o.reason):i.aborted?t(i.reason):(o.addEventListener("abort",n,{once:!0}),i.addEventListener("abort",r,{once:!0})),e.signal}async function y(o,i={},e={}){let t=e.kind||"api",n=(b[t]||b.api).knob,r=e.timeoutMs?Math.min(6e5,Math.max(1e3,Math.floor(e.timeoutMs))):_(t),s=i?.signal;if(s?.aborted)throw s.reason??new DOMException("This operation was aborted","AbortError");let a=AbortSignal.timeout(r),p=S(s,a);try{return await fetch(o,{...i,signal:p})}catch(u){throw a.aborted&&T(u)?new Error(`${e.what||"request"} TIMED OUT after ${r}ms against ${I(o)} (${n})`):u}}function R(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let o=N(j(import.meta.url)),i=k(o,"..","bin","mcp-skill.mjs");return O(i)?i:null}async function c(o,i={}){let{token:e}=await v("hubspot");if(!e)throw new Error("HubSpot not connected \u2014 Connect HubSpot in Integrations.");let t=o.startsWith("https://")?o:`https://api.hubapi.com${o}`,n={Authorization:`Bearer ${e}`,Accept:"application/json",...i.body?{"Content-Type":"application/json"}:{}},r=await y(t,{method:i.method||"GET",headers:n,body:i.body?JSON.stringify(i.body):void 0},{kind:"api",what:`HubSpot ${i.method||"GET"} ${o}`});if(!r.ok){let a=await r.text().catch(()=>""),p=r.status===401||r.status===403?" \u2014 token invalid/expired or missing the required Private App scope for this object":"";throw new Error(`HubSpot API ${r.status}${p}: ${a.slice(0,300)}`)}let s=await r.text().catch(()=>"");if(!s)return{};try{return JSON.parse(s)}catch{return{raw:s}}}function d(o){return typeof o!="string"?null:o.trim()||null}function h(o,i={}){let e=new URLSearchParams;if(o!=null){let n=Array.isArray(o)?o.join(","):String(o);n&&e.set("properties",n)}for(let[n,r]of Object.entries(i))r!=null&&r!==""&&e.set(n,String(r));let t=e.toString();return t?`?${t}`:""}var l="The CRM object type \u2014 one of the common values `contacts`, `companies`, `deals`, `tickets`, `notes`, `tasks`, `feedback_submissions` (customer feedback: NPS/CSAT/CES), or any custom object name/id.",q={id:"hubspot",callsBackend:!0,serverName:"hubspot",allowedTools:["mcp__hubspot__*"],requiresIntegration:m.HUBSPOT,envKeys:["PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV"],description:"HubSpot CRM \u2014 search/read/create/update contacts, companies, deals, tickets, notes and feedback submissions via the HubSpot REST API.",promptFragment:"## HubSpot CRM\nYou have access to the user's HubSpot CRM via the HubSpot REST API (OAuth \u2014 the user connects HubSpot in Integrations; the token is resolved and auto-refreshed for you). The connected app grants the CRM scopes for the objects you touch.\n\nHubSpot's object model is **uniform** \u2014 nearly every tool takes an `objectType` (`contacts`, `companies`, `deals`, `tickets`, `notes`, `tasks`, `feedback_submissions`, or a custom object). Records are `{ id, properties }`; you set/read named properties.\n\n**Before you create/update/search, call `hubspot_list_properties` to learn the valid property names for that object type** (they're not guessable). `feedback_submissions` is where NPS/CSAT/CES customer-feedback survey responses live.\n\n### Identity\n- hubspot_whoami: Confirm the token works \u2014 returns the portal (hub) id, account type, time zone, UI domain.\n\n### Schema\n- hubspot_list_properties: List the defined properties (name, label, type, fieldType) for an objectType. Do this first so you use real property names.\n\n### Read\n- hubspot_search: Search an objectType by full-text `query` OR structured `filters` (array of {propertyName, operator, value}). Returns { total, results:[{id, properties}] }.\n- hubspot_get_object: Fetch one record by id (optionally selecting specific properties).\n- hubspot_list_objects: Page through all records of an objectType (limit + after cursor).\n\n### Write\n- hubspot_create_object: Create a record from a `properties` object.\n- hubspot_update_object: Patch a record's `properties` by id.\n- hubspot_create_note: Convenience \u2014 log a note (hs_note_body) and optionally associate it to a contact/company/deal/ticket.\n- hubspot_associate: Associate two records (fromType/fromId \u2194 toType/toId) with the default association type.",resolve(){let o=R();if(!o)return{command:null,args:[],env:{},description:this.description};let i={};for(let e of this.envKeys)process.env[e]&&(i[e]=process.env[e]);return{type:"stdio",command:"node",args:[o,"../dist/hubspot.js","hubspotSkill"],env:i,description:this.description,alwaysLoad:!0}},async handleToolCall(o,i){try{let e=i||{};switch(o){case"hubspot_whoami":{let t=await c("/account-info/v3/details");return JSON.stringify({portalId:t.portalId,accountType:t.accountType,timeZone:t.timeZone,uiDomain:t.uiDomain,companyCurrency:t.companyCurrency})}case"hubspot_list_properties":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required (e.g. contacts, companies, deals, tickets, feedback_submissions)"});let r=((await c(`/crm/v3/properties/${encodeURIComponent(t)}`)).results||[]).map(s=>({name:s.name,label:s.label,type:s.type,fieldType:s.fieldType}));return JSON.stringify({objectType:t,count:r.length,properties:r})}case"hubspot_search":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});let r={limit:Number.isFinite(Number(e.limit))&&Number(e.limit)>0?Math.trunc(Number(e.limit)):20};e.query&&(r.query=String(e.query)),Array.isArray(e.filters)&&e.filters.length&&(r.filterGroups=[{filters:e.filters}]),e.properties!=null&&(r.properties=Array.isArray(e.properties)?e.properties:String(e.properties).split(",").map(a=>a.trim()).filter(Boolean));let s=await c(`/crm/v3/objects/${encodeURIComponent(t)}/search`,{method:"POST",body:r});return JSON.stringify({total:s.total??(s.results?s.results.length:0),results:(s.results||[]).map(a=>({id:a.id,properties:a.properties}))})}case"hubspot_get_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.id)return JSON.stringify({error:"id is required"});let n=h(e.properties,{associations:e.associations}),r=await c(`/crm/v3/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.id)}${n}`);return JSON.stringify({id:r.id,properties:r.properties,...r.associations?{associations:r.associations}:{}})}case"hubspot_list_objects":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});let n=Number.isFinite(Number(e.limit))&&Number(e.limit)>0?Math.trunc(Number(e.limit)):20,r=h(e.properties,{limit:n,after:e.after}),s=await c(`/crm/v3/objects/${encodeURIComponent(t)}${r}`);return JSON.stringify({results:(s.results||[]).map(a=>({id:a.id,properties:a.properties})),paging:s.paging||null})}case"hubspot_create_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.properties||typeof e.properties!="object"||Array.isArray(e.properties))return JSON.stringify({error:"properties is required (an object of { propertyName: value } \u2014 call hubspot_list_properties first for valid names)"});let n=await c(`/crm/v3/objects/${encodeURIComponent(t)}`,{method:"POST",body:{properties:e.properties}});return JSON.stringify({id:n.id,properties:n.properties})}case"hubspot_update_object":{let t=d(e.objectType);if(!t)return JSON.stringify({error:"objectType is required"});if(!e.id)return JSON.stringify({error:"id is required"});if(!e.properties||typeof e.properties!="object"||Array.isArray(e.properties))return JSON.stringify({error:"properties is required (an object of { propertyName: value })"});let n=await c(`/crm/v3/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.id)}`,{method:"PATCH",body:{properties:e.properties}});return JSON.stringify({id:n.id,properties:n.properties})}case"hubspot_create_note":{if(!e.body||typeof e.body!="string")return JSON.stringify({error:"body is required (the note text)"});let t=typeof e.timestamp=="string"&&e.timestamp?e.timestamp:null;if(!t)try{t=new Date().toISOString()}catch{t=null}if(!t)return JSON.stringify({error:"timestamp is required (pass an ISO 8601 string, e.g. 2026-01-01T00:00:00.000Z)"});let n=await c("/crm/v3/objects/notes",{method:"POST",body:{properties:{hs_note_body:e.body,hs_timestamp:t}}}),r=n.id,s=[["contacts",e.contactId],["companies",e.companyId],["deals",e.dealId],["tickets",e.ticketId]].filter(([,p])=>p!=null&&p!==""),a=[];for(let[p,u]of s)try{await c(`/crm/v4/objects/notes/${encodeURIComponent(r)}/associations/default/${p}/${encodeURIComponent(u)}`,{method:"PUT"}),a.push({toType:p,toId:String(u)})}catch(f){a.push({toType:p,toId:String(u),error:f.message})}return JSON.stringify({id:r,properties:n.properties,associatedTo:a})}case"hubspot_associate":{let t=d(e.fromType),n=d(e.toType);return!t||!e.fromId||!n||!e.toId?JSON.stringify({error:"fromType, fromId, toType and toId are all required"}):(await c(`/crm/v4/objects/${encodeURIComponent(t)}/${encodeURIComponent(e.fromId)}/associations/default/${encodeURIComponent(n)}/${encodeURIComponent(e.toId)}`,{method:"PUT"}),JSON.stringify({ok:!0}))}default:return JSON.stringify({error:`Unknown tool: ${o}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"hubspot_whoami",description:"Confirm the HubSpot token works: returns the portal (hub) id, account type, time zone and UI domain.",input_schema:{type:"object",properties:{}}},{name:"hubspot_list_properties",description:"List the defined properties (name, label, type, fieldType) for a CRM object type. Call this FIRST so you use valid property names when creating/updating/searching.",input_schema:{type:"object",properties:{objectType:{type:"string",description:l}},required:["objectType"]}},{name:"hubspot_search",description:"Search a CRM object type. Pass a full-text `query` OR structured `filters` (array of {propertyName, operator, value}, e.g. operator EQ/CONTAINS_TOKEN/GT/\u2026). Returns { total, results:[{id, properties}] }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:l},query:{type:"string",description:"Optional full-text search string."},filters:{type:"array",description:"Optional structured filters (ANDed). Each: { propertyName, operator, value }. Operators: EQ, NEQ, LT, LTE, GT, GTE, CONTAINS_TOKEN, HAS_PROPERTY, IN, \u2026",items:{type:"object",properties:{propertyName:{type:"string"},operator:{type:"string"},value:{type:"string"}}}},properties:{type:"array",items:{type:"string"},description:"Optional: property names to return on each result."},limit:{type:"number",description:"Max results (default 20)."}},required:["objectType"]}},{name:"hubspot_get_object",description:"Fetch one CRM record by id. Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:l},id:{type:"string",description:"The record id."},properties:{type:"array",items:{type:"string"},description:"Optional: specific property names to return."},associations:{type:"string",description:'Optional: comma-separated object types to also return associations for (e.g. "companies,deals").'}},required:["objectType","id"]}},{name:"hubspot_list_objects",description:"Page through records of a CRM object type. Returns { results, paging } \u2014 pass paging.next.after back as `after` for the next page.",input_schema:{type:"object",properties:{objectType:{type:"string",description:l},properties:{type:"array",items:{type:"string"},description:"Optional: property names to return on each record."},limit:{type:"number",description:"Page size (default 20)."},after:{type:"string",description:"Optional paging cursor from a previous response (paging.next.after)."}},required:["objectType"]}},{name:"hubspot_create_object",description:"Create a CRM record. Pass `properties` as an object of { propertyName: value } (call hubspot_list_properties first for valid names). Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:l},properties:{type:"object",description:"Object of { propertyName: value } to set on the new record."}},required:["objectType","properties"]}},{name:"hubspot_update_object",description:"Update (PATCH) a CRM record by id. Pass `properties` as an object of { propertyName: value }. Returns { id, properties }.",input_schema:{type:"object",properties:{objectType:{type:"string",description:l},id:{type:"string",description:"The record id to update."},properties:{type:"object",description:"Object of { propertyName: value } to change."}},required:["objectType","id","properties"]}},{name:"hubspot_create_note",description:"Log a note (hs_note_body) and optionally associate it to a contact/company/deal/ticket. Returns { id, associatedTo }.",input_schema:{type:"object",properties:{body:{type:"string",description:"The note text (stored as hs_note_body)."},contactId:{type:"string",description:"Optional: associate the note to this contact id."},companyId:{type:"string",description:"Optional: associate the note to this company id."},dealId:{type:"string",description:"Optional: associate the note to this deal id."},ticketId:{type:"string",description:"Optional: associate the note to this ticket id."},timestamp:{type:"string",description:"Optional ISO 8601 timestamp for the note (defaults to now)."}},required:["body"]}},{name:"hubspot_associate",description:"Associate two CRM records with the default association type (e.g. a contact to a company). Returns { ok:true }.",input_schema:{type:"object",properties:{fromType:{type:"string",description:"Source object type (e.g. contacts)."},fromId:{type:"string",description:"Source record id."},toType:{type:"string",description:"Target object type (e.g. companies)."},toId:{type:"string",description:"Target record id."}},required:["fromType","fromId","toType","toId"]}}]};export{q as hubspotSkill};
|