@novu/framework 2.13.0 → 2.13.1-rc.72c80d5b17

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 (82) hide show
  1. package/dist/cjs/{agent.types-Dqm2VBTO.d.cts → agent.types-B5VnP69G.d.cts} +48 -2
  2. package/dist/cjs/ai-sdk/index.d.cts +1 -1
  3. package/dist/cjs/cards.cjs +1 -1
  4. package/dist/cjs/{health-check.types-B9FbzRbm.d.cts → health-check.types-CtWQ_YSy.d.cts} +4 -3
  5. package/dist/cjs/{index-CLZZRnNV.d.cts → index-vgb88C84.d.cts} +3 -3
  6. package/dist/cjs/index.cjs +88 -88
  7. package/dist/cjs/index.d.cts +5 -5
  8. package/dist/cjs/internal/index.cjs +43 -43
  9. package/dist/cjs/internal/index.d.cts +19 -15
  10. package/dist/cjs/langchain/index.cjs +1 -1
  11. package/dist/cjs/langchain/index.d.cts +15 -1
  12. package/dist/cjs/servers/express.cjs +88 -88
  13. package/dist/cjs/servers/express.d.cts +6 -6
  14. package/dist/cjs/servers/h3.cjs +86 -86
  15. package/dist/cjs/servers/h3.d.cts +6 -6
  16. package/dist/cjs/servers/hono.cjs +86 -86
  17. package/dist/cjs/servers/hono.d.cts +6 -6
  18. package/dist/cjs/servers/lambda.cjs +88 -88
  19. package/dist/cjs/servers/lambda.d.cts +6 -6
  20. package/dist/cjs/servers/nest.cjs +96 -96
  21. package/dist/cjs/servers/nest.d.cts +8 -8
  22. package/dist/cjs/servers/next.cjs +90 -90
  23. package/dist/cjs/servers/next.d.cts +6 -6
  24. package/dist/cjs/servers/nuxt.cjs +86 -86
  25. package/dist/cjs/servers/nuxt.d.cts +6 -6
  26. package/dist/cjs/servers/remix.cjs +86 -86
  27. package/dist/cjs/servers/remix.d.cts +6 -6
  28. package/dist/cjs/servers/sveltekit.cjs +74 -74
  29. package/dist/cjs/servers/sveltekit.d.cts +6 -6
  30. package/dist/cjs/step-resolver.cjs +4 -4
  31. package/dist/cjs/step-resolver.d.cts +17 -4
  32. package/dist/cjs/{subscriber.types-DubxcL8q.d.cts → subscriber.types-CyNKT0nZ.d.cts} +67 -2
  33. package/dist/cjs/validators.cjs +1 -1
  34. package/dist/esm/{agent.types-E3sxq6xr.d.ts → agent.types-HUDhyXrV.d.ts} +48 -2
  35. package/dist/esm/ai-sdk/index.d.ts +1 -1
  36. package/dist/esm/cards.js +1 -1
  37. package/dist/esm/{chunk-WDBIT4NK.js → chunk-CGZ5P44A.js} +66 -66
  38. package/dist/esm/chunk-FMKD6TON.js +1 -0
  39. package/dist/esm/{chunk-CANJPWLT.js → chunk-SPS3KBKF.js} +4 -4
  40. package/dist/esm/{chunk-FRWG7YTE.js → chunk-VY27ZAO7.js} +1 -1
  41. package/dist/esm/{chunk-46AHJTS7.js → chunk-X5AZIKIR.js} +8 -8
  42. package/dist/esm/{chunk-22DBAEUX.js → chunk-XIVU4VDS.js} +1 -1
  43. package/dist/esm/{chunk-2M25EATE.js → chunk-YLCLZVYS.js} +1 -1
  44. package/dist/esm/{health-check.types-BNocZ4Wk.d.ts → health-check.types-0Rv-l8yD.d.ts} +4 -3
  45. package/dist/esm/{index-CWldA6G5.d.ts → index-C0oUWDlb.d.ts} +3 -3
  46. package/dist/esm/index.d.ts +5 -5
  47. package/dist/esm/index.js +1 -1
  48. package/dist/esm/internal/index.d.ts +10 -6
  49. package/dist/esm/internal/index.js +1 -1
  50. package/dist/esm/jsx-dev-runtime.js +1 -1
  51. package/dist/esm/{jsx-runtime-P2HN3TPO.js → jsx-runtime-5ZWEWA4A.js} +1 -1
  52. package/dist/esm/jsx-runtime.js +1 -1
  53. package/dist/esm/langchain/index.d.ts +15 -1
  54. package/dist/esm/langchain/index.js +1 -1
  55. package/dist/esm/servers/express.d.ts +6 -6
  56. package/dist/esm/servers/express.js +1 -1
  57. package/dist/esm/servers/h3.d.ts +6 -6
  58. package/dist/esm/servers/h3.js +1 -1
  59. package/dist/esm/servers/hono.d.ts +6 -6
  60. package/dist/esm/servers/hono.js +1 -1
  61. package/dist/esm/servers/lambda.d.ts +6 -6
  62. package/dist/esm/servers/lambda.js +1 -1
  63. package/dist/esm/servers/nest.d.ts +8 -8
  64. package/dist/esm/servers/nest.js +1 -1
  65. package/dist/esm/servers/next.d.ts +6 -6
  66. package/dist/esm/servers/next.js +1 -1
  67. package/dist/esm/servers/nuxt.d.ts +6 -6
  68. package/dist/esm/servers/nuxt.js +1 -1
  69. package/dist/esm/servers/remix.d.ts +6 -6
  70. package/dist/esm/servers/remix.js +1 -1
  71. package/dist/esm/servers/sveltekit.d.ts +6 -6
  72. package/dist/esm/servers/sveltekit.js +1 -1
  73. package/dist/esm/step-resolver.d.ts +17 -4
  74. package/dist/esm/step-resolver.js +1 -1
  75. package/dist/esm/{subscriber.types-CmybpXhA.d.ts → subscriber.types-g7VnI_ZQ.d.ts} +67 -2
  76. package/dist/esm/validators.js +1 -1
  77. package/langchain/package.json +4 -0
  78. package/nest/package.json +2 -1
  79. package/package.json +2 -2
  80. package/dist/esm/chunk-LHU5A7DI.js +0 -1
  81. /package/dist/esm/{chunk-3ZWME5KT.js → chunk-7C3QBYLB.js} +0 -0
  82. /package/dist/esm/{chunk-XEHQJMMQ.js → chunk-RBTQQ5IZ.js} +0 -0
