loopable-cli 0.2.0 → 0.2.1

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 (65) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/_connectorId-CkygNLny.js +1 -0
  3. package/.output/public/assets/_loopId-Cshlc5Ja.js +1 -0
  4. package/.output/public/assets/_taskId-BKDIJ_Fg.js +1 -0
  5. package/.output/public/assets/connector-icon-BUoK6Cru.js +1 -0
  6. package/.output/public/assets/connectors-CeLBtEtg.js +1 -0
  7. package/.output/public/assets/gaps-BtFoD7mF.js +1 -0
  8. package/.output/public/assets/{inbox-CLEXUXCI.js → inbox-BYNjkNDJ.js} +1 -1
  9. package/.output/public/assets/index-0yP3Jn_G.js +18 -0
  10. package/.output/public/assets/loop-form-DnSJNc1k.js +1 -0
  11. package/.output/public/assets/loops-1CvbqO6m.js +1 -0
  12. package/.output/public/assets/{new-DPEaXKAY.js → new-m5NlqYQT.js} +1 -1
  13. package/.output/public/assets/refresh-cw-C3xBnKfy.js +1 -0
  14. package/.output/public/assets/{runners-BVBggS5B.js → runners-D8QVl-Y6.js} +1 -1
  15. package/.output/public/assets/{setting-fields-BT1naVJX.js → setting-fields-bJ_gTG7Q.js} +1 -1
  16. package/.output/public/assets/styles-ClTGaXU0.css +2 -0
  17. package/.output/public/assets/{task-list-CrptnI1N.js → task-list-BAxjcVgr.js} +1 -1
  18. package/.output/server/{_connectorId-DcSnoRjk.mjs → _connectorId-C9yydJrC.mjs} +90 -9
  19. package/.output/server/{_loopId-G_TAkYtS.mjs → _loopId-B0VG-eBC.mjs} +42 -13
  20. package/.output/server/_ssr/{callback-D20cVD2w.mjs → access-DTttr563.mjs} +37 -20
  21. package/.output/server/_ssr/{agents-Dms_6TBF.mjs → agents-C7B6RJ6-.mjs} +3 -3
  22. package/.output/server/_ssr/{agents-CrUmIQpi.mjs → agents-DG643yoJ.mjs} +2 -2
  23. package/.output/server/_ssr/alert-DQvzE7bu.mjs +1 -1
  24. package/.output/server/_ssr/connection-status-BZr3Y-IC.mjs +1 -1
  25. package/.output/server/_ssr/{connections-ypex3qUd.mjs → connections-Df-aDpfJ.mjs} +814 -15
  26. package/.output/server/_ssr/connector-icon-WvxwZ5TF.mjs +56 -0
  27. package/.output/server/_ssr/{connectors-4yzKb0KG.mjs → connectors-BU0IiRge.mjs} +6 -5
  28. package/.output/server/_ssr/{connectors-BZly0yGF.mjs → connectors-e0mf2pMs.mjs} +14 -3
  29. package/.output/server/_ssr/{gaps-D2Zh8sEo.mjs → gaps-Cz76ZicM.mjs} +6 -6
  30. package/.output/server/_ssr/{inbox-C2VBGLa5.mjs → inbox-CAUBa1I3.mjs} +3 -3
  31. package/.output/server/_ssr/{loop-form-D-U-kU4k.mjs → loop-form-FqSaXiHl.mjs} +5 -5
  32. package/.output/server/_ssr/{loops-Og_G3KyZ.mjs → loops-D8WuK7Ke.mjs} +199 -6
  33. package/.output/server/_ssr/{loops-D0XJ8eBb.mjs → loops-Dqoebe8q.mjs} +6 -6
  34. package/.output/server/_ssr/{new-CajvgIog.mjs → new-bBsVaWD6.mjs} +5 -5
  35. package/.output/server/_ssr/{router-BbrBz36P.mjs → router-54IDWTVz.mjs} +24 -19
  36. package/.output/server/_ssr/{runners-B_WuF8UJ.mjs → runners-Cj6z9Mqh.mjs} +26 -3
  37. package/.output/server/_ssr/{runners-D-0_lfiq.mjs → runners-D2UAdLyj.mjs} +1 -1
  38. package/.output/server/_ssr/{runners-zqF_zbEc.mjs → runners-DGWaVvWi.mjs} +2 -2
  39. package/.output/server/_ssr/{setting-fields-mpXfGftI.mjs → setting-fields-DzBlslan.mjs} +2 -2
  40. package/.output/server/_ssr/ssr.mjs +42 -34
  41. package/.output/server/_ssr/{start-BgTj-h_C.mjs → start-Vq3Oan3v.mjs} +2 -3
  42. package/.output/server/_ssr/switch-1pnd_bPJ.mjs +1 -1
  43. package/.output/server/_ssr/{task-list-BnQJ94Dk.mjs → task-list-_qgBS9LU.mjs} +5 -5
  44. package/.output/server/_ssr/{tasks-B_QmDFVs.mjs → tasks-BDqznm57.mjs} +16 -5
  45. package/.output/server/_ssr/{tasks-LIi-W4cy.mjs → tasks-Qtml5TlK.mjs} +3 -3
  46. package/.output/server/_ssr/textarea-CHJTKtsJ.mjs +1 -1
  47. package/.output/server/{_tanstack-start-manifest_v-BCHAazE8.mjs → _tanstack-start-manifest_v-CvheE7ZF.mjs} +25 -23
  48. package/.output/server/{_taskId-CIv0ajIx.mjs → _taskId-V4QLBO2N.mjs} +4 -4
  49. package/.output/server/index.mjs +139 -132
  50. package/README.md +24 -19
  51. package/dist/cli.mjs +24 -59
  52. package/dist/dispatcher.mjs +811 -31
  53. package/package.json +21 -17
  54. package/.output/public/assets/_connectorId-m67WbiJ8.js +0 -1
  55. package/.output/public/assets/_loopId-Bf4K5sdd.js +0 -1
  56. package/.output/public/assets/_taskId-eCKkcVOx.js +0 -1
  57. package/.output/public/assets/connector-icon-qGpNsPgH.js +0 -1
  58. package/.output/public/assets/connectors-DxXlc9zF.js +0 -1
  59. package/.output/public/assets/gaps-CoTA-PzA.js +0 -1
  60. package/.output/public/assets/index-Cndsw84p.js +0 -16
  61. package/.output/public/assets/loop-form-BvizlZdR.js +0 -1
  62. package/.output/public/assets/loops-Dbe_mf5T.js +0 -1
  63. package/.output/public/assets/styles-D3sonCfX.css +0 -2
  64. package/.output/server/_ssr/access-B7TcOZ7F.mjs +0 -42
  65. package/.output/server/_ssr/connector-icon-CFrrHjzR.mjs +0 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopable-cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI to run Loopable: App, Dispatcher, and Runner.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,6 +29,25 @@
29
29
  "imports": {
30
30
  "#/*": "./src/*"
31
31
  },
