codicent-app-sdk 0.4.11 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/ListView.d.ts +4 -1
- package/dist/cjs/components/ListView.d.ts.map +1 -1
- package/dist/cjs/components/ListView.js +1 -1
- package/dist/cjs/components/MessageItem.d.ts.map +1 -1
- package/dist/cjs/components/MessageItem.js +1 -1
- package/dist/cjs/config/index.d.ts +1 -0
- package/dist/cjs/config/index.d.ts.map +1 -1
- package/dist/cjs/config/index.js +1 -1
- package/dist/cjs/hooks/useCodicentApp.d.ts.map +1 -1
- package/dist/cjs/hooks/useCodicentApp.js +1 -1
- package/dist/cjs/hooks/useTools.d.ts.map +1 -1
- package/dist/cjs/hooks/useTools.js +1 -1
- package/dist/cjs/pages/EnvFormPage.d.ts.map +1 -1
- package/dist/cjs/services/codicent.d.ts +6 -2
- package/dist/cjs/services/codicent.d.ts.map +1 -1
- package/dist/cjs/services/codicent.js +1 -1
- package/dist/esm/components/ListView.d.ts +4 -1
- package/dist/esm/components/ListView.d.ts.map +1 -1
- package/dist/esm/components/ListView.js +1 -1
- package/dist/esm/components/MessageItem.d.ts.map +1 -1
- package/dist/esm/components/MessageItem.js +1 -1
- package/dist/esm/config/index.d.ts +1 -0
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +1 -1
- package/dist/esm/hooks/useCodicentApp.d.ts.map +1 -1
- package/dist/esm/hooks/useCodicentApp.js +1 -1
- package/dist/esm/hooks/useTools.d.ts.map +1 -1
- package/dist/esm/hooks/useTools.js +1 -1
- package/dist/esm/pages/EnvFormPage.d.ts.map +1 -1
- package/dist/esm/services/codicent.d.ts +6 -2
- package/dist/esm/services/codicent.d.ts.map +1 -1
- package/dist/esm/services/codicent.js +1 -1
- package/dist/index.d.ts +11 -3
- package/package.json +1 -1
|
@@ -14,9 +14,11 @@ export interface ColumnDefinition {
|
|
|
14
14
|
hidden?: boolean;
|
|
15
15
|
hideOnMobile?: boolean;
|
|
16
16
|
maxWidth?: number;
|
|
17
|
-
type?: "file" | "checkbox" | "textarea" | undefined;
|
|
17
|
+
type?: "file" | "checkbox" | "textarea" | "enum" | undefined;
|
|
18
18
|
/** Number of rows for textarea type (default: 3) */
|
|
19
19
|
rows?: number;
|
|
20
|
+
/** Options for enum type columns */
|
|
21
|
+
enumOptions?: string[];
|
|
20
22
|
editable?: boolean;
|
|
21
23
|
filterable?: boolean;
|
|
22
24
|
/** Default sort direction for this column. If multiple columns have defaultSort, only the first one is used. */
|
|
@@ -33,6 +35,7 @@ export interface ListViewProps {
|
|
|
33
35
|
onEdit?: (item: Record<string, unknown>, index: number) => void;
|
|
34
36
|
onDelete?: (item: Record<string, unknown>, index: number) => void;
|
|
35
37
|
onToggleCheckbox?: (item: Record<string, unknown>, key: string | string[], newValue: boolean, index: number) => void;
|
|
38
|
+
onEnumChange?: (item: Record<string, unknown>, key: string | string[], newValue: string, index: number) => void;
|
|
36
39
|
onFilteredDataChange?: (filteredData: Record<string, unknown>[]) => void;
|
|
37
40
|
}
|
|
38
41
|
export declare const ListView: React.FC<ListViewProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/components/ListView.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAuC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/components/ListView.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAiB5D,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,kHAAkH;IAClH,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC;IAC1B,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;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AAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChH,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,IAAI,CAAC;CAC1E;AAID,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA4d5C,CAAC;;AAGF,wBAAoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@fluentui/react-components"),i=require("@fluentui/react-icons"),r=require("../services/codicent.js"),o=require("../hooks/useLocalization.js");const l=n.makeStyles({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"}}),a=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},s=({data:s,columns:c,canEdit:d,onEdit:p,onDelete:h,onToggleCheckbox:x,onFilteredDataChange:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("@fluentui/react-components"),i=require("@fluentui/react-icons"),r=require("../services/codicent.js"),o=require("../hooks/useLocalization.js");const l=n.makeStyles({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"}}),a=(e,t)=>{if("string"==typeof t)return e[t];for(const n of t)if(void 0!==e[n])return e[n]},s=({data:s,columns:c,canEdit:d,onEdit:p,onDelete:h,onToggleCheckbox:x,onEnumChange:u,onFilteredDataChange:m})=>{const f=l(),{visibleColumns:g,defaultSortIndex:y,defaultSortDirection:j}=t.useMemo((()=>{const e=s&&s.length>0?Array.from(new Set(s.flatMap((e=>Object.keys(e))))):[],t=(c||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}}),[s,c]),[b,w]=t.useState(y>=0?y:null),[k,C]=t.useState(j),[S,v]=t.useState(!1),[W,N]=t.useState({title:"",text:""}),[$,M]=t.useState({}),[A,O]=t.useState(0),{t:B}=o.default(),D=e=>e.title?B(e.title):Array.isArray(e.key)?e.key[0]:e.key,I=e=>{const t=[];return e.hideOnMobile&&t.push(f.hideOnMobile),t.join(" ")},T=e=>null==e||"string"==typeof e&&e.startsWith("[")&&e.endsWith("]")?"":"object"==typeof e?JSON.stringify(e):String(e),F=t.useMemo((()=>{const e=[...s];if(null!==b&&k){const t=g[b];e.sort(((e,n)=>{const i=a(e,t.key),r=a(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"===k?o:-o}))}return e}),[s,b,k,g]),L=t.useMemo((()=>F.filter((e=>{for(const[t,n]of Object.entries($)){const i=parseInt(t),r=g[i],o=a(e,r.key),l=T(o).toLowerCase(),s=n.toLowerCase();if(!l.includes(s))return!1}return!0}))),[F,$,g]);t.useEffect((()=>{m&&m(L)}),[L,m]);const q="undefined"!=typeof window?window.innerHeight-250:600,z=Math.max(0,Math.floor(A/49)-5),E=Math.min(L.length,Math.ceil((A+q)/49)+5),H=L.slice(z,E),P=49*L.length,R=49*z,_=(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)})(g.slice(0,3).map((t=>String(a(e,t.key)??""))).join("-"))}`};return s&&0!==s.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:f.container,onScroll:e=>{O(e.currentTarget.scrollTop)},style:{maxHeight:"calc(100vh - 200px)",overflowY:"auto"},children:e.jsxs("table",{className:f.table,children:[e.jsxs("thead",{children:[e.jsxs("tr",{children:[g.map(((t,n)=>{const i=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsxs("th",{className:`${f.th} ${I(t)}`.trim(),style:i,onClick:()=>(e=>{b===e?"asc"===k?C("desc"):"desc"===k&&(w(null),C(null)):(w(e),C("asc"))})(n),children:[D(t),b===n&&e.jsx("span",{className:f.sortIndicator,children:"asc"===k?"▲":"▼"})]},n)})),d&&e.jsx("th",{className:`${f.th} ${f.actionsColumn}`,style:{width:"100px"},children:B("Actions")})]}),e.jsxs("tr",{children:[g.map(((t,i)=>{const r=t.maxWidth?{width:`${t.maxWidth}px`,maxWidth:`${t.maxWidth}px`}:{};return e.jsx("th",{className:I(t),style:r,children:t.filterable&&e.jsxs("div",{className:f.filterWrapper,children:[e.jsx("input",{type:"text",className:f.filterInput,placeholder:B("Filter")+"...",value:$[i]||"",onChange:e=>((e,t)=>{M((n=>{const i={...n};return""===t.trim()?delete i[e]:i[e]=t,i}))})(i,e.target.value),onClick:e=>e.stopPropagation()}),($[i]||"").length>0&&e.jsx(n.Button,{appearance:"subtle",className:f.clearFilterButton,onClick:e=>{e.stopPropagation(),(e=>{M((t=>{const n={...t};return delete n[e],n}))})(i)},children:"×"})]})},i)})),d&&e.jsx("th",{className:f.actionsColumn})]})]}),e.jsxs("tbody",{children:[z>0&&e.jsx("tr",{style:{height:`${R}px`},children:e.jsx("td",{colSpan:g.length+(d?1:0),style:{padding:0,border:"none"}})}),H.map(((t,o)=>{const l=t._index,s="number"==typeof l?l:z+o;return e.jsxs("tr",{className:f.tr,children:[g.map(((i,o)=>{const l=a(t,i.key),c=i.format?i.format(l):T(l),d=i.maxWidth?`${f.td} ${f.tdTruncated} ${I(i)}`.trim():`${f.td} ${I(i)}`.trim(),p=()=>{window.matchMedia("(hover: hover)").matches||i.maxWidth&&c.length>0&&(N({title:D(i),text:c}),v(!0))};if("file"===i.type&&c)return e.jsx("td",{className:d,onClick:p,children:e.jsx("a",{href:r.CodicentService.getFileUrl(c),target:"_blank",rel:"noopener noreferrer",children:B("Download")})},o);if("checkbox"===i.type){const r=!0===l||"true"===l||"yes"===l||"1"===l;return e.jsx("td",{className:d,children:e.jsx(n.Checkbox,{checked:r,onChange:(e,n)=>{x&&x(t,i.key,!0===n.checked,s)}})},o)}if("enum"===i.type&&i.enumOptions)return e.jsx("td",{className:d,children:e.jsxs(n.Select,{value:c,"aria-label":i.title?B(i.title):Array.isArray(i.key)?i.key[0]:i.key,onChange:(e,n)=>{u&&u(t,i.key,n.value,s)},style:{width:"100%"},children:[!i.enumOptions.includes(c)&&c&&e.jsx("option",{value:c,children:c}),i.enumOptions.map((t=>e.jsx("option",{value:t,children:B(t)},t)))]})},o);const h=()=>i.maxWidth&&c.length>0?e.jsx(n.Tooltip,{content:{children:c,style:{maxWidth:"600px",whiteSpace:"normal"}},relationship:"description",children:e.jsx("span",{children:c})}):c;return e.jsx("td",{className:d,onClick:p,children:i.action?e.jsxs("div",{className:f.cellWithAction,children:[e.jsx("span",{className:f.cellText,children:h()}),(()=>{if(!i.action)return null;const r=i.action,o=i.action.icon,l=e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(o,{}),className:f.actionIcon,onClick:e=>{e.stopPropagation(),r.onClick(t)},size:"small"});return r.tooltip?e.jsx(n.Tooltip,{content:B(r.tooltip),relationship:"label",children:l}):l})()]}):h()},o)})),d&&(p||h)&&e.jsx("td",{className:`${f.td} ${f.actionsColumn}`,children:e.jsxs("div",{style:{display:"flex",gap:"4px",justifyContent:"center"},children:[p&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Edit24Regular,{}),className:f.editButton,onClick:()=>p(t,s),title:B("Edit")}),h&&e.jsx(n.Button,{appearance:"subtle",icon:e.jsx(i.Delete24Regular,{}),className:f.editButton,onClick:()=>h(t,s),title:B("Delete")})]})})]},_(t,s))})),E<L.length&&e.jsx("tr",{style:{height:P-R-49*H.length+"px"},children:e.jsx("td",{colSpan:g.length+(d?1:0),style:{padding:0,border:"none"}})})]})]})}),e.jsx(n.Dialog,{open:S,onOpenChange:(e,t)=>v(t.open),children:e.jsx(n.DialogSurface,{children:e.jsxs(n.DialogBody,{children:[e.jsx(n.DialogTitle,{children:W.title}),e.jsx(n.DialogContent,{className:f.dialogContent,children:W.text})]})})})]}):e.jsx("div",{className:f.emptyState,children:B("No data to display")})};var c=t.memo(s);exports.ListView=s,exports.default=c;
|
|
@@ -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,
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@fluentui/react-components"),i=require("react-router-dom"),a=require("@fluentui/react-icons"),s=require("../services/codicent.js"),o=require("./Markdown.js");require("./Textarea.js"),require("./Button.js"),require("./CompoundButton.js");var n=require("./Text.js");require("./Spinner.js"),require("./TextHeader.js"),require("./TypingIndicator.js"),require("./Dialog.js"),require("./ChatInput.js"),require("./CombinedPlaceholderDialog.js"),require("./ChatMessage.js"),require("./Header.js");var l=require("../utils/MessageContent.js");require("../node_modules/tinycolor2/esm/tinycolor.js"),require("../_virtual/index.js");var u=require("../config/index.js");require("../utils/cacheManager.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("../pages/AppFrame.js"),require("../pages/Chat.js"),require("../pages/Compose.js"),require("../pages/Snap.js"),require("../pages/Search.js"),require("../pages/Login.js"),require("../pages/CrmPage.js"),require("../pages/CrmPagePersistent.js"),require("../pages/ImageView.js"),require("../pages/FormInvite.js"),require("../pages/FormAccept.js"),require("../pages/Sales.js"),require("../pages/Purchase.js"),require("./Content.js"),require("./Page.js"),require("../pages/QrScan.js");var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@fluentui/react-components"),i=require("react-router-dom"),a=require("@fluentui/react-icons"),s=require("../services/codicent.js"),o=require("./Markdown.js");require("./Textarea.js"),require("./Button.js"),require("./CompoundButton.js");var n=require("./Text.js");require("./Spinner.js"),require("./TextHeader.js"),require("./TypingIndicator.js"),require("./Dialog.js"),require("./ChatInput.js"),require("./CombinedPlaceholderDialog.js"),require("./ChatMessage.js"),require("./Header.js");var l=require("../utils/MessageContent.js");require("../node_modules/tinycolor2/esm/tinycolor.js"),require("../_virtual/index.js");var u=require("../config/index.js");require("../utils/cacheManager.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("../pages/AppFrame.js"),require("../pages/Chat.js"),require("../pages/Compose.js"),require("../pages/Snap.js"),require("../pages/Search.js"),require("../pages/Login.js"),require("../pages/CrmPage.js"),require("../pages/CrmPagePersistent.js"),require("../pages/ImageView.js"),require("../pages/FormInvite.js"),require("../pages/FormAccept.js"),require("../pages/Sales.js"),require("../pages/Purchase.js"),require("./Content.js"),require("./Page.js"),require("../pages/QrScan.js");var c=require("../hooks/useLocalization.js"),d=require("./FileThumbnail.js");require("react-dom/client"),require("../node_modules/@auth0/auth0-react/dist/auth0-react.esm.js"),require("../hooks/useAppStyles.js"),require("./MessageInput.js"),require("./UploadFile.js"),require("./SnapFooter.js"),require("./Profile.js"),require("./AiInput.js"),require("./SearchBox.js"),require("./HtmlView.js"),require("./Footer.js"),require("./QrCodeDialog.js"),require("./QrScanner.js"),require("./OfflineMessage.js"),require("./LanguageSelector.js"),require("./ListView.js"),require("./RecordModal.js"),require("./BulkUploadDialog.js"),require("./CookieBanner.js");const g=t.makeStyles({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:t.tokens.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:t.tokens.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"}}});exports.default=({header:m,description:p,timestamp:h,text:j,image:x,tags:f,id:q,fileIds:S,codicentService:w,busy:b,onEdit:C,onShowHtmlPreview:O,maxHeightPx:k})=>{const v=g(),I=i.useNavigate(),[E,_]=r.useState(!1),[T,N]=r.useState(!1),[y,A]=r.useState("unknown"),[R,B]=r.useState(!1),L=r.useRef(null),F=Object.keys(u.getConfigValue("LOGBOOK_TAG_DEFINITIONS")),P=F.find((e=>f.includes(e)))||(S.length>0?F.find((e=>"file"===e)):void 0),[H,D]=r.useState([]),G=f.includes("todo"),{t:M}=c.default(),V=["TYPE","CUSTOMER","CONTACT","SALESPERSON","MESSAGE","COMPANY","PHONE","EMAIL","WEBSITE","INFO","FÖRETAG","ROLE","KONTAKT"],z=[M("Typ"),M("Kund"),M("Kontakt"),M("Säljare"),M("Meddelande"),M("Företag"),M("Telefon"),M("E-post"),M("Hemsida"),M("Info"),M("Företag"),M("Roll"),M("Kontakt")];r.useEffect((()=>{Promise.all(S.map((e=>w.getFileInfo(e)))).then((e=>{D(e)}))}),[w,D,S]),r.useEffect((()=>{const e=()=>{if(L.current){const e=k??100,r=L.current.scrollHeight>e+(H.length>0?-72:0);N(r)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[j,H,k]),r.useEffect((()=>{if(G){(async()=>{try{const e=await w.getTodoStatus(q);A(e)}catch(e){console.error("Error loading todo status:",e),A("unknown")}})()}}),[G,q,w]);const K=()=>_(!E),W=f.includes("chat")&&(j.includes("#function_result")||j.includes("#finish_reason_function_call")),$=e=>{const r=e.indexOf("```html");if(-1===r)return e;const t=e.indexOf("```",r+7);if(-1===t)return e.substring(r+7);return e.substring(r+7,t)},U=new l.default(j),Q=U.data,Y=u.getConfigValue("LOGBOOK_STRIP_TAGS")?U.content:j,X=P&&u.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[P].editable,J=P&&u.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[P].imageSize||void 0;return e.jsxs(t.Card,{className:E?v.expandedCard:v.card,style:{backgroundColor:u.getConfigValue("MESSAGE_HIDE_BAR")?P?u.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[P].color:u.getConfigValue("APP_HEADER_COLOR")||"#eee":"#eee",maxHeight:!E&&k?`${k}px`:void 0},onClick:f.includes("chat")?e=>{f.includes("chat")&&(e&&e.stopPropagation(),I("/chat?id="+q))}:void 0,children:[!u.getConfigValue("MESSAGE_HIDE_BAR")&&e.jsx("div",{className:v.rectangle,style:{backgroundColor:P?u.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[P].color:u.getConfigValue("APP_HEADER_COLOR")||void 0}}),e.jsxs("div",{className:v.iconButtonRow,children:[G&&e.jsx(t.Switch,{className:v.todoSwitch,checked:"done"===y,onChange:(e,r)=>(async e=>{if(!R){B(!0);try{const r=e?"done":"undone";await w.updateTodoStatus(q,r)&&A(r)}catch(e){console.error("Error updating todo status:",e)}finally{B(!1)}}})(r.checked),disabled:R||"unknown"===y,label:M("done"===y?"Done":"Todo")}),X&&C&&e.jsx(a.Edit20Regular,{className:v.htmlButton,onClick:()=>C()}),O&&!X&&f.includes("html")&&e.jsx(a.FullScreenMaximizeRegular,{className:v.htmlButton,onClick:e=>{e.stopPropagation(),O($(j))}}),T&&!f.includes("chat")&&E&&e.jsx(a.ArrowCollapseAllRegular,{className:v.headerButton,onClick:K}),T&&!f.includes("chat")&&!E&&e.jsx(a.ArrowExpandAllRegular,{className:v.headerButton,onClick:K})]}),e.jsx(t.CardHeader,{image:x?e.jsx("img",{className:v.headerImage,src:"app_logo.svg",alt:"User"}):null,header:b?e.jsx(t.Skeleton,{style:{width:"50%"},children:e.jsx(t.SkeletonItem,{})}):e.jsxs("div",{className:v.header,children:[e.jsx(n.Text,{weight:"semibold",children:m}),h&&e.jsx(n.Text,{weight:"regular",children:h})]}),description:e.jsx(t.Caption1,{className:v.caption,children:p})}),e.jsxs("div",{ref:L,className:`${v.content} ${E?"":v.truncated}`,style:{maxHeight:!E&&k?`${k}px`:void 0},children:[H.length>0&&e.jsx("div",{className:v.fileList,children:H.map((r=>e.jsx(d.FileThumbnail,{file:r,thumbnailSize:J,getImageUrl:s.CodicentService.getImageUrl,onClick:()=>{r.contentType.startsWith("image")?I(`/image?id=${q}&file=${r.id}`):s.CodicentService.downloadFile(r)}},r.id)))}),b?e.jsxs(t.Skeleton,{style:{width:"100%"},children:[e.jsx(t.SkeletonItem,{}),e.jsx(t.SkeletonItem,{}),e.jsx(t.SkeletonItem,{}),e.jsx(t.SkeletonItem,{}),e.jsx(t.SkeletonItem,{})]}):e.jsx("div",{className:v.text,children:f.includes("html")?e.jsx("iframe",{className:v.iframe,title:"html",srcDoc:$(j),sandbox:"allow-same-origin allow-scripts"}):f.includes("crm")&&0===Object.keys(Q).length?e.jsx(o.default,{content:W?"*"+M("Tänker")+"...*":Q?(()=>{const e=new RegExp(`(${V.join("|")})\\s*:\\s*`,"gi"),r=Y.replace(e,((e,r)=>{const t=V.indexOf(r.toUpperCase());-1===t&&console.log("Field not found:",r);return`\n**${-1!==t?z[t]:r}:** `}));return r.trim()})():j}):e.jsx(o.default,{content:W?"*"+M("Tänker")+"...*":Q?Q&&Object.keys(Q).length>0?Object.keys(Q).map((e=>{const r=V.indexOf(e.toUpperCase());return`**${-1!==r?z[r]:e}:** ${Q[e]}\n`})).join("\n"):Y:j})})]})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAGA,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,CA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GAAG,MAAM,CAAC;IAC9C,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE,GAAG,SAAS,CAAC;IAIvE,iBAAiB,EAAE,SAAS,GAAG,MAAM,CAAC;IACtC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,yBAAyB,EAAE,OAAO,CAAC;IACnC,oBAAoB,EAAE,SAAS,GAAG,MAAM,CAAC;IACzC,2BAA2B,EAAE,OAAO,CAAC;IAErC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,4BAA4B,EAAE,OAAO,CAAC;IACtC,yBAAyB,EAAE,OAAO,CAAC;IACnC,kBAAkB,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC1C;AAyID,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAG5F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM,QAgBtE"}
|
package/dist/cjs/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=require("mermaid");class T{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const O={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new T,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_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_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 E=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(O);exports.AppConfig=T,exports.getConfigValue=function(_){return E[_]},exports.initCodicentApp=function(T={}){for(const[_,E]of Object.entries(T))void 0!==E&&(O[_]=E);void 0!==T.TRANSLATIONS&&(globalThis.__CODICENT_REINIT_I18N__=!0),_.initialize({startOnLoad:!1})};
|
|
1
|
+
"use strict";var _=require("mermaid");class T{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const O={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new T,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_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 E=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(O);exports.AppConfig=T,exports.getConfigValue=function(_){return E[_]},exports.initCodicentApp=function(T={}){for(const[_,E]of Object.entries(T))void 0!==E&&(O[_]=E);void 0!==T.TRANSLATIONS&&(globalThis.__CODICENT_REINIT_I18N__=!0),_.initialize({startOnLoad:!1})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCodicentApp.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCodicentApp.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAyB,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|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react");require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime");var t=require("../utils/appState.js");require("../_virtual/index.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("../utils/cacheManager.js");var r=require("./useAudioRecorder.js"),s=require("./useAuthState.js"),n=require("./useRealtimeVoiceAI.js"),a=require("./useTools.js"),c=require("../config/index.js");exports.useCodicentApp=({auth0:
|
|
1
|
+
"use strict";var e=require("react");require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime");var t=require("../utils/appState.js");require("../_virtual/index.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("../utils/cacheManager.js");var r=require("./useAudioRecorder.js"),s=require("./useAuthState.js"),n=require("./useRealtimeVoiceAI.js"),a=require("./useTools.js"),c=require("../config/index.js");exports.useCodicentApp=({auth0:u,toolsConfig:i})=>{const o=s.default(u),l=e.useRef(t.createAppStateMachine(o.codicentService,(()=>{}))),[d,m]=e.useState(),{service:p,context:f}=l.current,{nickname:h,name:g,error:A,errorType:k,selectedApp:v}=f,C=e.useCallback(((e,t)=>{const r=e.get("file").name;p.uploadFile(r,e).then((e=>{p.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[p]),b=r.useAudioRecorder(C),[S,q]=e.useState(),[j,w]=e.useState(),[y,x]=e.useState(!1),T=e.useMemo((()=>new Audio("./notification.mp3")),[]),_=e.useCallback((()=>x(!0)),[]),E=a.default(p,q,w,T,S,_,i),I=e.useMemo((()=>c.getConfigValue("REALTIME_VOICE_API_KEY")||""),[]),M=n.default(p,I,E);e.useEffect((()=>{y&&(M?.disconnectConversation(),x(!1))}),[y,M]),e.useEffect((()=>{o.isAuthenticated&&o.user&&o.accessToken&&l.current.updateContext({isAuthenticated:o.isAuthenticated,user:{sub:o.user.sub,email:o.user.email},accessToken:o.accessToken})}),[o.isAuthenticated,o.user,o.accessToken]);const R=e.useRef(o.isAuthenticated);e.useEffect((()=>{const e=!0===R.current,t=!0===o.isAuthenticated;e&&!t&&l.current.logout(),R.current=o.isAuthenticated}),[o.isAuthenticated]),e.useEffect((()=>l.current.updateContext({nickname:o.nickname})),[o.nickname]),e.useEffect((()=>{l.current.update();let e,t=l.current.getCurrentStateName();m(l.current.getCurrentStateName()),JSON.stringify(l.current.context);let r=!1;const s=n=>setInterval((()=>{const n=l.current.getCurrentStateName();if("hasAccess"===n&&!r)return console.log("🎯 Reached stable state - switching to slower polling (1000ms)"),r=!0,clearInterval(e),void(e=s(1e3));if("hasAccess"!==n&&r)return console.log("🚨 Left stable state - switching to fast polling (200ms)"),r=!1,clearInterval(e),void(e=s(200));const a=JSON.stringify(l.current.context);l.current.update();const c=JSON.stringify(l.current.context),u=l.current.getCurrentStateName();u===t&&a===c||(m(u),t=u)}),n);return e=s(200),()=>clearInterval(e)}),[]);const N=e.useCallback((e=>e.replace("{nickname}",h||"unknown").replace("{token}",encodeURIComponent(o.accessToken||"unknown")).replace("{app}",v||"unknown")),[h,o.accessToken,v]),O=e.useCallback((e=>{l.current.updateContext({isAnonymous:e})}),[]),J=e.useCallback((()=>l.current.isBusy()),[]);return e.useMemo((()=>({audio:b,auth:o,currentStateName:d,stateMachine:l.current,service:p,context:f,state:d,nickname:h,name:g,error:A,errorType:k,fixAppUrl:N,setAnonymous:O,allStates:l.current.allStates,isBusy:J,voice:M,html:S,setHtml:q,script:j})),[d,h,g,A,k,S,j,o.isAuthenticated,o.isLoading,b.isRecording,M?.isConnected,N,O,J])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTools.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,QAAA,MAAM,QAAQ,QACP,eAAe,YACX,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,8BAG7B,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,qBAGhC,gBAAgB,SACf,MAAM,qBACK,MAAM,IAAI,gBAGd,WAAW,
|
|
1
|
+
{"version":3,"file":"useTools.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,QAAA,MAAM,QAAQ,QACP,eAAe,YACX,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,8BAG7B,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,qBAGhC,gBAAgB,SACf,MAAM,qBACK,MAAM,IAAI,gBAGd,WAAW,WA2mB1B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../config/index.js");exports.default=(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../config/index.js");require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime"),require("../_virtual/index.js"),require("../utils/cacheManager.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js");var s=require("../utils/device.js");exports.default=(a,r=e=>{console.log(e)},i=e=>{console.log(e)},n,o,p=()=>{console.log("stopVoiceSession")},c)=>e.useMemo((()=>{const e=[],d=(t,s)=>{e.push({definition:t,handler:s})},l=async()=>{const e=t.getConfigValue("APP_CONFIG"),s=t.getConfigValue("APP_BUTTONS");return[...s&&e.apps[s]?e.apps[s].tasks:[],...await a.getAppTasks()]};d({name:"stop_voice_session",description:"Stops the voice session.",parameters:{type:"object",properties:{}}},(async()=>(console.log("TOOL: stop_voice_session"),r(void 0),p(),{ok:!0}))),d({name:"inject_script",description:"Injects a script into the html/canvas view.",parameters:{type:"object",properties:{script:{type:"string",description:"The script to inject"}},required:["script"]}},(async({script:e})=>(console.log("TOOL: inject_script",e),i(e),{ok:!0}))),d({name:"post_codicent_message",description:"Posts a message to Codicent, only when requested by the user.",parameters:{type:"object",properties:{content:{type:"string",description:'The codicent message text, e.g. "remember to call Linda"'},parent_id:{type:"string",description:'The parent message id of a previous message that you will add a new revision to, by setting parent_id to the origin message being "edited"'}},required:["content"]}},(async({content:e,parent_id:t})=>await a.sendMessage(e,t))),d({name:"update_codicent_message",description:"Posts an edited message, which replaces the old message.",parameters:{type:"object",properties:{content:{type:"string",description:'The updated codicent message text, e.g. "remember to call Johan", usually including the tags from the original message.'},parent_id:{type:"string",description:"The message id of a previous/old message to be updated."}},required:["content","parent_id"]}},(async({content:e,parent_id:t})=>await a.sendMessage(e,t))),d({name:"get_messages_list",description:"Gets messages tagged with given tag name, optionally limited by num_messages. The messages are listed in chronological order, latest first.",parameters:{type:"object",properties:{num_messages:{type:"integer",description:"The number of matching messages to return"},search_text:{type:"string",description:"Search text to filter messages by"},tag_name:{type:"string",description:"Name of tag to find messages by"},after_timestamp:{type:"string",description:"Only return messages after this timestamp"},before_timestamp:{type:"string",description:"Only return messages before this timestamp"}},required:["num_messages"]}},(async({num_messages:e,search_text:t,tag_name:s,after_timestamp:r,before_timestamp:i})=>{let n=await a.getMessages(s?[s]:[],void 0,e);t&&(n=n.filter((e=>e.content.includes(t)))),r&&(n=n.filter((e=>e.createdAt>r))),i&&(n=n.filter((e=>e.createdAt<i)));const o=n.slice(0,e);return console.log("get_messages_list result:",o),o})),d({name:"chat_with_codicent_ai",description:"Sends a message to Codicent AI and gets a response message back. Remember that you can always ask codicent via this tool to find out more about what you can achieve from chatting with the codicent AI.",parameters:{type:"object",properties:{message:{type:"string",description:"Text of message to the codicent"}},required:["message"]}},(async({message:e})=>await a.chat(e))),d({name:"create_todo",description:"Saves a todo message in Codicent.",parameters:{type:"object",properties:{text:{type:"string",description:"Text of todo"}},required:["text"]}},(async({text:e})=>await a.sendMessage("#todo "+e))),d({name:"place_order",description:"Places and order with the Codicent AI.",parameters:{type:"object",properties:{message:{type:"string",description:"The text message of the order as spoken by the user."}},required:["message"]}},(async({message:e})=>await a.sendMessage(`#do Jag kommer ge dig en text (nedan) på vad jag ska beställa. Använd bara den text du får av mig, inga tools.\n Du ska skapa en tabell med detaljerad information inklusive lagerstatus \n för varje artikel i beställningen. Svara först när du har all info på plats. Ställ inga frågor på vägen utan använd det du får av mig.\n \n ----\n EXEMPEL PÅ SVAR:\n ----\n Här är en tabell med detaljerad information inklusive lagerstatus för varje artikel i beställningen:\n \n Artikel\tHyresobjekt\tNamn\tLagertyp\tGrupp\tNamn.1\tSRA/SBEF\tLeverantör\tLevnr\tDepå\tLager\tReserverat\tUthyrt nu\tTillgängligt nu\tMärke/typ\tTillverkarnr\tTillv.år\tInköpsdato\tInköpspris\tVikt\n Elverk\t12345\tElverk 1\tHyresobjekt\tMaskiner\tElverk\tSRA\tLeverantör A\t001\tDepå 1\t5\t0\t1\t4\tHonda EU22i\t123456\t2020\t2020-01-01\t10000 SEK\t21 kg\n Elverk\t12345\tElverk 2\tHyresobjekt\tMaskiner\tElverk\tSRA\tLeverantör B\t002\tDepå 2\t3\t0\t1\t2\tYamaha EF2000iS\t654321\t2019\t2019-05-01\t9000 SEK\t20 kg\n Observera att denna tabell är baserad på den information som finns tillgänglig i lagerstatusen. Om du behöver ytterligare detaljer eller om något specifikt saknas, vänligen meddela mig.\n ----\n \n --- här följer texten på vad jag vill beställa ---\n \n \n ${e}`))),d({name:"remember_info",description:"Saves info in your internal memory for future use. Use this tool to save insights on how to perform our conversations and tasks related to them.",parameters:{type:"object",properties:{message:{type:"string",description:"Your insights to improve our future conversations."}},required:["message"]}},(async({message:e})=>await a.sendMessage(`#index #insights\n\n${e}`))),d({name:"save_to_crm",description:"Saves CRM related info to your memory (logbook).",parameters:{type:"object",properties:{message:{type:"string",description:"CRM log entry description/contents."},company:{type:"string",description:"Company name for CRM log entry."},contact:{type:"string",description:"Contact name for CRM log entry."}},required:["message","company"]}},(async({message:e,company:t,contact:s})=>await a.sendMessage(`#crm\n\nFöretag: ${t}\n\nInfo: ${e}${s?"\n\nKontakt: "+s:""}`))),d({name:"set_page_html",description:"Sets the innerHtml of the div covering the full app page. You can display any html/javascript/style/mermaid content here for the user to see ;-). This view is usually referred to as the canvas, or tavlan in Swedish.",parameters:{type:"object",properties:{html:{type:"string",description:"The inner html to set the page to."}},required:["html"]}},(async({html:e})=>(r(e),n.play(),{ok:!0}))),d({name:"hide_page_html",description:"Hides the inner html of the page.",parameters:{type:"object",properties:{}}},(async()=>(r(void 0),{ok:!0}))),d({name:"get_page_html",description:"Gets the inner html of the page.",parameters:{type:"object",properties:{}}},(async()=>({html:o}))),d({name:"get_tasks",description:"Gets the list of possible tasks that can be performed. This lists task names and their id:s. Use get_task to get the task instructions given a task id.",parameters:{type:"object",properties:{},required:[]}},(async e=>(await l()).map((e=>({id:e.id,name:e.title}))))),d({name:"get_task",description:"Gets the task instructions for a given task id. Use get_tasks to get a list of possible tasks (with their id:s).",parameters:{type:"object",properties:{task_id:{type:"string",description:"The task id to get instructions for."}},required:["task_id"]}},(async({task_id:e})=>{const t=(await l()).find((t=>t.id===e));return t?t.content:"Task not found"})),d({name:"get_gps_location",description:"Gets the current GPS location of the device. Returns latitude and longitude coordinates. Use this when the user asks about nearby places, directions, or anything location-dependent.",parameters:{type:"object",properties:{},required:[]}},(async e=>{try{const e=await s.getGpsLocation();return e?{ok:!0,latitude:e.coords.latitude,longitude:e.coords.longitude,accuracy:e.coords.accuracy}:{ok:!1,error:"GPS not available"}}catch{return{ok:!1,error:"Failed to get GPS location"}}}));const{additionalTools:g=[],mergeStrategy:m="merge"}=c||{};return"replace"===m?g:"builtin-only"===m?e:[...e,...g]}),[a,r,i,o,n,c]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvFormPage.d.ts","sourceRoot":"","sources":["../../../src/pages/EnvFormPage.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAsE5C,UAAU,gBAAgB;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"EnvFormPage.d.ts","sourceRoot":"","sources":["../../../src/pages/EnvFormPage.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAsE5C,UAAU,gBAAgB;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAkND,QAAA,MAAM,WAAW,cAAe,gBAAgB,4CAyM/C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -138,14 +138,18 @@ export declare class CodicentService {
|
|
|
138
138
|
static getMiniChatReplyOld: (message: string, project?: string, messageId?: string) => Promise<string | undefined>;
|
|
139
139
|
/**
|
|
140
140
|
* Sends an AI chat request and polls for the result.
|
|
141
|
-
* Returns the AI reply content
|
|
141
|
+
* Returns the AI reply content and an optional responseId for stateful conversation chaining.
|
|
142
142
|
* @param message - The user's message
|
|
143
143
|
* @param project - The project name (default: "codicent-mini")
|
|
144
144
|
* @param messageId - Optional parent message ID for conversation context
|
|
145
145
|
* @param maxPollingTime - Maximum time to poll in milliseconds (default: 5 minutes)
|
|
146
146
|
* @param pollingInterval - Interval between poll requests in milliseconds (default: 2 seconds)
|
|
147
|
+
* @param previousResponseId - Optional OpenAI Responses API response ID from a previous turn (stateful chaining)
|
|
147
148
|
*/
|
|
148
|
-
static getMiniChatReply: (message: string, project?: string, messageId?: string, maxPollingTime?: number, pollingInterval?: number) => Promise<
|
|
149
|
+
static getMiniChatReply: (message: string, project?: string, messageId?: string, maxPollingTime?: number, pollingInterval?: number, previousResponseId?: string) => Promise<{
|
|
150
|
+
content: string;
|
|
151
|
+
responseId?: string;
|
|
152
|
+
} | undefined>;
|
|
149
153
|
getForms: () => Promise<Form[]>;
|
|
150
154
|
getFormById: (id: string) => Promise<Form>;
|
|
151
155
|
private handleUnauthorized;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,UAAU,QAAS,MAAM,SAerC,CAAC;AA8BF,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvC,UAAU,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AC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAqF9D;IAEF,QAAQ,QAAa,OAAO,CAAC,IAAI,EAAE,CAAC,CAMlC;IAEF,WAAW,OAAc,MAAM,mBAO7B;IAGF,OAAO,CAAC,kBAAkB;IAM1B,aAAa,cAAqB,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,CAiB/E;IAEF,gBAAgB,cAAqB,MAAM,UAAU,MAAM,GAAG,QAAQ,sBAcpE;IAEI,uBAAuB,CAAC,KAAK,GAAE,MAAgB,EAAE,QAAQ,GAAE,MAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAsB9F,iBAAiB,CAAC,QAAQ,GAAE,MAAiB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAoBzG;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,SACd,MAAM,kBACI,MAAM,YACb,MAAM,KACd,OAAO,CAAC,mBAAmB,CAAC,CAsB7B;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e=require("../node_modules/@stripe/stripe-js/dist/index.js"),o=require("../utils/MessageContent.js");require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime"),require("react"),require("../_virtual/index.js"),require("../config/index.js"),require("../utils/cacheManager.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js");let a="https://codicent.com/",n="-";const s=t=>{t&&"string"==typeof t?(a=t.endsWith("/")?t:t+"/","undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init&&window.Codicent.init({token:n,baseUrl:a})):console.warn("Invalid base URL provided, using default")},i=()=>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:n,baseUrl:a}),!0);let r=i();if(!r){const t=setInterval((()=>{r=i(),r&&clearInterval(t)}),100)}class c{constructor(t){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,a,n,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:a,length:n,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 e=new o.default(t.content).content.split("\n"),a=e[0],n=e.slice(1).join("\n");return{id:t.id,title:a,content:n}})),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(`${a}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,n=void 0,s,i=0)=>{const r=await this.request(`${a}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))})),n){const t=await this.getPublicFlow(n);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let a=[];const n=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(n)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,o,n)=>{const s=await fetch(`${a}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";const i=await s.text();return window.Codicent.init({token:n,baseUrl:a}),i},this.loginUser=async(t,e)=>{try{const o=await fetch(`${a}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 n=await o.text();return this.setToken(n),n}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${a}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(`${a}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=(await t.json()).filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))));return e}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${a}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(`${a}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let n=await o.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),o=JSON.parse(e),s=o.sub||o.userId,i=await fetch(`${a}app/GetNickname?userId=${s}`,{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(`${a}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 n=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=n;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:n})=>{const s=await fetch(`${a}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:n,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(`${a}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(`${a}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(`${a}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=>{n=t,n&&window.Codicent.init({token:n,baseUrl:a})},this.getToken=()=>n,this.checkPurchaseStatus=async()=>{const t=await fetch(`${a}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(`${a}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,n={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(n.source=e),o&&o>0&&(n.trialPeriodDays=o);const s=await fetch(`${a}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(n)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async t=>{const o=await e.loadStripe(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const a=await this.createCheckoutSession(t),{error:n}=await o.redirectToCheckout({sessionId:a});if(n)throw new Error(n.message)},this.getChatHistory=async t=>{const e=await fetch(`${a}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(`${a}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(`${a}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"},n=await fetch(`${a}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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),a=JSON.parse(o).nickname;if(!await this.addFollower(e,a))throw new Error("Failed to add follower: "+a)}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(`${a}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${a}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${a}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(`${a}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=t,s(t.API_BASE_URL)}async request(t,e,o={}){const a={};o.headers&&o.headers.forEach((([t,e])=>{a[t]=e}));const n=await fetch(t,{...o,method:e,headers:a});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${a}realtime/session?voice=${t}&provider=${e}`,n=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!n.ok)throw new Error(`Failed to fetch session token: ${n.statusText}`);const s=await n.json(),i=s.client_secret?.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${a}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}}}t=c,c.getImageUrl=(t,e)=>`${a}app/GetImage?fileId=${t}&width=${e}`,c.getFileUrl=(t,e)=>`${a}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,c.downloadFile=async e=>{fetch(t.getFileUrl(e.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((t=>{const o=window.URL.createObjectURL(t),a=document.createElement("a");a.style.display="none",a.href=o,a.download=e.filename,document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},c.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let s={project:e,message:t};o&&(s.messageId=o);const i=await fetch(`${a}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(s)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},c.getMiniChatReply=async(t,e="codicent-mini",o,s=3e5,i=2e3)=>{const r={project:e,message:t};let c;o&&(r.messageId=o);try{const t=await fetch(`${a}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(r)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(c=(await t.json()).promptMessageId,!c)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const h=Date.now();for(;Date.now()-h<s;)try{const t=await fetch(`${a}app/GetAi2ChatReplyStatus?promptMessageId=${c}`,{method:"GET",headers:[["Authorization",`Bearer ${n}`]]});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();return o.content.replace(`@${e}`,"").replace("@codicent-mini","").trim()}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},c.getTranslations=async(t,e,o="codicent-mini")=>{const s=await fetch(`${a}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${n}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!s.ok)throw s.status,new Error(`Failed to get translations: ${s.statusText}`);return await s.json()},exports.CodicentService=c,exports.setBaseUrl=s;
|
|
1
|
+
"use strict";var t,e=require("../node_modules/@stripe/stripe-js/dist/index.js"),o=require("../utils/MessageContent.js");require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime"),require("react"),require("../_virtual/index.js"),require("../config/index.js"),require("../utils/cacheManager.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js");let a="https://codicent.com/",n="-";const s=t=>{t&&"string"==typeof t?(a=t.endsWith("/")?t:t+"/","undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init&&window.Codicent.init({token:n,baseUrl:a})):console.warn("Invalid base URL provided, using default")},i=()=>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:n,baseUrl:a}),!0);let r=i();if(!r){const t=setInterval((()=>{r=i(),r&&clearInterval(t)}),100)}class c{constructor(t){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,a,n,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:a,length:n,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 e=new o.default(t.content).content.split("\n"),a=e[0],n=e.slice(1).join("\n");return{id:t.id,title:a,content:n}})),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(`${a}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,n=void 0,s,i=0)=>{const r=await this.request(`${a}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))})),n){const t=await this.getPublicFlow(n);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let a=[];const n=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(n)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,o,n)=>{const s=await fetch(`${a}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";const i=await s.text();return window.Codicent.init({token:n,baseUrl:a}),i},this.loginUser=async(t,e)=>{try{const o=await fetch(`${a}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 n=await o.text();return this.setToken(n),n}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${a}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(`${a}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=(await t.json()).filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))));return e}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${a}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(`${a}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let n=await o.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),o=JSON.parse(e),s=o.sub||o.userId,i=await fetch(`${a}app/GetNickname?userId=${s}`,{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(`${a}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 n=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=n;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:n})=>{const s=await fetch(`${a}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:n,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(`${a}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(`${a}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(`${a}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=>{n=t,n&&window.Codicent.init({token:n,baseUrl:a})},this.getToken=()=>n,this.checkPurchaseStatus=async()=>{const t=await fetch(`${a}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(`${a}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,n={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(n.source=e),o&&o>0&&(n.trialPeriodDays=o);const s=await fetch(`${a}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(n)});if(!s.ok)throw new Error("Failed to create checkout session");const{id:i}=await s.json();return i},this.redirectToCheckout=async t=>{const o=await e.loadStripe(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const a=await this.createCheckoutSession(t),{error:n}=await o.redirectToCheckout({sessionId:a});if(n)throw new Error(n.message)},this.getChatHistory=async t=>{const e=await fetch(`${a}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(`${a}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(`${a}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"},n=await fetch(`${a}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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),a=JSON.parse(o).nickname;if(!await this.addFollower(e,a))throw new Error("Failed to add follower: "+a)}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(`${a}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${a}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${a}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(`${a}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=t,s(t.API_BASE_URL)}async request(t,e,o={}){const a={};o.headers&&o.headers.forEach((([t,e])=>{a[t]=e}));const n=await fetch(t,{...o,method:e,headers:a});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${a}realtime/session?voice=${t}&provider=${e}`,n=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!n.ok)throw new Error(`Failed to fetch session token: ${n.statusText}`);const s=await n.json(),i=s.client_secret?.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${a}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}}}t=c,c.getImageUrl=(t,e)=>`${a}app/GetImage?fileId=${t}&width=${e}`,c.getFileUrl=(t,e)=>`${a}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,c.downloadFile=async e=>{fetch(t.getFileUrl(e.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((t=>{const o=window.URL.createObjectURL(t),a=document.createElement("a");a.style.display="none",a.href=o,a.download=e.filename,document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},c.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let s={project:e,message:t};o&&(s.messageId=o);const i=await fetch(`${a}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(s)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},c.getMiniChatReply=async(t,e="codicent-mini",o,s=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(`${a}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],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<s;)try{const t=await fetch(`${a}app/GetAi2ChatReplyStatus?promptMessageId=${h}`,{method:"GET",headers:[["Authorization",`Bearer ${n}`]]});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(),s=o.content??o.content??"";return{content:s.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")},c.getTranslations=async(t,e,o="codicent-mini")=>{const s=await fetch(`${a}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${n}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!s.ok)throw s.status,new Error(`Failed to get translations: ${s.statusText}`);return await s.json()},exports.CodicentService=c,exports.setBaseUrl=s;
|
|
@@ -14,9 +14,11 @@ export interface ColumnDefinition {
|
|
|
14
14
|
hidden?: boolean;
|
|
15
15
|
hideOnMobile?: boolean;
|
|
16
16
|
maxWidth?: number;
|
|
17
|
-
type?: "file" | "checkbox" | "textarea" | undefined;
|
|
17
|
+
type?: "file" | "checkbox" | "textarea" | "enum" | undefined;
|
|
18
18
|
/** Number of rows for textarea type (default: 3) */
|
|
19
19
|
rows?: number;
|
|
20
|
+
/** Options for enum type columns */
|
|
21
|
+
enumOptions?: string[];
|
|
20
22
|
editable?: boolean;
|
|
21
23
|
filterable?: boolean;
|
|
22
24
|
/** Default sort direction for this column. If multiple columns have defaultSort, only the first one is used. */
|
|
@@ -33,6 +35,7 @@ export interface ListViewProps {
|
|
|
33
35
|
onEdit?: (item: Record<string, unknown>, index: number) => void;
|
|
34
36
|
onDelete?: (item: Record<string, unknown>, index: number) => void;
|
|
35
37
|
onToggleCheckbox?: (item: Record<string, unknown>, key: string | string[], newValue: boolean, index: number) => void;
|
|
38
|
+
onEnumChange?: (item: Record<string, unknown>, key: string | string[], newValue: string, index: number) => void;
|
|
36
39
|
onFilteredDataChange?: (filteredData: Record<string, unknown>[]) => void;
|
|
37
40
|
}
|
|
38
41
|
export declare const ListView: React.FC<ListViewProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../../../src/components/ListView.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAuC,MAAM,OAAO,CAAC;
|
|
1
|
+
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ClB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChH,oBAAoB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,IAAI,CAAC;CAC1E;AAID,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA4d5C,CAAC;;AAGF,wBAAoC"}
|
|
@@ -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,
|
|
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 +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,
|
|
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 +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
|
|
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 _}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"./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}=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(_,{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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAGA,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,KAA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C,SAAS,MAAM,gBAAgB,EAAE,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAG5F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM,QAgBtE"}
|
package/dist/esm/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import _ from"mermaid";class T{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const O={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new T,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_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_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 E=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(O);function A(_){return E[_]}function I(T={}){for(const[_,E]of Object.entries(T))void 0!==E&&(O[_]=E);void 0!==T.TRANSLATIONS&&(globalThis.__CODICENT_REINIT_I18N__=!0),_.initialize({startOnLoad:!1})}export{T as AppConfig,A as getConfigValue,I as initCodicentApp};
|
|
1
|
+
import _ from"mermaid";class T{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const O={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new T,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_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 E=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(O);function A(_){return E[_]}function I(T={}){for(const[_,E]of Object.entries(T))void 0!==E&&(O[_]=E);void 0!==T.TRANSLATIONS&&(globalThis.__CODICENT_REINIT_I18N__=!0),_.initialize({startOnLoad:!1})}export{T as AppConfig,A as getConfigValue,I as initCodicentApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCodicentApp.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCodicentApp.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAyB,MAAM,UAAU,CAAC;AACpG,OAAyB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAqB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAA2B,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAiB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGnD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,E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,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,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;CAC3B;AAED,eAAO,MAAM,cAAc,2BAA4B,qBAAqB,KAgLrE,gBACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as e,useState as t,useCallback as
|
|
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})=>{const d=c(m),h=e(o(d.codicentService,(()=>{}))),[g,A]=t(),{service:f,context:v}=h.current,{nickname:k,name:j,error:w,errorType:y,selectedApp:b}=v,x=n(((e,t)=>{const n=e.get("file").name;f.uploadFile(n,e).then((e=>{f.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[f]),C=i(x),[S,T]=t(),[_,I]=t(),[N,R]=t(!1),M=r((()=>new Audio("./notification.mp3")),[]),E=n((()=>R(!0)),[]),O=u(f,T,I,M,S,E,p),J=r((()=>l("REALTIME_VOICE_API_KEY")||""),[]),L=a(f,J,O);s((()=>{N&&(L?.disconnectConversation(),R(!1))}),[N,L]),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 B=e(d.isAuthenticated);s((()=>{const e=!0===B.current,t=!0===d.isAuthenticated;e&&!t&&h.current.logout(),B.current=d.isAuthenticated}),[d.isAuthenticated]),s((()=>h.current.updateContext({nickname:d.nickname})),[d.nickname]),s((()=>{h.current.update();let e,t=h.current.getCurrentStateName();A(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),c=h.current.getCurrentStateName();c===t&&o===i||(A(c),t=c)}),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]),V=n((e=>{h.current.updateContext({isAnonymous:e})}),[]),$=n((()=>h.current.isBusy()),[]);return r((()=>({audio:C,auth:d,currentStateName:g,stateMachine:h.current,service:f,context:v,state:g,nickname:k,name:j,error:w,errorType:y,fixAppUrl:U,setAnonymous:V,allStates:h.current.allStates,isBusy:$,voice:L,html:S,setHtml:T,script:_})),[g,k,j,w,y,S,_,d.isAuthenticated,d.isLoading,C.isRecording,L?.isConnected,U,V,$])};export{m as useCodicentApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTools.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,QAAA,MAAM,QAAQ,QACP,eAAe,YACX,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,8BAG7B,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,qBAGhC,gBAAgB,SACf,MAAM,qBACK,MAAM,IAAI,gBAGd,WAAW,
|
|
1
|
+
{"version":3,"file":"useTools.d.ts","sourceRoot":"","sources":["../../../src/hooks/useTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,QAAA,MAAM,QAAQ,QACP,eAAe,YACX,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,8BAG7B,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,qBAGhC,gBAAgB,SACf,MAAM,qBACK,MAAM,IAAI,gBAGd,WAAW,WA2mB1B,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as e}from"react";import{getConfigValue as t}from"../config/index.js";const
|
|
1
|
+
import{useMemo as e}from"react";import{getConfigValue as t}from"../config/index.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import"../_virtual/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{getGpsLocation as s}from"../utils/device.js";const a=(a,r=e=>{console.log(e)},i=e=>{console.log(e)},n,o,p=()=>{console.log("stopVoiceSession")},c)=>e((()=>{const e=[],d=(t,s)=>{e.push({definition:t,handler:s})},l=async()=>{const e=t("APP_CONFIG"),s=t("APP_BUTTONS");return[...s&&e.apps[s]?e.apps[s].tasks:[],...await a.getAppTasks()]};d({name:"stop_voice_session",description:"Stops the voice session.",parameters:{type:"object",properties:{}}},(async()=>(console.log("TOOL: stop_voice_session"),r(void 0),p(),{ok:!0}))),d({name:"inject_script",description:"Injects a script into the html/canvas view.",parameters:{type:"object",properties:{script:{type:"string",description:"The script to inject"}},required:["script"]}},(async({script:e})=>(console.log("TOOL: inject_script",e),i(e),{ok:!0}))),d({name:"post_codicent_message",description:"Posts a message to Codicent, only when requested by the user.",parameters:{type:"object",properties:{content:{type:"string",description:'The codicent message text, e.g. "remember to call Linda"'},parent_id:{type:"string",description:'The parent message id of a previous message that you will add a new revision to, by setting parent_id to the origin message being "edited"'}},required:["content"]}},(async({content:e,parent_id:t})=>await a.sendMessage(e,t))),d({name:"update_codicent_message",description:"Posts an edited message, which replaces the old message.",parameters:{type:"object",properties:{content:{type:"string",description:'The updated codicent message text, e.g. "remember to call Johan", usually including the tags from the original message.'},parent_id:{type:"string",description:"The message id of a previous/old message to be updated."}},required:["content","parent_id"]}},(async({content:e,parent_id:t})=>await a.sendMessage(e,t))),d({name:"get_messages_list",description:"Gets messages tagged with given tag name, optionally limited by num_messages. The messages are listed in chronological order, latest first.",parameters:{type:"object",properties:{num_messages:{type:"integer",description:"The number of matching messages to return"},search_text:{type:"string",description:"Search text to filter messages by"},tag_name:{type:"string",description:"Name of tag to find messages by"},after_timestamp:{type:"string",description:"Only return messages after this timestamp"},before_timestamp:{type:"string",description:"Only return messages before this timestamp"}},required:["num_messages"]}},(async({num_messages:e,search_text:t,tag_name:s,after_timestamp:r,before_timestamp:i})=>{let n=await a.getMessages(s?[s]:[],void 0,e);t&&(n=n.filter((e=>e.content.includes(t)))),r&&(n=n.filter((e=>e.createdAt>r))),i&&(n=n.filter((e=>e.createdAt<i)));const o=n.slice(0,e);return console.log("get_messages_list result:",o),o})),d({name:"chat_with_codicent_ai",description:"Sends a message to Codicent AI and gets a response message back. Remember that you can always ask codicent via this tool to find out more about what you can achieve from chatting with the codicent AI.",parameters:{type:"object",properties:{message:{type:"string",description:"Text of message to the codicent"}},required:["message"]}},(async({message:e})=>await a.chat(e))),d({name:"create_todo",description:"Saves a todo message in Codicent.",parameters:{type:"object",properties:{text:{type:"string",description:"Text of todo"}},required:["text"]}},(async({text:e})=>await a.sendMessage("#todo "+e))),d({name:"place_order",description:"Places and order with the Codicent AI.",parameters:{type:"object",properties:{message:{type:"string",description:"The text message of the order as spoken by the user."}},required:["message"]}},(async({message:e})=>await a.sendMessage(`#do Jag kommer ge dig en text (nedan) på vad jag ska beställa. Använd bara den text du får av mig, inga tools.\n Du ska skapa en tabell med detaljerad information inklusive lagerstatus \n för varje artikel i beställningen. Svara först när du har all info på plats. Ställ inga frågor på vägen utan använd det du får av mig.\n \n ----\n EXEMPEL PÅ SVAR:\n ----\n Här är en tabell med detaljerad information inklusive lagerstatus för varje artikel i beställningen:\n \n Artikel\tHyresobjekt\tNamn\tLagertyp\tGrupp\tNamn.1\tSRA/SBEF\tLeverantör\tLevnr\tDepå\tLager\tReserverat\tUthyrt nu\tTillgängligt nu\tMärke/typ\tTillverkarnr\tTillv.år\tInköpsdato\tInköpspris\tVikt\n Elverk\t12345\tElverk 1\tHyresobjekt\tMaskiner\tElverk\tSRA\tLeverantör A\t001\tDepå 1\t5\t0\t1\t4\tHonda EU22i\t123456\t2020\t2020-01-01\t10000 SEK\t21 kg\n Elverk\t12345\tElverk 2\tHyresobjekt\tMaskiner\tElverk\tSRA\tLeverantör B\t002\tDepå 2\t3\t0\t1\t2\tYamaha EF2000iS\t654321\t2019\t2019-05-01\t9000 SEK\t20 kg\n Observera att denna tabell är baserad på den information som finns tillgänglig i lagerstatusen. Om du behöver ytterligare detaljer eller om något specifikt saknas, vänligen meddela mig.\n ----\n \n --- här följer texten på vad jag vill beställa ---\n \n \n ${e}`))),d({name:"remember_info",description:"Saves info in your internal memory for future use. Use this tool to save insights on how to perform our conversations and tasks related to them.",parameters:{type:"object",properties:{message:{type:"string",description:"Your insights to improve our future conversations."}},required:["message"]}},(async({message:e})=>await a.sendMessage(`#index #insights\n\n${e}`))),d({name:"save_to_crm",description:"Saves CRM related info to your memory (logbook).",parameters:{type:"object",properties:{message:{type:"string",description:"CRM log entry description/contents."},company:{type:"string",description:"Company name for CRM log entry."},contact:{type:"string",description:"Contact name for CRM log entry."}},required:["message","company"]}},(async({message:e,company:t,contact:s})=>await a.sendMessage(`#crm\n\nFöretag: ${t}\n\nInfo: ${e}${s?"\n\nKontakt: "+s:""}`))),d({name:"set_page_html",description:"Sets the innerHtml of the div covering the full app page. You can display any html/javascript/style/mermaid content here for the user to see ;-). This view is usually referred to as the canvas, or tavlan in Swedish.",parameters:{type:"object",properties:{html:{type:"string",description:"The inner html to set the page to."}},required:["html"]}},(async({html:e})=>(r(e),n.play(),{ok:!0}))),d({name:"hide_page_html",description:"Hides the inner html of the page.",parameters:{type:"object",properties:{}}},(async()=>(r(void 0),{ok:!0}))),d({name:"get_page_html",description:"Gets the inner html of the page.",parameters:{type:"object",properties:{}}},(async()=>({html:o}))),d({name:"get_tasks",description:"Gets the list of possible tasks that can be performed. This lists task names and their id:s. Use get_task to get the task instructions given a task id.",parameters:{type:"object",properties:{},required:[]}},(async e=>(await l()).map((e=>({id:e.id,name:e.title}))))),d({name:"get_task",description:"Gets the task instructions for a given task id. Use get_tasks to get a list of possible tasks (with their id:s).",parameters:{type:"object",properties:{task_id:{type:"string",description:"The task id to get instructions for."}},required:["task_id"]}},(async({task_id:e})=>{const t=(await l()).find((t=>t.id===e));return t?t.content:"Task not found"})),d({name:"get_gps_location",description:"Gets the current GPS location of the device. Returns latitude and longitude coordinates. Use this when the user asks about nearby places, directions, or anything location-dependent.",parameters:{type:"object",properties:{},required:[]}},(async e=>{try{const e=await s();return e?{ok:!0,latitude:e.coords.latitude,longitude:e.coords.longitude,accuracy:e.coords.accuracy}:{ok:!1,error:"GPS not available"}}catch{return{ok:!1,error:"Failed to get GPS location"}}}));const{additionalTools:m=[],mergeStrategy:g="merge"}=c||{};return"replace"===g?m:"builtin-only"===g?e:[...e,...m]}),[a,r,i,o,n,c]);export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvFormPage.d.ts","sourceRoot":"","sources":["../../../src/pages/EnvFormPage.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAsE5C,UAAU,gBAAgB;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"EnvFormPage.d.ts","sourceRoot":"","sources":["../../../src/pages/EnvFormPage.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAsE5C,UAAU,gBAAgB;IACxB,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAkND,QAAA,MAAM,WAAW,cAAe,gBAAgB,4CAyM/C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -138,14 +138,18 @@ export declare class CodicentService {
|
|
|
138
138
|
static getMiniChatReplyOld: (message: string, project?: string, messageId?: string) => Promise<string | undefined>;
|
|
139
139
|
/**
|
|
140
140
|
* Sends an AI chat request and polls for the result.
|
|
141
|
-
* Returns the AI reply content
|
|
141
|
+
* Returns the AI reply content and an optional responseId for stateful conversation chaining.
|
|
142
142
|
* @param message - The user's message
|
|
143
143
|
* @param project - The project name (default: "codicent-mini")
|
|
144
144
|
* @param messageId - Optional parent message ID for conversation context
|
|
145
145
|
* @param maxPollingTime - Maximum time to poll in milliseconds (default: 5 minutes)
|
|
146
146
|
* @param pollingInterval - Interval between poll requests in milliseconds (default: 2 seconds)
|
|
147
|
+
* @param previousResponseId - Optional OpenAI Responses API response ID from a previous turn (stateful chaining)
|
|
147
148
|
*/
|
|
148
|
-
static getMiniChatReply: (message: string, project?: string, messageId?: string, maxPollingTime?: number, pollingInterval?: number) => Promise<
|
|
149
|
+
static getMiniChatReply: (message: string, project?: string, messageId?: string, maxPollingTime?: number, pollingInterval?: number, previousResponseId?: string) => Promise<{
|
|
150
|
+
content: string;
|
|
151
|
+
responseId?: string;
|
|
152
|
+
} | undefined>;
|
|
149
153
|
getForms: () => Promise<Form[]>;
|
|
150
154
|
getFormById: (id: string) => Promise<Form>;
|
|
151
155
|
private handleUnauthorized;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,UAAU,QAAS,MAAM,SAerC,CAAC;AA8BF,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9C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,OAAO,CAAC,IAAI,EAAE,CAAC,CAMlC;IAEF,WAAW,OAAc,MAAM,mBAO7B;IAGF,OAAO,CAAC,kBAAkB;IAM1B,aAAa,cAAqB,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,CAiB/E;IAEF,gBAAgB,cAAqB,MAAM,UAAU,MAAM,GAAG,QAAQ,sBAcpE;IAEI,uBAAuB,CAAC,KAAK,GAAE,MAAgB,EAAE,QAAQ,GAAE,MAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAsB9F,iBAAiB,CAAC,QAAQ,GAAE,MAAiB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAoBzG;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,SACd,MAAM,kBACI,MAAM,YACb,MAAM,KACd,OAAO,CAAC,mBAAmB,CAAC,CAsB7B;CACH"}
|
|
@@ -1 +1 @@
|
|
|
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 a="https://codicent.com/",n="-";const s=t=>{t&&"string"==typeof t?(a=t.endsWith("/")?t:t+"/","undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init&&window.Codicent.init({token:n,baseUrl:a})):console.warn("Invalid base URL provided, using default")},i=()=>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:n,baseUrl:a}),!0);let r=i();if(!r){const t=setInterval((()=>{r=i(),r&&clearInterval(t)}),100)}class c{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,a,n,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:a,length:n,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"),a=o[0],n=o.slice(1).join("\n");return{id:t.id,title:a,content:n}})),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(`${a}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,n=void 0,s,i=0)=>{const r=await this.request(`${a}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))})),n){const t=await this.getPublicFlow(n);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let a=[];const n=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(n)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,o,n)=>{const s=await fetch(`${a}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";const i=await s.text();return window.Codicent.init({token:n,baseUrl:a}),i},this.loginUser=async(t,e)=>{try{const o=await fetch(`${a}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 n=await o.text();return this.setToken(n),n}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${a}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(`${a}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(`${a}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(`${a}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let n=await o.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),o=JSON.parse(e),s=o.sub||o.userId,i=await fetch(`${a}app/GetNickname?userId=${s}`,{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(`${a}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 n=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=n;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:n})=>{const s=await fetch(`${a}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:n,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(`${a}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(`${a}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(`${a}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=>{n=t,n&&window.Codicent.init({token:n,baseUrl:a})},this.getToken=()=>n,this.checkPurchaseStatus=async()=>{const t=await fetch(`${a}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(`${a}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,n={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(n.source=e),o&&o>0&&(n.trialPeriodDays=o);const s=await fetch(`${a}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(n)});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 a=await this.createCheckoutSession(e),{error:n}=await o.redirectToCheckout({sessionId:a});if(n)throw new Error(n.message)},this.getChatHistory=async t=>{const e=await fetch(`${a}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(`${a}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(`${a}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"},n=await fetch(`${a}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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),a=JSON.parse(o).nickname;if(!await this.addFollower(e,a))throw new Error("Failed to add follower: "+a)}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(`${a}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${a}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${a}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(`${a}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,s(o.API_BASE_URL)}async request(t,e,o={}){const a={};o.headers&&o.headers.forEach((([t,e])=>{a[t]=e}));const n=await fetch(t,{...o,method:e,headers:a});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${a}realtime/session?voice=${t}&provider=${e}`,n=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!n.ok)throw new Error(`Failed to fetch session token: ${n.statusText}`);const s=await n.json(),i=s.client_secret?.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${a}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=c,c.getImageUrl=(t,e)=>`${a}app/GetImage?fileId=${t}&width=${e}`,c.getFileUrl=(t,e)=>`${a}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,c.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),a=document.createElement("a");a.style.display="none",a.href=o,a.download=t.filename,document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},c.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let s={project:e,message:t};o&&(s.messageId=o);const i=await fetch(`${a}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(s)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},c.getMiniChatReply=async(t,e="codicent-mini",o,s=3e5,i=2e3)=>{const r={project:e,message:t};let c;o&&(r.messageId=o);try{const t=await fetch(`${a}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(r)});if(!t.ok)return t.status,void console.error(`Failed to start AI chat: ${t.status}`);if(c=(await t.json()).promptMessageId,!c)return void console.error("No promptMessageId returned from server")}catch(t){return void console.error("Error starting AI chat:",t)}const h=Date.now();for(;Date.now()-h<s;)try{const t=await fetch(`${a}app/GetAi2ChatReplyStatus?promptMessageId=${c}`,{method:"GET",headers:[["Authorization",`Bearer ${n}`]]});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();return o.content.replace(`@${e}`,"").replace("@codicent-mini","").trim()}catch(t){return void console.error("Error polling AI chat status:",t)}console.error("Polling timeout reached for AI chat")},c.getTranslations=async(t,e,o="codicent-mini")=>{const s=await fetch(`${a}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${n}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!s.ok)throw s.status,new Error(`Failed to get translations: ${s.statusText}`);return await s.json()};export{c as CodicentService,s as setBaseUrl};
|
|
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 a="https://codicent.com/",n="-";const s=t=>{t&&"string"==typeof t?(a=t.endsWith("/")?t:t+"/","undefined"!=typeof window&&void 0!==window.Codicent&&"function"==typeof window.Codicent.init&&window.Codicent.init({token:n,baseUrl:a})):console.warn("Invalid base URL provided, using default")},i=()=>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:n,baseUrl:a}),!0);let r=i();if(!r){const t=setInterval((()=>{r=i(),r&&clearInterval(t)}),100)}class c{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,a,n,s,i,r)=>await window.Codicent.data.read({codicent:o||this.codicent,tag:t,search:e,start:a,length:n,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"),a=o[0],n=o.slice(1).join("\n");return{id:t.id,title:a,content:n}})),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(`${a}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,n=void 0,s,i=0)=>{const r=await this.request(`${a}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))})),n){const t=await this.getPublicFlow(n);c=c.concat(t),c.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return c},this.getMessages=async(t,e,o=10)=>{let a=[];const n=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(n)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,o,n)=>{const s=await fetch(`${a}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!s.ok)return"";const i=await s.text();return window.Codicent.init({token:n,baseUrl:a}),i},this.loginUser=async(t,e)=>{try{const o=await fetch(`${a}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 n=await o.text();return this.setToken(n),n}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${a}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(`${a}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(`${a}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(`${a}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let n=await o.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),o=JSON.parse(e),s=o.sub||o.userId,i=await fetch(`${a}app/GetNickname?userId=${s}`,{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(`${a}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 n=await o.json(),{email:s,picture:i,description:r,followers:c,properties:h,owner:d}=n;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:n})=>{const s=await fetch(`${a}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:n,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(`${a}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(`${a}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(`${a}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=>{n=t,n&&window.Codicent.init({token:n,baseUrl:a})},this.getToken=()=>n,this.checkPurchaseStatus=async()=>{const t=await fetch(`${a}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(`${a}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,n={priceId:t,successUrl:window.location.href,cancelUrl:window.location.href};e&&(n.source=e),o&&o>0&&(n.trialPeriodDays=o);const s=await fetch(`${a}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify(n)});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 a=await this.createCheckoutSession(e),{error:n}=await o.redirectToCheckout({sessionId:a});if(n)throw new Error(n.message)},this.getChatHistory=async t=>{const e=await fetch(`${a}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(`${a}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(`${a}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"},n=await fetch(`${a}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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),a=JSON.parse(o).nickname;if(!await this.addFollower(e,a))throw new Error("Failed to add follower: "+a)}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(`${a}app/GetForms?codicent=${this.codicent}`,"GET",{headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${a}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.getTodoStatus=async t=>{const e=await fetch(`${a}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(`${a}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,s(o.API_BASE_URL)}async request(t,e,o={}){const a={};o.headers&&o.headers.forEach((([t,e])=>{a[t]=e}));const n=await fetch(t,{...o,method:e,headers:a});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}async getRealtimeSessionToken(t="alloy",e="openai"){const o=`${a}realtime/session?voice=${t}&provider=${e}`,n=await fetch(o,{headers:{Authorization:`Bearer ${this.getToken()}`}});if(!n.ok)throw new Error(`Failed to fetch session token: ${n.statusText}`);const s=await n.json(),i=s.client_secret?.value;if(!i)throw new Error("No ephemeral key returned from session endpoint");return i}async getRealtimeConfig(t="openai"){try{const e=`${a}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=c,c.getImageUrl=(t,e)=>`${a}app/GetImage?fileId=${t}&width=${e}`,c.getFileUrl=(t,e)=>`${a}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,c.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),a=document.createElement("a");a.style.display="none",a.href=o,a.download=t.filename,document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},c.getMiniChatReplyOld=async(t,e="codicent-mini",o)=>{let s={project:e,message:t};o&&(s.messageId=o);const i=await fetch(`${a}app/GetAi2ChatReply`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify(s)});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},c.getMiniChatReply=async(t,e="codicent-mini",o,s=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(`${a}app/StartAi2ChatAsync`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],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<s;)try{const t=await fetch(`${a}app/GetAi2ChatReplyStatus?promptMessageId=${h}`,{method:"GET",headers:[["Authorization",`Bearer ${n}`]]});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(),s=o.content??o.content??"";return{content:s.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")},c.getTranslations=async(t,e,o="codicent-mini")=>{const s=await fetch(`${a}app/GetTranslations`,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Bearer ${n}`},body:JSON.stringify({project:o,text:t,targetLanguage:e})});if(!s.ok)throw s.status,new Error(`Failed to get translations: ${s.statusText}`);return await s.json()};export{c as CodicentService,s as setBaseUrl};
|
package/dist/index.d.ts
CHANGED
|
@@ -151,14 +151,18 @@ declare class CodicentService {
|
|
|
151
151
|
static getMiniChatReplyOld: (message: string, project?: string, messageId?: string) => Promise<string | undefined>;
|
|
152
152
|
/**
|
|
153
153
|
* Sends an AI chat request and polls for the result.
|
|
154
|
-
* Returns the AI reply content
|
|
154
|
+
* Returns the AI reply content and an optional responseId for stateful conversation chaining.
|
|
155
155
|
* @param message - The user's message
|
|
156
156
|
* @param project - The project name (default: "codicent-mini")
|
|
157
157
|
* @param messageId - Optional parent message ID for conversation context
|
|
158
158
|
* @param maxPollingTime - Maximum time to poll in milliseconds (default: 5 minutes)
|
|
159
159
|
* @param pollingInterval - Interval between poll requests in milliseconds (default: 2 seconds)
|
|
160
|
+
* @param previousResponseId - Optional OpenAI Responses API response ID from a previous turn (stateful chaining)
|
|
160
161
|
*/
|
|
161
|
-
static getMiniChatReply: (message: string, project?: string, messageId?: string, maxPollingTime?: number, pollingInterval?: number) => Promise<
|
|
162
|
+
static getMiniChatReply: (message: string, project?: string, messageId?: string, maxPollingTime?: number, pollingInterval?: number, previousResponseId?: string) => Promise<{
|
|
163
|
+
content: string;
|
|
164
|
+
responseId?: string;
|
|
165
|
+
} | undefined>;
|
|
162
166
|
getForms: () => Promise<Form$1[]>;
|
|
163
167
|
getFormById: (id: string) => Promise<Form$1>;
|
|
164
168
|
private handleUnauthorized;
|
|
@@ -1083,9 +1087,11 @@ interface ColumnDefinition {
|
|
|
1083
1087
|
hidden?: boolean;
|
|
1084
1088
|
hideOnMobile?: boolean;
|
|
1085
1089
|
maxWidth?: number;
|
|
1086
|
-
type?: "file" | "checkbox" | "textarea" | undefined;
|
|
1090
|
+
type?: "file" | "checkbox" | "textarea" | "enum" | undefined;
|
|
1087
1091
|
/** Number of rows for textarea type (default: 3) */
|
|
1088
1092
|
rows?: number;
|
|
1093
|
+
/** Options for enum type columns */
|
|
1094
|
+
enumOptions?: string[];
|
|
1089
1095
|
editable?: boolean;
|
|
1090
1096
|
filterable?: boolean;
|
|
1091
1097
|
/** Default sort direction for this column. If multiple columns have defaultSort, only the first one is used. */
|
|
@@ -1102,6 +1108,7 @@ interface ListViewProps$1 {
|
|
|
1102
1108
|
onEdit?: (item: Record<string, unknown>, index: number) => void;
|
|
1103
1109
|
onDelete?: (item: Record<string, unknown>, index: number) => void;
|
|
1104
1110
|
onToggleCheckbox?: (item: Record<string, unknown>, key: string | string[], newValue: boolean, index: number) => void;
|
|
1111
|
+
onEnumChange?: (item: Record<string, unknown>, key: string | string[], newValue: string, index: number) => void;
|
|
1105
1112
|
onFilteredDataChange?: (filteredData: Record<string, unknown>[]) => void;
|
|
1106
1113
|
}
|
|
1107
1114
|
declare const _default: React__default.NamedExoticComponent<ListViewProps$1>;
|
|
@@ -1226,6 +1233,7 @@ interface AppConfigOptions {
|
|
|
1226
1233
|
imageSize?: number;
|
|
1227
1234
|
};
|
|
1228
1235
|
};
|
|
1236
|
+
LOGBOOK_STRIP_TAGS: boolean;
|
|
1229
1237
|
LOGBOOK_TAGS: string;
|
|
1230
1238
|
MENU_BACKGROUND_IMAGE_URL: undefined | string;
|
|
1231
1239
|
MESSAGE_HIDE_BAR: boolean;
|