@@ -1,13 +1,13 @@
1
- import{D as _,F as y,a as P,b as L,c as w,d as b,e as k,f as Z,g as Y,h as tt,i as et,j as at,k as rt,l as st,m as it,n as nt,o as ot,p as lt,q as ct,r as R,s as dt,t as ht,u as ut,v as ft,w as gt,x as pt}from"./chunk-XEHQJMMQ.js";import{f as c}from"./chunk-FHYMHX3T.js";var C=Symbol.for("workflow-serialize"),x=Symbol.for("workflow-deserialize");var jt=Object.defineProperty,zt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,Kt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable,_t=(t,e,a)=>e in t?jt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,kt=(t,e)=>{for(var a in e||(e={}))Kt.call(e,a)&&_t(t,a,e[a]);if(mt)for(var a of mt(e))Xt.call(e,a)&&_t(t,a,e[a]);return t},Mt=(t,e)=>zt(t,Bt(e)),p=(t,e)=>{let a=!1,r=!1;for(let s=0;s<e;s+=1){if(t[s]==="\\"&&s+1<t.length&&t[s+1]==="`"){s+=1;continue}if(t.substring(s,s+3)==="```"){r=!r,s+=2;continue}!r&&t[s]==="`"&&(a=!a)}return a||r},qt=(t,e)=>{let a=t.substring(e,e+3)==="```",r=e>0&&t.substring(e-1,e+2)==="```",s=e>1&&t.substring(e-2,e+1)==="```";return a||r||s},Gt=t=>{let e=0;for(let a=0;a<t.length;a+=1){if(t[a]==="\\"&&a+1<t.length&&t[a+1]==="`"){a+=1;continue}t[a]==="`"&&!qt(t,a)&&(e+=1)}return e},M=(t,e)=>{let a=!1,r=!1,s=-1;for(let i=0;i<t.length;i+=1){if(t[i]==="\\"&&i+1<t.length&&t[i+1]==="`"){i+=1;continue}if(t.substring(i,i+3)==="```"){r=!r,i+=2;continue}if(!r&&t[i]==="`")if(a){if(s<e&&e<i)return!0;a=!1,s=-1}else a=!0,s=i}return!1},Vt=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,Qt=t=>!t||typeof t!="string"||!t.includes(">")?t:t.replace(Vt,(e,a,r,s)=>p(t,s)?e:`${a}\\>${r}`),Zt=/(\*\*)([^*]*\*?)$/,Yt=/(__)([^_]*?)$/,te=/(\*\*\*)([^*]*?)$/,ee=/(\*)([^*]*?)$/,ae=/(_)([^_]*?)$/,re=/(`)([^`]*?)$/,se=/(~~)([^~]*?)$/,S=/^[\s_~*`]*$/,It=/^[\s]*[-*+][\s]+$/,ie=/[\p{L}\p{N}_]/u,ne=/^```[^`\n]*```?$/,oe=/^\*{4,}$/,le=/(__)([^_]+)_$/,ce=/(~~)([^~]+)~$/,yt=/~~/g,I=t=>{if(!t)return!1;let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95?!0:ie.test(t)};var de=(t,e)=>{let a=1;for(let r=e-1;r>=0;r-=1)if(t[r]==="]")a+=1;else if(t[r]==="["&&(a-=1,a===0))return r;return-1},St=(t,e)=>{let a=1;for(let r=e+1;r<t.length;r+=1)if(t[r]==="[")a+=1;else if(t[r]==="]"&&(a-=1,a===0))return r;return-1},$=(t,e)=>{let a=!1,r=!1;for(let s=0;s<t.length&&s<e;s+=1){if(t[s]==="\\"&&t[s+1]==="$"){s+=1;continue}t[s]==="$"&&(t[s+1]==="$"?(r=!r,s+=1,a=!1):r||(a=!a))}return a||r},he=(t,e)=>{for(let a=e;a<t.length;a+=1){if(t[a]===")")return!0;if(t[a]===`
1
+ import{D as y,F as _,a as P,b as L,c as w,d as b,e as k,f as Z,g as Y,h as tt,i as et,j as at,k as rt,l as st,m as it,n as nt,o as ot,p as lt,q as ct,r as R,s as dt,t as ht,u as ut,v as ft,w as gt,x as pt}from"./chunk-RBTQQ5IZ.js";import{f as c}from"./chunk-FHYMHX3T.js";var C=Symbol.for("workflow-serialize"),x=Symbol.for("workflow-deserialize");var jt=Object.defineProperty,zt=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,Kt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable,yt=(t,e,a)=>e in t?jt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,kt=(t,e)=>{for(var a in e||(e={}))Kt.call(e,a)&&yt(t,a,e[a]);if(mt)for(var a of mt(e))Xt.call(e,a)&&yt(t,a,e[a]);return t},Mt=(t,e)=>zt(t,Bt(e)),p=(t,e)=>{let a=!1,r=!1;for(let s=0;s<e;s+=1){if(t[s]==="\\"&&s+1<t.length&&t[s+1]==="`"){s+=1;continue}if(t.substring(s,s+3)==="```"){r=!r,s+=2;continue}!r&&t[s]==="`"&&(a=!a)}return a||r},qt=(t,e)=>{let a=t.substring(e,e+3)==="```",r=e>0&&t.substring(e-1,e+2)==="```",s=e>1&&t.substring(e-2,e+1)==="```";return a||r||s},Gt=t=>{let e=0;for(let a=0;a<t.length;a+=1){if(t[a]==="\\"&&a+1<t.length&&t[a+1]==="`"){a+=1;continue}t[a]==="`"&&!qt(t,a)&&(e+=1)}return e},M=(t,e)=>{let a=!1,r=!1,s=-1;for(let i=0;i<t.length;i+=1){if(t[i]==="\\"&&i+1<t.length&&t[i+1]==="`"){i+=1;continue}if(t.substring(i,i+3)==="```"){r=!r,i+=2;continue}if(!r&&t[i]==="`")if(a){if(s<e&&e<i)return!0;a=!1,s=-1}else a=!0,s=i}return!1},Vt=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,Qt=t=>!t||typeof t!="string"||!t.includes(">")?t:t.replace(Vt,(e,a,r,s)=>p(t,s)?e:`${a}\\>${r}`),Zt=/(\*\*)([^*]*\*?)$/,Yt=/(__)([^_]*?)$/,te=/(\*\*\*)([^*]*?)$/,ee=/(\*)([^*]*?)$/,ae=/(_)([^_]*?)$/,re=/(`)([^`]*?)$/,se=/(~~)([^~]*?)$/,S=/^[\s_~*`]*$/,It=/^[\s]*[-*+][\s]+$/,ie=/[\p{L}\p{N}_]/u,ne=/^```[^`\n]*```?$/,oe=/^\*{4,}$/,le=/(__)([^_]+)_$/,ce=/(~~)([^~]+)~$/,_t=/~~/g,I=t=>{if(!t)return!1;let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95?!0:ie.test(t)};var de=(t,e)=>{let a=1;for(let r=e-1;r>=0;r-=1)if(t[r]==="]")a+=1;else if(t[r]==="["&&(a-=1,a===0))return r;return-1},St=(t,e)=>{let a=1;for(let r=e+1;r<t.length;r+=1)if(t[r]==="[")a+=1;else if(t[r]==="]"&&(a-=1,a===0))return r;return-1},$=(t,e)=>{let a=!1,r=!1;for(let s=0;s<t.length&&s<e;s+=1){if(t[s]==="\\"&&t[s+1]==="$"){s+=1;continue}t[s]==="$"&&(t[s+1]==="$"?(r=!r,s+=1,a=!1):r||(a=!a))}return a||r},he=(t,e)=>{for(let a=e;a<t.length;a+=1){if(t[a]===")")return!0;if(t[a]===`
2
2
  `)return!1}return!1},Tt=(t,e)=>{for(let a=e-1;a>=0;a-=1){if(t[a]===")")return!1;if(t[a]==="(")return a>0&&t[a-1]==="]"?he(t,e):!1;if(t[a]===`
3
3
  `)return!1}return!1},ue=(t,e)=>{for(let a=e-1;a>=0;a-=1){if(t[a]===">")return!1;if(t[a]==="<"){let r=a+1<t.length?t[a+1]:"";return r>="a"&&r<="z"||r>="A"&&r<="Z"||r==="/"}if(t[a]===`
4
4
  `)return!1}return!1},W=(t,e,a)=>{let r=0;for(let l=e-1;l>=0;l-=1)if(t[l]===`
5
5
  `){r=l+1;break}let s=t.length;for(let l=e;l<t.length;l+=1)if(t[l]===`
6
6
  `){s=l;break}let i=t.substring(r,s),n=0,o=!1;for(let l of i)if(l===a)n+=1;else if(l!==" "&&l!==" "){o=!0;break}return n>=3&&!o},fe=(t,e,a,r)=>a==="\\"||t.includes("$")&&$(t,e)?!0:a!=="*"&&r==="*"?(e<t.length-2?t[e+2]:"")!=="*":!!(a==="*"||a&&r&&I(a)&&I(r)||(!a||a===" "||a===" "||a===`
7
7
  `)&&(!r||r===" "||r===" "||r===`
8
- `)),Et=t=>{let e=0,a=!1,r=t.length;for(let s=0;s<r;s+=1){if(t[s]==="`"&&s+2<r&&t[s+1]==="`"&&t[s+2]==="`"){a=!a,s+=2;continue}if(a||t[s]!=="*")continue;let i=s>0?t[s-1]:"",n=s<r-1?t[s+1]:"";fe(t,s,i,n)||(e+=1)}return e},ge=(t,e,a,r)=>!!(a==="\\"||t.includes("$")&&$(t,e)||Tt(t,e)||ue(t,e)||a==="_"||r==="_"||a&&r&&I(a)&&I(r)),pe=t=>{let e=0,a=!1,r=t.length;for(let s=0;s<r;s+=1){if(t[s]==="`"&&s+2<r&&t[s+1]==="`"&&t[s+2]==="`"){a=!a,s+=2;continue}if(a||t[s]!=="_")continue;let i=s>0?t[s-1]:"",n=s<r-1?t[s+1]:"";ge(t,s,i,n)||(e+=1)}return e},me=t=>{let e=0,a=0,r=!1;for(let s=0;s<t.length;s+=1){if(t[s]==="`"&&s+2<t.length&&t[s+1]==="`"&&t[s+2]==="`"){a>=3&&(e+=Math.floor(a/3)),a=0,r=!r,s+=2;continue}r||(t[s]==="*"?a+=1:(a>=3&&(e+=Math.floor(a/3)),a=0))}return a>=3&&(e+=Math.floor(a/3)),e},J=t=>{let e=0,a=!1;for(let r=0;r<t.length;r+=1){if(t[r]==="`"&&r+2<t.length&&t[r+1]==="`"&&t[r+2]==="`"){a=!a,r+=2;continue}a||t[r]==="*"&&r+1<t.length&&t[r+1]==="*"&&(e+=1,r+=1)}return e},wt=t=>{let e=0,a=!1;for(let r=0;r<t.length;r+=1){if(t[r]==="`"&&r+2<t.length&&t[r+1]==="`"&&t[r+2]==="`"){a=!a,r+=2;continue}a||t[r]==="_"&&r+1<t.length&&t[r+1]==="_"&&(e+=1,r+=1)}return e},_e=(t,e,a)=>{if(!e||S.test(e))return!0;let r=t.substring(0,a).lastIndexOf(`
8
+ `)),Et=t=>{let e=0,a=!1,r=t.length;for(let s=0;s<r;s+=1){if(t[s]==="`"&&s+2<r&&t[s+1]==="`"&&t[s+2]==="`"){a=!a,s+=2;continue}if(a||t[s]!=="*")continue;let i=s>0?t[s-1]:"",n=s<r-1?t[s+1]:"";fe(t,s,i,n)||(e+=1)}return e},ge=(t,e,a,r)=>!!(a==="\\"||t.includes("$")&&$(t,e)||Tt(t,e)||ue(t,e)||a==="_"||r==="_"||a&&r&&I(a)&&I(r)),pe=t=>{let e=0,a=!1,r=t.length;for(let s=0;s<r;s+=1){if(t[s]==="`"&&s+2<r&&t[s+1]==="`"&&t[s+2]==="`"){a=!a,s+=2;continue}if(a||t[s]!=="_")continue;let i=s>0?t[s-1]:"",n=s<r-1?t[s+1]:"";ge(t,s,i,n)||(e+=1)}return e},me=t=>{let e=0,a=0,r=!1;for(let s=0;s<t.length;s+=1){if(t[s]==="`"&&s+2<t.length&&t[s+1]==="`"&&t[s+2]==="`"){a>=3&&(e+=Math.floor(a/3)),a=0,r=!r,s+=2;continue}r||(t[s]==="*"?a+=1:(a>=3&&(e+=Math.floor(a/3)),a=0))}return a>=3&&(e+=Math.floor(a/3)),e},J=t=>{let e=0,a=!1;for(let r=0;r<t.length;r+=1){if(t[r]==="`"&&r+2<t.length&&t[r+1]==="`"&&t[r+2]==="`"){a=!a,r+=2;continue}a||t[r]==="*"&&r+1<t.length&&t[r+1]==="*"&&(e+=1,r+=1)}return e},wt=t=>{let e=0,a=!1;for(let r=0;r<t.length;r+=1){if(t[r]==="`"&&r+2<t.length&&t[r+1]==="`"&&t[r+2]==="`"){a=!a,r+=2;continue}a||t[r]==="_"&&r+1<t.length&&t[r+1]==="_"&&(e+=1,r+=1)}return e},ye=(t,e,a)=>{if(!e||S.test(e))return!0;let r=t.substring(0,a).lastIndexOf(`
9
9
  `),s=r===-1?0:r+1,i=t.substring(s,a);return It.test(i)&&e.includes(`
10
- `)?!0:W(t,a,"*")},ye=t=>{let e=t.match(Zt);if(!e)return t;let a=e[2],r=t.lastIndexOf(e[1]);return p(t,r)||M(t,r)||_e(t,a,r)?t:J(t)%2===1?a.endsWith("*")?`${t}*`:`${t}**`:t},we=(t,e,a)=>{if(!e||S.test(e))return!0;let r=t.substring(0,a).lastIndexOf(`
10
+ `)?!0:W(t,a,"*")},_e=t=>{let e=t.match(Zt);if(!e)return t;let a=e[2],r=t.lastIndexOf(e[1]);return p(t,r)||M(t,r)||ye(t,a,r)?t:J(t)%2===1?a.endsWith("*")?`${t}*`:`${t}**`:t},we=(t,e,a)=>{if(!e||S.test(e))return!0;let r=t.substring(0,a).lastIndexOf(`
11
11
  `),s=r===-1?0:r+1,i=t.substring(s,a);return It.test(i)&&e.includes(`
12
12
  `)?!0:W(t,a,"_")},be=t=>{let e=t.match(Yt);if(!e){let s=t.match(le);if(s){let i=t.lastIndexOf(s[1]);if(!(p(t,i)||M(t,i))&&wt(t)%2===1)return`${t}_`}return t}let a=e[2],r=t.lastIndexOf(e[1]);return p(t,r)||M(t,r)||we(t,a,r)?t:wt(t)%2===1?`${t}__`:t},ke=t=>{let e=!1;for(let a=0;a<t.length;a+=1){if(t[a]==="`"&&a+2<t.length&&t[a+1]==="`"&&t[a+2]==="`"){e=!e,a+=2;continue}if(!e&&t[a]==="*"&&t[a-1]!=="*"&&t[a+1]!=="*"&&t[a-1]!=="\\"&&!$(t,a)){let r=a>0?t[a-1]:"",s=a<t.length-1?t[a+1]:"";if((!r||r===" "||r===" "||r===`
13
13
  `)&&(!s||s===" "||s===" "||s===`
@@ -19,18 +19,18 @@ import{D as _,F as y,a as P,b as L,c as w,d as b,e as k,f as Z,g as Y,h as tt,i
19
19
  $$`:`${t}$$`},ve=t=>Oe(t)%2===0?t:De(t),Ue=t=>$e(t)%2===1?`${t}$`:t,Pe=(t,e,a)=>{if(t.substring(e+2).includes(")"))return null;let r=de(t,e);if(r===-1||p(t,r))return null;let s=r>0&&t[r-1]==="!",i=s?r-1:r,n=t.substring(0,i);if(s)return n;let o=t.substring(r+1,e);return a==="text-only"?`${n}${o}`:`${n}[${o}](streamdown:incomplete-link)`},bt=(t,e)=>{for(let a=0;a<e;a++)if(t[a]==="["&&!p(t,a)){if(a>0&&t[a-1]==="!")continue;let r=St(t,a);if(r===-1)return a;if(r+1<t.length&&t[r+1]==="("){let s=t.indexOf(")",r+2);s!==-1&&(a=s)}}return e},He=(t,e,a)=>{let r=e>0&&t[e-1]==="!",s=r?e-1:e;if(!t.substring(e+1).includes("]")){let i=t.substring(0,s);if(r)return i;if(a==="text-only"){let n=bt(t,e);return t.substring(0,n)+t.substring(n+1)}return`${t}](streamdown:incomplete-link)`}if(St(t,e)===-1){let i=t.substring(0,s);if(r)return i;if(a==="text-only"){let n=bt(t,e);return t.substring(0,n)+t.substring(n+1)}return`${t}](streamdown:incomplete-link)`}return null},xt=(t,e="protocol")=>{let a=t.lastIndexOf("](");if(a!==-1&&!p(t,a)){let r=Pe(t,a,e);if(r!==null)return r}for(let r=t.length-1;r>=0;r-=1)if(t[r]==="["&&!p(t,r)){let s=He(t,r,e);if(s!==null)return s}return t},We=/^-{1,2}$/,Je=/^[\s]*-{1,2}[\s]+$/,je=/^={1,2}$/,ze=/^[\s]*={1,2}[\s]+$/,Be=t=>{if(!t||typeof t!="string")return t;let e=t.lastIndexOf(`
20
20
  `);if(e===-1)return t;let a=t.substring(e+1),r=t.substring(0,e),s=a.trim();if(We.test(s)&&!a.match(Je)){let i=r.split(`
21
21
  `).at(-1);if(i&&i.trim().length>0)return`${t}\u200B`}if(je.test(s)&&!a.match(ze)){let i=r.split(`
22
- `).at(-1);if(i&&i.trim().length>0)return`${t}\u200B`}return t},Ke=new RegExp("(?<=[\\p{L}\\p{N}_])~(?!~)(?=[\\p{L}\\p{N}_])","gu"),Xe=t=>!t||typeof t!="string"||!t.includes("~")?t:t.replace(Ke,(e,a)=>p(t,a)?e:"\\~"),qe=t=>{var e,a;let r=t.match(se);if(r){let s=r[2];if(!s||S.test(s))return t;let i=t.lastIndexOf(r[1]);if(p(t,i)||M(t,i))return t;if(((e=t.match(yt))==null?void 0:e.length)%2===1)return`${t}~~`}else{let s=t.match(ce);if(s){let i=t.lastIndexOf(s[0].slice(0,2));if(p(t,i)||M(t,i))return t;if(((a=t.match(yt))==null?void 0:a.length)%2===1)return`${t}~`}}return t},H=t=>t!==!1,Ge=t=>t===!0,g={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},Ve=[{handler:{name:"singleTilde",handle:Xe,priority:g.SINGLE_TILDE},optionKey:"singleTilde"},{handler:{name:"comparisonOperators",handle:Qt,priority:g.COMPARISON_OPERATORS},optionKey:"comparisonOperators"},{handler:{name:"htmlTags",handle:Fe,priority:g.HTML_TAGS},optionKey:"htmlTags"},{handler:{name:"setextHeadings",handle:Be,priority:g.SETEXT_HEADINGS},optionKey:"setextHeadings"},{handler:{name:"links",handle:xt,priority:g.LINKS},optionKey:"links",earlyReturn:t=>t.endsWith("](streamdown:incomplete-link)")},{handler:{name:"boldItalic",handle:Ce,priority:g.BOLD_ITALIC},optionKey:"boldItalic"},{handler:{name:"bold",handle:ye,priority:g.BOLD},optionKey:"bold"},{handler:{name:"italicDoubleUnderscore",handle:be,priority:g.ITALIC_DOUBLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"italicSingleAsterisk",handle:Me,priority:g.ITALIC_SINGLE_ASTERISK},optionKey:"italic"},{handler:{name:"italicSingleUnderscore",handle:Te,priority:g.ITALIC_SINGLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"inlineCode",handle:Re,priority:g.INLINE_CODE},optionKey:"inlineCode"},{handler:{name:"strikethrough",handle:qe,priority:g.STRIKETHROUGH},optionKey:"strikethrough"},{handler:{name:"katex",handle:ve,priority:g.KATEX},optionKey:"katex"},{handler:{name:"inlineKatex",handle:Ue,priority:g.INLINE_KATEX},optionKey:"inlineKatex"}],Qe=t=>{var e;let a=(e=t==null?void 0:t.linkMode)!=null?e:"protocol";return Ve.filter(({handler:r,optionKey:s})=>r.name==="links"?H(t==null?void 0:t.links)||H(t==null?void 0:t.images):r.name==="inlineKatex"?Ge(t==null?void 0:t.inlineKatex):H(t==null?void 0:t[s])).map(({handler:r,earlyReturn:s})=>r.name==="links"?{handler:Mt(kt({},r),{handle:i=>xt(i,a)}),earlyReturn:a==="protocol"?s:void 0}:{handler:r,earlyReturn:s})},Ze=(t,e)=>{var a;if(!t||typeof t!="string")return t;let r=t.endsWith(" ")&&!t.endsWith(" ")?t.slice(0,-1):t,s=Qe(e),i=((a=e==null?void 0:e.handlers)!=null?a:[]).map(o=>{var l;return{handler:Mt(kt({},o),{priority:(l=o.priority)!=null?l:g.DEFAULT}),earlyReturn:void 0}}),n=[...s,...i].sort((o,l)=>{var h,f;return((h=o.handler.priority)!=null?h:0)-((f=l.handler.priority)!=null?f:0)});for(let{handler:o,earlyReturn:l}of n)if(r=o.handle(r),l!=null&&l(r))return r;return r},O=Ze;var Ye="__cb:",ta="chat:callback:",ea=720*60*60*1e3;function aa(t){return`${Ye}${t}`}function ra(){return crypto.randomUUID().replace(/-/g,"").slice(0,16)}async function sa(t,e){return{type:"actions",children:await Promise.all(t.children.map(async a=>{if(a.type!=="button"||!a.callbackUrl)return a;let r=ra(),s={url:a.callbackUrl,originalValue:a.value};return await e.set(`${ta}${r}`,s,ea),{type:"button",id:a.id,label:a.label,style:a.style,disabled:a.disabled,value:aa(r),actionType:a.actionType}}))}}function Dt(t){for(let e of t){if(e.type==="actions"){for(let a of e.children)if(a.type==="button"&&a.callbackUrl)return!0}if(e.type==="section"&&"children"in e&&Dt(e.children))return!0}return!1}async function vt(t,e){let a=[];for(let r of t)r.type==="actions"?a.push(await sa(r,e)):r.type==="section"&&"children"in r?a.push({...r,children:await vt(r.children,e)}):a.push(r);return a}async function D(t,e){return Dt(t.children)?{...t,children:await vt(t.children,e)}:t}var Ft=null;function v(){if(!Ft)throw new Error("No Chat singleton registered. Call chat.registerSingleton() first.");return Ft}var ia=new Set(["markdown_text","task_update","plan_update"]);async function*Ut(t){var r,s;let e=!1,a=!1;for await(let i of t){if(typeof i=="string"){yield i;continue}if(i===null||typeof i!="object"||!("type"in i))continue;let n=i;if(ia.has(n.type)){yield i;continue}let o=(s=(r=n.text)!=null?r:n.delta)!=null?s:n.textDelta;n.type==="text-delta"&&typeof o=="string"?(e&&a&&(yield`
22
+ `).at(-1);if(i&&i.trim().length>0)return`${t}\u200B`}return t},Ke=new RegExp("(?<=[\\p{L}\\p{N}_])~(?!~)(?=[\\p{L}\\p{N}_])","gu"),Xe=t=>!t||typeof t!="string"||!t.includes("~")?t:t.replace(Ke,(e,a)=>p(t,a)?e:"\\~"),qe=t=>{var e,a;let r=t.match(se);if(r){let s=r[2];if(!s||S.test(s))return t;let i=t.lastIndexOf(r[1]);if(p(t,i)||M(t,i))return t;if(((e=t.match(_t))==null?void 0:e.length)%2===1)return`${t}~~`}else{let s=t.match(ce);if(s){let i=t.lastIndexOf(s[0].slice(0,2));if(p(t,i)||M(t,i))return t;if(((a=t.match(_t))==null?void 0:a.length)%2===1)return`${t}~`}}return t},H=t=>t!==!1,Ge=t=>t===!0,g={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},Ve=[{handler:{name:"singleTilde",handle:Xe,priority:g.SINGLE_TILDE},optionKey:"singleTilde"},{handler:{name:"comparisonOperators",handle:Qt,priority:g.COMPARISON_OPERATORS},optionKey:"comparisonOperators"},{handler:{name:"htmlTags",handle:Fe,priority:g.HTML_TAGS},optionKey:"htmlTags"},{handler:{name:"setextHeadings",handle:Be,priority:g.SETEXT_HEADINGS},optionKey:"setextHeadings"},{handler:{name:"links",handle:xt,priority:g.LINKS},optionKey:"links",earlyReturn:t=>t.endsWith("](streamdown:incomplete-link)")},{handler:{name:"boldItalic",handle:Ce,priority:g.BOLD_ITALIC},optionKey:"boldItalic"},{handler:{name:"bold",handle:_e,priority:g.BOLD},optionKey:"bold"},{handler:{name:"italicDoubleUnderscore",handle:be,priority:g.ITALIC_DOUBLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"italicSingleAsterisk",handle:Me,priority:g.ITALIC_SINGLE_ASTERISK},optionKey:"italic"},{handler:{name:"italicSingleUnderscore",handle:Te,priority:g.ITALIC_SINGLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"inlineCode",handle:Re,priority:g.INLINE_CODE},optionKey:"inlineCode"},{handler:{name:"strikethrough",handle:qe,priority:g.STRIKETHROUGH},optionKey:"strikethrough"},{handler:{name:"katex",handle:ve,priority:g.KATEX},optionKey:"katex"},{handler:{name:"inlineKatex",handle:Ue,priority:g.INLINE_KATEX},optionKey:"inlineKatex"}],Qe=t=>{var e;let a=(e=t==null?void 0:t.linkMode)!=null?e:"protocol";return Ve.filter(({handler:r,optionKey:s})=>r.name==="links"?H(t==null?void 0:t.links)||H(t==null?void 0:t.images):r.name==="inlineKatex"?Ge(t==null?void 0:t.inlineKatex):H(t==null?void 0:t[s])).map(({handler:r,earlyReturn:s})=>r.name==="links"?{handler:Mt(kt({},r),{handle:i=>xt(i,a)}),earlyReturn:a==="protocol"?s:void 0}:{handler:r,earlyReturn:s})},Ze=(t,e)=>{var a;if(!t||typeof t!="string")return t;let r=t.endsWith(" ")&&!t.endsWith(" ")?t.slice(0,-1):t,s=Qe(e),i=((a=e==null?void 0:e.handlers)!=null?a:[]).map(o=>{var l;return{handler:Mt(kt({},o),{priority:(l=o.priority)!=null?l:g.DEFAULT}),earlyReturn:void 0}}),n=[...s,...i].sort((o,l)=>{var h,f;return((h=o.handler.priority)!=null?h:0)-((f=l.handler.priority)!=null?f:0)});for(let{handler:o,earlyReturn:l}of n)if(r=o.handle(r),l!=null&&l(r))return r;return r},O=Ze;var Ye="__cb:",ta="chat:callback:",ea=720*60*60*1e3;function aa(t){return`${Ye}${t}`}function ra(){return crypto.randomUUID().replace(/-/g,"").slice(0,16)}async function sa(t,e){return{type:"actions",children:await Promise.all(t.children.map(async a=>{if(a.type!=="button"||!a.callbackUrl)return a;let r=ra(),s={url:a.callbackUrl,originalValue:a.value};return await e.set(`${ta}${r}`,s,ea),{type:"button",id:a.id,label:a.label,style:a.style,disabled:a.disabled,value:aa(r),actionType:a.actionType}}))}}function Dt(t){for(let e of t){if(e.type==="actions"){for(let a of e.children)if(a.type==="button"&&a.callbackUrl)return!0}if(e.type==="section"&&"children"in e&&Dt(e.children))return!0}return!1}async function vt(t,e){let a=[];for(let r of t)r.type==="actions"?a.push(await sa(r,e)):r.type==="section"&&"children"in r?a.push({...r,children:await vt(r.children,e)}):a.push(r);return a}async function D(t,e){return Dt(t.children)?{...t,children:await vt(t.children,e)}:t}var Ft=null;function v(){if(!Ft)throw new Error("No Chat singleton registered. Call chat.registerSingleton() first.");return Ft}var ia=new Set(["markdown_text","task_update","plan_update"]);async function*Ut(t){var r,s;let e=!1,a=!1;for await(let i of t){if(typeof i=="string"){yield i;continue}if(i===null||typeof i!="object"||!("type"in i))continue;let n=i;if(ia.has(n.type)){yield i;continue}let o=(s=(r=n.text)!=null?r:n.delta)!=null?s:n.textDelta;n.type==="text-delta"&&typeof o=="string"?(e&&a&&(yield`
23
23
 
24
- `),e=!1,a=!0,yield o):n.type==="finish-step"&&(e=!0)}}var na=new WeakMap;var T=class z{constructor(e){c(this,"id");c(this,"threadId");c(this,"text");c(this,"formatted");c(this,"raw");c(this,"author");c(this,"metadata");c(this,"attachments");c(this,"isMention");c(this,"userKey");c(this,"links");c(this,"_subjectPromise");var a;this.id=e.id,this.threadId=e.threadId,this.text=e.text,this.formatted=e.formatted,this.raw=e.raw,this.author=e.author,this.metadata=e.metadata,this.attachments=e.attachments,this.isMention=e.isMention,this.links=(a=e.links)!=null?a:[]}get subject(){if(this._subjectPromise)return this._subjectPromise;let e=na.get(this);return e!=null&&e.fetchSubject?(this._subjectPromise=e.fetchSubject(this.raw).catch(()=>null),this._subjectPromise):(this._subjectPromise=Promise.resolve(null),this._subjectPromise)}toJSON(){var e;return{_type:"chat:Message",id:this.id,threadId:this.threadId,text:this.text,formatted:this.formatted,raw:this.raw,author:{userId:this.author.userId,userName:this.author.userName,fullName:this.author.fullName,isBot:this.author.isBot,isMe:this.author.isMe},metadata:{dateSent:this.metadata.dateSent.toISOString(),edited:this.metadata.edited,editedAt:(e=this.metadata.editedAt)==null?void 0:e.toISOString()},attachments:this.attachments.map(a=>({type:a.type,url:a.url,name:a.name,mimeType:a.mimeType,size:a.size,width:a.width,height:a.height,fetchMetadata:a.fetchMetadata})),isMention:this.isMention,links:this.links.length>0?this.links.map(a=>({url:a.url,title:a.title,description:a.description,imageUrl:a.imageUrl,siteName:a.siteName})):void 0}}static fromJSON(e){return new z({id:e.id,threadId:e.threadId,text:e.text,formatted:e.formatted,raw:e.raw,author:e.author,metadata:{dateSent:new Date(e.metadata.dateSent),edited:e.metadata.edited,editedAt:e.metadata.editedAt?new Date(e.metadata.editedAt):void 0},attachments:e.attachments,isMention:e.isMention,links:e.links})}static[C](e){return e.toJSON()}static[x](e){return z.fromJSON(e)}},oa=Symbol.for("chat.postable");function Pt(t){return typeof t=="object"&&t!==null&&t.$$typeof===oa}async function Ht(t,e,a,r,s){let i=n=>{var o;return{adapter:e,logger:s,messageId:n.id,threadId:(o=n.threadId)!=null?o:a}};if(t.isSupported(e)&&e.postObject){let n=await e.postObject(a,t.kind,t.getPostData());t.onPosted(i(n))}else{let n=await r(a,t.getFallbackText());t.onPosted(i(n))}}var la=class extends Error{constructor(e,a,r){super(e);c(this,"code");c(this,"cause");this.name="ChatError",this.code=a,this.cause=r}};var Wt=class extends la{constructor(e,a,r){super(e,"NOT_IMPLEMENTED",r);c(this,"feature");this.name="NotImplementedError",this.feature=a}};var U=720*60*60*1e3,Nt="channel-state:";function ca(t){return"adapterName"in t&&!("adapter"in t)}function da(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var ha=class B{constructor(e){c(this,"id");c(this,"isDM");c(this,"channelVisibility");c(this,"_adapter");c(this,"_adapterName");c(this,"_stateAdapterInstance");c(this,"_name",null);c(this,"_threadHistory");var a,r;this.id=e.id,this.isDM=(a=e.isDM)!=null?a:!1,this.channelVisibility=(r=e.channelVisibility)!=null?r:"unknown",ca(e)?this._adapterName=e.adapterName:(this._adapter=e.adapter,this._stateAdapterInstance=e.stateAdapter,this._threadHistory=e.threadHistory)}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Channel has no adapter configured");let a=v().getAdapter(this._adapterName);if(!a)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=a,a}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let e=v();return this._stateAdapterInstance=e.getState(),this._stateAdapterInstance}get name(){return this._name}get state(){return this._stateAdapter.get(`${Nt}${this.id}`)}async setState(e,a){let r=`${Nt}${this.id}`;if(a!=null&&a.replace)await this._stateAdapter.set(r,e,U);else{let i={...await this._stateAdapter.get(r),...e};await this._stateAdapter.set(r,i,U)}}get messages(){let e=this.adapter,a=this.id,r=this._threadHistory;return{async*[Symbol.asyncIterator](){let s,i=!1;for(;;){let n={cursor:s,direction:"backward"},o=e.fetchChannelMessages?await e.fetchChannelMessages(a,n):await e.fetchMessages(a,n),l=[...o.messages].reverse();for(let h of l)i=!0,yield h;if(!o.nextCursor||o.messages.length===0)break;s=o.nextCursor}if(!i&&r){let n=await r.getMessages(a);for(let o=n.length-1;o>=0;o--)yield n[o]}}}}threads(){let e=this.adapter,a=this.id;return{async*[Symbol.asyncIterator](){if(!e.listThreads)return;let r;for(;;){let s=await e.listThreads(a,{cursor:r});for(let i of s.threads)yield i;if(!s.nextCursor||s.threads.length===0)break;r=s.nextCursor}}}}async fetchMetadata(){var e;if(this.adapter.fetchChannelInfo){let a=await this.adapter.fetchChannelInfo(this.id);return this._name=(e=a.name)!=null?e:null,a}return{id:this.id,isDM:this.isDM,metadata:{}}}async post(e){if(Pt(e))return await this.handlePostableObject(e),e;if(da(e)){let r="";for await(let s of Ut(e))typeof s=="string"?r+=s:s.type==="markdown_text"&&(r+=s.text);return this.postSingleMessage({markdown:r})}let a=e;if(y(e)){let r=_(e);if(!r)throw new Error("Invalid JSX element: must be a Card element");a=r}return a=await this.processCallbackUrls(a),this.postSingleMessage(a)}async handlePostableObject(e){await Ht(e,this.adapter,this.id,(a,r)=>this.adapter.postChannelMessage?this.adapter.postChannelMessage(a,r):this.adapter.postMessage(a,r))}async postSingleMessage(e){let a=this.adapter.postChannelMessage?await this.adapter.postChannelMessage(this.id,e):await this.adapter.postMessage(this.id,e),r=this.createSentMessage(a.id,e,a.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new T(r)),r}async postEphemeral(e,a,r){let{fallbackToDM:s}=r,i=typeof e=="string"?e:e.userId,n;if(y(a)){let o=_(a);if(!o)throw new Error("Invalid JSX element: must be a Card element");n=o}else n=a;if(n=await this.processCallbackUrls(n),this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,i,n);if(!s)return null;if(this.adapter.openDM){let o=await this.adapter.openDM(i),l=await this.adapter.postMessage(o,n);return{id:l.id,threadId:o,usedFallback:!0,raw:l.raw}}return null}async schedule(e,a){let r;if(y(e)){let s=_(e);if(!s)throw new Error("Invalid JSX element: must be a Card element");r=s}else r=e;if(r=await this.processCallbackUrls(r),!this.adapter.scheduleMessage)throw new Wt("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,r,a)}async processCallbackUrls(e){var a;if(typeof e=="string")return e;if("type"in e&&e.type==="card")return D(e,this._stateAdapter);if("card"in e&&((a=e.card)==null?void 0:a.type)==="card"){let r=await D(e.card,this._stateAdapter);if(r!==e.card)return{...e,card:r}}return e}async startTyping(e){await this.adapter.startTyping(this.id,e)}mentionUser(e){return`<@${e}>`}toJSON(){var e;return{_type:"chat:Channel",id:this.id,adapterName:(e=this._adapterName)!=null?e:this.adapter.name,channelVisibility:this.channelVisibility,isDM:this.isDM}}static fromJSON(e,a){let r=new B({id:e.id,adapterName:e.adapterName,channelVisibility:e.channelVisibility,isDM:e.isDM});return a&&(r._adapter=a),r}static[C](e){return e.toJSON()}static[x](e){return B.fromJSON(e)}createSentMessage(e,a,r){let s=this.adapter,i=r||this.id,n=this,{plainText:o,formatted:l,attachments:h}=fa(a);return{id:e,threadId:i,text:o,formatted:l,raw:null,author:{userId:"self",userName:s.userName,fullName:s.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:h,links:[],toJSON(){return new T(this).toJSON()},async edit(d){let u=d;if(y(d)){let m=_(d);if(!m)throw new Error("Invalid JSX element: must be a Card element");u=m}return u=await n.processCallbackUrls(u),await s.editMessage(i,e,u),n.createSentMessage(e,u)},async delete(){await s.deleteMessage(i,e)},async addReaction(d){await s.addReaction(i,e,d)},async removeReaction(d){await s.removeReaction(i,e,d)}}}};function ua(t,e){return t.channelIdFromThreadId(e)}function fa(t){if(typeof t=="string")return{plainText:t,formatted:k([b([w(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:k([b([w(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let e=P(t.markdown);return{plainText:L(e),formatted:e,attachments:t.attachments||[]}}if("ast"in t)return{plainText:L(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let e=t.fallbackText||R(t.card);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}if("type"in t&&t.type==="card"){let e=R(t);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var ga=class{constructor(t={}){c(this,"accumulated","");c(this,"dirty",!0);c(this,"cachedRender","");c(this,"finished",!1);c(this,"fenceToggles",0);c(this,"incompleteLine","");c(this,"options");var e;this.options={wrapTablesForAppend:(e=t.wrapTablesForAppend)!=null?e:!0}}push(t){var a;this.accumulated+=t,this.dirty=!0,this.incompleteLine+=t;let e=this.incompleteLine.split(`
24
+ `),e=!1,a=!0,yield o):n.type==="finish-step"&&(e=!0)}}var na=new WeakMap;var T=class z{constructor(e){c(this,"id");c(this,"threadId");c(this,"text");c(this,"formatted");c(this,"raw");c(this,"author");c(this,"metadata");c(this,"attachments");c(this,"isMention");c(this,"userKey");c(this,"links");c(this,"_subjectPromise");var a;this.id=e.id,this.threadId=e.threadId,this.text=e.text,this.formatted=e.formatted,this.raw=e.raw,this.author=e.author,this.metadata=e.metadata,this.attachments=e.attachments,this.isMention=e.isMention,this.links=(a=e.links)!=null?a:[]}get subject(){if(this._subjectPromise)return this._subjectPromise;let e=na.get(this);return e!=null&&e.fetchSubject?(this._subjectPromise=e.fetchSubject(this.raw).catch(()=>null),this._subjectPromise):(this._subjectPromise=Promise.resolve(null),this._subjectPromise)}toJSON(){var e;return{_type:"chat:Message",id:this.id,threadId:this.threadId,text:this.text,formatted:this.formatted,raw:this.raw,author:{userId:this.author.userId,userName:this.author.userName,fullName:this.author.fullName,isBot:this.author.isBot,isMe:this.author.isMe},metadata:{dateSent:this.metadata.dateSent.toISOString(),edited:this.metadata.edited,editedAt:(e=this.metadata.editedAt)==null?void 0:e.toISOString()},attachments:this.attachments.map(a=>({type:a.type,url:a.url,name:a.name,mimeType:a.mimeType,size:a.size,width:a.width,height:a.height,fetchMetadata:a.fetchMetadata})),isMention:this.isMention,links:this.links.length>0?this.links.map(a=>({url:a.url,title:a.title,description:a.description,imageUrl:a.imageUrl,siteName:a.siteName})):void 0}}static fromJSON(e){return new z({id:e.id,threadId:e.threadId,text:e.text,formatted:e.formatted,raw:e.raw,author:e.author,metadata:{dateSent:new Date(e.metadata.dateSent),edited:e.metadata.edited,editedAt:e.metadata.editedAt?new Date(e.metadata.editedAt):void 0},attachments:e.attachments,isMention:e.isMention,links:e.links})}static[C](e){return e.toJSON()}static[x](e){return z.fromJSON(e)}},oa=Symbol.for("chat.postable");function Pt(t){return typeof t=="object"&&t!==null&&t.$$typeof===oa}async function Ht(t,e,a,r,s){let i=n=>{var o;return{adapter:e,logger:s,messageId:n.id,threadId:(o=n.threadId)!=null?o:a}};if(t.isSupported(e)&&e.postObject){let n=await e.postObject(a,t.kind,t.getPostData());t.onPosted(i(n))}else{let n=await r(a,t.getFallbackText());t.onPosted(i(n))}}var la=class extends Error{constructor(e,a,r){super(e);c(this,"code");c(this,"cause");this.name="ChatError",this.code=a,this.cause=r}};var Wt=class extends la{constructor(e,a,r){super(e,"NOT_IMPLEMENTED",r);c(this,"feature");this.name="NotImplementedError",this.feature=a}};var U=720*60*60*1e3,Nt="channel-state:";function ca(t){return"adapterName"in t&&!("adapter"in t)}function da(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var ha=class B{constructor(e){c(this,"id");c(this,"isDM");c(this,"channelVisibility");c(this,"_adapter");c(this,"_adapterName");c(this,"_stateAdapterInstance");c(this,"_name",null);c(this,"_threadHistory");var a,r;this.id=e.id,this.isDM=(a=e.isDM)!=null?a:!1,this.channelVisibility=(r=e.channelVisibility)!=null?r:"unknown",ca(e)?this._adapterName=e.adapterName:(this._adapter=e.adapter,this._stateAdapterInstance=e.stateAdapter,this._threadHistory=e.threadHistory)}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Channel has no adapter configured");let a=v().getAdapter(this._adapterName);if(!a)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=a,a}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let e=v();return this._stateAdapterInstance=e.getState(),this._stateAdapterInstance}get name(){return this._name}get state(){return this._stateAdapter.get(`${Nt}${this.id}`)}async setState(e,a){let r=`${Nt}${this.id}`;if(a!=null&&a.replace)await this._stateAdapter.set(r,e,U);else{let i={...await this._stateAdapter.get(r),...e};await this._stateAdapter.set(r,i,U)}}get messages(){let e=this.adapter,a=this.id,r=this._threadHistory;return{async*[Symbol.asyncIterator](){let s,i=!1;for(;;){let n={cursor:s,direction:"backward"},o=e.fetchChannelMessages?await e.fetchChannelMessages(a,n):await e.fetchMessages(a,n),l=[...o.messages].reverse();for(let h of l)i=!0,yield h;if(!o.nextCursor||o.messages.length===0)break;s=o.nextCursor}if(!i&&r){let n=await r.getMessages(a);for(let o=n.length-1;o>=0;o--)yield n[o]}}}}threads(){let e=this.adapter,a=this.id;return{async*[Symbol.asyncIterator](){if(!e.listThreads)return;let r;for(;;){let s=await e.listThreads(a,{cursor:r});for(let i of s.threads)yield i;if(!s.nextCursor||s.threads.length===0)break;r=s.nextCursor}}}}async fetchMetadata(){var e;if(this.adapter.fetchChannelInfo){let a=await this.adapter.fetchChannelInfo(this.id);return this._name=(e=a.name)!=null?e:null,a}return{id:this.id,isDM:this.isDM,metadata:{}}}async post(e){if(Pt(e))return await this.handlePostableObject(e),e;if(da(e)){let r="";for await(let s of Ut(e))typeof s=="string"?r+=s:s.type==="markdown_text"&&(r+=s.text);return this.postSingleMessage({markdown:r})}let a=e;if(_(e)){let r=y(e);if(!r)throw new Error("Invalid JSX element: must be a Card element");a=r}return a=await this.processCallbackUrls(a),this.postSingleMessage(a)}async handlePostableObject(e){await Ht(e,this.adapter,this.id,(a,r)=>this.adapter.postChannelMessage?this.adapter.postChannelMessage(a,r):this.adapter.postMessage(a,r))}async postSingleMessage(e){let a=this.adapter.postChannelMessage?await this.adapter.postChannelMessage(this.id,e):await this.adapter.postMessage(this.id,e),r=this.createSentMessage(a.id,e,a.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new T(r)),r}async postEphemeral(e,a,r){let{fallbackToDM:s}=r,i=typeof e=="string"?e:e.userId,n;if(_(a)){let o=y(a);if(!o)throw new Error("Invalid JSX element: must be a Card element");n=o}else n=a;if(n=await this.processCallbackUrls(n),this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,i,n);if(!s)return null;if(this.adapter.openDM){let o=await this.adapter.openDM(i),l=await this.adapter.postMessage(o,n);return{id:l.id,threadId:o,usedFallback:!0,raw:l.raw}}return null}async schedule(e,a){let r;if(_(e)){let s=y(e);if(!s)throw new Error("Invalid JSX element: must be a Card element");r=s}else r=e;if(r=await this.processCallbackUrls(r),!this.adapter.scheduleMessage)throw new Wt("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,r,a)}async processCallbackUrls(e){var a;if(typeof e=="string")return e;if("type"in e&&e.type==="card")return D(e,this._stateAdapter);if("card"in e&&((a=e.card)==null?void 0:a.type)==="card"){let r=await D(e.card,this._stateAdapter);if(r!==e.card)return{...e,card:r}}return e}async startTyping(e){await this.adapter.startTyping(this.id,e)}mentionUser(e){return`<@${e}>`}toJSON(){var e;return{_type:"chat:Channel",id:this.id,adapterName:(e=this._adapterName)!=null?e:this.adapter.name,channelVisibility:this.channelVisibility,isDM:this.isDM}}static fromJSON(e,a){let r=new B({id:e.id,adapterName:e.adapterName,channelVisibility:e.channelVisibility,isDM:e.isDM});return a&&(r._adapter=a),r}static[C](e){return e.toJSON()}static[x](e){return B.fromJSON(e)}createSentMessage(e,a,r){let s=this.adapter,i=r||this.id,n=this,{plainText:o,formatted:l,attachments:h}=fa(a);return{id:e,threadId:i,text:o,formatted:l,raw:null,author:{userId:"self",userName:s.userName,fullName:s.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:h,links:[],toJSON(){return new T(this).toJSON()},async edit(d){let u=d;if(_(d)){let m=y(d);if(!m)throw new Error("Invalid JSX element: must be a Card element");u=m}return u=await n.processCallbackUrls(u),await s.editMessage(i,e,u),n.createSentMessage(e,u)},async delete(){await s.deleteMessage(i,e)},async addReaction(d){await s.addReaction(i,e,d)},async removeReaction(d){await s.removeReaction(i,e,d)}}}};function ua(t,e){return t.channelIdFromThreadId(e)}function fa(t){if(typeof t=="string")return{plainText:t,formatted:k([b([w(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:k([b([w(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let e=P(t.markdown);return{plainText:L(e),formatted:e,attachments:t.attachments||[]}}if("ast"in t)return{plainText:L(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let e=t.fallbackText||R(t.card);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}if("type"in t&&t.type==="card"){let e=R(t);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var ga=class{constructor(t={}){c(this,"accumulated","");c(this,"dirty",!0);c(this,"cachedRender","");c(this,"finished",!1);c(this,"fenceToggles",0);c(this,"incompleteLine","");c(this,"options");var e;this.options={wrapTablesForAppend:(e=t.wrapTablesForAppend)!=null?e:!0}}push(t){var a;this.accumulated+=t,this.dirty=!0,this.incompleteLine+=t;let e=this.incompleteLine.split(`
25
25
  `);this.incompleteLine=(a=e.pop())!=null?a:"";for(let r of e){let s=r.trimStart();(s.startsWith("```")||s.startsWith("~~~"))&&this.fenceToggles++}}isAccumulatedInsideFence(){let t=this.fenceToggles%2===1,e=this.incompleteLine.trimStart();return(e.startsWith("```")||e.startsWith("~~~"))&&(t=!t),t}render(){if(!this.dirty)return this.cachedRender;if(this.dirty=!1,this.finished)return this.cachedRender=O(this.accumulated),this.cachedRender;if(this.isAccumulatedInsideFence())return this.cachedRender=O(this.accumulated),this.cachedRender;let t=Rt(this.accumulated);return this.cachedRender=O(t),this.cachedRender}getCommittableText(){if(this.finished)return this.formatAppendOnlyText(this.accumulated,!0);let t=this.accumulated;if(t.length>0&&!t.endsWith(`
26
26
  `)){let r=t.lastIndexOf(`
27
- `),s=r>=0?t.slice(0,r+1):"";if(j(s))return this.formatAppendOnlyText(t);t=s}if(j(t))return this.formatAppendOnlyText(t);let e=Rt(t),a=this.formatAppendOnlyText(e);return j(a)?a:ma(a)}getText(){return this.accumulated}finish(){return this.finished=!0,this.dirty=!0,this.render()}formatAppendOnlyText(t,e=!1){return this.options.wrapTablesForAppend?_a(t,e):t}},pa=new Set(["*","~","`","["]);function Lt(t){return O(t).length<=t.length}function ma(t){if(t.length===0||Lt(t))return t;for(let e=t.length-1;e>=0;e--)if(pa.has(t[e])){for(;e>0&&t[e-1]===t[e];)e--;let a=t.slice(0,e);if(Lt(a))return a}return""}var K=/^\|.*\|$/,X=/^\|[\s:]*-{1,}[\s:]*(\|[\s:]*-{1,}[\s:]*)*\|$/;function j(t){let e=!1;for(let a of t.split(`
27
+ `),s=r>=0?t.slice(0,r+1):"";if(j(s))return this.formatAppendOnlyText(t);t=s}if(j(t))return this.formatAppendOnlyText(t);let e=Rt(t),a=this.formatAppendOnlyText(e);return j(a)?a:ma(a)}getText(){return this.accumulated}finish(){return this.finished=!0,this.dirty=!0,this.render()}formatAppendOnlyText(t,e=!1){return this.options.wrapTablesForAppend?ya(t,e):t}},pa=new Set(["*","~","`","["]);function Lt(t){return O(t).length<=t.length}function ma(t){if(t.length===0||Lt(t))return t;for(let e=t.length-1;e>=0;e--)if(pa.has(t[e])){for(;e>0&&t[e-1]===t[e];)e--;let a=t.slice(0,e);if(Lt(a))return a}return""}var K=/^\|.*\|$/,X=/^\|[\s:]*-{1,}[\s:]*(\|[\s:]*-{1,}[\s:]*)*\|$/;function j(t){let e=!1;for(let a of t.split(`
28
28
  `)){let r=a.trimStart();(r.startsWith("```")||r.startsWith("~~~"))&&(e=!e)}return e}function Rt(t){let e=t.endsWith(`
29
29
  `),a=t.split(`
30
30
  `);!e&&a.length>0&&a.pop(),e&&a.length>0&&a.at(-1)===""&&a.pop();let r=0,s=!1;for(let l=a.length-1;l>=0;l--){let h=a[l].trim();if(h==="")break;if(X.test(h)){s=!0;break}if(K.test(h))r++;else break}if(s||r===0)return t;let i=a.length-r,n=a.slice(0,i),o=n.join(`
31
31
  `);return n.length>0&&(o+=`
32
- `),o}function _a(t,e=!1){let a=t.endsWith(`
32
+ `),o}function ya(t,e=!1){let a=t.endsWith(`
33
33
  `),r=t.split(`
34
34
  `);a&&r.length>0&&r.at(-1)===""&&r.pop();let s=[],i=!1,n=!1;for(let l=0;l<r.length;l++){let h=r[l].trim();if(!i&&(h.startsWith("```")||h.startsWith("~~~"))){n=!n,s.push(r[l]);continue}if(n){s.push(r[l]);continue}let f=h!==""&&(K.test(h)||X.test(h));if(f&&!i){let d=!1;for(let u=l;u<r.length;u++){let m=r[u].trim();if(X.test(m)){d=!0;break}if(m===""||!K.test(m))break}d&&(s.push("```"),i=!0)}else!f&&i&&(s.push("```"),i=!1);s.push(r[l])}i&&e&&s.push("```");let o=s.join(`
35
35
  `);return a&&(o+=`
36
- `),o}function ya(t){return"adapterName"in t&&!("adapter"in t)}var Ot="thread-state:";function wa(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var mr=class q{constructor(e){c(this,"id");c(this,"channelId");c(this,"isDM");c(this,"channelVisibility");c(this,"_adapter");c(this,"_adapterName");c(this,"_stateAdapterInstance");c(this,"_recentMessages",[]);c(this,"_isSubscribedContext");c(this,"_currentMessage");c(this,"_streamingUpdateIntervalMs");c(this,"_fallbackStreamingPlaceholderText");c(this,"_channel");c(this,"_threadHistory");c(this,"_logger");var a,r,s,i;this.id=e.id,this.channelId=e.channelId,this.isDM=(a=e.isDM)!=null?a:!1,this.channelVisibility=(r=e.channelVisibility)!=null?r:"unknown",this._isSubscribedContext=(s=e.isSubscribedContext)!=null?s:!1,this._currentMessage=e.currentMessage,this._logger=e.logger,this._streamingUpdateIntervalMs=(i=e.streamingUpdateIntervalMs)!=null?i:500,this._fallbackStreamingPlaceholderText=e.fallbackStreamingPlaceholderText!==void 0?e.fallbackStreamingPlaceholderText:"...",ya(e)?this._adapterName=e.adapterName:(this._adapter=e.adapter,this._stateAdapterInstance=e.stateAdapter,this._threadHistory=e.threadHistory),e.initialMessage&&(this._recentMessages=[e.initialMessage])}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Thread has no adapter configured");let a=v().getAdapter(this._adapterName);if(!a)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=a,a}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let e=v();return this._stateAdapterInstance=e.getState(),this._stateAdapterInstance}get recentMessages(){return this._recentMessages}set recentMessages(e){this._recentMessages=e}get state(){return this._stateAdapter.get(`${Ot}${this.id}`)}async setState(e,a){let r=`${Ot}${this.id}`;if(a!=null&&a.replace)await this._stateAdapter.set(r,e,U);else{let i={...await this._stateAdapter.get(r),...e};await this._stateAdapter.set(r,i,U)}}get channel(){if(!this._channel){let e=ua(this.adapter,this.id);this._channel=new ha({id:e,adapter:this.adapter,stateAdapter:this._stateAdapter,isDM:this.isDM,channelVisibility:this.channelVisibility,threadHistory:this._threadHistory})}return this._channel}get messages(){let e=this.adapter,a=this.id,r=this._threadHistory;return{async*[Symbol.asyncIterator](){let s,i=!1;for(;;){let n=await e.fetchMessages(a,{cursor:s,direction:"backward"}),o=[...n.messages].reverse();for(let l of o)i=!0,yield l;if(!n.nextCursor||n.messages.length===0)break;s=n.nextCursor}if(!i&&r){let n=await r.getMessages(a);for(let o=n.length-1;o>=0;o--)yield n[o]}}}}get allMessages(){let e=this.adapter,a=this.id,r=this._threadHistory;return{async*[Symbol.asyncIterator](){let s,i=!1;for(;;){let n=await e.fetchMessages(a,{limit:100,cursor:s,direction:"forward"});for(let o of n.messages)i=!0,yield o;if(!n.nextCursor||n.messages.length===0)break;s=n.nextCursor}if(!i&&r){let n=await r.getMessages(a);for(let o of n)yield o}}}}async getParticipants(){let e=new Map;this._currentMessage&&!this._currentMessage.author.isMe&&!this._currentMessage.author.isBot&&e.set(this._currentMessage.author.userId,this._currentMessage.author);for await(let a of this.allMessages)a.author.isMe||a.author.isBot||e.has(a.author.userId)||e.set(a.author.userId,a.author);return[...e.values()]}async isSubscribed(){return this._isSubscribedContext?!0:this._stateAdapter.isSubscribed(this.id)}async subscribe(){await this._stateAdapter.subscribe(this.id),this.adapter.onThreadSubscribe&&await this.adapter.onThreadSubscribe(this.id)}async unsubscribe(){await this._stateAdapter.unsubscribe(this.id)}async post(e){if(Pt(e)){if(e.kind==="stream"){let i=e.getPostData(),n={...i.options.updateIntervalMs?{updateIntervalMs:i.options.updateIntervalMs}:{},...i.options.groupTasks?{taskDisplayMode:i.options.groupTasks}:{},...i.options.endWith?{stopBlocks:i.options.endWith}:{}};return await this.handleStream(i.stream,n),e}return await this.handlePostableObject(e),e}if(wa(e))return this.handleStream(e);let a=e;if(y(e)){let i=_(e);if(!i)throw new Error("Invalid JSX element: must be a Card element");a=i}a=await this.processCallbackUrls(a);let r=await this.adapter.postMessage(this.id,a),s=this.createSentMessage(r.id,a,r.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new T(s)),s}async handlePostableObject(e){await Ht(e,this.adapter,this.id,(a,r)=>this.adapter.postMessage(a,r),this._logger)}async postEphemeral(e,a,r){let{fallbackToDM:s}=r,i=typeof e=="string"?e:e.userId,n;if(y(a)){let o=_(a);if(!o)throw new Error("Invalid JSX element: must be a Card element");n=o}else n=a;if(n=await this.processCallbackUrls(n),this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,i,n);if(!s)return null;if(this.adapter.openDM){let o=await this.adapter.openDM(i),l=await this.adapter.postMessage(o,n);return{id:l.id,threadId:o,usedFallback:!0,raw:l.raw}}return null}async processCallbackUrls(e){var a;if(typeof e=="string")return e;if("type"in e&&e.type==="card")return D(e,this._stateAdapter);if("card"in e&&((a=e.card)==null?void 0:a.type)==="card"){let r=await D(e.card,this._stateAdapter);if(r!==e.card)return{...e,card:r}}return e}async schedule(e,a){let r;if(y(e)){let s=_(e);if(!s)throw new Error("Invalid JSX element: must be a Card element");r=s}else r=e;if(r=await this.processCallbackUrls(r),!this.adapter.scheduleMessage)throw new Wt("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,r,a)}async handleStream(e,a){let r=Ut(e),s={updateIntervalMs:this._streamingUpdateIntervalMs,...a};if(this._currentMessage&&(s.recipientUserId=this._currentMessage.author.userId,s.recipientTeamId=this.extractSlackRecipientTeamId(this._currentMessage.raw)),this.adapter.stream){let n="",o={[Symbol.asyncIterator]:()=>{let h=r[Symbol.asyncIterator]();return{async next(){let f=await h.next();if(!f.done){let d=f.value;typeof d=="string"?n+=d:d.type==="markdown_text"&&(n+=d.text)}return f}}}},l=await this.adapter.stream(this.id,o,s);if(l){let h=this.createSentMessage(l.id,{markdown:n},l.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new T(h)),h}}let i={[Symbol.asyncIterator]:()=>{let n=r[Symbol.asyncIterator]();return{async next(){for(;;){let o=await n.next();if(o.done)return{value:void 0,done:!0};let l=o.value;if(typeof l=="string")return{value:l,done:!1};if(l.type==="markdown_text")return{value:l.text,done:!1}}}}}};return this.fallbackStream(i,s)}extractSlackRecipientTeamId(e){var r;if(!e||typeof e!="object")return;let a=e;if(typeof a.team_id=="string"&&a.team_id)return a.team_id;if(typeof a.team=="string"&&a.team)return a.team;if(a.team&&typeof a.team=="object"&&typeof a.team.id=="string"&&a.team.id)return a.team.id;if(typeof((r=a.user)==null?void 0:r.team_id)=="string"&&a.user.team_id)return a.user.team_id}async startTyping(e){await this.adapter.startTyping(this.id,e)}async fallbackStream(e,a){var Q;let r=(Q=a==null?void 0:a.updateIntervalMs)!=null?Q:this._streamingUpdateIntervalMs,s=this._fallbackStreamingPlaceholderText,i=s===null?null:await this.adapter.postMessage(this.id,s),n=this.id,o=new ga,l="",h=!1,f=null,d=null;i&&(n=i.threadId||this.id,l=s!=null?s:"");let u=()=>{d=setTimeout(()=>{f=m()},r)},m=async()=>{var A;if(h||!i)return;let E=o.render();if(E.trim()&&E!==l)try{await this.adapter.editMessage(n,i.id,{markdown:E}),l=E}catch(Jt){(A=this._logger)==null||A.warn("fallbackStream edit failed",Jt)}h||u()};i&&u();try{for await(let E of e)if(o.push(E),!i){let A=o.render();A.trim()&&(i=await this.adapter.postMessage(this.id,{markdown:A}),n=i.threadId||this.id,l=A,u())}}finally{h=!0,d&&(clearTimeout(d),d=null)}f&&await f;let N=o.getText(),G=o.finish();i||(i=await this.adapter.postMessage(this.id,{markdown:N.trim()?N:" "}),n=i.threadId||this.id,l=N),G.trim()&&G!==l&&await this.adapter.editMessage(n,i.id,{markdown:N});let V=this.createSentMessage(i.id,{markdown:N},n);return this._threadHistory&&await this._threadHistory.append(this.id,new T(V)),V}async refresh(){let e=await this.adapter.fetchMessages(this.id,{limit:50});e.messages.length>0?this._recentMessages=e.messages:this._threadHistory?this._recentMessages=await this._threadHistory.getMessages(this.id,50):this._recentMessages=[]}mentionUser(e){return`<@${e}>`}toJSON(){var e,a;return{_type:"chat:Thread",id:this.id,channelId:this.channelId,channelVisibility:this.channelVisibility,currentMessage:(e=this._currentMessage)==null?void 0:e.toJSON(),isDM:this.isDM,adapterName:(a=this._adapterName)!=null?a:this.adapter.name}}static fromJSON(e,a){let r=new q({id:e.id,adapterName:e.adapterName,channelId:e.channelId,channelVisibility:e.channelVisibility,currentMessage:e.currentMessage?T.fromJSON(e.currentMessage):void 0,isDM:e.isDM});return a&&(r._adapter=a),r}static[C](e){return e.toJSON()}static[x](e){return q.fromJSON(e)}createSentMessage(e,a,r){let s=this.adapter,i=r||this.id,n=this,{plainText:o,formatted:l,attachments:h}=ba(a);return{id:e,threadId:i,text:o,formatted:l,raw:null,links:[],author:{userId:"self",userName:s.userName,fullName:s.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:h,toJSON(){return new T(this).toJSON()},async edit(d){let u=d;if(y(d)){let m=_(d);if(!m)throw new Error("Invalid JSX element: must be a Card element");u=m}return u=await n.processCallbackUrls(u),await s.editMessage(i,e,u),n.createSentMessage(e,u)},async delete(){await s.deleteMessage(i,e)},async addReaction(d){await s.addReaction(i,e,d)},async removeReaction(d){await s.removeReaction(i,e,d)}}}createSentMessageFromMessage(e){let a=this.adapter,r=this.id,s=e.id,i=this;return{id:e.id,threadId:e.threadId,text:e.text,formatted:e.formatted,raw:e.raw,author:e.author,metadata:e.metadata,attachments:e.attachments,links:e.links,isMention:e.isMention,toJSON(){return e.toJSON()},async edit(n){let o=n;if(y(n)){let l=_(n);if(!l)throw new Error("Invalid JSX element: must be a Card element");o=l}return o=await i.processCallbackUrls(o),await a.editMessage(r,s,o),i.createSentMessage(s,o,r)},async delete(){await a.deleteMessage(r,s)},async addReaction(n){await a.addReaction(r,s,n)},async removeReaction(n){await a.removeReaction(r,s,n)}}}};function ba(t){if(typeof t=="string")return{plainText:t,formatted:k([b([w(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:k([b([w(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let e=P(t.markdown);return{plainText:L(e),formatted:e,attachments:t.attachments||[]}}if("ast"in t)return{plainText:L(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let e=t.fallbackText||R(t.card);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}if("type"in t&&t.type==="card"){let e=R(t);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var _r=10080*60*1e3;var yr=300*1e3,wr=1440*60*1e3;var $t=new Map;function F(t){let e=$t.get(t);return e||(e=Object.freeze({name:t,toString:()=>`{{emoji:${t}}}`,toJSON:()=>`{{emoji:${t}}}`}),$t.set(t,e)),e}var ka={thumbs_up:{slack:["+1","thumbsup"],gchat:"\u{1F44D}"},thumbs_down:{slack:["-1","thumbsdown"],gchat:"\u{1F44E}"},clap:{slack:"clap",gchat:"\u{1F44F}"},wave:{slack:"wave",gchat:"\u{1F44B}"},pray:{slack:"pray",gchat:"\u{1F64F}"},muscle:{slack:"muscle",gchat:"\u{1F4AA}"},ok_hand:{slack:"ok_hand",gchat:"\u{1F44C}"},point_up:{slack:"point_up",gchat:"\u{1F446}"},point_down:{slack:"point_down",gchat:"\u{1F447}"},point_left:{slack:"point_left",gchat:"\u{1F448}"},point_right:{slack:"point_right",gchat:"\u{1F449}"},raised_hands:{slack:"raised_hands",gchat:"\u{1F64C}"},shrug:{slack:"shrug",gchat:"\u{1F937}"},facepalm:{slack:"facepalm",gchat:"\u{1F926}"},heart:{slack:"heart",gchat:["\u2764\uFE0F","\u2764"]},smile:{slack:["smile","slightly_smiling_face"],gchat:"\u{1F60A}"},laugh:{slack:["laughing","satisfied","joy"],gchat:["\u{1F602}","\u{1F606}"]},thinking:{slack:"thinking_face",gchat:"\u{1F914}"},sad:{slack:["cry","sad","white_frowning_face"],gchat:"\u{1F622}"},cry:{slack:"sob",gchat:"\u{1F62D}"},angry:{slack:"angry",gchat:"\u{1F620}"},love_eyes:{slack:"heart_eyes",gchat:"\u{1F60D}"},cool:{slack:"sunglasses",gchat:"\u{1F60E}"},wink:{slack:"wink",gchat:"\u{1F609}"},surprised:{slack:"open_mouth",gchat:"\u{1F62E}"},worried:{slack:"worried",gchat:"\u{1F61F}"},confused:{slack:"confused",gchat:"\u{1F615}"},neutral:{slack:"neutral_face",gchat:"\u{1F610}"},sleeping:{slack:"sleeping",gchat:"\u{1F634}"},sick:{slack:"nauseated_face",gchat:"\u{1F922}"},mind_blown:{slack:"exploding_head",gchat:"\u{1F92F}"},relieved:{slack:"relieved",gchat:"\u{1F60C}"},grimace:{slack:"grimacing",gchat:"\u{1F62C}"},rolling_eyes:{slack:"rolling_eyes",gchat:"\u{1F644}"},hug:{slack:"hugging_face",gchat:"\u{1F917}"},zany:{slack:"zany_face",gchat:"\u{1F92A}"},check:{slack:["white_check_mark","heavy_check_mark"],gchat:["\u2705","\u2714\uFE0F"]},x:{slack:["x","heavy_multiplication_x"],gchat:["\u274C","\u2716\uFE0F"]},question:{slack:"question",gchat:["\u2753","?"]},exclamation:{slack:"exclamation",gchat:"\u2757"},warning:{slack:"warning",gchat:"\u26A0\uFE0F"},stop:{slack:"octagonal_sign",gchat:"\u{1F6D1}"},info:{slack:"information_source",gchat:"\u2139\uFE0F"},100:{slack:"100",gchat:"\u{1F4AF}"},fire:{slack:"fire",gchat:"\u{1F525}"},star:{slack:"star",gchat:"\u2B50"},sparkles:{slack:"sparkles",gchat:"\u2728"},lightning:{slack:"zap",gchat:"\u26A1"},boom:{slack:"boom",gchat:"\u{1F4A5}"},eyes:{slack:"eyes",gchat:"\u{1F440}"},green_circle:{slack:"large_green_circle",gchat:"\u{1F7E2}"},yellow_circle:{slack:"large_yellow_circle",gchat:"\u{1F7E1}"},red_circle:{slack:"red_circle",gchat:"\u{1F534}"},blue_circle:{slack:"large_blue_circle",gchat:"\u{1F535}"},white_circle:{slack:"white_circle",gchat:"\u26AA"},black_circle:{slack:"black_circle",gchat:"\u26AB"},rocket:{slack:"rocket",gchat:"\u{1F680}"},party:{slack:["tada","partying_face"],gchat:["\u{1F389}","\u{1F973}"]},confetti:{slack:"confetti_ball",gchat:"\u{1F38A}"},balloon:{slack:"balloon",gchat:"\u{1F388}"},gift:{slack:"gift",gchat:"\u{1F381}"},trophy:{slack:"trophy",gchat:"\u{1F3C6}"},medal:{slack:"first_place_medal",gchat:"\u{1F947}"},lightbulb:{slack:"bulb",gchat:"\u{1F4A1}"},gear:{slack:"gear",gchat:"\u2699\uFE0F"},wrench:{slack:"wrench",gchat:"\u{1F527}"},hammer:{slack:"hammer",gchat:"\u{1F528}"},bug:{slack:"bug",gchat:"\u{1F41B}"},link:{slack:"link",gchat:"\u{1F517}"},lock:{slack:"lock",gchat:"\u{1F512}"},unlock:{slack:"unlock",gchat:"\u{1F513}"},key:{slack:"key",gchat:"\u{1F511}"},pin:{slack:"pushpin",gchat:"\u{1F4CC}"},memo:{slack:"memo",gchat:"\u{1F4DD}"},clipboard:{slack:"clipboard",gchat:"\u{1F4CB}"},calendar:{slack:"calendar",gchat:"\u{1F4C5}"},clock:{slack:"clock1",gchat:"\u{1F550}"},hourglass:{slack:"hourglass",gchat:"\u23F3"},bell:{slack:"bell",gchat:"\u{1F514}"},megaphone:{slack:"mega",gchat:"\u{1F4E2}"},speech_bubble:{slack:"speech_balloon",gchat:"\u{1F4AC}"},email:{slack:"email",gchat:"\u{1F4E7}"},inbox:{slack:"inbox_tray",gchat:"\u{1F4E5}"},outbox:{slack:"outbox_tray",gchat:"\u{1F4E4}"},package:{slack:"package",gchat:"\u{1F4E6}"},folder:{slack:"file_folder",gchat:"\u{1F4C1}"},file:{slack:"page_facing_up",gchat:"\u{1F4C4}"},chart_up:{slack:"chart_with_upwards_trend",gchat:"\u{1F4C8}"},chart_down:{slack:"chart_with_downwards_trend",gchat:"\u{1F4C9}"},coffee:{slack:"coffee",gchat:"\u2615"},pizza:{slack:"pizza",gchat:"\u{1F355}"},beer:{slack:"beer",gchat:"\u{1F37A}"},arrow_up:{slack:"arrow_up",gchat:"\u2B06\uFE0F"},arrow_down:{slack:"arrow_down",gchat:"\u2B07\uFE0F"},arrow_left:{slack:"arrow_left",gchat:"\u2B05\uFE0F"},arrow_right:{slack:"arrow_right",gchat:"\u27A1\uFE0F"},refresh:{slack:"arrows_counterclockwise",gchat:"\u{1F504}"},sun:{slack:"sunny",gchat:"\u2600\uFE0F"},cloud:{slack:"cloud",gchat:"\u2601\uFE0F"},rain:{slack:"rain_cloud",gchat:"\u{1F327}\uFE0F"},snow:{slack:"snowflake",gchat:"\u2744\uFE0F"},rainbow:{slack:"rainbow",gchat:"\u{1F308}"}},Ma=class{constructor(t){c(this,"emojiMap");c(this,"slackToNormalized");c(this,"gchatToNormalized");this.emojiMap={...ka,...t},this.slackToNormalized=new Map,this.gchatToNormalized=new Map,this.buildReverseMaps()}buildReverseMaps(){for(let[t,e]of Object.entries(this.emojiMap)){let a=Array.isArray(e.slack)?e.slack:[e.slack];for(let s of a)this.slackToNormalized.set(s.toLowerCase(),t);let r=Array.isArray(e.gchat)?e.gchat:[e.gchat];for(let s of r)this.gchatToNormalized.set(s,t)}}fromSlack(t){var r;let e=t.replace(/^:|:$/g,"").toLowerCase(),a=(r=this.slackToNormalized.get(e))!=null?r:t;return F(a)}fromGChat(t){var a;let e=(a=this.gchatToNormalized.get(t))!=null?a:t;return F(e)}fromTeams(t){var r;let a=(r={like:"thumbs_up",heart:"heart",laugh:"laugh",surprised:"surprised",sad:"sad",angry:"angry"}[t])!=null?r:t;return F(a)}toSlack(t){let e=typeof t=="string"?t:t.name,a=this.emojiMap[e];return a?Array.isArray(a.slack)?a.slack[0]:a.slack:e}toGChat(t){let e=typeof t=="string"?t:t.name,a=this.emojiMap[e];return a?Array.isArray(a.gchat)?a.gchat[0]:a.gchat:e}toDiscord(t){return this.toGChat(t)}matches(t,e){let a=typeof e=="string"?e:e.name,r=this.emojiMap[a];if(!r)return t===a;let s=Array.isArray(r.slack)?r.slack:[r.slack],i=Array.isArray(r.gchat)?r.gchat:[r.gchat],n=t.replace(/^:|:$/g,"").toLowerCase();return s.some(o=>o.toLowerCase()===n)||i.includes(t)}extend(t){Object.assign(this.emojiMap,t),this.buildReverseMaps()}},Ia=new Ma;function Sa(t){let e=["thumbs_up","thumbs_down","clap","wave","pray","muscle","ok_hand","point_up","point_down","point_left","point_right","raised_hands","shrug","facepalm","heart","smile","laugh","thinking","sad","cry","angry","love_eyes","cool","wink","surprised","worried","confused","neutral","sleeping","sick","mind_blown","relieved","grimace","rolling_eyes","hug","zany","check","x","question","exclamation","warning","stop","info","100","fire","star","sparkles","lightning","boom","eyes","green_circle","yellow_circle","red_circle","blue_circle","white_circle","black_circle","rocket","party","confetti","balloon","gift","trophy","medal","lightbulb","gear","wrench","hammer","bug","link","lock","unlock","key","pin","memo","clipboard","calendar","clock","hourglass","bell","megaphone","speech_bubble","email","inbox","outbox","package","folder","file","chart_up","chart_down","coffee","pizza","beer","arrow_up","arrow_down","arrow_left","arrow_right","refresh","sun","cloud","rain","snow","rainbow"],a={custom:r=>F(r)};for(let r of e)a[r]=F(r);if(t){for(let r of Object.keys(t))a[r]=F(r);Ia.extend(t)}return a}var br=Sa(),kr=rt,Mr=st,Ir=Z;var Sr=ct,Tr=Y,Er=et,Ar=nt,Cr=ot;var xr=tt;var Fr=it,Nr=at,Lr=lt;var Rr=ft,Or=dt,$r=pt,Dr=ut,vr=gt,Ur=ht;export{kr as a,Mr as b,Ir as c,Sr as d,Tr as e,Er as f,Ar as g,Cr as h,xr as i,Fr as j,Nr as k,Lr as l,Rr as m,Or as n,$r as o,Dr as p,vr as q,Ur as r};
36
+ `),o}function _a(t){return"adapterName"in t&&!("adapter"in t)}var Ot="thread-state:";function wa(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var mr=class q{constructor(e){c(this,"id");c(this,"channelId");c(this,"isDM");c(this,"channelVisibility");c(this,"_adapter");c(this,"_adapterName");c(this,"_stateAdapterInstance");c(this,"_recentMessages",[]);c(this,"_isSubscribedContext");c(this,"_currentMessage");c(this,"_streamingUpdateIntervalMs");c(this,"_fallbackStreamingPlaceholderText");c(this,"_channel");c(this,"_threadHistory");c(this,"_logger");var a,r,s,i;this.id=e.id,this.channelId=e.channelId,this.isDM=(a=e.isDM)!=null?a:!1,this.channelVisibility=(r=e.channelVisibility)!=null?r:"unknown",this._isSubscribedContext=(s=e.isSubscribedContext)!=null?s:!1,this._currentMessage=e.currentMessage,this._logger=e.logger,this._streamingUpdateIntervalMs=(i=e.streamingUpdateIntervalMs)!=null?i:500,this._fallbackStreamingPlaceholderText=e.fallbackStreamingPlaceholderText!==void 0?e.fallbackStreamingPlaceholderText:"...",_a(e)?this._adapterName=e.adapterName:(this._adapter=e.adapter,this._stateAdapterInstance=e.stateAdapter,this._threadHistory=e.threadHistory),e.initialMessage&&(this._recentMessages=[e.initialMessage])}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Thread has no adapter configured");let a=v().getAdapter(this._adapterName);if(!a)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=a,a}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let e=v();return this._stateAdapterInstance=e.getState(),this._stateAdapterInstance}get recentMessages(){return this._recentMessages}set recentMessages(e){this._recentMessages=e}get state(){return this._stateAdapter.get(`${Ot}${this.id}`)}async setState(e,a){let r=`${Ot}${this.id}`;if(a!=null&&a.replace)await this._stateAdapter.set(r,e,U);else{let i={...await this._stateAdapter.get(r),...e};await this._stateAdapter.set(r,i,U)}}get channel(){if(!this._channel){let e=ua(this.adapter,this.id);this._channel=new ha({id:e,adapter:this.adapter,stateAdapter:this._stateAdapter,isDM:this.isDM,channelVisibility:this.channelVisibility,threadHistory:this._threadHistory})}return this._channel}get messages(){let e=this.adapter,a=this.id,r=this._threadHistory;return{async*[Symbol.asyncIterator](){let s,i=!1;for(;;){let n=await e.fetchMessages(a,{cursor:s,direction:"backward"}),o=[...n.messages].reverse();for(let l of o)i=!0,yield l;if(!n.nextCursor||n.messages.length===0)break;s=n.nextCursor}if(!i&&r){let n=await r.getMessages(a);for(let o=n.length-1;o>=0;o--)yield n[o]}}}}get allMessages(){let e=this.adapter,a=this.id,r=this._threadHistory;return{async*[Symbol.asyncIterator](){let s,i=!1;for(;;){let n=await e.fetchMessages(a,{limit:100,cursor:s,direction:"forward"});for(let o of n.messages)i=!0,yield o;if(!n.nextCursor||n.messages.length===0)break;s=n.nextCursor}if(!i&&r){let n=await r.getMessages(a);for(let o of n)yield o}}}}async getParticipants(){let e=new Map;this._currentMessage&&!this._currentMessage.author.isMe&&!this._currentMessage.author.isBot&&e.set(this._currentMessage.author.userId,this._currentMessage.author);for await(let a of this.allMessages)a.author.isMe||a.author.isBot||e.has(a.author.userId)||e.set(a.author.userId,a.author);return[...e.values()]}async isSubscribed(){return this._isSubscribedContext?!0:this._stateAdapter.isSubscribed(this.id)}async subscribe(){await this._stateAdapter.subscribe(this.id),this.adapter.onThreadSubscribe&&await this.adapter.onThreadSubscribe(this.id)}async unsubscribe(){await this._stateAdapter.unsubscribe(this.id)}async post(e){if(Pt(e)){if(e.kind==="stream"){let i=e.getPostData(),n={...i.options.updateIntervalMs?{updateIntervalMs:i.options.updateIntervalMs}:{},...i.options.groupTasks?{taskDisplayMode:i.options.groupTasks}:{},...i.options.endWith?{stopBlocks:i.options.endWith}:{}};return await this.handleStream(i.stream,n),e}return await this.handlePostableObject(e),e}if(wa(e))return this.handleStream(e);let a=e;if(_(e)){let i=y(e);if(!i)throw new Error("Invalid JSX element: must be a Card element");a=i}a=await this.processCallbackUrls(a);let r=await this.adapter.postMessage(this.id,a),s=this.createSentMessage(r.id,a,r.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new T(s)),s}async handlePostableObject(e){await Ht(e,this.adapter,this.id,(a,r)=>this.adapter.postMessage(a,r),this._logger)}async postEphemeral(e,a,r){let{fallbackToDM:s}=r,i=typeof e=="string"?e:e.userId,n;if(_(a)){let o=y(a);if(!o)throw new Error("Invalid JSX element: must be a Card element");n=o}else n=a;if(n=await this.processCallbackUrls(n),this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,i,n);if(!s)return null;if(this.adapter.openDM){let o=await this.adapter.openDM(i),l=await this.adapter.postMessage(o,n);return{id:l.id,threadId:o,usedFallback:!0,raw:l.raw}}return null}async processCallbackUrls(e){var a;if(typeof e=="string")return e;if("type"in e&&e.type==="card")return D(e,this._stateAdapter);if("card"in e&&((a=e.card)==null?void 0:a.type)==="card"){let r=await D(e.card,this._stateAdapter);if(r!==e.card)return{...e,card:r}}return e}async schedule(e,a){let r;if(_(e)){let s=y(e);if(!s)throw new Error("Invalid JSX element: must be a Card element");r=s}else r=e;if(r=await this.processCallbackUrls(r),!this.adapter.scheduleMessage)throw new Wt("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,r,a)}async handleStream(e,a){let r=Ut(e),s={updateIntervalMs:this._streamingUpdateIntervalMs,...a};if(this._currentMessage&&(s.recipientUserId=this._currentMessage.author.userId,s.recipientTeamId=this.extractSlackRecipientTeamId(this._currentMessage.raw)),this.adapter.stream){let n="",o={[Symbol.asyncIterator]:()=>{let h=r[Symbol.asyncIterator]();return{async next(){let f=await h.next();if(!f.done){let d=f.value;typeof d=="string"?n+=d:d.type==="markdown_text"&&(n+=d.text)}return f}}}},l=await this.adapter.stream(this.id,o,s);if(l){let h=this.createSentMessage(l.id,{markdown:n},l.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new T(h)),h}}let i={[Symbol.asyncIterator]:()=>{let n=r[Symbol.asyncIterator]();return{async next(){for(;;){let o=await n.next();if(o.done)return{value:void 0,done:!0};let l=o.value;if(typeof l=="string")return{value:l,done:!1};if(l.type==="markdown_text")return{value:l.text,done:!1}}}}}};return this.fallbackStream(i,s)}extractSlackRecipientTeamId(e){var r;if(!e||typeof e!="object")return;let a=e;if(typeof a.team_id=="string"&&a.team_id)return a.team_id;if(typeof a.team=="string"&&a.team)return a.team;if(a.team&&typeof a.team=="object"&&typeof a.team.id=="string"&&a.team.id)return a.team.id;if(typeof((r=a.user)==null?void 0:r.team_id)=="string"&&a.user.team_id)return a.user.team_id}async startTyping(e){await this.adapter.startTyping(this.id,e)}async fallbackStream(e,a){var Q;let r=(Q=a==null?void 0:a.updateIntervalMs)!=null?Q:this._streamingUpdateIntervalMs,s=this._fallbackStreamingPlaceholderText,i=s===null?null:await this.adapter.postMessage(this.id,s),n=this.id,o=new ga,l="",h=!1,f=null,d=null;i&&(n=i.threadId||this.id,l=s!=null?s:"");let u=()=>{d=setTimeout(()=>{f=m()},r)},m=async()=>{var A;if(h||!i)return;let E=o.render();if(E.trim()&&E!==l)try{await this.adapter.editMessage(n,i.id,{markdown:E}),l=E}catch(Jt){(A=this._logger)==null||A.warn("fallbackStream edit failed",Jt)}h||u()};i&&u();try{for await(let E of e)if(o.push(E),!i){let A=o.render();A.trim()&&(i=await this.adapter.postMessage(this.id,{markdown:A}),n=i.threadId||this.id,l=A,u())}}finally{h=!0,d&&(clearTimeout(d),d=null)}f&&await f;let N=o.getText(),G=o.finish();i||(i=await this.adapter.postMessage(this.id,{markdown:N.trim()?N:" "}),n=i.threadId||this.id,l=N),G.trim()&&G!==l&&await this.adapter.editMessage(n,i.id,{markdown:N});let V=this.createSentMessage(i.id,{markdown:N},n);return this._threadHistory&&await this._threadHistory.append(this.id,new T(V)),V}async refresh(){let e=await this.adapter.fetchMessages(this.id,{limit:50});e.messages.length>0?this._recentMessages=e.messages:this._threadHistory?this._recentMessages=await this._threadHistory.getMessages(this.id,50):this._recentMessages=[]}mentionUser(e){return`<@${e}>`}toJSON(){var e,a;return{_type:"chat:Thread",id:this.id,channelId:this.channelId,channelVisibility:this.channelVisibility,currentMessage:(e=this._currentMessage)==null?void 0:e.toJSON(),isDM:this.isDM,adapterName:(a=this._adapterName)!=null?a:this.adapter.name}}static fromJSON(e,a){let r=new q({id:e.id,adapterName:e.adapterName,channelId:e.channelId,channelVisibility:e.channelVisibility,currentMessage:e.currentMessage?T.fromJSON(e.currentMessage):void 0,isDM:e.isDM});return a&&(r._adapter=a),r}static[C](e){return e.toJSON()}static[x](e){return q.fromJSON(e)}createSentMessage(e,a,r){let s=this.adapter,i=r||this.id,n=this,{plainText:o,formatted:l,attachments:h}=ba(a);return{id:e,threadId:i,text:o,formatted:l,raw:null,links:[],author:{userId:"self",userName:s.userName,fullName:s.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:h,toJSON(){return new T(this).toJSON()},async edit(d){let u=d;if(_(d)){let m=y(d);if(!m)throw new Error("Invalid JSX element: must be a Card element");u=m}return u=await n.processCallbackUrls(u),await s.editMessage(i,e,u),n.createSentMessage(e,u)},async delete(){await s.deleteMessage(i,e)},async addReaction(d){await s.addReaction(i,e,d)},async removeReaction(d){await s.removeReaction(i,e,d)}}}createSentMessageFromMessage(e){let a=this.adapter,r=this.id,s=e.id,i=this;return{id:e.id,threadId:e.threadId,text:e.text,formatted:e.formatted,raw:e.raw,author:e.author,metadata:e.metadata,attachments:e.attachments,links:e.links,isMention:e.isMention,toJSON(){return e.toJSON()},async edit(n){let o=n;if(_(n)){let l=y(n);if(!l)throw new Error("Invalid JSX element: must be a Card element");o=l}return o=await i.processCallbackUrls(o),await a.editMessage(r,s,o),i.createSentMessage(s,o,r)},async delete(){await a.deleteMessage(r,s)},async addReaction(n){await a.addReaction(r,s,n)},async removeReaction(n){await a.removeReaction(r,s,n)}}}};function ba(t){if(typeof t=="string")return{plainText:t,formatted:k([b([w(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:k([b([w(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let e=P(t.markdown);return{plainText:L(e),formatted:e,attachments:t.attachments||[]}}if("ast"in t)return{plainText:L(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let e=t.fallbackText||R(t.card);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}if("type"in t&&t.type==="card"){let e=R(t);return{plainText:e,formatted:k([b([w(e)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var yr=10080*60*1e3;var _r=600*1e3,wr=1440*60*1e3;var $t=new Map;function F(t){let e=$t.get(t);return e||(e=Object.freeze({name:t,toString:()=>`{{emoji:${t}}}`,toJSON:()=>`{{emoji:${t}}}`}),$t.set(t,e)),e}var ka={thumbs_up:{slack:["+1","thumbsup"],gchat:"\u{1F44D}"},thumbs_down:{slack:["-1","thumbsdown"],gchat:"\u{1F44E}"},clap:{slack:"clap",gchat:"\u{1F44F}"},wave:{slack:"wave",gchat:"\u{1F44B}"},pray:{slack:"pray",gchat:"\u{1F64F}"},muscle:{slack:"muscle",gchat:"\u{1F4AA}"},ok_hand:{slack:"ok_hand",gchat:"\u{1F44C}"},point_up:{slack:"point_up",gchat:"\u{1F446}"},point_down:{slack:"point_down",gchat:"\u{1F447}"},point_left:{slack:"point_left",gchat:"\u{1F448}"},point_right:{slack:"point_right",gchat:"\u{1F449}"},raised_hands:{slack:"raised_hands",gchat:"\u{1F64C}"},shrug:{slack:"shrug",gchat:"\u{1F937}"},facepalm:{slack:"facepalm",gchat:"\u{1F926}"},heart:{slack:"heart",gchat:["\u2764\uFE0F","\u2764"]},smile:{slack:["smile","slightly_smiling_face"],gchat:"\u{1F60A}"},laugh:{slack:["laughing","satisfied","joy"],gchat:["\u{1F602}","\u{1F606}"]},thinking:{slack:"thinking_face",gchat:"\u{1F914}"},sad:{slack:["cry","sad","white_frowning_face"],gchat:"\u{1F622}"},cry:{slack:"sob",gchat:"\u{1F62D}"},angry:{slack:"angry",gchat:"\u{1F620}"},love_eyes:{slack:"heart_eyes",gchat:"\u{1F60D}"},cool:{slack:"sunglasses",gchat:"\u{1F60E}"},wink:{slack:"wink",gchat:"\u{1F609}"},surprised:{slack:"open_mouth",gchat:"\u{1F62E}"},worried:{slack:"worried",gchat:"\u{1F61F}"},confused:{slack:"confused",gchat:"\u{1F615}"},neutral:{slack:"neutral_face",gchat:"\u{1F610}"},sleeping:{slack:"sleeping",gchat:"\u{1F634}"},sick:{slack:"nauseated_face",gchat:"\u{1F922}"},mind_blown:{slack:"exploding_head",gchat:"\u{1F92F}"},relieved:{slack:"relieved",gchat:"\u{1F60C}"},grimace:{slack:"grimacing",gchat:"\u{1F62C}"},rolling_eyes:{slack:"rolling_eyes",gchat:"\u{1F644}"},hug:{slack:"hugging_face",gchat:"\u{1F917}"},zany:{slack:"zany_face",gchat:"\u{1F92A}"},check:{slack:["white_check_mark","heavy_check_mark"],gchat:["\u2705","\u2714\uFE0F"]},x:{slack:["x","heavy_multiplication_x"],gchat:["\u274C","\u2716\uFE0F"]},question:{slack:"question",gchat:["\u2753","?"]},exclamation:{slack:"exclamation",gchat:"\u2757"},warning:{slack:"warning",gchat:"\u26A0\uFE0F"},stop:{slack:"octagonal_sign",gchat:"\u{1F6D1}"},info:{slack:"information_source",gchat:"\u2139\uFE0F"},100:{slack:"100",gchat:"\u{1F4AF}"},fire:{slack:"fire",gchat:"\u{1F525}"},star:{slack:"star",gchat:"\u2B50"},sparkles:{slack:"sparkles",gchat:"\u2728"},lightning:{slack:"zap",gchat:"\u26A1"},boom:{slack:"boom",gchat:"\u{1F4A5}"},eyes:{slack:"eyes",gchat:"\u{1F440}"},green_circle:{slack:"large_green_circle",gchat:"\u{1F7E2}"},yellow_circle:{slack:"large_yellow_circle",gchat:"\u{1F7E1}"},red_circle:{slack:"red_circle",gchat:"\u{1F534}"},blue_circle:{slack:"large_blue_circle",gchat:"\u{1F535}"},white_circle:{slack:"white_circle",gchat:"\u26AA"},black_circle:{slack:"black_circle",gchat:"\u26AB"},rocket:{slack:"rocket",gchat:"\u{1F680}"},party:{slack:["tada","partying_face"],gchat:["\u{1F389}","\u{1F973}"]},confetti:{slack:"confetti_ball",gchat:"\u{1F38A}"},balloon:{slack:"balloon",gchat:"\u{1F388}"},gift:{slack:"gift",gchat:"\u{1F381}"},trophy:{slack:"trophy",gchat:"\u{1F3C6}"},medal:{slack:"first_place_medal",gchat:"\u{1F947}"},lightbulb:{slack:"bulb",gchat:"\u{1F4A1}"},gear:{slack:"gear",gchat:"\u2699\uFE0F"},wrench:{slack:"wrench",gchat:"\u{1F527}"},hammer:{slack:"hammer",gchat:"\u{1F528}"},bug:{slack:"bug",gchat:"\u{1F41B}"},link:{slack:"link",gchat:"\u{1F517}"},lock:{slack:"lock",gchat:"\u{1F512}"},unlock:{slack:"unlock",gchat:"\u{1F513}"},key:{slack:"key",gchat:"\u{1F511}"},pin:{slack:"pushpin",gchat:"\u{1F4CC}"},memo:{slack:"memo",gchat:"\u{1F4DD}"},clipboard:{slack:"clipboard",gchat:"\u{1F4CB}"},calendar:{slack:"calendar",gchat:"\u{1F4C5}"},clock:{slack:"clock1",gchat:"\u{1F550}"},hourglass:{slack:"hourglass",gchat:"\u23F3"},bell:{slack:"bell",gchat:"\u{1F514}"},megaphone:{slack:"mega",gchat:"\u{1F4E2}"},speech_bubble:{slack:"speech_balloon",gchat:"\u{1F4AC}"},email:{slack:"email",gchat:"\u{1F4E7}"},inbox:{slack:"inbox_tray",gchat:"\u{1F4E5}"},outbox:{slack:"outbox_tray",gchat:"\u{1F4E4}"},package:{slack:"package",gchat:"\u{1F4E6}"},folder:{slack:"file_folder",gchat:"\u{1F4C1}"},file:{slack:"page_facing_up",gchat:"\u{1F4C4}"},chart_up:{slack:"chart_with_upwards_trend",gchat:"\u{1F4C8}"},chart_down:{slack:"chart_with_downwards_trend",gchat:"\u{1F4C9}"},coffee:{slack:"coffee",gchat:"\u2615"},pizza:{slack:"pizza",gchat:"\u{1F355}"},beer:{slack:"beer",gchat:"\u{1F37A}"},arrow_up:{slack:"arrow_up",gchat:"\u2B06\uFE0F"},arrow_down:{slack:"arrow_down",gchat:"\u2B07\uFE0F"},arrow_left:{slack:"arrow_left",gchat:"\u2B05\uFE0F"},arrow_right:{slack:"arrow_right",gchat:"\u27A1\uFE0F"},refresh:{slack:"arrows_counterclockwise",gchat:"\u{1F504}"},sun:{slack:"sunny",gchat:"\u2600\uFE0F"},cloud:{slack:"cloud",gchat:"\u2601\uFE0F"},rain:{slack:"rain_cloud",gchat:"\u{1F327}\uFE0F"},snow:{slack:"snowflake",gchat:"\u2744\uFE0F"},rainbow:{slack:"rainbow",gchat:"\u{1F308}"}},Ma=class{constructor(t){c(this,"emojiMap");c(this,"slackToNormalized");c(this,"gchatToNormalized");this.emojiMap={...ka,...t},this.slackToNormalized=new Map,this.gchatToNormalized=new Map,this.buildReverseMaps()}buildReverseMaps(){for(let[t,e]of Object.entries(this.emojiMap)){let a=Array.isArray(e.slack)?e.slack:[e.slack];for(let s of a)this.slackToNormalized.set(s.toLowerCase(),t);let r=Array.isArray(e.gchat)?e.gchat:[e.gchat];for(let s of r)this.gchatToNormalized.set(s,t)}}fromSlack(t){var r;let e=t.replace(/^:|:$/g,"").toLowerCase(),a=(r=this.slackToNormalized.get(e))!=null?r:t;return F(a)}fromGChat(t){var a;let e=(a=this.gchatToNormalized.get(t))!=null?a:t;return F(e)}fromTeams(t){var r;let a=(r={like:"thumbs_up",heart:"heart",laugh:"laugh",surprised:"surprised",sad:"sad",angry:"angry"}[t])!=null?r:t;return F(a)}toSlack(t){let e=typeof t=="string"?t:t.name,a=this.emojiMap[e];return a?Array.isArray(a.slack)?a.slack[0]:a.slack:e}toGChat(t){let e=typeof t=="string"?t:t.name,a=this.emojiMap[e];return a?Array.isArray(a.gchat)?a.gchat[0]:a.gchat:e}toDiscord(t){return this.toGChat(t)}matches(t,e){let a=typeof e=="string"?e:e.name,r=this.emojiMap[a];if(!r)return t===a;let s=Array.isArray(r.slack)?r.slack:[r.slack],i=Array.isArray(r.gchat)?r.gchat:[r.gchat],n=t.replace(/^:|:$/g,"").toLowerCase();return s.some(o=>o.toLowerCase()===n)||i.includes(t)}extend(t){Object.assign(this.emojiMap,t),this.buildReverseMaps()}},Ia=new Ma;function Sa(t){let e=["thumbs_up","thumbs_down","clap","wave","pray","muscle","ok_hand","point_up","point_down","point_left","point_right","raised_hands","shrug","facepalm","heart","smile","laugh","thinking","sad","cry","angry","love_eyes","cool","wink","surprised","worried","confused","neutral","sleeping","sick","mind_blown","relieved","grimace","rolling_eyes","hug","zany","check","x","question","exclamation","warning","stop","info","100","fire","star","sparkles","lightning","boom","eyes","green_circle","yellow_circle","red_circle","blue_circle","white_circle","black_circle","rocket","party","confetti","balloon","gift","trophy","medal","lightbulb","gear","wrench","hammer","bug","link","lock","unlock","key","pin","memo","clipboard","calendar","clock","hourglass","bell","megaphone","speech_bubble","email","inbox","outbox","package","folder","file","chart_up","chart_down","coffee","pizza","beer","arrow_up","arrow_down","arrow_left","arrow_right","refresh","sun","cloud","rain","snow","rainbow"],a={custom:r=>F(r)};for(let r of e)a[r]=F(r);if(t){for(let r of Object.keys(t))a[r]=F(r);Ia.extend(t)}return a}var br=Sa(),kr=rt,Mr=st,Ir=Z;var Sr=ct,Tr=Y,Er=et,Ar=nt,Cr=ot;var xr=tt;var Fr=it,Nr=at,Lr=lt;var Rr=ft,Or=dt,$r=pt,Dr=ut,vr=gt,Ur=ht;export{kr as a,Mr as b,Ir as c,Sr as d,Tr as e,Er as f,Ar as g,Cr as h,xr as i,Fr as j,Nr as k,Lr as l,Rr as m,Or as n,$r as o,Dr as p,vr as q,Ur as r};
@@ -1 +1 @@
1
- import{u as h}from"./chunk-FRWG7YTE.js";import f from"ajv";import y from"ajv-formats";var S=t=>typeof structuredClone=="function"?structuredClone(t):JSON.parse(JSON.stringify(t));var n=class extends h{constructor(a,o){let r=o.length===1?"it":"them";super(`Tried to use a ${a} in @novu/framework without ${o.join(", ")} installed. Please install ${r} by running \`npm install ${o.join(" ")}\`.`);this.statusCode=500;this.code="MissingDependencyError"}};var m=async(t,e)=>{let a=new Set;if((await Promise.allSettled(t.map(r=>r.import))).forEach((r,p)=>{let s=t[p];r.status==="fulfilled"&&s.exports.every(u=>r.value[u]!==void 0)||a.add(s.name)}),a.size>0)throw new n(e,Array.from(a))};var i=class{constructor(){this.requiredImports=[];this.ajv=new f({useDefaults:!0,removeAdditional:"failing",strict:!1}),y(this.ajv),this.compiledSchemas=new Map}async canHandle(e){let a=e.type==="object"||!!e.anyOf||!!e.allOf||!!e.oneOf;return a&&await m(this.requiredImports,"JSON schema"),a}async validate(e,a){let o=this.compiledSchemas.get(a);o||(o=this.ajv.compile(a),this.compiledSchemas.set(a,o));let r=S(e);return o(r)?{success:!0,data:r}:{success:!1,errors:o.errors.map(s=>({path:s.instancePath,message:s.message}))}}async transformToJsonSchema(e){return e}};var c=class{constructor(){this.requiredImports=[{name:"zod",import:import("zod"),exports:["ZodType"]},{name:"zod-to-json-schema",import:import("zod-to-json-schema"),exports:["zodToJsonSchema"]}]}async canHandle(e){let a=e.safeParseAsync!==void 0;return a&&await m(this.requiredImports,"Zod schema"),a}async validate(e,a){let o=await a.safeParseAsync(e);return o.success?{success:!0,data:o.data}:{success:!1,errors:o.error.issues.map(r=>({path:`/${r.path.join("/")}`,message:r.message}))}}async transformToJsonSchema(e){let{zodToJsonSchema:a}=await import("zod-to-json-schema");return a(e)}};var d=new c,l=new i,v=async(t,e)=>{if(await d.canHandle(t))return d.validate(e,t);if(await l.canHandle(t))return l.validate(e,t);throw new Error("Invalid schema")},T=async t=>{if(await d.canHandle(t))return d.transformToJsonSchema(t);if(await l.canHandle(t))return l.transformToJsonSchema(t);throw new Error("Invalid schema")};export{v as a,T as b};
1
+ import{u as h}from"./chunk-VY27ZAO7.js";import f from"ajv";import y from"ajv-formats";var S=t=>typeof structuredClone=="function"?structuredClone(t):JSON.parse(JSON.stringify(t));var n=class extends h{constructor(a,o){let r=o.length===1?"it":"them";super(`Tried to use a ${a} in @novu/framework without ${o.join(", ")} installed. Please install ${r} by running \`npm install ${o.join(" ")}\`.`);this.statusCode=500;this.code="MissingDependencyError"}};var m=async(t,e)=>{let a=new Set;if((await Promise.allSettled(t.map(r=>r.import))).forEach((r,p)=>{let s=t[p];r.status==="fulfilled"&&s.exports.every(u=>r.value[u]!==void 0)||a.add(s.name)}),a.size>0)throw new n(e,Array.from(a))};var i=class{constructor(){this.requiredImports=[];this.ajv=new f({useDefaults:!0,removeAdditional:"failing",strict:!1}),y(this.ajv),this.compiledSchemas=new Map}async canHandle(e){let a=e.type==="object"||!!e.anyOf||!!e.allOf||!!e.oneOf;return a&&await m(this.requiredImports,"JSON schema"),a}async validate(e,a){let o=this.compiledSchemas.get(a);o||(o=this.ajv.compile(a),this.compiledSchemas.set(a,o));let r=S(e);return o(r)?{success:!0,data:r}:{success:!1,errors:o.errors.map(s=>({path:s.instancePath,message:s.message}))}}async transformToJsonSchema(e){return e}};var c=class{constructor(){this.requiredImports=[{name:"zod",import:import("zod"),exports:["ZodType"]},{name:"zod-to-json-schema",import:import("zod-to-json-schema"),exports:["zodToJsonSchema"]}]}async canHandle(e){let a=e.safeParseAsync!==void 0;return a&&await m(this.requiredImports,"Zod schema"),a}async validate(e,a){let o=await a.safeParseAsync(e);return o.success?{success:!0,data:o.data}:{success:!1,errors:o.error.issues.map(r=>({path:`/${r.path.join("/")}`,message:r.message}))}}async transformToJsonSchema(e){let{zodToJsonSchema:a}=await import("zod-to-json-schema");return a(e)}};var d=new c,l=new i,v=async(t,e)=>{if(await d.canHandle(t))return d.validate(e,t);if(await l.canHandle(t))return l.validate(e,t);throw new Error("Invalid schema")},T=async t=>{if(await d.canHandle(t))return d.transformToJsonSchema(t);if(await l.canHandle(t))return l.transformToJsonSchema(t);throw new Error("Invalid schema")};export{v as a,T as b};
@@ -1 +1 @@
1
- function d(a,n,e){return{type:"email",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function t(a,n,e){return{type:"sms",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function l(a,n,e){return{type:"chat",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function S(a,n,e){return{type:"push",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function c(a,n,e){return{type:"in_app",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function m(a,n,e){return{type:"delay",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip}}function r(a,n,e){return{type:"digest",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip}}function h(a,n,e){return{type:"throttle",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip}}var o={email:d,sms:t,chat:l,push:S,inApp:c,delay:m,digest:r,throttle:h};export{o as a};
1
+ function l(a,n,e){return{type:"email",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function d(a,n,e){return{type:"sms",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function t(a,n,e){return{type:"chat",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function S(a,n,e){return{type:"push",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function c(a,n,e){return{type:"in_app",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function m(a,n,e){return{type:"tool",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip,providers:e==null?void 0:e.providers,disableOutputSanitization:e==null?void 0:e.disableOutputSanitization}}function r(a,n,e){return{type:"delay",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip}}function h(a,n,e){return{type:"digest",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip}}function o(a,n,e){return{type:"throttle",stepId:a,resolve:n,controlSchema:e==null?void 0:e.controlSchema,payloadSchema:e==null?void 0:e.payloadSchema,envSchema:e==null?void 0:e.envSchema,skip:e==null?void 0:e.skip}}var v={email:l,sms:d,chat:t,push:S,inApp:c,tool:m,delay:r,digest:h,throttle:o};export{v as a};
@@ -1,5 +1,5 @@
1
- import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-CmybpXhA.js';
2
- import { I as ITriggerPayload, w as TriggerRecipientsPayload, x as ISubscriberPayload, y as TriggerEventStatusEnum, W as WorkflowPreferencesPartial } from './agent.types-E3sxq6xr.js';
1
+ import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-g7VnI_ZQ.js';
2
+ import { I as ITriggerPayload, z as TriggerRecipientsPayload, B as ISubscriberPayload, C as TriggerEventStatusEnum, W as WorkflowPreferencesPartial } from './agent.types-HUDhyXrV.js';
3
3
  import { C as ConditionalPartial, P as PickRequiredKeys, a as Prettify, D as DeepPartial, A as Awaitable } from './util.types-DaFfsxgy.js';
4
4
  import { S as Schema, J as JsonSchema } from './base.schema.types-BApIn9jr.js';
5
5
 
@@ -178,7 +178,8 @@ declare enum WorkflowChannelEnum {
178
178
  PUSH = "push",
179
179
  CHAT = "chat",
180
180
  /** Differs from ChannelTypeEnum in capitalization / snake_case */
181
- IN_APP = "inApp"
181
+ IN_APP = "inApp",
182
+ TOOL = "tool"
182
183
  }
183
184
 
184
185
  type EventPayload = ITriggerPayload;
@@ -1,10 +1,10 @@
1
- import { i as AgentHandlers, A as Agent } from './agent.types-E3sxq6xr.js';
2
- import { L as Logger, C as ClientOptions, W as Workflow, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-BNocZ4Wk.js';
1
+ import { k as AgentHandlers, A as Agent } from './agent.types-HUDhyXrV.js';
2
+ import { L as Logger, C as ClientOptions, W as Workflow, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-0Rv-l8yD.js';
3
3
  import { A as Awaitable } from './util.types-DaFfsxgy.js';
4
4
  import 'chat';
5
5
  import { S as Schema, a as FromSchema, F as FromSchemaUnvalidated } from './base.schema.types-BApIn9jr.js';
6
6
  import './step-resolver.js';
7
- import './subscriber.types-CmybpXhA.js';
7
+ import './subscriber.types-g7VnI_ZQ.js';
8
8
 
9
9
  /**
10
10
  * Define a new conversational agent.
@@ -1,9 +1,9 @@
1
- export { C as Client, N as NovuRequestHandler, S as ServeHandlerOptions, a as agent, w as workflow } from './index-CWldA6G5.js';
2
- export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-BNocZ4Wk.js';
1
+ export { C as Client, N as NovuRequestHandler, S as ServeHandlerOptions, a as agent, w as workflow } from './index-C0oUWDlb.js';
2
+ export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-0Rv-l8yD.js';
3
3
  export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
4
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentConversation, f as AgentDeliveryError, g as AgentError, h as AgentHandlerContext, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentResolveContext, r as AgentSubscriber, s as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, t as ToolApprovalConfig, u as ToolApprovalDecision, v as toAgentError } from './agent.types-E3sxq6xr.js';
5
- export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from './step-resolver.js';
6
- export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from './subscriber.types-CmybpXhA.js';
4
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentContextPayload, f as AgentContextValue, g as AgentConversation, h as AgentDeliveryError, i as AgentError, j as AgentHandlerContext, k as AgentHandlers, l as AgentHistoryEntry, m as AgentMessage, n as AgentMessageAuthor, o as AgentMessageContext, p as AgentPlatformContext, q as AgentReaction, r as AgentReactionContext, s as AgentResolveContext, t as AgentSubscriber, u as AgentSubscriberAccess, v as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, w as ToolApprovalConfig, x as ToolApprovalDecision, y as toAgentError } from './agent.types-HUDhyXrV.js';
5
+ export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, ToolStepResolver, step } from './step-resolver.js';
6
+ export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from './subscriber.types-g7VnI_ZQ.js';
7
7
  import './util.types-DaFfsxgy.js';
8
8
  import './base.schema.types-BApIn9jr.js';
9
9
  import 'json-schema-to-ts';
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{b as k,c as o,d as p,e as s}from"./chunk-WDBIT4NK.js";import{a as t}from"./chunk-2M25EATE.js";import"./chunk-22DBAEUX.js";import{M as l,N as m,O as n,V as r}from"./chunk-LHU5A7DI.js";import{a,b,c,d,e,f,p as g,q as h,r as i}from"./chunk-46AHJTS7.js";import"./chunk-XEHQJMMQ.js";import{a as q}from"./chunk-CANJPWLT.js";import{f as j}from"./chunk-FRWG7YTE.js";import"./chunk-W6DIBD4Z.js";import"./chunk-FHYMHX3T.js";export{a as Actions,m as AgentDeliveryError,l as AgentError,b as Button,c as Card,d as CardLink,e as CardText,k as Client,j as CronExpression,f as Divider,o as NovuRequestHandler,g as Select,h as SelectOption,r as SeverityLevelEnum,i as TextInput,p as agent,q as providerSchemas,t as step,n as toAgentError,s as workflow};
1
+ import{b as k,c as o,d as p,e as s}from"./chunk-CGZ5P44A.js";import{a as t}from"./chunk-YLCLZVYS.js";import"./chunk-XIVU4VDS.js";import{M as l,N as m,O as n,V as r}from"./chunk-FMKD6TON.js";import{a,b,c,d,e,f,p as g,q as h,r as i}from"./chunk-X5AZIKIR.js";import"./chunk-RBTQQ5IZ.js";import{a as q}from"./chunk-SPS3KBKF.js";import{f as j}from"./chunk-VY27ZAO7.js";import"./chunk-W6DIBD4Z.js";import"./chunk-FHYMHX3T.js";export{a as Actions,m as AgentDeliveryError,l as AgentError,b as Button,c as Card,d as CardLink,e as CardText,k as Client,j as CronExpression,f as Divider,o as NovuRequestHandler,g as Select,h as SelectOption,r as SeverityLevelEnum,i as TextInput,p as agent,q as providerSchemas,t as step,n as toAgentError,s as workflow};
@@ -1,10 +1,10 @@
1
- import { P as PostActionEnum } from '../health-check.types-BNocZ4Wk.js';
2
- export { b as CancelEventTriggerResponse, c as ChannelPreference, C as ClientOptions, d as CodeResult, a as CronExpression, D as DiscoverAgentOutput, e as DiscoverOutput, f as DiscoverProviderOutput, g as DiscoverStepOutput, h as DiscoverWorkflowOutput, i as Event, j as EventTriggerParams, k as EventTriggerResponse, l as EventTriggerResult, m as Execute, E as ExecuteInput, n as ExecuteOutput, o as ExecuteOutputMetadata, p as ExecuteOutputOptions, G as GetActionEnum, H as HealthCheck, L as Logger, S as SeverityLevelEnum, q as State, r as StepType, W as Workflow, s as WorkflowChannelEnum, t as WorkflowOptions, u as WorkflowPreference, v as WorkflowPreferences } from '../health-check.types-BNocZ4Wk.js';
3
- export { e as ActionStep, A as ActionStepEnum, f as ChannelStep, c as ChannelStepEnum, g as ChatOutput, h as ChatOutputUnvalidated, i as ChatResult, a as ContextPayload, C as ContextResolved, j as ContextValue, k as CustomStep, D as DelayDynamicOutput, l as DelayDynamicOutputUnvalidated, m as DelayOutput, n as DelayOutputUnvalidated, o as DelayRegularOutput, q as DelayRegularOutputUnvalidated, r as DelayResult, s as DelayTimedOutput, t as DelayTimedOutputUnvalidated, u as DigestOutput, v as DigestOutputUnvalidated, w as DigestRegularOutput, x as DigestRegularOutputUnvalidated, y as DigestResult, z as DigestTimedOutput, B as DigestTimedOutputUnvalidated, F as EmailOutput, G as EmailOutputUnvalidated, H as EmailResult, E as EnvironmentSystemVariables, I as InAppOutput, J as InAppOutputUnvalidated, K as InAppResult, L as JobStatusEnum, P as PushOutput, M as PushOutputUnvalidated, N as PushResult, O as Skip, Q as SmsOutput, R as SmsOutputUnvalidated, T as SmsResult, b as Step, U as StepContext, d as StepOptions, V as StepOutput, S as Subscriber, X as ThrottleOutput, Y as ThrottleOutputUnvalidated, Z as ThrottleResult, _ as actionStepSchemas, $ as channelStepSchemas } from '../subscriber.types-CmybpXhA.js';
1
+ import { P as PostActionEnum } from '../health-check.types-0Rv-l8yD.js';
2
+ export { b as CancelEventTriggerResponse, c as ChannelPreference, C as ClientOptions, d as CodeResult, a as CronExpression, D as DiscoverAgentOutput, e as DiscoverOutput, f as DiscoverProviderOutput, g as DiscoverStepOutput, h as DiscoverWorkflowOutput, i as Event, j as EventTriggerParams, k as EventTriggerResponse, l as EventTriggerResult, m as Execute, E as ExecuteInput, n as ExecuteOutput, o as ExecuteOutputMetadata, p as ExecuteOutputOptions, G as GetActionEnum, H as HealthCheck, L as Logger, S as SeverityLevelEnum, q as State, r as StepType, W as Workflow, s as WorkflowChannelEnum, t as WorkflowOptions, u as WorkflowPreference, v as WorkflowPreferences } from '../health-check.types-0Rv-l8yD.js';
3
+ export { e as ActionStep, A as ActionStepEnum, f as ChannelStep, c as ChannelStepEnum, g as ChatOutput, h as ChatOutputUnvalidated, i as ChatResult, a as ContextPayload, C as ContextResolved, j as ContextValue, k as CustomStep, D as DelayDynamicOutput, l as DelayDynamicOutputUnvalidated, m as DelayOutput, n as DelayOutputUnvalidated, o as DelayRegularOutput, q as DelayRegularOutputUnvalidated, r as DelayResult, s as DelayTimedOutput, t as DelayTimedOutputUnvalidated, u as DigestOutput, v as DigestOutputUnvalidated, w as DigestRegularOutput, x as DigestRegularOutputUnvalidated, y as DigestResult, z as DigestTimedOutput, B as DigestTimedOutputUnvalidated, F as EmailOutput, G as EmailOutputUnvalidated, H as EmailResult, E as EnvironmentSystemVariables, I as InAppOutput, J as InAppOutputUnvalidated, K as InAppResult, L as JobStatusEnum, P as PushOutput, M as PushOutputUnvalidated, N as PushResult, O as Skip, Q as SmsOutput, R as SmsOutputUnvalidated, T as SmsResult, b as Step, U as StepContext, d as StepOptions, V as StepOutput, S as Subscriber, X as ThrottleOutput, Y as ThrottleOutputUnvalidated, Z as ThrottleResult, _ as ToolOutput, $ as ToolOutputUnvalidated, a0 as actionStepSchemas, a1 as channelStepSchemas } from '../subscriber.types-g7VnI_ZQ.js';
4
4
  import { Filter, LiquidOptions, Liquid } from 'liquidjs';
5
5
  import { Emoji } from 'chat';
6
- import { h as AgentHandlerContext, z as ToolResult, B as ToolApprovalRequestPayload, T as ToolApprovalCard, R as ReplyHandle, m as AgentMessageContext, C as AgentEventEnum, a as AgentAction, k as AgentMessage, o as AgentReaction, e as AgentConversation, r as AgentSubscriber, j as AgentHistoryEntry, n as AgentPlatformContext, D as TypingControl, E as ToolApprovalControl, G as AgentBridgeRequest, t as ToolApprovalConfig, M as MessageContent, F as FileRef, H as AgentReplyPayload, S as SentMessageInfo, w as TriggerRecipientsPayload } from '../agent.types-E3sxq6xr.js';
7
- export { J as DeleteMessagePayload, K as EditPayload, L as MetadataSignal, P as ParsedApprovalAction, N as ReplyContent, O as Signal, Q as TriggerSignal, U as buildApprovalActionId, V as parseApprovalActionId } from '../agent.types-E3sxq6xr.js';
6
+ import { j as AgentHandlerContext, D as ToolResult, E as ToolApprovalRequestPayload, T as ToolApprovalCard, R as ReplyHandle, o as AgentMessageContext, G as AgentEventEnum, a as AgentAction, m as AgentMessage, q as AgentReaction, g as AgentConversation, t as AgentSubscriber, e as AgentContextPayload, l as AgentHistoryEntry, p as AgentPlatformContext, H as TypingControl, J as ToolApprovalControl, K as AgentBridgeRequest, w as ToolApprovalConfig, M as MessageContent, F as FileRef, L as AgentReplyPayload, S as SentMessageInfo, z as TriggerRecipientsPayload } from '../agent.types-HUDhyXrV.js';
7
+ export { N as DeleteMessagePayload, O as EditPayload, P as MetadataSignal, Q as ParsedApprovalAction, U as ReplyContent, V as Signal, X as TriggerSignal, Y as buildApprovalActionId, Z as parseApprovalActionId } from '../agent.types-HUDhyXrV.js';
8
8
  export { a as FromSchema, F as FromSchemaUnvalidated, J as JsonSchema, S as Schema, Z as ZodSchema, b as ZodSchemaMinimal } from '../base.schema.types-BApIn9jr.js';
9
9
  export { S as SupportedFrameworkName } from '../server.types-Cc6o5eYH.js';
10
10
  export { A as Awaitable, C as ConditionalPartial, D as DeepPartial, b as DeepRequired, E as Either, I as Indexable, c as PickOptional, d as PickOptionalKeys, e as PickRequired, P as PickRequiredKeys, a as Prettify } from '../util.types-DaFfsxgy.js';
@@ -456,6 +456,7 @@ declare class AgentContextImpl implements AgentRuntimeContext {
456
456
  readonly reaction: AgentReaction | null;
457
457
  readonly conversation: AgentConversation;
458
458
  readonly subscriber: AgentSubscriber | null;
459
+ readonly context: AgentContextPayload | null;
459
460
  readonly history: AgentHistoryEntry[];
460
461
  readonly platform: string;
461
462
  readonly platformContext: AgentPlatformContext;
@@ -521,4 +522,7 @@ declare class AgentContextImpl implements AgentRuntimeContext {
521
522
  */
522
523
  declare function createLiquidEngine(options?: LiquidOptions): Liquid;
523
524
 
524
- export { AgentBridgeRequest, AgentContextImpl, AgentEventEnum, AgentReplyPayload, type AgentRuntimeContext, BadRequestError, BridgeError, ConflictError, ErrorCodeEnum, ExecutionEventControlsInvalidError, ExecutionEventPayloadInvalidError, ExecutionProviderOutputInvalidError, ExecutionStateControlsInvalidError, ExecutionStateCorruptError, ExecutionStateOutputInvalidError, ExecutionStateResultInvalidError, FILTER_VALIDATORS, ForbiddenError, FrameworkError, HttpHeaderKeysEnum, HttpMethodEnum, HttpQueryKeysEnum, HttpStatusEnum, InvalidActionError, type LiquidFilterIssue, MethodNotAllowedError, MissingSecretKeyError, NotFoundError, NovuApiEndpointsEnum, PlatformError, PostActionEnum, ProviderExecutionFailedError, ProviderNotFoundError, ResourceConflictError, ResourceEnum, ResourceExecutionFailed, ResourceNotFoundError, SIGNATURE_TIMESTAMP_TOLERANCE, SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES, SentMessageInfo, ServerError, SignatureExpiredError, SignatureInvalidError, SignatureMismatchError, SignatureNotFoundError, SignatureVersionInvalidError, SigningKeyNotFoundError, StepAlreadyExistsError, StepControlCompilationFailedError, StepExecutionFailedError, StepNotFoundError, ToolApprovalRequestPayload, ToolResult, UnauthorizedError, WorkflowAlreadyExistsError, WorkflowNotFoundError, WorkflowPayloadInvalidError, createLiquidEngine, digest, isFrameworkError, isNativeError, pluralize, toSentence, toSentenceArgsValidator };
525
+ declare function repairJsonString(value: string): string;
526
+ declare function compileJsonControlValues(values: Record<string, unknown>, context: Record<string, unknown>, liquidEngine?: ReturnType<typeof createLiquidEngine>): Promise<Record<string, unknown>>;
527
+
528
+ export { AgentBridgeRequest, AgentContextImpl, AgentEventEnum, AgentReplyPayload, type AgentRuntimeContext, BadRequestError, BridgeError, ConflictError, ErrorCodeEnum, ExecutionEventControlsInvalidError, ExecutionEventPayloadInvalidError, ExecutionProviderOutputInvalidError, ExecutionStateControlsInvalidError, ExecutionStateCorruptError, ExecutionStateOutputInvalidError, ExecutionStateResultInvalidError, FILTER_VALIDATORS, ForbiddenError, FrameworkError, HttpHeaderKeysEnum, HttpMethodEnum, HttpQueryKeysEnum, HttpStatusEnum, InvalidActionError, type LiquidFilterIssue, MethodNotAllowedError, MissingSecretKeyError, NotFoundError, NovuApiEndpointsEnum, PlatformError, PostActionEnum, ProviderExecutionFailedError, ProviderNotFoundError, ResourceConflictError, ResourceEnum, ResourceExecutionFailed, ResourceNotFoundError, SIGNATURE_TIMESTAMP_TOLERANCE, SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES, SentMessageInfo, ServerError, SignatureExpiredError, SignatureInvalidError, SignatureMismatchError, SignatureNotFoundError, SignatureVersionInvalidError, SigningKeyNotFoundError, StepAlreadyExistsError, StepControlCompilationFailedError, StepExecutionFailedError, StepNotFoundError, ToolApprovalRequestPayload, ToolResult, UnauthorizedError, WorkflowAlreadyExistsError, WorkflowNotFoundError, WorkflowPayloadInvalidError, compileJsonControlValues, createLiquidEngine, digest, isFrameworkError, isNativeError, pluralize, repairJsonString, toSentence, toSentenceArgsValidator };
@@ -1 +1 @@
1
- import{A as oe,B as re,C as ae,D as pe,E as ne,F as ie,H as le,I as se,J as me,K as e,L as t,P as o,S as p,U as ge,V as fe,a as C,b as M,c as D,d as b,e as k,f as B,g as O,h as _,i as j,j as w,k as z,m as G,n as H,o as J,p as K,q as N,r as Q,s as U,t as W,u as X,v as Y,w as Z,x as $,y as ee,z as te}from"../chunk-LHU5A7DI.js";import"../chunk-46AHJTS7.js";import"../chunk-XEHQJMMQ.js";import{e as n,f as i}from"../chunk-CANJPWLT.js";import{a as l,b as s,c as m,d as g,e as f,f as x,g as d,h as c,i as u,j as A,k as y,l as S,m as I,n as R,o as v,p as q,q as E,r as F,s as L,t as P,u as T,v as V,w as h}from"../chunk-FRWG7YTE.js";import{d as r,e as a}from"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";var de={toSentence:e};export{R as ActionStepEnum,p as AgentContextImpl,o as AgentEventEnum,L as BadRequestError,C as BridgeError,I as ChannelStepEnum,V as ConflictError,x as CronExpression,d as ErrorCodeEnum,b as ExecutionEventControlsInvalidError,D as ExecutionEventPayloadInvalidError,j as ExecutionProviderOutputInvalidError,k as ExecutionStateControlsInvalidError,M as ExecutionStateCorruptError,B as ExecutionStateOutputInvalidError,O as ExecutionStateResultInvalidError,de as FILTER_VALIDATORS,h as ForbiddenError,E as FrameworkError,s as GetActionEnum,c as HttpHeaderKeysEnum,u as HttpMethodEnum,A as HttpQueryKeysEnum,y as HttpStatusEnum,H as InvalidActionError,ge as JobStatusEnum,G as MethodNotAllowedError,J as MissingSecretKeyError,F as NotFoundError,m as NovuApiEndpointsEnum,K as PlatformError,l as PostActionEnum,X as ProviderExecutionFailedError,W as ProviderNotFoundError,N as ResourceConflictError,S as ResourceEnum,U as ResourceExecutionFailed,Q as ResourceNotFoundError,f as SIGNATURE_TIMESTAMP_TOLERANCE,g as SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES,T as ServerError,fe as SeverityLevelEnum,ee as SignatureExpiredError,$ as SignatureInvalidError,Y as SignatureMismatchError,Z as SignatureNotFoundError,oe as SignatureVersionInvalidError,te as SigningKeyNotFoundError,ae as StepAlreadyExistsError,_ as StepControlCompilationFailedError,pe as StepExecutionFailedError,re as StepNotFoundError,P as UnauthorizedError,ie as WorkflowAlreadyExistsError,v as WorkflowChannelEnum,ne as WorkflowNotFoundError,w as WorkflowPayloadInvalidError,n as actionStepSchemas,r as buildApprovalActionId,i as channelStepSchemas,t as createLiquidEngine,le as digest,z as isFrameworkError,q as isNativeError,a as parseApprovalActionId,se as pluralize,me as toSentence,e as toSentenceArgsValidator};
1
+ import{A as le,B as me,C as ge,D as ce,E as de,F as ue,H as fe,I as xe,J as ye,K as o,L as r,P as p,S as m,U as Ae,V as Se,a as D,b,c as j,d as B,e as _,f as z,g as G,h as H,i as K,j as Q,k as U,m as W,n as X,o as Y,p as Z,q as $,r as ee,s as re,t as oe,u as te,v as ne,w as ie,x as ae,y as pe,z as se}from"../chunk-FMKD6TON.js";import"../chunk-X5AZIKIR.js";import"../chunk-RBTQQ5IZ.js";import{e as g,f as c}from"../chunk-SPS3KBKF.js";import{a as f,b as x,c as y,d as A,e as S,f as R,g as E,h as I,i as q,j as v,k as w,l as J,m as L,n as P,o as T,p as V,q as h,r as k,s as C,t as F,u as O,v as M,w as N}from"../chunk-VY27ZAO7.js";import{d as s,e as l}from"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";var Ee={toSentence:o};import{jsonrepair as t}from"jsonrepair";function d(e){return t(e)}async function u(e,n,i=r()){let a=await i.parseAndRender(JSON.stringify(e),n);try{return JSON.parse(t(a))}catch{throw new Error("Rendered template output is not valid JSON")}}export{P as ActionStepEnum,m as AgentContextImpl,p as AgentEventEnum,C as BadRequestError,D as BridgeError,L as ChannelStepEnum,M as ConflictError,R as CronExpression,E as ErrorCodeEnum,B as ExecutionEventControlsInvalidError,j as ExecutionEventPayloadInvalidError,K as ExecutionProviderOutputInvalidError,_ as ExecutionStateControlsInvalidError,b as ExecutionStateCorruptError,z as ExecutionStateOutputInvalidError,G as ExecutionStateResultInvalidError,Ee as FILTER_VALIDATORS,N as ForbiddenError,h as FrameworkError,x as GetActionEnum,I as HttpHeaderKeysEnum,q as HttpMethodEnum,v as HttpQueryKeysEnum,w as HttpStatusEnum,X as InvalidActionError,Ae as JobStatusEnum,W as MethodNotAllowedError,Y as MissingSecretKeyError,k as NotFoundError,y as NovuApiEndpointsEnum,Z as PlatformError,f as PostActionEnum,te as ProviderExecutionFailedError,oe as ProviderNotFoundError,$ as ResourceConflictError,J as ResourceEnum,re as ResourceExecutionFailed,ee as ResourceNotFoundError,S as SIGNATURE_TIMESTAMP_TOLERANCE,A as SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES,O as ServerError,Se as SeverityLevelEnum,pe as SignatureExpiredError,ae as SignatureInvalidError,ne as SignatureMismatchError,ie as SignatureNotFoundError,le as SignatureVersionInvalidError,se as SigningKeyNotFoundError,ge as StepAlreadyExistsError,H as StepControlCompilationFailedError,ce as StepExecutionFailedError,me as StepNotFoundError,F as UnauthorizedError,ue as WorkflowAlreadyExistsError,T as WorkflowChannelEnum,de as WorkflowNotFoundError,Q as WorkflowPayloadInvalidError,g as actionStepSchemas,s as buildApprovalActionId,c as channelStepSchemas,u as compileJsonControlValues,r as createLiquidEngine,fe as digest,U as isFrameworkError,V as isNativeError,l as parseApprovalActionId,xe as pluralize,d as repairJsonString,ye as toSentence,o as toSentenceArgsValidator};
@@ -1 +1 @@
1
- import"./chunk-2GCKOQK4.js";import"./chunk-3ZWME5KT.js";import{A as x,B as e,C as j,z as s}from"./chunk-XEHQJMMQ.js";import"./chunk-FHYMHX3T.js";export{j as Fragment,s as jsx,e as jsxDEV,x as jsxs};
1
+ import"./chunk-2GCKOQK4.js";import"./chunk-7C3QBYLB.js";import{A as x,B as e,C as j,z as s}from"./chunk-RBTQQ5IZ.js";import"./chunk-FHYMHX3T.js";export{j as Fragment,s as jsx,e as jsxDEV,x as jsxs};
@@ -1 +1 @@
1
- import"./chunk-3ZWME5KT.js";import{A as c,B as d,C as e,D as f,E as g,F as h,y as a,z as b}from"./chunk-XEHQJMMQ.js";import"./chunk-FHYMHX3T.js";export{e as Fragment,a as isCardLinkProps,h as isJSX,b as jsx,d as jsxDEV,c as jsxs,f as toCardElement,g as toModalElement};
1
+ import"./chunk-7C3QBYLB.js";import{A as c,B as d,C as e,D as f,E as g,F as h,y as a,z as b}from"./chunk-RBTQQ5IZ.js";import"./chunk-FHYMHX3T.js";export{e as Fragment,a as isCardLinkProps,h as isJSX,b as jsx,d as jsxDEV,c as jsxs,f as toCardElement,g as toModalElement};
@@ -1 +1 @@
1
- import"./chunk-2GCKOQK4.js";import"./chunk-3ZWME5KT.js";import{A as b,B as c,C as d,z as a}from"./chunk-XEHQJMMQ.js";import"./chunk-FHYMHX3T.js";export{d as Fragment,a as jsx,c as jsxDEV,b as jsxs};
1
+ import"./chunk-2GCKOQK4.js";import"./chunk-7C3QBYLB.js";import{A as b,B as c,C as d,z as a}from"./chunk-RBTQQ5IZ.js";import"./chunk-FHYMHX3T.js";export{d as Fragment,a as jsx,c as jsxDEV,b as jsxs};
@@ -1,6 +1,7 @@
1
1
  import { BaseMessage } from '@langchain/core/messages';
2
- import { j as AgentHistoryEntry, i as AgentHandlers, k as AgentMessage, m as AgentMessageContext, M as MessageContent, u as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent } from '../agent.types-E3sxq6xr.js';
2
+ import { l as AgentHistoryEntry, M as MessageContent, k as AgentHandlers, m as AgentMessage, o as AgentMessageContext, x as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent } from '../agent.types-HUDhyXrV.js';
3
3
  import { LanguageModelLike } from '@langchain/core/language_models/base';
4
+ import { RunnableConfig } from '@langchain/core/runnables';
4
5
  import { StructuredToolInterface } from '@langchain/core/tools';
5
6
  import { AgentMiddleware } from 'langchain';
6
7
  import { A as Awaitable } from '../util.types-DaFfsxgy.js';
@@ -49,6 +50,19 @@ interface LangChainAgentConfig {
49
50
  needsApproval?: (toolCall: LangChainToolCall) => boolean;
50
51
  /** Extra LangChain middleware, appended after Novu's approval middleware. */
51
52
  middleware?: AgentMiddleware[];
53
+ /**
54
+ * Run config forwarded as the second argument to `agent.invoke(...)` (e.g.
55
+ * `signal`, `configurable`, `context`, `recursionLimit`, `callbacks`). Use this
56
+ * to control the LangGraph run for a turn.
57
+ */
58
+ invokeConfig?: RunnableConfig;
59
+ /**
60
+ * Optional post-run reply formatter. Receives the model's final text and returns
61
+ * the content to deliver — a string or a {@link MessageContent} card. Return
62
+ * `void`/`undefined` to deliver the final text unchanged. Runs only when the
63
+ * model produced a non-empty final text.
64
+ */
65
+ formatReply?: (finalText: string) => Awaitable<MessageContent | void>;
52
66
  }
53
67
  /**
54
68
  * Result of a LangChain agent/graph you invoked yourself (e.g. `await agent.invoke(...)`).
@@ -1 +1 @@
1
- import{b as g,c as I,f as T}from"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";import{AIMessage as J,HumanMessage as V,SystemMessage as G}from"@langchain/core/messages";import{AIMessage as D,ToolMessage as w}from"@langchain/core/messages";var M="tool_approval_request",h="tool_approval_decision",x="tool_result",U=JSON.stringify({type:"execution-denied"});function m(e){var t;let o=e.toolData;if(!(!o||typeof o.approvalId!="string"||typeof o.toolCallId!="string"))return{approvalId:o.approvalId,toolCallId:o.toolCallId,name:(t=o.toolName)!=null?t:"tool",input:o.input}}function E(e){let o=e.toolData;if(!(!o||typeof o.approvalId!="string"||typeof o.approved!="boolean"))return{approvalId:o.approvalId,approved:o.approved}}function L(e){let o=e.toolData;if(!(!o||typeof o.toolCallId!="string"))return{toolCallId:o.toolCallId,toolName:o.toolName,output:o.output}}function N(e,o){let t=new Set,n=new Map,s=new Map;for(let a of e)if(a.type===M){let r=m(a);r&&s.set(r.approvalId,r.toolCallId)}else if(a.type===h){let r=E(a);r&&!r.approved&&t.add(r.approvalId)}else if(a.type===x){let r=L(a);r&&n.set(r.toolCallId,r)}if(o)for(let[a,r]of o)n.set(a,r);return{deniedApprovalIds:t,toolResults:n,approvalIdToToolCallId:s}}function j(e,o){return o.deniedApprovalIds.has(e.approvalId)?"denied":o.toolResults.has(e.toolCallId)?"resolved":"in-flight"}function R(e){var o;return new D({content:"",tool_calls:[{id:e.toolCallId,name:e.name,args:(o=e.input)!=null?o:{},type:"tool_call"}]})}function $(e){return typeof e=="string"?e:JSON.stringify(e)}function Y(e){var o;return new w({content:$(e.output),tool_call_id:e.toolCallId,name:(o=e.toolName)!=null?o:"tool"})}function z(e){return new w({content:U,tool_call_id:e.toolCallId,name:e.name,status:"error"})}function S(e,o){let t=m(e);if(!t)return[];let n=j(t,o);switch(n){case"denied":return[R(t),z(t)];case"resolved":{let s=o.toolResults.get(t.toolCallId);return s?[R(t),Y(s)]:[]}case"in-flight":return[];default:return n}}function P(e){let o=new Set,t=new Set,n=[];for(let s of e)if(s.type===M){let a=m(s);a&&n.push({approvalId:a.approvalId,toolCallId:a.toolCallId,toolName:a.name,input:a.input})}else if(s.type===h){let a=E(s);a!=null&&a.approved&&o.add(a.approvalId)}else if(s.type===x){let a=L(s);a&&t.add(a.toolCallId)}return n.filter(s=>o.has(s.approvalId)&&!t.has(s.toolCallId)).map(({toolCallId:s,toolName:a,input:r})=>({toolCallId:s,toolName:a,input:r}))}var Q="message",X="tool_approval_request";function _(e){return e==="agent"||e==="assistant"}function F(e){let o=new Set;for(let t of e)!_(t.role)&&t.role!=="system"&&t.senderName&&o.add(t.senderName);return o.size}function K(e,o){if(!e.content.trim())return;if(_(e.role))return new J(e.content);let n=o&&e.senderName?`${e.senderName}: ${e.content}`:e.content;return new V(n)}function W(e,o,t){switch(e.type){case Q:{let n=K(e,o);return n?[n]:[]}case X:return S(e,t);default:return[]}}function y(e,o,t){let n=F(e)>1,s=N(e,t),a=e.flatMap(r=>W(r,n,s));return o?[new G(o),...a]:a}import{isAIMessage as ie,isBaseMessage as q}from"@langchain/core/messages";import{createAgent as pe}from"langchain";import{isBaseMessage as Z}from"@langchain/core/messages";import{createMiddleware as ee}from"langchain";var d=class extends Error{constructor(o){super(`Tool "${o.toolName}" requires approval`),this.name="NovuToolApprovalRequired",this.toolCallId=o.toolCallId,this.toolName=o.toolName,this.input=o.input}},oe=10;function H(e){let o=e;for(let t=0;t<oe&&o!=null;t+=1){if(o instanceof d)return o;o=o.cause}}function k(e){return ee({name:"novu-tool-approval",wrapToolCall:async(o,t)=>{let{id:n,name:s,args:a}=o.toolCall,r=a!=null?a:{};if(e({id:n,name:s,args:r}))throw new d({toolCallId:n!=null?n:s,toolName:s,input:r});return t(o)}})}async function B(e,o,t){let n={id:o.toolCallId,name:o.toolName,input:o.input};await T(e,n,t)}function te(e){return Z(e)?e.content:e}function ne(e){let o=new Map;for(let t of e!=null?e:[])o.set(t.name,t);return o}async function O(e,o){var a;let t=P(o.history),n=new Map;if(t.length===0)return n;let s=ne(e);for(let r of t){let l=s.get(r.toolName);if(!l)continue;let i=te(await l.invoke((a=r.input)!=null?a:{}));n.set(r.toolCallId,{toolCallId:r.toolCallId,toolName:r.toolName,output:i}),o.emitToolResult({toolCallId:r.toolCallId,toolName:r.toolName,output:i,preview:`Tool "${r.toolName}" result`})}return n}import{isToolMessage as ae}from"@langchain/core/messages";function re(e){var t;let o=new Set;for(let n of e.history)n.type==="tool_approval_request"&&((t=n.toolData)!=null&&t.toolCallId)&&o.add(n.toolData.toolCallId);return o}function se(e,o){var n;let t=new Set(o);for(let s of e.history)s.type==="tool_result"&&((n=s.toolData)!=null&&n.toolCallId)&&t.add(s.toolData.toolCallId);return t}function le(e){return typeof e=="string"?e:JSON.stringify(e)}function A(e,o,t=new Set){var a;let n=re(o);if(n.size===0)return;let s=se(o,t);for(let r of e){if(!ae(r))continue;let l=r.tool_call_id;!n.has(l)||s.has(l)||(s.add(l),o.emitToolResult({toolCallId:l,toolName:r.name,output:le(r.content),preview:`Tool "${(a=r.name)!=null?a:l}" result`}))}}function b(e){if(typeof e!="object"||e===null)return!1;let o=e.model;return typeof o=="string"||typeof o=="object"&&o!==null}function ue(e){return typeof e=="object"&&e!==null&&Array.isArray(e.messages)}function f(e){return typeof e!="object"||e===null||I(e)?!1:q(e)||b(e)||ue(e)}function de(e){return typeof e=="string"?e:e.map(o=>{let t=o;return t.type==="text"&&typeof t.text=="string"?t.text:""}).join("")}function C(e){for(let o=e.length-1;o>=0;o-=1){let t=e[o];if(ie(t))return de(t.content).trim()}return""}async function v(e,o){if(!e){await o.typing.stop();return}await o.reply(e)}async function ge(e,o,t){var i;let n=await O(e.tools,o),s=y(o.history,void 0,n),a=[];e.needsApproval&&a.push(k(e.needsApproval)),e.middleware&&a.push(...e.middleware);let r=pe({model:e.model,tools:(i=e.tools)!=null?i:[],...e.system?{prompt:e.system}:{},...a.length>0?{middleware:a}:{}}),l;try{l=await r.invoke({messages:s})}catch(p){let u=H(p);if(u){await B(o,u,t);return}throw p}A(l.messages,o,new Set(n.keys())),await v(C(l.messages),o)}async function c(e,o,t){if(b(e)){await ge(e,o,t);return}if(q(e)){await v(C([e]),o);return}A(e.messages,o),await v(C(e.messages),o)}var fe={text:"",platformMessageId:"",author:{userId:"",fullName:"",userName:"",isBot:!1},timestamp:""};function ce(e){return typeof e=="object"&&e!==null&&"messageId"in e&&"platformThreadId"in e}function me(e,o){let t=typeof o=="function"?{onMessage:o}:o;if(typeof t.onMessage!="function")throw new Error(`agent('${e}') requires an onMessage handler`);return t}function ye(e,o){if(!e)throw new Error("agent() requires a non-empty agentId");let t=me(e,o),n=t.toolApproval,s=typeof t.onToolApproval=="function",a=async l=>{let i=g(l),p=await t.onMessage(fe,i.asMessageContext());f(p)&&await c(p,i,n)},r={onMessage:async(l,i)=>{let p=await t.onMessage(l,i);if(f(p)){await c(p,g(i),n);return}return p},onToolApproval:async(l,i)=>{let p=g(i);if(t.onToolApproval){let u=await t.onToolApproval(l,i);if(f(u)){await c(u,p,n);return}u!=null&&!ce(u)&&await p.reply(u)}await a(i)},...n&&{toolApproval:n},...t.onAction&&{onAction:t.onAction},...t.onReaction&&{onReaction:t.onReaction},...t.onResolve&&{onResolve:t.onResolve},...t.onError&&{onError:t.onError}};return{id:e,handlers:r,userOnToolApproval:s}}export{d as NovuToolApprovalRequired,ye as agent,y as toLangChainMessages};
1
+ import{b as g,c as I,f as T}from"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";import{AIMessage as J,HumanMessage as V,SystemMessage as G}from"@langchain/core/messages";import{AIMessage as D,ToolMessage as w}from"@langchain/core/messages";var M="tool_approval_request",h="tool_approval_decision",x="tool_result",U=JSON.stringify({type:"execution-denied"});function m(e){var t;let o=e.toolData;if(!(!o||typeof o.approvalId!="string"||typeof o.toolCallId!="string"))return{approvalId:o.approvalId,toolCallId:o.toolCallId,name:(t=o.toolName)!=null?t:"tool",input:o.input}}function E(e){let o=e.toolData;if(!(!o||typeof o.approvalId!="string"||typeof o.approved!="boolean"))return{approvalId:o.approvalId,approved:o.approved}}function L(e){let o=e.toolData;if(!(!o||typeof o.toolCallId!="string"))return{toolCallId:o.toolCallId,toolName:o.toolName,output:o.output}}function N(e,o){let t=new Set,n=new Map,r=new Map;for(let a of e)if(a.type===M){let s=m(a);s&&r.set(s.approvalId,s.toolCallId)}else if(a.type===h){let s=E(a);s&&!s.approved&&t.add(s.approvalId)}else if(a.type===x){let s=L(a);s&&n.set(s.toolCallId,s)}if(o)for(let[a,s]of o)n.set(a,s);return{deniedApprovalIds:t,toolResults:n,approvalIdToToolCallId:r}}function j(e,o){return o.deniedApprovalIds.has(e.approvalId)?"denied":o.toolResults.has(e.toolCallId)?"resolved":"in-flight"}function R(e){var o;return new D({content:"",tool_calls:[{id:e.toolCallId,name:e.name,args:(o=e.input)!=null?o:{},type:"tool_call"}]})}function $(e){return typeof e=="string"?e:JSON.stringify(e)}function Y(e){var o;return new w({content:$(e.output),tool_call_id:e.toolCallId,name:(o=e.toolName)!=null?o:"tool"})}function z(e){return new w({content:U,tool_call_id:e.toolCallId,name:e.name,status:"error"})}function S(e,o){let t=m(e);if(!t)return[];let n=j(t,o);switch(n){case"denied":return[R(t),z(t)];case"resolved":{let r=o.toolResults.get(t.toolCallId);return r?[R(t),Y(r)]:[]}case"in-flight":return[];default:return n}}function P(e){let o=new Set,t=new Set,n=[];for(let r of e)if(r.type===M){let a=m(r);a&&n.push({approvalId:a.approvalId,toolCallId:a.toolCallId,toolName:a.name,input:a.input})}else if(r.type===h){let a=E(r);a!=null&&a.approved&&o.add(a.approvalId)}else if(r.type===x){let a=L(r);a&&t.add(a.toolCallId)}return n.filter(r=>o.has(r.approvalId)&&!t.has(r.toolCallId)).map(({toolCallId:r,toolName:a,input:s})=>({toolCallId:r,toolName:a,input:s}))}var Q="message",X="tool_approval_request";function _(e){return e==="agent"||e==="assistant"}function F(e){let o=new Set;for(let t of e)!_(t.role)&&t.role!=="system"&&t.senderName&&o.add(t.senderName);return o.size}function K(e,o){if(!e.content.trim())return;if(_(e.role))return new J(e.content);let n=o&&e.senderName?`${e.senderName}: ${e.content}`:e.content;return new V(n)}function W(e,o,t){switch(e.type){case Q:{let n=K(e,o);return n?[n]:[]}case X:return S(e,t);default:return[]}}function y(e,o,t){let n=F(e)>1,r=N(e,t),a=e.flatMap(s=>W(s,n,r));return o?[new G(o),...a]:a}import{isAIMessage as ie,isBaseMessage as q}from"@langchain/core/messages";import{createAgent as pe}from"langchain";import{isBaseMessage as Z}from"@langchain/core/messages";import{createMiddleware as ee}from"langchain";var d=class extends Error{constructor(o){super(`Tool "${o.toolName}" requires approval`),this.name="NovuToolApprovalRequired",this.toolCallId=o.toolCallId,this.toolName=o.toolName,this.input=o.input}},oe=10;function k(e){let o=e;for(let t=0;t<oe&&o!=null;t+=1){if(o instanceof d)return o;o=o.cause}}function H(e){return ee({name:"novu-tool-approval",wrapToolCall:async(o,t)=>{let{id:n,name:r,args:a}=o.toolCall,s=a!=null?a:{};if(e({id:n,name:r,args:s}))throw new d({toolCallId:n!=null?n:r,toolName:r,input:s});return t(o)}})}async function B(e,o,t){let n={id:o.toolCallId,name:o.toolName,input:o.input};await T(e,n,t)}function te(e){return Z(e)?e.content:e}function ne(e){let o=new Map;for(let t of e!=null?e:[])o.set(t.name,t);return o}async function O(e,o){var a;let t=P(o.history),n=new Map;if(t.length===0)return n;let r=ne(e);for(let s of t){let l=r.get(s.toolName);if(!l)continue;let i=te(await l.invoke((a=s.input)!=null?a:{}));n.set(s.toolCallId,{toolCallId:s.toolCallId,toolName:s.toolName,output:i}),o.emitToolResult({toolCallId:s.toolCallId,toolName:s.toolName,output:i,preview:`Tool "${s.toolName}" result`})}return n}import{isToolMessage as ae}from"@langchain/core/messages";function re(e){var t;let o=new Set;for(let n of e.history)n.type==="tool_approval_request"&&((t=n.toolData)!=null&&t.toolCallId)&&o.add(n.toolData.toolCallId);return o}function se(e,o){var n;let t=new Set(o);for(let r of e.history)r.type==="tool_result"&&((n=r.toolData)!=null&&n.toolCallId)&&t.add(r.toolData.toolCallId);return t}function le(e){return typeof e=="string"?e:JSON.stringify(e)}function A(e,o,t=new Set){var a;let n=re(o);if(n.size===0)return;let r=se(o,t);for(let s of e){if(!ae(s))continue;let l=s.tool_call_id;!n.has(l)||r.has(l)||(r.add(l),o.emitToolResult({toolCallId:l,toolName:s.name,output:le(s.content),preview:`Tool "${(a=s.name)!=null?a:l}" result`}))}}function b(e){if(typeof e!="object"||e===null)return!1;let o=e.model;return typeof o=="string"||typeof o=="object"&&o!==null}function ue(e){return typeof e=="object"&&e!==null&&Array.isArray(e.messages)}function f(e){return typeof e!="object"||e===null||I(e)?!1:q(e)||b(e)||ue(e)}function de(e){return typeof e=="string"?e:e.map(o=>{let t=o;return t.type==="text"&&typeof t.text=="string"?t.text:""}).join("")}function C(e){for(let o=e.length-1;o>=0;o-=1){let t=e[o];if(ie(t))return de(t.content).trim()}return""}async function v(e,o,t){var r;if(!e){await o.typing.stop();return}let n=t&&(r=await t(e))!=null?r:e;await o.reply(n)}async function ge(e,o,t){var i;let n=await O(e.tools,o),r=y(o.history,void 0,n),a=[];e.needsApproval&&a.push(H(e.needsApproval)),e.middleware&&a.push(...e.middleware);let s=pe({model:e.model,tools:(i=e.tools)!=null?i:[],...e.system?{prompt:e.system}:{},...a.length>0?{middleware:a}:{}}),l;try{l=await s.invoke({messages:r},e.invokeConfig)}catch(p){let u=k(p);if(u){await B(o,u,t);return}throw p}A(l.messages,o,new Set(n.keys())),await v(C(l.messages),o,e.formatReply)}async function c(e,o,t){if(b(e)){await ge(e,o,t);return}if(q(e)){await v(C([e]),o);return}A(e.messages,o),await v(C(e.messages),o)}var fe={text:"",platformMessageId:"",author:{userId:"",fullName:"",userName:"",isBot:!1},timestamp:""};function ce(e){return typeof e=="object"&&e!==null&&"messageId"in e&&"platformThreadId"in e}function me(e,o){let t=typeof o=="function"?{onMessage:o}:o;if(typeof t.onMessage!="function")throw new Error(`agent('${e}') requires an onMessage handler`);return t}function ye(e,o){if(!e)throw new Error("agent() requires a non-empty agentId");let t=me(e,o),n=t.toolApproval,r=typeof t.onToolApproval=="function",a=async l=>{let i=g(l),p=await t.onMessage(fe,i.asMessageContext());f(p)&&await c(p,i,n)},s={onMessage:async(l,i)=>{let p=await t.onMessage(l,i);if(f(p)){await c(p,g(i),n);return}return p},onToolApproval:async(l,i)=>{let p=g(i);if(t.onToolApproval){let u=await t.onToolApproval(l,i);if(f(u)){await c(u,p,n);return}u!=null&&!ce(u)&&await p.reply(u)}await a(i)},...n&&{toolApproval:n},...t.onAction&&{onAction:t.onAction},...t.onReaction&&{onReaction:t.onReaction},...t.onResolve&&{onResolve:t.onResolve},...t.onError&&{onError:t.onError}};return{id:e,handlers:s,userOnToolApproval:r}}export{d as NovuToolApprovalRequired,ye as agent,y as toLangChainMessages};
@@ -1,11 +1,11 @@
1
- import { S as ServeHandlerOptions } from '../index-CWldA6G5.js';
2
- export { C as Client, N as NovuRequestHandler, a as agent, w as workflow } from '../index-CWldA6G5.js';
3
- export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-BNocZ4Wk.js';
4
- export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CmybpXhA.js';
1
+ import { S as ServeHandlerOptions } from '../index-C0oUWDlb.js';
2
+ export { C as Client, N as NovuRequestHandler, a as agent, w as workflow } from '../index-C0oUWDlb.js';
3
+ export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-0Rv-l8yD.js';
4
+ export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-g7VnI_ZQ.js';
5
5
  import { S as SupportedFrameworkName } from '../server.types-Cc6o5eYH.js';
6
6
  export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
7
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentConversation, f as AgentDeliveryError, g as AgentError, h as AgentHandlerContext, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentResolveContext, r as AgentSubscriber, s as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, t as ToolApprovalConfig, u as ToolApprovalDecision, v as toAgentError } from '../agent.types-E3sxq6xr.js';
8
- export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from '../step-resolver.js';
7
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentContextPayload, f as AgentContextValue, g as AgentConversation, h as AgentDeliveryError, i as AgentError, j as AgentHandlerContext, k as AgentHandlers, l as AgentHistoryEntry, m as AgentMessage, n as AgentMessageAuthor, o as AgentMessageContext, p as AgentPlatformContext, q as AgentReaction, r as AgentReactionContext, s as AgentResolveContext, t as AgentSubscriber, u as AgentSubscriberAccess, v as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, w as ToolApprovalConfig, x as ToolApprovalDecision, y as toAgentError } from '../agent.types-HUDhyXrV.js';
8
+ export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, ToolStepResolver, step } from '../step-resolver.js';
9
9
  import '../util.types-DaFfsxgy.js';
10
10
  import '../base.schema.types-BApIn9jr.js';
11
11
  import 'json-schema-to-ts';
@@ -1 +1 @@
1
- import{b as x,c as a,d as V,e as O}from"../chunk-WDBIT4NK.js";import{a as $}from"../chunk-2M25EATE.js";import"../chunk-22DBAEUX.js";import{M as A,N,O as R,V as k}from"../chunk-LHU5A7DI.js";import{a as y,b as h,c,d as m,e as f,f as H,p as v,q as w,r as E}from"../chunk-46AHJTS7.js";import"../chunk-XEHQJMMQ.js";import{a as b}from"../chunk-CANJPWLT.js";import{f as S}from"../chunk-FRWG7YTE.js";import"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";var l="express",U=p=>new a({frameworkName:l,...p,handler:(t,o)=>({body:()=>t.body,headers:e=>{let r=t.headers[e];return Array.isArray(r)?r[0]:r},method:()=>t.method||"GET",url:()=>{let e=t.headers.host||"",r=e!=null&&e.includes("://")?"":`${t.protocol||"https"}://`;return new URL(t.originalUrl||t.url||"",`${r}${e||""}`)},queryString:e=>{let r=t.query[e];return Array.isArray(r)?r[0]:r},transformResponse:({body:e,headers:r,status:s})=>(Object.entries(r).forEach(([n,d])=>{o.setHeader(n,d)}),o.status(s).send(e))})}).createHandler();export{y as Actions,N as AgentDeliveryError,A as AgentError,h as Button,c as Card,m as CardLink,f as CardText,x as Client,S as CronExpression,H as Divider,a as NovuRequestHandler,v as Select,w as SelectOption,k as SeverityLevelEnum,E as TextInput,V as agent,l as frameworkName,b as providerSchemas,U as serve,$ as step,R as toAgentError,O as workflow};
1
+ import{b as x,c as a,d as V,e as O}from"../chunk-CGZ5P44A.js";import{a as $}from"../chunk-YLCLZVYS.js";import"../chunk-XIVU4VDS.js";import{M as A,N,O as R,V as k}from"../chunk-FMKD6TON.js";import{a as y,b as h,c,d as m,e as f,f as H,p as v,q as w,r as E}from"../chunk-X5AZIKIR.js";import"../chunk-RBTQQ5IZ.js";import{a as b}from"../chunk-SPS3KBKF.js";import{f as S}from"../chunk-VY27ZAO7.js";import"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";var l="express",U=p=>new a({frameworkName:l,...p,handler:(t,o)=>({body:()=>t.body,headers:e=>{let r=t.headers[e];return Array.isArray(r)?r[0]:r},method:()=>t.method||"GET",url:()=>{let e=t.headers.host||"",r=e!=null&&e.includes("://")?"":`${t.protocol||"https"}://`;return new URL(t.originalUrl||t.url||"",`${r}${e||""}`)},queryString:e=>{let r=t.query[e];return Array.isArray(r)?r[0]:r},transformResponse:({body:e,headers:r,status:s})=>(Object.entries(r).forEach(([n,d])=>{o.setHeader(n,d)}),o.status(s).send(e))})}).createHandler();export{y as Actions,N as AgentDeliveryError,A as AgentError,h as Button,c as Card,m as CardLink,f as CardText,x as Client,S as CronExpression,H as Divider,a as NovuRequestHandler,v as Select,w as SelectOption,k as SeverityLevelEnum,E as TextInput,V as agent,l as frameworkName,b as providerSchemas,U as serve,$ as step,R as toAgentError,O as workflow};
@@ -1,13 +1,13 @@
1
1
  import * as h3 from 'h3';
2
2
  import { H3Event } from 'h3';
3
- import { S as ServeHandlerOptions } from '../index-CWldA6G5.js';
4
- export { C as Client, N as NovuRequestHandler, a as agent, w as workflow } from '../index-CWldA6G5.js';
5
- export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-BNocZ4Wk.js';
6
- export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CmybpXhA.js';
3
+ import { S as ServeHandlerOptions } from '../index-C0oUWDlb.js';
4
+ export { C as Client, N as NovuRequestHandler, a as agent, w as workflow } from '../index-C0oUWDlb.js';
5
+ export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-0Rv-l8yD.js';
6
+ export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-g7VnI_ZQ.js';
7
7
  import { S as SupportedFrameworkName } from '../server.types-Cc6o5eYH.js';
8
8
  export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
9
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentConversation, f as AgentDeliveryError, g as AgentError, h as AgentHandlerContext, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentResolveContext, r as AgentSubscriber, s as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, t as ToolApprovalConfig, u as ToolApprovalDecision, v as toAgentError } from '../agent.types-E3sxq6xr.js';
10
- export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from '../step-resolver.js';
9
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentContextPayload, f as AgentContextValue, g as AgentConversation, h as AgentDeliveryError, i as AgentError, j as AgentHandlerContext, k as AgentHandlers, l as AgentHistoryEntry, m as AgentMessage, n as AgentMessageAuthor, o as AgentMessageContext, p as AgentPlatformContext, q as AgentReaction, r as AgentReactionContext, s as AgentResolveContext, t as AgentSubscriber, u as AgentSubscriberAccess, v as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, w as ToolApprovalConfig, x as ToolApprovalDecision, y as toAgentError } from '../agent.types-HUDhyXrV.js';
10
+ export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, ToolStepResolver, step } from '../step-resolver.js';
11
11
  import '../util.types-DaFfsxgy.js';
12
12
  import '../base.schema.types-BApIn9jr.js';
13
13
  import 'json-schema-to-ts';
@@ -1 +1 @@
1
- import{b as E,c as t,d as b,e as $}from"../chunk-WDBIT4NK.js";import{a as B}from"../chunk-2M25EATE.js";import"../chunk-22DBAEUX.js";import{M as k,N as x,O,V as F}from"../chunk-LHU5A7DI.js";import{a as l,b as y,c as H,d as S,e as i,f,p as g,q as N,r as w}from"../chunk-46AHJTS7.js";import"../chunk-XEHQJMMQ.js";import{a as q}from"../chunk-CANJPWLT.js";import{f as c}from"../chunk-FRWG7YTE.js";import"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";import{getHeader as o,getQuery as a,readBody as p,send as n,setHeaders as m}from"h3";var h="h3",L=d=>new t({frameworkName:h,...d,handler:r=>({body:()=>p(r),headers:e=>o(r,e),method:()=>r.method,url:()=>new URL(String(r.path),`${process.env.NODE_ENV==="development"?"http":"https"}://${String(o(r,"host"))}`),queryString:e=>String(a(r)[e]),transformResponse:e=>{let{res:s}=r.node;return s.statusCode=e.status,m(r,e.headers),n(r,e.body)}})}).createHandler();export{l as Actions,x as AgentDeliveryError,k as AgentError,y as Button,H as Card,S as CardLink,i as CardText,E as Client,c as CronExpression,f as Divider,t as NovuRequestHandler,g as Select,N as SelectOption,F as SeverityLevelEnum,w as TextInput,b as agent,h as frameworkName,q as providerSchemas,L as serve,B as step,O as toAgentError,$ as workflow};
1
+ import{b as E,c as t,d as b,e as $}from"../chunk-CGZ5P44A.js";import{a as B}from"../chunk-YLCLZVYS.js";import"../chunk-XIVU4VDS.js";import{M as k,N as x,O,V as F}from"../chunk-FMKD6TON.js";import{a as l,b as y,c as H,d as S,e as i,f,p as g,q as N,r as w}from"../chunk-X5AZIKIR.js";import"../chunk-RBTQQ5IZ.js";import{a as q}from"../chunk-SPS3KBKF.js";import{f as c}from"../chunk-VY27ZAO7.js";import"../chunk-W6DIBD4Z.js";import"../chunk-FHYMHX3T.js";import{getHeader as o,getQuery as a,readBody as p,send as n,setHeaders as m}from"h3";var h="h3",L=d=>new t({frameworkName:h,...d,handler:r=>({body:()=>p(r),headers:e=>o(r,e),method:()=>r.method,url:()=>new URL(String(r.path),`${process.env.NODE_ENV==="development"?"http":"https"}://${String(o(r,"host"))}`),queryString:e=>String(a(r)[e]),transformResponse:e=>{let{res:s}=r.node;return s.statusCode=e.status,m(r,e.headers),n(r,e.body)}})}).createHandler();export{l as Actions,x as AgentDeliveryError,k as AgentError,y as Button,H as Card,S as CardLink,i as CardText,E as Client,c as CronExpression,f as Divider,t as NovuRequestHandler,g as Select,N as SelectOption,F as SeverityLevelEnum,w as TextInput,b as agent,h as frameworkName,q as providerSchemas,L as serve,B as step,O as toAgentError,$ as workflow};