@flowe-ai/cli 0.1.8 → 0.2.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.
Files changed (36) hide show
  1. package/README.md +86 -7
  2. package/assets/menubar-icon.png +0 -0
  3. package/assets/notification-icon.png +0 -0
  4. package/audio/body_scan_60.ellie.cues.json +21 -21
  5. package/audio/body_scan_60.ellie.mp3 +0 -0
  6. package/audio/box_breath_45.ellie.cues.json +25 -25
  7. package/audio/box_breath_45.ellie.mp3 +0 -0
  8. package/audio/box_breath_60.ellie.cues.json +33 -33
  9. package/audio/box_breath_60.ellie.mp3 +0 -0
  10. package/audio/extended_box_90.ellie.cues.json +49 -49
  11. package/audio/extended_box_90.ellie.mp3 +0 -0
  12. package/audio/eye_rotation_30.ellie.cues.json +11 -11
  13. package/audio/eye_rotation_30.ellie.mp3 +0 -0
  14. package/audio/full_sensory_90.ellie.cues.json +17 -17
  15. package/audio/full_sensory_90.ellie.mp3 +0 -0
  16. package/audio/grounded_feet_45.ellie.cues.json +11 -11
  17. package/audio/grounded_feet_45.ellie.mp3 +0 -0
  18. package/audio/neck_rotation_45.ellie.cues.json +15 -15
  19. package/audio/neck_rotation_45.ellie.mp3 +0 -0
  20. package/audio/palming_60.ellie.cues.json +17 -17
  21. package/audio/palming_60.ellie.mp3 +0 -0
  22. package/audio/physiological_sigh_30.ellie.cues.json +13 -13
  23. package/audio/physiological_sigh_30.ellie.mp3 +0 -0
  24. package/audio/progressive_palming_90.ellie.cues.json +19 -19
  25. package/audio/progressive_palming_90.ellie.mp3 +0 -0
  26. package/audio/quick_palming_30.ellie.cues.json +11 -11
  27. package/audio/quick_palming_30.ellie.mp3 +0 -0
  28. package/bin/flowe.js +0 -0
  29. package/bin/menubar/flowe.1s.sh +96 -0
  30. package/dist/ambient-SIMIQWQM.js +1 -0
  31. package/dist/chunk-AX3TLBEV.js +2 -0
  32. package/dist/{chunk-CGFAXS4S.js → chunk-C6NO4B4N.js} +2 -2
  33. package/dist/cli.js +62 -23
  34. package/dist/mcp-server.js +1 -1
  35. package/package.json +6 -2
  36. package/skills/flowe/SKILL.md +69 -6
@@ -1,61 +1,61 @@
1
1
  {
2
2
  "protocol_id": "progressive_palming_90",
3
3
  "voice": "ellie",
4
- "duration_ms": 36500,
4
+ "duration_ms": 36900,
5
5
  "cues": [
6
6
  {
7
7
  "label": "warm palms",
8
8
  "mode": "palming",
9
- "start_ms": 3240,
10
- "end_ms": 7120
9
+ "start_ms": 3080,
10
+ "end_ms": 6700
11
11
  },
12
12
  {
13
13
  "label": "cup over eyes",
14
14
  "mode": "palming",
15
- "start_ms": 7120,
16
- "end_ms": 10940
15
+ "start_ms": 6700,
16
+ "end_ms": 10680
17
17
  },
18
18
  {
19
19
  "label": "eye rest",
20
20
  "mode": "palming",
21
- "start_ms": 10940,
22
- "end_ms": 16220
21
+ "start_ms": 10680,
22
+ "end_ms": 15580
23
23
  },
24
24
  {
25
25
  "label": "slow breaths",
26
26
  "mode": "palming",
27
- "start_ms": 16220,
28
- "end_ms": 18500
27
+ "start_ms": 15580,
28
+ "end_ms": 18980
29
29
  },
30
30
  {
31
31
  "label": "soften forehead",
32
32
  "mode": "palming",
33
- "start_ms": 18500,
34
- "end_ms": 19600
33
+ "start_ms": 18980,
34
+ "end_ms": 19980
35
35
  },
36
36
  {
37
37
  "label": "soften jaw",
38
38
  "mode": "palming",
39
- "start_ms": 19600,
40
- "end_ms": 21240
39
+ "start_ms": 19980,
40
+ "end_ms": 21680
41
41
  },
42
42
  {
43
43
  "label": "drop shoulders",
44
44
  "mode": "palming",
45
- "start_ms": 21240,
46
- "end_ms": 24860
45
+ "start_ms": 21680,
46
+ "end_ms": 25240
47
47
  },
48
48
  {
49
49
  "label": "slow breath",
50
50
  "mode": "palming",
51
- "start_ms": 24860,
52
- "end_ms": 26580
51
+ "start_ms": 25240,
52
+ "end_ms": 26840
53
53
  },
54
54
  {
55
55
  "label": "eyes warm dark",
56
56
  "mode": "palming",
57
- "start_ms": 26580,
58
- "end_ms": 31480
57
+ "start_ms": 26840,
58
+ "end_ms": 31800
59
59
  }
60
60
  ]
61
61
  }
