@flowe-ai/cli 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- import{a as p,j as f}from"./chunk-P2IV5O3T.js";function a(t,o){return Object.assign(new Error(o),{code:t})}async function h(t){try{let{spawn:o}=await import("child_process"),{platform:i}=await import("process"),[n,...c]=i==="darwin"?["open",t]:i==="win32"?["cmd","/c","start",'""',t]:["xdg-open",t];return o(n,c,{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function _(t){return new Promise(o=>setTimeout(o,t))}async function R(t={}){let o=p(),i=t.fetch??globalThis.fetch,n=t.write??(e=>process.stdout.write(e)),c=t.openBrowser??h,d=t.sleep??_,u=t.now??(()=>Date.now()),g=t.maxWaitSeconds??900,s;try{let e=await i(`${o.backend_url}/api/v1/cli/auth/start`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!e.ok)throw a("START_FAILED",`server returned ${e.status} when requesting device code`);s=await e.json()}catch(e){let r=e;throw r.code?r:a("NETWORK",`could not reach ${o.backend_url}: ${e.message}`)}n(`
1
+ import{a as p,j as f}from"./chunk-EC5WRPZP.js";function a(t,o){return Object.assign(new Error(o),{code:t})}async function h(t){try{let{spawn:o}=await import("child_process"),{platform:i}=await import("process"),[n,...c]=i==="darwin"?["open",t]:i==="win32"?["cmd","/c","start",'""',t]:["xdg-open",t];return o(n,c,{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function _(t){return new Promise(o=>setTimeout(o,t))}async function R(t={}){let o=p(),i=t.fetch??globalThis.fetch,n=t.write??(e=>process.stdout.write(e)),c=t.openBrowser??h,d=t.sleep??_,u=t.now??(()=>Date.now()),g=t.maxWaitSeconds??900,s;try{let e=await i(`${o.backend_url}/api/v1/cli/auth/start`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!e.ok)throw a("START_FAILED",`server returned ${e.status} when requesting device code`);s=await e.json()}catch(e){let r=e;throw r.code?r:a("NETWORK",`could not reach ${o.backend_url}: ${e.message}`)}n(`
2
2
  Enter this code in your browser: ${s.user_code}
3
3
  `),n(` Open: ${s.verification_uri_complete}
4
4
 
5
5
  `),await c(s.verification_uri_complete)||n(` (could not open browser automatically \u2014 copy the URL above)
6
6
 
7
7
  `),n(` Waiting for approval...
8
- `);let w=u()+g*1e3,m=Math.max(1,s.interval)*1e3;for(;await d(m),!(u()>=w);){let e;try{let r=await i(`${o.backend_url}/api/v1/cli/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:s.device_code})});if(r.status===410)throw a("EXPIRED","device code expired \u2014 run `flowe login` again");if(!r.ok)throw a("POLL_FAILED",`server returned ${r.status} when polling`);e=await r.json()}catch(r){let l=r;throw l.code?l:a("NETWORK",`poll failed: ${r.message}`)}if(e.status==="authorized"&&e.token&&e.user_id){await f(e.token);try{let{refreshUserFirstName:r}=await import("./me-LA6RUW2D.js");await r({fetch:i,authToken:e.token})}catch{}return n(`
8
+ `);let w=u()+g*1e3,m=Math.max(1,s.interval)*1e3;for(;await d(m),!(u()>=w);){let e;try{let r=await i(`${o.backend_url}/api/v1/cli/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:s.device_code})});if(r.status===410)throw a("EXPIRED","device code expired \u2014 run `flowe login` again");if(!r.ok)throw a("POLL_FAILED",`server returned ${r.status} when polling`);e=await r.json()}catch(r){let l=r;throw l.code?l:a("NETWORK",`poll failed: ${r.message}`)}if(e.status==="authorized"&&e.token&&e.user_id){await f(e.token);try{let{refreshUserFirstName:r}=await import("./me-SZLS6RWX.js");await r({fetch:i,authToken:e.token})}catch{}return n(`
9
9
  Signed in.
10
10
  `),{token:e.token,user_id:e.user_id}}}throw a("TIMEOUT","timed out waiting for approval")}export{R as runLogin};
@@ -1,4 +1,9 @@
1
- import{b as o,i,j as a}from"./chunk-C6NO4B4N.js";import"./chunk-P2IV5O3T.js";import{Server as c}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as u}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as p,ListToolsRequestSchema as l}from"@modelcontextprotocol/sdk/types.js";var g=["Run a short neural reset (30, 45, 60, or 90 seconds) for the human operator.","Call this when you notice signs the human is fatigued, overwhelmed, or about to wait:","\xB7 after a long debugging loop or a frustrating error cascade","\xB7 before kicking off a task that will take >30s (long test run, long compile, long agent call)","\xB7 when the human expresses frustration, exhaustion, or decision fatigue","\xB7 when a task has spanned multiple hours with no apparent break","The tool returns immediately (non-blocking). Audio plays on the human's machine in the background.","Continue your work after calling this. Do not wait for the reset to finish."].join(`
2
- `),d=["Start a guided NSDR (Non-Sleep Deep Rest) session for the human operator.","The human scans a QR / opens the returned link on their phone to join a voice session.","Defaults to quick_reset (classic yoga nidra) when no session_type is given.","Pass a session_type when the human asks for something specific:","\xB7 logic_lock when stuck debugging or problem-solving","\xB7 deploy_anxiety before high-stakes moments (deploy, incident)","\xB7 context_switch after a draining meeting","\xB7 sprint_prep before deep work / a coding sprint","\xB7 executive_reset after decision fatigue / many meetings","\xB7 presentation_prep before speaking / a big meeting","\xB7 shutdown at end of day / sleep prep","Call this when the human asks for a longer reset, is wrapping up a long work block,","or explicitly requests an NSDR / yoga nidra session.","Returns a join URL immediately. The session does not start until the human joins from mobile."].join(`
3
- `),h=[{name:"flowe_reset",description:g,inputSchema:{type:"object",properties:{duration_seconds:{type:"number",enum:[30,45,60,90],description:"Length of the reset in seconds."},trigger:{type:"string",enum:["claude_thinking","long_compile","agent_call","user_requested"],description:"Why you are firing this reset. Used for analytics only."}},required:["duration_seconds"]}},{name:"flowe_nsdr",description:d,inputSchema:{type:"object",properties:{session_type:{type:"string",enum:[...o],description:"Which NSDR session type to run. Defaults to quick_reset."}},required:[]}}];function m(e){let n=e,t=n?.message||String(e);return{content:[{type:"text",text:`error[${n?.code??"unknown"}]: ${t}`}],isError:!0}}async function f(e,n={}){try{if(e==="flowe_reset"){let t=n.duration_seconds,r=n.trigger??"claude_thinking",s=await i(t,r);return{content:[{type:"text",text:JSON.stringify(s)}]}}if(e==="flowe_nsdr"){let t=n.session_type??"quick_reset",r=await a(t,{suppressQr:!0});return{content:[{type:"text",text:JSON.stringify(r)}]}}return{content:[{type:"text",text:`unknown tool: ${e}`}],isError:!0}}catch(t){return m(t)}}async function y(){let e=new c({name:"flowe",version:"0.1.0"},{capabilities:{tools:{}}});e.setRequestHandler(l,async()=>({tools:h})),e.setRequestHandler(p,async t=>{let{name:r,arguments:s}=t.params;return await f(r,s??{})});let n=new u;await e.connect(n)}var w=import.meta.url===`file://${process.argv[1]}`||process.argv[1]?.endsWith("mcp-server.js")||process.argv[1]?.endsWith("mcp-server.ts");w&&y().catch(e=>{process.stderr.write(`flowe-mcp: ${e instanceof Error?e.message:String(e)}
4
- `),process.exit(1)});export{h as TOOL_DEFINITIONS,f as handleCallTool,y as runMcpServer};
1
+ import{a as N,b,c as x,e as z,j as H,k as L,l as Q,m as O,o as v,s as B,v as K}from"./chunk-ZP43LZEQ.js";import{e as W,f as V,i as G,j as J}from"./chunk-3TLGYA6M.js";import{a as Y,b as X,c as E,d as Z,e as y,f as ee,g as te}from"./chunk-QVIYCUHZ.js";import{a as A,b as P,e as $,f as g,g as h,h as j}from"./chunk-EC5WRPZP.js";import{McpServer as Ne}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as Ae}from"@modelcontextprotocol/sdk/server/stdio.js";import{registerAppResource as le,registerAppTool as _,RESOURCE_MIME_TYPE as de}from"@modelcontextprotocol/ext-apps/server";import{z as i}from"zod/v4";import{existsSync as ne,mkdirSync as be,readFileSync as ke,renameSync as ve,writeFileSync as Re}from"fs";import{join as xe}from"path";var Ee="mcp-session.json",Te=300*1e3,Fe=14400*1e3;function ie(){return xe(O(),Ee)}function T(t){return{version:1,session_started_at:t,last_reset_at:null,last_suggested_at:null,snoozed_until:null,resets_this_session:0}}function F(t=Date.now()){let e=ie();if(!ne(e)){let s=T(t);return w(s),s}try{let s=JSON.parse(ke(e,"utf-8"));if(s.version!==1||typeof s.session_started_at!="number"){let n=T(t);return w(n),n}let o=Math.max(s.session_started_at,s.last_reset_at??0,s.last_suggested_at??0);if(t-o>Fe){let n=T(t);return w(n),n}return{version:1,session_started_at:s.session_started_at,last_reset_at:s.last_reset_at??null,last_suggested_at:s.last_suggested_at??null,snoozed_until:s.snoozed_until??null,resets_this_session:s.resets_this_session??0}}catch{let s=T(t);return w(s),s}}function w(t){let e=O();ne(e)||be(e,{recursive:!0});let s=ie(),o=`${s}.tmp`;Re(o,JSON.stringify(t,null,2),"utf-8"),ve(o,s)}function re(t=Date.now()){let e=F(t);return e.last_suggested_at=t,w(e),e}function C(t=Date.now()){let e=F(t);return e.last_reset_at=t,e.resets_this_session+=1,w(e),e}function ae(t,e=Date.now()){let s=Math.max(1,Math.min(240,Math.round(t))),o=F(e);return o.snoozed_until=e+s*60*1e3,w(o),o}function M(t={}){let e=t.nowMs??Date.now(),s=t.cooldownMs??Te,o=F(e),n=v({now:()=>e}),r=H(),a=Math.max(0,Math.round((e-o.session_started_at)/6e4)),c=o.last_reset_at!==null?Math.max(0,e-o.last_reset_at):null,u=c!==null?Math.round(c/6e4):null,d=c!==null?Math.max(0,s-c):0,k=o.snoozed_until!==null?Math.max(0,o.snoozed_until-e):0,f=null;r?f="opted_out":k>0?f="snoozed":n&&(n.status==="BREAK"||n.status==="LONG_BREAK")?f="focus_break_active":d>0&&(f="cooldown");let R="micro";if(t.authenticated){let S=u??a;S>=120?R="deep":S>=45&&(R="quick")}return{opted_out:r,can_suggest:f===null,blocked_reason:f,session_minutes:a,minutes_since_last_reset:u,cooldown_remaining_seconds:Math.ceil(d/1e3),snooze_remaining_minutes:Math.ceil(k/6e4),resets_this_session:o.resets_this_session,sessions_today:g(new Date(e)),streak_days:h(new Date(e)),total_sessions:j(),active_focus:n,recommended_tier:R}}import{existsSync as Ce,readFileSync as Me}from"fs";import{dirname as Ie,join as ce,resolve as Oe}from"path";import{fileURLToPath as De}from"url";var l="ui://flowe/micro.html",m="ui://flowe/live-session.html",D={ui:{prefersBorder:!1,csp:{connectDomains:[],resourceDomains:[]}}},q={ui:{prefersBorder:!1,permissions:{microphone:{}},csp:{connectDomains:["https://www.flowe.ai","https://flowe.ai","wss://*.livekit.cloud","https://*.livekit.cloud"],resourceDomains:[]}}},ue=new Map;function qe(t,e=import.meta.url){let s=Ie(De(e));for(let o=0;o<4;o++){let n=[ce(s,"ui",t),ce(s,"dist","ui",t)];for(let a of n)if(Ce(a))return a;let r=Oe(s,"..");if(r===s)break;s=r}return null}function Ue(t){return`<!doctype html><html lang="en"><head><meta charset="UTF-8"/><title>${t}</title><style>body{margin:0;padding:16px;font-family:-apple-system,BlinkMacSystemFont,sans-serif;background:#fff4e8;color:#1a1611}@media(prefers-color-scheme:dark){body{background:#15120f;color:#fff5e3}}</style></head><body><p><strong>${t}</strong> \u2014 run <code>pnpm build</code> in flowe-cli to bundle UI resources.</p></body></html>`}function U(t){let e=ue.get(t);if(e)return e;let s=qe(t);if(s){let o=Me(s,"utf-8");return ue.set(t,o),o}return Ue(t==="live-session.html"?"Flowe Live Session":"Flowe")}function _e(){return{authenticated:!1,first_name:null,email:null,is_pro:!1,plan_type:"guest",quick_reset_quota:null}}var me=["Check the human operator\u2019s Flowe state before suggesting a reset.","Returns session duration, time since last reset, cooldown/snooze status,","active focus cycle state, streak, and whether they are signed in to Flowe","(plus remaining free Quick Resets / Flowe Pro status).","Read-only and fast \u2014 call this before calling flowe_suggest_reset during long sessions."].join(`
2
+ `),fe=["Render a calm, non-intrusive inline Flowe reset suggestion card in the host UI","when the human has been working for a long stretch, hit a frustrating debugging loop,","or is about to wait on a long build/agent task.","Unlike flowe_reset, this NEVER plays audio unexpectedly \u2014 it explains why now and lets","the user start a 30\u201390s Micro-Reset, launch a real 5\u201315m Quick Reset, or Snooze 25m."].join(`
3
+ `),ge=["Run an instant offline 30, 45, 60, or 90-second micro-reset for the human operator","and display the live interactive Flowe Reset Runner inline.","Pick a protocol family that matches what you observed:","\xB7 physiological_sigh (30s) when frustrated or stuck on errors","\xB7 quick_palming (30s) / palming (60s) / progressive_palming (90s) for eye fatigue","\xB7 box_breath (45s, 60s) / extended_box (90s) for stress or composure","\xB7 body_scan (60s) / full_sensory (90s) for cognitive overload","\xB7 neck_rotation (45s) / grounded_feet (45s) / eye_rotation (30s) for physical/screen reset","Returns immediately (non-blocking). Prefer flowe_suggest_reset unless the user asked for a reset directly."].join(`
4
+ `),I=["Start a real, authenticated Flowe Quick Reset (5\u201315 min live AI-guided NSDR voice session)","and render the live Flowe Quick Reset player inline (with automatic QR/Web handoff fallback).","If the user is not signed in yet, renders an inline Flowe device sign-in card that automatically","launches the Quick Reset as soon as they approve in their browser.","Session types:","\xB7 quick_reset (Reset, 10m) \u2014 mental refresh between tasks","\xB7 deploy_anxiety (Calm Down, 5m) \u2014 heart racing, high stakes","\xB7 logic_lock (Unstuck, 10m) \u2014 when a problem keeps circling","\xB7 context_switch (Clear, 8m) \u2014 after meetings, before code","\xB7 sprint_prep (Lock In, 10m) \u2014 before deep work","\xB7 executive_reset (Defog, 12m) \u2014 brain fog, decision fatigue","\xB7 presentation_prep (Steady, 8m) \u2014 before speaking / a big meeting","\xB7 shutdown (Wind Down, 15m) \u2014 end of day, sleep transition"].join(`
5
+ `),he=["Start a real, authenticated Flowe Deep Reset (15\u201325 min interactive two-way LiveKit hypnotherapy session)","and render the live Flowe Deep Reset player inline (or seamless Desktop/Web/Phone QR handoff).","If the user is not signed in yet, renders an inline Flowe sign-in card first.","Session types: ht_stress, ht_anxiety, ht_burnout, ht_procrastination, ht_confidence,","ht_people_pleasing, ht_relationships, ht_fears, ht_anger."].join(`
6
+ `),ye=["Show or start a detached Flowe Focus cycle (pomodoro 25/5, dev 50/10, ultradian 90/15)","with optional ambient soundscape and render live Pause/Resume/Skip/End controls inline.","Focus cycles are opt-in: ask or show the Focus Room card rather than starting unprompted."].join(`
7
+ `),we=["Sign in to a Flowe account right inside the AI harness via OAuth device grant","(renders a calm inline card with browser link, short code, and QR code), or check current sign-in status."].join(`
8
+ `),gt=[{name:"flowe_check_state",description:me,inputSchema:{type:"object",properties:{},required:[]}},{name:"flowe_suggest_reset",description:fe,_meta:{ui:{resourceUri:l}},inputSchema:{type:"object",properties:{reason:{type:"string",description:"Short, calm explanation of why a reset helps right now."},signal:{type:"string",enum:["long_session","debugging_loop","eye_strain","stress","overload","pre_wait","wind_down"],description:"Observed context signal."},recommended_duration:{type:"number",enum:[30,45,60,90]},recommended_protocol:{type:"string"}},required:[]}},{name:"flowe_reset",description:ge,_meta:{ui:{resourceUri:l}},inputSchema:{type:"object",properties:{duration_seconds:{type:"number",enum:[30,45,60,90],description:"Length of the micro-reset in seconds."},protocol:{type:"string",description:"Optional protocol family (e.g. physiological_sigh, box_breath, palming, body_scan)."},trigger:{type:"string",enum:["claude_thinking","long_compile","agent_call","user_requested","long_session","harness_suggested"],description:"Why this reset fired (analytics only)."},voice:{type:"string",enum:["ellie","ada","sage"]},audio_mode:{type:"string",enum:["local","silent","chime"]}},required:["duration_seconds"]}},{name:"flowe_quick_reset",description:I,_meta:{ui:{resourceUri:m}},inputSchema:{type:"object",properties:{session_type:{type:"string",enum:[...b],description:"Which Quick Reset to run. Defaults to quick_reset."},voice:{type:"string",enum:["ellie","ada","sage"]},ambient:{type:"string",description:'Optional ambient scene id or "none".'}},required:[]}},{name:"flowe_deep_reset",description:he,_meta:{ui:{resourceUri:m}},inputSchema:{type:"object",properties:{session_type:{type:"string",enum:[...x],description:"Which Deep Reset to run. Defaults to ht_stress."},voice:{type:"string",enum:["ellie","ada","sage"]},ambient:{type:"string"}},required:[]}},{name:"flowe_nsdr",description:I,_meta:{ui:{resourceUri:m}},inputSchema:{type:"object",properties:{session_type:{type:"string",enum:[...b],description:"Which Quick Reset (NSDR) session type to run. Defaults to quick_reset."}},required:[]}},{name:"flowe_focus",description:ye,_meta:{ui:{resourceUri:l}},inputSchema:{type:"object",properties:{action:{type:"string",enum:["show","start"]},preset:{type:"string",enum:["pomodoro","dev","ultradian"]},ambient:{type:"string"}},required:[]}},{name:"flowe_auth",description:we,_meta:{ui:{resourceUri:l}},inputSchema:{type:"object",properties:{},required:[]}}];function Pe(t){let e=t,s=e?.message||String(t),o=e?.code??"unknown";return{content:[{type:"text",text:`error[${o}]: ${s}`}],structuredContent:{error:!0,code:o,message:s},isError:!0}}function $e(t){switch(t){case"debugging_loop":return{eyebrow:"DEBUGGING LOOP",headline:"Break the loop for 30 seconds",protocol:"physiological_sigh",duration:30,quickType:"logic_lock"};case"eye_strain":return{eyebrow:"SCREEN FATIGUE",headline:"Give your eyes a minute of dark rest",protocol:"palming",duration:60,quickType:"context_switch"};case"stress":return{eyebrow:"HIGH STAKES",headline:"Steady your breath before you ship",protocol:"box_breath",duration:60,quickType:"deploy_anxiety"};case"overload":return{eyebrow:"COGNITIVE LOAD",headline:"Clear working memory before picking a path",protocol:"body_scan",duration:60,quickType:"executive_reset"};case"wind_down":return{eyebrow:"END OF BLOCK",headline:"Step down smoothly from deep work",protocol:"progressive_palming",duration:90,quickType:"shutdown"};default:return{eyebrow:"LONG SESSION",headline:"Take a short breath while your agent works",protocol:"physiological_sigh",duration:30,quickType:"quick_reset"}}}async function pe(t,e){let s=t==="deep"?e.session_type??"ht_stress":e.session_type??"quick_reset",o=e.voice,n=e.ambient??"none",r=await y().catch(()=>({authenticated:!1,is_pro:!1,plan_type:"guest",quick_reset_quota:null}));if(!r.authenticated){let a=await E(),c={view:"auth",auth:a,pending_tier:t,pending_session_type:s,voice:o,ambient:n,account:r,message:`Sign in to Flowe to start this ${t==="deep"?"Deep Reset":"Quick Reset"}: ${a.verification_uri_complete} (code: ${a.user_code})`};return{content:[{type:"text",text:c.message}],structuredContent:c}}try{let a=await ee({tier:t,sessionType:s,voice:o,ambient:n}),c={view:"live_session",...a,account:r};return{content:[{type:"text",text:JSON.stringify(a)}],structuredContent:c}}catch(a){let c=a;if(c.code==="auth_required"){let u=await E(),d={view:"auth",auth:u,pending_tier:t,pending_session_type:s,voice:o,ambient:n,account:{authenticated:!1,is_pro:!1,plan_type:"guest"},message:`Your Flowe sign-in expired. Approve here to continue: ${u.verification_uri_complete} (code: ${u.user_code})`};return{content:[{type:"text",text:d.message}],structuredContent:d}}if(c.code==="quota_exceeded"||c.code==="subscription_required"){let u={view:"quota",code:c.code,message:c.message??"Flowe Pro unlocks unlimited live Quick and Deep Resets.",account:r};return{content:[{type:"text",text:u.message}],structuredContent:u}}throw a}}async function p(t,e={}){try{if(t==="flowe_check_state"){let s=await y().catch(()=>({authenticated:!1,is_pro:!1,plan_type:"guest",quick_reset_quota:null})),n={...M({authenticated:s.authenticated}),account:s,voice:A().voice,available_micro_protocols:z(),available_quick_resets:Y.map(r=>({id:r.id,name:r.name,minutes:r.duration_minutes})),available_deep_resets:X.map(r=>({id:r.id,name:r.name,minutes:r.duration_minutes}))};return{content:[{type:"text",text:JSON.stringify(n)}],structuredContent:n}}if(t==="flowe_suggest_reset"){let s=await y().catch(()=>({authenticated:!1,is_pro:!1,plan_type:"guest",quick_reset_quota:null})),o=M({authenticated:s.authenticated});if(!o.can_suggest){let d=o.blocked_reason==="snoozed"?`Flowe suggestions are snoozed for ${o.snooze_remaining_minutes}m.`:o.blocked_reason==="cooldown"?`Flowe reset cooldown active (${o.cooldown_remaining_seconds}s remaining).`:o.blocked_reason==="focus_break_active"?"A Flowe focus break is already active.":"Flowe resets are opted out via FLOWE_OPT_OUT.";return{content:[{type:"text",text:d}],structuredContent:{view:"snoozed",snooze_minutes:o.snooze_remaining_minutes||5,blocked_reason:o.blocked_reason,account:s,message:d}}}re();let n=$e(e.signal),r=e.recommended_duration??n.duration,a=e.recommended_protocol??n.protocol,c=e.reason??`You\u2019ve been working for ${Math.max(1,o.session_minutes)} minutes. A short reset clears visual and nervous-system load without losing context.`,u={view:"suggest",eyebrow:o.session_minutes>=20?`${n.eyebrow} \xB7 ${o.session_minutes} MIN`:n.eyebrow,headline:n.headline,reason:c,recommended_tier:o.recommended_tier,recommended_duration:r,recommended_protocol:a,recommended_quick_type:n.quickType,session_minutes:o.session_minutes,sessions_today:o.sessions_today,streak_days:o.streak_days,account:s};return{content:[{type:"text",text:`${n.headline} \u2014 ${c} (Suggested: ${r}s ${a}${s.authenticated?` or Quick Reset: ${n.quickType}`:""})`}],structuredContent:u}}if(t==="flowe_reset"){let s=e.duration_seconds??60,o=e.trigger??"claude_thinking",n=e.protocol,r=e.voice,a=e.audio_mode,u=await Q(s,o,n,{audioMode:a==="silent"||a==="chime"?"silent":"local",voice:r,recordOnComplete:!0});C();let d={view:"micro_reset",...u,audio_mode:a??"local",sessions_today:g(),streak_days:h()};return{content:[{type:"text",text:JSON.stringify(u)}],structuredContent:d}}if(t==="flowe_quick_reset"||t==="flowe_nsdr")return await pe("quick",e);if(t==="flowe_deep_reset")return await pe("deep",e);if(t==="flowe_focus"){let s=e.action??"show",o=await y().catch(()=>({authenticated:!1,is_pro:!1,plan_type:"guest",quick_reset_quota:null}));if(s==="start"){let c=e.preset??"pomodoro",u=e.ambient??"rain_window_soft",d,k;if(u!=="none")try{let f=await G().catch(()=>null),S=V(f,W())?.sounds.find(Se=>Se.id===u);S&&(d=await J(S),k=S.id)}catch{}K({preset:c,ambientFilePath:d,ambientId:k})}let n=v(),r={view:"focus",focus:n,account:o};return{content:[{type:"text",text:n?`Flowe Focus active: ${n.preset} (${n.status}, block ${n.blockIndex}/${n.blocks}, ${Math.ceil(n.remainingSec/60)}m left${n.paused?", paused":""}).`:"No active Flowe Focus cycle. Pick Pomodoro (25/5), Dev (50/10), or Ultradian (90/15) to start."}],structuredContent:r}}if(t==="flowe_auth"){let s=await y().catch(_e);if(s.authenticated){let r={view:"complete",account:s,sessions_today:g(),streak_days:h(),message:`Signed in to Flowe${s.first_name?` as ${s.first_name}`:""} (${s.is_pro?"Flowe Pro":s.plan_type}).`};return{content:[{type:"text",text:r.message}],structuredContent:r}}let o=await E(),n={view:"auth",auth:o,account:s,message:`Sign in to Flowe at ${o.verification_uri_complete} (code: ${o.user_code})`};return{content:[{type:"text",text:n.message}],structuredContent:n}}if(t==="flowe_auth_poll"){let s=String(e.device_code??""),o=await Z(s),n={...o};return{content:[{type:"text",text:JSON.stringify(o)}],structuredContent:n}}if(t==="flowe_reset_control"){let s=String(e.action??"");if(s==="stop"){let o=L();return{content:[{type:"text",text:o?"Reset stopped.":"No active reset."}],structuredContent:{stopped:o}}}if(s==="complete"){$(),C();let o={sessions_today:g(),streak_days:h()};return{content:[{type:"text",text:JSON.stringify(o)}],structuredContent:o}}if(s==="snooze"){let o=Number(e.snooze_minutes??25),r={snoozed_until:ae(o).snoozed_until,snooze_minutes:o};return{content:[{type:"text",text:`Snoozed for ${o} minutes.`}],structuredContent:r}}if(s==="set_voice"){let o=e.voice;return(o==="ellie"||o==="ada"||o==="sage")&&P(o),{content:[{type:"text",text:`Voice set to ${o}.`}],structuredContent:{voice:o}}}return{content:[{type:"text",text:`unknown reset control action: ${s}`}],isError:!0}}if(t==="flowe_session_complete"){let s=String(e.session_id??""),o=typeof e.duration_minutes=="number"?e.duration_minutes:void 0,n=await te(s,{durationMinutes:o});C();let r={...n,sessions_today:g(),streak_days:h()};return{content:[{type:"text",text:JSON.stringify(r)}],structuredContent:r}}if(t==="flowe_focus_control"){let s=String(e.action??"status");(s==="pause"||s==="resume"||s==="skip"||s==="quit")&&B(s);let n={view:"focus",focus:v()};return{content:[{type:"text",text:JSON.stringify(n)}],structuredContent:n}}return{content:[{type:"text",text:`unknown tool: ${t}`}],isError:!0}}catch(s){return Pe(s)}}function je(){let t=new Ne({name:"flowe",version:N()});return le(t,"Flowe Reset & Focus Card",l,{_meta:D},async()=>({contents:[{uri:l,mimeType:de,text:U("micro.html"),_meta:D}]})),le(t,"Flowe Live Quick & Deep Reset Player",m,{_meta:q},async()=>({contents:[{uri:m,mimeType:de,text:U("live-session.html"),_meta:q}]})),t.registerResource("Flowe Session State","flowe://session/state",{description:"Current local Flowe session cadence, cooldown, focus daemon, and account summary.",mimeType:"application/json"},async()=>{let e=await y().catch(_e),s=M({authenticated:e.authenticated});return{contents:[{uri:"flowe://session/state",mimeType:"application/json",text:JSON.stringify({...s,account:e},null,2)}]}}),t.registerTool("flowe_check_state",{title:"Check Flowe Reset State",description:me,annotations:{readOnlyHint:!0,idempotentHint:!0,openWorldHint:!1}},async()=>p("flowe_check_state",{})),_(t,"flowe_suggest_reset",{title:"Suggest a Flowe Reset",description:fe,inputSchema:i.object({reason:i.string().optional().describe("Calm 1-sentence reason why a reset fits right now."),signal:i.enum(["long_session","debugging_loop","eye_strain","stress","overload","pre_wait","wind_down"]).optional(),recommended_duration:i.union([i.literal(30),i.literal(45),i.literal(60),i.literal(90)]).optional(),recommended_protocol:i.string().optional()}),annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!1},_meta:{ui:{resourceUri:l,visibility:["model","app"]}}},async e=>p("flowe_suggest_reset",e)),_(t,"flowe_reset",{title:"Run Micro-Reset (30\u201390s)",description:ge,inputSchema:i.object({duration_seconds:i.union([i.literal(30),i.literal(45),i.literal(60),i.literal(90)]),protocol:i.string().optional().describe("Protocol family (e.g. physiological_sigh, box_breath, palming, body_scan)."),trigger:i.enum(["claude_thinking","long_compile","agent_call","user_requested","long_session","harness_suggested"]).optional(),voice:i.enum(["ellie","ada","sage"]).optional(),audio_mode:i.enum(["local","silent","chime"]).optional()}),annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!1},_meta:{ui:{resourceUri:l,visibility:["model","app"]}}},async e=>p("flowe_reset",e)),_(t,"flowe_quick_reset",{title:"Start Live Flowe Quick Reset (5\u201315m)",description:I,inputSchema:i.object({session_type:i.enum(b).optional(),voice:i.enum(["ellie","ada","sage"]).optional(),ambient:i.string().optional()}),annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!0},_meta:{ui:{resourceUri:m,visibility:["model","app"]}}},async e=>p("flowe_quick_reset",e)),_(t,"flowe_deep_reset",{title:"Start Live Flowe Deep Reset (15\u201325m)",description:he,inputSchema:i.object({session_type:i.enum(x).optional(),voice:i.enum(["ellie","ada","sage"]).optional(),ambient:i.string().optional()}),annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!0},_meta:{ui:{resourceUri:m,visibility:["model","app"]}}},async e=>p("flowe_deep_reset",e)),_(t,"flowe_nsdr",{title:"Start Guided NSDR Quick Reset",description:I,inputSchema:i.object({session_type:i.enum(b).optional()}),annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!0},_meta:{ui:{resourceUri:m,visibility:["model","app"]}}},async e=>p("flowe_nsdr",e)),_(t,"flowe_focus",{title:"Flowe Focus Room",description:ye,inputSchema:i.object({action:i.enum(["show","start"]).optional(),preset:i.enum(["pomodoro","dev","ultradian"]).optional(),ambient:i.string().optional()}),annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!1},_meta:{ui:{resourceUri:l,visibility:["model","app"]}}},async e=>p("flowe_focus",e)),_(t,"flowe_auth",{title:"Sign in to Flowe",description:we,annotations:{readOnlyHint:!1,destructiveHint:!1,openWorldHint:!0},_meta:{ui:{resourceUri:l,visibility:["model","app"]}}},async()=>p("flowe_auth",{})),_(t,"flowe_auth_poll",{description:"Poll device-grant authentication status from the Flowe sign-in card.",inputSchema:i.object({device_code:i.string().min(8)}),_meta:{ui:{resourceUri:l,visibility:["app"]}}},async e=>p("flowe_auth_poll",e)),_(t,"flowe_reset_control",{description:"Stop, complete, snooze, or adjust voice for a Flowe micro-reset.",inputSchema:i.object({action:i.enum(["stop","complete","snooze","set_voice"]),session_id:i.string().optional(),snooze_minutes:i.number().optional(),voice:i.enum(["ellie","ada","sage"]).optional()}),_meta:{ui:{resourceUri:l,visibility:["app"]}}},async e=>p("flowe_reset_control",e)),_(t,"flowe_session_complete",{description:"Complete an active live Flowe Quick or Deep Reset session.",inputSchema:i.object({session_id:i.string().min(1),duration_minutes:i.number().optional()}),_meta:{ui:{resourceUri:m,visibility:["app"]}}},async e=>p("flowe_session_complete",e)),_(t,"flowe_focus_control",{description:"Inspect or control the detached Flowe focus daemon.",inputSchema:i.object({action:i.enum(["status","pause","resume","skip","quit"])}),_meta:{ui:{resourceUri:l,visibility:["app"]}}},async e=>p("flowe_focus_control",e)),t.registerPrompt("flowe_checkin",{title:"Flowe Reset Check-in",description:"Check session fatigue and suggest the right Flowe reset."},async()=>({messages:[{role:"user",content:{type:"text",text:"Call flowe_check_state and, if appropriate, call flowe_suggest_reset with a calm one-sentence reason matching what we have been working on."}}]})),t.registerPrompt("flowe_quick_reset",{title:"Flowe Quick Reset",description:"Start a live 5\u201315 minute Flowe Quick Reset session.",argsSchema:{type:i.enum(b).optional().describe("Quick Reset type (default: quick_reset)")}},async({type:e})=>({messages:[{role:"user",content:{type:"text",text:`Start a Flowe Quick Reset using flowe_quick_reset${e?` with session_type="${e}"`:""}.`}}]})),t.registerPrompt("flowe_deep_reset",{title:"Flowe Deep Reset",description:"Start an interactive 15\u201325 minute Flowe Deep Reset session.",argsSchema:{type:i.enum(x).optional().describe("Deep Reset type (default: ht_stress)")}},async({type:e})=>({messages:[{role:"user",content:{type:"text",text:`Start a Flowe Deep Reset using flowe_deep_reset${e?` with session_type="${e}"`:""}.`}}]})),t}async function ze(){let t=je(),e=new Ae;await t.connect(e)}var He=import.meta.url===`file://${process.argv[1]}`||process.argv[1]?.endsWith("mcp-server.js")||process.argv[1]?.endsWith("mcp-server.ts");He&&ze().catch(t=>{process.stderr.write(`flowe-mcp: ${t instanceof Error?t.message:String(t)}
9
+ `),process.exit(1)});export{gt as TOOL_DEFINITIONS,je as createFloweMcpServer,p as handleCallTool,ze as runMcpServer};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-3HG2U5YK.js";import"./chunk-EC5WRPZP.js";export{a as fetchMe,b as refreshUserFirstName};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h}from"./chunk-QVIYCUHZ.js";import"./chunk-EC5WRPZP.js";export{b as DEEP_RESET_CATALOG,a as QUICK_RESET_CATALOG,h as cancelLiveSession,g as completeLiveSession,f as createAndStartLiveSession,e as fetchAccountStatus,d as pollDeviceAuth,c as startDeviceAuth};
@@ -0,0 +1,9 @@
1
+ import{existsSync as d,mkdirSync as l,readFileSync as f,writeFileSync as u}from"fs";import{homedir as g,platform as m}from"os";import{dirname as v,join as n}from"path";var P=["claude-desktop","claude-code","antigravity","codex","cursor","vscode"];function b(e=g(),r=process.cwd(),s=m()){return{"claude-desktop":{id:"claude-desktop",label:"Claude Desktop",configPath:s==="darwin"?n(e,"Library","Application Support","Claude","claude_desktop_config.json"):s==="win32"?n(e,"AppData","Roaming","Claude","claude_desktop_config.json"):n(e,".config","Claude","claude_desktop_config.json"),format:"json-mcpServers",supportsMcpApps:!0},"claude-code":{id:"claude-code",label:"Claude Code",configPath:n(e,".claude.json"),format:"json-mcpServers",supportsMcpApps:!1},antigravity:{id:"antigravity",label:"Antigravity",configPath:n(e,".gemini","antigravity","mcp_config.json"),format:"json-mcpServers",supportsMcpApps:!0},codex:{id:"codex",label:"Codex",configPath:n(e,".codex","config.toml"),format:"toml-codex",supportsMcpApps:!1},cursor:{id:"cursor",label:"Cursor",configPath:n(e,".cursor","mcp.json"),format:"json-mcpServers",supportsMcpApps:!0},vscode:{id:"vscode",label:"VS Code (Copilot)",configPath:n(r,".vscode","mcp.json"),format:"json-servers",supportsMcpApps:!0}}}function S(e,r="flowe",s=["mcp"]){if(e.format==="toml-codex"){let t=s.map(o=>`"${o}"`).join(", ");return`[mcp_servers.flowe]
2
+ command = "${r}"
3
+ args = [${t}]
4
+ `}return e.format==="json-servers"?JSON.stringify({servers:{flowe:{type:"stdio",command:r,args:s}}},null,2):JSON.stringify({mcpServers:{flowe:{command:r,args:s}}},null,2)}function k(e,r={}){let s=r.command??"flowe",t=r.args??["mcp"],o=d(e.configPath)?f(e.configPath,"utf-8"):"",i;if(e.format==="toml-codex")if(/^\s*\[mcp_servers\.flowe\]/m.test(o))i=o;else{let c=o.length>0&&!o.endsWith(`
5
+ `)?`
6
+
7
+ `:o.length>0?`
8
+ `:"";i=`${o}${c}${S(e,s,t)}`}else{let c={};o.trim().length>0&&(c=JSON.parse(o));let a=e.format==="json-servers"?"servers":"mcpServers",p=c[a]??{};c[a]={...p,flowe:e.format==="json-servers"?{type:"stdio",command:s,args:t}:{command:s,args:t}},i=`${JSON.stringify(c,null,2)}
9
+ `}return r.dryRun||(l(v(e.configPath),{recursive:!0}),u(e.configPath,i,"utf-8")),{written:!r.dryRun,path:e.configPath,content:i}}export{P as HARNESS_IDS,k as applyHarnessConfig,S as buildHarnessSnippet,b as resolveHarnessTargets};