@zibby/skills 2.0.5 → 2.0.6
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/datasetStore.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as h,readFileSync as A}from"node:fs";import{homedir as L}from"node:os";import{join as N,dirname as R,resolve as k}from"node:path";import{fileURLToPath as v}from"node:url";var y={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 S(o,e,t=process.env){let r=Number(t?.[o]);return Number.isFinite(r)&&r>0?Math.min(6e5,Math.max(1e3,Math.floor(r))):e}function O(o="api",e=process.env){let t=y[o]||y.api;return S(t.knob,t.fallback,e)}function _(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 w(o,e){if(!o)return e;let t=new AbortController,r=i=>{t.signal.aborted||t.abort(i)},n=()=>r(o.reason),s=()=>r(e.reason);return t.signal.addEventListener("abort",()=>{o.removeEventListener("abort",n),e.removeEventListener("abort",s)},{once:!0}),o.aborted?r(o.reason):e.aborted?r(e.reason):(o.addEventListener("abort",n,{once:!0}),e.addEventListener("abort",s,{once:!0})),t.signal}async function u(o,e={},t={}){let r=t.kind||"api",n=(y[r]||y.api).knob,s=t.timeoutMs?Math.min(6e5,Math.max(1e3,Math.floor(t.timeoutMs))):O(r),i=e?.signal;if(i?.aborted)throw i.reason??new DOMException("This operation was aborted","AbortError");let a=AbortSignal.timeout(s),c=w(i,a);try{return await fetch(o,{...e,signal:c})}catch(l){throw a.aborted&&_(l)?new Error(`${t.what||"request"} TIMED OUT after ${s}ms against ${I(o)} (${n})`):l}}function B(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let o=R(v(import.meta.url)),e=k(o,"..","bin","mcp-skill.mjs");return h(e)?e:null}function g(){if(process.env.PROJECT_API_TOKEN)return process.env.PROJECT_API_TOKEN;if(process.env.ZIBBY_USER_TOKEN)return process.env.ZIBBY_USER_TOKEN;try{let o=N(L(),".zibby","config.json");return h(o)&&JSON.parse(A(o,"utf-8")).sessionToken||null}catch{return null}}function b(){return process.env.ZIBBY_ACCOUNT_API_URL?process.env.ZIBBY_ACCOUNT_API_URL.replace(/\/$/,""):(process.env.ZIBBY_ENV||"prod")==="local"?"http://localhost:3001":process.env.ZIBBY_PROD_ACCOUNT_API_URL||"https://api-prod.zibby.app"}function m(){return(typeof process.env.WORKFLOW_TYPE=="string"?process.env.WORKFLOW_TYPE.trim():"")||"agent"}function M(){let o={};for(let[e,t]of Object.entries(process.env)){let r=/^ZIBBY_STORE__(.+)$/.exec(e);if(!r)continue;let n=typeof t=="string"?t.trim():"";n&&(o[r[1]]=n)}return o}var f={};function K(){for(let o of Object.keys(f))delete f[o]}function p(o){let e={...M(),...f},t=Object.keys(e),r=typeof o=="string"?o.trim():"";return r?Object.prototype.hasOwnProperty.call(e,r)?{storeId:e[r],name:r}:{error:`unknown store '${r}'; available: ${t.join(", ")}`}:t.length===1?{storeId:e[t[0]],name:t[0]}:t.length===0?{error:"no stores bound to this agent"}:{error:`multiple stores are bound; pass \`store\` (one of: ${t.join(", ")})`}}async function q(o){let e=g();if(!e)throw new Error("No backend credential (PROJECT_API_TOKEN). Stores are only available inside a Zibby run.");let t=await u(`${b()}/datasets/stores/ensure`,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(o)},{kind:"api",what:"dataset store ensure"});if(!t.ok){let r=await t.text().catch(()=>"");throw new Error(`ensure_store failed (${t.status}): ${r.slice(0,300)}`)}return t.json()}async function d(o,e,t){let r=g();if(!r)throw new Error("No backend credential (PROJECT_API_TOKEN). Dataset store is only available inside a Zibby run.");let n=`${b()}/datasets/stores/${encodeURIComponent(o)}/${e}`,s=await u(n,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify(t)},{kind:e==="query"||e==="sql"?"job":"api",what:`dataset store ${e}`});if(!s.ok){let i=await s.text().catch(()=>"");throw new Error(`Store ${e} failed (${s.status}): ${i.slice(0,300)}`)}return s.json()}var x=Math.floor(3.5*1024*1024);async function U(o,e,t,r){let n=await d(o,"put-url",{path:e,contentType:r});if(!n?.url)throw new Error("put-url did not return an upload URL");let s=await u(n.url,{method:n.method||"PUT",headers:n.headers||{"Content-Type":r},body:t},{kind:"transfer",what:`dataset store presigned upload of ${e}`});if(!s.ok){let i=await s.text().catch(()=>"");throw new Error(`direct upload failed (${s.status}): ${i.slice(0,200)}`)}return{ok:!0,path:n.path||e,size:t.length,contentType:n.contentType||r,via:"presign"}}async function C(o,e){let t=await d(o,"get-url",{path:e});if(!t?.url)throw new Error("get-url did not return a download URL");let r=await u(t.url,{method:t.method||"GET"},{kind:"transfer",what:`dataset store presigned download of ${e}`});if(!r.ok){let s=await r.text().catch(()=>"");throw new Error(`direct download failed (${r.status}): ${s.slice(0,200)}`)}let n=await r.arrayBuffer();return{buf:Buffer.from(n),contentType:r.headers.get("content-type")||"application/octet-stream"}}var Y={id:"dataset-store",callsBackend:!0,serverName:"dataset_store",allowedTools:["mcp__dataset_store__*"],description:"Dataset store \u2014 a durable, queryable store for structured JSON records; append rows now, run SQL-style aggregations/reports later",promptFragment:`## Dataset Store (durable, queryable structured-record store)
|
|
2
2
|
You have one or more durable stores for STRUCTURED records that survive across
|
|
3
3
|
your stateless runs. Unlike key-value memory (for picking up where you left
|
|
4
4
|
off), this is for accumulating DATA you want to QUERY and AGGREGATE later \u2014 e.g.
|
|
@@ -45,4 +45,4 @@ Tools:
|
|
|
45
45
|
- file_list: (file stores) List stored files (optionally by path prefix).
|
|
46
46
|
- file_delete: (file stores) Delete ONE file by path.
|
|
47
47
|
Pick the tool that matches the store's TYPE; using a dataset tool on a sqlite
|
|
48
|
-
store (or a file tool on either, etc.) is rejected.`,resolve(){let s=I();if(!s)return{command:null,args:[],env:{},description:this.description};let t={};for(let e of["PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV","ZIBBY_PROD_ACCOUNT_API_URL","ZIBBY_USER_TOKEN","WORKFLOW_TYPE"])process.env[e]&&(t[e]=process.env[e]);for(let e of Object.keys(process.env))/^ZIBBY_STORE__.+$/.test(e)&&process.env[e]&&(t[e]=process.env[e]);return{type:"stdio",command:"node",args:[s,"../dist/datasetStore.js","datasetStoreSkill"],env:t,description:this.description,alwaysLoad:!1}},async handleToolCall(s,t){try{switch(s){case"dataset_append":{if(t?.record==null||typeof t.record!="object"||Array.isArray(t.record))return JSON.stringify({error:"record is required (a JSON object)"});let e=d(t?.store);if(e.error)return JSON.stringify({error:e.error});let r=typeof t?.agent=="string"&&t.agent.trim()?t.agent.trim():y(),o={record:t.record,agent:r};typeof t?.description=="string"&&t.description.trim()&&(o.description=t.description.trim());let n=await a(e.storeId,"append",o);return JSON.stringify({...n,store:e.name,storeId:e.storeId})}case"dataset_query":{let e=d(t?.store);if(e.error)return JSON.stringify({error:e.error});let r={};for(let n of["select","where","groupBy","orderBy","limit","since","until","agent"])t?.[n]!=null&&(r[n]=t[n]);let o=await a(e.storeId,"query",r);return JSON.stringify({...o,store:e.name,storeId:e.storeId})}case"ensure_store":{let e=typeof t?.name=="string"?t.name.trim():"";if(!e)return JSON.stringify({error:"name is required"});let r=typeof t?.type=="string"&&t.type.trim()?t.type.trim().toLowerCase():"sqlite",o=typeof t?.description=="string"?t.description.trim():"",n=await N({name:e,type:r,description:o,namespace:y()});return n?.storeId&&(u[e]=n.storeId),JSON.stringify({...n,store:e})}case"file_put":{let e=d(t?.store);if(e.error)return JSON.stringify({error:e.error});if(typeof t?.path!="string"||!t.path.trim())return JSON.stringify({error:'path is required (a relative file path like "reports/2026-07.json")'});let r=typeof t?.content=="string",o=typeof t?.contentBase64=="string"&&t.contentBase64.length>0;if(!r&&!o)return JSON.stringify({error:"content (text) or contentBase64 (base64 bytes) is required"});let n=t.path.trim(),i=typeof t?.contentType=="string"&&t.contentType.trim()?t.contentType.trim():"",p=r?Buffer.from(t.content,"utf8"):Buffer.from(String(t.contentBase64).replace(/\s+/g,""),"base64");if(p.length>L){let g=i||(r?"text/plain; charset=utf-8":"application/octet-stream"),E=await B(e.storeId,n,p,g);return JSON.stringify({...E,store:e.name,storeId:e.storeId})}let c={path:n};r?c.content=t.content:c.contentBase64=t.contentBase64,i&&(c.contentType=i);let l=await a(e.storeId,"put",c);return JSON.stringify({...l,store:e.name,storeId:e.storeId})}case"file_get":{let e=d(t?.store);if(e.error)return JSON.stringify({error:e.error});if(typeof t?.path!="string"||!t.path.trim())return JSON.stringify({error:"path is required"});let r=t.path.trim(),o;try{o=await a(e.storeId,"get",{path:r})}catch(c){if(!/failed \(413\)/.test(c?.message||""))throw c;let l=await R(e.storeId,r);o={path:r,size:l.buf.length,contentType:l.contentType,lastModified:null,contentBase64:l.buf.toString("base64")}}let n={ok:!0,store:e.name,storeId:e.storeId,path:o.path,size:o.size,contentType:o.contentType,lastModified:o.lastModified},i=Buffer.from(o.contentBase64||"","base64"),p=i.toString("utf8");return Buffer.compare(Buffer.from(p,"utf8"),i)===0&&!p.includes("\0")?(n.content=p,n.encoding="utf8"):(n.contentBase64=o.contentBase64,n.encoding="base64"),JSON.stringify(n)}case"file_list":{let e=d(t?.store);if(e.error)return JSON.stringify({error:e.error});let r={};typeof t?.prefix=="string"&&t.prefix.trim()&&(r.prefix=t.prefix.trim()),t?.limit!=null&&(r.limit=t.limit),typeof t?.cursor=="string"&&t.cursor&&(r.cursor=t.cursor);let o=await a(e.storeId,"list",r);return JSON.stringify({...o,store:e.name,storeId:e.storeId})}case"file_delete":{let e=d(t?.store);if(e.error)return JSON.stringify({error:e.error});if(typeof t?.path!="string"||!t.path.trim())return JSON.stringify({error:"path is required"});let r=await a(e.storeId,"delete",{path:t.path.trim()});return JSON.stringify({...r,store:e.name,storeId:e.storeId})}case"sqlite_exec":case"sqlite_query":{let e=d(t?.store);if(e.error)return JSON.stringify({error:e.error});if(typeof t?.sql!="string"||!t.sql.trim())return JSON.stringify({error:"sql is required (a non-empty SQL string)"});let r={sql:t.sql};s==="sqlite_query"&&(r.readOnly=!0),Array.isArray(t?.params)&&(r.params=t.params);let o=await a(e.storeId,"sql",r);return JSON.stringify({...o,store:e.name,storeId:e.storeId})}default:return JSON.stringify({error:`Unknown tool: ${s}`})}}catch(e){return JSON.stringify({error:e.message})}},tools:[{name:"dataset_append",description:"Append ONE structured JSON record to a bound store, durably. Records persist across your stateless runs and are auto-tagged with your agent type so you can filter to your own writes later. Use to accumulate data you will query/aggregate (e.g. per-run metrics, processed items). Append ONE record per call.",input_schema:{type:"object",properties:{store:{type:"string",description:'The logical store NAME to write to (e.g. "scorecards"), taken from the AVAILABLE STORES list \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this and it defaults to that store; you can ONLY write to a bound store name.'},record:{type:"object",description:'An arbitrary JSON object \u2014 one row of data. Its keys become queryable fields (e.g. {"repo":"owner/x","stars":1200}). One record per call.'},description:{type:"string",description:"Optional, informational note about this write. The store already exists from deploy, so this is not required and does not create anything."},agent:{type:"string",description:"Optional writing-agent tag. Defaults to your own agent type \u2014 leave unset to auto-tag."}},required:["record"]}},{name:"dataset_query",description:"Run a SQL-style query over a bound store to build reports: select/aggregate (count|sum|avg|min|max), filter, group, order, limit, and bound by month. Returns { columns, rows }. Use this to compute summaries/aggregations from records you appended earlier.",input_schema:{type:"object",properties:{store:{type:"string",description:'The logical store NAME to query (e.g. "scorecards"), taken from the AVAILABLE STORES list \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this and it defaults to that store.'},select:{type:"array",description:"Columns to return. Each item is { field?, agg?, as? }. agg \u2208 count|sum|avg|min|max; omit field for count(*). Omit `select` entirely to return raw rows."},where:{type:"array",description:"Filters, ANDed. Each item is { field, op, value }; op \u2208 eq|ne|gt|gte|lt|lte|like. `field` is a JSON key of the stored record."},groupBy:{type:"array",description:"Field names to group by (array of strings) for aggregation."},orderBy:{type:"array",description:"Sort spec. Each item is { field|as, dir }; dir \u2208 asc|desc."},limit:{type:"number",description:"Maximum number of rows to return."},since:{type:"string",description:"Inclusive lower bound month, 'yyyy-MM' (e.g. '2026-01')."},until:{type:"string",description:"Inclusive upper bound month, 'yyyy-MM' (e.g. '2026-06')."},agent:{type:"string",description:"Filter to records written by one agent namespace. Omit to query across all writers."}},required:[]}},{name:"ensure_store",description:'Create (or reuse) a store ON DEMAND for THIS agent \u2014 use when you need a store that was NOT declared/bound at deploy. Idempotent by name and private to this agent: calling again with the same name returns the SAME store (safe to call at the start of every run). Returns { storeId }. For type "sqlite" you then define schema with sqlite_exec (CREATE TABLE IF NOT EXISTS) and read/write via sqlite_exec/sqlite_query using this name.',input_schema:{type:"object",properties:{name:{type:"string",description:'A short logical name for the store (e.g. "linkedin_posts"). Letters, digits, _ and - only.'},type:{type:"string",enum:["sqlite","dataset","file"],description:'Store type. "sqlite" (default) = a mutable relational DB whose schema YOU define with SQL. "dataset" = append-only JSON records for later aggregation/analytics. "file" = arbitrary file/blob storage by relative path (file_put/file_get/file_list/file_delete).'},description:{type:"string",description:"What this store is for (shown in the Storage UI)."}},required:["name"]}},{name:"sqlite_exec",description:"For SQLITE-type stores: run SQL that CHANGES data \u2014 CREATE TABLE (use IF NOT EXISTS), INSERT, UPDATE, DELETE (one or more statements in one call). The store is a real, mutable SQLite database that persists across your stateless runs. Returns { rowsModified, wrote }. Use this to build schema on the fly and to update rows / track changing state (e.g. a queue with a status column).",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a sqlite-type store from AVAILABLE STORES) \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this."},sql:{type:"string",description:'The SQL to run. May contain multiple statements separated by ";". Prefer CREATE TABLE IF NOT EXISTS for idempotent schema.'},params:{type:"array",description:'Optional positional bind params for a SINGLE parameterized statement (safe binding of values), e.g. sql "UPDATE t SET s=? WHERE id=?" with params ["done", 1].'}},required:["sql"]}},{name:"sqlite_query",description:"For SQLITE-type stores: run a read-only SELECT (optionally with `params` for safe binding) against the store's SQLite database. Returns { columns, rows }. Never changes data. Use to read back rows/state you stored earlier.",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a sqlite-type store from AVAILABLE STORES) \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this."},sql:{type:"string",description:"A single SELECT statement. Use ? placeholders + `params` for any values."},params:{type:"array",description:'Optional positional bind params for the SELECT, e.g. ["linkedin_personal"].'}},required:["sql"]}},{name:"file_put",description:"For FILE-type stores: write (or overwrite) ONE file at a relative path \u2014 raw JSON dumps, CSVs, images, snapshots, any blob you want to keep across your stateless runs. Text goes in `content`; binary goes base64-encoded in `contentBase64` (pass exactly one). SIZE: there is no practical limit \u2014 anything over ~3.5 MiB is streamed straight to object storage via a presigned URL automatically, so do NOT gzip, base64-wrap, chunk or split a file just to make it fit. Non-ASCII paths (e.g. \u4E2A\u4EBA\u62A5\u544A.html) are fine \u2014 do not transliterate. Overwriting the same path UPDATES the file. Returns { ok, path, size }.",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a file-type store from AVAILABLE STORES) \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this."},path:{type:"string",description:'Relative file path, e.g. "dumps/run-42.json" or "img/chart.png". Letters, digits, ".", "_", "-" and "/" only; no "..", no leading "/".'},content:{type:"string",description:"Text content (UTF-8). Use for JSON/CSV/text files."},contentBase64:{type:"string",description:"Base64-encoded binary content (images etc.). Alternative to `content`."},contentType:{type:"string",description:'Optional MIME type (e.g. "application/json", "image/png"). Defaults sensibly.'}},required:["path"]}},{name:"file_get",description:'For FILE-type stores: read ONE stored file back by its relative path. Text files come back as `content` (encoding "utf8"); binary files come back as `contentBase64` (encoding "base64"). Returns { path, size, contentType, lastModified, content|contentBase64, encoding }.',input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a file-type store from AVAILABLE STORES). If exactly one store is bound you may omit this."},path:{type:"string",description:"The relative file path to fetch (as listed by file_list / used in file_put)."}},required:["path"]}},{name:"file_list",description:'For FILE-type stores: list the stored files \u2014 each entry has { path, size, lastModified }. Optionally filter by a path `prefix` (e.g. "dumps/"). Paginated via `cursor` when there are more results.',input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a file-type store from AVAILABLE STORES). If exactly one store is bound you may omit this."},prefix:{type:"string",description:'Optional path prefix filter, e.g. "dumps/" or "reports/2026".'},limit:{type:"number",description:"Max entries to return (default/max 1000)."},cursor:{type:"string",description:"Pagination cursor from a previous file_list response (nextCursor)."}},required:[]}},{name:"file_delete",description:"For FILE-type stores: delete ONE stored file by its relative path. Returns { ok, path, deleted }. Errors if the path does not exist.",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a file-type store from AVAILABLE STORES). If exactly one store is bound you may omit this."},path:{type:"string",description:"The relative file path to delete."}},required:["path"]}}]};export{C as __clearEnsuredStores,P as datasetStoreSkill};
|
|
48
|
+
store (or a file tool on either, etc.) is rejected.`,resolve(){let o=B();if(!o)return{command:null,args:[],env:{},description:this.description};let e={};for(let t of["PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV","ZIBBY_PROD_ACCOUNT_API_URL","ZIBBY_USER_TOKEN","WORKFLOW_TYPE"])process.env[t]&&(e[t]=process.env[t]);for(let t of Object.keys(process.env))/^ZIBBY_STORE__.+$/.test(t)&&process.env[t]&&(e[t]=process.env[t]);return{type:"stdio",command:"node",args:[o,"../dist/datasetStore.js","datasetStoreSkill"],env:e,description:this.description,alwaysLoad:!1}},async handleToolCall(o,e){try{switch(o){case"dataset_append":{if(e?.record==null||typeof e.record!="object"||Array.isArray(e.record))return JSON.stringify({error:"record is required (a JSON object)"});let t=p(e?.store);if(t.error)return JSON.stringify({error:t.error});let r=typeof e?.agent=="string"&&e.agent.trim()?e.agent.trim():m(),n={record:e.record,agent:r};typeof e?.description=="string"&&e.description.trim()&&(n.description=e.description.trim());let s=await d(t.storeId,"append",n);return JSON.stringify({...s,store:t.name,storeId:t.storeId})}case"dataset_query":{let t=p(e?.store);if(t.error)return JSON.stringify({error:t.error});let r={};for(let s of["select","where","groupBy","orderBy","limit","since","until","agent"])e?.[s]!=null&&(r[s]=e[s]);let n=await d(t.storeId,"query",r);return JSON.stringify({...n,store:t.name,storeId:t.storeId})}case"ensure_store":{let t=typeof e?.name=="string"?e.name.trim():"";if(!t)return JSON.stringify({error:"name is required"});let r=typeof e?.type=="string"&&e.type.trim()?e.type.trim().toLowerCase():"sqlite",n=typeof e?.description=="string"?e.description.trim():"",s=await q({name:t,type:r,description:n,namespace:m()});return s?.storeId&&(f[t]=s.storeId),JSON.stringify({...s,store:t})}case"file_put":{let t=p(e?.store);if(t.error)return JSON.stringify({error:t.error});if(typeof e?.path!="string"||!e.path.trim())return JSON.stringify({error:'path is required (a relative file path like "reports/2026-07.json")'});let r=typeof e?.content=="string",n=typeof e?.contentBase64=="string"&&e.contentBase64.length>0;if(!r&&!n)return JSON.stringify({error:"content (text) or contentBase64 (base64 bytes) is required"});let s=e.path.trim(),i=typeof e?.contentType=="string"&&e.contentType.trim()?e.contentType.trim():"",a=r?Buffer.from(e.content,"utf8"):Buffer.from(String(e.contentBase64).replace(/\s+/g,""),"base64");if(a.length>x){let E=i||(r?"text/plain; charset=utf-8":"application/octet-stream"),T=await U(t.storeId,s,a,E);return JSON.stringify({...T,store:t.name,storeId:t.storeId})}let c={path:s};r?c.content=e.content:c.contentBase64=e.contentBase64,i&&(c.contentType=i);let l=await d(t.storeId,"put",c);return JSON.stringify({...l,store:t.name,storeId:t.storeId})}case"file_get":{let t=p(e?.store);if(t.error)return JSON.stringify({error:t.error});if(typeof e?.path!="string"||!e.path.trim())return JSON.stringify({error:"path is required"});let r=e.path.trim(),n;try{n=await d(t.storeId,"get",{path:r})}catch(c){if(!/failed \(413\)/.test(c?.message||""))throw c;let l=await C(t.storeId,r);n={path:r,size:l.buf.length,contentType:l.contentType,lastModified:null,contentBase64:l.buf.toString("base64")}}let s={ok:!0,store:t.name,storeId:t.storeId,path:n.path,size:n.size,contentType:n.contentType,lastModified:n.lastModified},i=Buffer.from(n.contentBase64||"","base64"),a=i.toString("utf8");return Buffer.compare(Buffer.from(a,"utf8"),i)===0&&!a.includes("\0")?(s.content=a,s.encoding="utf8"):(s.contentBase64=n.contentBase64,s.encoding="base64"),JSON.stringify(s)}case"file_list":{let t=p(e?.store);if(t.error)return JSON.stringify({error:t.error});let r={};typeof e?.prefix=="string"&&e.prefix.trim()&&(r.prefix=e.prefix.trim()),e?.limit!=null&&(r.limit=e.limit),typeof e?.cursor=="string"&&e.cursor&&(r.cursor=e.cursor);let n=await d(t.storeId,"list",r);return JSON.stringify({...n,store:t.name,storeId:t.storeId})}case"file_delete":{let t=p(e?.store);if(t.error)return JSON.stringify({error:t.error});if(typeof e?.path!="string"||!e.path.trim())return JSON.stringify({error:"path is required"});let r=await d(t.storeId,"delete",{path:e.path.trim()});return JSON.stringify({...r,store:t.name,storeId:t.storeId})}case"sqlite_exec":case"sqlite_query":{let t=p(e?.store);if(t.error)return JSON.stringify({error:t.error});if(typeof e?.sql!="string"||!e.sql.trim())return JSON.stringify({error:"sql is required (a non-empty SQL string)"});let r={sql:e.sql};o==="sqlite_query"&&(r.readOnly=!0),Array.isArray(e?.params)&&(r.params=e.params);let n=await d(t.storeId,"sql",r);return JSON.stringify({...n,store:t.name,storeId:t.storeId})}default:return JSON.stringify({error:`Unknown tool: ${o}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"dataset_append",description:"Append ONE structured JSON record to a bound store, durably. Records persist across your stateless runs and are auto-tagged with your agent type so you can filter to your own writes later. Use to accumulate data you will query/aggregate (e.g. per-run metrics, processed items). Append ONE record per call.",input_schema:{type:"object",properties:{store:{type:"string",description:'The logical store NAME to write to (e.g. "scorecards"), taken from the AVAILABLE STORES list \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this and it defaults to that store; you can ONLY write to a bound store name.'},record:{type:"object",description:'An arbitrary JSON object \u2014 one row of data. Its keys become queryable fields (e.g. {"repo":"owner/x","stars":1200}). One record per call.'},description:{type:"string",description:"Optional, informational note about this write. The store already exists from deploy, so this is not required and does not create anything."},agent:{type:"string",description:"Optional writing-agent tag. Defaults to your own agent type \u2014 leave unset to auto-tag."}},required:["record"]}},{name:"dataset_query",description:"Run a SQL-style query over a bound store to build reports: select/aggregate (count|sum|avg|min|max), filter, group, order, limit, and bound by month. Returns { columns, rows }. Use this to compute summaries/aggregations from records you appended earlier.",input_schema:{type:"object",properties:{store:{type:"string",description:'The logical store NAME to query (e.g. "scorecards"), taken from the AVAILABLE STORES list \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this and it defaults to that store.'},select:{type:"array",description:"Columns to return. Each item is { field?, agg?, as? }. agg \u2208 count|sum|avg|min|max; omit field for count(*). Omit `select` entirely to return raw rows."},where:{type:"array",description:"Filters, ANDed. Each item is { field, op, value }; op \u2208 eq|ne|gt|gte|lt|lte|like. `field` is a JSON key of the stored record."},groupBy:{type:"array",description:"Field names to group by (array of strings) for aggregation."},orderBy:{type:"array",description:"Sort spec. Each item is { field|as, dir }; dir \u2208 asc|desc."},limit:{type:"number",description:"Maximum number of rows to return."},since:{type:"string",description:"Inclusive lower bound month, 'yyyy-MM' (e.g. '2026-01')."},until:{type:"string",description:"Inclusive upper bound month, 'yyyy-MM' (e.g. '2026-06')."},agent:{type:"string",description:"Filter to records written by one agent namespace. Omit to query across all writers."}},required:[]}},{name:"ensure_store",description:'Create (or reuse) a store ON DEMAND for THIS agent \u2014 use when you need a store that was NOT declared/bound at deploy. Idempotent by name and private to this agent: calling again with the same name returns the SAME store (safe to call at the start of every run). Returns { storeId }. For type "sqlite" you then define schema with sqlite_exec (CREATE TABLE IF NOT EXISTS) and read/write via sqlite_exec/sqlite_query using this name.',input_schema:{type:"object",properties:{name:{type:"string",description:'A short logical name for the store (e.g. "linkedin_posts"). Letters, digits, _ and - only.'},type:{type:"string",enum:["sqlite","dataset","file"],description:'Store type. "sqlite" (default) = a mutable relational DB whose schema YOU define with SQL. "dataset" = append-only JSON records for later aggregation/analytics. "file" = arbitrary file/blob storage by relative path (file_put/file_get/file_list/file_delete).'},description:{type:"string",description:"What this store is for (shown in the Storage UI)."}},required:["name"]}},{name:"sqlite_exec",description:"For SQLITE-type stores: run SQL that CHANGES data \u2014 CREATE TABLE (use IF NOT EXISTS), INSERT, UPDATE, DELETE (one or more statements in one call). The store is a real, mutable SQLite database that persists across your stateless runs. Returns { rowsModified, wrote }. Use this to build schema on the fly and to update rows / track changing state (e.g. a queue with a status column).",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a sqlite-type store from AVAILABLE STORES) \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this."},sql:{type:"string",description:'The SQL to run. May contain multiple statements separated by ";". Prefer CREATE TABLE IF NOT EXISTS for idempotent schema.'},params:{type:"array",description:'Optional positional bind params for a SINGLE parameterized statement (safe binding of values), e.g. sql "UPDATE t SET s=? WHERE id=?" with params ["done", 1].'}},required:["sql"]}},{name:"sqlite_query",description:"For SQLITE-type stores: run a read-only SELECT (optionally with `params` for safe binding) against the store's SQLite database. Returns { columns, rows }. Never changes data. Use to read back rows/state you stored earlier.",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a sqlite-type store from AVAILABLE STORES) \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this."},sql:{type:"string",description:"A single SELECT statement. Use ? placeholders + `params` for any values."},params:{type:"array",description:'Optional positional bind params for the SELECT, e.g. ["linkedin_personal"].'}},required:["sql"]}},{name:"file_put",description:"For FILE-type stores: write (or overwrite) ONE file at a relative path \u2014 raw JSON dumps, CSVs, images, snapshots, any blob you want to keep across your stateless runs. Text goes in `content`; binary goes base64-encoded in `contentBase64` (pass exactly one). SIZE: there is no practical limit \u2014 anything over ~3.5 MiB is streamed straight to object storage via a presigned URL automatically, so do NOT gzip, base64-wrap, chunk or split a file just to make it fit. Non-ASCII paths (e.g. \u4E2A\u4EBA\u62A5\u544A.html) are fine \u2014 do not transliterate. Overwriting the same path UPDATES the file. Returns { ok, path, size }.",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a file-type store from AVAILABLE STORES) \u2014 pick by description. NOT an id. If exactly one store is bound you may omit this."},path:{type:"string",description:'Relative file path, e.g. "dumps/run-42.json" or "img/chart.png". Letters, digits, ".", "_", "-" and "/" only; no "..", no leading "/".'},content:{type:"string",description:"Text content (UTF-8). Use for JSON/CSV/text files."},contentBase64:{type:"string",description:"Base64-encoded binary content (images etc.). Alternative to `content`."},contentType:{type:"string",description:'Optional MIME type (e.g. "application/json", "image/png"). Defaults sensibly.'}},required:["path"]}},{name:"file_get",description:'For FILE-type stores: read ONE stored file back by its relative path. Text files come back as `content` (encoding "utf8"); binary files come back as `contentBase64` (encoding "base64"). Returns { path, size, contentType, lastModified, content|contentBase64, encoding }.',input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a file-type store from AVAILABLE STORES). If exactly one store is bound you may omit this."},path:{type:"string",description:"The relative file path to fetch (as listed by file_list / used in file_put)."}},required:["path"]}},{name:"file_list",description:'For FILE-type stores: list the stored files \u2014 each entry has { path, size, lastModified }. Optionally filter by a path `prefix` (e.g. "dumps/"). Paginated via `cursor` when there are more results.',input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a file-type store from AVAILABLE STORES). If exactly one store is bound you may omit this."},prefix:{type:"string",description:'Optional path prefix filter, e.g. "dumps/" or "reports/2026".'},limit:{type:"number",description:"Max entries to return (default/max 1000)."},cursor:{type:"string",description:"Pagination cursor from a previous file_list response (nextCursor)."}},required:[]}},{name:"file_delete",description:"For FILE-type stores: delete ONE stored file by its relative path. Returns { ok, path, deleted }. Errors if the path does not exist.",input_schema:{type:"object",properties:{store:{type:"string",description:"The logical store NAME (a file-type store from AVAILABLE STORES). If exactly one store is bound you may omit this."},path:{type:"string",description:"The relative file path to delete."}},required:["path"]}}]};export{K as __clearEnsuredStores,Y as datasetStoreSkill};
|
package/dist/discord.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
`),a=
|
|
1
|
+
import{existsSync as T}from"fs";import{fileURLToPath as S}from"url";import{dirname as O,resolve as k}from"path";import{resolveIntegrationToken as D}from"@zibby/core/backend-client.js";var l=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"}),N=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 d={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(e,t,n=process.env){let i=Number(n?.[e]);return Number.isFinite(i)&&i>0?Math.min(6e5,Math.max(1e3,Math.floor(i))):t}function m(e="api",t=process.env){let n=d[e]||d.api;return g(n.knob,n.fallback,t)}function I(e){return e?.name==="TimeoutError"||e?.name==="AbortError"}function b(e){try{return new URL(String(e?.url??e)).host||"unknown host"}catch{return"unknown host"}}function f(e,t){if(!e)return t;let n=new AbortController,i=o=>{n.signal.aborted||n.abort(o)},r=()=>i(e.reason),s=()=>i(t.reason);return n.signal.addEventListener("abort",()=>{e.removeEventListener("abort",r),t.removeEventListener("abort",s)},{once:!0}),e.aborted?i(e.reason):t.aborted?i(t.reason):(e.addEventListener("abort",r,{once:!0}),t.addEventListener("abort",s,{once:!0})),n.signal}async function _(e,t={},n={}){let i=n.kind||"api",r=(d[i]||d.api).knob,s=n.timeoutMs?Math.min(6e5,Math.max(1e3,Math.floor(n.timeoutMs))):m(i),o=t?.signal;if(o?.aborted)throw o.reason??new DOMException("This operation was aborted","AbortError");let a=AbortSignal.timeout(s),c=f(o,a);try{return await fetch(e,{...t,signal:c})}catch(u){throw a.aborted&&I(u)?new Error(`${n.what||"request"} TIMED OUT after ${s}ms against ${b(e)} (${r})`):u}}function v(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let e=O(S(import.meta.url)),t=k(e,"..","bin","mcp-skill.mjs");return T(t)?t:null}var E=process.env.DISCORD_API_URL||"https://discord.com/api/v10",L=2e3;function y(e,t=L){let n=String(e??"");if(!n.trim())return[];if(n.length<=t)return[n];let i=[],r=n;for(;r.length>t;){let o=r.slice(0,t).lastIndexOf(`
|
|
2
|
+
`),a=o>t/2?o+1:t;i.push(r.slice(0,a)),r=r.slice(a)}return r&&i.push(r),i}async function h(){let e=(process.env.DISCORD_BOT_TOKEN||"").trim();if(e)return{token:e,guildId:(process.env.DISCORD_GUILD_ID||"").trim()};let t=await D(l.DISCORD),n=(t&&t.token?String(t.token):"").trim();if(!n)throw new Error("Discord is not connected: connect Discord in the Zibby dashboard or set DISCORD_BOT_TOKEN.");return{token:n,guildId:(t.guildId||"").trim()}}async function p(e,t,{token:n,body:i}={}){let r=n.startsWith("Bot ")?n:`Bot ${n}`,s=await _(`${E}${t}`,{method:e,headers:{Authorization:r,...i!==void 0?{"Content-Type":"application/json"}:{}},...i!==void 0?{body:JSON.stringify(i)}:{}},{kind:"api",what:`Discord ${e} ${t}`}),o=await s.json().catch(()=>null);if(!s.ok){let a=o&&(o.message||o.error)?o.message||o.error:`HTTP ${s.status}`;throw new Error(`Discord API error (${s.status}): ${a}`)}return o}async function A({token:e,guildId:t},n){let i=String(n||"").trim()||t||(process.env.DISCORD_GUILD_ID||"").trim();if(i)return i;let r=await p("GET","/users/@me/guilds",{token:e}),s=Array.isArray(r)?r:[];if(s.length===1)return s[0].id;if(s.length===0)throw new Error("The bot is not in any Discord server \u2014 invite it to a server first.");let o=s.slice(0,10).map(a=>`${a.name} (${a.id})`).join(", ");throw new Error(`The bot is in ${s.length} servers \u2014 pass guildId explicitly. Servers: ${o}`)}var B={id:"discord",callsBackend:!0,serverName:"discord",allowedTools:["mcp__discord__*"],requiresIntegration:l.DISCORD,envKeys:["DISCORD_BOT_TOKEN","DISCORD_GUILD_ID"],description:"Discord bot tools (send messages, list channels)",promptFragment:`## Discord
|
|
3
3
|
You can post to the user's Discord server as their bot. Tools:
|
|
4
4
|
- discord_send_message(channelId, text) \u2014 post a message to a channel (long text is auto-chunked to Discord's 2000-char limit)
|
|
5
|
-
- discord_list_channels(guildId?) \u2014 list the server's text channels (id + name) to find where to post; guildId is optional when the bot is in one server`,resolve(){let
|
|
5
|
+
- discord_list_channels(guildId?) \u2014 list the server's text channels (id + name) to find where to post; guildId is optional when the bot is in one server`,resolve(){let e={};for(let n of this.envKeys)process.env[n]&&(e[n]=process.env[n]);for(let n of["PROJECT_API_TOKEN","ZIBBY_USER_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV","ZIBBY_PROD_ACCOUNT_API_URL","ZIBBY_SELF_HOST","DISCORD_API_URL","EXECUTION_ID","PROJECT_ID","STAGE"])process.env[n]&&(e[n]=process.env[n]);let t=v();return t?{type:"stdio",command:"node",args:[t,"../dist/discord.js","discordSkill"],env:e,description:this.description,alwaysLoad:!0}:{command:null,args:[],env:e,description:this.description}},async handleToolCall(e,t={}){try{switch(e){case"discord_send_message":{let n=String(t.channelId||"").trim(),i=String(t.text||"");if(!n||!i.trim())return JSON.stringify({ok:!1,error:"channelId and text are required"});let r=await h(),s=y(i),o=[];for(let a of s){let c=await p("POST",`/channels/${encodeURIComponent(n)}/messages`,{token:r.token,body:{content:a}});o.push(c&&c.id?c.id:"")}return JSON.stringify({ok:!0,channelId:n,messageIds:o,chunks:s.length})}case"discord_list_channels":{let n=await h(),i=await A(n,t.guildId),r=await p("GET",`/guilds/${encodeURIComponent(i)}/channels`,{token:n.token}),s=(Array.isArray(r)?r:[]).filter(o=>o&&(o.type===0||o.type===5)).map(o=>({id:o.id,name:o.name,type:o.type===5?"announcement":"text",...o.topic?{topic:o.topic}:{}}));return JSON.stringify({ok:!0,guildId:i,channels:s})}default:return JSON.stringify({ok:!1,error:`Unknown tool: ${e}`})}}catch(n){return JSON.stringify({ok:!1,error:n.message})}},tools:[{name:"discord_send_message",description:"Post a message to a Discord channel as the connected bot. Text over 2000 chars is automatically split into sequential messages.",input_schema:{type:"object",properties:{channelId:{type:"string",description:"Discord channel id (snowflake). Use discord_list_channels to find it."},text:{type:"string",description:"Message text (Discord markdown supported)"}},required:["channelId","text"]}},{name:"discord_list_channels",description:"List the text channels of the connected Discord server (id + name). Pass guildId only when the bot is in multiple servers.",input_schema:{type:"object",properties:{guildId:{type:"string",description:"Discord server (guild) id \u2014 optional when the bot is in exactly one server or one was captured at connect time"}}}}]};export{L as DISCORD_MAX_CONTENT,y as chunkDiscordContent,B as discordSkill};
|
package/dist/figma.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as T}from"fs";import{fileURLToPath as A}from"url";import{dirname as U,resolve as P}from"path";import{resolveIntegrationToken as E}from"@zibby/core/backend-client.js";var b=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"}),j=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark 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 u={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 v(e,t,i=process.env){let n=Number(i?.[e]);return Number.isFinite(n)&&n>0?Math.min(6e5,Math.max(1e3,Math.floor(n))):t}function O(e="api",t=process.env){let i=u[e]||u.api;return v(i.knob,i.fallback,t)}function k(e){return e?.name==="TimeoutError"||e?.name==="AbortError"}function L(e){try{return new URL(String(e?.url??e)).host||"unknown host"}catch{return"unknown host"}}function N(e,t){if(!e)return t;let i=new AbortController,n=a=>{i.signal.aborted||i.abort(a)},s=()=>n(e.reason),r=()=>n(t.reason);return i.signal.addEventListener("abort",()=>{e.removeEventListener("abort",s),t.removeEventListener("abort",r)},{once:!0}),e.aborted?n(e.reason):t.aborted?n(t.reason):(e.addEventListener("abort",s,{once:!0}),t.addEventListener("abort",r,{once:!0})),i.signal}async function S(e,t={},i={}){let n=i.kind||"api",s=(u[n]||u.api).knob,r=i.timeoutMs?Math.min(6e5,Math.max(1e3,Math.floor(i.timeoutMs))):O(n),a=t?.signal;if(a?.aborted)throw a.reason??new DOMException("This operation was aborted","AbortError");let o=AbortSignal.timeout(r),c=N(a,o);try{return await fetch(e,{...t,signal:c})}catch(d){throw o.aborted&&k(d)?new Error(`${i.what||"request"} TIMED OUT after ${r}ms against ${L(e)} (${s})`):d}}function w(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let e=U(A(import.meta.url)),t=P(e,"..","bin","mcp-skill.mjs");return T(t)?t:null}async function f(e,t={}){let{token:i}=await E("figma"),n=e.startsWith("https://")?e:`https://api.figma.com${e}`,s={"X-Figma-Token":i,Accept:"application/json",...t.body?{"Content-Type":"application/json"}:{}},r=await S(n,{method:t.method||"GET",headers:s,body:t.body?JSON.stringify(t.body):void 0},{kind:"api",what:`Figma ${t.method||"GET"} ${e}`});if(!r.ok){let a=await r.text().catch(()=>"");throw new Error(`Figma API ${r.status}: ${a.slice(0,300)}`)}return r.json()}function g(e){let t=String(e||"").trim(),i=t.match(/figma\.com\/(?:file|design|board|proto)\/([A-Za-z0-9]+)/i);return i?i[1]:t}function _(e){return e==null?void 0:(Array.isArray(e)?e:String(e).split(",")).map(i=>String(i).trim().replace(/-/g,":")).filter(Boolean).join(",")}function M(e){let t=String(e||"").match(/[?&]node-id=([^&]+)/i);return t?decodeURIComponent(t[1]).replace(/-/g,":"):void 0}var p=e=>typeof e=="number"?Math.round(e*100)/100:e;function h(e){if(!e)return null;let t=n=>Math.round((n??0)*255).toString(16).padStart(2,"0"),i={hex:`#${t(e.r)}${t(e.g)}${t(e.b)}`.toUpperCase()};return e.a!=null&&e.a<1&&(i.opacity=p(e.a)),i}function I(e){return!e||e.visible===!1?null:e.type==="SOLID"?{type:"SOLID",...h(e.color),...e.opacity!=null?{opacity:e.opacity}:{}}:{type:e.type,...e.opacity!=null?{opacity:e.opacity}:{},...e.gradientStops?{stops:e.gradientStops.map(t=>({position:p(t.position),...h(t.color)}))}:{}}}function R(e,t){let i=e.absoluteBoundingBox,n={id:e.id,name:e.name,type:e.type};i&&(n.size={w:p(i.width),h:p(i.height)},n.position={x:p(i.x),y:p(i.y)}),e.opacity!=null&&e.opacity!==1&&(n.opacity=e.opacity),e.cornerRadius!=null&&(n.cornerRadius=e.cornerRadius),Array.isArray(e.rectangleCornerRadii)&&(n.cornerRadii=e.rectangleCornerRadii);let s=(e.fills||[]).map(I).filter(Boolean);s.length&&(n.fills=s);let r=(e.strokes||[]).map(I).filter(Boolean);r.length&&(n.strokes=r,e.strokeWeight!=null&&(n.strokeWeight=e.strokeWeight));let a=(e.effects||[]).filter(o=>o.visible!==!1).map(o=>({type:o.type,...o.radius!=null?{radius:o.radius}:{},...o.offset?{offset:{x:p(o.offset.x),y:p(o.offset.y)}}:{},...o.spread?{spread:o.spread}:{},...o.color?h(o.color):{}}));if(a.length&&(n.effects=a),e.layoutMode&&e.layoutMode!=="NONE"&&(n.autoLayout={direction:e.layoutMode,padding:{l:e.paddingLeft??0,r:e.paddingRight??0,t:e.paddingTop??0,b:e.paddingBottom??0},gap:e.itemSpacing??0,align:{primary:e.primaryAxisAlignItems,counter:e.counterAxisAlignItems}}),e.type==="TEXT"){let o=e.style||{};n.text=e.characters,n.textStyle={fontFamily:o.fontFamily,fontWeight:o.fontWeight,fontSize:o.fontSize,lineHeightPx:o.lineHeightPx!=null?p(o.lineHeightPx):void 0,letterSpacing:o.letterSpacing!=null?p(o.letterSpacing):void 0,align:o.textAlignHorizontal,case:o.textCase}}return t>0&&Array.isArray(e.children)&&e.children.length&&(n.children=e.children.map(o=>R(o,t-1))),n}var q={id:"figma",callsBackend:!0,serverName:"figma",allowedTools:["mcp__figma__*"],requiresIntegration:b.FIGMA,envKeys:["PROJECT_API_TOKEN","ZIBBY_ACCOUNT_API_URL","ZIBBY_ENV"],description:"Figma \u2014 read files, nodes and comments; extract dev-handoff specs (sizes/colors/fonts/auto-layout); list versions and image fills; render frames to PNG/JPG/SVG/PDF; browse team projects/files; and post comments",promptFragment:`## Figma
|
|
2
2
|
You have access to the user's Figma files via the Figma REST API. Every tool that takes a file accepts EITHER the raw file key OR a full figma.com URL (figma.com/file|design/<key>/...). Node ids accept URL form \`1-23\` or API form \`1:23\` interchangeably. Tools:
|
|
3
3
|
|
|
4
4
|
### Identity
|
|
@@ -29,4 +29,4 @@ You have access to the user's Figma files via the Figma REST API. Every tool tha
|
|
|
29
29
|
|
|
30
30
|
### Notes
|
|
31
31
|
- The file key is NOT the file name \u2014 it's the opaque id segment in the URL (or just paste the URL).
|
|
32
|
-
- Node ids look like "1:23" and come from figma_get_file / figma_get_nodes / figma_parse_url output.`,resolve(){let e=L();if(!e)return{command:null,args:[],env:{},description:this.description};let n={};for(let i of this.envKeys)process.env[i]&&(n[i]=process.env[i]);return{type:"stdio",command:"node",args:[e,"../dist/figma.js","figmaSkill"],env:n,description:this.description,alwaysLoad:!0}},async handleToolCall(e,n){try{switch(e){case"figma_get_me":{let i=await f("/v1/me");return JSON.stringify({id:i.id,handle:i.handle,email:i.email,imgUrl:i.img_url})}case"figma_get_file":{let i=g((n||{}).fileKey),{depth:o}=n||{};if(!i)return JSON.stringify({error:"fileKey is required (a file key or a figma.com URL)"});let s=`/v1/files/${encodeURIComponent(i)}`;if(o!=null){let t=Number(o);!Number.isNaN(t)&&t>0&&(s+=`?depth=${t}`)}let r=await f(s),a=(r.document?.children||[]).map(t=>({id:t.id,name:t.name,type:t.type,childCount:Array.isArray(t.children)?t.children.length:0,children:(t.children||[]).slice(0,50).map(c=>({id:c.id,name:c.name,type:c.type}))}));return JSON.stringify({name:r.name,lastModified:r.lastModified,version:r.version,editorType:r.editorType,role:r.role,pages:a})}case"figma_get_nodes":{let i=g((n||{}).fileKey),{ids:o,depth:s}=n||{};if(!i)return JSON.stringify({error:"fileKey is required (a file key or a figma.com URL)"});let r=u(o);if(!r)return JSON.stringify({error:"ids is required (comma-separated or array of node ids; `1-23` or `1:23`)"});let a=new URLSearchParams;if(a.set("ids",r),s!=null){let d=Number(s);!Number.isNaN(d)&&d>0&&a.set("depth",String(d))}let t=await f(`/v1/files/${encodeURIComponent(i)}/nodes?${a.toString()}`),c={};for(let[d,m]of Object.entries(t.nodes||{}))c[d]=m?.document?{id:m.document.id,name:m.document.name,type:m.document.type,document:m.document}:m;return JSON.stringify({name:t.name,nodes:c})}case"figma_get_node_specs":{let i=g((n||{}).file),{ids:o,depth:s}=n||{};if(!i)return JSON.stringify({error:"file is required (a file key or a figma.com URL)"});let r=u(o);if(!r)return JSON.stringify({error:"ids is required (comma-separated or array of node ids; `1-23` or `1:23`)"});let a=Number(s);Number.isNaN(a)&&(a=2),a=Math.min(6,Math.max(0,Math.trunc(a)));let t=new URLSearchParams;t.set("ids",r),t.set("depth",String(a));let c=await f(`/v1/files/${encodeURIComponent(i)}/nodes?${t.toString()}`),d={};for(let[m,l]of Object.entries(c.nodes||{}))d[m]=l&&l.document?R(l.document,a):null;return JSON.stringify(d)}case"figma_render_png":{let i=g((n||{}).fileKey??(n||{}).file),{ids:o,scale:s,format:r,svg_include_id:a,version:t}=n||{};if(!i)return JSON.stringify({error:"fileKey is required (a file key or a figma.com URL)"});let c=u(o);if(!c)return JSON.stringify({error:"ids is required (comma-separated or array of node ids; `1-23` or `1:23`)"});let d=["png","jpg","svg","pdf"].includes(String(r||"").toLowerCase())?String(r).toLowerCase():"png",m=new URLSearchParams;m.set("ids",c),m.set("format",d);let l;(d==="png"||d==="jpg")&&(l=Number(s),(Number.isNaN(l)||l<=0)&&(l=1),l=Math.min(4,Math.max(.01,l)),m.set("scale",String(l))),d==="svg"&&a!=null&&m.set("svg_include_id",String(!!a)),t&&m.set("version",String(t));let y=await f(`/v1/images/${encodeURIComponent(i)}?${m.toString()}`);return y.err?JSON.stringify({error:`Figma render error: ${y.err}`}):JSON.stringify({format:d,...l!=null?{scale:l}:{},images:y.images||{}})}case"figma_get_image_fills":{let i=g((n||{}).file);if(!i)return JSON.stringify({error:"file is required (a file key or a figma.com URL)"});let o=await f(`/v1/files/${encodeURIComponent(i)}/images`);return JSON.stringify({images:o.meta?.images??o.images??{}})}case"figma_get_file_versions":{let i=g((n||{}).file);if(!i)return JSON.stringify({error:"file is required (a file key or a figma.com URL)"});let s=((await f(`/v1/files/${encodeURIComponent(i)}/versions`)).versions||[]).map(r=>({id:r.id,label:r.label,description:r.description,createdAt:r.created_at,user:r.user?.handle}));return JSON.stringify({count:s.length,versions:s})}case"figma_get_comments":{let i=g((n||{}).fileKey);if(!i)return JSON.stringify({error:"fileKey is required (a file key or a figma.com URL)"});let s=((await f(`/v1/files/${encodeURIComponent(i)}/comments`)).comments||[]).map(r=>({id:r.id,message:r.message,user:r.user?.handle,createdAt:r.created_at,resolvedAt:r.resolved_at||null,parentId:r.parent_id||null}));return JSON.stringify({count:s.length,comments:s})}case"figma_post_comment":{let i=g((n||{}).file),{message:o,comment_id:s,node_id:r,x:a,y:t}=n||{};if(!i)return JSON.stringify({error:"file is required (a file key or a figma.com URL)"});if(!o)return JSON.stringify({error:"message is required"});let c={message:o};s&&(c.comment_id=s),r?c.client_meta={node_id:u(r),node_offset:{x:a??0,y:t??0}}:(a!=null||t!=null)&&(c.client_meta={x:a??0,y:t??0});let d=await f(`/v1/files/${encodeURIComponent(i)}/comments`,{method:"POST",body:c});return JSON.stringify({id:d.id,message:d.message,fileKey:i,createdAt:d.created_at,parentId:d.parent_id||null})}case"figma_get_team_projects":{let{team_id:i}=n||{};if(!i)return JSON.stringify({error:"team_id is required"});let o=await f(`/v1/teams/${encodeURIComponent(i)}/projects`);return JSON.stringify({name:o.name,projects:o.projects||[]})}case"figma_get_project_files":{let{project_id:i,branch_data:o}=n||{};if(!i)return JSON.stringify({error:"project_id is required"});let s=new URLSearchParams;o&&s.set("branch_data","true");let r=s.toString(),a=await f(`/v1/projects/${encodeURIComponent(i)}/files${r?`?${r}`:""}`);return JSON.stringify({name:a.name,files:a.files||[]})}case"figma_parse_url":{let{url:i}=n||{};return JSON.stringify({file_key:g(i),node_id:I(i)??null})}default:return JSON.stringify({error:`Unknown tool: ${e}`})}}catch(i){return JSON.stringify({error:i.message})}},tools:[{name:"figma_get_me",description:"Get the authenticated Figma user profile (handle, email, id)",input_schema:{type:"object",properties:{}}},{name:"figma_get_file",description:"Get a Figma file's document tree. Accepts a file key OR a figma.com URL (figma.com/file|design/<key>/... \u2014 NOT the file name). Returns a summarized map of pages and their top-level frames/nodes. Use figma_get_nodes or figma_get_node_specs to drill into a specific node.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:'A file key OR a figma.com URL (e.g. "aBcD1234" or figma.com/design/aBcD1234/My-File)'},depth:{type:"number",description:"Optional: limit how deep the node tree is traversed (1-2 is usually enough to list pages/frames). Omit for the full tree."}},required:["fileKey"]}},{name:"figma_get_nodes",description:"Get specific nodes from a Figma file by their node ids. Use after figma_get_file to inspect a particular frame/component without re-fetching the whole file.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"A file key OR a figma.com URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to fetch. Accepts URL form ["1-23"] or API form ["1:23"]. A comma-separated string is also accepted.'},depth:{type:"number",description:"Optional: limit traversal depth within each node."}},required:["fileKey","ids"]}},{name:"figma_get_node_specs",description:"Dev-Mode-style inspection computed from the REST tree: for the given nodes and their children returns size, position, colors (hex), fonts/text-style, spacing/auto-layout, corner radius, strokes and effects \u2014 a compact spec for reproducing a design in code. Prefer this over figma_get_nodes when your job is to build UI from a Figma file.",input_schema:{type:"object",properties:{file:{type:"string",description:"A file key OR a figma.com URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to inspect (URL form "1-23" or API form "1:23"). A comma-separated string is also accepted.'},depth:{type:"number",description:"How many levels of children to walk (0-6, default 2)."}},required:["file","ids"]}},{name:"figma_render_png",description:"Render one or more Figma nodes to an image and return the URLs (a map of nodeId \u2192 URL). Despite the name it renders PNG/JPG/SVG/PDF (default png). Use to show or download a visual of a frame/component.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"A file key OR a figma.com URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to render (URL form "1-23" or API form "1:23"). A comma-separated string is also accepted.'},format:{type:"string",enum:["png","jpg","svg","pdf"],description:"Output format (default png)."},scale:{type:"number",description:"Render scale, 0.01\u20134 (raster formats only; default 1). 2 for retina/hi-dpi."},svg_include_id:{type:"boolean",description:"For SVG: include element ids as attributes."},version:{type:"string",description:"Render a specific file version id (from figma_get_file_versions)."}},required:["fileKey","ids"]}},{name:"figma_get_image_fills",description:"Get a map of imageRef \u2192 download URL for every image fill used in a Figma file.",input_schema:{type:"object",properties:{file:{type:"string",description:"A file key OR a figma.com URL"}},required:["file"]}},{name:"figma_get_file_versions",description:"List a Figma file's saved version history (version id, label, created_at, user). A version id can be passed to figma_render_png to render a past version.",input_schema:{type:"object",properties:{file:{type:"string",description:"A file key OR a figma.com URL"}},required:["file"]}},{name:"figma_get_comments",description:"Read the comments on a Figma file",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"A file key OR a figma.com URL"}},required:["fileKey"]}},{name:"figma_post_comment",description:"Post a comment on a Figma file (WRITE \u2014 needs a PAT with comment-write scope). Optionally reply to a comment (comment_id), pin it to a node (node_id, with optional x/y offset), or pin to a canvas point (x/y).",input_schema:{type:"object",properties:{file:{type:"string",description:"A file key OR a figma.com URL"},message:{type:"string",description:"The comment text."},comment_id:{type:"string",description:"Optional: reply to this parent comment id."},node_id:{type:"string",description:'Optional: pin the comment to this node ("1-23" or "1:23").'},x:{type:"number",description:"Optional: x position (node offset if node_id given, else canvas point)."},y:{type:"number",description:"Optional: y position (node offset if node_id given, else canvas point)."}},required:["file","message"]}},{name:"figma_get_team_projects",description:"List the projects in a Figma team. Get team_id from a Figma team URL (\u2026/files/team/<TEAM_ID>/\u2026).",input_schema:{type:"object",properties:{team_id:{type:"string",description:"The Figma team id."}},required:["team_id"]}},{name:"figma_get_project_files",description:"List the files in a Figma project (from figma_get_team_projects). Returns file key, name, thumbnail, last_modified.",input_schema:{type:"object",properties:{project_id:{type:"string",description:"The Figma project id."},branch_data:{type:"boolean",description:"Optional: include branch metadata for each file."}},required:["project_id"]}},{name:"figma_parse_url",description:"Local helper (no API call): extract the file key and node id (colon form) from a figma.com file/design URL. Returns { file_key, node_id }.",input_schema:{type:"object",properties:{url:{type:"string",description:"A full figma.com file/design URL."}},required:["url"]}}]};export{F as figmaSkill,g as fileKeyFrom,I as nodeIdFromUrl,R as nodeSpec,u as normalizeNodeIds};
|
|
32
|
+
- Node ids look like "1:23" and come from figma_get_file / figma_get_nodes / figma_parse_url output.`,resolve(){let e=w();if(!e)return{command:null,args:[],env:{},description:this.description};let t={};for(let i of this.envKeys)process.env[i]&&(t[i]=process.env[i]);return{type:"stdio",command:"node",args:[e,"../dist/figma.js","figmaSkill"],env:t,description:this.description,alwaysLoad:!0}},async handleToolCall(e,t){try{switch(e){case"figma_get_me":{let i=await f("/v1/me");return JSON.stringify({id:i.id,handle:i.handle,email:i.email,imgUrl:i.img_url})}case"figma_get_file":{let i=g((t||{}).fileKey),{depth:n}=t||{};if(!i)return JSON.stringify({error:"fileKey is required (a file key or a figma.com URL)"});let s=`/v1/files/${encodeURIComponent(i)}`;if(n!=null){let o=Number(n);!Number.isNaN(o)&&o>0&&(s+=`?depth=${o}`)}let r=await f(s),a=(r.document?.children||[]).map(o=>({id:o.id,name:o.name,type:o.type,childCount:Array.isArray(o.children)?o.children.length:0,children:(o.children||[]).slice(0,50).map(c=>({id:c.id,name:c.name,type:c.type}))}));return JSON.stringify({name:r.name,lastModified:r.lastModified,version:r.version,editorType:r.editorType,role:r.role,pages:a})}case"figma_get_nodes":{let i=g((t||{}).fileKey),{ids:n,depth:s}=t||{};if(!i)return JSON.stringify({error:"fileKey is required (a file key or a figma.com URL)"});let r=_(n);if(!r)return JSON.stringify({error:"ids is required (comma-separated or array of node ids; `1-23` or `1:23`)"});let a=new URLSearchParams;if(a.set("ids",r),s!=null){let d=Number(s);!Number.isNaN(d)&&d>0&&a.set("depth",String(d))}let o=await f(`/v1/files/${encodeURIComponent(i)}/nodes?${a.toString()}`),c={};for(let[d,m]of Object.entries(o.nodes||{}))c[d]=m?.document?{id:m.document.id,name:m.document.name,type:m.document.type,document:m.document}:m;return JSON.stringify({name:o.name,nodes:c})}case"figma_get_node_specs":{let i=g((t||{}).file),{ids:n,depth:s}=t||{};if(!i)return JSON.stringify({error:"file is required (a file key or a figma.com URL)"});let r=_(n);if(!r)return JSON.stringify({error:"ids is required (comma-separated or array of node ids; `1-23` or `1:23`)"});let a=Number(s);Number.isNaN(a)&&(a=2),a=Math.min(6,Math.max(0,Math.trunc(a)));let o=new URLSearchParams;o.set("ids",r),o.set("depth",String(a));let c=await f(`/v1/files/${encodeURIComponent(i)}/nodes?${o.toString()}`),d={};for(let[m,l]of Object.entries(c.nodes||{}))d[m]=l&&l.document?R(l.document,a):null;return JSON.stringify(d)}case"figma_render_png":{let i=g((t||{}).fileKey??(t||{}).file),{ids:n,scale:s,format:r,svg_include_id:a,version:o}=t||{};if(!i)return JSON.stringify({error:"fileKey is required (a file key or a figma.com URL)"});let c=_(n);if(!c)return JSON.stringify({error:"ids is required (comma-separated or array of node ids; `1-23` or `1:23`)"});let d=["png","jpg","svg","pdf"].includes(String(r||"").toLowerCase())?String(r).toLowerCase():"png",m=new URLSearchParams;m.set("ids",c),m.set("format",d);let l;(d==="png"||d==="jpg")&&(l=Number(s),(Number.isNaN(l)||l<=0)&&(l=1),l=Math.min(4,Math.max(.01,l)),m.set("scale",String(l))),d==="svg"&&a!=null&&m.set("svg_include_id",String(!!a)),o&&m.set("version",String(o));let y=await f(`/v1/images/${encodeURIComponent(i)}?${m.toString()}`);return y.err?JSON.stringify({error:`Figma render error: ${y.err}`}):JSON.stringify({format:d,...l!=null?{scale:l}:{},images:y.images||{}})}case"figma_get_image_fills":{let i=g((t||{}).file);if(!i)return JSON.stringify({error:"file is required (a file key or a figma.com URL)"});let n=await f(`/v1/files/${encodeURIComponent(i)}/images`);return JSON.stringify({images:n.meta?.images??n.images??{}})}case"figma_get_file_versions":{let i=g((t||{}).file);if(!i)return JSON.stringify({error:"file is required (a file key or a figma.com URL)"});let s=((await f(`/v1/files/${encodeURIComponent(i)}/versions`)).versions||[]).map(r=>({id:r.id,label:r.label,description:r.description,createdAt:r.created_at,user:r.user?.handle}));return JSON.stringify({count:s.length,versions:s})}case"figma_get_comments":{let i=g((t||{}).fileKey);if(!i)return JSON.stringify({error:"fileKey is required (a file key or a figma.com URL)"});let s=((await f(`/v1/files/${encodeURIComponent(i)}/comments`)).comments||[]).map(r=>({id:r.id,message:r.message,user:r.user?.handle,createdAt:r.created_at,resolvedAt:r.resolved_at||null,parentId:r.parent_id||null}));return JSON.stringify({count:s.length,comments:s})}case"figma_post_comment":{let i=g((t||{}).file),{message:n,comment_id:s,node_id:r,x:a,y:o}=t||{};if(!i)return JSON.stringify({error:"file is required (a file key or a figma.com URL)"});if(!n)return JSON.stringify({error:"message is required"});let c={message:n};s&&(c.comment_id=s),r?c.client_meta={node_id:_(r),node_offset:{x:a??0,y:o??0}}:(a!=null||o!=null)&&(c.client_meta={x:a??0,y:o??0});let d=await f(`/v1/files/${encodeURIComponent(i)}/comments`,{method:"POST",body:c});return JSON.stringify({id:d.id,message:d.message,fileKey:i,createdAt:d.created_at,parentId:d.parent_id||null})}case"figma_get_team_projects":{let{team_id:i}=t||{};if(!i)return JSON.stringify({error:"team_id is required"});let n=await f(`/v1/teams/${encodeURIComponent(i)}/projects`);return JSON.stringify({name:n.name,projects:n.projects||[]})}case"figma_get_project_files":{let{project_id:i,branch_data:n}=t||{};if(!i)return JSON.stringify({error:"project_id is required"});let s=new URLSearchParams;n&&s.set("branch_data","true");let r=s.toString(),a=await f(`/v1/projects/${encodeURIComponent(i)}/files${r?`?${r}`:""}`);return JSON.stringify({name:a.name,files:a.files||[]})}case"figma_parse_url":{let{url:i}=t||{};return JSON.stringify({file_key:g(i),node_id:M(i)??null})}default:return JSON.stringify({error:`Unknown tool: ${e}`})}}catch(i){return JSON.stringify({error:i.message})}},tools:[{name:"figma_get_me",description:"Get the authenticated Figma user profile (handle, email, id)",input_schema:{type:"object",properties:{}}},{name:"figma_get_file",description:"Get a Figma file's document tree. Accepts a file key OR a figma.com URL (figma.com/file|design/<key>/... \u2014 NOT the file name). Returns a summarized map of pages and their top-level frames/nodes. Use figma_get_nodes or figma_get_node_specs to drill into a specific node.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:'A file key OR a figma.com URL (e.g. "aBcD1234" or figma.com/design/aBcD1234/My-File)'},depth:{type:"number",description:"Optional: limit how deep the node tree is traversed (1-2 is usually enough to list pages/frames). Omit for the full tree."}},required:["fileKey"]}},{name:"figma_get_nodes",description:"Get specific nodes from a Figma file by their node ids. Use after figma_get_file to inspect a particular frame/component without re-fetching the whole file.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"A file key OR a figma.com URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to fetch. Accepts URL form ["1-23"] or API form ["1:23"]. A comma-separated string is also accepted.'},depth:{type:"number",description:"Optional: limit traversal depth within each node."}},required:["fileKey","ids"]}},{name:"figma_get_node_specs",description:"Dev-Mode-style inspection computed from the REST tree: for the given nodes and their children returns size, position, colors (hex), fonts/text-style, spacing/auto-layout, corner radius, strokes and effects \u2014 a compact spec for reproducing a design in code. Prefer this over figma_get_nodes when your job is to build UI from a Figma file.",input_schema:{type:"object",properties:{file:{type:"string",description:"A file key OR a figma.com URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to inspect (URL form "1-23" or API form "1:23"). A comma-separated string is also accepted.'},depth:{type:"number",description:"How many levels of children to walk (0-6, default 2)."}},required:["file","ids"]}},{name:"figma_render_png",description:"Render one or more Figma nodes to an image and return the URLs (a map of nodeId \u2192 URL). Despite the name it renders PNG/JPG/SVG/PDF (default png). Use to show or download a visual of a frame/component.",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"A file key OR a figma.com URL"},ids:{type:"array",items:{type:"string"},description:'Node ids to render (URL form "1-23" or API form "1:23"). A comma-separated string is also accepted.'},format:{type:"string",enum:["png","jpg","svg","pdf"],description:"Output format (default png)."},scale:{type:"number",description:"Render scale, 0.01\u20134 (raster formats only; default 1). 2 for retina/hi-dpi."},svg_include_id:{type:"boolean",description:"For SVG: include element ids as attributes."},version:{type:"string",description:"Render a specific file version id (from figma_get_file_versions)."}},required:["fileKey","ids"]}},{name:"figma_get_image_fills",description:"Get a map of imageRef \u2192 download URL for every image fill used in a Figma file.",input_schema:{type:"object",properties:{file:{type:"string",description:"A file key OR a figma.com URL"}},required:["file"]}},{name:"figma_get_file_versions",description:"List a Figma file's saved version history (version id, label, created_at, user). A version id can be passed to figma_render_png to render a past version.",input_schema:{type:"object",properties:{file:{type:"string",description:"A file key OR a figma.com URL"}},required:["file"]}},{name:"figma_get_comments",description:"Read the comments on a Figma file",input_schema:{type:"object",properties:{fileKey:{type:"string",description:"A file key OR a figma.com URL"}},required:["fileKey"]}},{name:"figma_post_comment",description:"Post a comment on a Figma file (WRITE \u2014 needs a PAT with comment-write scope). Optionally reply to a comment (comment_id), pin it to a node (node_id, with optional x/y offset), or pin to a canvas point (x/y).",input_schema:{type:"object",properties:{file:{type:"string",description:"A file key OR a figma.com URL"},message:{type:"string",description:"The comment text."},comment_id:{type:"string",description:"Optional: reply to this parent comment id."},node_id:{type:"string",description:'Optional: pin the comment to this node ("1-23" or "1:23").'},x:{type:"number",description:"Optional: x position (node offset if node_id given, else canvas point)."},y:{type:"number",description:"Optional: y position (node offset if node_id given, else canvas point)."}},required:["file","message"]}},{name:"figma_get_team_projects",description:"List the projects in a Figma team. Get team_id from a Figma team URL (\u2026/files/team/<TEAM_ID>/\u2026).",input_schema:{type:"object",properties:{team_id:{type:"string",description:"The Figma team id."}},required:["team_id"]}},{name:"figma_get_project_files",description:"List the files in a Figma project (from figma_get_team_projects). Returns file key, name, thumbnail, last_modified.",input_schema:{type:"object",properties:{project_id:{type:"string",description:"The Figma project id."},branch_data:{type:"boolean",description:"Optional: include branch metadata for each file."}},required:["project_id"]}},{name:"figma_parse_url",description:"Local helper (no API call): extract the file key and node id (colon form) from a figma.com file/design URL. Returns { file_key, node_id }.",input_schema:{type:"object",properties:{url:{type:"string",description:"A full figma.com file/design URL."}},required:["url"]}}]};export{q as figmaSkill,g as fileKeyFrom,M as nodeIdFromUrl,R as nodeSpec,_ as normalizeNodeIds};
|