@flowe-ai/cli 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/{chunk-GUTZZ5P5.js → chunk-3KM7AYV7.js} +1 -1
- package/dist/chunk-DX2IZG3L.js +1 -0
- package/dist/{chunk-MM4EMTNC.js → chunk-JTAA4OAX.js} +1 -1
- package/dist/{chunk-3HG2U5YK.js → chunk-M56P7SDZ.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/{login-Q4QMATEN.js → login-IDFOVWCU.js} +2 -2
- package/dist/mcp-server.js +1 -1
- package/dist/me-6WIWKE2Q.js +1 -0
- package/dist/{session-client-2SS65HUQ.js → session-client-XHJ2MGA5.js} +1 -1
- package/dist/{setup-harness-RR77VO5C.js → setup-harness-DWVJK4N5.js} +1 -1
- package/dist/ui/live-session.html +1 -1
- package/dist/ui/micro.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-EC5WRPZP.js +0 -1
- package/dist/me-SZLS6RWX.js +0 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Science-backed resets in your terminal and AI chat: 30–90 s micro-resets, live Quick and Deep Resets with Ada, and an MCP App for your AI tools.
|
|
4
4
|
|
|
5
|
-
`flowe` runs 30–90 s micro-resets in your terminal with no account, live Quick and Deep Resets with Ada when you sign in, and **MCP App cards (SEP-1865)** inside Claude Desktop, Antigravity, Cursor and VS Code, with plain text in
|
|
5
|
+
`flowe` runs 30–90 s micro-resets in your terminal with no account, live Quick and Deep Resets with Ada when you sign in, and **MCP App cards (SEP-1865)** inside the Codex app, Claude Desktop, Antigravity, Cursor and VS Code, with plain text in Claude Code and Codex in a terminal.
|
|
6
6
|
|
|
7
7
|
Docs and a live demo: **[cli.flowe.ai](https://cli.flowe.ai)**
|
|
8
8
|
|
|
@@ -41,9 +41,9 @@ Supporting MCP Apps hosts mount Flowe's self-contained **Dusk + Peek** UI cards
|
|
|
41
41
|
|
|
42
42
|
| Tier | Duration | Auth | Command |
|
|
43
43
|
|---|---|---|---|
|
|
44
|
-
| **Micro-Resets** | 30–90s | Free
|
|
45
|
-
| **Quick Resets** | 5–15 min |
|
|
46
|
-
| **Deep Resets** | 30–50 min | Flowe Pro or
|
|
44
|
+
| **Micro-Resets** | 30–90s | Free, no account needed | `flowe reset 60 --protocol box_breath` |
|
|
45
|
+
| **Quick Resets** | 5–15 min | 5 free a week with an account | `flowe quick logic_lock --ambient rain_window_soft` |
|
|
46
|
+
| **Deep Resets** | 30–50 min | Flowe Pro or a team plan | `flowe deep ht_burnout --open` |
|
|
47
47
|
|
|
48
48
|
### Micro-Resets
|
|
49
49
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as W,c as Q,e as Y,i as G}from"./chunk-
|
|
1
|
+
import{a as W,c as Q,e as Y,i as G}from"./chunk-DX2IZG3L.js";import{readFileSync as ge}from"fs";import{dirname as ye,join as he}from"path";import{fileURLToPath as be}from"url";var xe=ye(be(import.meta.url));function H(){try{let e=ge(he(xe,"..","package.json"),"utf-8");return JSON.parse(e).version}catch{return"0.0.0"}}var at=["logic_lock","deploy_anxiety","context_switch","sprint_prep","quick_reset","executive_reset","presentation_prep","shutdown"],ct=["ht_stress","ht_anxiety","ht_people_pleasing","ht_relationships","ht_confidence","ht_fears","ht_anger","ht_procrastination","ht_burnout"];import{readFileSync as K}from"fs";import{dirname as Se,join as N}from"path";import{fileURLToPath as ve}from"url";var A=Se(ve(import.meta.url));function Ee(){return N(A,"..","protocols.json")}var g=null;function k(){if(g)return g;try{let e=K(Ee(),"utf-8");return g=JSON.parse(e),g}catch{return g={protocols:{},audio_paths:{},cues_paths:{}},g}}function D(){return Object.values(k().protocols)}function M(e){return e.replace(/_\d+$/,"")}function ft(){let e=new Set;for(let t of D())e.add(M(t.protocol_id));return[...e].sort()}function _t(e){return D().filter(t=>M(t.protocol_id)===e).map(t=>t.duration_seconds).sort((t,r)=>t-r)}function z(e,t){let r=D().filter(n=>n.duration_seconds===e&&(t===void 0||M(n.protocol_id)===t));return r.length===0?null:t!==void 0?r[0]:r[Math.floor(Math.random()*r.length)]}function X(e,t){let r=k(),n=`${e}.${t}`,o=r.audio_paths[n];return o?N(A,"..",o):null}var C=new Map;function Z(e,t){let r=`${e}.${t}`,n=C.get(r);if(n!==void 0)return n;let a=k().cues_paths?.[r];if(!a)return C.set(r,null),null;try{let s=K(N(A,"..",a),"utf-8"),i=JSON.parse(s);return C.set(r,i),i}catch{return C.set(r,null),null}}import{spawn as R}from"child_process";import{platform as Pe}from"os";var d=null;function ee(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?1:Math.min(2,Math.max(.05,e))}function we(e,t=1){let r=ee(t),n=Pe();if(n==="darwin"){let a=r===1?[e]:["-v",String(r),e];return R("afplay",a,{stdio:"ignore"})}if(n==="win32"){let s=["Add-Type -AssemblyName presentationCore;","$p = New-Object System.Windows.Media.MediaPlayer;",`$p.Open([Uri]'${e.replace(/'/g,"''")}');`,`$p.Volume = ${Math.min(1,r)};`,"$p.Play();","Start-Sleep -Milliseconds 300;","while ($p.Position -lt $p.NaturalDuration.TimeSpan -and $p.NaturalDuration.HasTimeSpan) { Start-Sleep -Milliseconds 200 };","$p.Close();"].join(" ");return R("powershell",["-NoProfile","-NonInteractive","-Command",s],{stdio:"ignore"})}let o=Math.round(32768*r);return R("mpg123",["-q","-f",String(o),e],{stdio:"ignore"})}function I(){return d!==null}function xt(){return d?.donePromise??null}function te(e,t={}){if(d)return Promise.reject(new Error("already playing \u2014 call stopAudio first"));let r=ee(t.volume),n=t.spawnPlayer??we,o;try{o=n(e,r)}catch(c){return Promise.reject(c instanceof Error?c:new Error(String(c)))}let a=!1,s=!1,i,u,p=new Promise((c,l)=>{i=c,u=l}),f=()=>{d?.child===o&&(d=null)},_=()=>{a||(a=!0,f(),i())},T=c=>{a||(a=!0,f(),u(c))};return d={child:o,stop:()=>{if(s=!0,f(),!o.killed)try{o.kill("SIGTERM")}catch{}_()},donePromise:p},o.once("error",c=>{if(s){_();return}let l=Object.assign(new Error(`audio playback failed: ${c.message}`),{code:"audio_device"});T(l)}),o.once("exit",(c,l)=>{if(s||l==="SIGTERM"||l==="SIGINT"||c===0||c===null){_();return}let O=Object.assign(new Error(`audio player exited with code ${c}`),{code:"audio_device"});T(O)}),p}function re(){d&&d.stop()}import{nanoid as $e}from"nanoid";import{readFileSync as Te,writeFileSync as Ce,mkdirSync as Fe,existsSync as L,appendFileSync as Oe}from"fs";import{homedir as Ne}from"os";import{join as oe}from"path";var $=oe(Ne(),".cache","flowe"),v=oe($,"pending-events.jsonl"),Ae=5e3;function ke(){let e=process.env.FLOWE_OPT_OUT?.trim().toLowerCase();return e==="1"||e==="true"||e==="yes"}async function F(e,t,r){if(!(t.telemetry==="off"||ke())){try{De(),Me(e)}catch{return}try{await Ie(t,r)}catch{}}}function De(){L($)||Fe($,{recursive:!0})}function Me(e){for(let t of e)Oe(v,JSON.stringify(t)+`
|
|
2
2
|
`,"utf-8")}function Re(){return L(v)?Te(v,"utf-8").split(`
|
|
3
3
|
`).filter(t=>t.trim().length>0).map(t=>JSON.parse(t)):[]}function ne(){L(v)&&Ce(v,"","utf-8")}async function Ie(e,t){let r=Re();if(r.length===0)return;let n={version:H(),platform:`${process.platform}-${process.arch}`,node_version:process.version},o=new AbortController,a=setTimeout(()=>o.abort(),Ae);try{let s={"Content-Type":"application/json"};t&&(s.Authorization=`Bearer ${t}`);let i=await fetch(`${e.backend_url}/api/v1/reset/log`,{method:"POST",headers:s,body:JSON.stringify({events:r,client:n,anonymous_id:e.anonymous_id}),signal:o.signal});(i.ok||i.status===401||i.status===400)&&ne()}finally{clearTimeout(a)}}function Le(e,t,r){if(e.length===0)return[];let o=t*1e3/e.length;return e.map((a,s)=>({label:a,mode:r,start_ms:Math.round(s*o),end_ms:Math.round((s+1)*o)}))}function Rt(){return I()?(re(),!0):!1}async function It(e,t="user_requested",r,n={}){let o=process.env.FLOWE_SILENT_AUDIO==="1"?"silent":n.audioMode??"local";if(o==="local"&&I())throw Object.assign(new Error("a reset is already running"),{code:"agent_busy"});let a=W(),s=n.voice??a.voice,i=z(e,r);if(!i){let _e=r?`${r} at ${e}s`:`${e}s`;throw Object.assign(new Error(`no protocol available for ${_e}`),{code:"protocol_unavailable"})}let u=X(i.protocol_id,s);if(o==="local"&&!u)throw Object.assign(new Error(`no audio available for ${i.protocol_id}:${s}`),{code:"protocol_unavailable"});let p=`reset_${$e(8)}`,f=new Date,_=Math.floor(f.getTime()/1e3),T=_+e;Q();let c=await G();await F([{type:"reset_started",session_id:p,protocol_id:i.protocol_id,duration_seconds:e,voice:s,trigger:t,client_timestamp:f.toISOString()}],a,c),o==="local"&&u&&te(u).then(()=>{if(n.recordOnComplete)try{Y()}catch{}F([{type:"reset_completed",session_id:p,protocol_id:i.protocol_id,duration_seconds:e,voice:s,trigger:t,client_timestamp:new Date().toISOString()}],a,c).catch(()=>{})}).catch(()=>{F([{type:"reset_abandoned",session_id:p,protocol_id:i.protocol_id,duration_seconds:e,voice:s,trigger:t,client_timestamp:new Date().toISOString()}],a,c).catch(()=>{})});let l=Z(i.protocol_id,s),O=l?l.cues:Le(i.text_cues,e,i.category);return{session_id:p,protocol:i.protocol_id,protocol_display_name:i.display_name,duration_seconds:e,voice:s,category:i.category,audio_mode:o,cues:O,rounds:i.rounds,status:"started",started_at_unix:_,ends_at_unix:T,message_for_user:`${e}s ${i.display_name} started \xB7 ${s}`}}import{existsSync as y,mkdirSync as Ve,readFileSync as V,renameSync as se,rmSync as j,writeFileSync as q}from"fs";import{homedir as je}from"os";import{join as h}from"path";var qe="state.json",Be="daemon.pid",Ue="control.txt",Je="daemon.log",We=3e4,Qe=["pause","resume","skip","quit"];function Ye(){return process.env.FLOWE_HOME??h(je(),".flowe")}function b(){return h(Ye(),"sessions","active")}function ae(){return h(b(),qe)}function B(){return h(b(),Be)}function ce(){return h(b(),Ue)}function ue(){return h(b(),Je)}function E(){let e=b();return y(e)||Ve(e,{recursive:!0}),e}function Bt(e){E();let t=ae(),r=`${t}.tmp`;q(r,JSON.stringify(e,null,2),"utf-8"),se(r,t)}function Ut(e={}){let t=ae();if(!y(t))return null;try{let r=V(t,"utf-8"),n=JSON.parse(r);if(n.version!==1)return null;let o=n;if(!Ge(o)||x()!==o.pid)return null;if(!w(o.pid,e.kill))return P(),null;let s=e.now??Date.now,i=e.staleAfterMs??We;return s()-o.updatedAt>i?null:o}catch{return null}}function Ge(e){return e.version===1&&typeof e.pid=="number"&&Number.isInteger(e.pid)&&e.pid>0&&typeof e.updatedAt=="number"&&Number.isFinite(e.updatedAt)}function P(){let e=b();y(e)&&j(e,{recursive:!0,force:!0})}function ie(e=process.pid){E(),q(B(),String(e),"utf-8")}function x(){let e=B();if(!y(e))return null;try{let t=V(e,"utf-8").trim();if(t.length===0)return null;let r=Number(t);return!Number.isInteger(r)||r<=0?null:r}catch{return null}}function He(){let e=B();y(e)&&j(e,{force:!0})}function w(e,t=(r,n)=>{process.kill(r,n)}){if(!Number.isInteger(e)||e<=0)return!1;try{return t(e,0),!0}catch(r){return r.code==="EPERM"}}function Jt(e={}){let t=e.pidOverride??process.pid,r=x();return r!==null&&r!==t&&w(r,e.kill)?{kind:"busy",pid:r}:r!==null&&r!==t?(P(),ie(t),{kind:"swept",stalePid:r}):(ie(t),{kind:"acquired"})}function Wt(){He()}function Qt(e){let t=x();if(t===null||!w(t))throw t!==null&&P(),new Error("no active focus session");E();let r=ce(),n=`${r}.tmp`;q(n,`${e}
|
|
4
4
|
`,"utf-8"),se(n,r)}function Yt(){let e=ce();if(!y(e))return null;let t;try{t=V(e,"utf-8")}catch{return null}finally{j(e,{force:!0})}let r=t.trim().toLowerCase();return Qe.includes(r)?r:null}import{spawn as Ke}from"child_process";import{openSync as ze,closeSync as Xe}from"fs";var le="FLOWE_FOCUS_DAEMON",U="FLOWE_FOCUS_PRESET",de="FLOWE_FOCUS_AMBIENT_FILE",pe="FLOWE_FOCUS_AMBIENT_ID",me="FLOWE_FOCUS_BREAK_TYPE",fe="FLOWE_FOCUS_LONG_BREAK_TYPE",J=class extends Error{constructor(r){super(`a focus daemon is already running (pid ${r})`);this.existingPid=r;this.name="DaemonAlreadyRunningError"}existingPid};function Ze(e){let t={...process.env,[le]:"1",[U]:e.preset};return e.ambientFilePath&&(t[de]=e.ambientFilePath),e.ambientId&&(t[pe]=e.ambientId),e.breakType&&(t[me]=e.breakType),e.longBreakType&&(t[fe]=e.longBreakType),t}function Zt(e){let t=x();if(t!==null){if(w(t))throw new J(t);P()}E();let r=ue(),n=ze(r,"a"),o=e.spawnArgs?.cmd??process.execPath,a=e.spawnArgs?.args??[...process.execArgv,process.argv[1]??"","focus",e.preset],i=(e.spawnFn??Ke)(o,a,{detached:!0,stdio:["ignore",n,n],env:Ze(e)});if(Xe(n),i.unref(),i.pid===void 0)throw new Error("failed to spawn focus daemon (no pid returned)");let u=e.readyTimeoutMs??(e.spawnFn?0:1500);if(u>0&&!et(i.pid,u))throw new Error("focus daemon did not become ready");return{pid:i.pid,logPath:r}}function et(e,t){let r=Date.now()+t;for(;Date.now()<=r;){if(x()===e)return!0;tt(25)}return!1}function tt(e){let t=new SharedArrayBuffer(4),r=new Int32Array(t);Atomics.wait(r,0,0,e)}function er(){let e=process.env[U];if(e!=="pomodoro"&&e!=="dev"&&e!=="ultradian"&&e!=="test2"&&e!=="test5")throw new Error(`invalid ${U}: ${e??"(unset)"} \u2014 daemon child cannot start`);return{preset:e,ambientFilePath:process.env[de]||void 0,ambientId:process.env[pe]||void 0,breakType:process.env[me]||void 0,longBreakType:process.env[fe]||void 0}}function tr(){return process.env[le]==="1"}function rr(e){return[`detached. pid ${e.pid}.`,`logs: ${e.logPath}`,"status: flowe focus status","pause: flowe focus pause resume: flowe focus resume","skip: flowe focus skip quit: flowe focus quit"].join(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFileSync as A,writeFileSync as E,mkdirSync as T,existsSync as D}from"fs";import{homedir as P,platform as b}from"os";import{join as d}from"path";import{nanoid as v}from"nanoid";var S="https://www.flowe.ai",O=90,V=["sage","ada","ellie"];function N(t){return typeof t=="string"&&V.includes(t)?t:"ellie"}function k(){let t=P();return b()==="win32"?d(t,"AppData","Roaming","flowe"):d(t,".config","flowe")}function F(){return d(k(),"config.json")}function h(){return{version:2,voice:"ellie",anonymous_id:`anon_${v(12)}`,telemetry:"on",backend_url:process.env.FLOWE_BACKEND_URL||S,session_dates:[]}}function R(t){let e=typeof t.version=="number"?t.version:1,n=t.voice,r=N(n),o={version:2,voice:r,anonymous_id:t.anonymous_id??`anon_${v(12)}`,telemetry:t.telemetry??"on",backend_url:t.backend_url??S,session_dates:Array.isArray(t.session_dates)?t.session_dates:[]};return typeof t.first_reset_at=="string"&&(o.first_reset_at=t.first_reset_at),typeof t.user_first_name=="string"&&(o.user_first_name=t.user_first_name),(e<2||n!==r)&&a(o),o}function s(){let t=F();if(!D(t)){let e=h();return a(e),e}try{let e=A(t,"utf-8"),n=JSON.parse(e),r=R(n);return process.env.FLOWE_BACKEND_URL&&(r.backend_url=process.env.FLOWE_BACKEND_URL),r}catch{let e=h();return a(e),e}}function g(t){let e=k();D(e)||T(e,{recursive:!0}),E(F(),JSON.stringify(t,null,2),"utf-8")}function a(t){try{return g(t),!0}catch{return!1}}function X(t){let e=s();e.voice=t,g(e)}function Z(){let t=s();t.first_reset_at||(t.first_reset_at=new Date().toISOString(),a(t))}function tt(t){let e=s();t&&t.trim().length>0?e.user_first_name=t.trim():delete e.user_first_name,g(e)}function u(t=new Date){let e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`}function K(t,e){let n=new Date(e);n.setDate(n.getDate()-O);let r=u(n);return t.filter(o=>o>=r)}function et(t=new Date){let e=s(),n=u(t),r=K([...e.session_dates,n],t);e.session_dates=r,a(e)}function nt(t=new Date){let e=s(),n=u(t);return e.session_dates.filter(r=>r===n).length}function rt(t=new Date){let e=s(),n=new Set(e.session_dates),r=new Date(t);r.setHours(0,0,0,0);let o=new Date(r);n.has(u(o))||o.setDate(o.getDate()-1);let w=0;for(;n.has(u(o));)w+=1,o.setDate(o.getDate()-1);return w}function ot(){return s().session_dates.length}import{execFileSync as m}from"child_process";import{existsSync as y,mkdirSync as L,readFileSync as U,rmSync as I,writeFileSync as $}from"fs";import{homedir as j,platform as l}from"os";import{join as f}from"path";var i="flowe-cli",c="clerk-token";function p(){let t=j(),e=l()==="win32"?f(t,"AppData","Roaming","flowe"):f(t,".config","flowe");return f(e,".token")}function B(){if(l()!=="darwin")return null;try{let t=m("security",["find-generic-password","-s",i,"-a",c,"-w"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim();return t.length>0?t:null}catch{return null}}function M(t){if(l()!=="darwin")return!1;try{return m("security",["add-generic-password","-U","-s",i,"-a",c,"-w",t],{stdio:"ignore"}),!0}catch{return!1}}function W(){if(l()!=="darwin")return!1;try{return m("security",["delete-generic-password","-s",i,"-a",c],{stdio:"ignore"}),!0}catch{return!1}}function H(){try{let t=p();if(!y(t))return null;let e=U(t,"utf-8").trim();return e.length>0?e:null}catch{return null}}function J(t){let e=p(),n=f(e,"..");y(n)||L(n,{recursive:!0}),$(e,t,{encoding:"utf-8",mode:384})}function Y(){try{let t=p();y(t)&&I(t,{force:!0})}catch{}}async function _(){try{let e=(await import("keytar")).default;return e&&typeof e.getPassword=="function"?e:null}catch{return null}}async function lt(){let t=process.env.FLOWE_AUTH_TOKEN?.trim();if(t)return t;let e=await _();if(e)try{let n=await e.getPassword(i,c);return n||null}catch{return null}return B()??H()}async function dt(t){let e=await _();if(e)try{await e.setPassword(i,c,t);return}catch{}M(t)||J(t)}async function gt(){let t=await _();if(t)try{await t.deletePassword(i,c)}catch{}W(),Y()}export{s as a,X as b,Z as c,tt as d,et as e,nt as f,rt as g,ot as h,lt as i,dt as j,gt as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as y,d as v,e as C,i as f,j as D}from"./chunk-
|
|
1
|
+
import{a as y,d as v,e as C,i as f,j as D}from"./chunk-DX2IZG3L.js";var O="30\u201350 min",F=[{id:"quick_reset",name:"Reset",description:"Quick mental refresh between tasks.",duration_minutes:10,technique:"Yoga Nidra",category:"calm"},{id:"sprint_prep",name:"Lock In",description:"Before deep work or a focus sprint.",duration_minutes:10,technique:"Dopamine priming",category:"focus"},{id:"context_switch",name:"Clear",description:"After meetings, before code.",duration_minutes:8,technique:"Body scan",category:"focus"},{id:"shutdown",name:"Wind Down",description:"End of day, sleep transition.",duration_minutes:15,technique:"Breathing",category:"sleep"},{id:"logic_lock",name:"Unstuck",description:"When a problem keeps circling.",duration_minutes:10,technique:"Open focus",category:"focus"},{id:"deploy_anxiety",name:"Calm Down",description:"Heart racing, high stakes.",duration_minutes:5,technique:"Cyclic sighing",category:"calm"},{id:"executive_reset",name:"Defog",description:"Brain fog, decision fatigue.",duration_minutes:12,technique:"Quiet focus",category:"calm"},{id:"presentation_prep",name:"Steady",description:"Before a presentation or meeting.",duration_minutes:8,technique:"Grounding",category:"focus"}],I=[{id:"ht_stress",name:"Stress",hook:"For the days everything feels too much."},{id:"ht_anxiety",name:"Anxiety",hook:"For the racing 2 a.m. loop you cannot shake."},{id:"ht_people_pleasing",name:"People pleasing",hook:"When saying no still feels impossible."},{id:"ht_relationships",name:"Relationships",hook:"When the same fight keeps showing up."},{id:"ht_confidence",name:"Confidence",hook:"When imposter syndrome will not quiet down."},{id:"ht_fears",name:"Fears and phobias",hook:"For the freeze before the big moment."},{id:"ht_anger",name:"Anger",hook:"When the reaction is bigger than the trigger."},{id:"ht_procrastination",name:"Procrastination",hook:"For the task you cannot seem to start."},{id:"ht_burnout",name:"Burnout",hook:"When nothing feels like it refills you."}];function l(e,t){return Object.assign(new Error(t),{code:e})}function _(e){return(e?.backendUrl??y().backend_url).replace(/\/+$/,"")}async function Q(e={}){let t=e.fetch??globalThis.fetch,r=_(e),s;try{s=await t(`${r}/api/v1/cli/auth/start`,{method:"POST",headers:{"Content-Type":"application/json"}})}catch{throw l("network_error",`could not reach ${r}`)}if(!s.ok)throw l("network_error",`failed to start sign-in (${s.status})`);let n=await s.json();return{device_code:n.device_code,user_code:n.user_code,verification_uri:n.verification_uri,verification_uri_complete:n.verification_uri_complete,interval:n.interval,expires_at:n.expires_at}}async function U(e,t={}){let r=t.fetch??globalThis.fetch,s=t.setAuthToken??D,n=_(t),o;try{o=await r(`${n}/api/v1/cli/auth/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_code:e})})}catch{throw l("network_error",`could not reach ${n}`)}if(o.status===410)return{status:"expired"};if(!o.ok)throw l("network_error",`sign-in poll failed (${o.status})`);let i=await o.json();if(i.status==="authorized"&&i.token){await s(i.token);let c=await x({...t,getAuthToken:async()=>i.token}).catch(()=>({authenticated:!0,user_id:i.user_id,is_pro:!1,plan_type:"free"}));return c.first_name&&v(c.first_name),{status:"authorized",user_id:i.user_id,account:c}}return{status:"authorization_pending"}}async function x(e={}){let t=e.fetch??globalThis.fetch,r=e.getAuthToken??f,s=_(e),n=await r();if(!n)return{authenticated:!1,is_pro:!1,plan_type:"guest",quick_reset_quota:null};let o={Authorization:`Bearer ${n}`},[i,c,m]=await Promise.all([t(`${s}/api/v1/me`,{headers:o}).catch(()=>null),t(`${s}/api/v1/user/plan-status`,{headers:o}).catch(()=>null),t(`${s}/api/v1/quota/quick-reset`,{headers:o}).catch(()=>null)]);if(i?.status===401)return{authenticated:!1,is_pro:!1,plan_type:"guest",quick_reset_quota:null};let d=i?.ok?await i.json():null,a=c?.ok?await c.json():null,u=m?.ok?await m.json():null;d?.first_name&&v(d.first_name);let g=a?!a.is_quota_limited:u?.cap===-1;return{authenticated:!0,user_id:d?.user_id,first_name:d?.first_name??y().user_first_name??null,email:d?.email??null,is_pro:g,plan_type:a?.plan_type??(g?"pro":"free"),quick_reset_quota:u,team:a?.plan_source==="team"?q(a.team_info):null,team_paused:q(a?.team_paused)}}function q(e){return e?.team_name?{name:e.team_name,role:e.role??"member",status:e.status,trial_ends_at:e.trial_ends_at??null}:null}function P(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString("en-GB",{day:"numeric",month:"short",timeZone:"UTC"})}function z(e){switch(e.status){case"trial_ended":return`The free trial of your team plan (${e.name}) ended.`;case"canceled":return`Your team plan (${e.name}) is canceled.`;case"paused":return`Your team plan (${e.name}) is paused.`;default:return`Your team plan (${e.name}) is off.`}}function W(e){if(e.team){let t=e.team.status==="trialing"?P(e.team.trial_ends_at):null;return`team: ${e.team.name}${t?` \xB7 trial ends ${t}`:""}`}if(e.team_paused){let t=e.team_paused.status==="trial_ended"?"free trial ended":e.team_paused.status??"off";return`team: ${e.team_paused.name} \xB7 ${t} \xB7 ask your admin to turn it back on`}return null}function G(e){return e.is_pro?e.team?`Flowe Pro from ${e.team.name}`:"Flowe Pro":e.plan_type}async function J(e,t={}){let r=t.fetch??globalThis.fetch,s=t.getAuthToken??f,n=_(t),o=y(),i=await s();if(!i)throw l("auth_required","Sign in with Flowe to run live Quick and Deep Resets.");let c=e.tier==="deep"?"hypnotherapy":"nsdr",m=e.voice??o.voice,d=e.ambient??"none",a;try{a=await r(`${n}/api/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({protocolId:c,sessionType:e.sessionType})})}catch{throw l("network_error","Network unreachable \u2014 try a local 30\u201390s micro-reset.")}if(!a.ok){let h=await a.json().catch(()=>({})),p=h?.error?.code,T=h?.error?.message??h?.message??`server error ${a.status}`;throw a.status===401?l("auth_required","Session expired \u2014 sign in to Flowe again."):a.status===403?l(p==="QUOTA_EXCEEDED"?"quota_exceeded":"subscription_required",T):l("network_error",T)}let u=await a.json(),g=`flowe://session/${u.session_id}`,b=`${n}/session/${u.session_id}`,S,k,w,A,R=[],$="waiting_for_join";if(e.startRoom!==!1)try{let h=await r(`${n}/api/v1/sessions/${encodeURIComponent(u.session_id)}/start`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({voiceId:m,ambient:d})});if(h.ok){let p=await h.json();S=p.room_name,k=p.livekit_url,w=p.livekit_token,A=p.current_phase,R=Array.isArray(p.phases)?p.phases:[],k&&w&&($="live")}}catch{}let E=e.tier==="deep"?"Deep Reset":"Quick Reset";return{session_id:u.session_id,tier:e.tier,protocol_id:u.protocol_id??c,session_type:u.session_type??e.sessionType,session_type_name:u.session_type_name,estimated_duration:u.estimated_duration,voice:m,ambient:d,room_name:S,livekit_url:k,livekit_token:w,current_phase:A,phases:R,join_url:g,web_url:b,status:$,requires_microphone:e.tier==="deep",message_for_user:`${E}: ${u.session_type_name} (${u.estimated_duration} min) ready \xB7 ${b}`}}async function M(e,t={},r={}){let s=r.fetch??globalThis.fetch,n=r.getAuthToken??f,o=_(r),i=await n();if(!i)throw l("auth_required","Sign in with Flowe first.");let c={};if(typeof t.durationMinutes=="number"&&(c.durationMinutes=t.durationMinutes),typeof t.rating=="number"&&(c.userFeedback={rating:t.rating,comments:t.comments}),(await s(`${o}/api/v1/sessions/${encodeURIComponent(e)}/complete`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(c)})).ok){try{C()}catch{}return{completed:!0}}return{completed:!1}}async function Y(e,t={}){let r=t.fetch??globalThis.fetch,s=t.getAuthToken??f,n=_(t),o=await s();if(!o)return{cancelled:!1};try{return{cancelled:(await r(`${n}/api/v1/sessions/${encodeURIComponent(e)}`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})).ok}}catch{return{cancelled:!1}}}export{O as a,F as b,I as c,Q as d,U as e,x as f,z as g,W as h,G as i,J as j,M as k,Y as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i,d as n,i as o}from"./chunk-
|
|
1
|
+
import{a as i,d as n,i as o}from"./chunk-DX2IZG3L.js";async function l(t={}){let e=i(),r=t.authToken!==void 0?t.authToken:await o();if(!r)return null;let a=t.fetch??globalThis.fetch;try{let s=await a(`${e.backend_url}/api/v1/me`,{method:"GET",headers:{Authorization:`Bearer ${r}`}});return s.ok?await s.json():null}catch{return null}}async function m(t={}){let e=await l(t);return e?typeof e.first_name=="string"&&e.first_name.trim().length>0?(n(e.first_name),e.first_name):(n(null),null):null}export{l as a,m as b};
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Dt,b as We,c as Je,d as Ut,e as jt,f as Xe,g as Ze,h as qt,i as Ht,l as Yt,n as _e,o as pe,p as Re,q as ve,r as Ie,s as $e,t as Oe,u as Xt,v as Zt,w as en,x as tn,y as nn}from"./chunk-
|
|
1
|
+
import{a as Dt,b as We,c as Je,d as Ut,e as jt,f as Xe,g as Ze,h as qt,i as Ht,l as Yt,n as _e,o as pe,p as Re,q as ve,r as Ie,s as $e,t as Oe,u as Xt,v as Zt,w as en,x as tn,y as nn}from"./chunk-3KM7AYV7.js";import{d as Vt,g as Wt,h as Jt,i as et,j as Ee,k as se,l as Qt,m as zt}from"./chunk-3TLGYA6M.js";import{b as tt}from"./chunk-M56P7SDZ.js";import{a as q,b as Qe,e as ze,f as Lt,g as Ft,h as Kt,i as V,k as Gt}from"./chunk-DX2IZG3L.js";import{cac as Oi}from"cac";import{existsSync as Pi}from"fs";import Nr from"qrcode-terminal";async function rn(e="quick_reset",t={}){let n=q(),r=await V();if(!r)throw Object.assign(new Error("sign in with: flowe login"),{code:"auth_required"});let o;try{o=await fetch(`${n.backend_url}/api/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({protocolId:"nsdr",sessionType:e})})}catch{throw Object.assign(new Error("network unreachable \u2014 try: flowe reset"),{code:"network_error"})}if(!o.ok)throw o.status===401?Object.assign(new Error("session expired \u2014 run: flowe login"),{code:"auth_required"}):Object.assign(new Error(`server error ${o.status}`),{code:"network_error"});let s=await o.json(),i=`flowe://session/${s.session_id}`;return!t.suppressQr&&process.stdout.isTTY&&Nr.generate(i,{small:!0}),{session_id:s.session_id,session_type:s.session_type,session_type_name:s.session_type_name,estimated_duration:s.estimated_duration,join_url:i,status:"waiting_for_join",message_for_user:`${s.session_type_name} (${s.estimated_duration}min) ready \xB7 ${i}`}}import{createWriteStream as Br}from"fs";import{mkdtemp as Dr,rm as Lr}from"fs/promises";import{tmpdir as Fr}from"os";import{join as on}from"path";import{pipeline as Kr}from"stream/promises";import{Readable as Ur}from"stream";async function sn(e){let t=await Dr(on(Fr(),"flowe-stream-")),n=on(t,"audio.mp3"),r=async()=>{try{await Lr(t,{recursive:!0,force:!0})}catch{}};try{let o=await fetch(e.url,{headers:e.headers,signal:e.signal});if(o.status===401)throw Object.assign(new Error("login required \u2014 run: flowe login"),{code:"auth_required"});if(o.status===404)throw Object.assign(new Error("session type not available on server"),{code:"protocol_unavailable"});if(!o.ok)throw Object.assign(new Error(`stream failed: ${o.status} ${o.statusText}`),{code:"network_error"});if(!o.body)throw Object.assign(new Error("empty response body"),{code:"network_error"});let s=(()=>{let l=o.headers.get("content-length");return l?parseInt(l,10):null})(),i=(()=>{let d=o.headers.get("cache-control")?.match(/max-age=(\d+)/);return d?parseInt(d[1],10):null})(),a=0,u=Ur.fromWeb(o.body),c=Br(n);return u.on("data",l=>{a+=l.length,e.onProgress?.(a,s)}),await Kr(u,c),{filePath:n,cleanup:r,bytes:a,cacheMaxAge:i}}catch(o){throw await r(),o}}function jr(e,t,n,r){let o=new URL(`/api/v1/nsdr/sessions/${t}/stream`,e);return o.searchParams.set("duration",String(n)),o.searchParams.set("voice",r),o.toString()}async function ie(e){let t=q(),n=await V();if(!n)throw Object.assign(new Error("sign in with: flowe login"),{code:"auth_required"});let r=e.durationMin??5,o=e.voice??t.voice,s=jr(t.backend_url,e.type,r,o),i;if(process.stdout.isTTY){let l=-1;i=(d,w)=>{if(!w){process.stdout.write(`\r fetching ${e.type}\u2026 ${d} bytes`);return}let S=Math.floor(d/w*100);S!==l&&(l=S,process.stdout.write(`\r fetching ${e.type}\u2026 ${S}%`))}}let a=await sn({url:s,headers:{Authorization:`Bearer ${n}`},signal:e.signal,onProgress:i});process.stdout.isTTY&&process.stdout.write("\r\x1B[2K");let c=qt(a.filePath).finally(()=>a.cleanup());return{started_at:new Date().toISOString(),type:e.type,voice:o,durationMin:r,finished:c,cancel:()=>Ht()}}import ts from"node-notifier";import{fileURLToPath as ns}from"url";import{dirname as rs,join as os}from"path";var nt="\x1B[0m",qr="\x1B[1m",Hr="\x1B[2m",rt={oak:{r:212,g:165,b:116},oakDeep:{r:184,g:145,b:95},sage:{r:124,g:154,b:142},dusk:{r:139,g:123,b:164},duskLight:{r:185,g:163,b:204},duskDeep:{r:110,g:97,b:137},charcoal:{r:45,g:45,b:45}};function ot(){return process.env.NO_COLOR?!1:process.env.FORCE_COLOR?!0:!!process.stdout.isTTY}function st(e,t){return ot()?`\x1B[38;2;${e.r};${e.g};${e.b}m${t}${nt}`:t}var m=e=>st(rt.oak,e),N=e=>st(rt.oakDeep,e),an=e=>st(rt.sage,e);var f=e=>ot()?`${Hr}${e}${nt}`:e,R=e=>ot()?`${qr}${e}${nt}`:e;var Gr=/\x1b\[[0-9;]*m/g,Q={tl:"\u256D",tr:"\u256E",bl:"\u2570",br:"\u256F",h:"\u2500",v:"\u2502"};function it(e){return e.replace(Gr,"").length}function z(e,t){let n=it(e);return n>=t?e:e+" ".repeat(t-n)}function H(e,t){let n=Q.tl+Q.h.repeat(t+2)+Q.tr,r=Q.bl+Q.h.repeat(t+2)+Q.br;return[n,...e.map(o=>`${Q.v} ${z(o,t)} ${Q.v}`),r]}function F(e,t){let n=it(e);if(n>=t)return e;let r=Math.floor((t-n)/2);return" ".repeat(r)+e}var Yr=54;function ct(e,t=Yr){return H(e,t)}function Vr(e=new Date){let t=e.getHours();return t<5?"Late night":t<12?"Good morning":t<18?"Good afternoon":t<22?"Good evening":"Late night"}function un(e,t=new Date){let n=Vr(t),r=(e??"").trim(),o=r.length>0?r:"there";return`${n}, ${o}.`}function Pe(e,t){let n=t?m("\u25B8 "):" ",r=t?R(m(e.label)):e.label,o=e.detail?" "+f("\xB7 "+e.detail):"";return` ${n}${r}${o}`}function lt(e){let t=m("\u2713"),n=f(e.label.toUpperCase().padEnd(8)),r=m(e.value);return` ${t} ${n} ${r}`}function dt(e){return e.length===0?[]:[...e.map(lt),""]}var cn=" \u2191\u2193 to move \u23CE to select esc to cancel",Wr=" \u2191\u2193 to move \u23CE to select esc to back",ft=[30,45,60,90],Te=[{id:"ellie",description:"warm, even pace"},{id:"sage",description:"grounded, low"},{id:"ada",description:"clear, neutral"}];function Jr(e,t=[]){return ct(["",...dt(t),` ${N("\u25C6")} you're not signed in.`,""," sign in to track your progress, build a streak,"," and personalize your sessions.","",Pe({label:"SIGN IN"},e===0),Pe({label:"MAYBE LATER",detail:"anonymous"},e===1),"",f(cn),""])}function Qr(e,t,n=[],r=ft){return ct(["",...dt(n),` ${t}`," What's the cadence for today?","",...r.map((o,s)=>Pe({label:`${o} seconds`},s===e)),"",f(cn),""])}function zr(e,t=[]){return ct(["",...dt(t)," Pick your guide.","",...Te.map((n,r)=>Pe({label:n.id,detail:n.description},r===e)),"",f(Wr),""])}var xe=e=>`\x1B[${e}A`,ut="\x1B[2K",Xr="\x1B[?25l",Zr="\x1B[?25h";function eo(e,t,n){let r="";n>0&&(r+=xe(n));for(let o of t)r+=`\r${ut}${o}
|
|
2
2
|
`;if(n>t.length){let o=n-t.length;for(let s=0;s<o;s++)r+=`\r${ut}
|
|
3
3
|
`;r+=xe(o)}e.write(r)}function to(e,t=ft){let n=t.indexOf(e);if(n>=0)return n;let r=t.indexOf(60);return r>=0?r:0}function no(e){let t=Te.findIndex(n=>n.id===e);return t>=0?t:0}async function at(e,t,n,r,o,s){let i=n,a=()=>{let u=o(i);eo(e.out,u,t.height),t.height=u.length};for(a();;){let u=await e.keys.next();if(u.done)return{cancel:!0};let c=u.value;if(c.name==="ctrl-c")return{cancel:!0};if(c.name==="escape")return{back:!0};if(c.name==="up"||c.name==="char"&&c.char==="k"){i=(i-1+r)%r,a();continue}if(c.name==="down"||c.name==="tab"||c.name==="char"&&c.char==="j"){i=(i+1)%r,a();continue}if(c.name==="return")return{result:s(i)}}}async function ln(e){let t=e.io??ro();t.setRawMode?.(!0),t.out.write(Xr);let n={height:0};try{let r="already_authed",o=[];if(e.showAuthWedge){let i=await at(t,n,0,2,a=>Jr(a,o),a=>a===0?"signin":"later");if("cancel"in i||"back"in i)return null;i.result==="signin"?(e.signIn&&await e.signIn(),r="signed_in",o.push({label:"auth",value:"signed in"})):(r="maybe_later",o.push({label:"auth",value:"continuing as guest"}))}let s=e.availableDurations?.length?e.availableDurations:ft;for(;;){let i=await at(t,n,to(e.defaultDuration,s),s.length,u=>Qr(u,e.greeting,o,s),u=>s[u]);if("cancel"in i||"back"in i)return null;o.push({label:"cadence",value:`${i.result} seconds`});let a=await at(t,n,no(e.defaultVoice),Te.length,u=>zr(u,o),u=>Te[u].id);if("cancel"in a)return null;if("back"in a){o.pop();continue}return{duration:i.result,voice:a.result,authChoice:r}}}finally{if(t.setRawMode?.(!1),t.out.write(Zr),e.clearOnExit&&n.height>0){let r=xe(n.height);for(let o=0;o<n.height;o++)r+=`\r${ut}
|
|
4
4
|
`;r+=xe(n.height),t.out.write(r)}await t.keys.return?.()}}function dn(){return!!process.stdout.isTTY&&!!process.stdin.isTTY&&!process.env.NO_COLOR&&!process.env.CI}function ro(){let e=process.stdin;return{out:process.stdout,setRawMode:n=>{e.isTTY&&e.setRawMode(n)},keys:oo(e)}}function oo(e){e.resume();let t=[],n=[],r=!1,o=i=>{let a=Buffer.isBuffer(i)?i:Buffer.from(i),u=W(a);for(let c of u){let l=n.shift();l?l(c):t.push(c)}},s=()=>{for(r=!0;n.length;)n.shift()(null)};return e.on("data",o),e.once("end",s),{async next(){return t.length?{value:t.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise(i=>{n.push(a=>{i(a===null?{value:void 0,done:!0}:{value:a,done:!1})})})},async return(){return e.off("data",o),e.off("end",s),e.pause(),{value:void 0,done:!0}}}}function W(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===3){t.push({name:"ctrl-c"}),n+=1;continue}if(r===13||r===10){t.push({name:"return"}),n+=1;continue}if(r===9){t.push({name:"tab"}),n+=1;continue}if(r===27){if(e[n+1]===91){let o=e[n+2];o===65?t.push({name:"up"}):o===66?t.push({name:"down"}):t.push({name:"escape"}),n+=3;continue}t.push({name:"escape"}),n+=1;continue}if(r>=32&&r<127){t.push({name:"char",char:String.fromCharCode(r)}),n+=1;continue}n+=1}return t}var U={pomodoro:{focusSec:1500,breakSec:300,longBreakSec:900,blocks:4},dev:{focusSec:3e3,breakSec:600,longBreakSec:1800,blocks:3},ultradian:{focusSec:5400,breakSec:900,longBreakSec:1800,blocks:2},test2:{focusSec:20,breakSec:20,longBreakSec:50,blocks:2},test5:{focusSec:90,breakSec:30,longBreakSec:80,blocks:2}},be=5;function Ae(e,t){return{status:"PRE_FLIGHT",blockIndex:0,enteredAtMs:t,pausedAtMs:null,pausedDurationMs:0,preset:e}}function ge(e,t){return e.status!=="PRE_FLIGHT"?e:{...e,status:"FOCUS_BLOCK",blockIndex:1,enteredAtMs:t,pausedAtMs:null,pausedDurationMs:0}}function so(e,t){let n=t-e.enteredAtMs;return e.pausedAtMs!==null?e.pausedAtMs-e.enteredAtMs-e.pausedDurationMs:n-e.pausedDurationMs}function Me(e){switch(e.status){case"FOCUS_BLOCK":return e.preset.focusSec;case"TRANSITION":return be;case"BREAK":return e.preset.breakSec;case"LONG_BREAK":return e.preset.longBreakSec;default:return 0}}function J(e,t){let n=Me(e),r=Math.floor(so(e,t)/1e3);return Math.max(0,n-r)}function fn(e,t,n){return{...e,status:t,blockIndex:t==="FOCUS_BLOCK"?e.blockIndex+1:e.blockIndex,enteredAtMs:n,pausedAtMs:null,pausedDurationMs:0}}function mn(e){switch(e.status){case"FOCUS_BLOCK":return"TRANSITION";case"TRANSITION":return e.blockIndex>=e.preset.blocks?"LONG_BREAK":"BREAK";case"BREAK":return"FOCUS_BLOCK";case"LONG_BREAK":return"CYCLE_DONE";default:return e.status}}function Ne(e,t){switch(t.kind){case"PAUSE":return e.pausedAtMs!==null||e.status==="PRE_FLIGHT"||e.status==="CYCLE_DONE"?e:{...e,pausedAtMs:t.nowMs};case"RESUME":{if(e.pausedAtMs===null)return e;let n=t.nowMs-e.pausedAtMs;return{...e,pausedAtMs:null,pausedDurationMs:e.pausedDurationMs+n}}case"SKIP":return e.status!=="FOCUS_BLOCK"&&e.status!=="BREAK"&&e.status!=="LONG_BREAK"&&e.status!=="TRANSITION"?e:fn(e,mn(e),t.nowMs);case"QUIT":return{...e,status:"CYCLE_DONE",enteredAtMs:t.nowMs,pausedAtMs:null};case"TICK":return e.pausedAtMs!==null||e.status==="PRE_FLIGHT"||e.status==="CYCLE_DONE"||J(e,t.nowMs)>0?e:fn(e,mn(e),t.nowMs)}}function Be(e,t){return e.status!==t.status||e.blockIndex!==t.blockIndex}var io=(()=>{let e=[];for(let n=0;n<9;n+=1){let r=(-72+n*18)*Math.PI/180,o=Math.cos(r),s=Math.max(6,Math.round(30*o));for(let i=0;i<s;i+=1){let a=(i+n%2*.5)/s*2*Math.PI,u=e.length,c=Math.abs(Math.sin(u*12.9898+78.233)*43758.5453)%1;e.push({x:o*Math.cos(a),y:Math.sin(r),z:o*Math.sin(a),seed:c})}}return e})(),ao=[[/\bhead\b|forehead/,.84],[/\bjaw\b/,.66],[/shoulder/,.46],[/\bchest\b/,.26],[/stomach|belly/,.06],[/\bhips?\b|\bhands?\b/,-.16],[/\blegs?\b/,-.46],[/\bfeet\b|\bfoot\b|weight/,-.8]];function pn(e){let t=e.label.toLowerCase(),r={dir:0,band:0,double:!1,dim:e.mode==="palming"||/palm|cup over eyes|eye rest|eyes warm/.test(t)};if(e.phase==="inhale"||/\binhale\b/.test(t))return{...r,kind:"inhale",double:/double|top.?up/.test(t)};if(e.phase==="exhale"||/\bexhale\b/.test(t))return{...r,kind:"exhale"};if(e.phase==="hold_in"||e.phase==="hold_out"||/\bhold\b/.test(t))return{...r,kind:"hold"};if(/counter|anti.?clockwise|\bleft\b|\bback\b/.test(t)&&(e.mode==="rotation"||/clockwise|roll/.test(t)))return{...r,kind:"circle",dir:-1};if(/clockwise|\bright\b|forward/.test(t)&&(e.mode==="rotation"||/clockwise|roll/.test(t)))return{...r,kind:"circle",dir:1};if(/\bbreath(e|s)?\b/.test(t))return{...r,kind:"breath"};if(/whole body/.test(t))return{...r,kind:"band",band:Number.NaN};for(let[o,s]of ao)if(o.test(t))return{...r,kind:"band",band:s};return{...r,kind:"rest"}}var Z=e=>.5-.5*Math.cos(Math.PI*Math.max(0,Math.min(1,e)));function mt(e){return .3+.18*(.5-.5*Math.cos(2*Math.PI*e/9e3))}function bn(e,t,n,r){let o=Math.max(1,t.endMs-t.startMs),s=Math.max(0,Math.min(1,(n-t.startMs)/o));switch(e.kind){case"inhale":return e.double?s<.62?r+(.82-r)*Z(s/.62):.82+.18*Z((s-.62)/.38):r+(1-r)*Z(s);case"exhale":return r*(1-Z(s));case"hold":return r;case"breath":return s<.42?r+(.9-r)*Z(s/.42):.9-.75*Z((s-.42)/.58);default:{let i=Z((n-t.startMs)/1200);return r+(mt(n)-r)*i}}}function uo(e,t){if(t.length===0||e<t[0].startMs)return-1;for(let n=0;n<t.length;n+=1)if(e<t[n].endMs)return n;return t.length-1}function co(e,t=[]){let n=uo(e,t);if(n<0)return{fill:mt(e),light:null,turn:1,band:null,dim:!1};let r=mt(t[0].startMs);for(let l=0;l<n;l+=1)r=bn(pn(t[l]),t[l],t[l].endMs,r);let o=t[n],s=pn(o),i=bn(s,o,e,r),a=e<o.endMs,u=s.kind==="circle"&&a?s.dir*2*Math.PI*(e-o.startMs)/3200:null,c=s.kind==="band"&&a?s.band:null;return{fill:i,light:u,turn:s.dir||1,band:c,dim:s.dim&&a}}var lo=[[1,8],[2,16],[4,32],[64,128]];function fo(e){return e>=.8?3:e>=.5?2:e>=.2?1:0}var mo=4;function gn(e,t,n={}){let r=n.width??24,o=n.height??11,s=n.braille??!0,i=Array.from({length:o},()=>new Array(r).fill(0)),a=Array.from({length:o},()=>new Array(r).fill(-1)),u=(l,d,w)=>{let S=Math.floor(l/2),$=Math.floor(d/4);l<0||d<0||S>=r||$>=o||(i[$][S]|=lo[d%4][l%2],w>a[$][S]&&(a[$][S]=w))},c=Math.min(1,Math.max(0,e)/1e3,Math.max(0,t)/1e3);if(c>0){let l=co(e,n.cues??[]),d=r*2,w=o*4,S=(d-1)/2,$=(w-1)/2,C=Math.min(d,w)/2-1,g=C*(.55+(1-.55)*l.fill),k=2*Math.PI*e/26e3,[b,v]=[Math.sin(k),Math.cos(k)],[h,O]=[Math.sin(.42),Math.cos(.42)];io.forEach((P,E)=>{if(P.seed>=c)return;let T=P.x*v+P.z*b,L=-P.x*b+P.z*v,y=P.y*O-L*h,K=P.y*h+L*O;if(K<-.05&&E%mo!==0)return;let M=fo(K);l.band!==null&&(M=Number.isNaN(l.band)||Math.abs(P.y-l.band)<.17?Math.min(3,M+(Number.isNaN(l.band)?1:2)):Math.max(0,M-1)),l.dim&&(M=Math.max(0,M-1)),u(Math.round(S+T*g),Math.round($-y*g),M)});let D=l.light;if(D!==null&&c>=1){let P=Math.min(C+.5,g*1.16);[3,3,3,2,2,1,1,0].forEach((T,L)=>{let y=D-l.turn*L*.13;u(Math.round(S+Math.sin(y)*P),Math.round($-Math.cos(y)*P),T)})}}return i.map((l,d)=>{let w=[];return l.forEach((S,$)=>{let C=S===0?null:a[d][$],g=" ";if(S!==0)if(s)g=String.fromCharCode(10240+S);else{let b=0;for(let v=S;v;v>>=1)b+=v&1;g=b<=2?"\xB7":b<=4?"\u2022":"\u25CF"}let k=w[w.length-1];k&&k.tone===C?k.text+=g:w.push({text:g,tone:C})}),w})}function hn(e,t){return e.FLOWE_ORB==="dots"?!1:e.FLOWE_ORB==="braille"?!0:!(e.TERM==="linux"||t==="win32"&&!e.WT_SESSION&&!e.TERM_PROGRAM)}var go=100;var wn=28;function ho(e,t){if(t.length===0||e<t[0].start_ms)return-1;let n=t.length-1;if(e>=t[n].end_ms)return n;for(let r=0;r<=n;r+=1)if(e<t[r].end_ms)return r;return n}var wo={0:e=>f(N(e)),1:N,2:m,3:m};function So(e){return{label:e.label,startMs:e.start_ms,endMs:e.end_ms,mode:e.mode,phase:e.phase}}function pt(e,t,n=[],r=24,o=11){let s=hn(process.env,process.platform);return gn(e,t,{width:r,height:o,braille:s,cues:n.map(So)}).map(i=>i.map(a=>a.tone===null?a.text:wo[a.tone](a.text)).join(""))}var bt=60;function yo(e){return`${Math.max(0,Math.floor(e))}s`}function ko(e,t,n){return` ${N("\u2740")} ${R("SESSION_ACTIVE")} ${t}s \xB7 ${e} \xB7 ${f(n)}`}function Co(e){return["",...e.map(t=>F(t,bt)),""]}function Eo(e){let t=e.toLowerCase().trim();return/\binhale\b/.test(t)?"INHALING . . .":/\bexhale\b/.test(t)?"EXHALING . . .":/\bhold\b/.test(t)?"HOLDING . . .":`${t.replace(/^\d+\s+/,"").trim().toUpperCase()} . . .`}function _o(e,t){let n=ho(t,e);if(n<0)return"";let r=Eo(e[n].label),o=`[ ${R(m(r))} ]`;return F(o,bt)}function Ro(e,t,n){let r=Math.max(0,Math.min(.999,e/t));return Math.min(n,Math.floor(r*n)+1)}function vo(e,t,n,r){let o=`${f("TIME_REMAINING")} ${m(`-${yo(e/1e3)}`)}`;if(!r)return` ${o}`;let s=Ro(t,n,r),i=`${f("ROUND")} ${m(`${s} / ${r}`)}`,a=Math.floor(bt/2);return z(` ${o}`,a)+i}function Io(e,t){let n=Math.min(1,Math.max(0,e/t)),r=Math.round(n*wn),o=wn-r,s=`${m("\u2588".repeat(r))}${f("\u2591".repeat(o))}`,i=`${Math.round(n*100)}%`;return` ${f("PROGRESS_SEQUENCE")} [${s}] ${f(i)}`}var $o="\x1B[?25l",Sn="\x1B[?25h",Oo=e=>`\x1B[${e}A`,Po="\x1B[H",To="\x1B[2K",xo="\r",Ao="\x1B[?1049h",yn="\x1B[?1049l",Mo=25;function kn(e,t,n){let r=Math.max(0,n-t),o=Co(pt(t,r,e.cues));return{lines:["",...["",ko(e.displayName,e.duration,e.voice),"",...o,"",_o(e.cues,t),"",vo(r,t,n,e.rounds),"",Io(t,n),""].map(i=>` ${i}`),""]}}function Cn(e,t,n){let r="";n||(r+=Oo(Mo));for(let o of t.lines)r+=`${xo}${To}${o}
|
|
@@ -21,13 +21,13 @@ import{a as Dt,b as We,c as Je,d as Ut,e as jt,f as Xe,g as Ze,h as qt,i as Ht,l
|
|
|
21
21
|
`);return n.length}function Si(){let e=N("\u25C6"),t=`[${m("r")}] repeat`,n=`[${m("n")}] new session`,r=`[${m("x")}] exit`;return` ${e} ${t} ${f("\xB7")} ${n} ${f("\xB7")} ${r}`}var vr=2;async function Ir(e){e.setRawMode?.(!0),e.out.write(`
|
|
22
22
|
`+Si()+`
|
|
23
23
|
`);try{for(;;){let t=await e.keys.next();if(t.done)return"exit";let n=t.value;if(n.name==="ctrl-c"||n.name==="escape")return"exit";if(n.name==="char"){let r=(n.char??"").toLowerCase();if(r==="r")return"repeat";if(r==="n")return"new";if(r==="x"||r==="q")return"exit"}}}finally{e.setRawMode?.(!1),await e.keys.return?.()}}function $r(){let e=process.stdin;return{out:process.stdout,setRawMode:n=>{e.isTTY&&e.setRawMode(n)},keys:yi(e)}}function yi(e){e.resume();let t=[],n=[],r=!1,o=i=>{let a=Buffer.isBuffer(i)?i:Buffer.from(i),u=W(a);for(let c of u){let l=n.shift();l?l(c):t.push(c)}},s=()=>{for(r=!0;n.length;)n.shift()(null)};return e.on("data",o),e.once("end",s),{async next(){return t.length?{value:t.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise(i=>{n.push(a=>{i(a===null?{value:void 0,done:!0}:{value:a,done:!1})})})},async return(){return e.off("data",o),e.off("end",s),e.pause(),{value:void 0,done:!0}}}}import{existsSync as ki,mkdirSync as Ci,writeFileSync as Ei}from"fs";import{homedir as _i,platform as Ri}from"os";import{join as He}from"path";var Or="welcomed";function It(){let e=_i();return Ri()==="win32"?He(e,"AppData","Roaming","flowe"):He(e,".config","flowe")}function vi(){return["","flowe-cli installed.","","Try it:"," flowe reset interactive picker (pick duration + protocol)"," flowe reset 60 quick 60-second reset, random protocol"," flowe protocols list all 12 protocols","","Docs: https://cli.flowe.ai/docs/",""].join(`
|
|
24
|
-
`)}function Ii(e=It()){return ki(He(e,Or))}function $i(e=It()){Ci(e,{recursive:!0}),Ei(He(e,Or),"","utf-8")}function Pr(e=process.stderr){try{let t=It();if(Ii(t))return
|
|
24
|
+
`)}function Ii(e=It()){return ki(He(e,Or))}function $i(e=It()){Ci(e,{recursive:!0}),Ei(He(e,Or),"","utf-8")}function Pr(e=process.stderr){try{let t=It();if(Ii(t))return;$i(t),e.write(vi())}catch{}}var Tr=e=>`\x1B[${e}A`,Ti="\x1B[2K";function xi(e,t){if(t<=0)return;let n=Tr(t);for(let r=0;r<t;r++)n+=`\r${Ti}
|
|
25
25
|
`;n+=Tr(t),e.write(n)}function Ai(e){switch(e){case"auth_required":return 2;case"agent_busy":return 3;case"network_error":case"offline":return 4;default:return 1}}function j(e){let t=e,n=t?.message||String(e);process.stderr.write(`flowe: ${n}
|
|
26
|
-
`),process.exit(Ai(t?.code))}function Mi(e){return Array.isArray(e)?e.join(" ").trim():(e??"").trim()}function Pt(e){let t=typeof e=="number"?e:parseInt(e,10);if(t===30||t===45||t===60||t===90)return t;throw Object.assign(new Error("duration must be 30, 45, 60, or 90"),{code:"invalid_duration"})}function $t(e){if(We.includes(e))return e;throw Object.assign(new Error(`type must be one of: ${We.join(", ")}`),{code:"invalid_duration"})}function Ni(e){if(Je.includes(e))return e;throw Object.assign(new Error(`type must be one of: ${Je.join(", ")}`),{code:"invalid_duration"})}function Ot(e){if(e==="sage"||e==="ada"||e==="ellie")return e;throw Object.assign(new Error("voice must be sage, ada, or ellie"),{code:"invalid_duration"})}function Bi(e){let t=jt();if(t.includes(e))return e;throw Object.assign(new Error(`unknown protocol "${e}" \u2014 available: ${t.join(", ")}`),{code:"invalid_duration"})}async function Di(e=2e3){let t=tt().catch(()=>null),n=new Promise(r=>setTimeout(()=>r(null),e));return Promise.race([t,n])}async function xr(e,t){let n=q(),r=await V();r&&!n.user_first_name&&(await Di(),n=q());let o=un(n.user_first_name),s=60;if(e)try{s=Pt(e)}catch{}let i=t?Xe(t):void 0,a=await ln({defaultDuration:s,defaultVoice:n.voice,greeting:o,showAuthWedge:!r,availableDurations:i,signIn:async()=>{let{runLogin:u}=await import("./login-
|
|
26
|
+
`),process.exit(Ai(t?.code))}function Mi(e){return Array.isArray(e)?e.join(" ").trim():(e??"").trim()}function Pt(e){let t=typeof e=="number"?e:parseInt(e,10);if(t===30||t===45||t===60||t===90)return t;throw Object.assign(new Error("duration must be 30, 45, 60, or 90"),{code:"invalid_duration"})}function $t(e){if(We.includes(e))return e;throw Object.assign(new Error(`type must be one of: ${We.join(", ")}`),{code:"invalid_duration"})}function Ni(e){if(Je.includes(e))return e;throw Object.assign(new Error(`type must be one of: ${Je.join(", ")}`),{code:"invalid_duration"})}function Ot(e){if(e==="sage"||e==="ada"||e==="ellie")return e;throw Object.assign(new Error("voice must be sage, ada, or ellie"),{code:"invalid_duration"})}function Bi(e){let t=jt();if(t.includes(e))return e;throw Object.assign(new Error(`unknown protocol "${e}" \u2014 available: ${t.join(", ")}`),{code:"invalid_duration"})}async function Di(e=2e3){let t=tt().catch(()=>null),n=new Promise(r=>setTimeout(()=>r(null),e));return Promise.race([t,n])}async function xr(e,t){let n=q(),r=await V();r&&!n.user_first_name&&(await Di(),n=q());let o=un(n.user_first_name),s=60;if(e)try{s=Pt(e)}catch{}let i=t?Xe(t):void 0,a=await ln({defaultDuration:s,defaultVoice:n.voice,greeting:o,showAuthWedge:!r,availableDurations:i,signIn:async()=>{let{runLogin:u}=await import("./login-IDFOVWCU.js");await u(),await tt()},clearOnExit:!0});return a?{duration:a.duration,voice:a.voice,family:t}:null}async function Li(e,t){if(t){let r=Xe(t);if(e===void 0&&r.length===1)return{duration:r[0],family:t};if(e===void 0)throw Object.assign(new Error(`protocol "${t}" supports multiple durations (${r.join(", ")}s) \u2014 pass one as: flowe reset <duration> --protocol ${t}`),{code:"invalid_duration"});let o=Pt(e);if(!r.includes(o))throw Object.assign(new Error(`protocol "${t}" has no ${o}s variant \u2014 available: ${r.join(", ")}s`),{code:"invalid_duration"});return{duration:o,family:t}}return{duration:Pt(e??60)}}async function Fi(){if(tn()){let t=en(),n=await Gn({preset:t.preset,ambientFilePath:t.ambientFilePath,ambientId:t.ambientId??null,breakType:t.breakType,longBreakType:t.longBreakType,notifications:process.env.FLOWE_FOCUS_NO_NOTIFICATIONS!=="1"});process.exit(n.reason==="busy"?1:0)}process.argv[2]!=="mcp"&&Pr();let e=Oi("flowe");e.command("reset [duration]","Run a micro-reset (30, 45, 60, or 90 seconds)").option("--trigger <trigger>","why this reset fired",{default:"user_requested"}).option("-q, --quick","skip the interactive picker and run with the given duration").option("--protocol <family>","restrict to a specific protocol family (e.g., physiological_sigh, box_breath)").action(async(t,n)=>{try{let r=n.trigger,o=n.protocol?Bi(n.protocol):void 0,i=!n.quick&&dn()?await xr(t,o):await Li(t,o);if(!i)return;for(;;){i.voice&&Qe(i.voice);let a=await Yt(i.duration,r,i.family),u=Ze();if(_n()&&u){await En({duration:a.duration_seconds,voice:a.voice,displayName:a.protocol_display_name,cues:a.cues,rounds:a.rounds,donePromise:u}),ze();let c=Rr({protocolDisplayName:a.protocol_display_name,duration:a.duration_seconds,voice:a.voice,rounds:a.rounds,sessionsToday:Lt(),totalSessions:Kt(),streakDays:Ft()});if(n.quick)return;let l=await Ir($r());if(l==="exit")return;if(xi(process.stdout,c+vr),l==="repeat")continue;if(l==="new"){let d=await xr(void 0,i.family);if(!d)return;i=d;continue}return}process.stdout.write(`${a.message_for_user}
|
|
27
27
|
`);for(let c of a.cues)process.stdout.write(` \xB7 ${c.label}
|
|
28
|
-
`);u&&(await u,ze());return}}catch(r){j(r)}}),e.command("quick [type]","Start a real authenticated Flowe Quick Reset (5\u201315 min live AI voice session)").option("--voice <name>","override guide voice (ellie, ada, sage)").option("--ambient <id>","ambient soundscape id (default: none)").option("--open","open the live session in your browser automatically").action(async(t,n)=>{try{let r=t?$t(t):"quick_reset",o=n.voice?Ot(n.voice):void 0,{createAndStartLiveSession:s}=await import("./session-client-
|
|
28
|
+
`);u&&(await u,ze());return}}catch(r){j(r)}}),e.command("quick [type]","Start a real authenticated Flowe Quick Reset (5\u201315 min live AI voice session)").option("--voice <name>","override guide voice (ellie, ada, sage)").option("--ambient <id>","ambient soundscape id (default: none)").option("--open","open the live session in your browser automatically").action(async(t,n)=>{try{let r=t?$t(t):"quick_reset",o=n.voice?Ot(n.voice):void 0,{createAndStartLiveSession:s}=await import("./session-client-XHJ2MGA5.js"),i=await s({tier:"quick",sessionType:r,voice:o,ambient:n.ambient});if(process.stdout.isTTY&&(await import("qrcode-terminal")).default.generate(i.join_url,{small:!0}),process.stdout.write(`${i.message_for_user}
|
|
29
29
|
`),process.stdout.write(` mobile/desktop: ${i.join_url}
|
|
30
|
-
`),n.open){let{spawn:a}=await import("child_process"),u=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",c=process.platform==="win32"?["/c","start",'""',i.web_url]:[i.web_url];a(u,c,{detached:!0,stdio:"ignore"}).unref()}}catch(r){j(r)}}),e.command("deep [type]","Start a Flowe Deep Reset (30\u201350 min, two-way voice with Ada; Flowe Pro or a team plan)").option("--voice <name>","override guide voice (ellie, ada, sage)").option("--ambient <id>","ambient soundscape id (default: none)").option("--open","open the live session in your browser automatically").action(async(t,n)=>{try{let r=t?Ni(t):"ht_stress",o=n.voice?Ot(n.voice):void 0,{createAndStartLiveSession:s}=await import("./session-client-
|
|
30
|
+
`),n.open){let{spawn:a}=await import("child_process"),u=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",c=process.platform==="win32"?["/c","start",'""',i.web_url]:[i.web_url];a(u,c,{detached:!0,stdio:"ignore"}).unref()}}catch(r){j(r)}}),e.command("deep [type]","Start a Flowe Deep Reset (30\u201350 min, two-way voice with Ada; Flowe Pro or a team plan)").option("--voice <name>","override guide voice (ellie, ada, sage)").option("--ambient <id>","ambient soundscape id (default: none)").option("--open","open the live session in your browser automatically").action(async(t,n)=>{try{let r=t?Ni(t):"ht_stress",o=n.voice?Ot(n.voice):void 0,{createAndStartLiveSession:s}=await import("./session-client-XHJ2MGA5.js"),i=await s({tier:"deep",sessionType:r,voice:o,ambient:n.ambient});if(process.stdout.isTTY&&(await import("qrcode-terminal")).default.generate(i.join_url,{small:!0}),process.stdout.write(`${i.message_for_user}
|
|
31
31
|
`),process.stdout.write(` mobile/desktop: ${i.join_url}
|
|
32
32
|
`),n.open){let{spawn:a}=await import("child_process"),u=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open",c=process.platform==="win32"?["/c","start",'""',i.web_url]:[i.web_url];a(u,c,{detached:!0,stdio:"ignore"}).unref()}}catch(r){j(r)}}),e.command("nsdr [type]","Start an NSDR Quick Reset session (default: quick_reset; or pass a Core 8 type)").action(async t=>{try{let n=t?$t(t):"quick_reset",r=await rn(n);process.stdout.write(`${r.message_for_user}
|
|
33
33
|
`)}catch(n){j(n)}}),e.command("break [type]","Stream and play a 5- or 15-minute NSDR reset (default: quick_reset)").option("--duration <minutes>","session length: 5 or 15",{default:"5"}).option("--voice <name>","override the configured voice (sage, ada, ellie)").action(async(t,n)=>{try{let r=t?$t(t):"quick_reset",o=parseInt(n.duration,10);if(o!==5&&o!==15)throw Object.assign(new Error("--duration must be 5 or 15"),{code:"invalid_duration"});let s=n.voice?n.voice==="sage"||n.voice==="ada"||n.voice==="ellie"?n.voice:(()=>{throw Object.assign(new Error("--voice must be sage, ada, or ellie"),{code:"invalid_duration"})})():void 0,i=new AbortController,a=()=>i.abort();process.on("SIGINT",a),process.stdout.write(` ${r} \xB7 ${o}min \xB7 ${s??q().voice}
|
|
@@ -58,14 +58,14 @@ available: sage, ada, ellie
|
|
|
58
58
|
`);return}try{let n=Ot(t);Qe(n),process.stdout.write(`voice set to ${n}
|
|
59
59
|
`)}catch(n){j(n)}}),e.command("protocols","List bundled reset protocols").action(()=>{let t=Ut();if(t.length===0){process.stdout.write(`(no protocols bundled yet)
|
|
60
60
|
`);return}for(let n of t)process.stdout.write(`${n.duration_seconds}s ${n.protocol_id.padEnd(24)} ${n.display_name}
|
|
61
|
-
`)}),e.command("login","Sign in with Clerk (device-grant flow)").action(async()=>{try{let{runLogin:t}=await import("./login-
|
|
61
|
+
`)}),e.command("login","Sign in with Clerk (device-grant flow)").action(async()=>{try{let{runLogin:t}=await import("./login-IDFOVWCU.js");await t()}catch(t){j(t)}}),e.command("logout","Sign out and clear stored token").action(async()=>{await Gt(),process.stdout.write(`signed out
|
|
62
62
|
`)}),e.command("whoami","Show current auth status and Flowe plan").action(async()=>{if(!await V()){process.stdout.write(`not signed in \u2014 run: flowe login
|
|
63
|
-
`);return}try{let{fetchAccountStatus:n,teamLine:r}=await import("./session-client-
|
|
63
|
+
`);return}try{let{fetchAccountStatus:n,teamLine:r}=await import("./session-client-XHJ2MGA5.js"),o=await n();if(!o.authenticated){process.stdout.write(`session expired \u2014 run: flowe login
|
|
64
64
|
`);return}let s=o.first_name?`${o.first_name}${o.email?` (${o.email})`:""}`:o.email??"signed in",i=o.is_pro?"Flowe Pro":o.plan_type;process.stdout.write(`signed in \xB7 ${s} \xB7 ${i}
|
|
65
65
|
`);let a=r(o);if(a&&process.stdout.write(`${a}
|
|
66
66
|
`),o.quick_reset_quota&&o.quick_reset_quota.cap>0){let u=Math.max(0,o.quick_reset_quota.cap-o.quick_reset_quota.used);process.stdout.write(`quick resets: ${u} of ${o.quick_reset_quota.cap} free left this week
|
|
67
67
|
`)}}catch{process.stdout.write(`signed in
|
|
68
|
-
`)}}),e.command("setup [harness]","Configure Flowe MCP Apps for Claude Desktop, Claude Code, Antigravity, Codex, Cursor, or VS Code").option("--write","write the config directly to the harness config file").option("--dry-run","preview the merged config without writing").action(async(t,n)=>{try{let{HARNESS_IDS:r,resolveHarnessTargets:o,buildHarnessSnippet:s,applyHarnessConfig:i}=await import("./setup-harness-
|
|
68
|
+
`)}}),e.command("setup [harness]","Configure Flowe MCP Apps for Claude Desktop, Claude Code, Antigravity, Codex, Cursor, or VS Code").option("--write","write the config directly to the harness config file").option("--dry-run","preview the merged config without writing").action(async(t,n)=>{try{let{HARNESS_IDS:r,resolveHarnessTargets:o,buildHarnessSnippet:s,applyHarnessConfig:i}=await import("./setup-harness-DWVJK4N5.js"),a=o();if(!t){process.stdout.write(`Available harnesses for Flowe MCP:
|
|
69
69
|
|
|
70
70
|
`);for(let c of r){let l=a[c],d=l.supportsMcpApps?"MCP Apps UI":"CLI / text";process.stdout.write(` ${c.padEnd(16)} ${l.label.padEnd(18)} [${d}] ${l.configPath}
|
|
71
71
|
`)}process.stdout.write("\nRun `flowe setup <harness>` to print config, or `flowe setup <harness> --write` to install.\n");return}if(!r.includes(t))throw Object.assign(new Error(`unknown harness "${t}" \u2014 available: ${r.join(", ")}`),{code:"invalid_duration"});let u=a[t];if(n.write||n.dryRun){let c=i(u,{dryRun:!!n.dryRun});n.dryRun?process.stdout.write(`# target: ${c.path}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{a as p,j as f}from"./chunk-
|
|
1
|
+
import{a as p,j as f}from"./chunk-DX2IZG3L.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-
|
|
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-6WIWKE2Q.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};
|
package/dist/mcp-server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as P,b as k,c as E,e as L,j as Q,k as W,l as V,m as D,o as R,s as Y,v as X}from"./chunk-
|
|
1
|
+
import{a as P,b as k,c as E,e as L,j as Q,k as W,l as V,m as D,o as R,s as Y,v as X}from"./chunk-3KM7AYV7.js";import{e as G,f as B,i as J,j as K}from"./chunk-3TLGYA6M.js";import{a as Z,b as ee,c as te,d as T,e as oe,f as w,g as U,i as se,j as ne,k as ie}from"./chunk-JTAA4OAX.js";import{a as q,b as j,e as z,f as g,g as h,h as H}from"./chunk-DX2IZG3L.js";import{McpServer as qe}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as je}from"@modelcontextprotocol/sdk/server/stdio.js";import{registerAppResource as _e,registerAppTool as m,RESOURCE_MIME_TYPE as fe}from"@modelcontextprotocol/ext-apps/server";import{z as i}from"zod/v4";import{existsSync as ce,mkdirSync as Re,readFileSync as xe,renameSync as Ee,writeFileSync as Te}from"fs";import{join as Fe}from"path";var Ce="mcp-session.json",Me=300*1e3,Ie=14400*1e3;function ue(){return Fe(D(),Ce)}function F(t){return{version:1,session_started_at:t,last_reset_at:null,last_suggested_at:null,snoozed_until:null,resets_this_session:0}}function C(t=Date.now()){let e=ue();if(!ce(e)){let o=F(t);return y(o),o}try{let o=JSON.parse(xe(e,"utf-8"));if(o.version!==1||typeof o.session_started_at!="number"){let n=F(t);return y(n),n}let s=Math.max(o.session_started_at,o.last_reset_at??0,o.last_suggested_at??0);if(t-s>Ie){let n=F(t);return y(n),n}return{version:1,session_started_at:o.session_started_at,last_reset_at:o.last_reset_at??null,last_suggested_at:o.last_suggested_at??null,snoozed_until:o.snoozed_until??null,resets_this_session:o.resets_this_session??0}}catch{let o=F(t);return y(o),o}}function y(t){let e=D();ce(e)||Re(e,{recursive:!0});let o=ue(),s=`${o}.tmp`;Te(s,JSON.stringify(t,null,2),"utf-8"),Ee(s,o)}function le(t=Date.now()){let e=C(t);return e.last_suggested_at=t,y(e),e}function M(t=Date.now()){let e=C(t);return e.last_reset_at=t,e.resets_this_session+=1,y(e),e}function de(t,e=Date.now()){let o=Math.max(1,Math.min(240,Math.round(t))),s=C(e);return s.snoozed_until=e+o*60*1e3,y(s),s}function I(t={}){let e=t.nowMs??Date.now(),o=t.cooldownMs??Me,s=C(e),n=R({now:()=>e}),r=Q(),a=Math.max(0,Math.round((e-s.session_started_at)/6e4)),c=s.last_reset_at!==null?Math.max(0,e-s.last_reset_at):null,u=c!==null?Math.round(c/6e4):null,d=c!==null?Math.max(0,o-c):0,v=s.snoozed_until!==null?Math.max(0,s.snoozed_until-e):0,f=null;r?f="opted_out":v>0?f="snoozed":n&&(n.status==="BREAK"||n.status==="LONG_BREAK")?f="focus_break_active":d>0&&(f="cooldown");let x="micro";if(t.authenticated){let S=u??a;S>=120?x="deep":S>=45&&(x="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(v/6e4),resets_this_session:s.resets_this_session,sessions_today:g(new Date(e)),streak_days:h(new Date(e)),total_sessions:H(),active_focus:n,recommended_tier:x}}import{existsSync as Oe,readFileSync as De}from"fs";import{dirname as Ue,join as pe,resolve as Ae}from"path";import{fileURLToPath as Ne}from"url";var l="ui://flowe/micro.html",_="ui://flowe/live-session.html",A={ui:{prefersBorder:!1,csp:{connectDomains:[],resourceDomains:[]}}},N={ui:{prefersBorder:!1,permissions:{microphone:{}},csp:{connectDomains:["https://www.flowe.ai","https://flowe.ai","wss://*.livekit.cloud","https://*.livekit.cloud"],resourceDomains:[]}}},me=new Map;function $e(t,e=import.meta.url){let o=Ue(Ne(e));for(let s=0;s<4;s++){let n=[pe(o,"ui",t),pe(o,"dist","ui",t)];for(let a of n)if(Oe(a))return a;let r=Ae(o,"..");if(r===o)break;o=r}return null}function Pe(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 $(t){let e=me.get(t);if(e)return e;let o=$e(t);if(o){let s=De(o,"utf-8");return me.set(t,s),s}return Pe(t==="live-session.html"?"Flowe Live Session":"Flowe")}function b(){return{authenticated:!1,first_name:null,email:null,is_pro:!1,plan_type:"guest",quick_reset_quota:null}}var he=["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
2
|
`),we=["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
3
|
`),ye=["Run an instant 30, 45, 60, or 90-second micro-reset for the human operator (no account needed)","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
4
|
`),O=["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.","A free account gets 5 Quick Resets a week; Flowe Pro, alone or through a team, is unlimited.","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(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-M56P7SDZ.js";import"./chunk-DX2IZG3L.js";export{a as fetchMe,b as refreshUserFirstName};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-JTAA4OAX.js";import"./chunk-DX2IZG3L.js";export{c as DEEP_RESET_CATALOG,a as DEEP_RESET_LENGTH,b as QUICK_RESET_CATALOG,l as cancelLiveSession,k as completeLiveSession,j as createAndStartLiveSession,f as fetchAccountStatus,i as planWords,e as pollDeviceAuth,d as startDeviceAuth,h as teamLine,g as teamStoppedSentence};
|
|
@@ -1,4 +1,4 @@
|
|
|
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
|
+
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:!0},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
2
|
command = "${r}"
|
|
3
3
|
args = [${t}]
|
|
4
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(`
|