@tday-com/mcp 0.4.8 → 0.4.9

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.
Files changed (2) hide show
  1. package/dist/cli.js +18 -18
  2. package/package.json +1 -14
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as yG}from"node:module";var OG=Object.defineProperty;var AG=($)=>$;function IG($,Z){this[$]=AG.bind(null,Z)}var V4=($,Z)=>{for(var Q in Z)OG($,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:IG.bind(Z,Q)})};var I=($,Z)=>()=>($&&(Z=$($=0)),Z);var Z5=yG(import.meta.url);import{readFileSync as TG}from"node:fs";function l0(){return JSON.parse(TG(new URL("../package.json",import.meta.url),"utf8")).version}function H4(){return`${S$}@${l0()}`}var S$="@tday-com/mcp";var F1=()=>{};import{readFile as kG}from"node:fs/promises";import{homedir as zG}from"node:os";import{join as SG}from"node:path";async function B4(){let $=process.env.TDAY_API_URL,Z=process.env.TDAY_WEB_URL,Q=process.env.TDAY_TOKEN??null,J=H8($??J5),Y=H8(Z??Q5(J));if(Q)return{apiBaseUrl:J,webBaseUrl:Y,token:Q};let X=await xG([EG]),G=H8(X?.apiBaseUrl??J),W=H8(X?.webBaseUrl??Z??Q5(G));return{apiBaseUrl:G,webBaseUrl:W,token:X?.token??null}}async function xG($){for(let Z of $)try{let Q=await kG(Z,"utf8"),J=JSON.parse(Q);if(J&&typeof J==="object")return J}catch{}return null}function H8($){return $.trim().replace(/\/+$/,"").replace(/\/api$/i,"")}function Q5($){try{let Z=new URL($);if(Z.hostname.startsWith("api."))Z.hostname=Z.hostname.slice(4);return Z.pathname="",Z.search="",Z.hash="",H8(Z.toString())}catch{return J5}}var EG,J5="https://tday.com";var L9=I(()=>{EG=SG(zG(),".tday","config.json")});var J0="@tday-com/mcp",V$="0.4.8",N1="x-tday-mcp-version";async function o($,Z,Q={}){if(!$.token)throw Error("Not authenticated. Run `npx -y @tday-com/mcp install` to link this MCP server to your tday account in the browser, then restart your AI agent.");let J=new AbortController,Y=Q.method==="POST"?120000:30000,X=setTimeout(()=>J.abort(),Y);if(typeof X==="object"&&"unref"in X)X.unref();let G=Q.signal;if(G?.aborted)J.abort(G.reason);G?.addEventListener("abort",()=>J.abort(G.reason),{once:!0});try{let W=typeof FormData<"u"&&Q.body instanceof FormData,K=await fetch(`${$.apiBaseUrl}${Z}`,{...Q,signal:J.signal,headers:{accept:"application/json",...W?{}:{"content-type":"application/json"},authorization:`Bearer ${$.token}`,[N1]:V$,...Q.headers}}),V=await K.text();if(!K.ok)throw Error(wG(K.status,Z,V,K.statusText));if(!V)return null;try{return JSON.parse(V)}catch{return V}}catch(W){if(W instanceof Error&&W.name==="AbortError"){if(G?.aborted)throw W;throw Error(`tday request timed out after ${Y/1000}s: ${Z}`)}throw W}finally{clearTimeout(X)}}function wG($,Z,Q,J){if($>=500)return`tday ${$} ${Z}. tday is temporarily unable to complete the request; retry shortly. If a design or launch video was already queued, keep polling it (tday_poll_generation or tday_poll_launch_video) rather than starting another.`;let Y=gG(Q)||J,X=`tday ${$} ${Z}: ${Y}`,G=fG(Q),W=hG(Q),K=[W.usage?`See what the organisation has spent: ${W.usage}`:null,W.billing?`The organisation's owner can change the plan at ${W.billing}`:null].filter(Boolean).join(" ");if(G&&vG.has(G)&&$!==402)return`${X}. ${bG[G]??"The organisation's plan does not include this."}${K?` ${K}`:""} Run tday_whoami to see what the plan includes and who owns it.`;switch($){case 400:return`${X}. Check the tool arguments and retry with values returned by tday list/get tools.`;case 401:return`${X}. This MCP server's tday link is missing, expired (links last 90 days) or was disconnected. Run \`npx -y @tday-com/mcp install\` to sign in and relink this machine, then restart your AI agent and retry tday_whoami.`;case 402:return`${X}. Nothing was started and no credits were spent. Do not retry until the balance changes.${K?` ${K}`:""} Run tday_whoami for each organisation's balance and who owns it; tday_get_credit_prices has what things cost.`;case 403:return`${X}. The linked tday account, or this connection, is not allowed to do that. Use tday_whoami to verify the account, then list brands/designs again.`;case 404:return`${X}. Check that the ID came from a tday_* list/get tool and belongs to the linked account.`;case 429:return`${X}. MCP/API generation is rate limited per account. Wait for the limit window to pass (see the Retry-After time), then retry. Do not retry in a loop. Run tday_whoami to check the plan and credit balance.`;default:return X}}function hG($){try{let Z=JSON.parse($);return{usage:Y5(Z.links?.usage),billing:Y5(Z.links?.billing)}}catch{return{usage:null,billing:null}}}function Y5($){if(typeof $!=="string"||$.length>500)return null;try{let Z=new URL($),Q=Z.hostname==="localhost"||Z.hostname==="127.0.0.1";return Z.protocol==="https:"&&(Z.hostname==="tday.com"||Z.hostname.endsWith(".tday.com"))||Q?Z.toString():null}catch{return null}}function fG($){if(!$)return null;try{let Z=JSON.parse($);return typeof Z.code==="string"?Z.code:null}catch{return null}}function gG($){if(!$)return"";try{let Z=JSON.parse($),Q=Z.error??Z.message;if(typeof Q==="string")return Q.slice(0,300)}catch{}return""}function X5($){let Z=$.match(/^https?:\/\//i)?$:`https://${$}`,Q;try{Q=new URL(Z)}catch{throw Error(`Invalid website URL: "${$}"`)}if(Q.protocol!=="http:"&&Q.protocol!=="https:")throw Error(`Website URL must use http or https (got ${Q.protocol})`);if(!Q.hostname||!Q.hostname.includes("."))throw Error("Website must include a valid domain, for example stripe.com");return Q.href}function G5($){return $?.imageUrl??$?.masterImageUrl??$?.panels?.find((Z)=>Z.imageUrl)?.imageUrl??null}function Y0($){let Z=new URLSearchParams;for(let[J,Y]of Object.entries($))if(Y!==void 0)Z.set(J,String(Y));let Q=Z.toString();return Q?`?${Q}`:""}var vG,bG;var L1=I(()=>{vG=new Set(["insufficient_credits","plan_locked","brand_plan_locked","format_locked","brand_limit_reached"]),bG={plan_locked:"This brand is locked by the organisation's plan.",brand_plan_locked:"This brand is locked by the organisation's plan.",format_locked:"The organisation's plan does not include this size; name another or omit it.",brand_limit_reached:"The organisation's plan does not include another brand."}});import{lstat as uG,mkdir as mG,realpath as W5}from"node:fs/promises";import{dirname as cG,isAbsolute as V5,resolve as K5,relative as H5,sep as dG}from"node:path";function p0($){let Z;try{Z=new URL($)}catch{throw Error(`Invalid image URL: "${$}"`)}if(Z.protocol!=="https:")throw Error(`Image URL must use HTTPS (got ${Z.protocol})`);if(!q9.has(Z.hostname))throw Error(`Image host "${Z.hostname}" is not allowed. Expected one of: ${[...q9].join(", ")}`);return Z}function B5($){let Z=process.cwd(),Q=K5(Z,$),J=H5(Z,Q);if(J===".."||J.startsWith(`..${dG}`)||V5(J)||K5(Z,J)!==Q)throw Error(`File path must be inside the working directory. "${$}" resolves outside of ${Z}`);return Q}async function B8($,Z={}){let Q=B5($),J=cG(Q);await mG(J,{recursive:!0});let Y=await W5(process.cwd()),X=await W5(J);if(!lG(Y,X))throw Error(`File path parent directory must stay inside the working directory and cannot traverse symlinks outside of ${process.cwd()}`);try{let G=await uG(Q);if(G.isSymbolicLink())throw Error("Refusing to write to a symbolic link.");if(!G.isFile())throw Error("Refusing to write because the target path exists and is not a regular file.");if(!Z.overwrite)throw Error("File already exists. Choose a new filePath or pass overwrite: true.")}catch(G){if(!pG(G)||G.code!=="ENOENT")throw G}return Q}function lG($,Z){let Q=H5($,Z);return Q===""||!Q.startsWith("..")&&!V5(Q)}function pG($){return $ instanceof Error&&"code"in $}var q9,q1=52428800;var U4=I(()=>{q9=new Set(["cdn.tday.com","video-cdn.communities.one","communities.one","media.brand.dev","asset.brandfetch.io","cdn.brandfetch.io","tday.com","www.tday.com","app.tday.com"])});import{z as E}from"zod";function t($){return E.object({...$,response_format:iG}).strict()}function G$($,Z){return $.replace(/:(\w+)/g,(Q,J)=>{let Y=String(Z[J]??"");if(!j5.test(Y))throw Error(`Invalid ${J}: must contain only letters, numbers, underscores, and hyphens (got "${Y}")`);return encodeURIComponent(Y)})}function N5($){let{response_format:Z,...Q}=$;return Q}function P9($){return $.response_format==="markdown"?"markdown":"json"}var j5,iG,$$,F5,D9,n$,U5,E$,j$,T$,j4;var i0=I(()=>{j5=/^[a-zA-Z0-9_-]+$/,iG=E.enum(["json","markdown"]).default("json").describe("Text response format. Defaults to json for backward compatibility; structuredContent is always returned when the MCP client supports it."),$$=E.string().trim().min(1).regex(j5,"must contain only letters, numbers, underscores, and hyphens");F5=t({}),D9=t({limit:E.number().int().min(1).max(100).default(50).describe("Maximum items to return. Defaults to 50."),offset:E.number().int().min(0).default(0).describe("Number of items to skip for pagination. Defaults to 0.")});n$=E.record(E.string(),E.unknown()),U5=E.object({total_count:E.number().optional(),total:E.number().optional(),count:E.number(),offset:E.number(),limit:E.number(),has_more:E.boolean().optional(),hasMore:E.boolean().optional(),next_offset:E.number().optional(),nextOffset:E.number().optional()}).passthrough(),E$={whoami:E.object({account:E.unknown().optional(),organizations:E.array(n$).optional(),defaultOrganizationId:E.string().nullable().optional(),features:E.unknown().optional(),links:E.unknown().optional(),notes:E.array(E.string()).optional()}).passthrough(),creditPrices:E.object({priceVersion:E.number().optional(),actions:E.array(n$).optional(),launchVideos:E.array(n$).optional(),launchVideoRevisions:E.array(n$).optional(),monthlyCredits:E.unknown().optional(),notes:E.array(E.string()).optional()}).passthrough(),usage:E.object({organization:n$.optional(),balance:E.unknown().optional(),usage:E.unknown().optional(),links:E.unknown().optional()}).passthrough(),listBrands:E.object({brands:E.array(n$),pagination:U5.optional()}).passthrough(),getBrand:E.object({brand:n$.optional(),role:E.string().optional()}).passthrough(),listDesigns:E.object({designs:E.array(n$),archivedCount:E.number().optional(),pagination:U5.optional()}).passthrough(),getDesign:E.object({design:n$.optional()}).passthrough(),createBrand:E.object({brand:n$.optional(),reviewStatus:E.string().optional()}).passthrough(),generate:E.object({designId:E.string(),generationId:E.string(),status:E.string(),editorUrl:E.string(),statusUrl:E.string(),format:E.string().optional(),formatNote:E.string().optional(),credits:E.unknown().optional()}).passthrough(),poll:E.object({designId:E.string(),generationId:E.string(),status:E.string(),editorUrl:E.string(),imageUrl:E.string().optional(),completedAt:E.string().nullable().optional(),platformBadge:E.boolean().optional(),badgeNote:E.string().optional(),failureMessage:E.string().optional()}).passthrough(),download:E.object({saved:E.boolean(),path:E.string(),size:E.number()}).passthrough()},j$={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0},T$={readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},j4={readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}});import{z as nG}from"zod";var L5,aG,q5;var D5=I(()=>{L1();i0();L5=[{name:"tday_get_credit_prices",title:"Credit prices",description:"What each thing costs in credits at today's price list: an image design, an edit, design videos, launch videos (every length, with or without music and voiceover, already added up), a launch video revision, scans, and each plan's monthly credits. Use it to tell the person what something will cost BEFORE starting it, next to the balance from tday_whoami.",inputSchema:t({}),outputSchema:E$.creditPrices,annotations:j$,handler:($,Z)=>o(Z,"/api/v1/credits/prices")},{name:"tday_get_usage",title:"Credit usage",description:"One organisation's credit balance and what it has spent this grant period, by action, by brand and by person, plus a link to its usage page. Pass organizationId from tday_whoami; omitted, the organisation the person owns.",inputSchema:t({organizationId:$$.optional().describe("Organisation ID from tday_whoami")}),outputSchema:E$.usage,annotations:j$,handler:($,Z)=>o(Z,`/api/v1/usage${Y0({organizationId:typeof $.organizationId==="string"?$.organizationId:void 0})}`)}],aG=["square","ig_post","story","fb_post","linkedin_post","desktop","a4_page"],q5=nG.enum(aG).optional().describe("Preset size: square 1080x1080, ig_post 1080x1350 (4:5 portrait), story 1080x1920 (9:16), fb_post 1200x630, linkedin_post 1200x627, desktop 1920x1080, a4_page. Portrait, square and story are on the paid plans where the plan gates sizes (tday_whoami output.allSizes); asking for one that is not included is refused with an upgrade link.")});import{constants as U8}from"node:fs";import{open as rG,rm as oG}from"node:fs/promises";import{z as d}from"zod";async function XW($,Z){if(typeof $.brandId!=="string"||typeof $.title!=="string"||typeof $.description!=="string")throw Error("Pass featureId (from tday_list_features), or brandId with a title and description for a new subject.");let J=(await o(Z,"/api/showcase/features",{method:"POST",body:JSON.stringify({brandId:$.brandId,title:$.title,description:$.description,typeId:null})}))?.feature?.id;if(typeof J!=="string")throw Error("tday could not start that film. Try again in a moment.");return J}function GW($){return`The subject "${String($)}" was saved on the brand's Launch page, where a film can be made from it later.`}function WW($){return{length:$.length,narration:$.narration,music:$.music,...$.musicMood?{musicMood:$.musicMood}:{},...$.voice?{voiceId:$.voice}:{},...$.narrationStyle?{narrationStyle:$.narrationStyle}:{},...$.direction?{direction:$.direction}:{}}}function j8($,Z){return`${$.webBaseUrl}/showcase/review/${encodeURIComponent(Z)}`}async function KW($,Z){let J=(await o($,G$("/api/showcase/videos/:videoId",{videoId:Z})))?.video?.versionId;if(typeof J!=="string")throw Error("This launch video has no finished cut yet. Poll tday_poll_launch_video until it is ready, then try again.");return J}function VW($,Z,Q){let J=F8(Z.feature?.status,"unknown"),Y=Array.isArray(Z.versions)?Z.versions[0]:void 0,X=typeof Y==="object"&&Y!==null?Y:null,G=F8(X?.status,null),W=F8(Z.video?.versionId,null),K=BW(J,G),V=K==="failed"?F8(X?.failureMessage,null):null,H=typeof Z.video?.durationMs==="number"?Z.video.durationMs:null;return{videoId:$,...typeof Z.feature?.title==="string"?{title:Z.feature.title}:{},status:J,state:K,terminal:K!=="in_progress",latestVersion:X?{versionId:F8(X.versionId,null),versionNumber:X.versionNumber??null,status:G}:null,...W?{readyVersionId:W}:{},...H!==null?{durationMs:H}:{},...V?{failureMessage:V}:{},reviewUrl:Q,next:UW(K,W)}}function HW($,Z){if($?.status==="rendering"||$?.status==="none"){let Q=typeof $.progress==="number"?$.progress:null;return{...Z,state:"rendering",progress:Q,next:`The file is being rendered${Q===null?"":` (${Math.round(Q*100)}% done)`}. ${M5}. Call tday_get_launch_video_mp4 again in 20-30 seconds.`}}if($?.status==="failed")return{...Z,state:"failed",error:typeof $.error==="string"?$.error:"The file could not be rendered.",next:"The file could not be rendered and spent no credits. Call tday_get_launch_video_mp4 again with retry: true to try again."};return null}function BW($,Z){if(Z==="ready")return"ready";if(Z==="failed"||$==="failed")return"failed";if(!Z&&($==="review"||$==="published"))return"ready";return"in_progress"}function UW($,Z){if($==="ready")return"Ready. Watch it at reviewUrl, call tday_get_launch_video_mp4 for the MP4 file (its first request renders the file, usually a minute or two), or tday_revise_launch_video to change it.";if($==="in_progress")return"Still being made. Poll again in 20-30 seconds.";return Z?"This cut failed and was not charged. The previous cut is still available: tday_get_launch_video_mp4 returns it, and tday_revise_launch_video can try the change again.":"This film failed and was not charged. Start a new one with tday_create_launch_video."}function F8($,Z){return typeof $==="string"&&$?$:Z}async function jW($,Z,Q){let J=p0($),Y=await B8(Z,{overwrite:Q}),X=await fetch(J.href);if(X.url)p0(X.url);if(!X.ok)throw Error(`Failed to download the video: ${X.status} ${X.statusText}`);let G=Number(X.headers.get("content-length")??0);if(Number.isFinite(G)&&G>N8)throw Error(`The video exceeds the ${N8/1024/1024}MB download limit. Use mp4Url instead.`);let W=X.headers.get("content-type")?.toLowerCase();if(W&&!/^(video\/|application\/octet-stream|binary\/octet-stream)/.test(W))throw Error(`The download is not a video (content-type: ${W}).`);let K=X.body?.getReader();if(!K)throw Error("No response body from the video URL.");let V=U8.O_WRONLY|U8.O_CREAT|(Q?U8.O_TRUNC:U8.O_EXCL)|(U8.O_NOFOLLOW??0),H=await rG(Y,V,384),B=0;try{for(;;){let{done:U,value:F}=await K.read();if(U)break;if(B+=F.byteLength,B>N8)throw Error(`The video exceeds the ${N8/1024/1024}MB download limit. Use mp4Url instead.`);await H.write(F)}}catch(U){throw await H.close(),await oG(Y,{force:!0}),U}finally{K.releaseLock()}return await H.close(),{path:Y,size:B}}var tG=160,sG=4000,P5=600,N8=262144000,eG,$W,ZW="talk (one person talking to one viewer who has the problem, the default); thread (says how many updates there are, then goes through each by name, the default for a product update); story (a day in the life of one person in your audience); duo (two voices: the viewer's inner voice and a narrator); team (from the team who built it); launch (quick and bright); doc (a calm, third-person documentary)",QW,JW="Reece, warm conversational narrator; Ivy, bright friendly presenter; Janet, warm expressive explainer; Sarah, upbeat lively presenter; Craig, deep polished broadcast voice",M9="Poll tday_poll_launch_video with this videoId every 20-30 seconds until it is ready.",YW="Voiceover is not included on this organisation's plan, so the film is silent and no voice was charged.",R9,F4,M5="The first request for a cut at a frame rate renders its file, which usually takes a minute or two",_9;var R5=I(()=>{L1();U4();i0();eG=["Cinematic","Upbeat","Minimal","Warm","Driving"],$W=["talk","thread","story","duo","team","launch","doc"],QW=["Reece","Ivy","Janet","Sarah","Craig"],R9=$$.describe("videoId returned by tday_create_launch_video"),F4={create:d.object({videoId:d.string(),status:d.string(),narration:d.string(),reviewUrl:d.string()}).passthrough(),poll:d.object({videoId:d.string(),status:d.string(),state:d.string(),terminal:d.boolean(),reviewUrl:d.string()}).passthrough(),mp4:d.object({videoId:d.string(),versionId:d.string(),fps:d.number(),state:d.enum(["ready","rendering","failed"]),mp4Url:d.string().optional(),progress:d.number().nullable().optional(),saved:d.boolean().optional(),path:d.string().optional(),size:d.number().optional()}).passthrough(),revise:d.object({videoId:d.string(),status:d.string(),reviewUrl:d.string()}).passthrough()},_9=[{name:"tday_create_launch_video",title:"Create launch video",description:"Make a launch video: a short animated film announcing a feature or product, in the brand's own look. tday's pipeline writes the brief, storyboard, motion, music and narration from the title and description; describe the subject well and pick the options. For a feature tday already has (tday_list_features), pass its featureId instead of brandId, title and description: the film is made of that feature, with what tday knows about it. It spends credits from the brand's organisation: a standard (20s), scored, silent film is 40 credits, and a voiceover or another length changes that (tday_get_credit_prices has the full list). A 402 means the balance cannot cover it: nothing was started, so do not retry. Returns a videoId and a reviewUrl at once; the film takes about 2-5 minutes, so poll tday_poll_launch_video.",inputSchema:t({featureId:$$.optional().describe("A feature's id from tday_list_features: the film is made of it, and brandId, title and description are not needed."),brandId:$$.optional().describe("Brand ID from tday_list_brands, for a new subject (without featureId). The film uses this brand's colours, fonts and logo."),title:d.string().trim().min(1).max(tG).optional().describe("The feature or product the film launches, as a short name (without featureId)."),description:d.string().trim().min(1).max(sG).optional().describe("What the feature or product does and who it is for (without featureId). The film's brief is written from this, so be specific."),length:d.enum(["short","standard","long"]).default("standard").describe("short (about 10s), standard (about 20s, the default) or long (about 50s)."),narration:d.enum(["silent","voiceover"]).default("silent").describe("silent (music and motion carry it, the default) or voiceover (narrated, with captions; costs more)."),music:d.enum(["score","none"]).default("score").describe("score (a bed written to the film's length, the default) or none."),musicMood:d.enum(eG).optional().describe("A mood for the score. Omit to let the planner choose."),voice:d.enum(QW).optional().describe(`The narrator of a voiceover film. Omit for the default. One of: ${JW}.`),narrationStyle:d.enum($W).optional().describe(`How a voiceover film tells its story. Omit for the default. One of: ${ZW}.`),direction:d.string().trim().min(1).max(P5).optional().describe("Optional creative notes in plain words, for example 'lead on the scrubbing, end on the call to action'.")}),outputSchema:F4.create,annotations:T$,handler:async($,Z)=>{let Q=typeof $.featureId==="string"?$.featureId:null,J=Q??await XW($,Z),Y=await o(Z,G$("/api/showcase/features/:id/create-launch-video",{id:J}),{method:"POST",body:JSON.stringify(WW($))}).catch((W)=>{if(Q)throw W;throw Error(`${W instanceof Error?W.message:String(W)} ${GW($.title)}`)}),X=Y?.runFeatureId;if(typeof X!=="string")throw Error("tday could not start that film. Try again in a moment.");let G=Y?.narration==="voiceover"||Y?.narration==="silent"?Y.narration:$.narration;return{videoId:X,status:"queued",length:$.length,narration:G,music:$.music,reviewUrl:j8(Z,X),...$.narration==="voiceover"&&G==="silent"?{note:YW}:{},next:`A film takes about 2-5 minutes. ${M9}`}}},{name:"tday_poll_launch_video",title:"Poll launch video",description:"Check a launch video made with tday_create_launch_video or revised with tday_revise_launch_video. state is in_progress, ready or failed; terminal is true once it is ready or failed. Poll every 20-30 seconds while it is in progress. When it is ready, watch it at reviewUrl or call tday_get_launch_video_mp4 for the MP4 file. Spends no credits.",inputSchema:t({videoId:R9}),outputSchema:F4.poll,annotations:j$,handler:async($,Z)=>{let Q=String($.videoId),J=await o(Z,G$("/api/showcase/videos/:videoId",$));return VW(Q,J??{},j8(Z,Q))}},{name:"tday_get_launch_video_mp4",title:"Get launch video MP4",description:"Get a ready launch video as an MP4 file URL. A launch video is ready before its file: "+M5+`, so this answers state rendering (with progress) until the file exists - call it again every 20-30 seconds until state is ready. Later requests return the stored file at once. Spends no credits. If state is failed, call it again with retry: true. versionId defaults to the newest ready cut (readyVersionId from tday_poll_launch_video). Pass download: true to also save it inside the current working directory once it is ready (at most ${N8/1024/1024}MB).`,inputSchema:t({videoId:R9,versionId:$$.optional().describe("A cut's versionId from tday_poll_launch_video. Omit for the newest ready cut."),fps:d.union([d.literal(60),d.literal(30)]).default(60).describe("The file's frame rate: 60 (the default, smoothest) or 30 (a smaller file). Older cuts that cannot be rendered again offer only 60 and answer 409 for 30."),retry:d.boolean().default(!1).describe("Ask again after state failed. Defaults to false."),download:d.boolean().default(!1).describe("Also save the MP4 into the current working directory. Defaults to false."),filePath:d.string().trim().min(1).max(500).optional().describe("Where to save it, relative to cwd. Defaults to ./tday-launch-videos/<videoId>-<versionId>.mp4 (<videoId>-<versionId>-30fps.mp4 at 30 fps, so both rates can sit side by side). Only used with download."),overwrite:d.boolean().default(!1).describe("Whether to overwrite an existing regular file. Defaults to false for safety.")}),outputSchema:F4.mp4,annotations:j4,handler:async($,Z)=>{let Q=String($.videoId),J=typeof $.versionId==="string"?$.versionId:await KW(Z,Q),Y=$.fps===30?30:60,X=await o(Z,G$("/api/showcase/videos/:videoId/render",$),{method:"POST",body:JSON.stringify({versionId:J,...Y===30?{fps:Y}:{},...$.retry?{retry:!0}:{}})}),G=HW(X,{videoId:Q,versionId:J,fps:Y,reviewUrl:j8(Z,Q)});if(G)return G;let W=X?.mp4Url;if(typeof W!=="string")throw Error("tday could not prepare the video. Try again in a moment.");let K={videoId:Q,versionId:J,fps:Y,state:"ready",mp4Url:W,reviewUrl:j8(Z,Q)};if(!$.download)return K;let V=typeof $.filePath==="string"?$.filePath:`./tday-launch-videos/${Q}-${J}${Y===30?"-30fps":""}.mp4`;return{...K,saved:!0,...await jW(W,V,Boolean($.overwrite))}}},{name:"tday_revise_launch_video",title:"Revise launch video",description:"Make a new cut of a ready launch video from notes, for example 'slow the ending down' or 'lead with the search box'. The kept film is edited to the notes, so the rest stays as it was. It spends tweak credits from the brand's organisation (13 credits for a standard film; tday_get_credit_prices has the full list), and a 402 means the balance cannot cover it. A 409 means a cut is already being made: poll until it finishes. The previous cut stays available while the new one is made. "+M9,inputSchema:t({videoId:R9,notes:d.string().trim().min(1).max(P5).describe("What to change, in plain words.")}),outputSchema:F4.revise,annotations:T$,handler:async($,Z)=>{let Q=String($.videoId),J=await o(Z,G$("/api/showcase/videos/:videoId/regenerate",$),{method:"POST",body:JSON.stringify({instructions:$.notes})});return{videoId:Q,...typeof J?.versionId==="string"?{versionId:J.versionId}:{},status:"queued",reviewUrl:j8(Z,Q),next:`A new cut takes a few minutes. ${M9}`}}}]});import{constants as _5}from"node:fs";import{open as FW,realpath as C5}from"node:fs/promises";import{basename as NW,extname as LW,isAbsolute as qW,relative as DW,resolve as PW}from"node:path";import{z as p}from"zod";function zW($){if(!$.verdict&&!$.note)throw Error("Give a verdict, a note, or both.");if($.x===void 0!==($.y===void 0))throw Error("Give both x and y to pin a note, or neither.");return{route:$.route,surface:"mcp",...$.verdict?{verdict:$.verdict}:{},...$.note?{text:$.note}:{},...$.x!==void 0?{x:$.x,y:$.y}:{},...$.plateId?{plateId:$.plateId}:{}}}function EW($){if($.action==="choose"){if(typeof $.option!=="number")throw Error("Pass option (the index of the reading that is true now) with action choose.");return{action:"choose",option:$.option}}return{action:$.action??"undo"}}async function vW($){let Z=await C5(process.cwd()),Q=await C5(PW(Z,$)),J=DW(Z,Q);if(J===".."||J.startsWith("../")||J.startsWith("..\\")||qW(J))throw Error("The screenshot must be inside the working directory.");let Y=xW[LW(Q).toLowerCase()];if(!Y)throw Error("Use a PNG, JPG or WebP screenshot.");let X=await FW(Q,_5.O_RDONLY|_5.O_NOFOLLOW);try{let G=await X.stat();if(!G.isFile()||G.size<=0)throw Error("The screenshot is empty or not a file.");if(G.size>wW)throw Error("The screenshot is over 4MB. Save it as a JPEG, or take a viewport screenshot instead of a full page.");return{bytes:await X.readFile(),type:Y,name:NW(Q)}}finally{await X.close()}}var MW="Get a brand's product screens: every screen of its product that tday's launch films and images can show, filed against the catalog features it shows. A screen is DRAWN (rebuilt from the app's own code and React components, with realistic data: the preferred kind, it follows every push) or a PHOTO (a screenshot someone uploaded or captured). Returns `state` (no_product_components, reading, building, ready) with a `summary` sentence; `screens` (id, kind, route, status, image URL, the features it is filed on, the facts on it, the latest review); the brand's `features` (id, title) to file screens on; every page of the app as read from its code (`appPages`: route, frame components, components, whether it is drawn); the flags the code branches on and how each reads for customers; the component library (`library`, and `excludedComponents` left out); every fact the brand has given; and its reference screenshots. Use it to answer questions about the brand's product screens, and as step 1 of setting them up: (1) read this; (2) research the product in its codebase, docs and running app; for each feature, pick the pages that show it, then call tday_set_product_screen_context with a `screen` fact per page (filed on its featureIds; a page may be filed on several features, at most 100 drawn pages) plus what each page shows with realistic data, the app frame, components, flags as customers see them, and anything to leave out; (3) optionally add a real screenshot of each page as a reference; (4) pages are drawn in the background (a few minutes): call this again until state is ready; (5) review every drawn screen with tday_get_product_screen and correct it with tday_leave_product_screen_feedback, repeating until each looks like the real product.",RW="Get one product screen for review: its status, the context it was drawn under (facts), its parts (each component's box as fractions of the image, to pin feedback on), its reference screenshots and recent feedback, and the drawn screen itself as an image so you can look at it. Pass before: true to also see the version it replaced, and reference: true to see the newest real screenshot of the page next to it. Compare the screen with what the real product shows (its code, the running app, the reference) and then call tday_leave_product_screen_feedback.",_W=`Write a brand's product-screen context in one call (send everything together: the screens are redrawn once, about 90 seconds after your last call). Each fact is one of: screen (scope: a route from appPages; featureIds: the features it shows, ids from tday_get_product_screens. Keeps that page drawn from the code and files it on those features: their page, flows, films and images use it. A page already drawn is just filed. At most 100 drawn pages); page (scope: a route, or "" for every page; text: what the page shows and how it is laid out, with the realistic data a busy, healthy account would have, in plain sentences a designer can follow); shell (scope: a route, or "" for every page; text: how the app's frame looks: sidebar, top bar, tabs, panes); component (scope: a component name from the library; text: how it really renders); flag (scope: a flag name from flags; value on/off: how it reads for customers); exclude_page (a route that is not part of the product customers use); exclude_component (a component that is not part of the product). Every scope must name something tday read from the code (routes and names exactly as tday_get_product_screens lists them); anything else is refused with the reason, and the rest is still applied. A fact is a strong hint to the screen writer, never an override. Undo any fact with tday_undo_product_screen_fact.`,CW="File a product screen (drawn or photo) on features, or take it off them: a feature's page, flows, launch films and images use the screens filed on it, and one screen may be filed on several features. Pass screenId from tday_get_product_screens and feature ids from its `features`. Taking a screen off a feature also takes it out of that feature's flows.",OW="Remove a screen from the brand's product screens: off every feature and flow. A drawn screen's page stops being drawn (add it again with a `screen` fact); a photo is no longer used. Films already made keep what they showed.",AW=`Review one product screen: a verdict (good: it looks like the real product; bad: something is off) and/or a note about what is wrong, optionally pinned at a point on the screen (x, y as fractions of its width and height; a point inside one of the screen's parts is read as feedback on that component). tday reads the note as one fact about the real product and applies it to every screen, redrawing what it changes. Say what the real product does ("The sidebar shows the workspace switcher above the nav, not below"), one thing per note. Returns the fact made, which tday_undo_product_screen_fact can undo.`,IW="Undo a product-screen fact (the screens go back to how they were, with no redraw when tday kept the earlier version), restore an undone one, or settle a fact tday put back to the brand (status needs_review: the code changed under it) by choosing one of its options (action choose, option: its index).",yW="Upload a real screenshot of one page of the brand's app (from its running app, at desktop size, logged in with realistic data). tday compares it with its drawn screen of that route on the next build and turns the differences into facts. Use a viewport screenshot around 1440x900 (2x is fine) in PNG, JPG or WebP, under 4MB (save a JPEG if a PNG is larger).",L8,G0,TW,kW,SW,xW,wW=4194304,X0,C9;var O5=I(()=>{L1();i0();L8=p.string().trim().min(1).max(512).describe("A route exactly as tday_get_product_screens lists it, for example /projects/[projectId]"),G0=$$.describe("Brand ID from tday_list_brands"),TW=p.discriminatedUnion("kind",[p.object({kind:p.literal("screen"),scope:L8,featureIds:p.array($$).max(50).optional().describe("The features this page shows")}).strict(),p.object({kind:p.literal("page"),scope:p.string().trim().max(512).describe('A route, or "" for every page'),text:p.string().trim().min(1).max(1500)}).strict(),p.object({kind:p.literal("shell"),scope:p.string().trim().max(512).describe('A route, or "" for every page'),text:p.string().trim().min(1).max(1500)}).strict(),p.object({kind:p.literal("component"),scope:p.string().trim().min(1).max(200).describe("A component name from the library"),text:p.string().trim().min(1).max(1500)}).strict(),p.object({kind:p.literal("flag"),scope:p.string().trim().min(1).max(200).describe("A flag name from flags"),value:p.enum(["on","off"])}).strict(),p.object({kind:p.literal("exclude_page"),scope:L8}).strict(),p.object({kind:p.literal("exclude_component"),scope:p.string().trim().min(1).max(200)}).strict()]),kW={brandId:G0,route:L8,verdict:p.enum(["good","bad"]).optional().describe("good: looks like the real product; bad: something is off"),note:p.string().trim().min(1).max(2000).optional().describe("What is wrong, as what the real product does"),x:p.number().min(0).max(1).optional().describe("Where on the screen, 0 = left edge, 1 = right edge"),y:p.number().min(0).max(1).optional().describe("Where on the screen, 0 = top, 1 = bottom"),plateId:p.string().trim().max(128).optional().describe("The screen's plateId from tday_get_product_screen (defaults to the current screen)")};SW={brandId:G0,factId:$$.describe("Fact ID from tday_get_product_screens or a tool's reply"),action:p.enum(["undo","restore","choose"]).default("undo"),option:p.number().int().min(0).max(5).optional().describe("With action choose: the index of the option that is true now")};xW={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp"};X0=p.object({}).passthrough(),C9=[{name:"tday_get_product_screens",title:"Product screens",description:MW,inputSchema:t({brandId:G0}),outputSchema:X0,annotations:j$,handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/overview",$))},{name:"tday_get_product_screen",title:"Product screen",description:RW,inputSchema:t({brandId:G0,route:L8,before:p.boolean().default(!1).describe("Also show the version this screen replaced"),reference:p.boolean().default(!1).describe("Also show the newest real screenshot of the page")}),outputSchema:X0,annotations:j$,images:!0,handler:($,Z)=>o(Z,`${G$("/api/brands/:brandId/product-screens/screen",$)}${Y0({route:String($.route),before:$.before?1:void 0,reference:$.reference?1:void 0})}`)},{name:"tday_set_product_screen_context",title:"Set product screen context",description:_W,inputSchema:t({brandId:G0,facts:p.array(TW).min(1).max(60)}),outputSchema:X0,annotations:T$,handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/context",$),{method:"POST",body:JSON.stringify({facts:$.facts})})},{name:"tday_file_product_screen",title:"File a product screen on features",description:CW,inputSchema:t({brandId:G0,screenId:$$.describe("Screen ID from tday_get_product_screens"),add:p.array($$).max(50).optional().describe("Feature ids to file it on"),remove:p.array($$).max(50).optional().describe("Feature ids to take it off")}),outputSchema:X0,annotations:{...T$,idempotentHint:!0},handler:($,Z)=>{if(!$.add?.length&&!$.remove?.length)throw Error("Name a feature to add or remove.");return o(Z,G$("/api/brands/:brandId/product-screens/screens/:screenId",$),{method:"PATCH",body:JSON.stringify({add:$.add,remove:$.remove})})}},{name:"tday_remove_product_screen",title:"Remove a product screen",description:OW,inputSchema:t({brandId:G0,screenId:$$.describe("Screen ID from tday_get_product_screens")}),outputSchema:X0,annotations:{...T$,destructiveHint:!0,idempotentHint:!0},handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/screens/:screenId",$),{method:"DELETE"})},{name:"tday_leave_product_screen_feedback",title:"Review a product screen",description:AW,inputSchema:t(kW),outputSchema:X0,annotations:T$,handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/feedback",$),{method:"POST",body:JSON.stringify(zW($))})},{name:"tday_undo_product_screen_fact",title:"Undo a product screen fact",description:IW,inputSchema:t(SW),outputSchema:X0,annotations:{...T$,idempotentHint:!0},handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/facts/:factId",$),{method:"PATCH",body:JSON.stringify(EW($))})},{name:"tday_add_product_screen_reference",title:"Add a product screenshot",description:`${yW} Pass filePath: a screenshot inside the current working directory.`,inputSchema:t({brandId:G0,route:L8,filePath:p.string().trim().min(1).max(500).describe("The screenshot, relative to the working directory, for example ./screens/projects.png")}),outputSchema:X0,annotations:T$,handler:async($,Z)=>{let Q=await vW(String($.filePath)),J=new FormData;return J.set("route",String($.route)),J.set("file",new Blob([new Uint8Array(Q.bytes)],{type:Q.type}),Q.name),o(Z,G$("/api/brands/:brandId/product-screens/references",$),{method:"POST",body:J})}},{name:"tday_remove_product_screen_reference",title:"Remove a product screenshot",description:"Stop comparing a page's drawn screen with one of its reference screenshots. The facts it proposed stay until undone.",inputSchema:t({brandId:G0,referenceId:$$.describe("Reference ID from tday_get_product_screens")}),outputSchema:X0,annotations:{...T$,destructiveHint:!0,idempotentHint:!0},handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/references/:referenceId",$),{method:"DELETE"})}]});import{z as M$}from"zod";var A5=50,bW="List a brand's features (its Launch page catalog), newest added first, with the videos each already has: how many launch videos are finished or being made, and the latest one with its link. Use it for the newest feature, for the features that still have no launch video (without: launch_video), or to find a feature's id for tday_create_launch_video. brandId may be left out when the account has one brand; otherwise pass one from tday_list_brands. `more` counts the features not listed. Spends no credits.",hW,O9;var I5=I(()=>{L1();i0();hW=M$.object({brand:M$.object({id:M$.string(),name:M$.string()}).passthrough(),counts:M$.record(M$.string(),M$.unknown()),features:M$.array(M$.record(M$.string(),M$.unknown())),more:M$.number()}).passthrough(),O9=[{name:"tday_list_features",title:"List features",description:bW,inputSchema:t({brandId:$$.optional().describe("Brand ID from tday_list_brands. Optional when the account has one brand."),without:M$.enum(["launch_video"]).optional().describe("launch_video: only features with no launch video finished or being made."),search:M$.string().trim().min(1).max(160).optional().describe("Only features whose title contains this, ignoring case."),limit:M$.number().int().min(1).max(A5).default(20).describe(`How many to list, newest first (at most ${A5}). Defaults to 20.`)}),outputSchema:hW,annotations:j$,handler:($,Z)=>o(Z,`/api/v1/features${Y0({brandId:typeof $.brandId==="string"?$.brandId:void 0,without:typeof $.without==="string"?$.without:void 0,q:typeof $.search==="string"?$.search:void 0,limit:typeof $.limit==="number"?$.limit:void 0})}`)}]});function q8($){return JSON.stringify($,(Z,Q)=>typeof Q==="bigint"?Q.toString():Q,2)}function D8($){if(!a$($)||!Array.isArray($.images))return{result:$,images:[]};let Z=[],Q=[];for(let J of $.images){if(!a$(J)||typeof J.data!=="string"||typeof J.mimeType!=="string"||!J.mimeType.startsWith("image/"))continue;Z.push({type:"image",data:J.data,mimeType:J.mimeType}),Q.push({label:J.label??null,mimeType:J.mimeType,bytes:Math.floor(J.data.length*3/4),position:Z.length})}return{result:{...$,images:Q},images:Z}}function A9($){return a$($)?$:{result:$}}function I9($,Z,Q,J){let Y=Q==="markdown"?gW($,Z,J):q8(Z);return fW(Y)}function a$($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function fW($){if($.length<=25000)return $;return`${$.slice(0,25000)}
2
+ import{createRequire as yG}from"node:module";var OG=Object.defineProperty;var AG=($)=>$;function IG($,Z){this[$]=AG.bind(null,Z)}var V4=($,Z)=>{for(var Q in Z)OG($,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:IG.bind(Z,Q)})};var I=($,Z)=>()=>($&&(Z=$($=0)),Z);var Z5=yG(import.meta.url);import{readFileSync as TG}from"node:fs";function l0(){return JSON.parse(TG(new URL("../package.json",import.meta.url),"utf8")).version}function H4(){return`${S$}@${l0()}`}var S$="@tday-com/mcp";var F1=()=>{};import{readFile as kG}from"node:fs/promises";import{homedir as zG}from"node:os";import{join as SG}from"node:path";async function B4(){let $=process.env.TDAY_API_URL,Z=process.env.TDAY_WEB_URL,Q=process.env.TDAY_TOKEN??null,J=H8($??J5),Y=H8(Z??Q5(J));if(Q)return{apiBaseUrl:J,webBaseUrl:Y,token:Q};let X=await xG([EG]),G=H8(X?.apiBaseUrl??J),W=H8(X?.webBaseUrl??Z??Q5(G));return{apiBaseUrl:G,webBaseUrl:W,token:X?.token??null}}async function xG($){for(let Z of $)try{let Q=await kG(Z,"utf8"),J=JSON.parse(Q);if(J&&typeof J==="object")return J}catch{}return null}function H8($){return $.trim().replace(/\/+$/,"").replace(/\/api$/i,"")}function Q5($){try{let Z=new URL($);if(Z.hostname.startsWith("api."))Z.hostname=Z.hostname.slice(4);return Z.pathname="",Z.search="",Z.hash="",H8(Z.toString())}catch{return J5}}var EG,J5="https://tday.com";var L9=I(()=>{EG=SG(zG(),".tday","config.json")});var J0="@tday-com/mcp",V$="0.4.9",N1="x-tday-mcp-version";async function o($,Z,Q={}){if(!$.token)throw Error("Not authenticated. Run `npx -y @tday-com/mcp install` to link this MCP server to your tday account in the browser, then restart your AI agent.");let J=new AbortController,Y=Q.method==="POST"?120000:30000,X=setTimeout(()=>J.abort(),Y);if(typeof X==="object"&&"unref"in X)X.unref();let G=Q.signal;if(G?.aborted)J.abort(G.reason);G?.addEventListener("abort",()=>J.abort(G.reason),{once:!0});try{let W=typeof FormData<"u"&&Q.body instanceof FormData,K=await fetch(`${$.apiBaseUrl}${Z}`,{...Q,signal:J.signal,headers:{accept:"application/json",...W?{}:{"content-type":"application/json"},authorization:`Bearer ${$.token}`,[N1]:V$,...Q.headers}}),V=await K.text();if(!K.ok)throw Error(wG(K.status,Z,V,K.statusText));if(!V)return null;try{return JSON.parse(V)}catch{return V}}catch(W){if(W instanceof Error&&W.name==="AbortError"){if(G?.aborted)throw W;throw Error(`tday request timed out after ${Y/1000}s: ${Z}`)}throw W}finally{clearTimeout(X)}}function wG($,Z,Q,J){if($>=500)return`tday ${$} ${Z}. tday is temporarily unable to complete the request; retry shortly. If a design or launch video was already queued, keep polling it (tday_poll_generation or tday_poll_launch_video) rather than starting another.`;let Y=gG(Q)||J,X=`tday ${$} ${Z}: ${Y}`,G=fG(Q),W=hG(Q),K=[W.usage?`See what the organisation has spent: ${W.usage}`:null,W.billing?`The organisation's owner can change the plan at ${W.billing}`:null].filter(Boolean).join(" ");if(G&&vG.has(G)&&$!==402)return`${X}. ${bG[G]??"The organisation's plan does not include this."}${K?` ${K}`:""} Run tday_whoami to see what the plan includes and who owns it.`;switch($){case 400:return`${X}. Check the tool arguments and retry with values returned by tday list/get tools.`;case 401:return`${X}. This MCP server's tday link is missing, expired (links last 90 days) or was disconnected. Run \`npx -y @tday-com/mcp install\` to sign in and relink this machine, then restart your AI agent and retry tday_whoami.`;case 402:return`${X}. Nothing was started and no credits were spent. Do not retry until the balance changes.${K?` ${K}`:""} Run tday_whoami for each organisation's balance and who owns it; tday_get_credit_prices has what things cost.`;case 403:return`${X}. The linked tday account, or this connection, is not allowed to do that. Use tday_whoami to verify the account, then list brands/designs again.`;case 404:return`${X}. Check that the ID came from a tday_* list/get tool and belongs to the linked account.`;case 429:return`${X}. MCP/API generation is rate limited per account. Wait for the limit window to pass (see the Retry-After time), then retry. Do not retry in a loop. Run tday_whoami to check the plan and credit balance.`;default:return X}}function hG($){try{let Z=JSON.parse($);return{usage:Y5(Z.links?.usage),billing:Y5(Z.links?.billing)}}catch{return{usage:null,billing:null}}}function Y5($){if(typeof $!=="string"||$.length>500)return null;try{let Z=new URL($),Q=Z.hostname==="localhost"||Z.hostname==="127.0.0.1";return Z.protocol==="https:"&&(Z.hostname==="tday.com"||Z.hostname.endsWith(".tday.com"))||Q?Z.toString():null}catch{return null}}function fG($){if(!$)return null;try{let Z=JSON.parse($);return typeof Z.code==="string"?Z.code:null}catch{return null}}function gG($){if(!$)return"";try{let Z=JSON.parse($),Q=Z.error??Z.message;if(typeof Q==="string")return Q.slice(0,300)}catch{}return""}function X5($){let Z=$.match(/^https?:\/\//i)?$:`https://${$}`,Q;try{Q=new URL(Z)}catch{throw Error(`Invalid website URL: "${$}"`)}if(Q.protocol!=="http:"&&Q.protocol!=="https:")throw Error(`Website URL must use http or https (got ${Q.protocol})`);if(!Q.hostname||!Q.hostname.includes("."))throw Error("Website must include a valid domain, for example stripe.com");return Q.href}function G5($){return $?.imageUrl??$?.masterImageUrl??$?.panels?.find((Z)=>Z.imageUrl)?.imageUrl??null}function Y0($){let Z=new URLSearchParams;for(let[J,Y]of Object.entries($))if(Y!==void 0)Z.set(J,String(Y));let Q=Z.toString();return Q?`?${Q}`:""}var vG,bG;var L1=I(()=>{vG=new Set(["insufficient_credits","plan_locked","brand_plan_locked","format_locked","brand_limit_reached"]),bG={plan_locked:"This brand is locked by the organisation's plan.",brand_plan_locked:"This brand is locked by the organisation's plan.",format_locked:"The organisation's plan does not include this size; name another or omit it.",brand_limit_reached:"The organisation's plan does not include another brand."}});import{lstat as uG,mkdir as mG,realpath as W5}from"node:fs/promises";import{dirname as cG,isAbsolute as V5,resolve as K5,relative as H5,sep as dG}from"node:path";function p0($){let Z;try{Z=new URL($)}catch{throw Error(`Invalid image URL: "${$}"`)}if(Z.protocol!=="https:")throw Error(`Image URL must use HTTPS (got ${Z.protocol})`);if(!q9.has(Z.hostname))throw Error(`Image host "${Z.hostname}" is not allowed. Expected one of: ${[...q9].join(", ")}`);return Z}function B5($){let Z=process.cwd(),Q=K5(Z,$),J=H5(Z,Q);if(J===".."||J.startsWith(`..${dG}`)||V5(J)||K5(Z,J)!==Q)throw Error(`File path must be inside the working directory. "${$}" resolves outside of ${Z}`);return Q}async function B8($,Z={}){let Q=B5($),J=cG(Q);await mG(J,{recursive:!0});let Y=await W5(process.cwd()),X=await W5(J);if(!lG(Y,X))throw Error(`File path parent directory must stay inside the working directory and cannot traverse symlinks outside of ${process.cwd()}`);try{let G=await uG(Q);if(G.isSymbolicLink())throw Error("Refusing to write to a symbolic link.");if(!G.isFile())throw Error("Refusing to write because the target path exists and is not a regular file.");if(!Z.overwrite)throw Error("File already exists. Choose a new filePath or pass overwrite: true.")}catch(G){if(!pG(G)||G.code!=="ENOENT")throw G}return Q}function lG($,Z){let Q=H5($,Z);return Q===""||!Q.startsWith("..")&&!V5(Q)}function pG($){return $ instanceof Error&&"code"in $}var q9,q1=52428800;var U4=I(()=>{q9=new Set(["cdn.tday.com","media.brand.dev","asset.brandfetch.io","cdn.brandfetch.io","tday.com","www.tday.com","app.tday.com"])});import{z as E}from"zod";function t($){return E.object({...$,response_format:iG}).strict()}function G$($,Z){return $.replace(/:(\w+)/g,(Q,J)=>{let Y=String(Z[J]??"");if(!j5.test(Y))throw Error(`Invalid ${J}: must contain only letters, numbers, underscores, and hyphens (got "${Y}")`);return encodeURIComponent(Y)})}function N5($){let{response_format:Z,...Q}=$;return Q}function P9($){return $.response_format==="markdown"?"markdown":"json"}var j5,iG,$$,F5,D9,n$,U5,E$,j$,T$,j4;var i0=I(()=>{j5=/^[a-zA-Z0-9_-]+$/,iG=E.enum(["json","markdown"]).default("json").describe("Text response format. Defaults to json for backward compatibility; structuredContent is always returned when the MCP client supports it."),$$=E.string().trim().min(1).regex(j5,"must contain only letters, numbers, underscores, and hyphens");F5=t({}),D9=t({limit:E.number().int().min(1).max(100).default(50).describe("Maximum items to return. Defaults to 50."),offset:E.number().int().min(0).default(0).describe("Number of items to skip for pagination. Defaults to 0.")});n$=E.record(E.string(),E.unknown()),U5=E.object({total_count:E.number().optional(),total:E.number().optional(),count:E.number(),offset:E.number(),limit:E.number(),has_more:E.boolean().optional(),hasMore:E.boolean().optional(),next_offset:E.number().optional(),nextOffset:E.number().optional()}).passthrough(),E$={whoami:E.object({account:E.unknown().optional(),organizations:E.array(n$).optional(),defaultOrganizationId:E.string().nullable().optional(),features:E.unknown().optional(),links:E.unknown().optional(),notes:E.array(E.string()).optional()}).passthrough(),creditPrices:E.object({priceVersion:E.number().optional(),actions:E.array(n$).optional(),launchVideos:E.array(n$).optional(),launchVideoRevisions:E.array(n$).optional(),monthlyCredits:E.unknown().optional(),notes:E.array(E.string()).optional()}).passthrough(),usage:E.object({organization:n$.optional(),balance:E.unknown().optional(),usage:E.unknown().optional(),links:E.unknown().optional()}).passthrough(),listBrands:E.object({brands:E.array(n$),pagination:U5.optional()}).passthrough(),getBrand:E.object({brand:n$.optional(),role:E.string().optional()}).passthrough(),listDesigns:E.object({designs:E.array(n$),archivedCount:E.number().optional(),pagination:U5.optional()}).passthrough(),getDesign:E.object({design:n$.optional()}).passthrough(),createBrand:E.object({brand:n$.optional(),reviewStatus:E.string().optional()}).passthrough(),generate:E.object({designId:E.string(),generationId:E.string(),status:E.string(),editorUrl:E.string(),statusUrl:E.string(),format:E.string().optional(),formatNote:E.string().optional(),credits:E.unknown().optional()}).passthrough(),poll:E.object({designId:E.string(),generationId:E.string(),status:E.string(),editorUrl:E.string(),imageUrl:E.string().optional(),completedAt:E.string().nullable().optional(),platformBadge:E.boolean().optional(),badgeNote:E.string().optional(),failureMessage:E.string().optional()}).passthrough(),download:E.object({saved:E.boolean(),path:E.string(),size:E.number()}).passthrough()},j$={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0},T$={readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},j4={readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}});import{z as nG}from"zod";var L5,aG,q5;var D5=I(()=>{L1();i0();L5=[{name:"tday_get_credit_prices",title:"Credit prices",description:"What each thing costs in credits at today's price list: an image design, an edit, design videos, launch videos (every length, with or without music and voiceover, already added up), a launch video revision, scans, and each plan's monthly credits. Use it to tell the person what something will cost BEFORE starting it, next to the balance from tday_whoami.",inputSchema:t({}),outputSchema:E$.creditPrices,annotations:j$,handler:($,Z)=>o(Z,"/api/v1/credits/prices")},{name:"tday_get_usage",title:"Credit usage",description:"One organisation's credit balance and what it has spent this grant period, by action, by brand and by person, plus a link to its usage page. Pass organizationId from tday_whoami; omitted, the organisation the person owns.",inputSchema:t({organizationId:$$.optional().describe("Organisation ID from tday_whoami")}),outputSchema:E$.usage,annotations:j$,handler:($,Z)=>o(Z,`/api/v1/usage${Y0({organizationId:typeof $.organizationId==="string"?$.organizationId:void 0})}`)}],aG=["square","ig_post","story","fb_post","linkedin_post","desktop","a4_page"],q5=nG.enum(aG).optional().describe("Preset size: square 1080x1080, ig_post 1080x1350 (4:5 portrait), story 1080x1920 (9:16), fb_post 1200x630, linkedin_post 1200x627, desktop 1920x1080, a4_page. Portrait, square and story are on the paid plans where the plan gates sizes (tday_whoami output.allSizes); asking for one that is not included is refused with an upgrade link.")});import{constants as U8}from"node:fs";import{open as rG,rm as oG}from"node:fs/promises";import{z as d}from"zod";async function XW($,Z){if(typeof $.brandId!=="string"||typeof $.title!=="string"||typeof $.description!=="string")throw Error("Pass featureId (from tday_list_features), or brandId with a title and description for a new subject.");let J=(await o(Z,"/api/showcase/features",{method:"POST",body:JSON.stringify({brandId:$.brandId,title:$.title,description:$.description,typeId:null})}))?.feature?.id;if(typeof J!=="string")throw Error("tday could not start that film. Try again in a moment.");return J}function GW($){return`The subject "${String($)}" was saved on the brand's Launch page, where a film can be made from it later.`}function WW($){return{length:$.length,narration:$.narration,music:$.music,...$.musicMood?{musicMood:$.musicMood}:{},...$.voice?{voiceId:$.voice}:{},...$.narrationStyle?{narrationStyle:$.narrationStyle}:{},...$.direction?{direction:$.direction}:{}}}function j8($,Z){return`${$.webBaseUrl}/showcase/review/${encodeURIComponent(Z)}`}async function KW($,Z){let J=(await o($,G$("/api/showcase/videos/:videoId",{videoId:Z})))?.video?.versionId;if(typeof J!=="string")throw Error("This launch video has no finished cut yet. Poll tday_poll_launch_video until it is ready, then try again.");return J}function VW($,Z,Q){let J=F8(Z.feature?.status,"unknown"),Y=Array.isArray(Z.versions)?Z.versions[0]:void 0,X=typeof Y==="object"&&Y!==null?Y:null,G=F8(X?.status,null),W=F8(Z.video?.versionId,null),K=BW(J,G),V=K==="failed"?F8(X?.failureMessage,null):null,H=typeof Z.video?.durationMs==="number"?Z.video.durationMs:null;return{videoId:$,...typeof Z.feature?.title==="string"?{title:Z.feature.title}:{},status:J,state:K,terminal:K!=="in_progress",latestVersion:X?{versionId:F8(X.versionId,null),versionNumber:X.versionNumber??null,status:G}:null,...W?{readyVersionId:W}:{},...H!==null?{durationMs:H}:{},...V?{failureMessage:V}:{},reviewUrl:Q,next:UW(K,W)}}function HW($,Z){if($?.status==="rendering"||$?.status==="none"){let Q=typeof $.progress==="number"?$.progress:null;return{...Z,state:"rendering",progress:Q,next:`The file is being rendered${Q===null?"":` (${Math.round(Q*100)}% done)`}. ${M5}. Call tday_get_launch_video_mp4 again in 20-30 seconds.`}}if($?.status==="failed")return{...Z,state:"failed",error:typeof $.error==="string"?$.error:"The file could not be rendered.",next:"The file could not be rendered and spent no credits. Call tday_get_launch_video_mp4 again with retry: true to try again."};return null}function BW($,Z){if(Z==="ready")return"ready";if(Z==="failed"||$==="failed")return"failed";if(!Z&&($==="review"||$==="published"))return"ready";return"in_progress"}function UW($,Z){if($==="ready")return"Ready. Watch it at reviewUrl, call tday_get_launch_video_mp4 for the MP4 file (its first request renders the file, usually a minute or two), or tday_revise_launch_video to change it.";if($==="in_progress")return"Still being made. Poll again in 20-30 seconds.";return Z?"This cut failed and was not charged. The previous cut is still available: tday_get_launch_video_mp4 returns it, and tday_revise_launch_video can try the change again.":"This film failed and was not charged. Start a new one with tday_create_launch_video."}function F8($,Z){return typeof $==="string"&&$?$:Z}async function jW($,Z,Q){let J=p0($),Y=await B8(Z,{overwrite:Q}),X=await fetch(J.href);if(X.url)p0(X.url);if(!X.ok)throw Error(`Failed to download the video: ${X.status} ${X.statusText}`);let G=Number(X.headers.get("content-length")??0);if(Number.isFinite(G)&&G>N8)throw Error(`The video exceeds the ${N8/1024/1024}MB download limit. Use mp4Url instead.`);let W=X.headers.get("content-type")?.toLowerCase();if(W&&!/^(video\/|application\/octet-stream|binary\/octet-stream)/.test(W))throw Error(`The download is not a video (content-type: ${W}).`);let K=X.body?.getReader();if(!K)throw Error("No response body from the video URL.");let V=U8.O_WRONLY|U8.O_CREAT|(Q?U8.O_TRUNC:U8.O_EXCL)|(U8.O_NOFOLLOW??0),H=await rG(Y,V,384),B=0;try{for(;;){let{done:U,value:F}=await K.read();if(U)break;if(B+=F.byteLength,B>N8)throw Error(`The video exceeds the ${N8/1024/1024}MB download limit. Use mp4Url instead.`);await H.write(F)}}catch(U){throw await H.close(),await oG(Y,{force:!0}),U}finally{K.releaseLock()}return await H.close(),{path:Y,size:B}}var tG=160,sG=4000,P5=600,N8=262144000,eG,$W,ZW="talk (one person talking to one viewer who has the problem, the default); thread (says how many updates there are, then goes through each by name, the default for a product update); story (a day in the life of one person in your audience); duo (two voices: the viewer's inner voice and a narrator); team (from the team who built it); launch (quick and bright); doc (a calm, third-person documentary)",QW,JW="Reece, warm conversational narrator; Ivy, bright friendly presenter; Janet, warm expressive explainer; Sarah, upbeat lively presenter; Craig, deep polished broadcast voice",M9="Poll tday_poll_launch_video with this videoId every 20-30 seconds until it is ready.",YW="Voiceover is not included on this organisation's plan, so the film is silent and no voice was charged.",R9,F4,M5="The first request for a cut at a frame rate renders its file, which usually takes a minute or two",_9;var R5=I(()=>{L1();U4();i0();eG=["Cinematic","Upbeat","Minimal","Warm","Driving"],$W=["talk","thread","story","duo","team","launch","doc"],QW=["Reece","Ivy","Janet","Sarah","Craig"],R9=$$.describe("videoId returned by tday_create_launch_video"),F4={create:d.object({videoId:d.string(),status:d.string(),narration:d.string(),reviewUrl:d.string()}).passthrough(),poll:d.object({videoId:d.string(),status:d.string(),state:d.string(),terminal:d.boolean(),reviewUrl:d.string()}).passthrough(),mp4:d.object({videoId:d.string(),versionId:d.string(),fps:d.number(),state:d.enum(["ready","rendering","failed"]),mp4Url:d.string().optional(),progress:d.number().nullable().optional(),saved:d.boolean().optional(),path:d.string().optional(),size:d.number().optional()}).passthrough(),revise:d.object({videoId:d.string(),status:d.string(),reviewUrl:d.string()}).passthrough()},_9=[{name:"tday_create_launch_video",title:"Create launch video",description:"Make a launch video: a short animated film announcing a feature or product, in the brand's own look. tday's pipeline writes the brief, storyboard, motion, music and narration from the title and description; describe the subject well and pick the options. For a feature tday already has (tday_list_features), pass its featureId instead of brandId, title and description: the film is made of that feature, with what tday knows about it. It spends credits from the brand's organisation: a standard (20s), scored, silent film is 40 credits, and a voiceover or another length changes that (tday_get_credit_prices has the full list). A 402 means the balance cannot cover it: nothing was started, so do not retry. Returns a videoId and a reviewUrl at once; the film takes about 2-5 minutes, so poll tday_poll_launch_video.",inputSchema:t({featureId:$$.optional().describe("A feature's id from tday_list_features: the film is made of it, and brandId, title and description are not needed."),brandId:$$.optional().describe("Brand ID from tday_list_brands, for a new subject (without featureId). The film uses this brand's colours, fonts and logo."),title:d.string().trim().min(1).max(tG).optional().describe("The feature or product the film launches, as a short name (without featureId)."),description:d.string().trim().min(1).max(sG).optional().describe("What the feature or product does and who it is for (without featureId). The film's brief is written from this, so be specific."),length:d.enum(["short","standard","long"]).default("standard").describe("short (about 10s), standard (about 20s, the default) or long (about 50s)."),narration:d.enum(["silent","voiceover"]).default("silent").describe("silent (music and motion carry it, the default) or voiceover (narrated, with captions; costs more)."),music:d.enum(["score","none"]).default("score").describe("score (a bed written to the film's length, the default) or none."),musicMood:d.enum(eG).optional().describe("A mood for the score. Omit to let the planner choose."),voice:d.enum(QW).optional().describe(`The narrator of a voiceover film. Omit for the default. One of: ${JW}.`),narrationStyle:d.enum($W).optional().describe(`How a voiceover film tells its story. Omit for the default. One of: ${ZW}.`),direction:d.string().trim().min(1).max(P5).optional().describe("Optional creative notes in plain words, for example 'lead on the scrubbing, end on the call to action'.")}),outputSchema:F4.create,annotations:T$,handler:async($,Z)=>{let Q=typeof $.featureId==="string"?$.featureId:null,J=Q??await XW($,Z),Y=await o(Z,G$("/api/showcase/features/:id/create-launch-video",{id:J}),{method:"POST",body:JSON.stringify(WW($))}).catch((W)=>{if(Q)throw W;throw Error(`${W instanceof Error?W.message:String(W)} ${GW($.title)}`)}),X=Y?.runFeatureId;if(typeof X!=="string")throw Error("tday could not start that film. Try again in a moment.");let G=Y?.narration==="voiceover"||Y?.narration==="silent"?Y.narration:$.narration;return{videoId:X,status:"queued",length:$.length,narration:G,music:$.music,reviewUrl:j8(Z,X),...$.narration==="voiceover"&&G==="silent"?{note:YW}:{},next:`A film takes about 2-5 minutes. ${M9}`}}},{name:"tday_poll_launch_video",title:"Poll launch video",description:"Check a launch video made with tday_create_launch_video or revised with tday_revise_launch_video. state is in_progress, ready or failed; terminal is true once it is ready or failed. Poll every 20-30 seconds while it is in progress. When it is ready, watch it at reviewUrl or call tday_get_launch_video_mp4 for the MP4 file. Spends no credits.",inputSchema:t({videoId:R9}),outputSchema:F4.poll,annotations:j$,handler:async($,Z)=>{let Q=String($.videoId),J=await o(Z,G$("/api/showcase/videos/:videoId",$));return VW(Q,J??{},j8(Z,Q))}},{name:"tday_get_launch_video_mp4",title:"Get launch video MP4",description:"Get a ready launch video as an MP4 file URL. A launch video is ready before its file: "+M5+`, so this answers state rendering (with progress) until the file exists - call it again every 20-30 seconds until state is ready. Later requests return the stored file at once. Spends no credits. If state is failed, call it again with retry: true. versionId defaults to the newest ready cut (readyVersionId from tday_poll_launch_video). Pass download: true to also save it inside the current working directory once it is ready (at most ${N8/1024/1024}MB).`,inputSchema:t({videoId:R9,versionId:$$.optional().describe("A cut's versionId from tday_poll_launch_video. Omit for the newest ready cut."),fps:d.union([d.literal(60),d.literal(30)]).default(60).describe("The file's frame rate: 60 (the default, smoothest) or 30 (a smaller file). Older cuts that cannot be rendered again offer only 60 and answer 409 for 30."),retry:d.boolean().default(!1).describe("Ask again after state failed. Defaults to false."),download:d.boolean().default(!1).describe("Also save the MP4 into the current working directory. Defaults to false."),filePath:d.string().trim().min(1).max(500).optional().describe("Where to save it, relative to cwd. Defaults to ./tday-launch-videos/<videoId>-<versionId>.mp4 (<videoId>-<versionId>-30fps.mp4 at 30 fps, so both rates can sit side by side). Only used with download."),overwrite:d.boolean().default(!1).describe("Whether to overwrite an existing regular file. Defaults to false for safety.")}),outputSchema:F4.mp4,annotations:j4,handler:async($,Z)=>{let Q=String($.videoId),J=typeof $.versionId==="string"?$.versionId:await KW(Z,Q),Y=$.fps===30?30:60,X=await o(Z,G$("/api/showcase/videos/:videoId/render",$),{method:"POST",body:JSON.stringify({versionId:J,...Y===30?{fps:Y}:{},...$.retry?{retry:!0}:{}})}),G=HW(X,{videoId:Q,versionId:J,fps:Y,reviewUrl:j8(Z,Q)});if(G)return G;let W=X?.mp4Url;if(typeof W!=="string")throw Error("tday could not prepare the video. Try again in a moment.");let K={videoId:Q,versionId:J,fps:Y,state:"ready",mp4Url:W,reviewUrl:j8(Z,Q)};if(!$.download)return K;let V=typeof $.filePath==="string"?$.filePath:`./tday-launch-videos/${Q}-${J}${Y===30?"-30fps":""}.mp4`;return{...K,saved:!0,...await jW(W,V,Boolean($.overwrite))}}},{name:"tday_revise_launch_video",title:"Revise launch video",description:"Make a new cut of a ready launch video from notes, for example 'slow the ending down' or 'lead with the search box'. The kept film is edited to the notes, so the rest stays as it was. It spends tweak credits from the brand's organisation (13 credits for a standard film; tday_get_credit_prices has the full list), and a 402 means the balance cannot cover it. A 409 means a cut is already being made: poll until it finishes. The previous cut stays available while the new one is made. "+M9,inputSchema:t({videoId:R9,notes:d.string().trim().min(1).max(P5).describe("What to change, in plain words.")}),outputSchema:F4.revise,annotations:T$,handler:async($,Z)=>{let Q=String($.videoId),J=await o(Z,G$("/api/showcase/videos/:videoId/regenerate",$),{method:"POST",body:JSON.stringify({instructions:$.notes})});return{videoId:Q,...typeof J?.versionId==="string"?{versionId:J.versionId}:{},status:"queued",reviewUrl:j8(Z,Q),next:`A new cut takes a few minutes. ${M9}`}}}]});import{constants as _5}from"node:fs";import{open as FW,realpath as C5}from"node:fs/promises";import{basename as NW,extname as LW,isAbsolute as qW,relative as DW,resolve as PW}from"node:path";import{z as p}from"zod";function zW($){if(!$.verdict&&!$.note)throw Error("Give a verdict, a note, or both.");if($.x===void 0!==($.y===void 0))throw Error("Give both x and y to pin a note, or neither.");return{route:$.route,surface:"mcp",...$.verdict?{verdict:$.verdict}:{},...$.note?{text:$.note}:{},...$.x!==void 0?{x:$.x,y:$.y}:{},...$.plateId?{plateId:$.plateId}:{}}}function EW($){if($.action==="choose"){if(typeof $.option!=="number")throw Error("Pass option (the index of the reading that is true now) with action choose.");return{action:"choose",option:$.option}}return{action:$.action??"undo"}}async function vW($){let Z=await C5(process.cwd()),Q=await C5(PW(Z,$)),J=DW(Z,Q);if(J===".."||J.startsWith("../")||J.startsWith("..\\")||qW(J))throw Error("The screenshot must be inside the working directory.");let Y=xW[LW(Q).toLowerCase()];if(!Y)throw Error("Use a PNG, JPG or WebP screenshot.");let X=await FW(Q,_5.O_RDONLY|_5.O_NOFOLLOW);try{let G=await X.stat();if(!G.isFile()||G.size<=0)throw Error("The screenshot is empty or not a file.");if(G.size>wW)throw Error("The screenshot is over 4MB. Save it as a JPEG, or take a viewport screenshot instead of a full page.");return{bytes:await X.readFile(),type:Y,name:NW(Q)}}finally{await X.close()}}var MW="Get a brand's product screens: every screen of its product that tday's launch films and images can show, filed against the catalog features it shows. A screen is DRAWN (rebuilt from the app's own code and React components, with realistic data: the preferred kind, it follows every push) or a PHOTO (a screenshot someone uploaded or captured). Returns `state` (no_product_components, reading, building, ready) with a `summary` sentence; `screens` (id, kind, route, status, image URL, the features it is filed on, the facts on it, the latest review); the brand's `features` (id, title) to file screens on; every page of the app as read from its code (`appPages`: route, frame components, components, whether it is drawn); the flags the code branches on and how each reads for customers; the component library (`library`, and `excludedComponents` left out); every fact the brand has given; and its reference screenshots. Use it to answer questions about the brand's product screens, and as step 1 of setting them up: (1) read this; (2) research the product in its codebase, docs and running app; for each feature, pick the pages that show it, then call tday_set_product_screen_context with a `screen` fact per page (filed on its featureIds; a page may be filed on several features, at most 100 drawn pages) plus what each page shows with realistic data, the app frame, components, flags as customers see them, and anything to leave out; (3) optionally add a real screenshot of each page as a reference; (4) pages are drawn in the background (a few minutes): call this again until state is ready; (5) review every drawn screen with tday_get_product_screen and correct it with tday_leave_product_screen_feedback, repeating until each looks like the real product.",RW="Get one product screen for review: its status, the context it was drawn under (facts), its parts (each component's box as fractions of the image, to pin feedback on), its reference screenshots and recent feedback, and the drawn screen itself as an image so you can look at it. Pass before: true to also see the version it replaced, and reference: true to see the newest real screenshot of the page next to it. Compare the screen with what the real product shows (its code, the running app, the reference) and then call tday_leave_product_screen_feedback.",_W=`Write a brand's product-screen context in one call (send everything together: the screens are redrawn once, about 90 seconds after your last call). Each fact is one of: screen (scope: a route from appPages; featureIds: the features it shows, ids from tday_get_product_screens. Keeps that page drawn from the code and files it on those features: their page, flows, films and images use it. A page already drawn is just filed. At most 100 drawn pages); page (scope: a route, or "" for every page; text: what the page shows and how it is laid out, with the realistic data a busy, healthy account would have, in plain sentences a designer can follow); shell (scope: a route, or "" for every page; text: how the app's frame looks: sidebar, top bar, tabs, panes); component (scope: a component name from the library; text: how it really renders); flag (scope: a flag name from flags; value on/off: how it reads for customers); exclude_page (a route that is not part of the product customers use); exclude_component (a component that is not part of the product). Every scope must name something tday read from the code (routes and names exactly as tday_get_product_screens lists them); anything else is refused with the reason, and the rest is still applied. A fact is a strong hint to the screen writer, never an override. Undo any fact with tday_undo_product_screen_fact.`,CW="File a product screen (drawn or photo) on features, or take it off them: a feature's page, flows, launch films and images use the screens filed on it, and one screen may be filed on several features. Pass screenId from tday_get_product_screens and feature ids from its `features`. Taking a screen off a feature also takes it out of that feature's flows.",OW="Remove a screen from the brand's product screens: off every feature and flow. A drawn screen's page stops being drawn (add it again with a `screen` fact); a photo is no longer used. Films already made keep what they showed.",AW=`Review one product screen: a verdict (good: it looks like the real product; bad: something is off) and/or a note about what is wrong, optionally pinned at a point on the screen (x, y as fractions of its width and height; a point inside one of the screen's parts is read as feedback on that component). tday reads the note as one fact about the real product and applies it to every screen, redrawing what it changes. Say what the real product does ("The sidebar shows the workspace switcher above the nav, not below"), one thing per note. Returns the fact made, which tday_undo_product_screen_fact can undo.`,IW="Undo a product-screen fact (the screens go back to how they were, with no redraw when tday kept the earlier version), restore an undone one, or settle a fact tday put back to the brand (status needs_review: the code changed under it) by choosing one of its options (action choose, option: its index).",yW="Upload a real screenshot of one page of the brand's app (from its running app, at desktop size, logged in with realistic data). tday compares it with its drawn screen of that route on the next build and turns the differences into facts. Use a viewport screenshot around 1440x900 (2x is fine) in PNG, JPG or WebP, under 4MB (save a JPEG if a PNG is larger).",L8,G0,TW,kW,SW,xW,wW=4194304,X0,C9;var O5=I(()=>{L1();i0();L8=p.string().trim().min(1).max(512).describe("A route exactly as tday_get_product_screens lists it, for example /projects/[projectId]"),G0=$$.describe("Brand ID from tday_list_brands"),TW=p.discriminatedUnion("kind",[p.object({kind:p.literal("screen"),scope:L8,featureIds:p.array($$).max(50).optional().describe("The features this page shows")}).strict(),p.object({kind:p.literal("page"),scope:p.string().trim().max(512).describe('A route, or "" for every page'),text:p.string().trim().min(1).max(1500)}).strict(),p.object({kind:p.literal("shell"),scope:p.string().trim().max(512).describe('A route, or "" for every page'),text:p.string().trim().min(1).max(1500)}).strict(),p.object({kind:p.literal("component"),scope:p.string().trim().min(1).max(200).describe("A component name from the library"),text:p.string().trim().min(1).max(1500)}).strict(),p.object({kind:p.literal("flag"),scope:p.string().trim().min(1).max(200).describe("A flag name from flags"),value:p.enum(["on","off"])}).strict(),p.object({kind:p.literal("exclude_page"),scope:L8}).strict(),p.object({kind:p.literal("exclude_component"),scope:p.string().trim().min(1).max(200)}).strict()]),kW={brandId:G0,route:L8,verdict:p.enum(["good","bad"]).optional().describe("good: looks like the real product; bad: something is off"),note:p.string().trim().min(1).max(2000).optional().describe("What is wrong, as what the real product does"),x:p.number().min(0).max(1).optional().describe("Where on the screen, 0 = left edge, 1 = right edge"),y:p.number().min(0).max(1).optional().describe("Where on the screen, 0 = top, 1 = bottom"),plateId:p.string().trim().max(128).optional().describe("The screen's plateId from tday_get_product_screen (defaults to the current screen)")};SW={brandId:G0,factId:$$.describe("Fact ID from tday_get_product_screens or a tool's reply"),action:p.enum(["undo","restore","choose"]).default("undo"),option:p.number().int().min(0).max(5).optional().describe("With action choose: the index of the option that is true now")};xW={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp"};X0=p.object({}).passthrough(),C9=[{name:"tday_get_product_screens",title:"Product screens",description:MW,inputSchema:t({brandId:G0}),outputSchema:X0,annotations:j$,handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/overview",$))},{name:"tday_get_product_screen",title:"Product screen",description:RW,inputSchema:t({brandId:G0,route:L8,before:p.boolean().default(!1).describe("Also show the version this screen replaced"),reference:p.boolean().default(!1).describe("Also show the newest real screenshot of the page")}),outputSchema:X0,annotations:j$,images:!0,handler:($,Z)=>o(Z,`${G$("/api/brands/:brandId/product-screens/screen",$)}${Y0({route:String($.route),before:$.before?1:void 0,reference:$.reference?1:void 0})}`)},{name:"tday_set_product_screen_context",title:"Set product screen context",description:_W,inputSchema:t({brandId:G0,facts:p.array(TW).min(1).max(60)}),outputSchema:X0,annotations:T$,handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/context",$),{method:"POST",body:JSON.stringify({facts:$.facts})})},{name:"tday_file_product_screen",title:"File a product screen on features",description:CW,inputSchema:t({brandId:G0,screenId:$$.describe("Screen ID from tday_get_product_screens"),add:p.array($$).max(50).optional().describe("Feature ids to file it on"),remove:p.array($$).max(50).optional().describe("Feature ids to take it off")}),outputSchema:X0,annotations:{...T$,idempotentHint:!0},handler:($,Z)=>{if(!$.add?.length&&!$.remove?.length)throw Error("Name a feature to add or remove.");return o(Z,G$("/api/brands/:brandId/product-screens/screens/:screenId",$),{method:"PATCH",body:JSON.stringify({add:$.add,remove:$.remove})})}},{name:"tday_remove_product_screen",title:"Remove a product screen",description:OW,inputSchema:t({brandId:G0,screenId:$$.describe("Screen ID from tday_get_product_screens")}),outputSchema:X0,annotations:{...T$,destructiveHint:!0,idempotentHint:!0},handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/screens/:screenId",$),{method:"DELETE"})},{name:"tday_leave_product_screen_feedback",title:"Review a product screen",description:AW,inputSchema:t(kW),outputSchema:X0,annotations:T$,handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/feedback",$),{method:"POST",body:JSON.stringify(zW($))})},{name:"tday_undo_product_screen_fact",title:"Undo a product screen fact",description:IW,inputSchema:t(SW),outputSchema:X0,annotations:{...T$,idempotentHint:!0},handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/facts/:factId",$),{method:"PATCH",body:JSON.stringify(EW($))})},{name:"tday_add_product_screen_reference",title:"Add a product screenshot",description:`${yW} Pass filePath: a screenshot inside the current working directory.`,inputSchema:t({brandId:G0,route:L8,filePath:p.string().trim().min(1).max(500).describe("The screenshot, relative to the working directory, for example ./screens/projects.png")}),outputSchema:X0,annotations:T$,handler:async($,Z)=>{let Q=await vW(String($.filePath)),J=new FormData;return J.set("route",String($.route)),J.set("file",new Blob([new Uint8Array(Q.bytes)],{type:Q.type}),Q.name),o(Z,G$("/api/brands/:brandId/product-screens/references",$),{method:"POST",body:J})}},{name:"tday_remove_product_screen_reference",title:"Remove a product screenshot",description:"Stop comparing a page's drawn screen with one of its reference screenshots. The facts it proposed stay until undone.",inputSchema:t({brandId:G0,referenceId:$$.describe("Reference ID from tday_get_product_screens")}),outputSchema:X0,annotations:{...T$,destructiveHint:!0,idempotentHint:!0},handler:($,Z)=>o(Z,G$("/api/brands/:brandId/product-screens/references/:referenceId",$),{method:"DELETE"})}]});import{z as M$}from"zod";var A5=50,bW="List a brand's features (its Launch page catalog), newest added first, with the videos each already has: how many launch videos are finished or being made, and the latest one with its link. Use it for the newest feature, for the features that still have no launch video (without: launch_video), or to find a feature's id for tday_create_launch_video. brandId may be left out when the account has one brand; otherwise pass one from tday_list_brands. `more` counts the features not listed. Spends no credits.",hW,O9;var I5=I(()=>{L1();i0();hW=M$.object({brand:M$.object({id:M$.string(),name:M$.string()}).passthrough(),counts:M$.record(M$.string(),M$.unknown()),features:M$.array(M$.record(M$.string(),M$.unknown())),more:M$.number()}).passthrough(),O9=[{name:"tday_list_features",title:"List features",description:bW,inputSchema:t({brandId:$$.optional().describe("Brand ID from tday_list_brands. Optional when the account has one brand."),without:M$.enum(["launch_video"]).optional().describe("launch_video: only features with no launch video finished or being made."),search:M$.string().trim().min(1).max(160).optional().describe("Only features whose title contains this, ignoring case."),limit:M$.number().int().min(1).max(A5).default(20).describe(`How many to list, newest first (at most ${A5}). Defaults to 20.`)}),outputSchema:hW,annotations:j$,handler:($,Z)=>o(Z,`/api/v1/features${Y0({brandId:typeof $.brandId==="string"?$.brandId:void 0,without:typeof $.without==="string"?$.without:void 0,q:typeof $.search==="string"?$.search:void 0,limit:typeof $.limit==="number"?$.limit:void 0})}`)}]});function q8($){return JSON.stringify($,(Z,Q)=>typeof Q==="bigint"?Q.toString():Q,2)}function D8($){if(!a$($)||!Array.isArray($.images))return{result:$,images:[]};let Z=[],Q=[];for(let J of $.images){if(!a$(J)||typeof J.data!=="string"||typeof J.mimeType!=="string"||!J.mimeType.startsWith("image/"))continue;Z.push({type:"image",data:J.data,mimeType:J.mimeType}),Q.push({label:J.label??null,mimeType:J.mimeType,bytes:Math.floor(J.data.length*3/4),position:Z.length})}return{result:{...$,images:Q},images:Z}}function A9($){return a$($)?$:{result:$}}function I9($,Z,Q,J){let Y=Q==="markdown"?gW($,Z,J):q8(Z);return fW(Y)}function a$($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function fW($){if($.length<=25000)return $;return`${$.slice(0,25000)}
3
3
 
4
4
  [Response text truncated at 25000 characters. Use structuredContent or narrower list/get calls for the complete data.]`}function gW($,Z,Q){if(!a$(Z))return String(Z);if(Q)return Q(Z);switch($){case"tday_whoami":return uW(Z);case"tday_list_brands":return T5("Brands",Z.brands,["id","name","role","status","industry"]);case"tday_list_designs":return T5("Designs",Z.designs,["id","name","brandName","currentStep","updatedAt"]);case"tday_generate_design":return["# Generation queued",`- Design ID: ${Z.designId??"unknown"}`,`- Generation ID: ${Z.generationId??"unknown"}`,`- Status: ${Z.status??"unknown"}`,Z.editorUrl?`- Editor: ${Z.editorUrl}`:void 0,"","Poll with `tday_poll_generation` until status is `completed` or `failed`."].filter(Boolean).join(`
5
5
  `);case"tday_poll_generation":return["# Generation status",`- Design ID: ${Z.designId??"unknown"}`,`- Generation ID: ${Z.generationId??"unknown"}`,`- Status: ${Z.status??"unknown"}`,Z.imageUrl?`- Image URL: ${Z.imageUrl}`:void 0,Z.editorUrl?`- Editor: ${Z.editorUrl}`:void 0,Z.failureMessage?`- Failure: ${Z.failureMessage}`:void 0].filter(Boolean).join(`
@@ -612,11 +612,11 @@ this repo and commits nothing: tell the developer what you saved, and that commi
612
612
  with their team's agents. In a public repo they choose .tday/apps or .tday/local (this machine only).
613
613
  `;var mX={};V4(mX,{updateAgents:()=>uX,runUpdate:()=>CF,refreshClaudeSkill:()=>G9,codexTdayBlock:()=>gX});import{existsSync as uZ,readFileSync as mZ,writeFileSync as RF}from"node:fs";import{homedir as cZ}from"node:os";import{join as fX}from"node:path";function gX($){let Z=$.split(/\r?\n/),Q=Z.findIndex((Y)=>/^\s*\[mcp_servers\.("tday"|tday)\]\s*(#.*)?$/.test(Y));if(Q<0)return"";let J=[];for(let Y of Z.slice(Q+1)){if(/^\s*\[/.test(Y))break;let X=Y.replace(/#.*$/,"").trim();if(X)J.push(X)}return J.join(`
614
614
  `)}function uX($=cZ(),Z=process.env){let Q=H4(),J=[];for(let G of V8($,Z)){let{name:W,configPath:K}=G;if(!uZ(K))continue;let V;try{V=JSON.parse(mZ(K,"utf8"))}catch{J.push({name:W,configPath:K,action:"skipped",message:`${K} is not valid JSON; left alone.`});continue}let H=K8(V)?V[G.key]:void 0,B=K8(H)?H[Q0]:void 0;if(!K8(B))continue;let U=Array.isArray(B.args)?B.args:[],F=U.findIndex(_F);if(F<0){J.push({name:W,configPath:K,action:"skipped",message:`${W}'s "${Q0}" server does not run ${S$}; left alone.`});continue}let j=U[F];if(j===Q){J.push({name:W,configPath:K,action:"current",from:j,message:`${W} already runs ${Q}.`});continue}B.args=U.map((L,M)=>M===F?Q:L),gZ(K,JSON.stringify(V,null,2)+`
615
- `),J.push({name:W,configPath:K,action:"updated",from:j,message:`${W}: ${j} -> ${Q} (${K}).`})}let Y=fX($,".codex","config.toml"),X=gX(uZ(Y)?mZ(Y,"utf8"):"");if(X.includes(`"${Q}"`))J.push({name:"Codex",configPath:Y,action:"current",from:Q,message:`Codex already runs ${Q}.`});else if(X.includes(`${S$}@`))J.push({name:"Codex",configPath:Y,action:"manual",message:`Codex: in ${Y}, change the ${S$} version in [mcp_servers."${Q0}"] args to "${Q}" (Codex's TOML is never edited for you).`});return J}function G9($=cZ()){let Z=fX($,".claude","skills","tday-capture","SKILL.md");if(!uZ(Z)||mZ(Z,"utf8")===U1)return null;return RF(Z,U1),`Refreshed the tday-capture skill (${Z}).`}function CF($=cZ(),Z=process.env){let Q=uX($,Z);for(let Y of Q)console.log(Y.message);let J=G9($);if(J)console.log(J);if(!Q.length){console.log(`No coding agent here runs the "${Q0}" server yet. Add it with \`npx --prefix ~ -y ${S$}@latest install\` (with a capture prompt's token, run its install line instead).`);return}if(Q.some((Y)=>Y.action==="updated")||J)console.log("Reload the tools to use it: in Claude Code, type /reload-plugins; restart any other coding agent.")}var _F=($)=>typeof $==="string"&&($===S$||$.startsWith(`${S$}@`));var dZ=I(()=>{X9();F1()});import{accessSync as OF,constants as AF,existsSync as IF,readFileSync as lZ,realpathSync as yF,renameSync as TF,rmSync as kF,statSync as zF,writeFileSync as SF}from"node:fs";import{homedir as pZ}from"node:os";import{join as EF}from"node:path";function dX($){let Z=$?.mcp?.version;return typeof Z==="string"&&wF.test(Z)?Z:null}async function hF($,Z=fetch){try{let Q=await Z(`${bF}/${S$.replace("/","%2f")}/${$}`,{headers:{accept:"application/json"},signal:AbortSignal.timeout(5000)});if(!Q.ok)return!1;let J=await Q.json(),Y=J._npmUser?.trustedPublisher;return J.version===$&&Y?.id==="github"&&Y.oidcConfigId===xF}catch{return!1}}function lX($){let Z=$?.args;if(!Array.isArray(Z))return null;for(let Q=0;Q<Z.length;Q++){let J=typeof Z[Q]==="string"?vF.exec(Z[Q]):null;if(J)return{index:Q,version:J[1]}}return null}function cX($,Z){if(typeof $!=="object"||$===null||Array.isArray($))return 0;let Q=0;for(let J of Object.values($)){let Y=lX(J);if(!Y||!X4(Z,Y.version)||fF(J))continue;J.args[Y.index]=`${S$}@${Z}`,Q++}return Q}function gF($,Z,Q){if(!$.includes(`${S$}@`))return null;let J;try{J=JSON.parse($)}catch{return null}if(typeof J!=="object"||J===null||Array.isArray(J))return null;let Y=J,X=cX(Y[Z],Q),G=Y.projects;if(Z==="mcpServers"&&typeof G==="object"&&G!==null)for(let W of Object.values(G))X+=cX(W?.mcpServers,Q);return X?JSON.stringify(J,null,2)+`
616
- `:null}function uF($,Z){let Q=yF($);OF(Q,AF.W_OK);for(let J=0;J<2;J++){let Y=lZ(Q,"utf8"),X=Z(Y);if(X===null)return!1;let G=`${Q}.tmp-${process.pid}-${Date.now()}`;try{if(SF(G,X,{encoding:"utf8",mode:zF(Q).mode&511}),lZ(Q,"utf8")!==Y)continue;return TF(G,Q),!0}finally{kF(G,{force:!0})}}return!1}function mF($,Z=pZ(),Q=process.env){let J=[];for(let Y of V8(Z,Q)){if(!IF(Y.configPath))continue;try{if(uF(Y.configPath,(X)=>gF(X,Y.key,$)))J.push(Y.configPath)}catch{}}return J}async function pX($){let Z=$.env??process.env,{approved:Q}=$;try{if(Z.TDAY_MCP_AUTO_UPDATE==="0"||!Q||!X4(Q,$.running))return[];if(!await hF(Q,$.fetchImpl))return[];let J=mF(Q,$.home??pZ(),Z);if(J.length)$.log?.(`[tday] Updated the tday MCP from ${$.running} to ${Q} in ${J.join(", ")}. Your coding agent runs it from its next start.`),TX(Q);return J}catch{return[]}}function iX($,Z=pZ()){try{let Q=JSON.parse(lZ(EF(Z,".claude.json"),"utf8"));return lX(Q.mcpServers?.tday)?.version===$?G9(Z):null}catch{return null}}var xF="0b453fc8-b9fa-4e97-81a1-efe71ba2eff5",wF,vF,bF="https://registry.npmjs.org",fF=($)=>$?.env?.TDAY_MCP_AUTO_UPDATE==="0";var iZ=I(()=>{G4();X9();dZ();F1();wF=/^\d+\.\d+\.\d+$/,vF=new RegExp(`^${S$.replace(/[/.]/g,"\\$&")}@(\\d+\\.\\d+\\.\\d+)$`)});async function nX($,Z,Q,J){try{let Y=await fetch(`${$}${Q}`,{headers:{authorization:`Bearer ${Z}`,accept:"application/json",[N1]:V$},signal:AbortSignal.timeout(J)});if(!Y.ok){let G=await Y.json().catch(()=>null);return{body:null,answered:Y.status<500,...typeof G?.error==="string"?{error:G.error}:{}}}let X=await Y.json();return typeof X==="object"&&X!==null&&!Array.isArray(X)?{body:X}:{body:null,answered:!1}}catch{return{body:null,answered:!1}}}async function W9($){let Z=$.timeoutMs??5000,Q=$.captureToken||$.accountToken,[J,Y]=await Promise.all([Q?nX($.captureToken?$.captureApiBaseUrl??$.apiBaseUrl:$.apiBaseUrl,Q,"/api/capture/me",Z):null,$.accountToken?nX($.apiBaseUrl,$.accountToken,"/api/v1/account",Z):null]),X=(H)=>H!==null&&H.body===null&&!H.answered&&$.unanswered,G=$.captureToken&&J&&J.body===null&&J.answered?J.error&&J.error!=="Unauthorized"?J.error:"Its token has expired or was revoked.":null,W=Array.isArray(J?.body?.brands)?J.body.brands:[],K=dX(J?.body??null),V=Y?.body?.features;return{capture:!Q||W.length>0||X(J),demos:W.some((H)=>H?.localDemos===!0)||X(J),images:V?.images===!0||X(Y),launchVideos:V?.launchVideos===!0||X(Y),...G?{captureRefused:G}:{},...K?{release:K}:{}}}function aX($,Z){let Q=Z.replace(/\/+$/,""),J=Q==="https://tday.com"?`curl -fsSL ${Q}/install.sh | bash`:`curl -fsSL ${Q}/install.sh | TDAY_WEB_URL=${Q} TDAY_API_URL=${Q} bash`;return`tday: this server was installed from a tday prompt that tday no longer accepts. ${$} Its demo and capture tools stay hidden until it is replaced. Tell the developer to ask for a new tday prompt and run its install line, or, with their own tday account, to run: ${J}. Then type /reload-plugins in Claude Code (restart any other coding agent).`}var nZ=I(()=>{iZ()});import{z as cF}from"zod";function dF($){return($??"").replace(/["\r\n\t]+/g," ").replace(/\s+/g," ").trim().slice(0,160)||null}function lF($){let Z=dF($);return[`Make a tday launch video of ${Z?`the feature "${Z}"`:"the newest feature that has no launch video yet"}.`,Z?`1. Find it with tday_list_features (search "${Z}") and use its id. If several match, show them and ask which.`:'1. Call tday_list_features with without "launch_video" and offer the newest feature it lists, with the next two as alternatives.'," If tday asks for a brand, list them with tday_list_brands and ask which.","2. Before spending anything, quote the price (tday_get_credit_prices) and the balance (tday_whoami), and ask me to confirm and whether I want a voiceover or another length.","3. Call tday_create_launch_video with the featureId and the options I chose, then poll tday_poll_launch_video every 20-30 seconds until it is ready.","4. Show me the reviewUrl as a link and offer the MP4 (tday_get_launch_video_mp4)."].join(`
617
- `)}function oX($,Z=!0){if(!Z)return;let Q=$.registerPrompt.bind($);Q("launch-video",{title:"Launch video of a feature",description:"Make a launch video of a feature: the one you name, or the newest feature without one. Quotes the credits before it starts.",argsSchema:{feature:cF.string().optional().describe("The feature's name. Leave empty for the newest feature without a launch video.")}},({feature:J})=>rX(lF(J))),Q("features",{title:"Latest features",description:"The brand's newest features and which already have a launch video."},()=>rX(pF))}var pF,rX=($)=>({messages:[{role:"user",content:{type:"text",text:$}}]});var tX=I(()=>{pF=["Show me my tday features, newest first, and which have a launch video: call tday_list_features (if tday asks for a brand, list them with tday_list_brands and ask which).","List each feature's name, when it was added, and its launch video: finished, being made, or none.","Then offer to make a launch video of the newest feature that has none."].join(`
618
- `)});function sX($,Z,Q){let J=$.registerTool.bind($);for(let Y of Z)J(Y.name,{title:Y.title,description:Y.description,inputSchema:Y.inputSchema,outputSchema:Y.outputSchema,annotations:{readOnlyHint:Y.annotations.readOnlyHint,destructiveHint:Y.annotations.destructiveHint,idempotentHint:Y.annotations.idempotentHint,openWorldHint:Y.annotations.openWorldHint}},async(X)=>{let G=X??{},{result:W,images:K}=Y.images?D8(await Y.handler(G,Q)):{result:await Y.handler(G,Q),images:[]},V=Z9();return{content:[{type:"text",text:I9(Y.name,W,P9(G),Y.markdown)},...K,...V?[{type:"text",text:V}]:[]],structuredContent:A9(W)}})}var eX=I(()=>{G4();N4()});var $G={};V4($G,{runServer:()=>iF,ACCOUNT_INSTRUCTIONS:()=>aZ});async function iF(){let[$,Z]=await Promise.all([B4(),Q$()]),Q=await W9({apiBaseUrl:$.apiBaseUrl,accountToken:$.token,captureToken:Z.tokenSource==="capture"?Z.token:null,captureApiBaseUrl:Z.apiBaseUrl,unanswered:!0});pX({running:l0(),approved:Q.release??null,log:(X)=>process.stderr.write(`${X}
619
- `)}),setImmediate(()=>iX(l0()));let J=Q.captureRefused?aX(Q.captureRefused,Z.apiBaseUrl):null,Y=Q.capture?vZ:J?$.token?`${J} ${aZ}`:J:aZ;await Q9({identity:{name:"tday",version:l0(),instructions:Y},tools:Q.capture?W4:[],prompts:Q.capture?void 0:[xZ],extend:(X)=>{if(!$.token)return;sX(X,z5(Q),$),oX(X,Q.launchVideos)}})}var aZ="tday: your tday.com account. tday_whoami first: your organisations, plan and credits. Quote what something costs (tday_get_credit_prices) before starting it.";var ZG=I(()=>{q$();bZ();wZ();nZ();L9();F1();tX();eX();iZ();N4()});var WG={};V4(WG,{installClients:()=>H9,claudeAddArgs:()=>XG,announceInstall:()=>GG,SIGNED_IN_INSTALL:()=>V9});import{execFile as nF}from"node:child_process";import{mkdir as aF,writeFile as rF}from"node:fs/promises";import{homedir as JG}from"node:os";import{join as QG}from"node:path";import{promisify as oF}from"node:util";function XG($){return["mcp","add","--scope","user",K9,...$,"--",...oZ()]}async function GG($=process.env,Z=fetch){let Q=await Q$($);if(Q.tokenSource!=="capture"||!Q.token)return null;try{let J=await Z(`${Q.apiBaseUrl}/api/capture/me`,{headers:{authorization:`Bearer ${Q.token}`,accept:"application/json"},signal:AbortSignal.timeout(5000)});if(J.status!==401&&J.status!==403)return null;let Y=await J.json().catch(()=>null);return`tday did not accept this capture prompt. ${typeof Y?.error==="string"&&Y.error!=="Unauthorized"?Y.error:"Its token has expired or was revoked. Ask for a new prompt."}`}catch{return null}}async function tF(){try{return await rZ("claude",["--version"]),!0}catch{return!1}}async function H9($){let Z=process.env.TDAY_CAPTURE_TOKEN,Q=process.env.TDAY_API_URL,J=[...Z?["-e",`TDAY_CAPTURE_TOKEN=${Z}`]:[],...Q?["-e",`TDAY_API_URL=${Q}`]:[]];if(!Z&&!(await Q$()).token)console.log(`No capture token and no tday login on this machine. With a tday account, sign in once instead: ${V9} (it adds this server to your coding agents). With a capture prompt from a teammate, run its install line, which carries the token.`);let Y=await GG();if(Y)console.log(Y);let X=Z?"then ask what your tday prompt says":'then ask: "Use tday to record a demo video of our newest feature"';if((!$||$==="claude")&&await tF()){for(let V of["tday-capture",K9])await rZ("claude",["mcp","remove","--scope","user",V]).catch(()=>{return});await rZ("claude",XG(J));let K=QG(JG(),".claude","skills","tday-capture");if(await aF(K,{recursive:!0}),await rF(QG(K,"SKILL.md"),U1),console.log(`Added the tday MCP server to Claude Code (user scope)${Z?" with your capture token":""}, and the tday-capture skill. In a Claude Code session that is already open, type /reload-plugins to load it (no restart needed), ${X}.`),$==="claude")return}let G=Z?', "env": { "TDAY_CAPTURE_TOKEN": "<your capture token>" }':"",W=oZ().slice(1).map((K)=>JSON.stringify(K)).join(", ");console.log(`
615
+ `),J.push({name:W,configPath:K,action:"updated",from:j,message:`${W}: ${j} -> ${Q} (${K}).`})}let Y=fX($,".codex","config.toml"),X=gX(uZ(Y)?mZ(Y,"utf8"):"");if(X.includes(`"${Q}"`))J.push({name:"Codex",configPath:Y,action:"current",from:Q,message:`Codex already runs ${Q}.`});else if(X.includes(`${S$}@`))J.push({name:"Codex",configPath:Y,action:"manual",message:`Codex: in ${Y}, change the ${S$} version in [mcp_servers."${Q0}"] args to "${Q}" (Codex's TOML is never edited for you).`});return J}function G9($=cZ()){let Z=fX($,".claude","skills","tday-capture","SKILL.md");if(!uZ(Z)||mZ(Z,"utf8")===U1)return null;return RF(Z,U1),`Refreshed the tday-capture skill (${Z}).`}function CF($=cZ(),Z=process.env){let Q=uX($,Z);for(let Y of Q)console.log(Y.message);let J=G9($);if(J)console.log(J);if(!Q.length){console.log(`No coding agent here runs the "${Q0}" server yet. Add it with \`npx --prefix ~ -y ${S$}@latest install\` (with a capture prompt's token, run its install line instead).`);return}if(Q.some((Y)=>Y.action==="updated")||J)console.log("Reload the tools to use it: in Claude Code, type /reload-plugins; restart any other coding agent.")}var _F=($)=>typeof $==="string"&&($===S$||$.startsWith(`${S$}@`));var dZ=I(()=>{X9();F1()});import{accessSync as OF,constants as AF,existsSync as IF,readFileSync as lZ,realpathSync as yF,renameSync as TF,rmSync as kF,statSync as zF,writeFileSync as SF}from"node:fs";import{homedir as pZ}from"node:os";import{join as EF}from"node:path";function dX($){let Z=$?.mcp?.version;return typeof Z==="string"&&wF.test(Z)?Z:null}async function gF($,Z=fetch){try{let Q=await Z(`${fF}/${bF(S$)}/${$}`,{headers:{accept:"application/json"},signal:AbortSignal.timeout(5000)});if(!Q.ok)return!1;let J=await Q.json(),Y=J._npmUser?.trustedPublisher;return J.version===$&&Y?.id==="github"&&Y.oidcConfigId===xF}catch{return!1}}function lX($){let Z=$?.args;if(!Array.isArray(Z))return null;for(let Q=0;Q<Z.length;Q++){let J=typeof Z[Q]==="string"?hF.exec(Z[Q]):null;if(J)return{index:Q,version:J[1]}}return null}function cX($,Z){if(typeof $!=="object"||$===null||Array.isArray($))return 0;let Q=0;for(let J of Object.values($)){let Y=lX(J);if(!Y||!X4(Z,Y.version)||uF(J))continue;J.args[Y.index]=`${S$}@${Z}`,Q++}return Q}function mF($,Z,Q){if(!$.includes(`${S$}@`))return null;let J;try{J=JSON.parse($)}catch{return null}if(typeof J!=="object"||J===null||Array.isArray(J))return null;let Y=J,X=cX(Y[Z],Q),G=Y.projects;if(Z==="mcpServers"&&typeof G==="object"&&G!==null)for(let W of Object.values(G))X+=cX(W?.mcpServers,Q);return X?JSON.stringify(J,null,2)+`
616
+ `:null}function cF($,Z){let Q=yF($);OF(Q,AF.W_OK);for(let J=0;J<2;J++){let Y=lZ(Q,"utf8"),X=Z(Y);if(X===null)return!1;let G=`${Q}.tmp-${process.pid}-${Date.now()}`;try{if(SF(G,X,{encoding:"utf8",mode:zF(Q).mode&511}),lZ(Q,"utf8")!==Y)continue;return TF(G,Q),!0}finally{kF(G,{force:!0})}}return!1}function dF($,Z=pZ(),Q=process.env){let J=[];for(let Y of V8(Z,Q)){if(!IF(Y.configPath))continue;try{if(cF(Y.configPath,(X)=>mF(X,Y.key,$)))J.push(Y.configPath)}catch{}}return J}async function pX($){let Z=$.env??process.env,{approved:Q}=$;try{if(Z.TDAY_MCP_AUTO_UPDATE==="0"||!Q||!X4(Q,$.running))return[];if(!await gF(Q,$.fetchImpl))return[];let J=dF(Q,$.home??pZ(),Z);if(J.length)$.log?.(`[tday] Updated the tday MCP from ${$.running} to ${Q} in ${J.join(", ")}. Your coding agent runs it from its next start.`),TX(Q);return J}catch{return[]}}function iX($,Z=pZ()){try{let Q=JSON.parse(lZ(EF(Z,".claude.json"),"utf8"));return lX(Q.mcpServers?.tday)?.version===$?G9(Z):null}catch{return null}}var xF="0b453fc8-b9fa-4e97-81a1-efe71ba2eff5",wF,vF=($)=>new RegExp(`^${$.replace(/[\\^$.*+?()[\]{}|/]/g,"\\$&")}@(\\d+\\.\\d+\\.\\d+)$`),bF=($)=>$.replaceAll("/","%2f"),hF,fF="https://registry.npmjs.org",uF=($)=>$?.env?.TDAY_MCP_AUTO_UPDATE==="0";var iZ=I(()=>{G4();X9();dZ();F1();wF=/^\d+\.\d+\.\d+$/,hF=vF(S$)});async function nX($,Z,Q,J){try{let Y=await fetch(`${$}${Q}`,{headers:{authorization:`Bearer ${Z}`,accept:"application/json",[N1]:V$},signal:AbortSignal.timeout(J)});if(!Y.ok){let G=await Y.json().catch(()=>null);return{body:null,answered:Y.status<500,...typeof G?.error==="string"?{error:G.error}:{}}}let X=await Y.json();return typeof X==="object"&&X!==null&&!Array.isArray(X)?{body:X}:{body:null,answered:!1}}catch{return{body:null,answered:!1}}}async function W9($){let Z=$.timeoutMs??5000,Q=$.captureToken||$.accountToken,[J,Y]=await Promise.all([Q?nX($.captureToken?$.captureApiBaseUrl??$.apiBaseUrl:$.apiBaseUrl,Q,"/api/capture/me",Z):null,$.accountToken?nX($.apiBaseUrl,$.accountToken,"/api/v1/account",Z):null]),X=(H)=>H!==null&&H.body===null&&!H.answered&&$.unanswered,G=$.captureToken&&J&&J.body===null&&J.answered?J.error&&J.error!=="Unauthorized"?J.error:"Its token has expired or was revoked.":null,W=Array.isArray(J?.body?.brands)?J.body.brands:[],K=dX(J?.body??null),V=Y?.body?.features;return{capture:!Q||W.length>0||X(J),demos:W.some((H)=>H?.localDemos===!0)||X(J),images:V?.images===!0||X(Y),launchVideos:V?.launchVideos===!0||X(Y),...G?{captureRefused:G}:{},...K?{release:K}:{}}}function aX($,Z){let Q=Z.replace(/\/+$/,""),J=Q==="https://tday.com"?`curl -fsSL ${Q}/install.sh | bash`:`curl -fsSL ${Q}/install.sh | TDAY_WEB_URL=${Q} TDAY_API_URL=${Q} bash`;return`tday: this server was installed from a tday prompt that tday no longer accepts. ${$} Its demo and capture tools stay hidden until it is replaced. Tell the developer to ask for a new tday prompt and run its install line, or, with their own tday account, to run: ${J}. Then type /reload-plugins in Claude Code (restart any other coding agent).`}var nZ=I(()=>{iZ()});import{z as lF}from"zod";function pF($){return($??"").replace(/["\r\n\t]+/g," ").replace(/\s+/g," ").trim().slice(0,160)||null}function iF($){let Z=pF($);return[`Make a tday launch video of ${Z?`the feature "${Z}"`:"the newest feature that has no launch video yet"}.`,Z?`1. Find it with tday_list_features (search "${Z}") and use its id. If several match, show them and ask which.`:'1. Call tday_list_features with without "launch_video" and offer the newest feature it lists, with the next two as alternatives.'," If tday asks for a brand, list them with tday_list_brands and ask which.","2. Before spending anything, quote the price (tday_get_credit_prices) and the balance (tday_whoami), and ask me to confirm and whether I want a voiceover or another length.","3. Call tday_create_launch_video with the featureId and the options I chose, then poll tday_poll_launch_video every 20-30 seconds until it is ready.","4. Show me the reviewUrl as a link and offer the MP4 (tday_get_launch_video_mp4)."].join(`
617
+ `)}function oX($,Z=!0){if(!Z)return;let Q=$.registerPrompt.bind($);Q("launch-video",{title:"Launch video of a feature",description:"Make a launch video of a feature: the one you name, or the newest feature without one. Quotes the credits before it starts.",argsSchema:{feature:lF.string().optional().describe("The feature's name. Leave empty for the newest feature without a launch video.")}},({feature:J})=>rX(iF(J))),Q("features",{title:"Latest features",description:"The brand's newest features and which already have a launch video."},()=>rX(nF))}var nF,rX=($)=>({messages:[{role:"user",content:{type:"text",text:$}}]});var tX=I(()=>{nF=["Show me my tday features, newest first, and which have a launch video: call tday_list_features (if tday asks for a brand, list them with tday_list_brands and ask which).","List each feature's name, when it was added, and its launch video: finished, being made, or none.","Then offer to make a launch video of the newest feature that has none."].join(`
618
+ `)});function sX($,Z,Q){let J=$.registerTool.bind($);for(let Y of Z)J(Y.name,{title:Y.title,description:Y.description,inputSchema:Y.inputSchema,outputSchema:Y.outputSchema,annotations:{readOnlyHint:Y.annotations.readOnlyHint,destructiveHint:Y.annotations.destructiveHint,idempotentHint:Y.annotations.idempotentHint,openWorldHint:Y.annotations.openWorldHint}},async(X)=>{let G=X??{},{result:W,images:K}=Y.images?D8(await Y.handler(G,Q)):{result:await Y.handler(G,Q),images:[]},V=Z9();return{content:[{type:"text",text:I9(Y.name,W,P9(G),Y.markdown)},...K,...V?[{type:"text",text:V}]:[]],structuredContent:A9(W)}})}var eX=I(()=>{G4();N4()});var $G={};V4($G,{runServer:()=>aF,ACCOUNT_INSTRUCTIONS:()=>aZ});async function aF(){let[$,Z]=await Promise.all([B4(),Q$()]),Q=await W9({apiBaseUrl:$.apiBaseUrl,accountToken:$.token,captureToken:Z.tokenSource==="capture"?Z.token:null,captureApiBaseUrl:Z.apiBaseUrl,unanswered:!0});pX({running:l0(),approved:Q.release??null,log:(X)=>process.stderr.write(`${X}
619
+ `)}),setImmediate(()=>iX(l0()));let J=Q.captureRefused?aX(Q.captureRefused,Z.apiBaseUrl):null,Y=Q.capture?vZ:J?$.token?`${J} ${aZ}`:J:aZ;await Q9({identity:{name:"tday",version:l0(),instructions:Y},tools:Q.capture?W4:[],prompts:Q.capture?void 0:[xZ],extend:(X)=>{if(!$.token)return;sX(X,z5(Q),$),oX(X,Q.launchVideos)}})}var aZ="tday: your tday.com account. tday_whoami first: your organisations, plan and credits. Quote what something costs (tday_get_credit_prices) before starting it.";var ZG=I(()=>{q$();bZ();wZ();nZ();L9();F1();tX();eX();iZ();N4()});var WG={};V4(WG,{installClients:()=>H9,claudeAddArgs:()=>XG,announceInstall:()=>GG,SIGNED_IN_INSTALL:()=>V9});import{execFile as rF}from"node:child_process";import{mkdir as oF,writeFile as tF}from"node:fs/promises";import{homedir as JG}from"node:os";import{join as QG}from"node:path";import{promisify as sF}from"node:util";function XG($){return["mcp","add","--scope","user",K9,...$,"--",...oZ()]}async function GG($=process.env,Z=fetch){let Q=await Q$($);if(Q.tokenSource!=="capture"||!Q.token)return null;try{let J=await Z(`${Q.apiBaseUrl}/api/capture/me`,{headers:{authorization:`Bearer ${Q.token}`,accept:"application/json"},signal:AbortSignal.timeout(5000)});if(J.status!==401&&J.status!==403)return null;let Y=await J.json().catch(()=>null);return`tday did not accept this capture prompt. ${typeof Y?.error==="string"&&Y.error!=="Unauthorized"?Y.error:"Its token has expired or was revoked. Ask for a new prompt."}`}catch{return null}}async function eF(){try{return await rZ("claude",["--version"]),!0}catch{return!1}}async function H9($){let Z=process.env.TDAY_CAPTURE_TOKEN,Q=process.env.TDAY_API_URL,J=[...Z?["-e",`TDAY_CAPTURE_TOKEN=${Z}`]:[],...Q?["-e",`TDAY_API_URL=${Q}`]:[]];if(!Z&&!(await Q$()).token)console.log(`No capture token and no tday login on this machine. With a tday account, sign in once instead: ${V9} (it adds this server to your coding agents). With a capture prompt from a teammate, run its install line, which carries the token.`);let Y=await GG();if(Y)console.log(Y);let X=Z?"then ask what your tday prompt says":'then ask: "Use tday to record a demo video of our newest feature"';if((!$||$==="claude")&&await eF()){for(let V of["tday-capture",K9])await rZ("claude",["mcp","remove","--scope","user",V]).catch(()=>{return});await rZ("claude",XG(J));let K=QG(JG(),".claude","skills","tday-capture");if(await oF(K,{recursive:!0}),await tF(QG(K,"SKILL.md"),U1),console.log(`Added the tday MCP server to Claude Code (user scope)${Z?" with your capture token":""}, and the tday-capture skill. In a Claude Code session that is already open, type /reload-plugins to load it (no restart needed), ${X}.`),$==="claude")return}let G=Z?', "env": { "TDAY_CAPTURE_TOKEN": "<your capture token>" }':"",W=oZ().slice(1).map((K)=>JSON.stringify(K)).join(", ");console.log(`
620
620
  Cursor (~/.cursor/mcp.json):
621
621
  { "mcpServers": { "${K9}": { "command": "npx", "args": [${W}]${G} } } }
622
622
  Codex (~/.codex/config.toml):
@@ -625,7 +625,7 @@ Codex (~/.codex/config.toml):
625
625
  args = [${W}]${Z?`
626
626
  env = { TDAY_CAPTURE_TOKEN = "<your capture token>" }`:""}
627
627
  Any other MCP client: run \`${oZ().join(" ")}\` over stdio.
628
- The agent's instructions: \`npx -y ${YG} skill\` prints them.`)}var rZ,K9="tday",YG,oZ=()=>["npx","--prefix",JG(),"-y",YG,"serve"],V9="curl -fsSL https://tday.com/install.sh | bash";var tZ=I(()=>{q$();rZ=oF(nF),YG=`${J0}@${V$}`});import sF from"node:http";function eF($){return $.headers["sec-fetch-mode"]==="navigate"||($.headers.accept??"").includes("text/html")}async function KG($){let Z,Q,J=new Promise((W,K)=>{Z=W,Q=K}),Y=sF.createServer((W,K)=>{if(K.setHeader("access-control-allow-origin","*"),K.setHeader("access-control-allow-methods","POST, OPTIONS"),K.setHeader("access-control-allow-headers","content-type"),W.method==="OPTIONS"){K.statusCode=204,K.end();return}if(W.url&&new URL(W.url,"http://127.0.0.1").pathname!=="/cb"){K.statusCode=404,K.end("not found");return}if(W.method!=="POST"){K.statusCode=405,K.end("method not allowed");return}let V="";W.on("data",(H)=>{if(V+=H.toString(),V.length>8192)K.statusCode=413,K.end("payload too large"),W.destroy()}),W.on("end",()=>{let H;try{H=JSON.parse(V)}catch{K.statusCode=400,K.end("invalid json");return}if(!H||typeof H!=="object"||typeof H.token!=="string"||typeof H.state!=="string"){K.statusCode=400,K.end("missing authorization payload or state");return}let B=H;if(B.state!==$.expectedState){K.statusCode=400,K.end("This authorization link is from another run of the installer. Re-run the installer and use its new link.");return}if(K.statusCode=200,eF(W))K.statusCode=303,K.setHeader("location",$.receivedUrl),K.setHeader("cache-control","no-store"),K.setHeader("referrer-policy","no-referrer"),K.end();else K.setHeader("content-type","application/json"),K.end(JSON.stringify({ok:!0}));Z(B)})});await new Promise((W,K)=>{Y.once("error",K),Y.listen(0,"127.0.0.1",()=>W())});let X=Y.address();if(!X||typeof X==="string")throw Y.close(),Error("failed to bind callback server");let G=setTimeout(()=>{Q(Error(`Authorization timed out after ${$.timeoutMs/1000}s`))},$.timeoutMs);return J.finally(()=>{clearTimeout(G),Y.close()}),{port:X.port,done:J}}var VG=()=>{};import{existsSync as HG,mkdirSync as $N,rmSync as ZN,writeFileSync as QN}from"node:fs";import{homedir as JN}from"node:os";import{join as K4}from"node:path";function YN($){return sZ.filter((Z)=>!Z.needs||$[Z.needs]).map((Z)=>Z.filename)}function UG($={demos:!1,images:!1,launchVideos:!1},Z=JN()){let Q=new Set(YN($)),J=sZ.filter((G)=>Q.has(G.filename)),Y=K4(Z,".claude");if(!HG(Y))return J.map((G)=>({name:BG(G.filename),path:K4(Y,"commands",G.filename),installed:!1}));let X=K4(Y,"commands");if(!HG(X))$N(X,{recursive:!0});for(let G of sZ){if(Q.has(G.filename))continue;try{ZN(K4(X,G.filename),{force:!0})}catch{}}return J.map((G)=>{let W=K4(X,G.filename);return QN(W,G.body,{encoding:"utf8",mode:420}),{name:BG(G.filename),path:W,installed:!0}})}var sZ,BG=($)=>$.replace(/\.md$/,"");var jG=I(()=>{sZ=[{filename:"tday.md",needs:"images",body:`---
628
+ The agent's instructions: \`npx -y ${YG} skill\` prints them.`)}var rZ,K9="tday",YG,oZ=()=>["npx","--prefix",JG(),"-y",YG,"serve"],V9="curl -fsSL https://tday.com/install.sh | bash";var tZ=I(()=>{q$();rZ=sF(rF),YG=`${J0}@${V$}`});import $N from"node:http";function ZN($){return $.headers["sec-fetch-mode"]==="navigate"||($.headers.accept??"").includes("text/html")}async function KG($){let Z,Q,J=new Promise((W,K)=>{Z=W,Q=K}),Y=$N.createServer((W,K)=>{if(K.setHeader("access-control-allow-origin","*"),K.setHeader("access-control-allow-methods","POST, OPTIONS"),K.setHeader("access-control-allow-headers","content-type"),W.method==="OPTIONS"){K.statusCode=204,K.end();return}if(W.url&&new URL(W.url,"http://127.0.0.1").pathname!=="/cb"){K.statusCode=404,K.end("not found");return}if(W.method!=="POST"){K.statusCode=405,K.end("method not allowed");return}let V="";W.on("data",(H)=>{if(V+=H.toString(),V.length>8192)K.statusCode=413,K.end("payload too large"),W.destroy()}),W.on("end",()=>{let H;try{H=JSON.parse(V)}catch{K.statusCode=400,K.end("invalid json");return}if(!H||typeof H!=="object"||typeof H.token!=="string"||typeof H.state!=="string"){K.statusCode=400,K.end("missing authorization payload or state");return}let B=H;if(B.state!==$.expectedState){K.statusCode=400,K.end("This authorization link is from another run of the installer. Re-run the installer and use its new link.");return}if(K.statusCode=200,ZN(W))K.statusCode=303,K.setHeader("location",$.receivedUrl),K.setHeader("cache-control","no-store"),K.setHeader("referrer-policy","no-referrer"),K.end();else K.setHeader("content-type","application/json"),K.end(JSON.stringify({ok:!0}));Z(B)})});await new Promise((W,K)=>{Y.once("error",K),Y.listen(0,"127.0.0.1",()=>W())});let X=Y.address();if(!X||typeof X==="string")throw Y.close(),Error("failed to bind callback server");let G=setTimeout(()=>{Q(Error(`Authorization timed out after ${$.timeoutMs/1000}s`))},$.timeoutMs);return J.finally(()=>{clearTimeout(G),Y.close()}),{port:X.port,done:J}}var VG=()=>{};import{existsSync as HG,mkdirSync as QN,rmSync as JN,writeFileSync as YN}from"node:fs";import{homedir as XN}from"node:os";import{join as K4}from"node:path";function GN($){return sZ.filter((Z)=>!Z.needs||$[Z.needs]).map((Z)=>Z.filename)}function UG($={demos:!1,images:!1,launchVideos:!1},Z=XN()){let Q=new Set(GN($)),J=sZ.filter((G)=>Q.has(G.filename)),Y=K4(Z,".claude");if(!HG(Y))return J.map((G)=>({name:BG(G.filename),path:K4(Y,"commands",G.filename),installed:!1}));let X=K4(Y,"commands");if(!HG(X))QN(X,{recursive:!0});for(let G of sZ){if(Q.has(G.filename))continue;try{JN(K4(X,G.filename),{force:!0})}catch{}}return J.map((G)=>{let W=K4(X,G.filename);return YN(W,G.body,{encoding:"utf8",mode:420}),{name:BG(G.filename),path:W,installed:!0}})}var sZ,BG=($)=>$.replace(/\.md$/,"");var jG=I(()=>{sZ=[{filename:"tday.md",needs:"images",body:`---
629
629
  name: tday
630
630
  description: Interact with your tday.com account. Generate designs, manage brands, check credits.
631
631
  ---
@@ -834,26 +834,26 @@ You are setting up the product screens of this product in tday.com: the screens
834
834
  - NEVER use Bash except to run the app and take the screenshots of step 5, and only after the user agrees.
835
835
  - Never invent product facts the code or the user does not support. Keep notes about how the product looks, not about tday.
836
836
  - No em dashes. Do not mention internal implementation details of tday.
837
- `}]});var qG={};V4(qG,{runInstaller:()=>jN,openBrowser:()=>LG});import{randomBytes as XN}from"node:crypto";import{chmodSync as FG,existsSync as GN,mkdirSync as WN,writeFileSync as KN}from"node:fs";import{homedir as VN}from"node:os";import{spawn as eZ}from"node:child_process";import{dirname as HN,join as BN}from"node:path";async function jN($){let Z=$.includes("--no-browser"),Q=$.includes("--dry-run");if(console.log(`tday MCP installer
837
+ `}]});var qG={};V4(qG,{runInstaller:()=>NN,openBrowser:()=>LG});import{randomBytes as WN}from"node:crypto";import{chmodSync as FG,existsSync as KN,mkdirSync as VN,writeFileSync as HN}from"node:fs";import{homedir as BN}from"node:os";import{spawn as eZ}from"node:child_process";import{dirname as UN,join as jN}from"node:path";async function NN($){let Z=$.includes("--no-browser"),Q=$.includes("--dry-run");if(console.log(`tday MCP installer
838
838
  `),Q){console.log(`Dry run - no files will be written, no browser opened.
839
- `);let L=hX();for(let M of L)console.log(` [${M.action}] ${M.name} - ${M.message}`);return}let J=XN(16).toString("hex"),Y=LN();console.log("1. Starting local callback listener…");let{port:X,done:G}=await KG({expectedState:J,timeoutMs:UN,receivedUrl:`${B9}/cli/auth/received?client=${encodeURIComponent(Y)}`}),W=`http://127.0.0.1:${X}/cb`,K=`${B9}/cli/auth?callback=${encodeURIComponent(W)}&state=${encodeURIComponent(J)}&client=${encodeURIComponent(Y)}`;if(console.log(`2. Sign in to tday in your browser to authorize this MCP connection:
839
+ `);let L=hX();for(let M of L)console.log(` [${M.action}] ${M.name} - ${M.message}`);return}let J=WN(16).toString("hex"),Y=DN();console.log("1. Starting local callback listener…");let{port:X,done:G}=await KG({expectedState:J,timeoutMs:FN,receivedUrl:`${B9}/cli/auth/received?client=${encodeURIComponent(Y)}`}),W=`http://127.0.0.1:${X}/cb`,K=`${B9}/cli/auth?callback=${encodeURIComponent(W)}&state=${encodeURIComponent(J)}&client=${encodeURIComponent(Y)}`;if(console.log(`2. Sign in to tday in your browser to authorize this MCP connection:
840
840
  `),console.log(` ${K}
841
841
  `),!Z)LG(K);console.log(`3. Waiting for authorization (timeout 5 min)…
842
842
  `);let V;try{V=(await G).token}catch(L){console.error(`
843
- Authorization failed: ${L.message}`),process.exit(1)}if(console.log("4. Verifying account link…"),!await NN(V))console.error(`Account link verification failed against ${U9}/api/billing/info. Nothing was saved.`),process.exit(1);FN(V),console.log(` Saved secure local connection to ${NG()} (chmod 0600)
843
+ Authorization failed: ${L.message}`),process.exit(1)}if(console.log("4. Verifying account link…"),!await qN(V))console.error(`Account link verification failed against ${U9}/api/billing/info. Nothing was saved.`),process.exit(1);LN(V),console.log(` Saved secure local connection to ${NG()} (chmod 0600)
844
844
  `);let B=await W9({apiBaseUrl:U9,accountToken:V,unanswered:!1});console.log("5. Patching installed AI agents (Claude Code, Cursor, Gemini CLI, Codex, VS Code)…");let U=bX();for(let L of U){let M=L.action==="patched"?"+":L.action==="manual"?"!":"-";console.log(` ${M} ${L.name}: ${L.message}`)}console.log(`
845
845
  6. Installing Claude Code slash commands...`);let F=UG(B);for(let L of F.filter((M)=>M.installed))console.log(` + ${L.path}`);if(F.some((L)=>!L.installed))console.log(" - Skipped (Claude Code not found)");let j=F.filter((L)=>L.installed).map((L)=>`/${L.name}`);console.log(`
846
- Done. In a Claude Code session that is already open, type /reload-plugins to load tday (no restart needed). Restart any other AI agent.${j.length?` In Claude Code, type / to see: ${j.join(", ")}`:""}`)}function NG(){return BN(VN(),".tday","config.json")}function FN($){let Z=NG(),Q=HN(Z);if(!GN(Q))WN(Q,{recursive:!0,mode:448});FG(Q,448),KN(Z,JSON.stringify({token:$,apiBaseUrl:U9,webBaseUrl:B9},null,2)+`
847
- `,{encoding:"utf8",mode:384}),FG(Z,384)}async function NN($){try{return(await fetch(`${U9}/api/billing/info`,{headers:{authorization:`Bearer ${$}`}})).ok}catch{return!1}}function LN(){if(process.env.TDAY_CLIENT_LABEL)return process.env.TDAY_CLIENT_LABEL;if(process.env.TERM_PROGRAM==="Claude Code")return"claude-code";if(process.env.CURSOR_TRACE_ID)return"cursor";return"tday-cli"}function LG($){let Z=process.platform,Q=()=>console.warn("Could not open the browser. Open the printed URL manually to continue.");try{let J;if(Z==="darwin")J=eZ("open",[$],{detached:!0,stdio:"ignore"});else if(Z==="win32")J=eZ("cmd",["/c","start","",$],{detached:!0,stdio:"ignore"});else J=eZ("xdg-open",[$],{detached:!0,stdio:"ignore"});J.once("error",Q),J.unref()}catch{Q()}}var B9,U9,UN=300000;var DG=I(()=>{VG();nZ();X9();jG();B9=(process.env.TDAY_WEB_URL??"https://tday.com").replace(/\/+$/,""),U9=(process.env.TDAY_API_URL??B9).replace(/\/+$/,"").replace(/\/api$/i,"")});var IN={};import{execSync as qN}from"node:child_process";import{readFile as DN}from"node:fs/promises";import{createInterface as PN}from"node:readline/promises";async function MN($,Z){if(process.stdout.write(`${$}
848
- `),PG("yes")){if(c9())return"ci";console.log("--yes is honored only in CI (CI=true). Type the code instead.")}if(!process.stdin.isTTY||!process.stdout.isTTY)return console.log("Not uploaded: confirming an upload needs a person at a terminal (or --yes in CI)."),null;let Q=await C4(Z);try{if(Q.state==="unopened")return console.log(`Not uploaded: tday shows the confirmation code only in a browser window, and none could open (${Q.problem}). Set TDAY_CAPTURE_BROWSER to a command that opens a URL where you can see it, then run this again.`),null;let J=PN({input:process.stdin,output:process.stdout}),Y=await J.question("Upload to tday? Type the confirmation code shown in the review tday opened in your browser (Enter to cancel): ");J.close();let X=O4(Z.key).state;if(X==="cancelled")console.log("Not uploaded: the review's address was opened somewhere other than your window as well, so tday cancelled its code. Run this again.");return X==="loaded"&&Y.trim()===Z.code?"code":null}finally{x$(Z.key)}}async function MG($){let Z=await B1($),Q=await o2($,Z);if(Q.blocking||Q.problems.length)throw Error(`Not uploading: ${Q.summary}`);let J=await MN(Q.summary,{key:$.store.dir,root:$.store.dir,page:"review/index.html",html:Q.html,files:Q.files,code:Q.token,isCurrent:()=>!0});if(!J){console.log("Not uploaded.");return}let Y=await s2($,Q.token,{onProgress:(X)=>console.log(X),consent:J});console.log(`tday: ${Y.status.status}${Y.status.featureUrls?.length?` - ${Y.status.featureUrls.join(" ")}`:""}`)}async function RN($){let Z=await p2($);$.reviewed=Z;let Q=await l2($,Z);if(Q.blocking||Z.problems.length)throw Error(`Not uploading: ${Q.summary}`);console.log(Q.summary);let J=await Y4($,Z.code,{onProgress:(Y)=>console.log(Y)});console.log(`tday: ${G8(J)}`)}async function _N(){let $=!0,Z=(G,W)=>{if(console.log(`${G?"ok ":"FAIL"} ${W}`),!G)$=!1};try{let G=await K0();Z(!0,`browser: ${G.browserType().name()} ${G.version()}`),await G.close()}catch(G){Z(!1,G.message)}let Q=await s4();if(Z(Boolean(Q),Q?`ffmpeg (demo videos): ${Q}`:`ffmpeg (demo videos): not found. ${t4}`),process.platform==="darwin"){let G=await L2();console.log(`${G?"-- ":"ok "} iOS Simulator (iPhone app demos): ${G??"Xcode and AXe found"}`)}let J=$8(),Y=O2(J);console.log(`${Y?"-- ":"ok "} Android emulator (Android app demos): ${Y??`SDK at ${J}`}`);let X=await Q$();if(Z(Boolean(X.token),X.token?`token: ${X.tokenSource==="capture"?"capture token (TDAY_CAPTURE_TOKEN)":"your tday login"}`:`token: none - sign in once with ${V9}, or set TDAY_CAPTURE_TOKEN from a capture prompt`),X.token&&X.tokenSource==="account"&&!$5("feature").length)try{let W=await m$({session:null,ask:null},{config:X}),K=W.me?.brands??[],V=K.find((H)=>H.id===W.brandId);Z(Boolean(W.me),W.me?`tday (${X.apiBaseUrl}): ${V?`brand ${V.name}${V.matchesRepo?` (connected to ${W.repo})`:""}`:`${K.length} brands, none picked for ${W.repo??"this folder"} (tools ask which)`}`:`tday (${X.apiBaseUrl}): ${W.problem}`)}catch(G){Z(!1,`tday (${X.apiBaseUrl}): ${G.message}`)}else if(X.token)try{let G=await new H0(X).context($5("feature"));Z(!0,`tday (${X.apiBaseUrl}): ${G.brand.name}, ${G.features.length} feature(s): ${G.features.map((W)=>W.title).join(", ")}`)}catch(G){Z(!1,`tday (${X.apiBaseUrl}): ${G.message}`)}return $?0:1}async function CN($){let Z=JSON.parse(await DN($,"utf8")),Q={session:null,ask:null,client:"tday-capture-cli"};try{for(let J of Z.calls){if(["capture_upload","capture_review","demo_upload","demo_review"].includes(J.tool))continue;let Y=W4.find((G)=>G.name===J.tool);if(!Y)throw Error(`Unknown tool ${J.tool}`);let X=await Y.run(J.args??{},Q);for(let G of X.content)if(G.type==="text")console.log(`[${J.tool}] ${G.text.split(`
849
- `)[0]}`);if(X.isError)throw Error(`${J.tool} failed`);if(J.tool==="capture_finish"||J.tool==="demo_finish")return}if(Q.session)await MG(Q.session);if(Q.demo)await RN(Q.demo)}finally{for(let J of[Q.session,Q.demo]){if(!J)continue;let Y=await J.finish();for(let X of Y.kept)console.log(`Not deleted (${X.reason}): ${X.path}`);console.log(Y.leftovers.length?`Left behind:
846
+ Done. In a Claude Code session that is already open, type /reload-plugins to load tday (no restart needed). Restart any other AI agent.${j.length?` In Claude Code, type / to see: ${j.join(", ")}`:""}`)}function NG(){return jN(BN(),".tday","config.json")}function LN($){let Z=NG(),Q=UN(Z);if(!KN(Q))VN(Q,{recursive:!0,mode:448});FG(Q,448),HN(Z,JSON.stringify({token:$,apiBaseUrl:U9,webBaseUrl:B9},null,2)+`
847
+ `,{encoding:"utf8",mode:384}),FG(Z,384)}async function qN($){try{return(await fetch(`${U9}/api/billing/info`,{headers:{authorization:`Bearer ${$}`}})).ok}catch{return!1}}function DN(){if(process.env.TDAY_CLIENT_LABEL)return process.env.TDAY_CLIENT_LABEL;if(process.env.TERM_PROGRAM==="Claude Code")return"claude-code";if(process.env.CURSOR_TRACE_ID)return"cursor";return"tday-cli"}function LG($){let Z=process.platform,Q=()=>console.warn("Could not open the browser. Open the printed URL manually to continue.");try{let J;if(Z==="darwin")J=eZ("open",[$],{detached:!0,stdio:"ignore"});else if(Z==="win32")J=eZ("cmd",["/c","start","",$],{detached:!0,stdio:"ignore"});else J=eZ("xdg-open",[$],{detached:!0,stdio:"ignore"});J.once("error",Q),J.unref()}catch{Q()}}var B9,U9,FN=300000;var DG=I(()=>{VG();nZ();X9();jG();B9=(process.env.TDAY_WEB_URL??"https://tday.com").replace(/\/+$/,""),U9=(process.env.TDAY_API_URL??B9).replace(/\/+$/,"").replace(/\/api$/i,"")});var TN={};import{execSync as PN}from"node:child_process";import{readFile as MN}from"node:fs/promises";import{createInterface as RN}from"node:readline/promises";async function _N($,Z){if(process.stdout.write(`${$}
848
+ `),PG("yes")){if(c9())return"ci";console.log("--yes is honored only in CI (CI=true). Type the code instead.")}if(!process.stdin.isTTY||!process.stdout.isTTY)return console.log("Not uploaded: confirming an upload needs a person at a terminal (or --yes in CI)."),null;let Q=await C4(Z);try{if(Q.state==="unopened")return console.log(`Not uploaded: tday shows the confirmation code only in a browser window, and none could open (${Q.problem}). Set TDAY_CAPTURE_BROWSER to a command that opens a URL where you can see it, then run this again.`),null;let J=RN({input:process.stdin,output:process.stdout}),Y=await J.question("Upload to tday? Type the confirmation code shown in the review tday opened in your browser (Enter to cancel): ");J.close();let X=O4(Z.key).state;if(X==="cancelled")console.log("Not uploaded: the review's address was opened somewhere other than your window as well, so tday cancelled its code. Run this again.");return X==="loaded"&&Y.trim()===Z.code?"code":null}finally{x$(Z.key)}}async function MG($){let Z=await B1($),Q=await o2($,Z);if(Q.blocking||Q.problems.length)throw Error(`Not uploading: ${Q.summary}`);let J=await _N(Q.summary,{key:$.store.dir,root:$.store.dir,page:"review/index.html",html:Q.html,files:Q.files,code:Q.token,isCurrent:()=>!0});if(!J){console.log("Not uploaded.");return}let Y=await s2($,Q.token,{onProgress:(X)=>console.log(X),consent:J});console.log(`tday: ${Y.status.status}${Y.status.featureUrls?.length?` - ${Y.status.featureUrls.join(" ")}`:""}`)}async function CN($){let Z=await p2($);$.reviewed=Z;let Q=await l2($,Z);if(Q.blocking||Z.problems.length)throw Error(`Not uploading: ${Q.summary}`);console.log(Q.summary);let J=await Y4($,Z.code,{onProgress:(Y)=>console.log(Y)});console.log(`tday: ${G8(J)}`)}async function ON(){let $=!0,Z=(G,W)=>{if(console.log(`${G?"ok ":"FAIL"} ${W}`),!G)$=!1};try{let G=await K0();Z(!0,`browser: ${G.browserType().name()} ${G.version()}`),await G.close()}catch(G){Z(!1,G.message)}let Q=await s4();if(Z(Boolean(Q),Q?`ffmpeg (demo videos): ${Q}`:`ffmpeg (demo videos): not found. ${t4}`),process.platform==="darwin"){let G=await L2();console.log(`${G?"-- ":"ok "} iOS Simulator (iPhone app demos): ${G??"Xcode and AXe found"}`)}let J=$8(),Y=O2(J);console.log(`${Y?"-- ":"ok "} Android emulator (Android app demos): ${Y??`SDK at ${J}`}`);let X=await Q$();if(Z(Boolean(X.token),X.token?`token: ${X.tokenSource==="capture"?"capture token (TDAY_CAPTURE_TOKEN)":"your tday login"}`:`token: none - sign in once with ${V9}, or set TDAY_CAPTURE_TOKEN from a capture prompt`),X.token&&X.tokenSource==="account"&&!$5("feature").length)try{let W=await m$({session:null,ask:null},{config:X}),K=W.me?.brands??[],V=K.find((H)=>H.id===W.brandId);Z(Boolean(W.me),W.me?`tday (${X.apiBaseUrl}): ${V?`brand ${V.name}${V.matchesRepo?` (connected to ${W.repo})`:""}`:`${K.length} brands, none picked for ${W.repo??"this folder"} (tools ask which)`}`:`tday (${X.apiBaseUrl}): ${W.problem}`)}catch(G){Z(!1,`tday (${X.apiBaseUrl}): ${G.message}`)}else if(X.token)try{let G=await new H0(X).context($5("feature"));Z(!0,`tday (${X.apiBaseUrl}): ${G.brand.name}, ${G.features.length} feature(s): ${G.features.map((W)=>W.title).join(", ")}`)}catch(G){Z(!1,`tday (${X.apiBaseUrl}): ${G.message}`)}return $?0:1}async function AN($){let Z=JSON.parse(await MN($,"utf8")),Q={session:null,ask:null,client:"tday-capture-cli"};try{for(let J of Z.calls){if(["capture_upload","capture_review","demo_upload","demo_review"].includes(J.tool))continue;let Y=W4.find((G)=>G.name===J.tool);if(!Y)throw Error(`Unknown tool ${J.tool}`);let X=await Y.run(J.args??{},Q);for(let G of X.content)if(G.type==="text")console.log(`[${J.tool}] ${G.text.split(`
849
+ `)[0]}`);if(X.isError)throw Error(`${J.tool} failed`);if(J.tool==="capture_finish"||J.tool==="demo_finish")return}if(Q.session)await MG(Q.session);if(Q.demo)await CN(Q.demo)}finally{for(let J of[Q.session,Q.demo]){if(!J)continue;let Y=await J.finish();for(let X of Y.kept)console.log(`Not deleted (${X.reason}): ${X.path}`);console.log(Y.leftovers.length?`Left behind:
850
850
  ${Y.leftovers.join(`
851
- `)}`:"Repo left exactly as it was.")}await o0()}}async function ON(){let $=j9("app");if(!$)throw Error("--app <dev server url> is required");let Z=await b1.start({appUrl:$,featureIds:$5("feature"),client:"tday-capture-cli"});try{let Q=j9("reset"),J=Q?async()=>{console.log(`Resetting the demo data: ${Q}`),qN(Q,{stdio:"inherit"})}:void 0;for(let Y of Z.tday?.features??[]){let X=await r2(Z,Y,{reset:J});if(console.log(`${Y.title}: ${X.screens.length} screen(s), ${X.flows.length} flow(s) recaptured${X.skipped.length?`; skipped ${X.skipped.map((G)=>`${G.key} (${G.reason})`).join(", ")}`:""}`),X.pending.length)console.log(`Not replayed (each changes the app's data; pass --reset "<your seed command>"): ${X.pending.join(", ")}`)}if(Z.assets.length)await MG(Z)}finally{let Q=await Z.finish();for(let J of Q.kept)console.log(`Not deleted (${J.reason}): ${J.path}`);if(Q.leftovers.length)console.log(`Left behind:
851
+ `)}`:"Repo left exactly as it was.")}await o0()}}async function IN(){let $=j9("app");if(!$)throw Error("--app <dev server url> is required");let Z=await b1.start({appUrl:$,featureIds:$5("feature"),client:"tday-capture-cli"});try{let Q=j9("reset"),J=Q?async()=>{console.log(`Resetting the demo data: ${Q}`),PN(Q,{stdio:"inherit"})}:void 0;for(let Y of Z.tday?.features??[]){let X=await r2(Z,Y,{reset:J});if(console.log(`${Y.title}: ${X.screens.length} screen(s), ${X.flows.length} flow(s) recaptured${X.skipped.length?`; skipped ${X.skipped.map((G)=>`${G.key} (${G.reason})`).join(", ")}`:""}`),X.pending.length)console.log(`Not replayed (each changes the app's data; pass --reset "<your seed command>"): ${X.pending.join(", ")}`)}if(Z.assets.length)await MG(Z)}finally{let Q=await Z.finish();for(let J of Q.kept)console.log(`Not deleted (${J.reason}): ${J.path}`);if(Q.leftovers.length)console.log(`Left behind:
852
852
  ${Q.leftovers.join(`
853
- `)}`)}}async function AN(){switch(M0[0]??"help"){case"mcp":if(PG("install"))return await H9(j9("client")),0;return await Q9(),-1;case"install":return await H9(j9("client")),0;case"doctor":return _N();case"run":if(!M0[1])throw Error("usage: tday run <plan.json> [--yes]");return await CN(M0[1]),0;case"recapture":return await ON(),0;case"skill":return console.log(U1),0;case"version":case"--version":return console.log(V$),0;default:return console.log(`tday-capture ${V$}: capture real UI and record narrated demos from your running app for tday.
853
+ `)}`)}}async function yN(){switch(M0[0]??"help"){case"mcp":if(PG("install"))return await H9(j9("client")),0;return await Q9(),-1;case"install":return await H9(j9("client")),0;case"doctor":return ON();case"run":if(!M0[1])throw Error("usage: tday run <plan.json> [--yes]");return await AN(M0[1]),0;case"recapture":return await IN(),0;case"skill":return console.log(U1),0;case"version":case"--version":return console.log(V$),0;default:return console.log(`tday-capture ${V$}: capture real UI and record narrated demos from your running app for tday.
854
854
  Commands: mcp | install [--client claude|cursor|codex] | skill | doctor [--feature id] | run <plan.json> [--yes] | recapture --app <url> [--feature id] [--yes]
855
855
  Environment: TDAY_CAPTURE_TOKEN (from a capture prompt) or TDAY_TOKEN; TDAY_API_URL (default https://tday.com).
856
- Only rendered UI and metadata leave your machine: https://docs.tday.com/capture-privacy`),0}}var M0,PG=($)=>M0.includes(`--${$}`),j9=($)=>{let Z=M0.indexOf(`--${$}`);return Z>=0?M0[Z+1]:void 0},$5=($)=>M0.flatMap((Z,Q)=>Z===`--${$}`&&M0[Q+1]?[M0[Q+1]]:[]);var RG=I(()=>{B0();a0();q$();T0();M1();C0();tZ();AZ();a2();g1();s1();a8();PZ();MZ();RZ();C8();t2();bZ();n4();kZ();M0=process.argv.slice(2);AN().then(async($)=>{if($>=0)await M8(),process.exit($)},async($)=>{console.error(`tday: ${$.message}`),await M8(),process.exit(1)})});F1();L9();N4();var[,,_G,...F9]=process.argv;async function yN(){switch(_G){case"serve":case"mcp":case void 0:{let{runServer:$}=await Promise.resolve().then(() => (ZG(),$G));await $();return}case"install":{if(process.env.TDAY_CAPTURE_TOKEN?.trim()){let{installClients:Z}=await Promise.resolve().then(() => (tZ(),WG)),Q=F9.indexOf("--client");await Z(Q>=0?F9[Q+1]:void 0);return}let{runInstaller:$}=await Promise.resolve().then(() => (DG(),qG));await $(F9);return}case"update":{let{runUpdate:$}=await Promise.resolve().then(() => (dZ(),mX));$();return}case"doctor":case"run":case"recapture":case"skill":await Promise.resolve().then(() => (RG(),IN));return;case"call":await TN(F9);return;case"version":case"-v":case"--version":{console.log(l0());return}case"help":case"-h":case"--help":CG();return;default:console.error(`Unknown command: ${_G}`),CG(),process.exit(1)}}function CG(){console.log(`tday - record narrated product demos with your coding agent
856
+ Only rendered UI and metadata leave your machine: https://docs.tday.com/capture-privacy`),0}}var M0,PG=($)=>M0.includes(`--${$}`),j9=($)=>{let Z=M0.indexOf(`--${$}`);return Z>=0?M0[Z+1]:void 0},$5=($)=>M0.flatMap((Z,Q)=>Z===`--${$}`&&M0[Q+1]?[M0[Q+1]]:[]);var RG=I(()=>{B0();a0();q$();T0();M1();C0();tZ();AZ();a2();g1();s1();a8();PZ();MZ();RZ();C8();t2();bZ();n4();kZ();M0=process.argv.slice(2);yN().then(async($)=>{if($>=0)await M8(),process.exit($)},async($)=>{console.error(`tday: ${$.message}`),await M8(),process.exit(1)})});F1();L9();N4();var[,,_G,...F9]=process.argv;async function kN(){switch(_G){case"serve":case"mcp":case void 0:{let{runServer:$}=await Promise.resolve().then(() => (ZG(),$G));await $();return}case"install":{if(process.env.TDAY_CAPTURE_TOKEN?.trim()){let{installClients:Z}=await Promise.resolve().then(() => (tZ(),WG)),Q=F9.indexOf("--client");await Z(Q>=0?F9[Q+1]:void 0);return}let{runInstaller:$}=await Promise.resolve().then(() => (DG(),qG));await $(F9);return}case"update":{let{runUpdate:$}=await Promise.resolve().then(() => (dZ(),mX));$();return}case"doctor":case"run":case"recapture":case"skill":await Promise.resolve().then(() => (RG(),TN));return;case"call":await zN(F9);return;case"version":case"-v":case"--version":{console.log(l0());return}case"help":case"-h":case"--help":CG();return;default:console.error(`Unknown command: ${_G}`),CG(),process.exit(1)}}function CG(){console.log(`tday - record narrated product demos with your coding agent
857
857
 
858
858
  Usage:
859
859
  tday install Sign in and add tday to Claude Code, Cursor, Gemini CLI, VS Code and Codex
@@ -876,4 +876,4 @@ Install from npm:
876
876
  npx -y @tday-com/mcp install
877
877
 
878
878
  Only rendered UI and metadata leave your machine: https://docs.tday.com/capture-privacy
879
- `)}async function TN($){let[Z,...Q]=$;if(!Z)throw Error("Usage: tday call <toolName> [jsonArgs]");let J=Q.join(" ").trim()||"{}",Y;try{Y=JSON.parse(J)}catch(W){throw Error(`Invalid JSON arguments for ${Z}: ${W.message}`)}if(!Y||typeof Y!=="object"||Array.isArray(Y))throw Error("Tool arguments must be a JSON object.");let X=await B4(),{result:G}=D8(await S5(Z,Y,X));console.log(q8(G))}yN().catch(($)=>{console.error($),process.exit(1)});
879
+ `)}async function zN($){let[Z,...Q]=$;if(!Z)throw Error("Usage: tday call <toolName> [jsonArgs]");let J=Q.join(" ").trim()||"{}",Y;try{Y=JSON.parse(J)}catch(W){throw Error(`Invalid JSON arguments for ${Z}: ${W.message}`)}if(!Y||typeof Y!=="object"||Array.isArray(Y))throw Error("Tool arguments must be a JSON object.");let X=await B4(),{result:G}=D8(await S5(Z,Y,X));console.log(q8(G))}kN().catch(($)=>{console.error($),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tday-com/mcp",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "Record narrated product demos with your coding agent: the tday MCP server and CLI for Claude Code, Cursor, Codex, VS Code and Gemini CLI. Only rendered UI and metadata leave your machine.",
5
5
  "keywords": [
6
6
  "mcp",
@@ -29,13 +29,6 @@
29
29
  "engines": {
30
30
  "node": ">=18.17"
31
31
  },
32
- "scripts": {
33
- "build": "rm -rf dist && bun build src/cli.ts --target node --outdir dist --format esm --minify --external playwright-core --external @modelcontextprotocol/sdk --external zod --external postcss --external parse5 --external pngjs --external @lydell/node-pty --external @xterm/xterm && chmod +x dist/cli.js && bun ../capture/scripts/check-bundle.ts dist/cli.js",
34
- "typecheck": "tsc -p tsconfig.json --noEmit",
35
- "test": "bun test",
36
- "prepublishOnly": "bun run build",
37
- "start": "node dist/cli.js serve"
38
- },
39
32
  "dependencies": {
40
33
  "@lydell/node-pty": "^1.1.0",
41
34
  "@modelcontextprotocol/sdk": "^1.30.0",
@@ -46,12 +39,6 @@
46
39
  "postcss": "^8.5.26",
47
40
  "zod": "^4.6.6"
48
41
  },
49
- "devDependencies": {
50
- "@markup-one/capture": "0.0.1",
51
- "@markup-one/capture-format": "0.0.1",
52
- "@types/node": "^26.1.2",
53
- "typescript": "^5.6.3"
54
- },
55
42
  "publishConfig": {
56
43
  "access": "public"
57
44
  }