@@ -1,39 +1,39 @@
1
1
  {
2
2
  "protocol_id": "quick_palming_30",
3
3
  "voice": "ellie",
4
- "duration_ms": 17700,
4
+ "duration_ms": 19000,
5
5
  "cues": [
6
6
  {
7
7
  "label": "warm palms",
8
8
  "mode": "palming",
9
- "start_ms": 1480,
10
- "end_ms": 4260
9
+ "start_ms": 1540,
10
+ "end_ms": 4320
11
11
  },
12
12
  {
13
13
  "label": "cup over eyes",
14
14
  "mode": "palming",
15
- "start_ms": 4260,
16
- "end_ms": 9100
15
+ "start_ms": 4320,
16
+ "end_ms": 9800
17
17
  },
18
18
  {
19
19
  "label": "breath one",
20
20
  "mode": "palming",
21
- "start_ms": 9100,
22
- "end_ms": 11060,
21
+ "start_ms": 9800,
22
+ "end_ms": 11880,
23
23
  "round": 1
24
24
  },
25
25
  {
26
26
  "label": "breath two",
27
27
  "mode": "palming",
28
- "start_ms": 11060,
29
- "end_ms": 13040,
28
+ "start_ms": 11880,
29
+ "end_ms": 13680,
30
30
  "round": 2
31
31
  },
32
32
  {
33
33
  "label": "breath three",
34
34
  "mode": "palming",
35
- "start_ms": 13040,
36
- "end_ms": 15320,
35
+ "start_ms": 13680,
36
+ "end_ms": 15880,
37
37
  "round": 3
38
38
  }
39
39
  ]
Binary file
package/bin/flowe.js CHANGED
File without changes
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env bash
2
+ # flowe SwiftBar plugin — refresh every 1s (filename suffix .1s.sh).
3
+ #
4
+ # Reads the active focus session's state.json and renders a menubar
5
+ # title plus a dropdown of controls (pause / resume / skip / quit).
6
+ # When no daemon is running, shows "Start pomodoro / dev / ultradian"
7
+ # entries that open Terminal so the picker chain can run.
8
+ #
9
+ # Auto-installed via `flowe install-menubar`, which writes this file
10
+ # into SwiftBar's plugin dir with NODE_BIN + FLOWE_BIN hardcoded to
11
+ # absolute paths. SwiftBar runs under a minimal launchd PATH, so a
12
+ # `#!/usr/bin/env node` shebang resolves to whatever launchd happens
13
+ # to find — often nothing, or an old node. Baking the absolute paths
14
+ # bypasses that entirely.
15
+ #
16
+ # Manual install: copy this file into SwiftBar's plugin dir and either
17
+ # set NODE_BIN + FLOWE_BIN below, or rely on `command -v` resolution.
18
+ #
19
+ # <bitbar.title>flowe focus</bitbar.title>
20
+ # <bitbar.author>flowe.ai</bitbar.author>
21
+ # <bitbar.desc>Active focus cycle status + controls</bitbar.desc>
22
+ # <bitbar.dependencies>flowe</bitbar.dependencies>
23
+ # <swiftbar.hideAbout>true</swiftbar.hideAbout>
24
+ # <swiftbar.hideRunInTerminal>true</swiftbar.hideRunInTerminal>
25
+ # <swiftbar.hideLastUpdated>true</swiftbar.hideLastUpdated>
26
+ # <swiftbar.hideDisablePlugin>true</swiftbar.hideDisablePlugin>
27
+ # <swiftbar.hideSwiftBar>true</swiftbar.hideSwiftBar>
28
+
29
+ set -e
30
+
31
+ # install-menubar replaces these lines with hardcoded absolute paths.
32
+ # When run manually, fall back to PATH resolution.
33
+ NODE_BIN="${NODE_BIN:-}"
34
+ FLOWE_BIN="${FLOWE_BIN:-}"
35
+
36
+ if [ -z "$FLOWE_BIN" ]; then
37
+ if command -v flowe >/dev/null 2>&1; then
38
+ FLOWE_BIN="$(command -v flowe)"
39
+ else
40
+ # Common Homebrew + npm-global fallbacks. SwiftBar inherits a
41
+ # minimal launchd env, so PATH may not include these by default.
42
+ for candidate in \
43
+ /opt/homebrew/bin/flowe \
44
+ /usr/local/bin/flowe \
45
+ "$HOME/.npm-global/bin/flowe" \
46
+ "$HOME/.bun/bin/flowe"
47
+ do
48
+ if [ -x "$candidate" ]; then
49
+ FLOWE_BIN="$candidate"
50
+ break
51
+ fi
52
+ done
53
+ fi
54
+ fi
55
+
56
+ if [ -z "$FLOWE_BIN" ] || [ ! -x "$FLOWE_BIN" ]; then
57
+ echo "flowe ⚠"
58
+ echo "---"
59
+ echo "could not locate the flowe binary"
60
+ echo "---"
61
+ echo "Run \`flowe install-menubar\` from a shell that has flowe on PATH."
62
+ exit 0
63
+ fi
64
+
65
+ if [ -z "$NODE_BIN" ]; then
66
+ if command -v node >/dev/null 2>&1; then
67
+ NODE_BIN="$(command -v node)"
68
+ else
69
+ for candidate in \
70
+ /opt/homebrew/bin/node \
71
+ /usr/local/bin/node \
72
+ "$HOME/.nvm/versions/node/$(ls -1 "$HOME/.nvm/versions/node" 2>/dev/null | tail -1)/bin/node"
73
+ do
74
+ if [ -x "$candidate" ]; then
75
+ NODE_BIN="$candidate"
76
+ break
77
+ fi
78
+ done
79
+ fi
80
+ fi
81
+
82
+ # When we have an absolute node, invoke it directly so we bypass the
83
+ # `#!/usr/bin/env node` shebang inside flowe.js. Without this, SwiftBar's
84
+ # launchd PATH may resolve to an older / missing node and crash on bare
85
+ # `import "stream"` style imports inside the bundled CLI.
86
+ #
87
+ # We also pass --node-bin so the menubar formatter can emit `bash=$NODE_BIN`
88
+ # for every dropdown action (Pause/Skip/Quit/etc). Without that, clicking
89
+ # an action would re-trigger the broken shebang resolution.
90
+ if [ -n "$NODE_BIN" ] && [ -x "$NODE_BIN" ]; then
91
+ exec "$NODE_BIN" "$FLOWE_BIN" focus menubar \
92
+ --flowe-bin "$FLOWE_BIN" \
93
+ --node-bin "$NODE_BIN"
94
+ fi
95
+
96
+ exec "$FLOWE_BIN" focus menubar --flowe-bin "$FLOWE_BIN"
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-AX3TLBEV.js";export{a as DEFAULT_MANIFEST_URL,c as applyAmbientAssetBaseUrl,l as buildAmbientEntries,d as cachePathFor,b as defaultManifestUrl,j as downloadAmbient,i as fetchAmbientManifest,h as isCached,e as loadCustomAmbientManifest,f as mergeAmbientManifests,g as saveCustomAmbientSound,m as selectableIndices,k as startAmbientFile};
@@ -0,0 +1,2 @@
1
+ import{spawn as y}from"child_process";import{createHash as A}from"crypto";import{createWriteStream as v,existsSync as h,mkdirSync as T,readFileSync as E,statSync as k,unlinkSync as M,writeFileSync as P}from"fs";import{homedir as C,platform as L}from"os";import{dirname as O,join as g}from"path";import{Readable as I}from"stream";import{pipeline as R}from"stream/promises";var F="https://www.flowe.ai/cli/ambient/manifest.json",N=5e3,U=3e4,D=29e3,$=900;function B(){return process.env.FLOWE_AMBIENT_MANIFEST_URL||F}function j(){return process.env.FLOWE_AMBIENT_ASSET_BASE_URL||null}function J(t){try{return new URL(t).pathname.split("/").filter(Boolean).pop()||t}catch{return t.split("/").filter(Boolean).pop()||t}}function W(t,e=j()){if(!e)return t;let n=e.replace(/\/+$/,"");return{...t,sounds:t.sounds.map(o=>({...o,url:`${n}/${encodeURIComponent(J(o.url))}`}))}}function w(){let t=C(),e=L()==="win32"?g(t,"AppData","Roaming","flowe"):g(t,".config","flowe");return g(e,"cache","ambient")}function x(){return g(w(),"custom-manifest.json")}function S(t){return g(w(),`${t.sha256}.mp3`)}function H(){let t=x();if(!h(t))return null;try{let e=JSON.parse(E(t,"utf-8"));return e.version!==1||!Array.isArray(e.categories)||!Array.isArray(e.sounds)?null:e}catch{return null}}function nt(t,e){if(!t&&!e)return null;if(!t)return e;if(!e||e.sounds.length===0)return t;let n=new Set(t.categories.map(r=>r.id)),o=[...t.categories];for(let r of e.categories)n.has(r.id)||(n.add(r.id),o.push(r));let i=new Set(t.sounds.map(r=>r.id)),s=[...t.sounds];for(let r of e.sounds)i.has(r.id)||(i.add(r.id),s.push(r));return{version:1,generated_at:t.generated_at,categories:o,sounds:s}}function rt(t){let e=Buffer.from(t.bytes),n=A("sha256").update(e).digest("hex"),o=`custom_${n.slice(0,12)}`,i=(t.name.trim()||"custom ambience").slice(0,48),s={id:o,category:"custom",name:i,blurb:"generated ambience",url:`flowe-local://ambient/custom/${o}.mp3`,sha256:n,bytes:e.byteLength};T(w(),{recursive:!0}),P(S(s),e);let r=H(),c=[s,...r?.sounds.filter(m=>m.id!==o)??[]],d={version:1,generated_at:(t.now??(()=>new Date))().toISOString(),categories:[{id:"custom",label:"custom"}],sounds:c};return P(x(),JSON.stringify(d,null,2)+`
2
+ `,"utf-8"),s}function q(t){let e=S(t);if(!h(e))return!1;try{let n=E(e);return A("sha256").update(n).digest("hex")===t.sha256}catch{return!1}}async function ot(t){let e=t?.url??B(),n=t?.timeoutMs??N,o=new AbortController,i=setTimeout(()=>o.abort(),n);t?.signal&&(t.signal.aborted?o.abort():t.signal.addEventListener("abort",()=>o.abort()));try{let s=await fetch(e,{signal:o.signal});if(!s.ok)throw new Error(`manifest fetch failed: ${s.status}`);let r=await s.json();if(!r.sounds||!r.categories)throw new Error("manifest shape invalid");return W(r)}finally{clearTimeout(i)}}async function it(t,e){let n=S(t);if(q(t))return e?.onProgress?.({downloaded:t.bytes,total:t.bytes}),n;T(O(n),{recursive:!0});let o=e?.timeoutMs??U,i=new AbortController,s=setTimeout(()=>i.abort(),o);e?.signal&&(e.signal.aborted?i.abort():e.signal.addEventListener("abort",()=>i.abort()));let r=`${n}.part`;try{let c=await fetch(t.url,{signal:i.signal});if(!c.ok||!c.body)throw new Error(`download failed: ${c.status}`);let d=t.bytes,m=0,f=A("sha256"),p=c.body.getReader(),b=new I({read(){p.read().then(({value:u,done:_})=>{if(_){this.push(null);return}m+=u.byteLength,f.update(u),e?.onProgress?.({downloaded:m,total:d}),this.push(Buffer.from(u))}).catch(u=>this.destroy(u))}});if(await R(b,v(r)),f.digest("hex")!==t.sha256){try{M(r)}catch{}throw new Error("sha256 mismatch")}let{renameSync:l}=await import("fs");return l(r,n),n}catch(c){try{h(r)&&M(r)}catch{}throw c}finally{clearTimeout(s)}}function z(t){return process.platform==="darwin"?y("afplay",[t],{stdio:"ignore"}):process.platform==="win32"?y("powershell",["-NoProfile","-Command",`(New-Object Media.SoundPlayer '${t}').PlaySync()`],{stdio:"ignore"}):y("mpg123",["-q",t],{stdio:"ignore"})}function st(t,e={}){if(!t||!h(t))return{stop:()=>{}};try{if(k(t).size<=0)return{stop:()=>{}}}catch{return{stop:()=>{}}}let n=!1,o=null,i=null,s=new Set,r=new Set,c=e.loopRestartMs??D,d=e.overlapMs??$,m=e.spawnPlayer??z,f=()=>{i&&(clearTimeout(i),i=null);for(let a of s)clearTimeout(a);s.clear()},p=a=>{if(a&&!a.killed)try{a.kill("SIGTERM")}catch{}},b=()=>{if(n)return;let a=o,l;try{l=m(t)}catch{n=!0;return}if(o=l,r.add(l),a&&a!==l){let u=setTimeout(()=>{s.delete(u),p(a)},d);s.add(u)}i=setTimeout(()=>{i=null,b()},c),l.on("exit",()=>{r.delete(l),!n&&o===l&&(i&&(clearTimeout(i),i=null),b())}),l.on("error",()=>{n=!0,f()})};return b(),{stop:()=>{n=!0,f(),o=null;for(let a of r)p(a);r.clear()}}}function at(t){let e=[{kind:"none"}];if(!t)return e;for(let n of t.categories){let o=t.sounds.filter(i=>i.category===n.id);if(o.length!==0){e.push({kind:"category",categoryId:n.id,label:n.label});for(let i of o)e.push({kind:"sound",sound:i})}}return e}function ct(t){let e=[];for(let n=0;n<t.length;n++)t[n].kind!=="category"&&e.push(n);return e}export{F as a,B as b,W as c,S as d,H as e,nt as f,rt as g,q as h,ot as i,it as j,st as k,at as l,ct as m};
@@ -1,3 +1,3 @@
1
- import{a as p,c as R,i as _}from"./chunk-P2IV5O3T.js";import{readFileSync as V}from"fs";import{dirname as q,join as J}from"path";import{fileURLToPath as Q}from"url";var U=q(Q(import.meta.url));function E(){try{let e=V(J(U,"..","package.json"),"utf-8");return JSON.parse(e).version}catch{return"0.0.0"}}var pe=["logic_lock","deploy_anxiety","context_switch","sprint_prep","quick_reset","executive_reset","presentation_prep","shutdown"];import{readFileSync as k}from"fs";import{dirname as B,join as h}from"path";import{fileURLToPath as L}from"url";var v=B(L(import.meta.url));function Y(){return h(v,"..","protocols.json")}var l=null;function w(){if(l)return l;try{let e=k(Y(),"utf-8");return l=JSON.parse(e),l}catch{return l={protocols:{},audio_paths:{},cues_paths:{}},l}}function x(){return Object.values(w().protocols)}function P(e){return e.replace(/_\d+$/,"")}function he(){let e=new Set;for(let o of x())e.add(P(o.protocol_id));return[...e].sort()}function ve(e){return x().filter(o=>P(o.protocol_id)===e).map(o=>o.duration_seconds).sort((o,r)=>o-r)}function T(e,o){let r=x().filter(n=>n.duration_seconds===e&&(o===void 0||P(n.protocol_id)===o));return r.length===0?null:o!==void 0?r[0]:r[Math.floor(Math.random()*r.length)]}function j(e,o){let r=w(),n=`${e}.${o}`,t=r.audio_paths[n];return t?h(v,"..",t):null}var f=new Map;function $(e,o){let r=`${e}.${o}`,n=f.get(r);if(n!==void 0)return n;let i=w().cues_paths?.[r];if(!i)return f.set(r,null),null;try{let s=k(h(v,"..",i),"utf-8"),a=JSON.parse(s);return f.set(r,a),a}catch{return f.set(r,null),null}}import z from"sound-play";var c=null;function F(){return c!==null}function Ce(){return c?.donePromise??null}async function M(e){if(c)throw new Error("already playing \u2014 call stopAudio first");let o,r,n=new Promise((s,a)=>{o=s,r=a}),t=z.play(e),i=!1;return c={stop:()=>{i=!0,o(),c=null},donePromise:n},t.then(()=>{i||(o(),c=null)}).catch(s=>{c=null,r(s instanceof Error?s:new Error(String(s)))}),n}import{nanoid as ne}from"nanoid";import{readFileSync as H,writeFileSync as G,mkdirSync as K,existsSync as S,appendFileSync as W}from"fs";import{homedir as X}from"os";import{join as N}from"path";var C=N(X(),".cache","flowe"),d=N(C,"pending-events.jsonl"),Z=5e3;async function g(e,o,r){if(o.telemetry!=="off"){ee(),oe(e);try{await re(o,r)}catch{}}}function ee(){S(C)||K(C,{recursive:!0})}function oe(e){for(let o of e)W(d,JSON.stringify(o)+`
1
+ import{a as p,c as R,i as _}from"./chunk-P2IV5O3T.js";import{readFileSync as V}from"fs";import{dirname as q,join as J}from"path";import{fileURLToPath as Q}from"url";var U=q(Q(import.meta.url));function E(){try{let e=V(J(U,"..","package.json"),"utf-8");return JSON.parse(e).version}catch{return"0.0.0"}}var pe=["logic_lock","deploy_anxiety","context_switch","sprint_prep","quick_reset","executive_reset","presentation_prep","shutdown"];import{readFileSync as k}from"fs";import{dirname as B,join as h}from"path";import{fileURLToPath as L}from"url";var v=B(L(import.meta.url));function Y(){return h(v,"..","protocols.json")}var l=null;function w(){if(l)return l;try{let e=k(Y(),"utf-8");return l=JSON.parse(e),l}catch{return l={protocols:{},audio_paths:{},cues_paths:{}},l}}function x(){return Object.values(w().protocols)}function P(e){return e.replace(/_\d+$/,"")}function he(){let e=new Set;for(let o of x())e.add(P(o.protocol_id));return[...e].sort()}function ve(e){return x().filter(o=>P(o.protocol_id)===e).map(o=>o.duration_seconds).sort((o,r)=>o-r)}function T(e,o){let r=x().filter(n=>n.duration_seconds===e&&(o===void 0||P(n.protocol_id)===o));return r.length===0?null:o!==void 0?r[0]:r[Math.floor(Math.random()*r.length)]}function j(e,o){let r=w(),n=`${e}.${o}`,t=r.audio_paths[n];return t?h(v,"..",t):null}var f=new Map;function $(e,o){let r=`${e}.${o}`,n=f.get(r);if(n!==void 0)return n;let i=w().cues_paths?.[r];if(!i)return f.set(r,null),null;try{let s=k(h(v,"..",i),"utf-8"),a=JSON.parse(s);return f.set(r,a),a}catch{return f.set(r,null),null}}import z from"sound-play";var c=null;function F(){return c!==null}function Ce(){return c?.donePromise??null}async function M(e){if(c)throw new Error("already playing \u2014 call stopAudio first");let o,r,n=new Promise((s,a)=>{o=s,r=a}),t=z.play(e),i=!1;return c={stop:()=>{i=!0,o(),c=null},donePromise:n},t.then(()=>{i||(o(),c=null)}).catch(s=>{c=null,r(s instanceof Error?s:new Error(String(s)))}),n}function Se(){c&&c.stop()}import{nanoid as ne}from"nanoid";import{readFileSync as H,writeFileSync as G,mkdirSync as K,existsSync as S,appendFileSync as W}from"fs";import{homedir as X}from"os";import{join as N}from"path";var C=N(X(),".cache","flowe"),d=N(C,"pending-events.jsonl"),Z=5e3;async function g(e,o,r){if(o.telemetry!=="off"){ee(),oe(e);try{await re(o,r)}catch{}}}function ee(){S(C)||K(C,{recursive:!0})}function oe(e){for(let o of e)W(d,JSON.stringify(o)+`
2
2
  `,"utf-8")}function te(){return S(d)?H(d,"utf-8").split(`
3
- `).filter(o=>o.trim().length>0).map(o=>JSON.parse(o)):[]}function O(){S(d)&&G(d,"","utf-8")}async function re(e,o){let r=te();if(r.length===0)return;let n={version:E(),platform:`${process.platform}-${process.arch}`,node_version:process.version},t=new AbortController,i=setTimeout(()=>t.abort(),Z);try{let s={"Content-Type":"application/json"};o&&(s.Authorization=`Bearer ${o}`);let a=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:t.signal});(a.ok||a.status===401||a.status===400)&&O()}finally{clearTimeout(i)}}function se(e,o,r){if(e.length===0)return[];let t=o*1e3/e.length;return e.map((i,s)=>({label:i,mode:r,start_ms:Math.round(s*t),end_ms:Math.round((s+1)*t)}))}async function Ae(e,o="user_requested",r){if(F())throw Object.assign(new Error("a reset is already running"),{code:"agent_busy"});let n=p(),t=T(e,r);if(!t){let A=r?`${r} at ${e}s`:`${e}s`;throw Object.assign(new Error(`no protocol available for ${A}`),{code:"protocol_unavailable"})}let i=j(t.protocol_id,n.voice);if(!i)throw Object.assign(new Error(`no audio available for ${t.protocol_id}:${n.voice}`),{code:"protocol_unavailable"});let s=`reset_${ne(8)}`,a=new Date,D=Math.floor(a.getTime()/1e3)+e;R();let y=await _();await g([{type:"reset_started",session_id:s,protocol_id:t.protocol_id,duration_seconds:e,voice:n.voice,trigger:o,client_timestamp:a.toISOString()}],n,y),M(i).then(()=>{g([{type:"reset_completed",session_id:s,protocol_id:t.protocol_id,duration_seconds:e,voice:n.voice,trigger:o,client_timestamp:new Date().toISOString()}],n,y).catch(()=>{})}).catch(()=>{g([{type:"reset_abandoned",session_id:s,protocol_id:t.protocol_id,duration_seconds:e,voice:n.voice,trigger:o,client_timestamp:new Date().toISOString()}],n,y).catch(()=>{})});let b=$(t.protocol_id,n.voice),I=b?b.cues:se(t.text_cues,e,t.category);return{session_id:s,protocol:t.protocol_id,protocol_display_name:t.display_name,duration_seconds:e,voice:n.voice,cues:I,rounds:t.rounds,status:"started",ends_at_unix:D,message_for_user:`${e}s ${t.display_name} started \xB7 ${n.voice}`}}import ie from"qrcode-terminal";async function Be(e="quick_reset",o={}){let r=p(),n=await _();if(!n)throw Object.assign(new Error("sign in with: flowe login"),{code:"auth_required"});let t;try{t=await fetch(`${r.backend_url}/api/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({protocolId:"nsdr",sessionType:e})})}catch{throw Object.assign(new Error("network unreachable \u2014 try: flowe reset"),{code:"network_error"})}if(!t.ok)throw t.status===401?Object.assign(new Error("session expired \u2014 run: flowe login"),{code:"auth_required"}):Object.assign(new Error(`server error ${t.status}`),{code:"network_error"});let i=await t.json(),s=`flowe://session/${i.session_id}`;return!o.suppressQr&&process.stdout.isTTY&&ie.generate(s,{small:!0}),{session_id:i.session_id,session_type:i.session_type,session_type_name:i.session_type_name,estimated_duration:i.estimated_duration,join_url:s,status:"waiting_for_join",message_for_user:`${i.session_type_name} (${i.estimated_duration}min) ready \xB7 ${s}`}}export{E as a,pe as b,x as c,he as d,ve as e,Ce as f,Ae as g,Be as h};
3
+ `).filter(o=>o.trim().length>0).map(o=>JSON.parse(o)):[]}function O(){S(d)&&G(d,"","utf-8")}async function re(e,o){let r=te();if(r.length===0)return;let n={version:E(),platform:`${process.platform}-${process.arch}`,node_version:process.version},t=new AbortController,i=setTimeout(()=>t.abort(),Z);try{let s={"Content-Type":"application/json"};o&&(s.Authorization=`Bearer ${o}`);let a=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:t.signal});(a.ok||a.status===401||a.status===400)&&O()}finally{clearTimeout(i)}}function se(e,o,r){if(e.length===0)return[];let t=o*1e3/e.length;return e.map((i,s)=>({label:i,mode:r,start_ms:Math.round(s*t),end_ms:Math.round((s+1)*t)}))}async function Ve(e,o="user_requested",r){if(F())throw Object.assign(new Error("a reset is already running"),{code:"agent_busy"});let n=p(),t=T(e,r);if(!t){let A=r?`${r} at ${e}s`:`${e}s`;throw Object.assign(new Error(`no protocol available for ${A}`),{code:"protocol_unavailable"})}let i=j(t.protocol_id,n.voice);if(!i)throw Object.assign(new Error(`no audio available for ${t.protocol_id}:${n.voice}`),{code:"protocol_unavailable"});let s=`reset_${ne(8)}`,a=new Date,D=Math.floor(a.getTime()/1e3)+e;R();let y=await _();await g([{type:"reset_started",session_id:s,protocol_id:t.protocol_id,duration_seconds:e,voice:n.voice,trigger:o,client_timestamp:a.toISOString()}],n,y),M(i).then(()=>{g([{type:"reset_completed",session_id:s,protocol_id:t.protocol_id,duration_seconds:e,voice:n.voice,trigger:o,client_timestamp:new Date().toISOString()}],n,y).catch(()=>{})}).catch(()=>{g([{type:"reset_abandoned",session_id:s,protocol_id:t.protocol_id,duration_seconds:e,voice:n.voice,trigger:o,client_timestamp:new Date().toISOString()}],n,y).catch(()=>{})});let b=$(t.protocol_id,n.voice),I=b?b.cues:se(t.text_cues,e,t.category);return{session_id:s,protocol:t.protocol_id,protocol_display_name:t.display_name,duration_seconds:e,voice:n.voice,cues:I,rounds:t.rounds,status:"started",ends_at_unix:D,message_for_user:`${e}s ${t.display_name} started \xB7 ${n.voice}`}}import ie from"qrcode-terminal";async function Le(e="quick_reset",o={}){let r=p(),n=await _();if(!n)throw Object.assign(new Error("sign in with: flowe login"),{code:"auth_required"});let t;try{t=await fetch(`${r.backend_url}/api/v1/sessions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({protocolId:"nsdr",sessionType:e})})}catch{throw Object.assign(new Error("network unreachable \u2014 try: flowe reset"),{code:"network_error"})}if(!t.ok)throw t.status===401?Object.assign(new Error("session expired \u2014 run: flowe login"),{code:"auth_required"}):Object.assign(new Error(`server error ${t.status}`),{code:"network_error"});let i=await t.json(),s=`flowe://session/${i.session_id}`;return!o.suppressQr&&process.stdout.isTTY&&ie.generate(s,{small:!0}),{session_id:i.session_id,session_type:i.session_type,session_type_name:i.session_type_name,estimated_duration:i.estimated_duration,join_url:s,status:"waiting_for_join",message_for_user:`${i.session_type_name} (${i.estimated_duration}min) ready \xB7 ${s}`}}export{E as a,pe as b,x as c,he as d,ve as e,Ce as f,M as g,Se as h,Ve as i,Le as j};