codicent-app-sdk 0.4.22 → 0.4.25

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 (39) hide show
  1. package/README.md +556 -556
  2. package/dist/cjs/components/ListView.d.ts.map +1 -1
  3. package/dist/cjs/components/ListView.js +1 -1
  4. package/dist/cjs/components/MessageItem.d.ts.map +1 -1
  5. package/dist/cjs/components/MessageItem.js +1 -1
  6. package/dist/cjs/components/RecordModal.d.ts.map +1 -1
  7. package/dist/cjs/components/RecordModal.js +1 -1
  8. package/dist/cjs/config/index.d.ts +0 -1
  9. package/dist/cjs/config/index.d.ts.map +1 -1
  10. package/dist/cjs/config/index.js +1 -1
  11. package/dist/cjs/hooks/useCodicentApp.d.ts.map +1 -1
  12. package/dist/cjs/hooks/useCodicentApp.js +1 -1
  13. package/dist/cjs/hooks/useRealtimeVoiceAI.d.ts +1 -1
  14. package/dist/cjs/hooks/useRealtimeVoiceAI.d.ts.map +1 -1
  15. package/dist/cjs/hooks/useRealtimeVoiceAI.js +1 -1
  16. package/dist/cjs/services/codicent.d.ts.map +1 -1
  17. package/dist/cjs/services/codicent.js +1 -1
  18. package/dist/cjs/types/index.d.ts +2 -0
  19. package/dist/cjs/types/index.d.ts.map +1 -1
  20. package/dist/esm/components/ListView.d.ts.map +1 -1
  21. package/dist/esm/components/ListView.js +1 -1
  22. package/dist/esm/components/MessageItem.d.ts.map +1 -1
  23. package/dist/esm/components/MessageItem.js +1 -1
  24. package/dist/esm/components/RecordModal.d.ts.map +1 -1
  25. package/dist/esm/components/RecordModal.js +1 -1
  26. package/dist/esm/config/index.d.ts +0 -1
  27. package/dist/esm/config/index.d.ts.map +1 -1
  28. package/dist/esm/config/index.js +1 -1
  29. package/dist/esm/hooks/useCodicentApp.d.ts.map +1 -1
  30. package/dist/esm/hooks/useCodicentApp.js +1 -1
  31. package/dist/esm/hooks/useRealtimeVoiceAI.d.ts +1 -1
  32. package/dist/esm/hooks/useRealtimeVoiceAI.d.ts.map +1 -1
  33. package/dist/esm/hooks/useRealtimeVoiceAI.js +1 -1
  34. package/dist/esm/services/codicent.d.ts.map +1 -1
  35. package/dist/esm/services/codicent.js +1 -1
  36. package/dist/esm/types/index.d.ts +2 -0
  37. package/dist/esm/types/index.d.ts.map +1 -1
  38. package/dist/index.d.ts +3 -2
  39. package/package.json +1 -1
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import i,{useMemo as r,useState as o,useEffect as l}from"react";import{makeStyles as a,Button as c,Checkbox as d,Select as s,Dialog as p,DialogSurface as h,DialogBody as u,DialogTitle as m,DialogContent as f,Tooltip as x}from"@fluentui/react-components";import{Edit24Regular as g,Delete24Regular as y}from"@fluentui/react-icons";import{CodicentService as b}from"../services/codicent.js";import w from"../hooks/useLocalization.js";const k=a({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),C=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},v=({data:i,columns:a,canEdit:v,onEdit:S,onDelete:W,onToggleCheckbox:N,onEnumChange:$,onFilteredDataChange:A})=>{const j=k(),{visibleColumns:I,defaultSortIndex:O,defaultSortDirection:M}=r((()=>{const e=i&&i.length>0?Array.from(new Set(i.flatMap((e=>Object.keys(e))))):[],t=(a||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[i,a]),[T,B]=o(O>=0?O:null),[z,D]=o(M),[F,L]=o(!1),[H,E]=o({title:"",text:""}),[P,Y]=o({}),[R,_]=o(0),{t:J}=w(),U=e=>e.title?J(e.title):Array.isArray(e.key)?e.key[0]:e.key,X=e=>{const t=[];return e.hideOnMobile&&t.push(j.hideOnMobile),t.join(" ")},q=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),G=r((()=>{const e=[...i];if(null!==T&&z){const t=I[T];e.sort(((e,n)=>{const i=C(e,t.key),r=C(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;return o="string"==typeof i&&"string"==typeof r?i.localeCompare(r):"number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r)),"asc"===z?o:-o}))}return e}),[i,T,z,I]),K=r((()=>G.filter((e=>{for(const[t,n]of Object.entries(P)){const i=parseInt(t),r=I[i],o=C(e,r.key),l=q(o).toLowerCase(),a=n.toLowerCase();if(!l.includes(a))return!1}return!0}))),[G,P,I]);l((()=>{A&&A(K)}),[K,A]);const Q="undefined"!=typeof window?window.innerHeight-250:600,V=Math.max(0,Math.floor(R/49)-5),Z=Math.min(K.length,Math.ceil((R+Q)/49)+5),ee=K.slice(V,Z),te=49*K.length,ne=49*V,ie=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(I.slice(0,3).map((t=>String(C(e,t.key)??""))).join("-"))}`};return i&&0!==i.length?t(n,{children:[e("div",{className:j.container,onScroll:e=>{_(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:t("table",{className:j.table,children:[t("thead",{children:[t("tr",{children:[I.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return t("th",{className:`${j.th} ${X(n)}`.trim(),style:r,onClick:()=>(e=>{T===e?"asc"===z?D("desc"):"desc"===z&&(B(null),D(null)):(B(e),D("asc"))})(i),children:[U(n),T===i&&e("span",{className:j.sortIndicator,children:"asc"===z?"▲":"▼"})]},i)})),v&&e("th",{className:`${j.th} ${j.actionsColumn}`,style:{width:"100px"},children:J("Actions")})]}),t("tr",{children:[I.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return e("th",{className:X(n),style:r,children:n.filterable&&t("div",{className:j.filterWrapper,children:[e("input",{type:"text",className:j.filterInput,placeholder:J("Filter")+"...",value:P[i]||"",onChange:e=>((e,t)=>{Y((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),(P[i]||"").length>0&&e(c,{appearance:"subtle",className:j.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{Y((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),v&&e("th",{className:j.actionsColumn})]})]}),t("tbody",{children:[V>0&&e("tr",{style:{height:`${ne}px`},children:e("td",{colSpan:I.length+(v?1:0),style:{padding:0,border:"none"}})}),ee.map(((n,i)=>{const r=n._index,o="number"==typeof r?r:V+i;return t("tr",{className:j.tr,children:[I.map(((i,r)=>{const l=C(n,i.key),a=i.format?i.format(l):q(l),p=i.maxWidth?`${j.td} ${j.tdTruncated} ${X(i)}`.trim():`${j.td} ${X(i)}`.trim(),h=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&a.length>0&&(E({title:U(i),text:a}),L(!0))};if("file"===i.type&&a)return e("td",{className:p,onClick:h,children:e("a",{href:b.getFileUrl(a),target:"_blank",rel:"noopener noreferrer",children:J("Download")})},r);if("checkbox"===i.type){return e("td",{className:p,children:e(d,{checked:!0===l||"true"===l||"yes"===l||"1"===l,onChange:(e,t)=>{N&&N(n,i.key,!0===t.checked,o)}})},r)}if("enum"===i.type&&i.enumOptions)return e("td",{className:p,children:t(s,{value:a,"aria-label":i.title?J(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,t)=>{$&&$(n,i.key,t.value,o)},style:{width:"100%"},children:[!i.enumOptions.includes(a)&&a&&e("option",{value:a,children:a}),i.enumOptions.map((t=>e("option",{value:t,children:J(t)},t)))]})},r);const u=()=>i.maxWidth&&a.length>0?e(x,{content:{children:a,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e("span",{children:a})}):a;return e("td",{className:p,onClick:h,children:i.action?t("div",{className:j.cellWithAction,children:[e("span",{className:j.cellText,children:u()}),(()=>{if(!i.action)return null;const t=i.action,r=i.action.icon,o=e(c,{appearance:"subtle",icon:e(r,{}),className:j.actionIcon,onClick:e=>{e.stopPropagation(),t.onClick(n)},size:"small"});return t.tooltip?e(x,{content:J(t.tooltip),relationship:"label",children:o}):o})()]}):u()},r)})),v&&(S||W)&&e("td",{className:`${j.td} ${j.actionsColumn}`,children:t("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[S&&e(c,{appearance:"subtle",icon:e(g,{}),className:j.editButton,onClick:()=>S(n,o),title:J("Edit")}),W&&e(c,{appearance:"subtle",icon:e(y,{}),className:j.editButton,onClick:()=>W(n,o),title:J("Delete")})]})})]},ie(n,o))})),Z<K.length&&e("tr",{style:{height:te-ne-49*ee.length+"px"},children:e("td",{colSpan:I.length+(v?1:0),style:{padding:0,border:"none"}})})]})]})}),e(p,{open:F,onOpenChange:(e,t)=>L(t.open),children:e(h,{children:t(u,{children:[e(m,{children:H.title}),e(f,{className:j.dialogContent,children:H.text})]})})})]}):e("div",{className:j.emptyState,children:J("No data to display")})};var S=i.memo(v);export{v as ListView,S as default};
1
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import i,{useMemo as r,useState as o,useEffect as l}from"react";import{makeStyles as a,Button as c,Checkbox as d,Select as s,Dialog as p,DialogSurface as h,DialogBody as u,DialogTitle as m,DialogContent as f,Tooltip as x}from"@fluentui/react-components";import{Edit24Regular as g,Delete24Regular as y}from"@fluentui/react-icons";import{CodicentService as b}from"../services/codicent.js";import w from"../hooks/useLocalization.js";const k=a({container:{width:"100%",overflowX:"auto",userSelect:"text"},table:{width:"100%",borderCollapse:"collapse",backgroundColor:"#ffffff",fontSize:"14px",tableLayout:"fixed",userSelect:"text"},th:{textAlign:"left",padding:"12px 8px",borderBottom:"2px solid #e0e0e0",fontWeight:"600",backgroundColor:"#f5f5f5",position:"sticky",top:0,zIndex:1,cursor:"pointer",userSelect:"none","&:hover":{backgroundColor:"#e8e8e8"}},td:{padding:"12px 8px",borderBottom:"1px solid #e0e0e0",verticalAlign:"top",wordWrap:"break-word",overflow:"hidden",userSelect:"text"},tdTruncated:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap","@media (hover: none)":{cursor:"pointer"}},tr:{"&:hover":{backgroundColor:"#f9f9f9"}},emptyState:{padding:"20px",textAlign:"center",color:"#666"},sortIndicator:{marginLeft:"4px",fontSize:"10px"},hideOnMobile:{"@media (max-width: 768px)":{display:"none"}},dialogContent:{wordWrap:"break-word",whiteSpace:"pre-wrap",maxHeight:"60vh",overflowY:"auto"},thumbnail:{maxWidth:"50px",maxHeight:"50px",objectFit:"cover"},tooltip:{maxWidth:"600px",whiteSpace:"normal",wordWrap:"break-word"},editButton:{minWidth:"auto",padding:"4px 8px"},actionsColumn:{width:"100px",textAlign:"center"},filterInput:{width:"100%",padding:"4px 8px",fontSize:"14px",border:"1px solid #e0e0e0",borderRadius:"4px",paddingRight:"28px"},filterWrapper:{position:"relative"},clearFilterButton:{position:"absolute",right:"6px",top:"50%",transform:"translateY(-50%)",minWidth:"auto",height:"20px",padding:"0 6px",lineHeight:"18px"},filterToolbar:{display:"flex",justifyContent:"flex-end",padding:"8px",gap:"8px"},cellWithAction:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"4px"},actionIcon:{minWidth:"auto",padding:"2px",marginLeft:"4px",flexShrink:0,cursor:"pointer",opacity:.7,"&:hover":{opacity:1}},cellText:{flex:1,overflow:"hidden",textOverflow:"ellipsis"}}),C=e=>{if(/^\d{4}-\d{2}-\d{2}/.test(e)){const t=new Date(e);if(!isNaN(t.getTime()))return t.getTime()}const t=e.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})/);if(t){const e=parseInt(t[1],10),n=parseInt(t[2],10)-1,i=parseInt(t[3],10),r=new Date(i,n,e);if(r.getFullYear()===i&&r.getMonth()===n&&r.getDate()===e)return r.getTime()}return null},v=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},S=({data:i,columns:a,canEdit:S,onEdit:N,onDelete:W,onToggleCheckbox:$,onEnumChange:I,onFilteredDataChange:A})=>{const j=k(),{visibleColumns:O,defaultSortIndex:M,defaultSortDirection:T}=r((()=>{const e=i&&i.length>0?Array.from(new Set(i.flatMap((e=>Object.keys(e))))):[],t=(a||e.map((e=>({key:e})))).filter((e=>!e.hidden)),n=t.findIndex((e=>e.defaultSort));return{visibleColumns:t,defaultSortIndex:n,defaultSortDirection:n>=0&&t[n].defaultSort||null}}),[i,a]),[D,F]=o(M>=0?M:null),[B,z]=o(T),[L,H]=o(!1),[E,Y]=o({title:"",text:""}),[P,R]=o({}),[_,J]=o(0),{t:U}=w(),X=e=>e.title?U(e.title):Array.isArray(e.key)?e.key[0]:e.key,q=e=>{const t=[];return e.hideOnMobile&&t.push(j.hideOnMobile),t.join(" ")},G=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),K=r((()=>{const e=[...i];if(null!==D&&B){const t=O[D];e.sort(((e,n)=>{const i=v(e,t.key),r=v(n,t.key);if(null==i)return 1;if(null==r)return-1;let o=0;if("string"==typeof i&&"string"==typeof r){const e=C(i),t=C(r);if(null!==e&&null!==t)o=e-t;else{const e=Number(i.trim()),t=Number(r.trim());o=""!==i.trim()&&""!==r.trim()&&isFinite(e)&&isFinite(t)?e-t:i.localeCompare(r)}}else o="number"==typeof i&&"number"==typeof r?i-r:String(i).localeCompare(String(r));return"asc"===B?o:-o}))}return e}),[i,D,B,O]),Q=r((()=>K.filter((e=>{for(const[t,n]of Object.entries(P)){const i=parseInt(t),r=O[i],o=v(e,r.key),l=G(o).toLowerCase(),a=n.toLowerCase();if(!l.includes(a))return!1}return!0}))),[K,P,O]);l((()=>{A&&A(Q)}),[Q,A]);const V="undefined"!=typeof window?window.innerHeight-250:600,Z=Math.max(0,Math.floor(_/49)-5),ee=Math.min(Q.length,Math.ceil((_+V)/49)+5),te=Q.slice(Z,ee),ne=49*Q.length,ie=49*Z,re=(e,t)=>{if(void 0!==e.id)return String(e.id);return`row-${t}-${(e=>{let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)})(O.slice(0,3).map((t=>String(v(e,t.key)??""))).join("-"))}`};return i&&0!==i.length?t(n,{children:[e("div",{className:j.container,onScroll:e=>{J(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:t("table",{className:j.table,children:[t("thead",{children:[t("tr",{children:[O.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return t("th",{className:`${j.th} ${q(n)}`.trim(),style:r,onClick:()=>(e=>{D===e?"asc"===B?z("desc"):"desc"===B&&(F(null),z(null)):(F(e),z("asc"))})(i),children:[X(n),D===i&&e("span",{className:j.sortIndicator,children:"asc"===B?"▲":"▼"})]},i)})),S&&e("th",{className:`${j.th} ${j.actionsColumn}`,style:{width:"100px"},children:U("Actions")})]}),t("tr",{children:[O.map(((n,i)=>{const r=n.maxWidth?{width:`${n.maxWidth}px`,maxWidth:`${n.maxWidth}px`}:{};return e("th",{className:q(n),style:r,children:n.filterable&&t("div",{className:j.filterWrapper,children:[e("input",{type:"text",className:j.filterInput,placeholder:U("Filter")+"...",value:P[i]||"",onChange:e=>((e,t)=>{R((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),(P[i]||"").length>0&&e(c,{appearance:"subtle",className:j.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{R((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),S&&e("th",{className:j.actionsColumn})]})]}),t("tbody",{children:[Z>0&&e("tr",{style:{height:`${ie}px`},children:e("td",{colSpan:O.length+(S?1:0),style:{padding:0,border:"none"}})}),te.map(((n,i)=>{const r=n._index,o="number"==typeof r?r:Z+i;return t("tr",{className:j.tr,children:[O.map(((i,r)=>{const l=v(n,i.key),a=i.format?i.format(l):G(l),p=i.maxWidth?`${j.td} ${j.tdTruncated} ${q(i)}`.trim():`${j.td} ${q(i)}`.trim(),h=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&a.length>0&&(Y({title:X(i),text:a}),H(!0))};if("file"===i.type&&a)return e("td",{className:p,onClick:h,children:e("a",{href:b.getFileUrl(a),target:"_blank",rel:"noopener noreferrer",children:U("Download")})},r);if("checkbox"===i.type){return e("td",{className:p,children:e(d,{checked:!0===l||"true"===l||"yes"===l||"1"===l,onChange:(e,t)=>{$&&$(n,i.key,!0===t.checked,o)}})},r)}if("enum"===i.type&&i.enumOptions)return e("td",{className:p,children:t(s,{value:a,"aria-label":i.title?U(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,t)=>{I&&I(n,i.key,t.value,o)},style:{width:"100%"},children:[!i.enumOptions.includes(a)&&a&&e("option",{value:a,children:a}),i.enumOptions.map((t=>e("option",{value:t,children:U(t)},t)))]})},r);const u=()=>i.maxWidth&&a.length>0?e(x,{content:{children:a,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e("span",{children:a})}):a;return e("td",{className:p,onClick:h,children:i.action?t("div",{className:j.cellWithAction,children:[e("span",{className:j.cellText,children:u()}),(()=>{if(!i.action)return null;const t=i.action,r=i.action.icon,o=e(c,{appearance:"subtle",icon:e(r,{}),className:j.actionIcon,onClick:e=>{e.stopPropagation(),t.onClick(n)},size:"small"});return t.tooltip?e(x,{content:U(t.tooltip),relationship:"label",children:o}):o})()]}):u()},r)})),S&&(N||W)&&e("td",{className:`${j.td} ${j.actionsColumn}`,children:t("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[N&&e(c,{appearance:"subtle",icon:e(g,{}),className:j.editButton,onClick:()=>N(n,o),title:U("Edit")}),W&&e(c,{appearance:"subtle",icon:e(y,{}),className:j.editButton,onClick:()=>W(n,o),title:U("Delete")})]})})]},re(n,o))})),ee<Q.length&&e("tr",{style:{height:ne-ie-49*te.length+"px"},children:e("td",{colSpan:O.length+(S?1:0),style:{padding:0,border:"none"}})})]})]})}),e(p,{open:L,onOpenChange:(e,t)=>H(t.open),children:e(h,{children:t(u,{children:[e(m,{children:E.title}),e(f,{className:j.dialogContent,children:E.text})]})})})]}):e("div",{className:j.emptyState,children:U("No data to display")})};var N=i.memo(S);export{S as ListView,N as default};
@@ -1 +1 @@
1
- {"version":3,"file":"MessageItem.d.ts","sourceRoot":"","sources":["../../../src/components/MessageItem.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2H9C,QAAA,MAAM,WAAW,uIAcd;IACD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,4CAwRA,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"MessageItem.d.ts","sourceRoot":"","sources":["../../../src/components/MessageItem.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2H9C,QAAA,MAAM,WAAW,uIAcd;IACD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,4CA4RA,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as i,useEffect as r}from"react";import{makeStyles as a,tokens as n,Card as s,Switch as l,CardHeader as m,Skeleton as c,SkeletonItem as d,Caption1 as p}from"@fluentui/react-components";import{useNavigate as g}from"react-router-dom";import{Edit20Regular as h,FullScreenMaximizeRegular as u,ArrowCollapseAllRegular as f,ArrowExpandAllRegular as j}from"@fluentui/react-icons";import{CodicentService as x}from"../services/codicent.js";import w from"./Markdown.js";import"./Textarea.js";import"./Button.js";import"./CompoundButton.js";import{Text as S}from"./Text.js";import"./Spinner.js";import"./TextHeader.js";import"./TypingIndicator.js";import"./Dialog.js";import"./ChatInput.js";import"./CombinedPlaceholderDialog.js";import"./ChatMessage.js";import"./Header.js";import b from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as O}from"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"../pages/AppFrame.js";import"../pages/Chat.js";import"../pages/Compose.js";import"../pages/Snap.js";import"../pages/Search.js";import"../pages/Login.js";import"../pages/CrmPage.js";import"../pages/CrmPagePersistent.js";import"../pages/ImageView.js";import"../pages/FormInvite.js";import"../pages/FormAccept.js";import"../pages/Sales.js";import"../pages/Purchase.js";import"./Content.js";import"./Page.js";import"../pages/QrScan.js";import I from"../hooks/useLocalization.js";import{FileThumbnail as k}from"./FileThumbnail.js";import"react-dom/client";import"../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js";import"../hooks/useAppStyles.js";import"./MessageInput.js";import"./UploadFile.js";import"./SnapFooter.js";import"./Profile.js";import"./AiInput.js";import"./SearchBox.js";import"./DataMessagePicker.js";import"./HtmlView.js";import"./Footer.js";import"./QrCodeDialog.js";import"./QrScanner.js";import"./OfflineMessage.js";import"./LanguageSelector.js";import"./ListView.js";import"./RecordModal.js";import"./BulkUploadDialog.js";import"./CookieBanner.js";const _=a({iframe:{border:"none",width:"100%",height:"100%"},main:{gap:"36px",display:"flex",flexDirection:"column",flexWrap:"wrap"},card:{minWidth:"300px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",maxHeight:"11em",borderRadius:"10px",position:"relative"},expandedCard:{minWidth:"320px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",borderRadius:"10px",position:"relative"},text:{margin:"0.5em",whiteSpace:"normal",fontSize:"larger"},caption:{color:n.colorNeutralForeground3},headerImage:{borderRadius:"4px",maxWidth:"44px",maxHeight:"44px"},rectangle:{margin:0,top:"-5px",left:"-2px",width:"5px",position:"absolute",height:"100%"},fileList:{display:"flex",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin",msOverflowStyle:"none",padding:"4px",margin:"0 -4px",maxWidth:"100%",boxSizing:"border-box","&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:n.colorNeutralStroke1,borderRadius:"3px"}},htmlButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},headerButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},iconButtonRow:{position:"absolute",top:"0.5em",right:"0.5em",display:"flex",alignItems:"center",gap:"0.5em",zIndex:2},content:{overflow:"hidden",transition:"max-height 0.3s ease-out",userSelect:"text"},truncated:{maxHeight:"10em"},header:{display:"flex",flexDirection:"row",gap:"0.5em",alignItems:"center"},todoSwitch:{transform:"scale(0.8)","& .fui-Switch__label":{fontSize:"0.75rem"}}}),v=({header:a,description:n,timestamp:v,text:E,image:N,tags:T,id:C,fileIds:y,codicentService:A,busy:B,onEdit:L,onShowHtmlPreview:P,maxHeightPx:F})=>{const R=_(),D=g(),[H,G]=o(!1),[M,z]=o(!1),[K,W]=o("unknown"),[$,U]=o(!1),Q=i(null),V=Object.keys(O("LOGBOOK_TAG_DEFINITIONS")),Y=V.find((e=>T.includes(e)))||(y.length>0?V.find((e=>"file"===e)):void 0),[X,q]=o([]),J=T.includes("todo"),{t:Z}=I(),ee=["TYPE","CUSTOMER","CONTACT","SALESPERSON","MESSAGE","COMPANY","PHONE","EMAIL","WEBSITE","INFO","FÖRETAG","ROLE","KONTAKT"],te=[Z("Typ"),Z("Kund"),Z("Kontakt"),Z("Säljare"),Z("Meddelande"),Z("Företag"),Z("Telefon"),Z("E-post"),Z("Hemsida"),Z("Info"),Z("Företag"),Z("Roll"),Z("Kontakt")];r((()=>{Promise.all(y.map((e=>A.getFileInfo(e)))).then((e=>{q(e)}))}),[A,q,y]),r((()=>{const e=()=>{if(Q.current){const e=F??100,t=Q.current.scrollHeight>e+(X.length>0?-72:0);z(t)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[E,X,F]),r((()=>{if(J){(async()=>{try{const e=await A.getTodoStatus(C);W(e)}catch(e){console.error("Error loading todo status:",e),W("unknown")}})()}}),[J,C,A]);const oe=()=>G(!H),ie=T.includes("chat")&&(E.includes("#function_result")||E.includes("#finish_reason_function_call")),re=e=>{const t=e.indexOf("```html");if(-1===t)return e;const o=e.indexOf("```",t+7);if(-1===o)return e.substring(t+7);return e.substring(t+7,o)},ae=new b(E),ne=ae.data,se=O("LOGBOOK_STRIP_TAGS")?ae.content:E,le=Y&&O("LOGBOOK_TAG_DEFINITIONS")[Y].editable,me=Y&&O("LOGBOOK_TAG_DEFINITIONS")[Y].imageSize||void 0;return e(s,{className:H?R.expandedCard:R.card,style:{backgroundColor:O("MESSAGE_HIDE_BAR")?Y?O("LOGBOOK_TAG_DEFINITIONS")[Y].color:O("APP_HEADER_COLOR")||"#eee":"#eee",maxHeight:!H&&F?`${F}px`:void 0},onClick:T.includes("chat")?e=>{T.includes("chat")&&(e&&e.stopPropagation(),D("/chat?id="+C))}:void 0,children:[!O("MESSAGE_HIDE_BAR")&&t("div",{className:R.rectangle,style:{backgroundColor:Y?O("LOGBOOK_TAG_DEFINITIONS")[Y].color:O("APP_HEADER_COLOR")||void 0}}),e("div",{className:R.iconButtonRow,children:[J&&t(l,{className:R.todoSwitch,checked:"done"===K,onChange:(e,t)=>(async e=>{if(!$){U(!0);try{const t=e?"done":"undone";await A.updateTodoStatus(C,t)&&W(t)}catch(e){console.error("Error updating todo status:",e)}finally{U(!1)}}})(t.checked),disabled:$||"unknown"===K,label:Z("done"===K?"Done":"Todo")}),le&&L&&t(h,{className:R.htmlButton,onClick:()=>L()}),P&&!le&&T.includes("html")&&t(u,{className:R.htmlButton,onClick:e=>{e.stopPropagation(),P(re(E))}}),M&&!T.includes("chat")&&H&&t(f,{className:R.headerButton,onClick:oe}),M&&!T.includes("chat")&&!H&&t(j,{className:R.headerButton,onClick:oe})]}),t(m,{image:N?t("img",{className:R.headerImage,src:"app_logo.svg",alt:"User"}):null,header:B?t(c,{style:{width:"50%"},children:t(d,{})}):e("div",{className:R.header,children:[t(S,{weight:"semibold",children:a}),v&&t(S,{weight:"regular",children:v})]}),description:t(p,{className:R.caption,children:n})}),e("div",{ref:Q,className:`${R.content} ${H?"":R.truncated}`,style:{maxHeight:!H&&F?`${F}px`:void 0},children:[X.length>0&&t("div",{className:R.fileList,children:X.map((e=>t(k,{file:e,thumbnailSize:me,getImageUrl:x.getImageUrl,onClick:()=>{e.contentType.startsWith("image")?D(`/image?id=${C}&file=${e.id}`):x.downloadFile(e)}},e.id)))}),B?e(c,{style:{width:"100%"},children:[t(d,{}),t(d,{}),t(d,{}),t(d,{}),t(d,{})]}):t("div",{className:R.text,children:T.includes("html")?t("iframe",{className:R.iframe,title:"html",srcDoc:re(E),sandbox:"allow-same-origin allow-scripts"}):T.includes("crm")&&0===Object.keys(ne).length?t(w,{content:ie?"*"+Z("Tänker")+"...*":ne?(()=>{const e=new RegExp(`(${ee.join("|")})\\s*:\\s*`,"gi");return se.replace(e,((e,t)=>{const o=ee.indexOf(t.toUpperCase());-1===o&&console.log("Field not found:",t);return`\n**${-1!==o?te[o]:t}:** `})).trim()})():E}):t(w,{content:ie?"*"+Z("Tänker")+"...*":ne?ne&&Object.keys(ne).length>0?Object.keys(ne).map((e=>{const t=ee.indexOf(e.toUpperCase());return`**${-1!==t?te[t]:e}:** ${ne[e]}\n`})).join("\n"):se:E})})]})]})};export{v as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as i,useEffect as r}from"react";import{makeStyles as a,tokens as n,Card as s,Switch as l,CardHeader as m,Skeleton as c,SkeletonItem as d,Caption1 as p}from"@fluentui/react-components";import{useNavigate as g}from"react-router-dom";import{Edit20Regular as u,FullScreenMaximizeRegular as h,ArrowCollapseAllRegular as f,ArrowExpandAllRegular as j}from"@fluentui/react-icons";import{CodicentService as x}from"../services/codicent.js";import b from"./Markdown.js";import"./Textarea.js";import"./Button.js";import"./CompoundButton.js";import{Text as w}from"./Text.js";import"./Spinner.js";import"./TextHeader.js";import"./TypingIndicator.js";import"./Dialog.js";import"./ChatInput.js";import"./CombinedPlaceholderDialog.js";import"./ChatMessage.js";import"./Header.js";import S from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as O}from"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"../pages/AppFrame.js";import"../pages/Chat.js";import"../pages/Compose.js";import"../pages/Snap.js";import"../pages/Search.js";import"../pages/Login.js";import"../pages/CrmPage.js";import"../pages/CrmPagePersistent.js";import"../pages/ImageView.js";import"../pages/FormInvite.js";import"../pages/FormAccept.js";import"../pages/Sales.js";import"../pages/Purchase.js";import"./Content.js";import"./Page.js";import"../pages/QrScan.js";import _ from"../hooks/useLocalization.js";import{FileThumbnail as I}from"./FileThumbnail.js";import"react-dom/client";import"../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js";import"../hooks/useAppStyles.js";import"./MessageInput.js";import"./UploadFile.js";import"./SnapFooter.js";import"./Profile.js";import"./AiInput.js";import"./SearchBox.js";import"./DataMessagePicker.js";import"./HtmlView.js";import"./Footer.js";import"./QrCodeDialog.js";import"./QrScanner.js";import"./OfflineMessage.js";import"./LanguageSelector.js";import"./ListView.js";import"./RecordModal.js";import"./BulkUploadDialog.js";import"./CookieBanner.js";const k=a({iframe:{border:"none",width:"100%",height:"100%"},main:{gap:"36px",display:"flex",flexDirection:"column",flexWrap:"wrap"},card:{minWidth:"300px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",maxHeight:"11em",borderRadius:"10px",position:"relative"},expandedCard:{minWidth:"320px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",borderRadius:"10px",position:"relative"},text:{margin:"0.5em",whiteSpace:"normal",fontSize:"larger"},caption:{color:n.colorNeutralForeground3},headerImage:{borderRadius:"4px",maxWidth:"44px",maxHeight:"44px"},rectangle:{margin:0,top:"-5px",left:"-2px",width:"5px",position:"absolute",height:"100%"},fileList:{display:"flex",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin",msOverflowStyle:"none",padding:"4px",margin:"0 -4px",maxWidth:"100%",boxSizing:"border-box","&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:n.colorNeutralStroke1,borderRadius:"3px"}},htmlButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},headerButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},iconButtonRow:{position:"absolute",top:"0.5em",right:"0.5em",display:"flex",alignItems:"center",gap:"0.5em",zIndex:2},content:{overflow:"hidden",transition:"max-height 0.3s ease-out",userSelect:"text"},truncated:{maxHeight:"10em"},header:{display:"flex",flexDirection:"row",gap:"0.5em",alignItems:"center"},todoSwitch:{transform:"scale(0.8)","& .fui-Switch__label":{fontSize:"0.75rem"}}}),v=({header:a,description:n,timestamp:v,text:E,image:N,tags:T,id:C,fileIds:y,codicentService:A,busy:B,onEdit:L,onShowHtmlPreview:P,maxHeightPx:F})=>{const R=k(),D=g(),[H,G]=o(!1),[M,z]=o(!1),[K,W]=o("unknown"),[$,U]=o(!1),Q=i(null),V=Object.keys(O("LOGBOOK_TAG_DEFINITIONS")),Y=V.find((e=>T.includes(e)))||(y.length>0?V.find((e=>"file"===e)):void 0),[X,q]=o([]),J=T.includes("todo"),{t:Z}=_(),ee=["TYPE","CUSTOMER","CONTACT","SALESPERSON","MESSAGE","COMPANY","PHONE","EMAIL","WEBSITE","INFO","FÖRETAG","ROLE","KONTAKT"],te=[Z("Typ"),Z("Kund"),Z("Kontakt"),Z("Säljare"),Z("Meddelande"),Z("Företag"),Z("Telefon"),Z("E-post"),Z("Hemsida"),Z("Info"),Z("Företag"),Z("Roll"),Z("Kontakt")];r((()=>{Promise.all(y.map((e=>A.getFileInfo(e)))).then((e=>{q(e)}))}),[A,q,y]),r((()=>{const e=()=>{if(Q.current){const e=F??100,t=Q.current.scrollHeight>e+(X.length>0?-72:0);z(t)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[E,X,F]),r((()=>{if(J){(async()=>{try{const e=await A.getTodoStatus(C);W(e)}catch(e){console.error("Error loading todo status:",e),W("unknown")}})()}}),[J,C,A]);const oe=()=>G(!H),ie=T.includes("chat")&&(E.includes("#function_result")||E.includes("#finish_reason_function_call")||E.includes("#function_results_batch")||E.includes("#finish_reason_tool_calls_batch")),re=e=>{const t=e.indexOf("```html");if(-1===t)return e;const o=e.indexOf("```",t+7);if(-1===o)return e.substring(t+7);return e.substring(t+7,o)},ae=new S(E),ne=ae.data,se=O("LOGBOOK_STRIP_TAGS")?ae.content:E,le=Y&&O("LOGBOOK_TAG_DEFINITIONS")[Y].editable,me=Y&&O("LOGBOOK_TAG_DEFINITIONS")[Y].imageSize||void 0;return e(s,{className:H?R.expandedCard:R.card,style:{backgroundColor:O("MESSAGE_HIDE_BAR")?Y?O("LOGBOOK_TAG_DEFINITIONS")[Y].color:O("APP_HEADER_COLOR")||"#eee":"#eee",maxHeight:!H&&F?`${F}px`:void 0},onClick:T.includes("chat")?e=>{T.includes("chat")&&(e&&e.stopPropagation(),D("/chat?id="+C))}:void 0,children:[!O("MESSAGE_HIDE_BAR")&&t("div",{className:R.rectangle,style:{backgroundColor:Y?O("LOGBOOK_TAG_DEFINITIONS")[Y].color:O("APP_HEADER_COLOR")||void 0}}),e("div",{className:R.iconButtonRow,children:[J&&t(l,{className:R.todoSwitch,checked:"done"===K,onChange:(e,t)=>(async e=>{if(!$){U(!0);try{const t=e?"done":"undone";await A.updateTodoStatus(C,t)&&W(t)}catch(e){console.error("Error updating todo status:",e)}finally{U(!1)}}})(t.checked),disabled:$||"unknown"===K,label:Z("done"===K?"Done":"Todo")}),le&&L&&t(u,{className:R.htmlButton,onClick:()=>L()}),P&&!le&&T.includes("html")&&t(h,{className:R.htmlButton,onClick:e=>{e.stopPropagation(),P(re(E))}}),M&&!T.includes("chat")&&H&&t(f,{className:R.headerButton,onClick:oe}),M&&!T.includes("chat")&&!H&&t(j,{className:R.headerButton,onClick:oe})]}),t(m,{image:N?t("img",{className:R.headerImage,src:"app_logo.svg",alt:"User"}):null,header:B?t(c,{style:{width:"50%"},children:t(d,{})}):e("div",{className:R.header,children:[t(w,{weight:"semibold",children:a}),v&&t(w,{weight:"regular",children:v})]}),description:t(p,{className:R.caption,children:n})}),e("div",{ref:Q,className:`${R.content} ${H?"":R.truncated}`,style:{maxHeight:!H&&F?`${F}px`:void 0},children:[X.length>0&&t("div",{className:R.fileList,children:X.map((e=>t(I,{file:e,thumbnailSize:me,getImageUrl:x.getImageUrl,onClick:()=>{e.contentType.startsWith("image")?D(`/image?id=${C}&file=${e.id}`):x.downloadFile(e)}},e.id)))}),B?e(c,{style:{width:"100%"},children:[t(d,{}),t(d,{}),t(d,{}),t(d,{}),t(d,{})]}):t("div",{className:R.text,children:T.includes("html")?t("iframe",{className:R.iframe,title:"html",srcDoc:re(E),sandbox:"allow-same-origin allow-scripts"}):T.includes("crm")&&0===Object.keys(ne).length?t(b,{content:ie?"*"+Z("Tänker")+"...*":ne?(()=>{const e=new RegExp(`(${ee.join("|")})\\s*:\\s*`,"gi");return se.replace(e,((e,t)=>{const o=ee.indexOf(t.toUpperCase());-1===o&&console.log("Field not found:",t);return`\n**${-1!==o?te[o]:t}:** `})).trim()})():E}):t(b,{content:ie?"*"+Z("Tänker")+"...*":ne?ne&&Object.keys(ne).length>0?Object.keys(ne).map((e=>{const t=ee.indexOf(e.toUpperCase());return`**${-1!==t?te[t]:e}:** ${ne[e]}\n`})).join("\n"):se:E})})]})]})};export{v as default};
@@ -1 +1 @@
1
- {"version":3,"file":"RecordModal.d.ts","sourceRoot":"","sources":["../../../src/components/RecordModal.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAiBnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoB9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAwHlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"RecordModal.d.ts","sourceRoot":"","sources":["../../../src/components/RecordModal.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAkBnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoB9C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAsIlD,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1 +1 @@
1
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useState as a,useEffect as o}from"react";import{makeStyles as n,tokens as l,Dialog as c,DialogSurface as t,DialogBody as i,DialogTitle as s,DialogContent as d,Field as p,Checkbox as h,Textarea as u,Input as f,DialogActions as m,Button as y}from"@fluentui/react-components";import k from"../hooks/useLocalization.js";const g=n({surface:{backgroundColor:l.colorNeutralBackground1},content:{display:"flex",flexDirection:"column",gap:"16px",minWidth:"400px",maxHeight:"60vh",overflowY:"auto"},field:{display:"flex",flexDirection:"column"}}),v=({open:n,onClose:l,onSave:v,columns:C,initialData:x,title:b})=>{const w=g(),{t:A}=k(),[N,S]=a({}),[D,E]=a(!1);o((()=>{n&&S(x||{})}),[n,x]);const L=e=>Array.isArray(e.key)?e.key[0]:e.key,j=e=>{if(Array.isArray(e.key))for(const r of e.key)if(void 0!==N[r])return r;return L(e)},z=(e,r)=>{const a=j(e);S((e=>({...e,[a]:r})))},R=C.filter((e=>!e.hidden&&"file"!==e.type&&"createdAt"!==L(e)));return e(c,{open:n,onOpenChange:(e,r)=>!D&&!1===r.open&&l(),children:e(t,{className:w.surface,backdrop:{style:{backgroundColor:"rgba(0, 0, 0, 0.4)"}},children:r(i,{children:[e(s,{children:b||A(x?"Edit Record":"Add Record")}),e(d,{className:w.content,children:R.map(((r,a)=>{const o=L(r),n=(e=>{const r=j(e);return N[r]})(r),l=r.title||o;return"checkbox"===r.type?e(p,{label:l,className:w.field,children:e(h,{checked:!0===n||"true"===n||"yes"===n||"1"===n,onChange:(e,a)=>z(r,a.checked)})},a):"textarea"===r.type?e(p,{label:l,className:w.field,children:e(u,{value:String(n??""),rows:r.rows??3,onChange:(e,a)=>z(r,a.value),placeholder:A("Enter")+" "+l.toLowerCase(),resize:"vertical"})},a):e(p,{label:l,className:w.field,children:e(f,{value:String(n??""),onChange:(e,a)=>z(r,a.value),placeholder:A("Enter")+" "+l.toLowerCase()})},a)}))}),r(m,{children:[e(y,{appearance:"secondary",onClick:l,disabled:D,children:A("Cancel")}),e(y,{appearance:"primary",onClick:async()=>{E(!0);try{await v(N),l()}catch(e){console.error("Failed to save record:",e)}finally{E(!1)}},disabled:D,children:A(D?"Saving...":"Save")})]})]})})})};export{v as RecordModal,v as default};
1
+ import{jsx as e,jsxs as r}from"react/jsx-runtime";import{useState as a,useEffect as n}from"react";import{makeStyles as o,tokens as l,Dialog as c,DialogSurface as t,DialogBody as i,DialogTitle as s,DialogContent as d,Field as p,Checkbox as u,Textarea as h,Select as m,Input as f,DialogActions as y,Button as g}from"@fluentui/react-components";import k from"../hooks/useLocalization.js";const v=o({surface:{backgroundColor:l.colorNeutralBackground1},content:{display:"flex",flexDirection:"column",gap:"16px",minWidth:"400px",maxHeight:"60vh",overflowY:"auto"},field:{display:"flex",flexDirection:"column"}}),C=({open:o,onClose:l,onSave:C,columns:b,initialData:x,title:N})=>{const w=v(),{t:A}=k(),[S,D]=a({}),[E,L]=a(!1);n((()=>{o&&D(x||{})}),[o,x]);const O=e=>Array.isArray(e.key)?e.key[0]:e.key,j=e=>{if(Array.isArray(e.key))for(const r of e.key)if(void 0!==S[r])return r;return O(e)},z=(e,r)=>{const a=j(e);D((e=>({...e,[a]:r})))},R=b.filter((e=>!e.hidden&&"file"!==e.type&&"createdAt"!==O(e)));return e(c,{open:o,onOpenChange:(e,r)=>!E&&!1===r.open&&l(),children:e(t,{className:w.surface,backdrop:{style:{backgroundColor:"rgba(0, 0, 0, 0.4)"}},children:r(i,{children:[e(s,{children:N||A(x?"Edit Record":"Add Record")}),e(d,{className:w.content,children:R.map(((r,a)=>{const n=O(r),o=(e=>{const r=j(e);return S[r]})(r),l=r.title||n;return"checkbox"===r.type?e(p,{label:l,className:w.field,children:e(u,{checked:!0===o||"true"===o||"yes"===o||"1"===o,onChange:(e,a)=>z(r,a.checked)})},a):"textarea"===r.type?e(p,{label:l,className:w.field,children:e(h,{value:String(o??""),rows:r.rows??3,onChange:(e,a)=>z(r,a.value),placeholder:A("Enter")+" "+l.toLowerCase(),resize:"vertical"})},a):"enum"===r.type&&r.enumOptions?e(p,{label:l,className:w.field,children:e(m,{value:String(o??""),onChange:(e,a)=>z(r,a.value),children:r.enumOptions.map((r=>e("option",{value:r,children:r||A("(None)")},r)))})},a):e(p,{label:l,className:w.field,children:e(f,{value:String(o??""),onChange:(e,a)=>z(r,a.value),placeholder:A("Enter")+" "+l.toLowerCase()})},a)}))}),r(y,{children:[e(g,{appearance:"secondary",onClick:l,disabled:E,children:A("Cancel")}),e(g,{appearance:"primary",onClick:async()=>{L(!0);try{await C(S),l()}catch(e){console.error("Failed to save record:",e)}finally{L(!1)}},disabled:E,children:A(E?"Saving...":"Save")})]})]})})})};export{C as RecordModal,C as default};
@@ -96,7 +96,6 @@ export interface AppConfigOptions {
96
96
  MESSAGE_HIDE_BAR: boolean;
97
97
  MODULE_VOICE: boolean;
98
98
  PUBLIC_FLOW_CODICENT: undefined | string;
99
- REALTIME_VOICE_API_KEY: string;
100
99
  REALTIME_VOICE_MODEL: string;
101
100
  REALTIME_VOICE_PROVIDER: string;
102
101
  USE_REALTIME_SESSION_ENDPOINT: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AACA,qBAAa,SAAS;;IAKpB,iBAAiB,EAAE,MAAM,CAAM;IAC/B,2BAA2B,EAAE,MAAM,CAAM;IACzC,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,OAAO,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,GAAG,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YAC1C,KAAK,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YACxD,iBAAiB,EAAE,MAAM,CAAC;YAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;YACvB,gBAAgB,EAAE,MAAM,CAAC;YACzB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;SACtB,CAAC;KACH,CAAC;CAyBH;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,yBAAyB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_{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const T={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",PUBSUB_URL:"https://pubsub.codicent.com/hub",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new _,APP_FOOTER_COLOR:void 0,APP_FOOTER_SELECTED_COLOR:void 0,APP_FOOTER_TEXT_COLOR:void 0,APP_HEADER_COLOR:void 0,APP_HEADER_ICON_URL:void 0,APP_HEADER_TEXT_COLOR:void 0,APP_ICON_URL:void 0,APP_LOG_CODICENT:"",APP_LOG_TOKEN:"",APP_LOGBOOK_TITLE:void 0,APP_MENU_TITLE:void 0,APP_NAME:void 0,APP_PREFIX:void 0,APP_SAVE_TITLE:void 0,APP_SEARCH_TITLE:void 0,APP_SLOGAN:void 0,APP_SPLASH_TEXT:void 0,APP_SPLASH_URL:void 0,APP_TEMPLATE:"",APP_TITLE:void 0,AUTH_REDIRECT_URL:void 0,AUTH0_AUDIENCE:"https://codicent.com/api",AUTH0_CLIENT_ID:"80STzWmmzN3Tgf76HgFRyv54keYmvnaw",AUTH0_DOMAIN:"auth.codicent.com",AUTH0_PASSWORDLESS_ENABLED:!1,AUTH0_PROVIDER_SCOPE:"read:current_user update:current_user_metadata openid profile email",AUTH0_SCOPE:"read:current_user",AUTH0_USER_DOMAIN:void 0,BUTTON_ACTIVE_COLOR:void 0,BUTTON_BACKGROUND_COLOR:void 0,BUTTON_BORDER_RADIUS:void 0,BUTTON_HOVER_COLOR:void 0,BUTTON_TAG:"app-button",BUTTON_TEXT_COLOR:void 0,CHAT_BACKGROUND_IMAGE_URL:void 0,CHAT_BOT_BACKGROUND_COLOR:void 0,CHAT_BOT_TEXT_COLOR:void 0,CHAT_INSTRUCTIONS:void 0,CHAT_USER_BACKGROUND_COLOR:void 0,CHAT_USER_TEXT_COLOR:void 0,CHAT_WELCOME:"Welcome",COMPOSE_BACKGROUND_IMAGE_URL:void 0,COMPOSE_AUTO_LOCATION:void 0,COMPOSE_HIDE_LOCATION:void 0,COMPOSE_SIMPLE_ATTACH_FILE:void 0,DEFAULT_LANGUAGE:"en",HIDE_CHAT_BUTTON:!1,HIDE_MENU_BUTTON:!1,HIDE_REGISTER_BUTTON:!1,HIDE_SAVE_BUTTON:!1,HOME_BACKGROUND_IMAGE_URL:void 0,INDEX_TITLE:void 0,LOGBOOK_TAG_DEFINITIONS:{},LOGBOOK_STRIP_TAGS:!1,LOGBOOK_TAGS:"[]",MENU_BACKGROUND_IMAGE_URL:void 0,MESSAGE_HIDE_BAR:!1,MODULE_VOICE:!1,PUBLIC_FLOW_CODICENT:void 0,REALTIME_VOICE_API_KEY:"",REALTIME_VOICE_MODEL:"alloy",REALTIME_VOICE_PROVIDER:"openai",USE_REALTIME_SESSION_ENDPOINT:!0,REALTIME_SESSION_ENDPOINT:"/realtime/session",REALTIME_CONFIG_ENDPOINT:"/realtime/config",SEND_BUTTON_ROUND_BACKGROUND:!1,SHOW_CANVAS_BUTTON:!1,SHOW_CHAT_PROMPTS:!1,SHOW_HELP_BUTTON:!1,SHOW_LOGBOOK_BUTTON:!1,SHOW_MICROPHONE_BUTTON:!1,SHOW_SETTINGS_BUTTON:!1,SHOW_SNAP_BUTTON:!1,SHOW_VOICE_BUTTON:!1,STRIPE_CUSTOMER_PORTAL:"",STRIPE_PRICE_ID:"",STRIPE_PUBLIC_KEY:"",STRIPE_SOURCE:"",STRIPE_TRIAL_PERIOD_DAYS:0,SUBSCRIPTION_NEEDED:!1,THEME_WELCOME:void 0,USER_PREFIX:void 0,WELCOME_STATUS_PROMPT:"",SHOW_SEND_BUTTON_TEXT:!1,SHOW_SAVE_BUTTON_TEXT:!1,FORM_BACKGROUND_IMAGE_URL:void 0,AUTO_TRANSLATE:!0,FORCE_LANGUAGE:void 0,TRANSLATIONS:void 0,LOGIN_WELCOME_TEXT:void 0,LOGIN_HIDE_WELCOME:!1,LOGIN_LOGO_URL:void 0,HIDE_CHAT_ADD_FILE_BUTTON:!1,FORM_ACCEPT_MARKDOWN:void 0,RESTART_AUDIO_ON_TAKE_PHOTO:!1,ENABLE_STATE_CACHE:!1,SESSION_CACHE_TTL:864e5,USER_INFO_CACHE_TTL:36e5,APPS_CACHE_TTL:3e5,OPTIMISTIC_CACHE_LOAD:!0,VALIDATE_CACHE_IN_BACKGROUND:!0,SHOW_VALIDATION_INDICATOR:!1,CACHE_FAILURE_MODE:"lenient"};const O=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(T);function E(_){return O[_]}function A(_={}){for(const[O,E]of Object.entries(_))void 0!==E&&(T[O]=E);void 0!==_.TRANSLATIONS&&(globalThis.__CODICENT_REINIT_I18N__=!0)}export{_ as AppConfig,E as getConfigValue,A as initCodicentApp};
1
+ class _{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const T={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",PUBSUB_URL:"https://pubsub.codicent.com/hub",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new _,APP_FOOTER_COLOR:void 0,APP_FOOTER_SELECTED_COLOR:void 0,APP_FOOTER_TEXT_COLOR:void 0,APP_HEADER_COLOR:void 0,APP_HEADER_ICON_URL:void 0,APP_HEADER_TEXT_COLOR:void 0,APP_ICON_URL:void 0,APP_LOG_CODICENT:"",APP_LOG_TOKEN:"",APP_LOGBOOK_TITLE:void 0,APP_MENU_TITLE:void 0,APP_NAME:void 0,APP_PREFIX:void 0,APP_SAVE_TITLE:void 0,APP_SEARCH_TITLE:void 0,APP_SLOGAN:void 0,APP_SPLASH_TEXT:void 0,APP_SPLASH_URL:void 0,APP_TEMPLATE:"",APP_TITLE:void 0,AUTH_REDIRECT_URL:void 0,AUTH0_AUDIENCE:"https://codicent.com/api",AUTH0_CLIENT_ID:"80STzWmmzN3Tgf76HgFRyv54keYmvnaw",AUTH0_DOMAIN:"auth.codicent.com",AUTH0_PASSWORDLESS_ENABLED:!1,AUTH0_PROVIDER_SCOPE:"read:current_user update:current_user_metadata openid profile email",AUTH0_SCOPE:"read:current_user",AUTH0_USER_DOMAIN:void 0,BUTTON_ACTIVE_COLOR:void 0,BUTTON_BACKGROUND_COLOR:void 0,BUTTON_BORDER_RADIUS:void 0,BUTTON_HOVER_COLOR:void 0,BUTTON_TAG:"app-button",BUTTON_TEXT_COLOR:void 0,CHAT_BACKGROUND_IMAGE_URL:void 0,CHAT_BOT_BACKGROUND_COLOR:void 0,CHAT_BOT_TEXT_COLOR:void 0,CHAT_INSTRUCTIONS:void 0,CHAT_USER_BACKGROUND_COLOR:void 0,CHAT_USER_TEXT_COLOR:void 0,CHAT_WELCOME:"Welcome",COMPOSE_BACKGROUND_IMAGE_URL:void 0,COMPOSE_AUTO_LOCATION:void 0,COMPOSE_HIDE_LOCATION:void 0,COMPOSE_SIMPLE_ATTACH_FILE:void 0,DEFAULT_LANGUAGE:"en",HIDE_CHAT_BUTTON:!1,HIDE_MENU_BUTTON:!1,HIDE_REGISTER_BUTTON:!1,HIDE_SAVE_BUTTON:!1,HOME_BACKGROUND_IMAGE_URL:void 0,INDEX_TITLE:void 0,LOGBOOK_TAG_DEFINITIONS:{},LOGBOOK_STRIP_TAGS:!1,LOGBOOK_TAGS:"[]",MENU_BACKGROUND_IMAGE_URL:void 0,MESSAGE_HIDE_BAR:!1,MODULE_VOICE:!1,PUBLIC_FLOW_CODICENT:void 0,REALTIME_VOICE_MODEL:"alloy",REALTIME_VOICE_PROVIDER:"openai",USE_REALTIME_SESSION_ENDPOINT:!0,REALTIME_SESSION_ENDPOINT:"/realtime/session",REALTIME_CONFIG_ENDPOINT:"/realtime/config",SEND_BUTTON_ROUND_BACKGROUND:!1,SHOW_CANVAS_BUTTON:!1,SHOW_CHAT_PROMPTS:!1,SHOW_HELP_BUTTON:!1,SHOW_LOGBOOK_BUTTON:!1,SHOW_MICROPHONE_BUTTON:!1,SHOW_SETTINGS_BUTTON:!1,SHOW_SNAP_BUTTON:!1,SHOW_VOICE_BUTTON:!1,STRIPE_CUSTOMER_PORTAL:"",STRIPE_PRICE_ID:"",STRIPE_PUBLIC_KEY:"",STRIPE_SOURCE:"",STRIPE_TRIAL_PERIOD_DAYS:0,SUBSCRIPTION_NEEDED:!1,THEME_WELCOME:void 0,USER_PREFIX:void 0,WELCOME_STATUS_PROMPT:"",SHOW_SEND_BUTTON_TEXT:!1,SHOW_SAVE_BUTTON_TEXT:!1,FORM_BACKGROUND_IMAGE_URL:void 0,AUTO_TRANSLATE:!0,FORCE_LANGUAGE:void 0,TRANSLATIONS:void 0,LOGIN_WELCOME_TEXT:void 0,LOGIN_HIDE_WELCOME:!1,LOGIN_LOGO_URL:void 0,HIDE_CHAT_ADD_FILE_BUTTON:!1,FORM_ACCEPT_MARKDOWN:void 0,RESTART_AUDIO_ON_TAKE_PHOTO:!1,ENABLE_STATE_CACHE:!1,SESSION_CACHE_TTL:864e5,USER_INFO_CACHE_TTL:36e5,APPS_CACHE_TTL:3e5,OPTIMISTIC_CACHE_LOAD:!0,VALIDATE_CACHE_IN_BACKGROUND:!0,SHOW_VALIDATION_INDICATOR:!1,CACHE_FAILURE_MODE:"lenient"};const O=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(T);function E(_){return O[_]}function A(_={}){for(const[O,E]of Object.entries(_))void 0!==E&&(T[O]=E);void 0!==_.TRANSLATIONS&&(globalThis.__CODICENT_REINIT_I18N__=!0)}export{_ as AppConfig,E as getConfigValue,A as initCodicentApp};
@@ -1 +1 @@
1
- {"version":3,"file":"useCodicentApp.d.ts","sourceRoot":"","s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,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,qBAAqB,CAAC;IAC7B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED,eAAO,MAAM,cAAc,wCAAyC,qBAAqB,KA+KlF,gBACN,CAAC"}
@@ -1 +1 @@
1
- import{useRef as e,useState as t,useCallback as n,useMemo as r,useEffect as s}from"react";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import{createAppStateMachine as o}from"../utils/appState.js";import"../_virtual/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"../utils/cacheManager.js";import{useAudioRecorder as i}from"./useAudioRecorder.js";import c from"./useAuthState.js";import a from"./useRealtimeVoiceAI.js";import u from"./useTools.js";import{getConfigValue as l}from"../config/index.js";const m=({auth0:m,toolsConfig:p,authOptions:d})=>{const h=c(m,d),g=e(o(h.codicentService,(()=>{}))),[A,f]=t(),{service:v,context:k}=g.current,{nickname:j,name:w,error:y,errorType:b,selectedApp:x}=k,C=n(((e,t)=>{const n=e.get("file").name;v.uploadFile(n,e).then((e=>{v.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[v]),S=i(C),[T,_]=t(),[I,N]=t(),[R,M]=t(!1),O=r((()=>new Audio("./notification.mp3")),[]),E=n((()=>M(!0)),[]),J=u(v,_,N,O,T,E,p),L=r((()=>l("REALTIME_VOICE_API_KEY")||""),[]),B=a(v,L,J);s((()=>{R&&(B?.disconnectConversation(),M(!1))}),[R,B]),s((()=>{h.isAuthenticated&&h.user&&h.accessToken&&g.current.updateContext({isAuthenticated:h.isAuthenticated,user:{sub:h.user.sub,email:h.user.email},accessToken:h.accessToken})}),[h.isAuthenticated,h.user,h.accessToken]);const U=e(h.isAuthenticated);s((()=>{const e=!0===U.current,t=!0===h.isAuthenticated;e&&!t&&g.current.logout(),U.current=h.isAuthenticated}),[h.isAuthenticated]),s((()=>g.current.updateContext({nickname:h.nickname})),[h.nickname]),s((()=>{g.current.update();let e,t=g.current.getCurrentStateName();f(g.current.getCurrentStateName()),JSON.stringify(g.current.context);let n=!1;const r=s=>setInterval((()=>{const s=g.current.getCurrentStateName();if("hasAccess"===s&&!n)return console.log("🎯 Reached stable state - switching to slower polling (1000ms)"),n=!0,clearInterval(e),void(e=r(1e3));if("hasAccess"!==s&&n)return console.log("🚨 Left stable state - switching to fast polling (200ms)"),n=!1,clearInterval(e),void(e=r(200));const o=JSON.stringify(g.current.context);g.current.update();const i=JSON.stringify(g.current.context),c=g.current.getCurrentStateName();c===t&&o===i||(f(c),t=c)}),s);return e=r(200),()=>clearInterval(e)}),[]);const V=n((e=>e.replace("{nickname}",j||"unknown").replace("{token}",encodeURIComponent(h.accessToken||"unknown")).replace("{app}",x||"unknown")),[j,h.accessToken,x]),$=n((e=>{g.current.updateContext({isAnonymous:e})}),[]),F=n((()=>g.current.isBusy()),[]);return r((()=>({audio:S,auth:h,currentStateName:A,stateMachine:g.current,service:v,context:k,state:A,nickname:j,name:w,error:y,errorType:b,fixAppUrl:V,setAnonymous:$,allStates:g.current.allStates,isBusy:F,voice:B,html:T,setHtml:_,script:I})),[A,j,w,y,b,T,I,h.isAuthenticated,h.isLoading,S.isRecording,B?.isConnected,V,$,F])};export{m as useCodicentApp};
1
+ import{useRef as e,useState as t,useCallback as n,useMemo as r,useEffect as s}from"react";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import{createAppStateMachine as o}from"../utils/appState.js";import"../_virtual/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"../utils/cacheManager.js";import{useAudioRecorder as i}from"./useAudioRecorder.js";import a from"./useAuthState.js";import c from"./useRealtimeVoiceAI.js";import u from"./useTools.js";const l=({auth0:l,toolsConfig:m,authOptions:p})=>{const d=a(l,p),h=e(o(d.codicentService,(()=>{}))),[g,v]=t(),{service:A,context:f}=h.current,{nickname:k,name:w,error:j,errorType:y,selectedApp:b}=f,S=n(((e,t)=>{const n=e.get("file").name;A.uploadFile(n,e).then((e=>{A.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[A]),x=i(S),[C,T]=t(),[N,_]=t(),[I,R]=t(!1),M=r((()=>new Audio("./notification.mp3")),[]),O=n((()=>R(!0)),[]),J=u(A,T,_,M,C,O,m),B=c(A,J);s((()=>{I&&(B?.disconnectConversation(),R(!1))}),[I,B]),s((()=>{d.isAuthenticated&&d.user&&d.accessToken&&h.current.updateContext({isAuthenticated:d.isAuthenticated,user:{sub:d.user.sub,email:d.user.email},accessToken:d.accessToken})}),[d.isAuthenticated,d.user,d.accessToken]);const L=e(d.isAuthenticated);s((()=>{const e=!0===L.current,t=!0===d.isAuthenticated;e&&!t&&h.current.logout(),L.current=d.isAuthenticated}),[d.isAuthenticated]),s((()=>h.current.updateContext({nickname:d.nickname})),[d.nickname]),s((()=>{h.current.update();let e,t=h.current.getCurrentStateName();v(h.current.getCurrentStateName()),JSON.stringify(h.current.context);let n=!1;const r=s=>setInterval((()=>{const s=h.current.getCurrentStateName();if("hasAccess"===s&&!n)return console.log("🎯 Reached stable state - switching to slower polling (1000ms)"),n=!0,clearInterval(e),void(e=r(1e3));if("hasAccess"!==s&&n)return console.log("🚨 Left stable state - switching to fast polling (200ms)"),n=!1,clearInterval(e),void(e=r(200));const o=JSON.stringify(h.current.context);h.current.update();const i=JSON.stringify(h.current.context),a=h.current.getCurrentStateName();a===t&&o===i||(v(a),t=a)}),s);return e=r(200),()=>clearInterval(e)}),[]);const U=n((e=>e.replace("{nickname}",k||"unknown").replace("{token}",encodeURIComponent(d.accessToken||"unknown")).replace("{app}",b||"unknown")),[k,d.accessToken,b]),$=n((e=>{h.current.updateContext({isAnonymous:e})}),[]),F=n((()=>h.current.isBusy()),[]);return r((()=>({audio:x,auth:d,currentStateName:g,stateMachine:h.current,service:A,context:f,state:g,nickname:k,name:w,error:j,errorType:y,fixAppUrl:U,setAnonymous:$,allStates:h.current.allStates,isBusy:F,voice:B,html:C,setHtml:T,script:N})),[g,k,w,j,y,C,N,d.isAuthenticated,d.isLoading,x.isRecording,B?.isConnected,U,$,F])};export{l as useCodicentApp};
@@ -50,7 +50,7 @@ export interface RealtimeVoice {
50
50
  updateInstructions: (instructions: string) => void;
51
51
  setLanguage: (language: string) => void;
52
52
  }
53
- declare const useRealtimeVoiceAI: (codicentService: CodicentService, apiKey: string, tools: {
53
+ declare const useRealtimeVoiceAI: (codicentService: CodicentService, tools: {
54
54
  definition: ToolDefinitionType;
55
55
  handler: Function;
56
56
  }[], voice?: string, provider?: string) => RealtimeVoice | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useRealtimeVoiceAI.d.ts","sourceRoot":"","sources":["../../../src/hooks/useRealtimeVoiceAI.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAK/E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE;QACV,KAAK,CAAC,EAAE,UA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;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,EAAE,UACtD,MAAM,aACH,MAAM,KAChB,aAAa,GAAG,SAysBlB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1 +1 @@
1
- import{useRef as e,useState as t,useCallback as n,useEffect as r,useMemo as o}from"react";import{WavRenderer as a}from"../utils/wav_renderer.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import{WavStreamPlayer as s}from"../lib/wavtools/lib/wav_stream_player.js";import{WavRecorder as i}from"../lib/wavtools/lib/wav_recorder.js";import{getConfigValue as c}from"../config/index.js";const l=(l,u,d,p,m)=>{const f=!!c("APP_CONFIG"),g=!!c("APP_BUTTONS");f||console.warn("APP_CONFIG is not set. Voice AI will not be available."),g||console.warn("APP_BUTTONS is not set. Voice AI will not be available.");const y=c("APP_CONFIG"),_=c("APP_BUTTONS");c("API_BASE_URL").replace(/\/$/,""),c("USE_REALTIME_SESSION_ENDPOINT"),c("REALTIME_SESSION_ENDPOINT");const w=p||c("REALTIME_VOICE_MODEL")||"alloy",h=m||c("REALTIME_VOICE_PROVIDER")||"openai",S=["alloy","shimmer","echo","verse","nova","fable","onyx"],v=S.includes(w)?w:"alloy";w!==v&&console.warn(`[codicent-app-sdk] Voice "${w}" is not supported in the current SDK version. Supported voices: ${S.join(", ")}. Falling back to "${v}".`);const O=e(new i({sampleRate:24e3})),I=e(new s({sampleRate:24e3})),T=e(null),N=e(null),E=e(null),C=e(null),A=e(!1),R=e(null),b=e(null),P=e(null),D=e((new Date).toISOString()),[L,x]=t([]),[F,J]=t([]),[M,V]=t(!1),[$,k]=t(!1),[U,j]=t(!1),[B,z]=t(!1),G=e(0),q=e(0),[W,H]=t(""),[K,Q]=t("en-US"),X=e(new Map),Y=e(null),[Z,ee]=t((()=>f&&g&&_&&y&&y.apps&&y.apps[_]?y.apps[_].voiceInstructions||y.REALTIME_VOICE_INSTRUCTIONS||"":y&&y.REALTIME_VOICE_INSTRUCTIONS||"")),te=n((e=>{const t=D.current,n=new Date(t).valueOf(),r=new Date(e).valueOf()-n,o=Math.floor(r/10)%100,a=Math.floor(r/1e3)%60,s=e=>{let t=e+"";for(;t.length<2;)t="0"+t;return t};return`${s(Math.floor(r/6e4)%60)}:${s(a)}.${s(o)}`}),[]),ne=n((async()=>{try{D.current=(new Date).toISOString(),V(!0),J([]),x([]),X.current.clear();const e=await l.getRealtimeSessionToken(v,h);if(!e)throw new Error("No ephemeral key returned from session endpoint");const t=new RTCPeerConnection;T.current=t,E.current||(E.current=new Audio,E.current.autoplay=!0),t.ontrack=e=>{E.current&&e.streams[0]&&(E.current.srcObject=e.streams[0])};const n=await navigator.mediaDevices.getUserMedia({audio:!0});C.current=n;const r=n.getTracks()[0];t.addTrack(r,n);const o=t.createDataChannel("oai-events");N.current=o,o.addEventListener("message",(e=>{try{const t=JSON.parse(e.data);if("session.created"===t.type);else if("conversation.item.created"===t.type)x((e=>[...e,t.item]));else if("conversation.item.input_audio_transcription.completed"===t.type)x((e=>{const n=[...e],r=n.findIndex((e=>e.id===t.item_id));return-1!==r&&n[r].formatted&&(n[r].formatted.transcript=t.transcript),n}));else if("response.audio_transcript.delta"===t.type);else if("response.audio_transcript.done"===t.type);else if("response.output_item.added"===t.type){const e=t.item;"function_call"===e?.type&&(console.log("[Voice AI] Function call initiated:",e.name),X.current.set(e.id,{name:e.name||"",arguments:"",call_id:e.call_id||e.id}))}else if("response.function_call_arguments.delta"===t.type){const e=t.item_id,n=t.delta,r=X.current.get(e);r&&n&&(r.arguments+=n,X.current.set(e,r))}else if("response.function_call_arguments.done"===t.type){const e=t.item_id,n=X.current.get(e);if(n){console.log(`[Voice AI] Executing tool: ${n.name}`);const t=d.find((e=>e.definition.name===n.name));if(t){let e={};try{e=n.arguments?JSON.parse(n.arguments):{}}catch(t){console.error("[Voice AI] Failed to parse tool arguments:",t),e={}}Promise.resolve(t.handler(e)).then((e=>{console.log(`[Voice AI] Tool ${n.name} completed:`,e),o&&"open"===o.readyState&&(o.send(JSON.stringify({type:"conversation.item.create",item:{type:"function_call_output",call_id:n.call_id,output:JSON.stringify(e)}})),o.send(JSON.stringify({type:"response.create"})))})).catch((e=>{console.error(`[Voice AI] Tool ${n.name} failed:`,e),o&&"open"===o.readyState&&(o.send(JSON.stringify({type:"conversation.item.create",item:{type:"function_call_output",call_id:n.call_id,output:JSON.stringify({error:e.message||"Tool execution failed"})}})),o.send(JSON.stringify({type:"response.create"})))}))}else console.error(`[Voice AI] Tool not found: ${n.name}`);X.current.delete(e)}}else"error"===t.type&&console.error("Server error:",t.error)}catch(t){console.warn("Invalid message:",e.data)}})),o.onopen=()=>{console.log("Data channel opened, configuring session");const e=Y.current||Z;Y.current=null,console.log("[Voice AI] Sending session.update with instructions length:",e.length,"preview:",e.substring(0,100));const t="azure"===h.toLowerCase();o.send(JSON.stringify({type:"session.update",session:{...t?{type:"realtime"}:{},instructions:e.replace("{{name}}",W).replace("{{language}}",K).replace("{{time}}",(new Date).toISOString()),...t?{}:{modalities:["text","audio"]},input_audio_transcription:{model:"whisper-1"},turn_detection:{type:"server_vad",threshold:.5,prefix_padding_ms:300,silence_duration_ms:500},voice:v,temperature:.8,max_response_output_tokens:4096,...t?{}:{input_audio_format:"pcm16",output_audio_format:"pcm16"},tools:d.map((e=>({type:"function",...e.definition})))}})),k(!0)},o.onclose=()=>{console.log("Data channel closed"),k(!1)};const a=await t.createOffer();await t.setLocalDescription(a);let s="gpt-4o-realtime-preview",i=null;try{const e=c("REALTIME_CONFIG_ENDPOINT"),t="azure"===h.toLowerCase();if(e||t){const e=await l.getRealtimeConfig(h);e&&e.model&&(s=e.model),e&&e.url&&(i=e.url)}}catch(e){console.warn("Failed to fetch realtime config, using default model:",e)}h.toLowerCase();const u=i??`https://api.openai.com/v1/realtime?model=${s}`,p={Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"},m=await fetch(u,{method:"POST",body:a.sdp,headers:p});if(!m.ok)throw new Error(`Failed to get SDP answer: ${m.statusText}`);const f={type:"answer",sdp:await m.text()};await t.setRemoteDescription(f),j(!1);const g=O.current,y=I.current;await g.begin(),await y.connect()}catch(e){throw console.error("[codicent-app-sdk] Failed to establish WebRTC connection:",e),V(!1),e}}),[l,v,Z,W,K,d]),re=n((async()=>{V(!1),k(!1),J([]),x([]),X.current.clear(),Y.current=null,N.current&&(N.current.close(),N.current=null),T.current&&(T.current.close(),T.current=null),C.current&&(C.current.getTracks().forEach((e=>e.stop())),C.current=null),E.current&&(E.current.pause(),E.current.srcObject=null);const e=O.current;await e.end();const t=I.current;await t.interrupt()}),[]),oe=n((async e=>{const t=N.current;t&&"open"===t.readyState&&t.send(JSON.stringify({type:"conversation.item.delete",item_id:e}))}),[]),ae=n((async()=>{z(!0);const e=N.current;e&&"open"===e.readyState&&e.send(JSON.stringify({type:"input_audio_buffer.commit"}))}),[]),se=n((async()=>{z(!1);const e=N.current;e&&"open"===e.readyState&&e.send(JSON.stringify({type:"response.create"}))}),[]),ie=n((async e=>{const t=N.current;t&&"open"===t.readyState&&t.send(JSON.stringify({type:"session.update",session:{turn_detection:"none"===e?null:{type:"server_vad"}}})),j("none"===e)}),[]);r((()=>{if(W&&$){const e=N.current;e&&"open"===e.readyState&&e.send(JSON.stringify({type:"session.update",session:{..."azure"===h.toLowerCase()?{type:"realtime"}:{},instructions:Z.replace("{{name}}",W).replace("{{language}}",K).replace("{{time}}",(new Date).toISOString())}}))}}),[Z,W,K,$]),r((()=>{let e=!0;const t=O.current,n=R.current;let r=null;const o=I.current,s=b.current;let i=null;const c=()=>{if(e){if(n&&(n.width&&n.height||(n.width=n.offsetWidth,n.height=n.offsetHeight),r=r||n.getContext("2d"),r)){r.clearRect(0,0,n.width,n.height);const e=t.recording?t.getFrequencies("voice"):{values:new Float32Array([0])},o=1-Math.max(...e.values);G.current=o,a.drawCircularBars(n,r,e.values,"#0099ff",20,0,8)}if(s&&(s.width&&s.height||(s.width=s.offsetWidth,s.height=s.offsetHeight),i=i||s.getContext("2d"),i)){i.clearRect(0,0,s.width,s.height);const e=o.analyser?o.getFrequencies("voice"):{values:new Float32Array([0])},t=1-Math.max(...e.values);q.current=t,a.drawCircularBars(s,i,e.values,"#009900",20,0,8)}window.requestAnimationFrame(c)}};return c(),()=>{e=!1}}),[]),r((()=>{!A.current&&d&&Z&&(A.current=!0)}),[d,Z]);const ce=n((e=>{ee(e);const t=N.current;if(t&&"open"===t.readyState){const n=e.replace("{{name}}",W).replace("{{language}}",K).replace("{{time}}",(new Date).toISOString());t.send(JSON.stringify({type:"session.update",session:{instructions:n}}))}else Y.current=e}),[W,K]);return o((()=>{if(f&&g)return{items:L,realtimeEvents:F,isConnected:M,isSessionReady:$,canPushToTalk:U,isRecording:B,clientCanvasRef:R,serverCanvasRef:b,eventsScrollRef:P,formatTime:te,connectConversation:ne,disconnectConversation:re,deleteConversationItem:oe,startRecording:ae,stopRecording:se,changeTurnEndType:ie,getRecorderLevel:()=>G.current,getStreamLevel:()=>q.current,setUsername:H,updateInstructions:ce,setLanguage:Q}}),[f,g,L,F,M,$,U,B,R,b,P])};export{l as default};
1
+ import{useRef as e,useState as t,useCallback as n,useEffect as r,useMemo as o}from"react";import{WavRenderer as a}from"../utils/wav_renderer.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import{WavStreamPlayer as s}from"../lib/wavtools/lib/wav_stream_player.js";import{WavRecorder as i}from"../lib/wavtools/lib/wav_recorder.js";import{getConfigValue as c}from"../config/index.js";const l=(l,u,d,p)=>{const m=!!c("APP_CONFIG"),f=!!c("APP_BUTTONS");m||console.warn("APP_CONFIG is not set. Voice AI will not be available."),f||console.warn("APP_BUTTONS is not set. Voice AI will not be available.");const g=c("APP_CONFIG"),y=c("APP_BUTTONS");c("API_BASE_URL").replace(/\/$/,""),c("USE_REALTIME_SESSION_ENDPOINT"),c("REALTIME_SESSION_ENDPOINT");const _=d||c("REALTIME_VOICE_MODEL")||"alloy",w=p||c("REALTIME_VOICE_PROVIDER")||"openai",h=["alloy","shimmer","echo","verse","nova","fable","onyx"],S=h.includes(_)?_:"alloy";_!==S&&console.warn(`[codicent-app-sdk] Voice "${_}" is not supported in the current SDK version. Supported voices: ${h.join(", ")}. Falling back to "${S}".`);const v=e(new i({sampleRate:24e3})),O=e(new s({sampleRate:24e3})),I=e(null),T=e(null),N=e(null),E=e(null),C=e(!1),A=e(null),R=e(null),b=e(null),P=e((new Date).toISOString()),[D,L]=t([]),[x,F]=t([]),[J,M]=t(!1),[V,$]=t(!1),[k,U]=t(!1),[j,B]=t(!1),z=e(0),G=e(0),[q,W]=t(""),[H,K]=t("en-US"),Q=e(new Map),X=e(null),[Y,Z]=t((()=>m&&f&&y&&g&&g.apps&&g.apps[y]?g.apps[y].voiceInstructions||g.REALTIME_VOICE_INSTRUCTIONS||"":g&&g.REALTIME_VOICE_INSTRUCTIONS||"")),ee=n((e=>{const t=P.current,n=new Date(t).valueOf(),r=new Date(e).valueOf()-n,o=Math.floor(r/10)%100,a=Math.floor(r/1e3)%60,s=e=>{let t=e+"";for(;t.length<2;)t="0"+t;return t};return`${s(Math.floor(r/6e4)%60)}:${s(a)}.${s(o)}`}),[]),te=n((async()=>{try{P.current=(new Date).toISOString(),M(!0),F([]),L([]),Q.current.clear();const e=await l.getRealtimeSessionToken(S,w);if(!e)throw new Error("No ephemeral key returned from session endpoint");const t=new RTCPeerConnection;I.current=t,N.current||(N.current=new Audio,N.current.autoplay=!0),t.ontrack=e=>{N.current&&e.streams[0]&&(N.current.srcObject=e.streams[0])};const n=await navigator.mediaDevices.getUserMedia({audio:!0});E.current=n;const r=n.getTracks()[0];t.addTrack(r,n);const o=t.createDataChannel("oai-events");T.current=o,o.addEventListener("message",(e=>{try{const t=JSON.parse(e.data);if("session.created"===t.type);else if("conversation.item.created"===t.type)L((e=>[...e,t.item]));else if("conversation.item.input_audio_transcription.completed"===t.type)L((e=>{const n=[...e],r=n.findIndex((e=>e.id===t.item_id));return-1!==r&&n[r].formatted&&(n[r].formatted.transcript=t.transcript),n}));else if("response.audio_transcript.delta"===t.type);else if("response.audio_transcript.done"===t.type);else if("response.output_item.added"===t.type){const e=t.item;"function_call"===e?.type&&(console.log("[Voice AI] Function call initiated:",e.name),Q.current.set(e.id,{name:e.name||"",arguments:"",call_id:e.call_id||e.id}))}else if("response.function_call_arguments.delta"===t.type){const e=t.item_id,n=t.delta,r=Q.current.get(e);r&&n&&(r.arguments+=n,Q.current.set(e,r))}else if("response.function_call_arguments.done"===t.type){const e=t.item_id,n=Q.current.get(e);if(n){console.log(`[Voice AI] Executing tool: ${n.name}`);const t=u.find((e=>e.definition.name===n.name));if(t){let e={};try{e=n.arguments?JSON.parse(n.arguments):{}}catch(t){console.error("[Voice AI] Failed to parse tool arguments:",t),e={}}Promise.resolve(t.handler(e)).then((e=>{console.log(`[Voice AI] Tool ${n.name} completed:`,e),o&&"open"===o.readyState&&(o.send(JSON.stringify({type:"conversation.item.create",item:{type:"function_call_output",call_id:n.call_id,output:JSON.stringify(e)}})),o.send(JSON.stringify({type:"response.create"})))})).catch((e=>{console.error(`[Voice AI] Tool ${n.name} failed:`,e),o&&"open"===o.readyState&&(o.send(JSON.stringify({type:"conversation.item.create",item:{type:"function_call_output",call_id:n.call_id,output:JSON.stringify({error:e.message||"Tool execution failed"})}})),o.send(JSON.stringify({type:"response.create"})))}))}else console.error(`[Voice AI] Tool not found: ${n.name}`);Q.current.delete(e)}}else"error"===t.type&&console.error("Server error:",t.error)}catch(t){console.warn("Invalid message:",e.data)}})),o.onopen=()=>{console.log("Data channel opened, configuring session");const e=X.current||Y;X.current=null,console.log("[Voice AI] Sending session.update with instructions length:",e.length,"preview:",e.substring(0,100));const t="azure"===w.toLowerCase();o.send(JSON.stringify({type:"session.update",session:{...t?{type:"realtime"}:{},instructions:e.replace("{{name}}",q).replace("{{language}}",H).replace("{{time}}",(new Date).toISOString()),...t?{}:{modalities:["text","audio"]},input_audio_transcription:{model:"whisper-1"},turn_detection:{type:"server_vad",threshold:.5,prefix_padding_ms:300,silence_duration_ms:500},voice:S,temperature:.8,max_response_output_tokens:4096,...t?{}:{input_audio_format:"pcm16",output_audio_format:"pcm16"},tools:u.map((e=>({type:"function",...e.definition})))}})),$(!0)},o.onclose=()=>{console.log("Data channel closed"),$(!1)};const a=await t.createOffer();await t.setLocalDescription(a);let s="gpt-4o-realtime-preview",i=null;try{const e=c("REALTIME_CONFIG_ENDPOINT"),t="azure"===w.toLowerCase();if(e||t){const e=await l.getRealtimeConfig(w);e&&e.model&&(s=e.model),e&&e.url&&(i=e.url)}}catch(e){console.warn("Failed to fetch realtime config, using default model:",e)}w.toLowerCase();const d=i??`https://api.openai.com/v1/realtime?model=${s}`,p={Authorization:`Bearer ${e}`,"Content-Type":"application/sdp"},m=await fetch(d,{method:"POST",body:a.sdp,headers:p});if(!m.ok)throw new Error(`Failed to get SDP answer: ${m.statusText}`);const f={type:"answer",sdp:await m.text()};await t.setRemoteDescription(f),U(!1);const g=v.current,y=O.current;await g.begin(),await y.connect()}catch(e){throw console.error("[codicent-app-sdk] Failed to establish WebRTC connection:",e),M(!1),e}}),[l,S,Y,q,H,u]),ne=n((async()=>{M(!1),$(!1),F([]),L([]),Q.current.clear(),X.current=null,T.current&&(T.current.close(),T.current=null),I.current&&(I.current.close(),I.current=null),E.current&&(E.current.getTracks().forEach((e=>e.stop())),E.current=null),N.current&&(N.current.pause(),N.current.srcObject=null);const e=v.current;await e.end();const t=O.current;await t.interrupt()}),[]),re=n((async e=>{const t=T.current;t&&"open"===t.readyState&&t.send(JSON.stringify({type:"conversation.item.delete",item_id:e}))}),[]),oe=n((async()=>{B(!0);const e=T.current;e&&"open"===e.readyState&&e.send(JSON.stringify({type:"input_audio_buffer.commit"}))}),[]),ae=n((async()=>{B(!1);const e=T.current;e&&"open"===e.readyState&&e.send(JSON.stringify({type:"response.create"}))}),[]),se=n((async e=>{const t=T.current;t&&"open"===t.readyState&&t.send(JSON.stringify({type:"session.update",session:{turn_detection:"none"===e?null:{type:"server_vad"}}})),U("none"===e)}),[]);r((()=>{if(q&&V){const e=T.current;e&&"open"===e.readyState&&e.send(JSON.stringify({type:"session.update",session:{..."azure"===w.toLowerCase()?{type:"realtime"}:{},instructions:Y.replace("{{name}}",q).replace("{{language}}",H).replace("{{time}}",(new Date).toISOString())}}))}}),[Y,q,H,V]),r((()=>{let e=!0;const t=v.current,n=A.current;let r=null;const o=O.current,s=R.current;let i=null;const c=()=>{if(e){if(n&&(n.width&&n.height||(n.width=n.offsetWidth,n.height=n.offsetHeight),r=r||n.getContext("2d"),r)){r.clearRect(0,0,n.width,n.height);const e=t.recording?t.getFrequencies("voice"):{values:new Float32Array([0])},o=1-Math.max(...e.values);z.current=o,a.drawCircularBars(n,r,e.values,"#0099ff",20,0,8)}if(s&&(s.width&&s.height||(s.width=s.offsetWidth,s.height=s.offsetHeight),i=i||s.getContext("2d"),i)){i.clearRect(0,0,s.width,s.height);const e=o.analyser?o.getFrequencies("voice"):{values:new Float32Array([0])},t=1-Math.max(...e.values);G.current=t,a.drawCircularBars(s,i,e.values,"#009900",20,0,8)}window.requestAnimationFrame(c)}};return c(),()=>{e=!1}}),[]),r((()=>{!C.current&&u&&Y&&(C.current=!0)}),[u,Y]);const ie=n((e=>{Z(e);const t=T.current;if(t&&"open"===t.readyState){const n=e.replace("{{name}}",q).replace("{{language}}",H).replace("{{time}}",(new Date).toISOString());t.send(JSON.stringify({type:"session.update",session:{instructions:n}}))}else X.current=e}),[q,H]);return o((()=>{if(m&&f)return{items:D,realtimeEvents:x,isConnected:J,isSessionReady:V,canPushToTalk:k,isRecording:j,clientCanvasRef:A,serverCanvasRef:R,eventsScrollRef:b,formatTime:ee,connectConversation:te,disconnectConversation:ne,deleteConversationItem:re,startRecording:oe,stopRecording:ae,changeTurnEndType:se,getRecorderLevel:()=>z.current,getStreamLevel:()=>G.current,setUsername:W,updateInstructions:ie,setLanguage:K}}),[m,f,D,x,J,V,k,j,A,R,b])};export{l as default};
@@ -1 +1 @@
1
- {"version":3,"file":"codic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Content.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import"react";import"../_virtual/index.js";import"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";var o;let n="https://codicent.com/",a="https://pubsub.codicent.com/hub",s="-";const i=()=>"undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init,r=t=>{t&&"string"==typeof t?(n=t.endsWith("/")?t:t+"/",i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})):console.warn("Invalid base URL provided, using default")},c=t=>{t&&"string"==typeof t&&(a=t,i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a}))},h=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:s,baseUrl:n,signalRHost:a}),!0);let d=h();if(!d){const t=setInterval((()=>{d=h(),d&&clearInterval(t)}),100)}class l{constructor(o){this.createDataMessage=async(t,e,o)=>await window.Codicent.data.create({codicent:o||this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e,o,n,a,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:n,length:a,afterTimestamp:s,beforeTimestamp:i,dataFilters:r}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e,o)=>await window.Codicent.data.update({id:t,data:e,codicent:o||this.codicent}),this.deleteDataMessage=async(t,e)=>await window.Codicent.data.delete({id:t,codicent:e||this.codicent}),this.getSchema=async(t,e)=>{try{const e=await fetch(`${this.options.API_BASE_URL}api/GetSchema/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.options.APP_LOG_TOKEN}`,"Content-Type":"application/json"}});if(!e.ok){if(404===e.status)return null;throw new Error(`Failed to fetch schema: ${e.statusText}`)}const o=await e.text();return JSON.parse(o)}catch(e){return console.error(`Error fetching schema for tag ${t}:`,e),null}},this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const o=new e(t.content).content.split("\n"),n=o[0],a=o.slice(1).join("\n");return{id:t.id,title:n,content:a}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.generateApiToken=async(t,e)=>{const o=await fetch(`${n}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);return await o.text()},this.sendMessage=(t,e,o)=>window.Codicent.postMessage({message:`@${o||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,o)=>window.Codicent.getChatReply4({message:t,codicent:o||this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,a=void 0,s,i=0)=>{const r=await this.request(`${n}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:s||this.codicent,search:e,start:i,length:o})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a){const t=await this.getPublicFlow(a);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let n=[];const a=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:o});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(a)).forEach((t=>{n=n.concat(t)})),e)try{const t=await this.getPublicFlow(e);n=n.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return n=n.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),n.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),n},this.registerUser=async(t,e,o,s)=>{const i=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!i.ok)return"";const r=await i.text();return window.Codicent.init({token:r,baseUrl:n,signalRHost:a}),r},this.loginUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in user:",t),""}},this.loginMicrosoftUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in Microsoft user:",t),""}},this.registerMicrosoftUser=async(t,e,o,a)=>{const s=await fetch(`${n}app/RegisterMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${a}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";return await s.text()},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${n}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))))}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${n}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let a=await o.json();if(a){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}if(a){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}}}return a},this.getNickname=async()=>{try{const t=s.split(".")[1],e=atob(t),o=JSON.parse(e),a=o.sub||o.userId,i=await fetch(`${n}app/GetNickname?userId=${a}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!i.ok)throw 401===i.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${i.statusText}`);return await i.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${n}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);const a=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=a;return{nickname:t,email:s,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:a})=>{const s=await fetch(`${n}app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:a,description:""})});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${n}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${n}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.getMemberInfo=async(t,e)=>{const o=await fetch(`${n}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);return await o.json()},this.setToken=t=>{s=t,s&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})},this.getToken=()=>s,this.checkPurchaseStatus=async()=>{const t=await fetch(`${n}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=this.options.STRIPE_SOURCE,o=this.options.STRIPE_TRIAL_PERIOD_DAYS,a={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(a.source=e),o&&o>0&&(a.trialPeriodDays=o);const s=await fetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(a)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async e=>{const o=await t(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(e),{error:a}=await o.redirectToCheckout({sessionId:n});if(a)throw new Error(a.message)},this.getChatHistory=async t=>{const e=await fetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),o},this.getPublicFlow=async t=>{const e=await fetch(`${n}app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},a=await fetch(`${n}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!a.ok)throw new Error(`${a.statusText||"Failed to post log message!"}`);return(await a.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],o=atob(t),n=JSON.parse(o).nickname;if(!await this.addFollower(e,n))throw new Error("Failed to add follower: "+n)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return e}}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await this.request(`${n}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${n}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${n}app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const o=await fetch(`${n}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)return console.warn(`updateTodoStatus() => ${o.statusText}`),!1;return await o.json()},this.codicent="",this.options=o,r(o.API_BASE_URL),o.PUBSUB_URL&&c(o.PUBSUB_URL)}async request(t,e,o={}){const n={};o.headers&&o.headers.forEach((([t,e])=>{n[t]=e}));const a=await fetch(t,{...o,method:e,headers:n});if(!a.ok)throw 401===a.status&&this.handleUnauthorized(),new Error(`${a.statusText}`);return a}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${n}realtime/session?voice=${t}&provider=${e}`,a=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!a.ok)throw new Error(`Failed to fetch session token: ${a.statusText}`);const s=await a.json(),i=s.client_secret?.value??s.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${n}realtime/config?provider=${t}`,o=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`}});return o.ok?await o.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}o=l,l.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,l.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,l.downloadFile=async t=>{fetch(o.getFileUrl(t.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((e=>{const o=window.URL.createObjectURL(e),n=document.createElement("a");n.style.display="none",n.href=o,n.download=t.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},l.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let a={project:e,message:t};o&&(a.messageId=o);const i=await fetch(`${n}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(a)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},l.getMiniChatReply=async(t,e="codicent-mini",o,a=3e5,i=2e3,r)=>{const c={project:e,message:t};let h;o&&(c.messageId=o),r&&(c.previousResponseId=r);try{const t=await fetch(`${n}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(c)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(h=(await t.json()).promptMessageId,!h)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const d=Date.now();for(;Date.now()-d<a;)try{const t=await fetch(`${n}app/GetAi2ChatReplyStatus?promptMessageId=${h}`,{method:"GET",headers:[["Authorization",`Bearer ${s}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,i)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const o=await t.json(),a=o.content??o.content??"";return{content:a.replace(`@${e}`,"").replace("@codicent-mini","").trim(),responseId:o.responseId??void 0}}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},l.getTranslations=async(t,e,o="codicent-mini")=>{if(!s||"-"===s)return{translation:t};const a=await fetch(`${n}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${s}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!a.ok)throw a.status,new Error(`Failed to get translations: ${a.statusText}`);return await a.json()};export{l as CodicentService,r as setBaseUrl,c as setSignalRHost};
1
+ import{loadStripe as t}from"../node_modules/@stripe/stripe-js/dist/index.js";import e from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import"react";import"../_virtual/index.js";import"../config/index.js";import"../utils/cacheManager.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";var o;let n="https://codicent.com/",a="https://pubsub.codicent.com/hub",s="-";const i=()=>"undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init,r=t=>{t&&"string"==typeof t?(n=t.endsWith("/")?t:t+"/",i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})):console.warn("Invalid base URL provided, using default")},c=t=>{t&&"string"==typeof t&&(a=t,i()&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a}))},h=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:s,baseUrl:n,signalRHost:a}),!0);let d=h();if(!d){const t=setInterval((()=>{d=h(),d&&clearInterval(t)}),100)}class l{constructor(o){this.createDataMessage=async(t,e,o)=>await window.Codicent.data.create({codicent:o||this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e,o,n,a,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:n,length:a,afterTimestamp:s,beforeTimestamp:i,dataFilters:r}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e,o)=>await window.Codicent.data.update({id:t,data:e,codicent:o||this.codicent}),this.deleteDataMessage=async(t,e)=>await window.Codicent.data.delete({id:t,codicent:e||this.codicent}),this.getSchema=async(t,e)=>{try{const e=await fetch(`${this.options.API_BASE_URL}api/GetSchema/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.options.APP_LOG_TOKEN}`,"Content-Type":"application/json"}});if(!e.ok){if(404===e.status)return null;throw new Error(`Failed to fetch schema: ${e.statusText}`)}const o=await e.text();return JSON.parse(o)}catch(e){return console.error(`Error fetching schema for tag ${t}:`,e),null}},this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const o=new e(t.content).content.split("\n"),n=o[0],a=o.slice(1).join("\n");return{id:t.id,title:n,content:a}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.generateApiToken=async(t,e)=>{const o=await fetch(`${n}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);return await o.text()},this.sendMessage=(t,e,o)=>window.Codicent.postMessage({message:`@${o||this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e,o)=>window.Codicent.getChatReply4({message:t,codicent:o||this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,a=void 0,s,i=0)=>{const r=await this.request(`${n}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:s||this.codicent,search:e,start:i,length:o})});let c=await r.json();if(c.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a){const t=await this.getPublicFlow(a);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let n=[];const a=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:o});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(a)).forEach((t=>{n=n.concat(t)})),e)try{const t=await this.getPublicFlow(e);n=n.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return n=n.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),n.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),n},this.registerUser=async(t,e,o,s)=>{const i=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!i.ok)return"";const r=await i.text();return window.Codicent.init({token:r,baseUrl:n,signalRHost:a}),r},this.loginUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in user:",t),""}},this.loginMicrosoftUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status?null:401===o.status?(this.handleUnauthorized(),null):"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in Microsoft user:",t),""}},this.registerMicrosoftUser=async(t,e,o,a)=>{const s=await fetch(`${n}app/RegisterMicrosoftUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${a}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";return await s.text()},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${n}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))))}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${n}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let a=await o.json();if(a){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}if(a){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}}}return a},this.getNickname=async()=>{try{const t=s.split(".")[1],e=atob(t),o=JSON.parse(e),a=o.sub||o.userId,i=await fetch(`${n}app/GetNickname?userId=${a}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!i.ok)throw 401===i.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${i.statusText}`);return await i.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${n}app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);const a=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=a;return{nickname:t,email:s,name:r,picture:i,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:a})=>{const s=await fetch(`${n}app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:a,description:""})});if(!s.ok)throw s.status,new Error(`${s.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${n}app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${n}app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.getMemberInfo=async(t,e)=>{const o=await fetch(`${n}app/GetMemberInfo?projectNickname=${encodeURIComponent(t)}&memberNickname=${encodeURIComponent(e)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${o.statusText}`);return await o.json()},this.setToken=t=>{s=t,s&&window.Codicent.init({token:s,baseUrl:n,signalRHost:a})},this.getToken=()=>s,this.checkPurchaseStatus=async()=>{const t=await fetch(`${n}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=this.options.STRIPE_SOURCE,o=this.options.STRIPE_TRIAL_PERIOD_DAYS,a={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(a.source=e),o&&o>0&&(a.trialPeriodDays=o);const s=await fetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(a)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async e=>{const o=await t(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(e),{error:a}=await o.redirectToCheckout({sessionId:n});if(a)throw new Error(a.message)},this.getChatHistory=async t=>{const e=await fetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!(t.content.includes("#function_result")||t.content.includes("#finish_reason_function_call")||t.content.includes("#function_results_batch")||t.content.includes("#finish_reason_tool_calls_batch")))),o},this.getPublicFlow=async t=>{const e=await fetch(`${n}app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},a=await fetch(`${n}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!a.ok)throw new Error(`${a.statusText||"Failed to post log message!"}`);return(await a.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],o=atob(t),n=JSON.parse(o).nickname;if(!await this.addFollower(e,n))throw new Error("Failed to add follower: "+n)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return e}}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await this.request(`${n}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${n}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${n}app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const o=await fetch(`${n}app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)return console.warn(`updateTodoStatus() => ${o.statusText}`),!1;return await o.json()},this.codicent="",this.options=o,r(o.API_BASE_URL),o.PUBSUB_URL&&c(o.PUBSUB_URL)}async request(t,e,o={}){const n={};o.headers&&o.headers.forEach((([t,e])=>{n[t]=e}));const a=await fetch(t,{...o,method:e,headers:n});if(!a.ok)throw 401===a.status&&this.handleUnauthorized(),new Error(`${a.statusText}`);return a}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${n}realtime/session?voice=${t}&provider=${e}`,a=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!a.ok)throw new Error(`Failed to fetch session token: ${a.statusText}`);const s=await a.json(),i=s.client_secret?.value??s.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${n}realtime/config?provider=${t}`,o=await fetch(e,{method:"GET",headers:{Authorization:`Bearer ${this.getToken()}`}});return o.ok?await o.json():null}catch(t){return console.warn("Failed to fetch realtime config:",t),null}}}o=l,l.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,l.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,l.downloadFile=async t=>{fetch(o.getFileUrl(t.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((e=>{const o=window.URL.createObjectURL(e),n=document.createElement("a");n.style.display="none",n.href=o,n.download=t.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},l.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let a={project:e,message:t};o&&(a.messageId=o);const i=await fetch(`${n}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(a)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},l.getMiniChatReply=async(t,e="codicent-mini",o,a=3e5,i=2e3,r)=>{const c={project:e,message:t};let h;o&&(c.messageId=o),r&&(c.previousResponseId=r);try{const t=await fetch(`${n}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${s}`]],body:JSON.stringify(c)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(h=(await t.json()).promptMessageId,!h)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const d=Date.now();for(;Date.now()-d<a;)try{const t=await fetch(`${n}app/GetAi2ChatReplyStatus?promptMessageId=${h}`,{method:"GET",headers:[["Authorization",`Bearer ${s}`]]});if(202===t.status){await new Promise((t=>setTimeout(t,i)));continue}if(!t.ok)return void console.error(`Error polling AI chat status: ${t.status}`);const o=await t.json(),a=o.content??o.content??"";return{content:a.replace(`@${e}`,"").replace("@codicent-mini","").trim(),responseId:o.responseId??void 0}}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},l.getTranslations=async(t,e,o="codicent-mini")=>{if(!s||"-"===s)return{translation:t};const a=await fetch(`${n}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${s}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!a.ok)throw a.status,new Error(`Failed to get translations: ${a.statusText}`);return await a.json()};export{l as CodicentService,r as setBaseUrl,c as setSignalRHost};
@@ -20,6 +20,8 @@ export interface ButtonConfig {
20
20
  notClaim?: string;
21
21
  /** Optional subtitle for compound buttons */
22
22
  subtitle?: string;
23
+ /** Display order index — lower values appear first; buttons without index come last (alphabetical tiebreak) */
24
+ index?: number;
23
25
  /** Sub-buttons for multi-option buttons */
24
26
  options?: ButtonConfig[];
25
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,i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AC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;CACjB"}
package/dist/index.d.ts CHANGED
@@ -714,7 +714,7 @@ interface RealtimeVoice {
714
714
  updateInstructions: (instructions: string) => void;
715
715
  setLanguage: (language: string) => void;
716
716
  }
717
- declare const useRealtimeVoiceAI: (codicentService: CodicentService, apiKey: string, tools: {
717
+ declare const useRealtimeVoiceAI: (codicentService: CodicentService, tools: {
718
718
  definition: ToolDefinitionType;
719
719
  handler: Function;
720
720
  }[], voice?: string, provider?: string) => RealtimeVoice | undefined;
@@ -1117,7 +1117,6 @@ interface AppConfigOptions {
1117
1117
  MESSAGE_HIDE_BAR: boolean;
1118
1118
  MODULE_VOICE: boolean;
1119
1119
  PUBLIC_FLOW_CODICENT: undefined | string;
1120
- REALTIME_VOICE_API_KEY: string;
1121
1120
  REALTIME_VOICE_MODEL: string;
1122
1121
  REALTIME_VOICE_PROVIDER: string;
1123
1122
  USE_REALTIME_SESSION_ENDPOINT: boolean;
@@ -1195,6 +1194,8 @@ interface ButtonConfig {
1195
1194
  notClaim?: string;
1196
1195
  /** Optional subtitle for compound buttons */
1197
1196
  subtitle?: string;
1197
+ /** Display order index — lower values appear first; buttons without index come last (alphabetical tiebreak) */
1198
+ index?: number;
1198
1199
  /** Sub-buttons for multi-option buttons */
1199
1200
  options?: ButtonConfig[];
1200
1201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codicent-app-sdk",
3
- "version": "0.4.22",
3
+ "version": "0.4.25",
4
4
  "description": "SDK for building AI-powered applications with Codicent",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",