32
+ "scripts": {
33
+ "dev": "node --experimental-strip-types scripts/dev.ts",
34
+ "start": "node dist/cli.mjs start",
35
+ "dispatcher": "LOOPABLE_DEV=1 node --experimental-strip-types src/cli.ts dispatcher",
36
+ "runner": "LOOPABLE_DEV=1 node --experimental-strip-types src/cli.ts runner",
37
+ "generate-routes": "tsr generate",
38
+ "build": "vite build && node scripts/build-cli.mjs",
39
+ "preview": "vite preview",
40
+ "test": "vitest run",
41
+ "test:watch": "vitest",
42
+ "db:generate": "drizzle-kit generate",
43
+ "db:studio": "LOOPABLE_DEV=1 drizzle-kit studio",
44
+ "typecheck": "tsc --noEmit",
45
+ "deploy": "LOOPABLE_CF=1 vite build && wrangler deploy",
46
+ "site:dev": "pnpm --filter loopable-site dev",
47
+ "site:build": "pnpm --filter loopable-site build",
48
+ "site:deploy": "pnpm --filter loopable-site deploy",
49
+ "prepublishOnly": "pnpm build && pnpm typecheck"
50
+ },
32
51
  "dependencies": {
33
52
  "@libsql/client": "^0.18.0"
34
53
  },
@@ -69,20 +88,5 @@
69
88
  "vite": "^8.0.0",
70
89
  "vitest": "^4.1.11",
71
90
  "wrangler": "^4.132.0"
72
- },
73
- "scripts": {
74
- "dev": "node --experimental-strip-types scripts/dev.ts",
75
- "start": "node dist/cli.mjs start",
76
- "dispatcher": "LOOPABLE_DEV=1 node --experimental-strip-types src/cli.ts dispatcher",
77
- "runner": "LOOPABLE_DEV=1 node --experimental-strip-types src/cli.ts runner",
78
- "generate-routes": "tsr generate",
79
- "build": "vite build && node scripts/build-cli.mjs",
80
- "preview": "vite preview",
81
- "test": "vitest run",
82
- "test:watch": "vitest",
83
- "db:generate": "drizzle-kit generate",
84
- "db:studio": "LOOPABLE_DEV=1 drizzle-kit studio",
85
- "typecheck": "tsc --noEmit",
86
- "deploy": "LOOPABLE_CF=1 vite build && wrangler deploy"
87
91
  }
