figura-mcp 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{promises as _,readFileSync as D}from"node:fs";import{homedir as M}from"node:os";import{join as U}from"node:path";import x from"axios";import{McpServer as A}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as R}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as K}from"zod";var l="https://api.figura.so",m="mcp",N=U(M(),".figura","config.json");function n(){return(process.env.FIGURA_API_URL||l).replace(/\/+$/,"")}async function E(){if(process.env.FIGURA_TOKEN)return process.env.FIGURA_TOKEN;try{let B=await _.readFile(N,"utf8"),J=JSON.parse(B);if(J&&typeof J==="object"&&typeof J.token==="string")return J.token}catch{}return}async function X(B,J={}){let Q=await E();if(!Q)throw Error("No Figura token. Set FIGURA_TOKEN or run `figura login` to create ~/.figura/config.json.");let P=`${n()}${B.startsWith("/")?"":"/"}${B}`,C={Accept:"application/json",Authorization:`Bearer ${Q}`,"X-Figura-Source":m},L;if(J.body!==void 0)C["Content-Type"]="application/json",L=JSON.stringify(J.body);let w=await x.request({url:P,method:J.method??"GET",headers:C,data:L,validateStatus:()=>!0,transformRequest:[(G)=>G],transformResponse:[(G)=>G]}),V=typeof w.data==="string"?w.data:"",$=void 0;if(V)try{$=JSON.parse(V)}catch{$=V}if(w.status<200||w.status>=300){let G=$&&typeof $==="object"&&$!==null&&"error"in $?String($.error):typeof $==="string"&&$?$:w.statusText||`HTTP ${w.status}`;throw Error(`${G} (HTTP ${w.status})`)}return $}function Y(B){return{content:[{type:"text",text:JSON.stringify(B,null,2)}]}}function Z(B){return{content:[{type:"text",text:B instanceof Error?B.message:String(B)}],isError:!0}}var H=()=>K.string().optional().describe("Product area / surface the fig belongs to, e.g. 'dashboard', 'settings', 'onboarding'. Free text."),j=["portrait","landscape","both"],q=["single","compare","variations"],T=(()=>{try{let B=JSON.parse(D(new URL("../package.json",import.meta.url),"utf8"));return typeof B.version==="string"?B.version:"0.0.0"}catch{return"0.0.0"}})(),W=new A({name:"figura",version:T});W.registerTool("figura_whoami",{title:"Figura: whoami",description:"Return the identity (team, actor, scopes) for the configured Figura token.",inputSchema:{}},async()=>{try{return Y(await X("/v1/whoami"))}catch(B){return Z(B)}});W.registerTool("figura_set_brand",{title:"Figura: set brand profile",description:'Set (upsert) the team brand profile that the fig generator renders against. Use this to "introduce a repo to Figura": scan the codebase for its design system, synthesize the brand, then push it here. `name` is required; `appDescription` is a one-clause product summary; `tokensBlock` is the freeform design-token reference (colors + hex + role, type scale + faces, spacing, the brand gradient, plus voice/conventions). This is a partial merge — fields you omit keep their saved value (pass an explicit empty string to clear one), so a name-only update will not wipe existing tokens. Editing the team brand — confirm with the user before calling.',inputSchema:{name:K.string().describe("Brand / app name (required)."),appDescription:K.string().optional().describe("One clause on what the product is + who it is for."),tokensBlock:K.string().optional().describe("Freeform plain-text design-token reference: colors (hex + role), type scale + faces, spacing, the brand gradient, and voice/conventions. Injected verbatim into the fig-generation prompt.")}},async(B)=>{try{let J={name:B.name};if(B.appDescription!==void 0)J.appDescription=B.appDescription;if(B.tokensBlock!==void 0)J.tokensBlock=B.tokensBlock;return Y(await X("/brand",{method:"PUT",body:J}))}catch(J){return Z(J)}});W.registerTool("figura_create_fig",{title:"Figura: create fig",description:"Create a new visualization from an HTML document. Returns the created fig (id, slug); with publish:true it is published and the result includes a shareable public url.",inputSchema:{html:K.string().describe("The full HTML document for the visualization."),title:K.string().optional().describe("Title (otherwise derived from the HTML)."),description:K.string().optional(),area:H(),tags:K.array(K.string()).optional(),orientation:K.enum(j).optional(),mode:K.enum(q).optional(),model:K.string().optional().describe("Model attribution."),issue:K.number().optional().describe("Linked issue number."),publish:K.boolean().optional().describe("Publish to a shareable public URL on create (requires a paid plan).")}},async(B)=>{try{let J={html:B.html};for(let Q of["title","description","area","tags","orientation","mode","model","issue","publish"])if(B[Q]!==void 0)J[Q]=B[Q];return Y(await X("/v1/figs",{method:"POST",body:J}))}catch(J){return Z(J)}});W.registerTool("figura_generate_fig",{title:"Figura: generate fig",description:"Generate a new fig server-side from a natural-language brief, then persist it. The engine runs Figura's on-brand generation — you do NOT write the HTML; just describe the screen. Returns the created fig (id, slug); publish:true publishes it with a shareable url. Requires an active paid subscription.",inputSchema:{prompt:K.string().describe("A natural-language brief describing the screen/UI to generate."),area:H(),orientation:K.enum(j).optional(),mode:K.enum(q).optional(),title:K.string().optional().describe("Title (otherwise derived from the generated HTML)."),fidelity:K.enum(["fast","high"]).optional().describe("Generation fidelity (default fast)."),publish:K.boolean().optional().describe("Publish to a shareable public URL on create (requires a paid plan).")}},async(B)=>{try{let J={prompt:B.prompt};for(let Q of["area","orientation","mode","title","fidelity","publish"])if(B[Q]!==void 0)J[Q]=B[Q];return Y(await X("/v1/figs/generate",{method:"POST",body:J}))}catch(J){return Z(J)}});W.registerTool("figura_revise_fig",{title:"Figura: revise fig",description:"Create a new revision (version) of an existing fig from updated HTML. Returns the new fig (id, slug, version, rootFigId); publish:true publishes it with a shareable url. The new version joins the original fig's chain — it does not replace it in place.",inputSchema:{id:K.string().describe("The fig id to create a new revision of."),html:K.string().describe("The full updated HTML document."),title:K.string().optional().describe("Title (otherwise derived from the HTML)."),description:K.string().optional(),area:K.string().optional().describe("Product area / surface; free text. Inherited from the parent if omitted."),tags:K.array(K.string()).optional(),orientation:K.enum(j).optional().describe("Inherited from the parent if omitted."),mode:K.enum(q).optional(),model:K.string().optional().describe("Model attribution."),issue:K.number().optional().describe("Linked issue number."),publish:K.boolean().optional().describe("Publish the new revision to a shareable public URL (requires a paid plan).")}},async(B)=>{try{let J={html:B.html};for(let Q of["title","description","area","tags","orientation","mode","model","issue","publish"])if(B[Q]!==void 0)J[Q]=B[Q];return Y(await X(`/v1/figs/${encodeURIComponent(B.id)}/revise`,{method:"POST",body:J}))}catch(J){return Z(J)}});W.registerTool("figura_list_revisions",{title:"Figura: list revisions",description:"List the full revision chain for a fig (all versions sharing a root), oldest to newest.",inputSchema:{id:K.string().describe("Any fig id in the chain.")}},async(B)=>{try{return Y(await X(`/v1/figs/${encodeURIComponent(B.id)}/revisions`))}catch(J){return Z(J)}});W.registerTool("figura_publish_fig",{title:"Figura: publish fig",description:"Publish (or unpublish) an existing fig to its shareable public URL. Requires a paid plan. Returns { isPublic, url, publicId }.",inputSchema:{id:K.string().describe("The fig id to publish."),isPublic:K.boolean().optional().describe("Set false to unpublish (make private). Defaults to true (publish).")}},async(B)=>{try{let J={};if(B.isPublic!==void 0)J.isPublic=B.isPublic;return Y(await X(`/v1/figs/${encodeURIComponent(B.id)}/publish`,{method:"POST",body:J}))}catch(J){return Z(J)}});W.registerTool("figura_list_figs",{title:"Figura: list figs",description:"List visualizations for the team, optionally filtered by area or tag.",inputSchema:{area:H(),tag:K.string().optional(),limit:K.number().optional(),cursor:K.string().optional()}},async(B)=>{try{let J=new URLSearchParams;if(B.area)J.set("area",B.area);if(B.tag)J.set("tag",B.tag);if(B.limit!==void 0)J.set("limit",String(B.limit));if(B.cursor)J.set("cursor",B.cursor);let Q=J.toString();return Y(await X(`/v1/figs${Q?`?${Q}`:""}`))}catch(J){return Z(J)}});W.registerTool("figura_get_fig",{title:"Figura: get fig",description:"Fetch a single visualization by id.",inputSchema:{id:K.string().describe("The fig id.")}},async(B)=>{try{return Y(await X(`/v1/figs/${encodeURIComponent(B.id)}`))}catch(J){return Z(J)}});W.registerTool("figura_comment",{title:"Figura: comment",description:"Add a comment to a visualization.",inputSchema:{fig_id:K.string().describe("The fig id to comment on."),body:K.string().describe("Comment text.")}},async(B)=>{try{return Y(await X(`/v1/figs/${encodeURIComponent(B.fig_id)}/comments`,{method:"POST",body:{body:B.body}}))}catch(J){return Z(J)}});W.registerTool("figura_request_feedback",{title:"Figura: request feedback",description:"Ask a teammate to review a fig. Resolve `from` to a team member (by name or email); they get a notification (in-app, push, email) and the discussion happens in the fig's comment thread. Use this when the user says they want a specific person's feedback/eyes/review on a fig. Returns { ok, request: { to, status }, figUrl }.",inputSchema:{id:K.string().describe("The fig id to request feedback on."),from:K.string().describe("The teammate to ask, by name or email (resolved within the team)."),note:K.string().optional().describe("Optional message for them (e.g. what to look at).")}},async(B)=>{try{let J={from:B.from};if(B.note!==void 0)J.note=B.note;return Y(await X(`/v1/figs/${encodeURIComponent(B.id)}/request-feedback`,{method:"POST",body:J}))}catch(J){return Z(J)}});W.registerTool("figura_list_sources",{title:"Figura: list sources",description:"List the company-brain source-spine connectors for the team, with event counts and last-synced times.",inputSchema:{}},async()=>{try{return Y(await X("/v1/sources"))}catch(B){return Z(B)}});W.registerTool("figura_sync_source",{title:"Figura: sync source",description:"Ingest new events from a connected source into the spine. Returns { ingested, fetched, nextCursor }.",inputSchema:{id:K.string().describe("The source id to sync (from figura_list_sources).")}},async(B)=>{try{return Y(await X(`/v1/sources/${encodeURIComponent(B.id)}/sync`,{method:"POST"}))}catch(J){return Z(J)}});W.registerTool("figura_update_fig",{title:"Figura: update fig",description:"Update a fig's metadata in place (title/description/area/tags/status) and optionally replace its HTML. Set status='archived' to soft-delete.",inputSchema:{id:K.string().describe("The fig id to update."),title:K.string().optional(),description:K.string().optional(),area:H(),tags:K.array(K.string()).optional().describe("Replaces the existing tags."),status:K.enum(["draft","published","archived"]).optional(),html:K.string().optional().describe("Replace the rendered HTML in place.")}},async(B)=>{try{let J={};if(B.title!==void 0)J.title=B.title;if(B.description!==void 0)J.description=B.description;if(B.area!==void 0)J.area=B.area;if(B.tags!==void 0)J.tags=B.tags;if(B.status!==void 0)J.status=B.status;if(B.html!==void 0)J.html=B.html;return Y(await X(`/v1/figs/${encodeURIComponent(B.id)}`,{method:"PATCH",body:J}))}catch(J){return Z(J)}});W.registerTool("figura_delete_fig",{title:"Figura: delete fig",description:"Archive a fig (soft-delete; leaves the library, public link stops resolving) or permanently delete it with hard=true.",inputSchema:{id:K.string().describe("The fig id to delete."),hard:K.boolean().optional().describe("Permanently delete instead of archive.")}},async(B)=>{try{return Y(await X(`/v1/figs/${encodeURIComponent(B.id)}${B.hard?"?hard=true":""}`,{method:"DELETE"}))}catch(J){return Z(J)}});await W.connect(new R);
|
|
2
|
+
import{existsSync as E,promises as U,readFileSync as m}from"node:fs";import{homedir as j}from"node:os";import{dirname as P,join as w}from"node:path";import O from"axios";import{McpServer as S}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as l}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as W}from"zod";var T="https://api.figura.so",F="mcp",C=w(j(),".figura","config.json"),b=w(".figura","config.json");async function N(K){try{let Q=JSON.parse(await U.readFile(K,"utf8"));if(Q&&typeof Q==="object")return Q}catch{}return{}}async function u(K=process.cwd()){let Q=j(),Z=K;for(;;){if(Z!==Q){let Y=w(Z,b);try{return await U.access(Y),Y}catch{}}let H=P(Z);if(H===Z)return null;Z=H}}function f(K=process.cwd()){let Q=K;for(;;){if(E(w(Q,".git")))return!0;let Z=P(Q);if(Z===Q)return!1;Q=Z}}async function I(){let K=await u(),Q=K?await N(K):{},Z=await N(C),H={...Z,...Q},Y=process.env.FIGURA_TOKEN||H.token||void 0,L=process.env.FIGURA_TOKEN?"env":Q.token?"project":Z.token?"global":"none",G=(process.env.FIGURA_API_URL||H.apiUrl||T).replace(/\/+$/,"");return{token:Y,apiUrl:G,team:H.team,source:L,configPath:L==="project"?K:L==="global"?C:null}}async function B(K,Q={}){let Z=await I(),H=Z.token;if(!H)throw Error("No Figura token. Run `figura link` in this repo (or `figura login`, or set FIGURA_TOKEN).");if((Q.method??"GET").toUpperCase()!=="GET"&&Z.source==="global"&&f()&&process.env.FIGURA_ALLOW_GLOBAL!=="1")throw Error(`this project isn't linked to a Figura team — the global credential${Z.team?` (team '${Z.team}')`:""} would receive this write. Ask the user to run \`figura link\` in this repo (or set FIGURA_ALLOW_GLOBAL=1 to use the global team deliberately).`);let L=`${Z.apiUrl}${K.startsWith("/")?"":"/"}${K}`,G={Accept:"application/json",Authorization:`Bearer ${H}`,"X-Figura-Source":F},_;if(Q.body!==void 0)G["Content-Type"]="application/json",_=JSON.stringify(Q.body);let J=await O.request({url:L,method:Q.method??"GET",headers:G,data:_,validateStatus:()=>!0,transformRequest:[(D)=>D],transformResponse:[(D)=>D]}),x=typeof J.data==="string"?J.data:"",q=void 0;if(x)try{q=JSON.parse(x)}catch{q=x}if(J.status<200||J.status>=300){let D=q&&typeof q==="object"&&q!==null&&"error"in q?String(q.error):typeof q==="string"&&q?q:J.statusText||`HTTP ${J.status}`;throw Error(`${D} (HTTP ${J.status})`)}return q}function V(K){return{content:[{type:"text",text:JSON.stringify(K,null,2)}]}}function X(K){return{content:[{type:"text",text:K instanceof Error?K.message:String(K)}],isError:!0}}var M=()=>W.string().optional().describe("Product area / surface the fig belongs to, e.g. 'dashboard', 'settings', 'onboarding'. Free text."),A=["portrait","landscape","both"],R=["single","compare","variations"],v=(()=>{try{let K=JSON.parse(m(new URL("../package.json",import.meta.url),"utf8"));return typeof K.version==="string"?K.version:"0.0.0"}catch{return"0.0.0"}})(),$=new S({name:"figura",version:v});$.registerTool("figura_whoami",{title:"Figura: whoami",description:"Return the identity (team, actor, scopes) for the configured Figura token, plus `binding` — which config tier supplied it (env | project | global). A `global` binding means this project is not linked to a team and writes will be refused; ask the user to run `figura link` in the repo.",inputSchema:{}},async()=>{try{let K=await B("/v1/whoami"),{source:Q,configPath:Z}=await I();return V({...K,binding:{source:Q,configPath:Z}})}catch(K){return X(K)}});$.registerTool("figura_set_brand",{title:"Figura: set brand profile",description:'Set (upsert) the team brand profile that the fig generator renders against. Use this to "introduce a repo to Figura": scan the codebase for its design system, synthesize the brand, then push it here. `name` is required; `appDescription` is a one-clause product summary; `tokensBlock` is the freeform design-token reference (colors + hex + role, type scale + faces, spacing, the brand gradient, plus voice/conventions). This is a partial merge — fields you omit keep their saved value (pass an explicit empty string to clear one), so a name-only update will not wipe existing tokens. Editing the team brand — confirm with the user before calling.',inputSchema:{name:W.string().describe("Brand / app name (required)."),appDescription:W.string().optional().describe("One clause on what the product is + who it is for."),tokensBlock:W.string().optional().describe("Freeform plain-text design-token reference: colors (hex + role), type scale + faces, spacing, the brand gradient, and voice/conventions. Injected verbatim into the fig-generation prompt.")}},async(K)=>{try{let Q={name:K.name};if(K.appDescription!==void 0)Q.appDescription=K.appDescription;if(K.tokensBlock!==void 0)Q.tokensBlock=K.tokensBlock;return V(await B("/brand",{method:"PUT",body:Q}))}catch(Q){return X(Q)}});$.registerTool("figura_create_fig",{title:"Figura: create fig",description:"Create a new visualization from an HTML document. Returns the created fig (id, slug); with publish:true it is published and the result includes a shareable public url.",inputSchema:{html:W.string().describe("The full HTML document for the visualization."),title:W.string().optional().describe("Title (otherwise derived from the HTML)."),description:W.string().optional(),area:M(),tags:W.array(W.string()).optional(),orientation:W.enum(A).optional(),mode:W.enum(R).optional(),model:W.string().optional().describe("Model attribution."),issue:W.number().optional().describe("Linked issue number."),publish:W.boolean().optional().describe("Publish to a shareable public URL on create (requires a paid plan).")}},async(K)=>{try{let Q={html:K.html};for(let Z of["title","description","area","tags","orientation","mode","model","issue","publish"])if(K[Z]!==void 0)Q[Z]=K[Z];return V(await B("/v1/figs",{method:"POST",body:Q}))}catch(Q){return X(Q)}});var k={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",svg:"image/svg+xml"};$.registerTool("figura_upload_asset",{title:"Figura: upload asset",description:"Upload a durable image asset and get back a STABLE, figura-hosted URL that never expires — use it in a fig's <img src> instead of a base64 data-URI (bloats the HTML past the publish size) or an external URL that expires (Instagram/CDN signed links). The fig CSP allows figura-hosted images. Provide either `path` (a local image file, content-type inferred from its extension) or `data` (base64 bytes) + `contentType`. Accepts png/jpeg/gif/webp/avif/svg, up to 5MB. Returns `{ url }`.",inputSchema:{path:W.string().optional().describe("Local path to an image file to upload (content-type inferred from the extension)."),data:W.string().optional().describe("Base64-encoded image bytes (alternative to `path`). Requires `contentType`."),contentType:W.string().optional().describe("MIME type for `data`, e.g. image/png. Required with `data`; inferred from `path`.")}},async(K)=>{try{let{data:Q,contentType:Z}=K;if(K.path){if(Q=(await U.readFile(K.path)).toString("base64"),!Z){let Y=K.path.split(".").pop()?.toLowerCase()??"";Z=k[Y]}}if(!Q)throw Error("Provide `path` (a local image file) or `data` (base64 bytes).");if(!Z)throw Error("`contentType` is required (could not infer from the file extension) — e.g. image/png.");return V(await B("/v1/assets",{method:"POST",body:{data:Q,contentType:Z}}))}catch(Q){return X(Q)}});$.registerTool("figura_generate_fig",{title:"Figura: generate fig",description:"Generate a new fig server-side from a natural-language brief, then persist it. The engine runs Figura's on-brand generation — you do NOT write the HTML; just describe the screen. Returns the created fig (id, slug); publish:true publishes it with a shareable url. Requires an active paid subscription.",inputSchema:{prompt:W.string().describe("A natural-language brief describing the screen/UI to generate."),area:M(),orientation:W.enum(A).optional(),mode:W.enum(R).optional(),title:W.string().optional().describe("Title (otherwise derived from the generated HTML)."),fidelity:W.enum(["fast","high"]).optional().describe("Generation fidelity (default fast)."),publish:W.boolean().optional().describe("Publish to a shareable public URL on create (requires a paid plan).")}},async(K)=>{try{let Q={prompt:K.prompt};for(let Z of["area","orientation","mode","title","fidelity","publish"])if(K[Z]!==void 0)Q[Z]=K[Z];return V(await B("/v1/figs/generate",{method:"POST",body:Q}))}catch(Q){return X(Q)}});$.registerTool("figura_revise_fig",{title:"Figura: revise fig",description:"Create a new revision (version) of an existing fig from updated HTML. Returns the new fig (id, slug, version); publish:true publishes it with a shareable url. The new version joins the original fig's chain — it does not replace it in place. Use list_revisions for the chain (rootFig + every version).",inputSchema:{id:W.string().describe("The fig to revise — its id (`fig_…`), a UUID, a share link/URL, or its publicId."),html:W.string().describe("The full updated HTML document."),title:W.string().optional().describe("Title (otherwise derived from the HTML)."),description:W.string().optional(),area:W.string().optional().describe("Product area / surface; free text. Inherited from the parent if omitted."),tags:W.array(W.string()).optional(),orientation:W.enum(A).optional().describe("Inherited from the parent if omitted."),mode:W.enum(R).optional(),model:W.string().optional().describe("Model attribution."),issue:W.number().optional().describe("Linked issue number."),publish:W.boolean().optional().describe("Publish the new revision to a shareable public URL (requires a paid plan).")}},async(K)=>{try{let Q={html:K.html};for(let Z of["title","description","area","tags","orientation","mode","model","issue","publish"])if(K[Z]!==void 0)Q[Z]=K[Z];return V(await B(`/v1/figs/${encodeURIComponent(K.id)}/revise`,{method:"POST",body:Q}))}catch(Q){return X(Q)}});$.registerTool("figura_list_revisions",{title:"Figura: list revisions",description:"List the full revision chain for a fig (all versions sharing a root), oldest to newest.",inputSchema:{id:W.string().describe("Any fig in the chain — its id (`fig_…`), a UUID, share link/URL, or publicId.")}},async(K)=>{try{return V(await B(`/v1/figs/${encodeURIComponent(K.id)}/revisions`))}catch(Q){return X(Q)}});$.registerTool("figura_publish_fig",{title:"Figura: publish fig",description:"Publish (or unpublish) an existing fig to its shareable public URL. Requires a paid plan. Returns { isPublic, url, publicId }.",inputSchema:{id:W.string().describe("The fig to publish — its id (`fig_…`), a UUID, a share link/URL, or its publicId."),isPublic:W.boolean().optional().describe("Set false to unpublish (make private). Defaults to true (publish).")}},async(K)=>{try{let Q={};if(K.isPublic!==void 0)Q.isPublic=K.isPublic;return V(await B(`/v1/figs/${encodeURIComponent(K.id)}/publish`,{method:"POST",body:Q}))}catch(Q){return X(Q)}});$.registerTool("figura_list_figs",{title:"Figura: list figs",description:"List visualizations for the team, optionally filtered by area or tag.",inputSchema:{area:M(),tag:W.string().optional(),limit:W.number().optional(),cursor:W.string().optional()}},async(K)=>{try{let Q=new URLSearchParams;if(K.area)Q.set("area",K.area);if(K.tag)Q.set("tag",K.tag);if(K.limit!==void 0)Q.set("limit",String(K.limit));if(K.cursor)Q.set("cursor",K.cursor);let Z=Q.toString();return V(await B(`/v1/figs${Z?`?${Z}`:""}`))}catch(Q){return X(Q)}});$.registerTool("figura_get_fig",{title:"Figura: get fig",description:"Fetch a single visualization by id.",inputSchema:{id:W.string().describe("The fig — its id (`fig_…`), a UUID, a share link/URL, or its publicId.")}},async(K)=>{try{return V(await B(`/v1/figs/${encodeURIComponent(K.id)}`))}catch(Q){return X(Q)}});$.registerTool("figura_comment",{title:"Figura: comment",description:"Add a comment to a visualization.",inputSchema:{fig_id:W.string().describe("The fig to comment on — its id (`fig_…`), a UUID, a share link/URL, or its publicId."),body:W.string().describe("Comment text.")}},async(K)=>{try{return V(await B(`/v1/figs/${encodeURIComponent(K.fig_id)}/comments`,{method:"POST",body:{body:K.body}}))}catch(Q){return X(Q)}});$.registerTool("figura_request_feedback",{title:"Figura: request feedback",description:"Ask a teammate to review a fig. Resolve `from` to a team member (by name or email); they get a notification (in-app, push, email) and the discussion happens in the fig's comment thread. Use this when the user says they want a specific person's feedback/eyes/review on a fig. Returns { ok, request: { to, status }, figUrl }.",inputSchema:{id:W.string().describe("The fig to request feedback on — its id (`fig_…`), a UUID, a share link/URL, or its publicId."),from:W.string().describe("The teammate to ask, by name or email (resolved within the team)."),note:W.string().optional().describe("Optional message for them (e.g. what to look at).")}},async(K)=>{try{let Q={from:K.from};if(K.note!==void 0)Q.note=K.note;return V(await B(`/v1/figs/${encodeURIComponent(K.id)}/request-feedback`,{method:"POST",body:Q}))}catch(Q){return X(Q)}});$.registerTool("figura_list_sources",{title:"Figura: list sources",description:"List the company-brain source-spine connectors for the team, with event counts and last-synced times.",inputSchema:{}},async()=>{try{return V(await B("/v1/sources"))}catch(K){return X(K)}});$.registerTool("figura_sync_source",{title:"Figura: sync source",description:"Ingest new events from a connected source into the spine. Returns { ingested, fetched, nextCursor }.",inputSchema:{id:W.string().describe("The source id to sync (from figura_list_sources).")}},async(K)=>{try{return V(await B(`/v1/sources/${encodeURIComponent(K.id)}/sync`,{method:"POST"}))}catch(Q){return X(Q)}});$.registerTool("figura_update_fig",{title:"Figura: update fig",description:"Update a fig's METADATA only (title/description/area/tags/status). Set status='archived' to soft-delete. To change the fig's HTML, use figura_revise_fig — it saves a new version and never destroys the old one. update cannot touch the HTML.",inputSchema:{id:W.string().describe("The fig to update — its id (`fig_…`), a UUID, a share link/URL, or its publicId."),title:W.string().optional(),description:W.string().optional(),area:M(),tags:W.array(W.string()).optional().describe("Replaces the existing tags."),status:W.enum(["draft","published","archived"]).optional()}},async(K)=>{try{let Q={};if(K.title!==void 0)Q.title=K.title;if(K.description!==void 0)Q.description=K.description;if(K.area!==void 0)Q.area=K.area;if(K.tags!==void 0)Q.tags=K.tags;if(K.status!==void 0)Q.status=K.status;return V(await B(`/v1/figs/${encodeURIComponent(K.id)}`,{method:"PATCH",body:Q}))}catch(Q){return X(Q)}});$.registerTool("figura_delete_fig",{title:"Figura: delete fig",description:"Archive a fig (soft-delete; leaves the library, public link stops resolving) or permanently delete it with hard=true.",inputSchema:{id:W.string().describe("The fig to delete — its id (`fig_…`), a UUID, a share link/URL, or its publicId."),hard:W.boolean().optional().describe("Permanently delete instead of archive.")}},async(K)=>{try{return V(await B(`/v1/figs/${encodeURIComponent(K.id)}${K.hard?"?hard=true":""}`,{method:"DELETE"}))}catch(Q){return X(Q)}});await $.connect(new l);
|