88
- }
92
+ }
@@ -1 +0,0 @@
1
- import{n as e,t}from"./rolldown-runtime-CbXtAM7H.js";import{$ as n,C as r,J as i,Yt as a,a as o,c as s,d as c,i as l,l as u,m as d,n as f,o as p,ot as m,q as h,r as g,ut as _,w as v,x as y}from"./preload-helper-CfdAYKD7.js";import{t as b}from"./arrow-left-CWUZt6k2.js";import{it as x,nt as S,ot as C,rt as w}from"./select-Cppu-hti.js";import{t as T}from"./connector-icon-qGpNsPgH.js";import{t as E}from"./external-link-DC11orFA.js";import{t as ee}from"./loader-B4Epchm_.js";import{t as te}from"./trash-2-BXZzBsoV.js";import{C as D,E as O,M as k,S as A,T as j,V as M,m as N,v as P,w as F}from"./index-Cndsw84p.js";import{n as I,t as L}from"./setting-fields-BT1naVJX.js";import{t as R}from"./connection-status-DCqqmY_6.js";import{n as z,r as B,t as V}from"./alert-BT2EVMJP.js";var H=i(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),U=i(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),W=e(a(),1),G=_();function K({fields:e,connection:t}){let n=m(),[r,i]=(0,W.useState)(()=>I(e,t.settings)),[a,o]=(0,W.useState)(!1);return e.length===0?null:(0,G.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,G.jsx)(L,{fields:e,values:r,onChange:(e,t)=>i(n=>({...n,[e]:t}))}),(0,G.jsx)(`div`,{children:(0,G.jsx)(s,{onClick:async()=>{o(!0);try{await j({data:{id:t.id,settings:r}}),await n.invalidate(),h.success(`Settings saved`)}catch(e){h.error(e instanceof Error?e.message:String(e))}finally{o(!1)}},disabled:a,children:a?`Saving...`:`Save settings`})})]})}var ne=2e3;function q({connectorId:e,note:t,onDone:n}){let r=m(),[i,a]=(0,W.useState)(null),[o,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null),[d,p]=(0,W.useState)(!0),_=(0,W.useRef)(null),v=async()=>{p(!0),u(null),c(null);try{let t=await A({data:{connectorId:e}});_.current=t.attempt,a({image:t.image,attempt:t.attempt})}catch(e){u(e instanceof Error?e.message:String(e)),a(null)}finally{p(!1)}};return(0,W.useEffect)(()=>{v()},[e]),(0,W.useEffect)(()=>{if(!i||l)return;let t=!1;return(async()=>{for(;!t;){if(await new Promise(e=>setTimeout(e,ne)),t||_.current===null)return;try{let i=await D({data:{connectorId:e,attempt:_.current}});if(t)return;if(i.state===`connected`){h.success(`Connected ${i.accountLabel??e}`),await r.invalidate(),n?.();return}if(i.state===`expired`){u(i.reason??`The code expired before it was scanned.`);return}_.current=i.attempt,c(i.hint??null)}catch(e){if(t)return;c(e instanceof Error?e.message:String(e))}}})(),()=>{t=!0}},[i,l,e,r,n]),(0,G.jsx)(f,{children:(0,G.jsxs)(g,{className:`flex flex-col items-center gap-4 py-8`,children:[(0,G.jsx)(`p`,{className:`max-w-md text-center text-sm text-muted-foreground`,children:t}),l?(0,G.jsxs)(V,{variant:`destructive`,className:`max-w-md`,children:[(0,G.jsx)(M,{}),(0,G.jsx)(z,{children:l})]}):(0,G.jsx)(`div`,{className:`flex size-[240px] items-center justify-center rounded-lg border bg-white`,children:d||!i?(0,G.jsx)(ee,{className:`size-5 animate-spin text-muted-foreground`}):(0,G.jsx)(`img`,{src:i.image,alt:`Scan with WeChat to connect`,className:`size-[240px]`})}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:l?`Ask for another and scan it this time.`:o??`Waiting for a scan...`}),(0,G.jsx)(s,{variant:l?`default`:`outline`,size:`sm`,onClick:v,disabled:d,children:l?`New code`:`Start over`})]})})}var J=W.createContext(void 0);function Y(){let e=W.useContext(J);if(e===void 0)throw Error(y(13));return e}var X={imageLoadingStatus:()=>null},Z=W.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=W.useState(`idle`),l={imageLoadingStatus:o},u=W.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),d=c(`span`,e,{state:l,ref:t,props:a,stateAttributesMapping:X});return(0,G.jsx)(J.Provider,{value:u,children:d})});function re(e,{referrerPolicy:t,crossOrigin:n,sizes:i,srcSet:a}){let[o,s]=W.useState(`idle`);return r(()=>{if(!e&&!a)return s(`error`),d;let r=!0,o=new window.Image,c=e=>()=>{r&&s(e)};return s(`loading`),o.onload=c(`loaded`),o.onerror=c(`error`),t&&(o.referrerPolicy=t),o.crossOrigin=n??null,i&&(o.sizes=i),a&&(o.srcset=a),e&&(o.src=e),o.complete&&s(o.naturalWidth>0?`loaded`:`error`),()=>{r=!1}},[e,a,i,n,t]),o}var ie={...X,...w},ae=W.forwardRef(function(e,t){let{className:n,render:i,onLoadingStatusChange:a,style:o,...s}=e,{setImageLoadingStatus:l}=Y(),u=re(s.src,s),d=u===`loaded`,{mounted:f,transitionStatus:p,setMounted:m}=S(d),h=W.useRef(null),g=v(e=>{a?.(e),l(e)});r(()=>{u!==`idle`&&g(u)},[u,g]),r(()=>()=>l(`idle`),[l]),x({open:d,ref:h,onComplete(){d||m(!1)}});let _=c(`img`,e,{state:{imageLoadingStatus:u,transitionStatus:p},ref:[t,h],props:s,stateAttributesMapping:ie,enabled:f});return f?_:null}),oe=W.forwardRef(function(e,t){let{className:n,render:r,delay:i=0,style:a,...o}=e,{imageLoadingStatus:s}=Y(),[l,u]=W.useState(i===0),d=C();return W.useEffect(()=>(i>0?d.start(i,()=>u(!0)):u(!0),d.clear),[d,i]),c(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:X,enabled:s!==`loaded`&&(i===0||l)})});function se({className:e,size:t=`default`,...n}){return(0,G.jsx)(Z,{"data-slot":`avatar`,"data-size":t,className:u(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,e),...n})}function Q({className:e,...t}){return(0,G.jsx)(ae,{"data-slot":`avatar-image`,className:u(`aspect-square size-full rounded-full object-cover`,e),...t})}function ce({className:e,...t}){return(0,G.jsx)(oe,{"data-slot":`avatar-fallback`,className:u(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}t(((e,t)=>{t.exports={}}))();function le(){return{}.LOOPABLE_BASE_URL?.replace(/\/$/,``)||null}function ue(e){return e===`127.0.0.1`||e===`localhost`||e===`::1`}function de(e){if(ue(e))return!0;let t=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(e);if(t){let e=Number(t[1]),n=Number(t[2]);return e===10||e===127||e===192&&n===168||e===172&&n>=16&&n<=31||e===169&&n===254}let n=e.toLowerCase();return!!(n.includes(`:`)&&(n.startsWith(`fe80:`)||n.startsWith(`fc`)||n.startsWith(`fd`)))}function fe(){let e=le();if(!e)return null;try{return de(new URL(e).hostname)?null:e}catch{return null}}function pe(e){let t=fe();return t?`${t}/api/connectors/${e}/callback`:`http://127.0.0.1/api/connectors/${e}/callback`}function me(){let{connectorId:e}=N.useParams(),t=N.useLoaderData(),r=P(e),i=r.allowsMultipleAccounts||t.connections.length===0,a=r.auth.kind===`qr_scan`,[c,u]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,G.jsxs)(n,{to:`/connectors`,className:`flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,G.jsx)(b,{className:`size-4`}),`Connectors`]}),(0,G.jsxs)(`header`,{className:`flex items-start gap-4`,children:[(0,G.jsx)(T,{icon:r.icon,accent:r.accent,className:`size-11`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:r.name}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:r.tagline})]}),t.readiness.ready&&i?a?(0,G.jsx)(s,{onClick:()=>u(e=>!e),children:c?`Cancel`:`Connect`}):(0,G.jsx)(s,{render:(0,G.jsx)(`a`,{href:`/api/connectors/${e}/authorize`}),children:t.connections.length>0?`Add another account`:`Connect`}):null]}),c&&r.auth.kind===`qr_scan`?(0,G.jsx)(q,{connectorId:e,note:r.auth.note,onDone:()=>u(!1)}):null,t.readiness.ready?null:(0,G.jsxs)(V,{variant:`destructive`,children:[(0,G.jsxs)(B,{children:[r.name,` is not available in this build`]}),(0,G.jsxs)(z,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`span`,{children:t.readiness.reason}),t.readiness.fixHint?(0,G.jsx)(`span`,{children:t.readiness.fixHint}):null,r.auth.kind===`oauth_redirect`?(0,G.jsxs)(`span`,{className:`text-xs`,children:[`Callback URL to register: `,(0,G.jsx)(`code`,{children:pe(e)})]}):null]})]}),t.connections.length===0&&t.readiness.ready&&!c?(0,G.jsx)(f,{children:(0,G.jsxs)(g,{className:`py-8 text-center text-sm text-muted-foreground`,children:[`No account connected yet.`,r.auth.kind===`oauth_redirect`?(0,G.jsxs)(G.Fragment,{children:[` `,`Connecting opens `,r.name,` and asks for`,` `,r.auth.scopes.join(`, `),`.`]}):null,r.auth.kind===`qr_scan`?` Connecting shows a code to scan.`:null]})}):null,t.connections.map(e=>(0,G.jsx)(he,{connection:e,manifest:r},e.id)),(0,G.jsxs)(f,{children:[(0,G.jsx)(l,{children:(0,G.jsx)(o,{className:`text-base`,children:`What this connector can do`})}),(0,G.jsxs)(g,{className:`flex flex-col gap-4`,children:[(0,G.jsx)($,{title:`Workflows it offers`,note:`Turn one on from the loops page.`,empty:`None yet. An account can be connected, but no loop can be built on it.`,items:r.workflows.map(e=>({id:e.id,name:e.name,summary:e.summary}))}),(0,G.jsx)(k,{}),(0,G.jsx)($,{title:`What it writes`,note:`A loop writes these back on its own.`,empty:`Nothing. Loopable can read this account but cannot write to it.`,items:r.actions.map(e=>({id:e.id,name:e.name,summary:e.summary}))}),r.docsUrl?(0,G.jsxs)(`a`,{href:r.docsUrl,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[`API documentation`,(0,G.jsx)(E,{className:`size-3.5`})]}):null]})]})]})}function $({title:e,note:t,empty:n,items:r}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium`,children:e}),t&&r.length>0?(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t}):null,r.length===0?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:n}):(0,G.jsx)(`ul`,{className:`mt-3 flex flex-col gap-2`,children:r.map(e=>(0,G.jsxs)(`li`,{className:`text-sm`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[` — `,e.summary]})]},e.id))})]})}function he({connection:e,manifest:t}){let n=m(),[r,i]=(0,W.useState)(null),a=e.status===`needs_reauth`||e.status===`error`,o=async t=>{i(t);try{if(t===`verify`){let t=await O({data:{id:e.id}});h[t.status===`connected`?`success`:`error`](t.status===`connected`?`${t.accountLabel} is reachable`:t.lastError??`This connection is not usable`)}else await F({data:{id:e.id}}),h.success(`Disconnected ${e.accountLabel}`);await n.invalidate()}catch(e){h.error(e instanceof Error?e.message:String(e))}finally{i(null)}};return(0,G.jsxs)(f,{children:[(0,G.jsxs)(l,{className:`flex flex-row items-center gap-3`,children:[(0,G.jsxs)(se,{children:[(0,G.jsx)(Q,{src:e.avatarUrl??void 0,alt:e.accountLabel}),(0,G.jsx)(ce,{children:e.accountLabel.slice(0,2).toUpperCase()})]}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.accountLabel}),(0,G.jsx)(R,{status:e.status})]}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.lastSyncedAt?`Last checked ${new Date(e.lastSyncedAt).toLocaleString()}`:`Not checked yet`})]}),(0,G.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>o(`verify`),disabled:r!==null,children:[(0,G.jsx)(H,{className:r===`verify`?`animate-spin`:void 0}),`Verify`]}),a?(0,G.jsxs)(s,{size:`sm`,render:(0,G.jsx)(`a`,{href:`/api/connectors/${e.connectorId}/authorize`}),children:[(0,G.jsx)(U,{}),`Reconnect`]}):null,(0,G.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>o(`disconnect`),disabled:r!==null,children:[(0,G.jsx)(te,{}),`Disconnect`]})]}),(0,G.jsxs)(g,{className:`flex flex-col gap-5 border-t pt-5`,children:[e.lastError?(0,G.jsx)(V,{variant:`destructive`,children:(0,G.jsx)(z,{children:e.lastError})}):null,e.scopes.length>0?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium`,children:`Granted access`}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.scopes.map(e=>(0,G.jsx)(p,{variant:`outline`,children:e},e))})]}):null,(0,G.jsx)(K,{fields:t.settings,connection:e})]})]})}export{me as component};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{$ as t,C as n,J as r,Yt as i,_ as a,b as o,c as s,d as c,f as l,g as u,l as d,n as f,ot as p,p as m,q as h,r as g,u as _,ut as v,w as y,x as b,y as x}from"./preload-helper-CfdAYKD7.js";import{t as S}from"./arrow-left-CWUZt6k2.js";import{t as C}from"./loop-form-BvizlZdR.js";import{C as w,T,_ as E,b as D,bt as O,c as k,ct as A,dt as j,ft as M,g as N,it as P,l as F,lt as I,nt as L,o as R,p as z,rt as B,s as V,ut as H,v as U,w as W,wt as G,x as ee,xt as te,y as ne,yt as re}from"./select-Cppu-hti.js";import{n as ie}from"./task-list-CrptnI1N.js";import{t as ae}from"./play-DD4xQgvi.js";import{S as oe,T as se,d as ce,h as le,i as ue,m as de,s as fe}from"./useValueChanged-VVyq4hb9.js";import{t as pe}from"./switch-hRIbNGOj.js";import{D as me,N as he,P as ge,V as _e,a as ve,l as ye,v as be}from"./index-Cndsw84p.js";import{n as K,r as q,t as J}from"./alert-BT2EVMJP.js";import{n as xe}from"./gaps-CoTA-PzA.js";var Se=r(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Y=e(i(),1),Ce=Y.createContext(void 0);function X(){let e=Y.useContext(Ce);if(e===void 0)throw Error(b(64));return e}var Z={tabActivationDirection:e=>({"data-activation-direction":e})},Q=v(),we=Y.forwardRef(function(e,t){let{className:r,defaultValue:i=0,onValueChange:a,orientation:o=`horizontal`,render:s,value:l,style:u,...d}=e,f=e.defaultValue!==void 0,p=Y.useRef([]),[m,h]=Y.useState(()=>new Map),[g,_]=oe({controlled:l,default:i,name:`Tabs`,state:`value`}),v=l!==void 0,[b,x]=Y.useState(()=>new Map),S=Y.useRef(void 0),C=Y.useCallback(e=>$(b,e),[b]),[w,T]=Y.useState(()=>({previousValue:g,tabActivationDirection:`none`})),{previousValue:E,tabActivationDirection:D}=w,O=D,k=!1;E!==g&&(O=Te(E,g,o,b),k=E!=null&&g!=null&&C(g)==null);let A=k?E:g,j=E!==A||D!==O;n(()=>{j&&T({previousValue:A,tabActivationDirection:O})},[A,j,O]);let M=y((e,t)=>{t.activationDirection=Te(g,e,o,b),a?.(e,t),!t.isCanceled&&_(e)}),N=y((e,t)=>{a?.(e,ue(t,void 0,void 0,{activationDirection:`none`}))}),P=y((e,t)=>(h(n=>{let r=new Map(n);return r.set(e,t),r}),()=>{h(n=>{if(n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})})),F=Y.useCallback(e=>m.get(e),[m]),I=Y.useCallback(e=>{for(let t of b.values())if(e===t.value)return t.id},[b]),L=Y.useMemo(()=>({getTabElementBySelectedValue:C,getTabIdByPanelValue:I,getTabPanelIdByValue:F,onValueChange:M,orientation:o,registerMountedTabPanel:P,setTabMap:x,tabActivationDirection:O,value:g}),[C,I,F,M,o,P,x,O,g]),R=Y.useMemo(()=>{for(let e of b.values())if(e.value===g)return e},[b,g]),z=Y.useMemo(()=>{for(let e of b.values())if(!e.disabled)return e.value},[b]),B=Y.useRef(!f),H=Y.useRef(i),U=Y.useRef(f),W=Y.useRef(!1);n(()=>{if(v)return;function e(e,t){_(e),T({previousValue:e,tabActivationDirection:`none`}),N(e,t),B.current=!1}if(b.size===0){W.current&&g!==null&&!S.current?.isConnected&&e(null,de);return}W.current=!0,S.current=b.keys().next().value;let t=R?.disabled,n=R==null&&g!==null;if(!t&&g===H.current&&(U.current=!1),U.current&&t&&g===H.current)return;let r=B.current;if(t||n){let n=z??null;if(g===n){B.current=!1;return}let i=de;r?i=ce:t&&(i=fe),e(n,i);return}r&&R!=null&&(N(g,ce),B.current=!1)},[z,v,N,R,_,b,g]);let G=c(`div`,e,{state:{orientation:o,tabActivationDirection:O},ref:t,props:d,stateAttributesMapping:Z});return(0,Q.jsx)(Ce.Provider,{value:L,children:(0,Q.jsx)(V,{elementsRef:p,children:G})})});function $(e,t){for(let[n,r]of e.entries())if(t===r.value)return n;return null}function Te(e,t,n,r){if(e==null||t==null)return`none`;let[i,a,o]=n===`horizontal`?[`left`,`left`,`right`]:[`top`,`up`,`down`],s=$(r,e),c=$(r,t);if(s==null||c==null)return s!==c&&(typeof e==`number`||typeof e==`string`)&&typeof e==typeof t?t>e?o:a:`none`;let l=s.getBoundingClientRect()[i],u=c.getBoundingClientRect()[i];return u<l?a:u>l?o:`none`}var Ee=`data-composite-item-active`;function De(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=o(),{ref:i,index:a}=R(e),s=n===a,c=Y.useRef(null),l=u(i,c);return{compositeProps:{tabIndex:s?0:-1,onFocus(){r(a)},onMouseMove(){let e=c.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!s&&!n&&e.focus()}},compositeRef:l,index:a}}var Oe=Y.createContext(void 0);function ke(){let e=Y.useContext(Oe);if(e===void 0)throw Error(b(65));return e}var Ae=Y.forwardRef(function(e,t){let{className:r,disabled:i=!1,render:s,value:l,id:u,nativeButton:d=!0,style:f,...p}=e,{value:m,getTabPanelIdByValue:h,onValueChange:g,orientation:_,tabActivationDirection:v}=X(),{activateOnFocus:b,registerTabResizeObserverElement:x,tabsListElement:S}=ke(),{highlightedIndex:C,onHighlightedIndexChange:w}=o(),T=se(u),{compositeProps:E,compositeRef:D,index:k}=De({metadata:Y.useMemo(()=>({disabled:i,id:T,value:l}),[i,T,l])}),A=l===m,j=Y.useRef(!1),M=Y.useRef(null),N=y(e=>{M.current?.(),M.current=e?x(e):null});n(()=>{if(j.current){j.current=!1;return}if(!(A&&k>-1&&C!==k))return;let e=S;if(e!=null){let t=re(G(e));if(t&&O(e,t))return}i||w(k)},[A,k,C,w,i,S]);let{getButtonProps:P,buttonRef:F}=a({disabled:i,native:d,focusableWhenDisabled:!0}),I=h(l),L=Y.useRef(!1),R=Y.useRef(!1);function z(e){g(l,ue(le,e.nativeEvent,void 0,{activationDirection:`none`}))}function B(e){A||i||z(e)}function V(e){A||i||b&&(!L.current||R.current)&&z(e)}function H(e){if(A||i)return;L.current=!0,R.current=e.button===0;let t=G(e.currentTarget);function n(){L.current=!1,R.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return c(`button`,e,{state:{disabled:i,active:A,orientation:_,tabActivationDirection:v},ref:[t,F,D,N],props:[E,{role:`tab`,"aria-controls":I,"aria-selected":A,id:T,onClick:B,onFocus:V,onPointerDown:H,[Ee]:A?``:void 0,onKeyDownCapture(){j.current=!0}},p,P],stateAttributesMapping:Z})}),je={...Z,...B},Me=Y.forwardRef(function(e,t){let{className:r,value:i,render:a,keepMounted:o=!1,style:s,...l}=e,{value:u,getTabIdByPanelValue:d,orientation:f,tabActivationDirection:p,registerMountedTabPanel:m}=X(),h=se(),{ref:g,index:_}=R(),v=i===u,{mounted:y,transitionStatus:b,setMounted:x}=L(v),S=!y,C=d(i),w={hidden:S,orientation:f,tabActivationDirection:p,transitionStatus:b},T=Y.useRef(null),E=c(`div`,e,{state:w,ref:[t,g,T],props:[{"aria-labelledby":C,hidden:S,id:h,role:`tabpanel`,tabIndex:v?0:-1,inert:N(!v),"data-index":_},l],stateAttributesMapping:je});return P({open:v,ref:T,onComplete(){v||x(!1)}}),n(()=>{if(!(h==null||S&&!o))return m(i,h)},[S,o,i,h,m]),o||y?E:null}),Ne=[];function Pe(e){let{loopFocus:t=!0,orientation:r=`both`,grid:i,onLoop:a,direction:o,highlightedIndex:s,onHighlightedIndexChange:c,rootRef:l,enableHomeAndEndKeys:d=!1,stopEventPropagation:f,disabledIndices:p,modifierKeys:m=Ne}=e,[h,g]=Y.useState(0),_=i!=null,v=Y.useRef(null),b=u(v,l),x=Y.useRef([]),S=Y.useRef(!1),C=s??h,w=y((e,t=!1)=>{if((c??g)(e),t){let t=x.current[e];T(v.current,t,o,r)}}),O=y(e=>{if(e.size===0||S.current)return;S.current=!0;let t=Array.from(e.keys()),n=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=n?e.get(n)?.index??-1:-1;if(i!==-1)w(i);else if(M(t,C,p)){let e=A(t,{disabledIndices:p});j(t,e)||w(e)}T(v.current,n,o,r)});n(()=>{if(p==null||s!=null||!S.current)return;let e=x.current;if(M(e,C,p)){let t=A(e,{disabledIndices:p});j(e,t)||w(t)}},[p,s,C,x,w]);let N=y((e,t,n)=>a?a(e,t,n,x):n),P=y(e=>{let n=e.key===`Home`||e.key===`End`;if(!ee.has(e.key)||!d&&n||Fe(e,m)||!v.current)return;let s=o===`rtl`,c=s?U:ne,l=s?ne:U,u=r===`vertical`?E:c,h=r===`vertical`?D:l,g=te(e.nativeEvent);if(g!=null&&W(g)&&!k(g)){let t=g.selectionStart,n=g.selectionEnd,r=g.value;if(t==null||e.shiftKey||t!==n||e.key!==h&&t<r.length||e.key!==u&&t>0)return}let y=C,b=H(x,p),S=I(x,p);i!=null&&(y=i({disabledIndices:p,elementsRef:x,event:e,highlightedIndex:C,loopFocus:t,maxIndex:S,minIndex:b,onLoop:N,orientation:r,rtl:s}));let T=r!==`vertical`&&e.key===c||r!==`horizontal`&&e.key===`ArrowDown`,O=r!==`vertical`&&e.key===l||r!==`horizontal`&&e.key===`ArrowUp`;d&&(e.key===`Home`?y=b:e.key===`End`&&(y=S)),y===C&&(T||O)&&(t&&y===S&&T?(y=b,a&&(y=a(e,C,y,x))):t&&y===b&&O?(y=S,a&&(y=a(e,C,y,x))):y=A(x.current,{startingIndex:y,decrement:O,disabledIndices:p})),y!==C&&!j(x.current,y)&&(f&&e.stopPropagation(),(_||n||T||O)&&e.preventDefault(),w(y,!0),queueMicrotask(()=>{x.current[y]?.focus()}))});return{props:{ref:b,onFocus(e){let t=v.current,n=te(e.nativeEvent);!t||n==null||!W(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:P},highlightedIndex:C,onHighlightedIndexChange:w,elementsRef:x,onMapChange:O,relayKeyboardEvent:P}}function Fe(e,t){for(let n of w)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Ie(e){let{render:t,className:n,style:r,refs:i=l,props:a=l,state:o=m,stateAttributesMapping:s,highlightedIndex:u,onHighlightedIndexChange:d,orientation:f,grid:p,loopFocus:h,onLoop:g,enableHomeAndEndKeys:_,onMapChange:v,stopEventPropagation:y=!0,rootRef:b,disabledIndices:S,modifierKeys:C,highlightItemOnHover:w=!1,tag:T=`div`,...E}=e,{props:D,highlightedIndex:O,onHighlightedIndexChange:k,elementsRef:A,onMapChange:j,relayKeyboardEvent:M}=Pe({grid:p,loopFocus:h,onLoop:g,orientation:f,highlightedIndex:u,onHighlightedIndexChange:d,rootRef:b,stopEventPropagation:y,enableHomeAndEndKeys:_,direction:z(),disabledIndices:S,modifierKeys:C}),N=c(T,e,{state:o,ref:i,props:[D,...a,E],stateAttributesMapping:s}),P=Y.useMemo(()=>({highlightedIndex:O,onHighlightedIndexChange:k,highlightItemOnHover:w,relayKeyboardEvent:M}),[O,k,w,M]);return(0,Q.jsx)(x.Provider,{value:P,children:(0,Q.jsx)(V,{elementsRef:A,onMapChange:e=>{v?.(e),j(e)},children:N})})}var Le=Y.forwardRef(function(e,t){let{activateOnFocus:r=!1,className:i,loopFocus:a=!0,render:o,style:s,...c}=e,{orientation:u,setTabMap:d,tabActivationDirection:f}=X(),[p,m]=Y.useState(0),[h,g]=Y.useState(null),_=Y.useRef(new Set),v=Y.useRef(new Set),b=Y.useRef(null);n(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{_.current.forEach(e=>{e()})});return b.current=e,h&&e.observe(h),v.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),b.current=null}},[h]);let x=y(e=>(_.current.add(e),()=>{_.current.delete(e)})),S=y(e=>(v.current.add(e),b.current?.observe(e),()=>{v.current.delete(e),b.current?.unobserve(e)})),C={orientation:u,tabActivationDirection:f},w={"aria-orientation":u===`vertical`?`vertical`:void 0,role:`tablist`},T=Y.useMemo(()=>({activateOnFocus:r,registerIndicatorUpdateListener:x,registerTabResizeObserverElement:S,tabsListElement:h}),[r,x,S,h]);return(0,Q.jsx)(Oe.Provider,{value:T,children:(0,Q.jsx)(Ie,{render:o,className:i,style:s,state:C,refs:[t,g],props:[w,c],stateAttributesMapping:Z,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:a,orientation:u,onHighlightedIndexChange:m,onMapChange:d,disabledIndices:l})})});function Re({className:e,orientation:t=`horizontal`,...n}){return(0,Q.jsx)(we,{"data-slot":`tabs`,"data-orientation":t,className:d(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var ze=_(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Be({className:e,variant:t=`default`,...n}){return(0,Q.jsx)(Le,{"data-slot":`tabs-list`,"data-variant":t,className:d(ze({variant:t}),e),...n})}function Ve({className:e,...t}){return(0,Q.jsx)(Ae,{"data-slot":`tabs-trigger`,className:d(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function He({className:e,...t}){return(0,Q.jsx)(Me,{"data-slot":`tabs-content`,className:d(`flex-1 text-sm outline-none`,e),...t})}function Ue(){let{loop:e,tasks:n,poll:r,readiness:i}=ve.useLoaderData();me();let a=xe(i,e);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(t,{to:`/loops`,className:`flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(S,{className:`size-4`}),`Loops`]}),(0,Q.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e.name}),a.length>0?(0,Q.jsxs)(J,{children:[(0,Q.jsx)(_e,{}),(0,Q.jsx)(q,{children:`This loop cannot run yet`}),(0,Q.jsx)(K,{className:`flex flex-col gap-1`,children:a.map(e=>(0,Q.jsx)(`span`,{children:e},e))})]}):null,(0,Q.jsx)(Ge,{loop:e,poll:r}),(0,Q.jsxs)(Re,{defaultValue:`settings`,children:[(0,Q.jsxs)(Be,{children:[(0,Q.jsx)(Ve,{value:`settings`,children:`Settings`}),(0,Q.jsx)(Ve,{value:`tasks`,children:`Tasks`})]}),(0,Q.jsx)(He,{value:`settings`,className:`pt-2`,children:(0,Q.jsx)(C,{loop:e})}),(0,Q.jsxs)(He,{value:`tasks`,className:`flex flex-col gap-4 pt-2`,children:[(0,Q.jsx)(Ke,{loop:e}),(0,Q.jsx)(ie,{tasks:n,showLoop:!1,empty:`This loop has not run yet.`})]})]})]})}function We(e){return new Date(e).toLocaleString()}function Ge({loop:e,poll:t}){let n=p(),[r,i]=(0,Y.useState)(!1);return e.enabled?t.pollError?(0,Q.jsxs)(J,{variant:`destructive`,children:[(0,Q.jsx)(_e,{}),(0,Q.jsx)(q,{children:`The last look did not work`}),(0,Q.jsx)(K,{children:t.pollError})]}):(0,Q.jsx)(f,{children:(0,Q.jsxs)(g,{className:`flex flex-col gap-4 pt-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3 text-sm`,children:[(0,Q.jsx)(Se,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:t.polledAt?`Watching. Last looked ${We(t.polledAt)}.`:`Not looked yet. The dispatcher checks every couple of minutes; the first look records what is already waiting without running it.`})]}),t.backlog.length>0?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:t.backlog.length===1?`One thing is waiting`:`${t.backlog.length} things are waiting`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Matched, but not run: either it was already there before the loop was made, or it was held back for the reason shown. Run them if you want them dealt with too.`})]}),(0,Q.jsx)(s,{variant:`outline`,size:`sm`,disabled:r,onClick:async()=>{i(!0);try{let{queued:t}=await ye({data:{id:e.id}});await n.invalidate(),h.success(t===1?`Queued 1 run`:`Queued ${t} runs`)}catch(e){h.error(e instanceof Error?e.message:String(e))}finally{i(!1)}},children:r?`Queueing...`:`Run these too`})]}),(0,Q.jsxs)(`ul`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[t.backlog.slice(0,8).map(e=>(0,Q.jsxs)(`li`,{className:`truncate`,children:[e.sourceRef,` · `,e.sourceTitle,e.hold?(0,Q.jsxs)(`span`,{className:`text-foreground`,children:[` · `,e.hold]}):null]},e.key)),t.backlog.length>8?(0,Q.jsxs)(`li`,{children:[`and `,t.backlog.length-8,` more`]}):null]})]}):null]})}):(0,Q.jsxs)(J,{children:[(0,Q.jsx)(q,{children:`This loop is off`}),(0,Q.jsx)(K,{children:`Nothing is being watched for until you turn it back on.`})]})}function Ke({loop:e}){let t=p(),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(!0),[o,c]=(0,Y.useState)(!1),l=be(e.connectorId),u=l?.byHand??{kind:`none`},d=async()=>{c(!0);try{await ge({data:{loopId:e.id,url:n.trim(),dryRun:i}}),await t.invalidate(),r(``),h.success(i?`Queued as a dry run`:`Queued`)}catch(e){h.error(e instanceof Error?e.message:String(e))}finally{c(!1)}};return u.kind===`none`?(0,Q.jsx)(f,{children:(0,Q.jsx)(g,{className:`pt-6 text-sm text-muted-foreground`,children:`This loop can only run on something arriving, so there is nothing to start by hand. What it does with what arrives is worth trying on the first one, with dry run left on.`})}):(0,Q.jsx)(f,{children:(0,Q.jsxs)(g,{className:`flex flex-col gap-4 pt-6`,children:[(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.kind===`now`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{children:`Run it now, without waiting for the time`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Runs exactly as it would when the clock came round, and does not count as that run: the next scheduled one still happens.`}),(0,Q.jsxs)(s,{onClick:d,disabled:o,children:[(0,Q.jsx)(ae,{}),`Run`]})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(F,{htmlFor:`run-url`,children:[`Try this loop on a `,l?.name??``,` link`]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(he,{id:`run-url`,value:n,placeholder:u.placeholder,onChange:e=>r(e.target.value)}),(0,Q.jsxs)(s,{onClick:d,disabled:o||n.trim()===``,children:[(0,Q.jsx)(ae,{}),`Run`]})]})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(F,{htmlFor:`run-dry`,children:`Dry run`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i?`Prepare the result and show it to you, without writing anything.`:`Write the result back, exactly as the loop would on its own.`})]}),(0,Q.jsx)(pe,{id:`run-dry`,checked:i,onCheckedChange:a})]})]})})}export{Ue as component};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{$ as t,J as n,Yt as r,a as i,c as a,i as o,n as s,o as c,ot as l,q as u,r as d,ut as f}from"./preload-helper-CfdAYKD7.js";import{t as p}from"./arrow-left-CWUZt6k2.js";import{i as m,r as h,t as g}from"./task-list-CrptnI1N.js";import{t as _}from"./external-link-DC11orFA.js";import{t as v}from"./loader-B4Epchm_.js";import{I as y,O as b,_ as x,f as S,k as C,v as w}from"./index-Cndsw84p.js";import{n as T,r as E,t as D}from"./alert-BT2EVMJP.js";var O=n(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),k=n(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),A=e(r()),j=f();function M(){let{task:e,log:n}=S.useLoaderData(),r=w(e.actionConnectorId),l=x(e.actionConnectorId,e.actionId);return b([e]),(0,j.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,j.jsxs)(t,{to:`/inbox`,className:`flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground`,children:[(0,j.jsx)(p,{className:`size-4`}),`Inbox`]}),(0,j.jsxs)(`header`,{className:`flex items-start gap-4`,children:[(0,j.jsxs)(`div`,{className:`flex-1`,children:[(0,j.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:m(e)}),(0,j.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.loopId?(0,j.jsxs)(j.Fragment,{children:[e.sourceRef,` ·`,` `,(0,j.jsx)(t,{to:`/loops/$loopId`,params:{loopId:e.loopId},className:`underline`,children:e.loopName})]}):e.loopName})]}),(0,j.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,j.jsx)(h,{state:e.state}),e.dryRun?(0,j.jsx)(c,{variant:`outline`,children:`Dry run`}):null,C(e.state)?(0,j.jsx)(F,{task:e}):null]})]}),e.error?(0,j.jsxs)(D,{variant:e.state===`failed`?`destructive`:void 0,children:[(0,j.jsx)(E,{children:e.state===`failed`?`This run failed`:e.state===`cancelled`?`Stopped before it finished`:`Waiting to try again`}),(0,j.jsx)(T,{className:`whitespace-pre-wrap`,children:e.error})]}):null,e.state===`skipped`?(0,j.jsxs)(D,{children:[(0,j.jsx)(E,{children:`Nothing was written`}),(0,j.jsx)(T,{children:`The agent judged there was nothing worth posting, so Loopable stayed quiet.`})]}):null,e.output?(0,j.jsxs)(s,{children:[(0,j.jsxs)(o,{className:`flex flex-row items-center gap-3`,children:[(0,j.jsx)(i,{className:`flex-1 text-base`,children:e.state===`done`?`What was written`:`What the agent wrote`}),e.resultUrl?(0,j.jsxs)(a,{variant:`outline`,size:`sm`,nativeButton:!1,render:(0,j.jsx)(`a`,{href:e.resultUrl,target:`_blank`,rel:`noreferrer`}),children:[`See it on `,r?.name??e.actionConnectorId,(0,j.jsx)(_,{})]}):null]}),(0,j.jsxs)(d,{className:`flex flex-col gap-4`,children:[(0,j.jsx)(`pre`,{className:`whitespace-pre-wrap break-words text-sm`,children:e.output}),e.comments.length>0?(0,j.jsx)(N,{comments:e.comments}):null]})]}):null,n?(0,j.jsx)(P,{log:n,live:C(e.state)}):null,(0,j.jsxs)(s,{children:[(0,j.jsx)(o,{children:(0,j.jsx)(i,{className:`text-base`,children:`How this ran`})}),(0,j.jsxs)(d,{className:`flex flex-col gap-3 text-sm`,children:[(0,j.jsx)(I,{label:`Source`,children:e.sourceKind===`prompt`?(0,j.jsx)(`span`,{children:g.prompt}):e.sourceUrl?(0,j.jsxs)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 underline`,children:[g[e.sourceKind],` `,e.sourceRef,(0,j.jsx)(_,{className:`size-3`})]}):(0,j.jsxs)(`span`,{children:[g[e.sourceKind],` `,e.sourceRef]})}),e.prompt?(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Prompt`}),(0,j.jsx)(`pre`,{className:`mt-1 overflow-x-auto whitespace-pre-wrap rounded-md bg-muted p-2.5 text-xs`,children:e.prompt})]}):null,e.sourceKind===`prompt`?null:(0,j.jsxs)(I,{label:`Action`,children:[l?.name??e.actionId,e.actionConnectorId===e.connectorId?null:` on ${r?.name??e.actionConnectorId}`]}),(0,j.jsx)(I,{label:`Agent`,children:e.agentId??`unknown`}),(0,j.jsx)(I,{label:`Queued`,children:new Date(e.createdAt).toLocaleString()}),e.attempts>1?(0,j.jsx)(I,{label:`Attempt`,children:e.attempts}):null,e.durationMs?(0,j.jsxs)(I,{label:`Took`,children:[(e.durationMs/1e3).toFixed(1),`s`]}):null,e.agentCommand?(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Command`}),(0,j.jsx)(`pre`,{className:`mt-1 overflow-x-auto rounded-md bg-muted p-2.5 text-xs`,children:e.agentCommand})]}):null]})]})]})}function N({comments:e}){return(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 border-t pt-4`,children:[(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.length===1?`One comment, on the line it is about`:`${e.length} comments, each on the line it is about`}),e.map((e,t)=>(0,j.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-1.5 font-mono text-xs text-muted-foreground`,children:[(0,j.jsx)(k,{className:`size-3.5 shrink-0`}),(0,j.jsxs)(`span`,{className:`truncate`,children:[e.path,`:`,e.startLine?`${e.startLine}-${e.line}`:e.line]})]}),(0,j.jsx)(`pre`,{className:`whitespace-pre-wrap break-words border-l-2 pl-3 text-sm`,children:e.body})]},`${e.path}:${e.line}:${t}`))]})}function P({log:e,live:t}){let n=(0,A.useRef)(null);return(0,A.useEffect)(()=>{t&&n.current&&(n.current.scrollTop=n.current.scrollHeight)},[t,e]),(0,j.jsxs)(s,{children:[(0,j.jsxs)(o,{className:`flex flex-row items-center gap-3`,children:[(0,j.jsx)(i,{className:`flex-1 text-base`,children:`Agent log`}),t?(0,j.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,j.jsx)(v,{className:`size-3.5 animate-spin`}),`still running`]}):null]}),(0,j.jsx)(d,{children:(0,j.jsx)(`pre`,{ref:n,className:`max-h-80 overflow-auto rounded-md bg-muted p-2.5 text-xs leading-relaxed whitespace-pre-wrap break-words`,children:e})})]})}function F({task:e}){let t=l(),[n,r]=(0,A.useState)(e.cancelRequested);return(0,j.jsxs)(a,{variant:`outline`,size:`sm`,onClick:async()=>{r(!0);try{await y({data:{id:e.id}}),await t.invalidate()}catch(e){r(!1),u.error(e instanceof Error?e.message:String(e))}},disabled:n,children:[(0,j.jsx)(O,{}),n?`Stopping`:`Stop`]})}function I({label:e,children:t}){return(0,j.jsxs)(`div`,{className:`flex gap-3`,children:[(0,j.jsx)(`span`,{className:`w-20 shrink-0 text-xs text-muted-foreground`,children:e}),(0,j.jsx)(`span`,{className:`text-sm`,children:t})]})}export{M as component};
@@ -1 +0,0 @@
1
- import{J as e,l as t,ut as n}from"./preload-helper-CfdAYKD7.js";import{z as r}from"./index-Cndsw84p.js";var i=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),a=n();function o(e,t){return function({className:n}){return(0,a.jsx)(`svg`,{viewBox:e,fill:`currentColor`,"aria-hidden":!0,className:n,children:(0,a.jsx)(`path`,{d:t})})}}var s={Github:o(`0 0 16 16`,`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-2.65-.89-2.65-2.5 0-.77.27-1.4.72-1.9-.07-.18-.31-.9.07-1.87 0 0 .59-.19 1.93.72a6.5 6.5 0 0 1 1.76-.24c.6 0 1.2.08 1.76.24 1.34-.91 1.93-.72 1.93-.72.38.97.14 1.69.07 1.87.45.5.72 1.13.72 1.9 0 1.62-.88 2.3-2.66 2.5.28.24.52.71.52 1.44 0 1.03-.01 1.87-.01 2.13 0 .21.15.46.55.38A7.99 7.99 0 0 0 16 8c0-4.42-3.58-8-8-8Z`),Gmail:o(`0 0 24 24`,`M24 5.457v13.909c0 .904-.732 1.636-1.636 1.636h-3.819V11.73L12 16.64l-6.545-4.91v9.273H1.636A1.636 1.636 0 0 1 0 19.366V5.457c0-.904.732-1.636 1.636-1.636h.749L12 10.907l9.615-7.086h.749c.904 0 1.636.732 1.636 1.636Z`),Wechat:o(`0 0 24 24`,`M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 4.882-2.235 7.621-1.552-.983-3.29-4.269-5.653-8.163-5.653zm-2.877 3.63a1.09 1.09 0 0 1 1.089 1.089 1.09 1.09 0 0 1-1.089 1.09 1.09 1.09 0 0 1-1.089-1.09 1.09 1.09 0 0 1 1.09-1.089zm5.807 0a1.09 1.09 0 0 1 1.089 1.089 1.09 1.09 0 0 1-1.09 1.09 1.09 1.09 0 0 1-1.088-1.09 1.09 1.09 0 0 1 1.089-1.089zm5.463 3.573C13.008 9.39 9.9 12.06 9.9 15.354c0 1.874 1.017 3.582 2.67 4.834a.492.492 0 0 1 .177.554l-.324 1.235c-.016.058-.04.117-.04.177 0 .136.108.246.242.246a.271.271 0 0 0 .14-.045l1.586-.928a.72.72 0 0 1 .597-.082c.786.226 1.633.336 2.517.336 4 0 7.245-2.741 7.245-6.122 0-3.38-3.245-6.121-7.245-6.121zm-2.203 3.026a.908.908 0 0 1 .907.907.908.908 0 0 1-.907.908.908.908 0 0 1-.908-.908.908.908 0 0 1 .908-.907zm4.839 0a.908.908 0 0 1 .907.907.908.908 0 0 1-.907.908.908.908 0 0 1-.908-.908.908.908 0 0 1 .908-.907z`),Clock:i,Plug:r};function c({icon:e,accent:n,className:i}){let o=s[e]??r;return(0,a.jsx)(`span`,{className:t(`flex size-9 shrink-0 items-center justify-center rounded-lg`,n,i),children:(0,a.jsx)(o,{className:`size-5`})})}export{i as n,c as t};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-CbXtAM7H.js";import{$ as t,Yt as n,c as r,i,n as a,o,q as s,r as c,ut as l}from"./preload-helper-CfdAYKD7.js";import{t as u}from"./arrow-right-dy_oOg_c.js";import{t as d}from"./connector-icon-qGpNsPgH.js";import{V as f,b as p,h as m,x as h}from"./index-Cndsw84p.js";import{t as g}from"./connection-status-DCqqmY_6.js";var _=e(n()),v=l();function y(){let e=h.useLoaderData(),{connected:n,error:l}=h.useSearch(),y=h.useNavigate();return(0,_.useEffect)(()=>{!n&&!l||(n&&s.success(`Connected as ${n}`),l&&s.error(l),y({search:{},replace:!0}))},[n,l,y]),(0,v.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,v.jsxs)(`header`,{children:[(0,v.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Connectors`}),(0,v.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Connect the services a loop should watch. Credentials stay with Loopable.`})]}),(0,v.jsx)(`div`,{className:`flex flex-col gap-4`,children:m.filter(e=>p(e.id)).map(n=>{let s=e.find(e=>e.connectorId===n.id),l=s?.connections??[],p=s?.readiness,m=p&&!p.ready?p:null;return(0,v.jsxs)(a,{children:[(0,v.jsxs)(i,{className:`flex flex-row items-start gap-4`,children:[(0,v.jsx)(d,{icon:n.icon,accent:n.accent}),(0,v.jsxs)(`div`,{className:`flex-1`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`h2`,{className:`font-medium`,children:n.name}),l.length>0?(0,v.jsxs)(o,{variant:`secondary`,children:[l.length,` account`,l.length>1?`s`:``]}):null]}),(0,v.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:n.tagline})]}),(0,v.jsxs)(r,{variant:`outline`,render:(0,v.jsx)(t,{to:`/connectors/$connectorId`,params:{connectorId:n.id}}),children:[l.length>0?`Manage`:`Set up`,(0,v.jsx)(u,{})]})]}),(l.length>0||m)&&(0,v.jsxs)(c,{className:`flex flex-col gap-2 border-t pt-4`,children:[m?(0,v.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-muted-foreground`,children:[(0,v.jsx)(f,{className:`mt-0.5 size-4 shrink-0`}),(0,v.jsx)(`span`,{children:m.reason})]}):null,l.map(e=>(0,v.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,v.jsx)(`span`,{className:`font-medium`,children:e.accountLabel}),(0,v.jsx)(g,{status:e.status}),e.lastError?(0,v.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.lastError}):null]},e.id))]})]},n.id)})})]})}export{y as component};
@@ -1 +0,0 @@
1
- import{b as e,j as t,v as n,y as r}from"./index-Cndsw84p.js";function i(e){return t(e)?.name??e}function a(e,t){return e.agentId??t.defaultAgentId}function o(e){return r(e.connectorId,e.workflowId)?.runsIn===`folder`}function s(e,t){if(!t.enabled)return[];let n=[],r=a(t,e),s=o(t)?e.hostAgentIds:e.availableAgentIds;return r?s.includes(r)||n.push(o(t)?`${t.name} needs a runner on this host with ${i(r)} signed in.`:`${t.name} uses ${i(r)}, which no online runner has signed in.`):n.push(t.agentId?`${t.name} uses ${i(t.agentId)}, which no online runner has signed in.`:`No default agent is chosen, so this loop cannot run.`),n}function c(t,r){let i=[],a=new Set(t.connectedConnectorIds);if(a.size===0&&i.push(`No account is connected yet, so no signal can arrive.`),t.availableAgentIds.length===0?i.push(`No coding agent is signed in on any runner, so nothing can be prepared.`):t.defaultAgentId||i.push(`No default agent is chosen, so loops that do not name one cannot run.`),a.size>0){let t=e=>n(e)?.name??e;for(let n of r)n.enabled&&(e(n.connectorId)&&!a.has(n.connectorId)&&i.push(`${n.name} watches ${t(n.connectorId)}, which has no account.`),e(n.actionConnectorId)&&!a.has(n.actionConnectorId)&&i.push(`${n.name} answers on ${t(n.actionConnectorId)}, which has no account.`))}if(t.availableAgentIds.length>0)for(let e of r)for(let n of s(t,e))n!==`No default agent is chosen, so this loop cannot run.`&&i.push(n);return i}export{s as n,c as t};