@whoz-oss/coday-client 0.0.0-workstream-forge.75 → 0.0.0-workstream-forge.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/browser/chunk-2LWDz5SQ.js +1 -0
  2. package/browser/{chunk-D2VUzw11.js → chunk-4OgRX34W.js} +1 -1
  3. package/browser/chunk-5uQQglui.js +2 -0
  4. package/browser/{chunk-C-7EKaLv.js → chunk-B39FYjZO.js} +1 -1
  5. package/browser/{chunk-tzI8SDtI.js → chunk-B9P_ly11.js} +1 -1
  6. package/browser/{chunk-6Be7kW0o.js → chunk-BDMHF0ej.js} +2 -2
  7. package/browser/chunk-BP4QHgC0.js +1 -0
  8. package/browser/chunk-Bayiswzc.js +1 -0
  9. package/browser/chunk-BdfGZqeZ.js +1 -0
  10. package/browser/chunk-BiaN7Mim.js +1 -0
  11. package/browser/{chunk-C5CsTmNj.js → chunk-BkujqYcN.js} +1 -1
  12. package/browser/{chunk-MhUYxl3Z.js → chunk-BlZg_xnX.js} +1 -1
  13. package/browser/chunk-Bnw1eK7z.js +2 -0
  14. package/browser/chunk-BuGBr1bw.js +1 -0
  15. package/browser/{chunk-CFuJNk7Q.js → chunk-C2h5l5r_.js} +1 -1
  16. package/browser/chunk-CA32vUN3.js +1 -0
  17. package/browser/{chunk-DwLys37P.js → chunk-CB09vhCC.js} +2 -2
  18. package/browser/{chunk-C7774IZF.js → chunk-CMB6fOce.js} +1 -1
  19. package/browser/chunk-CM_kdC9n.js +1 -0
  20. package/browser/chunk-CNH1L_8C.js +1 -0
  21. package/browser/{chunk-CY9LGSZW.js → chunk-CZkJE1B4.js} +2 -2
  22. package/browser/chunk-Cbj677Cr.js +1 -0
  23. package/browser/{chunk-D9lhavsa.js → chunk-Cc38C5Xa.js} +1 -1
  24. package/browser/chunk-CdIaivi4.js +1 -0
  25. package/browser/chunk-CddDyy6H.js +1 -0
  26. package/browser/{chunk-B1nDWA3v.js → chunk-CewwdWFI.js} +1 -1
  27. package/browser/{chunk-CIMARU-Z.js → chunk-Cf_S1UWC.js} +2 -2
  28. package/browser/{chunk-DrGGZMUF.js → chunk-Ck2uBFpB.js} +1 -1
  29. package/browser/chunk-Ckd2voqR.js +1 -0
  30. package/browser/{chunk-D6Uyjin9.js → chunk-Co47-WQ-.js} +1 -1
  31. package/browser/chunk-Czn2_yKR.js +1 -0
  32. package/browser/chunk-D-KxA-Nt.js +1 -0
  33. package/browser/chunk-D0LqUuf0.js +1 -0
  34. package/browser/chunk-D1Lo_oIb.js +1 -0
  35. package/browser/chunk-D99j8lVP.js +1 -0
  36. package/browser/{chunk-BlYydhGT.js → chunk-D9Soil8i.js} +1 -1
  37. package/browser/chunk-DE7pIM0j.js +1 -0
  38. package/browser/{chunk-DYWO9D4-.js → chunk-DH5xYCxZ.js} +1 -1
  39. package/browser/chunk-DHdHSP9c.js +1 -0
  40. package/browser/chunk-DI9SjYhv.js +1 -0
  41. package/browser/chunk-DK1yfea8.js +1 -0
  42. package/browser/chunk-DLW548uM.js +1 -0
  43. package/browser/{chunk-Cr26pdWO.js → chunk-DTKrz1r0.js} +2 -2
  44. package/browser/{chunk-DOfFWQHE.js → chunk-DYxoQJeM.js} +1 -1
  45. package/browser/chunk-D_SK1dCD.js +1 -0
  46. package/browser/{chunk-80hCpwon.js → chunk-DbQl4qcz.js} +1 -1
  47. package/browser/chunk-Dd2hh7F1.js +1 -0
  48. package/browser/chunk-Ddx43WZk.js +1 -0
  49. package/browser/chunk-DivcfktJ.js +1 -0
  50. package/browser/chunk-DpSFD5A1.js +5 -0
  51. package/browser/chunk-DqUTkdKy.js +1 -0
  52. package/browser/{chunk-6VeNGs2-.js → chunk-Dqcb10oo.js} +2 -2
  53. package/browser/{chunk-CoVye3Su.js → chunk-DqybJ3CV.js} +1 -1
  54. package/browser/{chunk-DsE7jEkK.js → chunk-DyDBfSvN.js} +1 -1
  55. package/browser/chunk-IJRyzpuP.js +1 -0
  56. package/browser/chunk-J1EHEyU1.js +1 -0
  57. package/browser/{chunk-B0es9TQT.js → chunk-JKBba9WI.js} +6 -6
  58. package/browser/{chunk-C0RjV9YR.js → chunk-JL-a2GkC.js} +1 -1
  59. package/browser/chunk-NMFDB0YN.js +1 -0
  60. package/browser/{chunk-AJHLyP2Q.js → chunk-NypJiPKS.js} +1 -1
  61. package/browser/chunk-O6thNI5B.js +2 -0
  62. package/browser/{chunk-42jw_j0t.js → chunk-SNYHeawQ.js} +1 -1
  63. package/browser/chunk-WMGAW86u.js +10 -0
  64. package/browser/{chunk-13WTmKep.js → chunk-ZcJ6UNEM.js} +1 -1
  65. package/browser/{chunk-buMTi15H.js → chunk-aZLcrpJC.js} +2 -2
  66. package/browser/{chunk-Dw-TsQE6.js → chunk-cAni-AV8.js} +1 -1
  67. package/browser/{chunk-BwapsUV-.js → chunk-d0lmTRlE.js} +1 -1
  68. package/browser/{chunk-BCvr3olm.js → chunk-i35kiL-I.js} +1 -1
  69. package/browser/chunk-oPCGexYM.js +1 -0
  70. package/browser/{chunk-B9cQUPc7.js → chunk-pSTSYKqy.js} +1 -1
  71. package/browser/{chunk-DqyQME6K.js → chunk-rDVpfvvv.js} +1 -1
  72. package/browser/index.html +1 -1
  73. package/browser/main-IZL5CRF5.js +1811 -0
  74. package/package.json +1 -1
  75. package/browser/chunk-2hH5YbLe.js +0 -2
  76. package/browser/chunk-5lNA_LR4.js +0 -1
  77. package/browser/chunk-93qYG1j4.js +0 -1
  78. package/browser/chunk-AblS4pXb.js +0 -1
  79. package/browser/chunk-B1R1JDKX.js +0 -1
  80. package/browser/chunk-BJ3cmxps.js +0 -10
  81. package/browser/chunk-BRFVbU6N.js +0 -1
  82. package/browser/chunk-BYvnZ4jZ.js +0 -1
  83. package/browser/chunk-BcDCPUzh.js +0 -1
  84. package/browser/chunk-BmMRXr--.js +0 -1
  85. package/browser/chunk-BnVoIxkm.js +0 -1
  86. package/browser/chunk-Bs4cz8et.js +0 -1
  87. package/browser/chunk-Buv4bUwG.js +0 -1
  88. package/browser/chunk-C2h53xO8.js +0 -1
  89. package/browser/chunk-C519Azc-.js +0 -1
  90. package/browser/chunk-C5jla22M.js +0 -1
  91. package/browser/chunk-C8Lny5xG.js +0 -2
  92. package/browser/chunk-CBAzExoV.js +0 -1
  93. package/browser/chunk-CErujabN.js +0 -1
  94. package/browser/chunk-CIPMuL5o.js +0 -1
  95. package/browser/chunk-CJy6YujN.js +0 -1
  96. package/browser/chunk-CLQWshBg.js +0 -1
  97. package/browser/chunk-CNbCiJwC.js +0 -1
  98. package/browser/chunk-CQzD4hlX.js +0 -1
  99. package/browser/chunk-CTep3Zcv.js +0 -1
  100. package/browser/chunk-CUD8zCnQ.js +0 -1
  101. package/browser/chunk-CX09OqPp.js +0 -1
  102. package/browser/chunk-Ccxus4_o.js +0 -2
  103. package/browser/chunk-CrIQg7gg.js +0 -5
  104. package/browser/chunk-CtRqtZpo.js +0 -1
  105. package/browser/chunk-Cw_eJAWw.js +0 -1
  106. package/browser/chunk-D0rG88ee.js +0 -1
  107. package/browser/chunk-D4rIP_px.js +0 -1
  108. package/browser/chunk-DSohMG90.js +0 -1
  109. package/browser/chunk-DVa9gI4Z.js +0 -1
  110. package/browser/chunk-DdV87KC5.js +0 -1
  111. package/browser/chunk-DgQbMek3.js +0 -1
  112. package/browser/chunk-EzRHT4mT.js +0 -1
  113. package/browser/chunk-Iomqh4vI.js +0 -1
  114. package/browser/chunk-SyIy1dgS.js +0 -1
  115. package/browser/chunk-cwPycVUY.js +0 -1
  116. package/browser/chunk-o7tHGyvk.js +0 -1
  117. package/browser/chunk-zsOy-bBo.js +0 -1
  118. package/browser/main-A4H3MFZY.js +0 -1811
@@ -0,0 +1 @@
1
+ import {l}from'./chunk-WMGAW86u.js';import {g,C as Ce,ao as W,F,d5 as G,G as Gi,b as U,e as xw,k as ws,q as Rg,c9 as kf,S as Sg,o as pl,n as GC,ck as Ff,J as Jw,a3 as VI,X as XE,v as eC,u as bg,a6 as UI,d6 as Ae,bU as Td,W as x,ac as gC,a5 as vl,a9 as lC,a8 as Yg,z as Ug,d7 as Pn,aa as If,ab as wf,s as rC,y as oC}from'./main-IZL5CRF5.js';import {o as z,k as _t,b as _e$1,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,A as At,Z as Zn,l as Xn,E as En,p as An}from'./chunk-C2h5l5r_.js';import'./chunk-4OgRX34W.js';import'./chunk-JKBba9WI.js';import'./chunk-Co47-WQ-.js';var M=class e{api=g(Ae);isLoading=Gi(false);result=Gi(null);errorMessage=Gi(null);invoke(t,o,a,s){return this.isLoading.set(true),this.result.set(null),this.errorMessage.set(null),this.api.invoke({namespaceId:t,userId:o||void 0,toolName:a,payload:s||void 0}).pipe(Td({next:f=>{this.result.set(f),this.isLoading.set(false);},error:f=>{this.errorMessage.set(ne(f)),this.isLoading.set(false);}}))}reset(){this.result.set(null),this.errorMessage.set(null);}static \u0275fac=function(o){return new(o||e)};static \u0275prov=x({token:e,factory:e.\u0275fac,providedIn:"root"})};function ne(e){if(e instanceof Pn){let t=e.error;return t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"?t.message:typeof t=="string"&&t.trim().length>0?t:e.statusText||`HTTP ${e.status}`}return e instanceof Error?e.message:"Unknown error"}var ie=(e,t)=>t.id;function re(e,t){e&1&&GC(0," Execute any registered tool directly \u2014 bypasses the normal agent-run pipeline. Restricted to super-admins. ");}function ae(e,t){e&1&&GC(0," Execute a registered tool directly in this namespace \u2014 bypasses the normal agent-run pipeline. ");}function le(e,t){e&1&&(ws(0,"p",17),GC(1,"Loading namespaces\u2026"),pl());}function se(e,t){if(e&1&&(ws(0,"option",27),GC(1),pl()),e&2){let o=t.$implicit;bg("value",o.id),XE(),Yg(o.name);}}function de(e,t){if(e&1&&(ws(0,"select",25)(1,"option",26),GC(2,"Select a namespace"),pl(),rC(3,se,2,2,"option",27,ie),pl(),VI()),e&2){let o=gC(2);UI(),XE(3),oC(o.namespaces());}}function ce(e,t){if(e&1&&Jw(0,le,2,0,"p",17)(1,de,5,0,"select",25),e&2){let o=gC();eC(o.namespacesLoading()?0:1);}}function me(e,t){if(e&1&&(ws(0,"p",11),GC(1),pl()),e&2){let o=gC();XE(),vl(" ",o.namespaceName()??o.namespaceId," ");}}function pe(e,t){e&1&&GC(0," Running\u2026 ");}function _e(e,t){e&1&&GC(0," Run tool ");}function ue(e,t){if(e&1){let o=lC();ws(0,"button",28),Rg("click",function(){If(o);let s=gC();return wf(s.reset())}),GC(1,"Clear result"),pl();}}function fe(e,t){e&1&&(ws(0,"section",23)(1,"h2",29),GC(2,"Error"),pl(),ws(3,"pre",30),GC(4),pl()()),e&2&&(XE(4),Yg(t));}function ve(e,t){e&1&&(ws(0,"h3",34),GC(1,"Metadata"),pl(),ws(2,"pre",30),GC(3),pl()),e&2&&(XE(3),Yg(t));}function ge(e,t){if(e&1&&(ws(0,"dt",36),GC(1,"Type"),pl(),ws(2,"dd",37),GC(3),pl()),e&2){let o=gC(2);XE(3),Yg(o.errorType);}}function ke(e,t){if(e&1&&(ws(0,"dt",36),GC(1,"Message"),pl(),ws(2,"dd",38),GC(3),pl()),e&2){let o=gC(2);XE(3),Yg(o.errorMessage);}}function be(e,t){if(e&1&&(ws(0,"h3",34),GC(1,"Tool error details"),pl(),ws(2,"dl",35),Jw(3,ge,4,1),Jw(4,ke,4,1),pl()),e&2){let o=gC();XE(3),eC(o.errorType?3:-1),XE(),eC(o.errorMessage?4:-1);}}function xe(e,t){if(e&1&&(ws(0,"section",31)(1,"header",32)(2,"h2",29),GC(3),pl(),ws(4,"span",33),GC(5),pl()(),ws(6,"h3",34),GC(7,"Output"),pl(),ws(8,"pre",30),GC(9),pl(),Jw(10,ve,4,1),ws(11,"h3",34),GC(12,"Structured output"),pl(),ws(13,"pre",30),GC(14),pl(),Jw(15,be,5,2),pl()),e&2){let o,a=t,s=gC();Ug("tool-invoke__result--failure",!a.success),XE(3),vl("Result \u2014 ",a.toolName),XE(),Ug("tool-invoke__badge--success",a.success)("tool-invoke__badge--failure",!a.success),XE(),vl(" ",a.success?"Success":"Tool error"," "),XE(4),Yg(a.output),XE(),eC((o=s.formatMetadata(a.metadata))?10:-1,o),XE(4),Yg(s.formatStructuredOutput(a.structuredOutput)??"null"),XE(),eC(a.errorType||a.errorMessage?15:-1);}}var te=class e{destroyRef=g(Ce);route=g(W);router=g(F);namespaceController=g(G);userState=g(l);state=g(M);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;namespaces=Gi([]);namespacesLoading=Gi(true);namespaceName=Gi(null);form=new z({namespaceId:new _t("",{nonNullable:true,validators:[_e$1.required]}),userId:new _t("",{nonNullable:true}),toolName:new _t("",{nonNullable:true,validators:[_e$1.required]}),payload:new _t("",{nonNullable:true})});ngOnInit(){let t=this.userState.currentUser()?.id;t?this.form.controls.userId.patchValue(t):this.userState.loadMe().pipe(U(this.destroyRef)).subscribe({next:o=>{o.id&&this.form.controls.userId.patchValue(o.id);}}),this.isPlatformMode?this.namespaceController.listAllNamespace().pipe(U(this.destroyRef)).subscribe({next:o=>{this.namespaces.set(o.map(a=>({id:a.id,name:a.name}))),this.namespacesLoading.set(false);},error:()=>this.namespacesLoading.set(false)}):(this.form.controls.namespaceId.patchValue(this.namespaceId),this.namespacesLoading.set(false),this.namespaceController.getByIdNamespace(this.namespaceId).pipe(U(this.destroyRef)).subscribe({next:o=>this.namespaceName.set(o.name),error:()=>this.namespaceName.set(this.namespaceId)}));}submit(){if(this.form.invalid||this.state.isLoading())return;let{namespaceId:t,userId:o,toolName:a,payload:s}=this.form.getRawValue();this.state.invoke(t,o.trim()||void 0,a.trim(),s.trim()||void 0).pipe(U(this.destroyRef)).subscribe();}reset(){this.state.reset();}formatMetadata(t){return !t||Object.keys(t).length===0?null:JSON.stringify(t,null,2)}formatStructuredOutput(t){return t===void 0?null:JSON.stringify(t,null,2)}back(){this.isPlatformMode?this.router.navigate(["/agentos","admin"]):this.router.navigate(["/agentos",this.namespaceId,"agent-configs"]);}static \u0275fac=function(o){return new(o||e)};static \u0275cmp=xw({type:e,selectors:[["agentos-tool-invoke"]],decls:46,vars:8,consts:[[1,"tool-invoke"],[1,"tool-invoke__header"],["type","button",1,"tool-invoke__back",3,"click"],["width","16","height","16","viewBox","0 0 24 24","fill","none","aria-hidden","true"],["d","M15 18l-6-6 6-6","stroke","currentColor","stroke-width","2","stroke-linecap","round","stroke-linejoin","round"],[1,"tool-invoke__title"],[1,"tool-invoke__subtitle"],[1,"tool-invoke__form",3,"ngSubmit","formGroup"],[1,"tool-invoke__field"],["for","ti-namespace",1,"tool-invoke__label"],[1,"tool-invoke__required"],["id","ti-namespace",1,"tool-invoke__namespace-static"],["for","ti-user",1,"tool-invoke__label"],[1,"tool-invoke__optional"],["id","ti-user","type","text","formControlName","userId","placeholder","UUID of the user \u2014 adds user-scoped overlay layers","autocomplete","off",1,"tool-invoke__input"],["for","ti-tool",1,"tool-invoke__label"],["id","ti-tool","type","text","formControlName","toolName","placeholder","e.g. MY_FILES__listFiles","autocomplete","off","spellcheck","false",1,"tool-invoke__input","tool-invoke__input--mono"],[1,"tool-invoke__hint"],["for","ti-payload",1,"tool-invoke__label"],["id","ti-payload","formControlName","payload","rows","6","placeholder",'JSON arguments for the tool, e.g. {"path": "/some/dir"}\\nLeave empty for tools with no input.',"spellcheck","false",1,"tool-invoke__textarea","tool-invoke__input--mono"],[1,"tool-invoke__actions"],["type","submit",1,"tool-invoke__submit",3,"disabled"],["type","button",1,"tool-invoke__reset"],[1,"tool-invoke__result","tool-invoke__result--error"],[1,"tool-invoke__result",3,"tool-invoke__result--failure"],["id","ti-namespace","formControlName","namespaceId",1,"tool-invoke__select"],["value","","disabled",""],[3,"value"],["type","button",1,"tool-invoke__reset",3,"click"],[1,"tool-invoke__result-title"],[1,"tool-invoke__output"],[1,"tool-invoke__result"],[1,"tool-invoke__result-header"],[1,"tool-invoke__badge"],[1,"tool-invoke__section-label"],[1,"tool-invoke__dl"],[1,"tool-invoke__dt"],[1,"tool-invoke__dd","tool-invoke__dd--mono"],[1,"tool-invoke__dd"]],template:function(o,a){if(o&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return a.back()}),kf(),ws(3,"svg",3),Sg(4,"path",4),pl(),GC(5," Back "),pl(),Ff(),ws(6,"h1",5),GC(7,"Tool invoke"),pl(),ws(8,"p",6),Jw(9,re,1,0)(10,ae,1,0),pl()(),ws(11,"form",7),Rg("ngSubmit",function(){return a.submit()}),ws(12,"div",8)(13,"label",9),GC(14,"Namespace "),ws(15,"span",10),GC(16,"*"),pl()(),Jw(17,ce,2,1)(18,me,2,1,"p",11),pl(),ws(19,"div",8)(20,"label",12),GC(21,"User ID "),ws(22,"span",13),GC(23,"(optional)"),pl()(),Sg(24,"input",14),VI(),pl(),ws(25,"div",8)(26,"label",15),GC(27,"Tool name "),ws(28,"span",10),GC(29,"*"),pl()(),Sg(30,"input",16),VI(),ws(31,"p",17),GC(32," Exact tool name as returned by the agent definition inspect page. When not found, the error response lists all available tools for the selected namespace. "),pl()(),ws(33,"div",8)(34,"label",18),GC(35,"Payload "),ws(36,"span",13),GC(37,"(optional)"),pl()(),Sg(38,"textarea",19),VI(),pl(),ws(39,"div",20)(40,"button",21),Jw(41,pe,1,0)(42,_e,1,0),pl(),Jw(43,ue,2,0,"button",22),pl()(),Jw(44,fe,5,1,"section",23),Jw(45,xe,16,12,"section",24),pl()),o&2){let s,f;XE(9),eC(a.isPlatformMode?9:10),XE(2),bg("formGroup",a.form),XE(6),eC(a.isPlatformMode?17:18),XE(7),UI(),XE(6),UI(),XE(8),UI(),XE(2),bg("disabled",a.form.invalid||a.state.isLoading()),XE(),eC(a.state.isLoading()?41:42),XE(2),eC(a.state.result()||a.state.errorMessage()?43:-1),XE(),eC((s=a.state.errorMessage())?44:-1,s),XE(),eC((f=a.state.result())?45:-1,f);}},dependencies:[ni,Jn,Qn,ei,Ye,At,Zn,Xn,En,An],styles:[".tool-invoke[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:720px;margin:0 auto;padding:2rem 1rem}.tool-invoke__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.tool-invoke__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.3rem;padding:0;border:none;background:transparent;color:var(--color-text-secondary, #6e6e73);font-size:.875rem;font-family:inherit;cursor:pointer;align-self:flex-start}.tool-invoke__back[_ngcontent-%COMP%]:hover{color:var(--color-text, #1d1d1f)}.tool-invoke__namespace-static[_ngcontent-%COMP%]{margin:0;padding:.5rem .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-surface-muted, rgba(0, 0, 0, .04));color:var(--color-text, #1d1d1f);font-size:.9375rem}.tool-invoke__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.tool-invoke__subtitle[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text-secondary, #6e6e73);line-height:1.5}.tool-invoke__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem;padding:1.5rem;border:1px solid var(--color-border, rgba(0, 0, 0, .1));border-radius:12px}.tool-invoke__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.4rem}.tool-invoke__label[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:500;color:var(--color-text-secondary, #6e6e73)}.tool-invoke__required[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30);margin-left:.1em}.tool-invoke__optional[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary, #6e6e73);font-size:.75rem}.tool-invoke__hint[_ngcontent-%COMP%]{margin:0;font-size:.75rem;color:var(--color-text-secondary, #6e6e73);line-height:1.4}.tool-invoke__input[_ngcontent-%COMP%], .tool-invoke__select[_ngcontent-%COMP%], .tool-invoke__textarea[_ngcontent-%COMP%]{padding:.5rem .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-surface, #fff);color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;transition:border-color .15s ease}.tool-invoke__input[_ngcontent-%COMP%]:focus, .tool-invoke__select[_ngcontent-%COMP%]:focus, .tool-invoke__textarea[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--color-primary, #007aff)}.tool-invoke__input--mono[_ngcontent-%COMP%], .tool-invoke__select--mono[_ngcontent-%COMP%], .tool-invoke__textarea--mono[_ngcontent-%COMP%]{font-family:monospace;font-size:.875rem}.tool-invoke__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:120px}.tool-invoke__select[_ngcontent-%COMP%]{cursor:pointer}.tool-invoke__actions[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;flex-wrap:wrap;padding-top:.25rem}.tool-invoke__submit[_ngcontent-%COMP%]{padding:.55rem 1.25rem;border-radius:8px;border:none;background:var(--color-primary, #007aff);color:#fff;font-size:.9375rem;font-weight:500;font-family:inherit;cursor:pointer;transition:opacity .15s ease}.tool-invoke__submit[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.tool-invoke__submit[_ngcontent-%COMP%]:not(:disabled):hover{opacity:.88}.tool-invoke__reset[_ngcontent-%COMP%]{padding:.55rem 1rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:transparent;color:var(--color-text-secondary, #6e6e73);font-size:.875rem;font-family:inherit;cursor:pointer}.tool-invoke__reset[_ngcontent-%COMP%]:hover{background:var(--color-surface-hover, rgba(0, 0, 0, .04))}.tool-invoke__result[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.75rem;padding:1.25rem;border:1px solid var(--color-border, rgba(0, 0, 0, .1));border-radius:12px}.tool-invoke__result--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30);background:var(--color-error-bg, #fff5f5)}.tool-invoke__result--failure[_ngcontent-%COMP%]{border-color:var(--color-warning, #ff9500);background:var(--color-warning-bg, #fffaf0)}.tool-invoke__result-header[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.75rem;flex-wrap:wrap}.tool-invoke__result-title[_ngcontent-%COMP%]{margin:0;font-size:.9375rem;font-weight:600;color:var(--color-text, #1d1d1f)}.tool-invoke__badge[_ngcontent-%COMP%]{display:inline-block;padding:.2em .6em;border-radius:4px;font-size:.75rem;font-weight:500}.tool-invoke__badge--success[_ngcontent-%COMP%]{background:var(--color-success-bg, #e3f5e1);color:var(--color-success, #34c759)}.tool-invoke__badge--failure[_ngcontent-%COMP%]{background:var(--color-warning-bg, #fff3cd);color:var(--color-warning, #ff9500)}.tool-invoke__section-label[_ngcontent-%COMP%]{margin:.5rem 0 0;font-size:.8125rem;font-weight:500;color:var(--color-text-secondary, #6e6e73);text-transform:uppercase;letter-spacing:.04em}.tool-invoke__output[_ngcontent-%COMP%]{margin:0;padding:.875rem 1rem;border-radius:6px;background:var(--color-surface-muted, rgba(0, 0, 0, .04));font-size:.875rem;font-family:monospace;color:var(--color-text, #1d1d1f);white-space:pre-wrap;word-break:break-word;line-height:1.6;max-height:500px;overflow-y:auto}.tool-invoke__dl[_ngcontent-%COMP%]{display:grid;grid-template-columns:max-content 1fr;gap:.4rem 1rem;margin:0}.tool-invoke__dt[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:500;color:var(--color-text-secondary, #6e6e73);align-self:start}.tool-invoke__dd[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text, #1d1d1f);word-break:break-word}.tool-invoke__dd--mono[_ngcontent-%COMP%]{font-family:monospace}"]})};export{te as ToolInvokeComponent};
@@ -0,0 +1 @@
1
+ import {o}from'./chunk-d0lmTRlE.js';import {g,ao as W$1,F,C as Ce,G as Gi,b as U$1,x,w,e as xw,$ as $t,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,a8 as Yg,v as eC,ac as gC,u as bg,a9 as lC,S as Sg,a3 as VI,a6 as UI,a5 as vl,s as rC,bo as tC,y as oC,aa as If,ab as wf}from'./main-IZL5CRF5.js';import {o as z,k as _t,b as _e,n as ni,J as Jn,Y as Ye,Z as Zn,l as Xn,C as Cn,E as En}from'./chunk-C2h5l5r_.js';function J(n,o){if(n&1&&(ws(0,"a",5),GC(1,"View skill \u2192"),pl()),n&2){let e=gC();bg("routerLink",e.inspectRoute());}}function K(n,o){n&1&&(ws(0,"span",6),GC(1,"Platform level"),pl());}function Q(n,o){n&1&&(ws(0,"p",7),GC(1,"Loading\u2026"),pl());}function W(n,o){n&1&&(ws(0,"p",14),GC(1," A valid, non-empty name is required. "),pl());}function X(n,o){if(n&1){let e=lC();ws(0,"li",26)(1,"div",27),Sg(2,"input",28),VI(),ws(3,"button",29),Rg("click",function(){let s=If(e).$implicit,H=gC(3);return wf(H.removeResource(s))}),GC(4," \xD7 "),pl()(),Sg(5,"textarea",30),VI(),pl();}if(n&2){let e=o.$implicit;XE(2),bg("formControl",e.path),UI(),XE(3),bg("formControl",e.content),UI();}}function Y(n,o){if(n&1&&(ws(0,"ul",20),rC(1,X,6,2,"li",26,tC),pl()),n&2){let e=gC(2);XE(),oC(e.resourceRows());}}function ee(n,o){if(n&1&&(ws(0,"p",22),GC(1),pl()),n&2){let e=gC(2);XE(),Yg(e.errorMessage());}}function te(n,o){if(n&1){let e=lC();ws(0,"form",9),Rg("ngSubmit",function(){If(e);let s=gC();return wf(s.submit())}),ws(1,"div",10)(2,"label",11),GC(3,"Name"),pl(),Sg(4,"input",12),VI(),ws(5,"p",13),GC(6," The value an agent's skillSelectors entry must match. Letters, digits, dash, dot, underscore and single spaces; 100 characters max. "),pl(),Jw(7,W,2,0,"p",14),pl(),ws(8,"div",10)(9,"label",15),GC(10,"Description"),pl(),Sg(11,"textarea",16),VI(),ws(12,"p",13),GC(13," This is what the agent sees in its skill catalog \u2014 it decides from this line alone whether to read the skill. 500 characters max. "),pl()(),ws(14,"div",10)(15,"label",17),GC(16,"Body"),pl(),Sg(17,"textarea",18),VI(),ws(18,"p",13),GC(19," Markdown instructions returned verbatim by the readSkill tool when the agent asks for this skill. "),pl()(),ws(20,"div",10)(21,"span",19),GC(22,"Resources"),pl(),ws(23,"p",13),GC(24," Optional files the agent can read with readSkillResource, by relative path. "),pl(),Jw(25,Y,3,0,"ul",20),ws(26,"button",21),Rg("click",function(){If(e);let s=gC();return wf(s.addResource())}),GC(27," + Add resource "),pl()(),Jw(28,ee,2,1,"p",22),ws(29,"div",23)(30,"button",24),Rg("click",function(){If(e);let s=gC();return wf(s.cancel())}),GC(31,"Cancel"),pl(),ws(32,"button",25),GC(33),pl()()();}if(n&2){let e=gC();bg("formGroup",e.form),XE(4),bg("formControl",e.nameControl),UI(),XE(3),eC(e.nameControl.invalid&&e.nameControl.touched?7:-1),XE(4),bg("formControl",e.descriptionControl),UI(),XE(6),bg("formControl",e.bodyControl),UI(),XE(8),eC(e.resourceRows().length>0?25:-1),XE(3),eC(e.errorMessage()?28:-1),XE(4),bg("disabled",e.form.invalid||e.isSubmitting()),XE(),vl(" ",e.isSubmitting()?"Saving\u2026":e.isEditMode()?"Save":"Create"," ");}}var U=class n{route=g(W$1);router=g(F);destroyRef=g(Ce);skillState=g(o);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isEditMode=Gi(false);isLoading=Gi(false);isSubmitting=Gi(false);errorMessage=Gi(null);existingSkill=null;form=new z({name:new _t("",{nonNullable:true,validators:[_e.required,_e.maxLength(100),_e.pattern(/^[a-zA-Z0-9_.-]+( [a-zA-Z0-9_.-]+)*$/)]}),description:new _t("",{nonNullable:true,validators:[_e.required,_e.maxLength(500),_e.pattern(/\S/)]}),body:new _t("",{nonNullable:true,validators:[_e.required,_e.pattern(/\S/)]})});resourceRows=Gi([]);get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get bodyControl(){return this.form.controls.body}ngOnInit(){let o=this.route.snapshot.paramMap.get("skillId");o&&(this.isEditMode.set(true),this.isLoading.set(true),this.skillState.getById(o).pipe(U$1(this.destroyRef)).subscribe({next:e=>{if(e.readOnly){this.router.navigate(this.inspectRoute());return}this.existingSkill=e,this.form.patchValue({name:e.name,description:e.description,body:e.body}),this.resourceRows.set(Object.entries(e.resources??{}).map(([a,s])=>({path:new _t(a,{nonNullable:true}),content:new _t(s,{nonNullable:true})}))),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}}));}addResource(){this.resourceRows.update(o=>[...o,{path:new _t("",{nonNullable:true}),content:new _t("",{nonNullable:true})}]);}removeResource(o){this.resourceRows.update(e=>e.filter(a=>a!==o));}buildResourcesPayload(){let o=this.resourceRows().map(e=>[e.path.value.trim(),e.content.value]).filter(([e])=>e.length>0);return Object.fromEntries(o)}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true),this.errorMessage.set(null);let o=x(w({},this.existingSkill??{}),{namespaceId:this.namespaceId??null,name:this.nameControl.value.trim(),description:this.descriptionControl.value.trim(),body:this.bodyControl.value,resources:this.buildResourcesPayload()});(this.isEditMode()?this.skillState.update(this.existingSkill?.id??"",o):this.skillState.create(o)).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:a=>{this.isSubmitting.set(false),a.status===409?this.errorMessage.set(`A skill named "${this.nameControl.value.trim()}" already exists in this scope.`):a.status===400?this.errorMessage.set("The server rejected this skill. A filesystem-backed skill cannot be modified."):this.errorMessage.set("Saving the skill failed.");}});}cancel(){this.navigateBack();}inspectRoute(){let o=this.route.snapshot.paramMap.get("skillId")??"";return this.isPlatformMode?["/agentos","admin","skills",o,"inspect"]:["/agentos",this.namespaceId,"skills",o,"inspect"]}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","skills"]):this.router.navigate(["/agentos",this.namespaceId,"skills"]);}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=xw({type:n,selectors:[["agentos-skill-form"]],decls:12,vars:4,consts:[[1,"skill-form"],[1,"skill-form__header"],["type","button","title","Back to skills",1,"skill-form__back",3,"click"],[1,"skill-form__back-icon"],[1,"skill-form__title"],[1,"skill-form__sibling-link",3,"routerLink"],[1,"skill-form__platform-badge"],[1,"skill-form__loading"],[1,"skill-form__form",3,"formGroup"],[1,"skill-form__form",3,"ngSubmit","formGroup"],[1,"skill-form__field"],["for","skill-name",1,"skill-form__label"],["id","skill-name","type","text","autocomplete","off",1,"skill-form__input",3,"formControl"],[1,"skill-form__field-hint"],["role","alert",1,"skill-form__field-hint","skill-form__field-hint--error"],["for","skill-description",1,"skill-form__label"],["id","skill-description","rows","2",1,"skill-form__input","skill-form__textarea",3,"formControl"],["for","skill-body",1,"skill-form__label"],["id","skill-body","rows","16",1,"skill-form__input","skill-form__textarea","skill-form__textarea--code",3,"formControl"],[1,"skill-form__label"],[1,"skill-form__resource-list"],["type","button",1,"skill-form__resource-btn","skill-form__resource-btn--add",3,"click"],["role","alert",1,"skill-form__error"],[1,"skill-form__actions"],["type","button",1,"skill-form__btn",3,"click"],["type","submit",1,"skill-form__btn","skill-form__btn--primary",3,"disabled"],[1,"skill-form__resource-row"],[1,"skill-form__resource-head"],["type","text","placeholder","e.g. references/checklist.md","autocomplete","off",1,"skill-form__input","skill-form__resource-path",3,"formControl"],["type","button","title","Remove",1,"skill-form__resource-btn","skill-form__resource-btn--danger",3,"click"],["rows","4",1,"skill-form__input","skill-form__textarea","skill-form__textarea--code",3,"formControl"]],template:function(e,a){e&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return a.cancel()}),ws(3,"span",3),GC(4,"\u2190"),pl(),GC(5," Skills "),pl(),ws(6,"h1",4),GC(7),pl(),Jw(8,J,2,1,"a",5),Jw(9,K,2,0,"span",6),pl(),Jw(10,Q,2,0,"p",7)(11,te,34,9,"form",8),pl()),e&2&&(XE(7),Yg(a.isEditMode()?"Edit skill":"New skill"),XE(),eC(a.isEditMode()?8:-1),XE(),eC(a.isPlatformMode?9:-1),XE(),eC(a.isLoading()?10:11));},dependencies:[ni,Jn,Ye,Zn,Xn,Cn,En,$t],styles:[".skill-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;max-width:720px;margin:0 auto;padding:2rem 1rem}.skill-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.skill-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.skill-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.skill-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.skill-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.skill-form__sibling-link[_ngcontent-%COMP%]{font-size:.8125rem;color:var(--color-primary, #007aff);text-decoration:none}.skill-form__sibling-link[_ngcontent-%COMP%]:hover{text-decoration:underline}.skill-form__platform-badge[_ngcontent-%COMP%]{align-self:flex-start;font-family:var(--font-heading);font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;padding:.15rem .5rem;border:1px solid var(--color-divider, rgba(0, 0, 0, .12));color:var(--color-neutral-600, #6e6e73)}.skill-form__loading[_ngcontent-%COMP%]{margin:0;font-size:.9rem;color:var(--color-text-secondary, #6e6e73)}.skill-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.skill-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.skill-form__label[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:500;color:var(--color-text-secondary, #6e6e73)}.skill-form__input[_ngcontent-%COMP%]{width:100%;box-sizing:border-box;padding:.5rem .75rem;border:1px solid var(--color-border, rgba(0, 0, 0, .12));border-radius:0;background:var(--color-surface, #fff);color:var(--color-text, #1d1d1f);font-family:inherit;font-size:.9375rem}.skill-form__input[_ngcontent-%COMP%]:focus{outline:none;border-color:var(--color-primary, #007aff)}.skill-form__textarea[_ngcontent-%COMP%]{resize:vertical;line-height:1.5}.skill-form__textarea--code[_ngcontent-%COMP%]{font-family:var(--font-code, monospace);font-size:.8125rem}.skill-form__field-hint[_ngcontent-%COMP%]{margin:0;font-size:.75rem;color:var(--color-text-secondary, #6e6e73)}.skill-form__field-hint--error[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30)}.skill-form__resource-list[_ngcontent-%COMP%]{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:.75rem}.skill-form__resource-row[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.skill-form__resource-head[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.skill-form__resource-path[_ngcontent-%COMP%]{flex:1;font-family:var(--font-code, monospace);font-size:.8125rem}.skill-form__resource-btn[_ngcontent-%COMP%]{align-self:flex-start;background:none;border:1px solid var(--color-border, rgba(0, 0, 0, .12));padding:.3rem .6rem;cursor:pointer;font-family:inherit;font-size:.8125rem;color:var(--color-text, #1d1d1f)}.skill-form__resource-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover, rgba(0, 0, 0, .04))}.skill-form__resource-btn--danger[_ngcontent-%COMP%]{color:var(--color-error, #ff3b30);font-size:1rem;line-height:1;padding:.25rem .5rem}.skill-form__resource-btn--add[_ngcontent-%COMP%]{color:var(--color-primary, #007aff)}.skill-form__error[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-error, #ff3b30)}.skill-form__actions[_ngcontent-%COMP%]{display:flex;gap:.5rem;justify-content:flex-end}.skill-form__btn[_ngcontent-%COMP%]{padding:.5rem 1rem;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:none;cursor:pointer;font-family:inherit;font-size:.875rem;color:var(--color-text, #1d1d1f)}.skill-form__btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover, rgba(0, 0, 0, .04))}.skill-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary, #007aff);border-color:var(--color-primary, #007aff);color:var(--color-text-on-accent, #fff)}.skill-form__btn--primary[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}"]})};export{U as SkillFormComponent};
@@ -0,0 +1 @@
1
+ import {l}from'./chunk-WMGAW86u.js';import {g,dh as ae,di as T,Q as br,bS as Ea,r as re,a7 as ya,cE as Dd,W as x}from'./main-IZL5CRF5.js';var v=class i{userState=g(l);membership=g(ae);currentUser$=T(this.userState.currentUser);cache=new Map;isAdminOfNamespace$(e){if(!e)return br(false);let t=this.cache.get(e);if(t)return t;let s=this.currentUser$.pipe(Ea(a=>a?a.isAdmin?br(true):this.membership.getMembersNamespaceMembership(e).pipe(re(d=>d.some(n=>n.id===a.id&&n.role==="ADMIN")),ya(()=>br(false))):br(false)),Dd({bufferSize:1,refCount:false}));return this.cache.set(e,s),s}static \u0275fac=function(t){return new(t||i)};static \u0275prov=x({token:i,factory:i.\u0275fac,providedIn:"root"})};export{v};
@@ -0,0 +1 @@
1
+ import {g,ao as W,F,C as Ce,dm as N,dg as k,aJ as Tr,G as Gi,bS as Ea,M as By,a7 as ya,Q as br,b as U$1,e as xw,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,v as eC,s as rC,ac as gC,y as oC,a8 as Yg,u as bg,a9 as lC,aa as If,ab as wf}from'./main-IZL5CRF5.js';import {d as Kn,J as Jn,Y as Yn}from'./chunk-JKBba9WI.js';import'./chunk-Co47-WQ-.js';import'./chunk-C2h5l5r_.js';var j=(n,e)=>e.key;function z(n,e){n&1&&(ws(0,"p",2),GC(1,"Loading AI models\u2026"),pl());}function B(n,e){n&1&&(ws(0,"p",3),GC(1,"No AI models configured."),pl());}function H(n,e){n&1&&(ws(0,"ds-tag",11),GC(1,"Read-only"),pl());}function J(n,e){if(n&1){let t=lC();ws(0,"button",14),Rg("click",function(){If(t);let s=gC().$implicit,r=gC(2);return wf(r.edit(s))}),GC(1,"Edit"),pl(),ws(2,"button",15),Rg("click",function(){If(t);let s=gC().$implicit,r=gC(2);return wf(r.delete(s))}),GC(3,"Delete"),pl();}}function U(n,e){n&1&&(ws(0,"button",13),GC(1,"Inherited"),pl());}function q(n,e){if(n&1&&(ws(0,"tr")(1,"td",7),GC(2),pl(),ws(3,"td"),GC(4),pl(),ws(5,"td",8),GC(6),pl(),ws(7,"td")(8,"div",9)(9,"ds-tag",10),GC(10),pl(),Jw(11,H,2,0,"ds-tag",11),pl()(),ws(12,"td",12),Jw(13,J,4,0)(14,U,2,0,"button",13),pl()()),n&2){let t=e.$implicit;XE(2),Yg(t.model.alias??t.model.apiModelName),XE(2),Yg(t.providerName),XE(2),Yg(t.model.apiModelName),XE(3),bg("variant",t.scope==="platform"?"neutral":"accent"),XE(),Yg(t.scope==="platform"?"Platform":"Namespace"),XE(),eC(t.scope==="platform"?11:-1),XE(2),eC(t.scope==="namespace"?13:14);}}function G(n,e){if(n&1&&(ws(0,"div",4)(1,"table",5)(2,"thead")(3,"tr")(4,"th"),GC(5,"Name"),pl(),ws(6,"th"),GC(7,"Provider"),pl(),ws(8,"th"),GC(9,"API model name"),pl(),ws(10,"th"),GC(11,"Scope"),pl(),ws(12,"th")(13,"span",6),GC(14,"Actions"),pl()()()(),ws(15,"tbody"),rC(16,q,15,7,"tr",null,j),pl()()()),n&2){let t=gC();XE(16),oC(t.rows());}}var V=class n{route=g(W);router=g(F);destroyRef=g(Ce);aiModelController=g(N);aiProviderController=g(k);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new Tr(void 0);isLoading=Gi(true);rows=Gi([]);data$=this.refresh$.pipe(Ea(()=>(this.isLoading.set(true),By({namespace:this.aiModelController.listByNamespaceIdAiModel(this.namespaceId),platform:this.aiModelController.listPlatformLevelAiModel().pipe(ya(()=>br([]))),providers:this.aiProviderController.listAiProvider(this.namespaceId)}))));constructor(){this.data$.pipe(U$1(this.destroyRef)).subscribe({next:({namespace:e,platform:t,providers:d})=>{let s=new Map(d.map(r=>[r.id??"",r.name]));this.rows.set([...t.map((r,g)=>({key:`platform:${r.id??g}`,model:r,providerName:s.get(r.aiProviderId)??r.aiProviderId,scope:"platform"})),...e.map((r,g)=>({key:`namespace:${r.id??g}`,model:r,providerName:s.get(r.aiProviderId)??r.aiProviderId,scope:"namespace"}))]),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"ai-models","new"]);}edit(e){e.scope==="platform"||!e.model.id||this.router.navigate(["/agentos",this.namespaceId,"ai-models",e.model.id,"edit"]);}delete(e){e.scope==="platform"||!e.model.id||!confirm(`Delete AI model \u201C${e.model.alias??e.model.apiModelName}\u201D?`)||this.aiModelController.deleteAiModel(e.model.id).pipe(U$1(this.destroyRef)).subscribe(()=>this.refresh$.next());}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=xw({type:n,selectors:[["agentos-namespace-ai-models"]],decls:6,vars:1,consts:[["title","AI models","description","AI models configured for this namespace, including models inherited from the platform."],["type","button",1,"ai-models__new",3,"click"],["role","status",1,"ai-models__status"],[1,"ai-models__status"],[1,"ai-models__table-wrap"],["dsTable",""],[1,"sr-only"],[1,"ai-models__name"],[1,"ai-models__secondary"],[1,"ai-models__tags"],[3,"variant"],["variant","outline"],[1,"ai-models__actions"],["type","button","disabled",""],["type","button",3,"click"],["type","button",1,"ai-models__delete",3,"click"]],template:function(t,d){t&1&&(ws(0,"ds-section-header",0)(1,"button",1),Rg("click",function(){return d.openCreateForm()}),GC(2,"New AI model"),pl()(),Jw(3,z,2,0,"p",2)(4,B,2,0,"p",3)(5,G,18,0,"div",4)),t&2&&(XE(3),eC(d.isLoading()?3:d.rows().length===0?4:5));},dependencies:[Kn,Jn,Yn],styles:[".ai-models__new[_ngcontent-%COMP%]{padding:7px 12px;border:1px solid var(--color-accent);border-radius:0;background:var(--color-accent);color:var(--color-bg);cursor:pointer;font-family:var(--font-heading);font-size:14px;font-weight:600}.ai-models__status[_ngcontent-%COMP%]{margin:20px 8px;color:var(--color-text-secondary)}.ai-models__table-wrap[_ngcontent-%COMP%]{overflow-x:auto}table.ds-table[_ngcontent-%COMP%]{width:100%;border-collapse:collapse;font-size:14px}table.ds-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid var(--color-divider);color:var(--color-neutral-600);font-size:11px;letter-spacing:.08em;text-align:left;text-transform:uppercase}table.ds-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid color-mix(in srgb,var(--color-text) 8%,transparent)}table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.ai-models__name[_ngcontent-%COMP%]{font-weight:500}.ai-models__secondary[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.ai-models__tags[_ngcontent-%COMP%]{display:flex;gap:4px;flex-wrap:wrap}.ai-models__actions[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;gap:4px;white-space:nowrap}.ai-models__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{padding:4px 7px;border:1px solid transparent;background:transparent;color:var(--color-accent);cursor:pointer;font:inherit}.ai-models__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-100)}.ai-models__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:disabled{color:var(--color-neutral-600);cursor:default}.ai-models__actions[_ngcontent-%COMP%] .ai-models__delete[_ngcontent-%COMP%]{color:var(--color-error)}.sr-only[_ngcontent-%COMP%]{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}"]})};export{V as NamespaceAiModelsComponent};
@@ -0,0 +1 @@
1
+ import {n}from'./chunk-CfgXrte_.js';import {O}from'./chunk-IJRyzpuP.js';import {v}from'./chunk-D0LqUuf0.js';import {g,ao as W,F as F$1,C as Ce,G as Gi,b as U$1,r as re,bS as Ea,Q as br,e as xw,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,v as eC,s as rC,ac as gC,y as oC,a9 as lC,a8 as Yg,u as bg,aa as If,ab as wf}from'./main-IZL5CRF5.js';import'./chunk-WMGAW86u.js';import {d as Kn,J as Jn,Y as Yn}from'./chunk-JKBba9WI.js';import'./chunk-Co47-WQ-.js';import'./chunk-C2h5l5r_.js';import'./chunk-CM_kdC9n.js';import'./chunk-4OgRX34W.js';var $=(i,e)=>e.key;function q(i,e){i&1&&(ws(0,"p",2),GC(1,"Loading AI providers\u2026"),pl());}function z(i,e){i&1&&(ws(0,"p",3),GC(1,"No AI providers available."),pl());}function j(i,e){i&1&&(ws(0,"ds-tag",11),GC(1,"Read-only"),pl());}function G(i,e){if(i&1){let t=lC();ws(0,"button",13),Rg("click",function(){If(t);let c=gC().$implicit,l=gC(2);return wf(l.edit(c))}),GC(1,"Edit"),pl(),ws(2,"button",15),Rg("click",function(){If(t);let c=gC().$implicit,l=gC(2);return wf(l.delete(c))}),GC(3,"Delete"),pl();}}function H(i,e){i&1&&(ws(0,"button",14),GC(1,"Inherited"),pl());}function U(i,e){if(i&1){let t=lC();ws(0,"tr")(1,"td",7),GC(2),pl(),ws(3,"td",8),GC(4),pl(),ws(5,"td")(6,"div",9)(7,"ds-tag",10),GC(8),pl(),Jw(9,j,2,0,"ds-tag",11),pl()(),ws(10,"td",12)(11,"button",13),Rg("click",function(){let c=If(t).$implicit,l=gC(2);return wf(l.duplicate(c))}),GC(12,"Duplicate"),pl(),Jw(13,G,4,0)(14,H,2,0,"button",14),pl()();}if(i&2){let t=e.$implicit;XE(2),Yg(t.config.name),XE(2),Yg(t.config.apiType),XE(3),bg("variant",t.scopeLabel==="Platform"?"neutral":t.scopeLabel==="Personal"?"outline":"accent"),XE(),Yg(t.scopeLabel),XE(),eC(t.canMutate?-1:9),XE(4),eC(t.canMutate?13:14);}}function B(i,e){if(i&1&&(ws(0,"div",4)(1,"table",5)(2,"thead")(3,"tr")(4,"th"),GC(5,"Name"),pl(),ws(6,"th"),GC(7,"API type"),pl(),ws(8,"th"),GC(9,"Scope"),pl(),ws(10,"th")(11,"span",6),GC(12,"Actions"),pl()()()(),ws(13,"tbody"),rC(14,U,15,6,"tr",null,$),pl()()()),i&2){let t=gC();XE(14),oC(t.rows());}}var F=class i{route=g(W);router=g(F$1);destroyRef=g(Ce);state=g(O);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isAdmin=Gi(false);isLoading=Gi(true);rows=Gi([]);ngOnInit(){this.route.paramMap.pipe(U$1(this.destroyRef)).subscribe(e=>{let t=e.get("namespaceId")??"";t&&t!==this.namespaceId&&(this.namespaceId=t),this.state.setNamespace(t);}),this.route.paramMap.pipe(re(e=>e.get("namespaceId")??""),Ea(e=>e?this.namespaceRole.isAdminOfNamespace$(e):br(false)),U$1(this.destroyRef)).subscribe(e=>this.isAdmin.set(e)),this.state.vm$.pipe(U$1(this.destroyRef)).subscribe({next:e=>{this.rows.set(this.toRows(e)),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"ai-providers","new"],{queryParams:{scope:n(this.isAdmin())}});}edit(e){!e.canMutate||!e.config.id||this.router.navigate(["/agentos",this.namespaceId,"ai-providers",e.config.id,"edit"],{queryParams:{scope:e.scope}});}delete(e){!e.canMutate||!e.config.id||!confirm(`Delete AI provider \u201C${e.config.name}\u201D?`)||this.state.delete(e.config.id,e.scope).pipe(U$1(this.destroyRef)).subscribe();}duplicate(e){if(!e.config.id)return;let t=e.scope==="platform"||e.scope==="namespace"&&!this.isAdmin()?"userOnNs":e.scope;this.router.navigate(["/agentos",this.namespaceId,"ai-providers","new"],{queryParams:{scope:t,template:e.config.id,templateScope:e.scope}});}toRows(e){return [...this.mapScope(e.platform,"platform","Platform",false),...this.mapScope(e.namespace,"namespace","Namespace",this.isAdmin()),...this.mapScope(e.userOnNs,"userOnNs","Personal",true),...this.mapScope(e.userGlobal,"userGlobal","Personal",true)]}mapScope(e,t,s,c){return e.map((l,V)=>({key:`${t}:${l.id??V}`,config:l,scope:t,scopeLabel:s,canMutate:c}))}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=xw({type:i,selectors:[["agentos-ai-providers-all-scopes"]],decls:6,vars:1,consts:[["title","AI providers","description","AI providers available in this namespace, including inherited platform and personal entries."],["type","button",1,"ai-providers__new",3,"click"],["role","status",1,"ai-providers__status"],[1,"ai-providers__status"],[1,"ai-providers__table-wrap"],["dsTable",""],[1,"sr-only"],[1,"ai-providers__name"],[1,"ai-providers__type"],[1,"ai-providers__tags"],[3,"variant"],["variant","outline"],[1,"ai-providers__actions"],["type","button",3,"click"],["type","button","disabled",""],["type","button",1,"ai-providers__delete",3,"click"]],template:function(t,s){t&1&&(ws(0,"ds-section-header",0)(1,"button",1),Rg("click",function(){return s.openCreateForm()}),GC(2," New AI provider "),pl()(),Jw(3,q,2,0,"p",2)(4,z,2,0,"p",3)(5,B,16,0,"div",4)),t&2&&(XE(3),eC(s.isLoading()?3:s.rows().length===0?4:5));},dependencies:[Kn,Jn,Yn],styles:[".ai-providers__new[_ngcontent-%COMP%]{padding:7px 12px;border:1px solid var(--color-accent);border-radius:0;background:var(--color-accent);color:var(--color-bg);cursor:pointer;font-family:var(--font-heading);font-size:14px;font-weight:600}.ai-providers__status[_ngcontent-%COMP%]{margin:20px 8px;color:var(--color-text-secondary)}.ai-providers__table-wrap[_ngcontent-%COMP%]{overflow-x:auto}table.ds-table[_ngcontent-%COMP%]{width:100%;border-collapse:collapse;font-size:14px}table.ds-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid var(--color-divider);color:var(--color-neutral-600);font-size:11px;letter-spacing:.08em;text-align:left;text-transform:uppercase}table.ds-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid color-mix(in srgb,var(--color-text) 8%,transparent)}table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.ai-providers__name[_ngcontent-%COMP%]{font-weight:500}.ai-providers__type[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.ai-providers__tags[_ngcontent-%COMP%]{display:flex;align-items:center;gap:4px;flex-wrap:wrap}.ai-providers__actions[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;gap:4px;white-space:nowrap}.ai-providers__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{padding:4px 7px;border:1px solid transparent;background:transparent;color:var(--color-accent);cursor:pointer;font:inherit}.ai-providers__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-100)}.ai-providers__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:disabled{color:var(--color-neutral-600);cursor:default}.ai-providers__actions[_ngcontent-%COMP%] .ai-providers__delete[_ngcontent-%COMP%]{color:var(--color-error)}.sr-only[_ngcontent-%COMP%]{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}"]})};export{F as AiProvidersAllScopesComponent};
@@ -1 +1 @@
1
- import {D}from'./chunk-MhUYxl3Z.js';import {o}from'./chunk-BwapsUV-.js';import {g,G,C as Ce,aJ as Tr,a as Gi,bS as Ea,cE as Dd,r as re,b as U$1,e as xw,aK as xb,J as Jw,k as ws,bf as aT,q as Rg,o as pl,af as Eg,u as CC,y as eC,X as XE,v as bg,bg as uT,ah as rT,n as GC,ac as gC,a8 as Yg,a9 as lC,aa as If,ab as wf,ag as fT}from'./main-A4H3MFZY.js';import {$ as $n,S as Se}from'./chunk-B0es9TQT.js';import'./chunk-D6Uyjin9.js';import'./chunk-CFuJNk7Q.js';var z=()=>[];function A(i,t){if(i&1&&(ws(0,"p",1),GC(1),pl()),i&2){let e=gC();XE(),Yg(e.errorMessage());}}function O(i,t){if(i&1){let e=lC();ws(0,"agentos-skill-item",5),Rg("deleteRequested",function(o){If(e);let j=gC(2);return wf(j.deleteSkill(o))}),pl();}i&2&&bg("skill",t)("platformMode",true);}function U(i,t){if(i&1&&Jw(0,O,1,2,"agentos-skill-item",4),i&2){let e,n=t.$implicit,o=gC();eC((e=o.resolveSkill(n.id))?0:-1,e);}}var V=class i{router=g(G);destroyRef=g(Ce);skillState=g(o);refresh$=new Tr(void 0);isLoading=Gi(true);errorMessage=Gi(null);skills$=this.refresh$.pipe(Ea(()=>(this.isLoading.set(true),this.skillState.listPlatform())),Dd({bufferSize:1,refCount:true}));skillItems$=this.skills$.pipe(re(t=>t.map(e=>({id:e.id??"",name:e.name,description:e.description}))));skillsById=new Map;constructor(){this.skills$.pipe(U$1(this.destroyRef)).subscribe({next:t=>{this.skillsById=new Map(t.map(e=>[e.id??"",e])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","admin"]);}openCreateForm(){this.router.navigate(["/agentos","admin","skills","new"]);}deleteSkill(t){this.errorMessage.set(null),this.skillState.delete(t.id??"").pipe(U$1(this.destroyRef)).subscribe({next:()=>this.refresh$.next(),error:e=>this.errorMessage.set(e.status===403?`Deleting "${t.name}" requires platform administrator rights.`:`Deleting "${t.name}" failed.`)});}resolveSkill(t){return this.skillsById.get(t)??null}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=xw({type:i,selectors:[["agentos-platform-skills"]],decls:6,vars:8,consts:[["skillItemTpl",""],["role","alert",1,"platform-skills__error"],["title","Platform Skills","emptyMessage","No platform skills defined yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[3,"skill","platformMode"],[3,"deleteRequested","skill","platformMode"]],template:function(e,n){if(e&1&&(Jw(0,A,2,1,"p",1),ws(1,"ds-entity-list",2),aT(2,"async"),Rg("createRequested",function(){return n.openCreateForm()}),ws(3,"ds-icon-button",3),Rg("action",function(){return n.goBack()}),pl()(),Eg(4,U,1,1,"ng-template",null,0,fT)),e&2){let o=CC(5);eC(n.errorMessage()?0:-1),XE(),bg("items",uT(2,5,n.skillItems$)??rT(7,z))("loading",n.isLoading())("showCreate",true)("itemTemplate",o);}},dependencies:[$n,D,Se,xb],styles:[".platform-skills[_ngcontent-%COMP%]{display:block}.platform-skills__error[_ngcontent-%COMP%]{margin:0 0 .75rem;font-size:.875rem;color:var(--color-error, var(--red, #dc2626))}"]})};export{V as PlatformSkillsComponent};
1
+ import {D}from'./chunk-BlZg_xnX.js';import {o}from'./chunk-d0lmTRlE.js';import {g,F,C as Ce,aJ as Tr,G as Gi,bS as Ea,cE as Dd,r as re,b as U$1,e as xw,aK as xb,J as Jw,k as ws,bf as aT,q as Rg,o as pl,af as Eg,t as CC,v as eC,X as XE,u as bg,bg as uT,ah as rT,n as GC,ac as gC,a8 as Yg,a9 as lC,aa as If,ab as wf,ag as fT}from'./main-IZL5CRF5.js';import {$ as $n,S as Se}from'./chunk-JKBba9WI.js';import'./chunk-Co47-WQ-.js';import'./chunk-C2h5l5r_.js';var z=()=>[];function A(i,t){if(i&1&&(ws(0,"p",1),GC(1),pl()),i&2){let e=gC();XE(),Yg(e.errorMessage());}}function O(i,t){if(i&1){let e=lC();ws(0,"agentos-skill-item",5),Rg("deleteRequested",function(o){If(e);let j=gC(2);return wf(j.deleteSkill(o))}),pl();}i&2&&bg("skill",t)("platformMode",true);}function U(i,t){if(i&1&&Jw(0,O,1,2,"agentos-skill-item",4),i&2){let e,n=t.$implicit,o=gC();eC((e=o.resolveSkill(n.id))?0:-1,e);}}var V=class i{router=g(F);destroyRef=g(Ce);skillState=g(o);refresh$=new Tr(void 0);isLoading=Gi(true);errorMessage=Gi(null);skills$=this.refresh$.pipe(Ea(()=>(this.isLoading.set(true),this.skillState.listPlatform())),Dd({bufferSize:1,refCount:true}));skillItems$=this.skills$.pipe(re(t=>t.map(e=>({id:e.id??"",name:e.name,description:e.description}))));skillsById=new Map;constructor(){this.skills$.pipe(U$1(this.destroyRef)).subscribe({next:t=>{this.skillsById=new Map(t.map(e=>[e.id??"",e])),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}goBack(){this.router.navigate(["/agentos","admin"]);}openCreateForm(){this.router.navigate(["/agentos","admin","skills","new"]);}deleteSkill(t){this.errorMessage.set(null),this.skillState.delete(t.id??"").pipe(U$1(this.destroyRef)).subscribe({next:()=>this.refresh$.next(),error:e=>this.errorMessage.set(e.status===403?`Deleting "${t.name}" requires platform administrator rights.`:`Deleting "${t.name}" failed.`)});}resolveSkill(t){return this.skillsById.get(t)??null}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=xw({type:i,selectors:[["agentos-platform-skills"]],decls:6,vars:8,consts:[["skillItemTpl",""],["role","alert",1,"platform-skills__error"],["title","Platform Skills","emptyMessage","No platform skills defined yet. Add one above.","cardMinWidth","400px",3,"createRequested","items","loading","showCreate","itemTemplate"],["toolbar-start","","icon","arrow_back","title","Back",3,"action"],[3,"skill","platformMode"],[3,"deleteRequested","skill","platformMode"]],template:function(e,n){if(e&1&&(Jw(0,A,2,1,"p",1),ws(1,"ds-entity-list",2),aT(2,"async"),Rg("createRequested",function(){return n.openCreateForm()}),ws(3,"ds-icon-button",3),Rg("action",function(){return n.goBack()}),pl()(),Eg(4,U,1,1,"ng-template",null,0,fT)),e&2){let o=CC(5);eC(n.errorMessage()?0:-1),XE(),bg("items",uT(2,5,n.skillItems$)??rT(7,z))("loading",n.isLoading())("showCreate",true)("itemTemplate",o);}},dependencies:[$n,D,Se,xb],styles:[".platform-skills[_ngcontent-%COMP%]{display:block}.platform-skills__error[_ngcontent-%COMP%]{margin:0 0 .75rem;font-size:.875rem;color:var(--color-error, var(--red, #dc2626))}"]})};export{V as PlatformSkillsComponent};
@@ -0,0 +1 @@
1
+ import {c}from'./chunk-cAni-AV8.js';import {g,ao as W$1,F,C as Ce,G as Gi,M as By,a7 as ya,Q as br,b as U$1,x,w,dc as Re,de as Ve,e as xw,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,v as eC,s as rC,ac as gC,y as oC,a8 as Yg,u as bg,a9 as lC,aa as If,ab as wf}from'./main-IZL5CRF5.js';import {d as Kn,J as Jn,Y as Yn}from'./chunk-JKBba9WI.js';import'./chunk-Co47-WQ-.js';import'./chunk-C2h5l5r_.js';var z=(n,t)=>t.key;function A(n,t){n&1&&(ws(0,"p",2),GC(1,"Loading scheduled prompts\u2026"),pl());}function j(n,t){n&1&&(ws(0,"p",3),GC(1,"No scheduled prompts available."),pl());}function K(n,t){if(n&1&&(ws(0,"span",8),GC(1),pl()),n&2){let e=gC().$implicit;XE(),Yg(e.prompt.description);}}function W(n,t){n&1&&(ws(0,"ds-tag",11),GC(1,"Read-only"),pl());}function q(n,t){if(n&1){let e=lC();ws(0,"button",14),Rg("click",function(){If(e);let d=gC().$implicit,l=gC(2);return wf(l.toggle(d))}),GC(1),pl(),ws(2,"button",14),Rg("click",function(){If(e);let d=gC().$implicit,l=gC(2);return wf(l.edit(d))}),GC(3,"Edit"),pl(),ws(4,"button",15),Rg("click",function(){If(e);let d=gC().$implicit,l=gC(2);return wf(l.delete(d))}),GC(5,"Delete"),pl();}if(n&2){let e=gC().$implicit;XE(),Yg(e.prompt.enabled?"Disable":"Enable");}}function B(n,t){n&1&&(ws(0,"button",13),GC(1,"Inherited"),pl());}function H(n,t){if(n&1&&(ws(0,"tr")(1,"td")(2,"span",7),GC(3),pl(),Jw(4,K,2,1,"span",8),pl(),ws(5,"td"),GC(6),pl(),ws(7,"td")(8,"ds-tag",9),GC(9),pl()(),ws(10,"td")(11,"div",10)(12,"ds-tag",9),GC(13),pl(),Jw(14,W,2,0,"ds-tag",11),pl()(),ws(15,"td",12),Jw(16,q,6,1)(17,B,2,0,"button",13),pl()()),n&2){let e=t.$implicit,r=gC(2);XE(3),Yg(e.prompt.name),XE(),eC(e.prompt.description?4:-1),XE(2),Yg(r.scheduleLabel(e.prompt)),XE(2),bg("variant",e.prompt.enabled?"accent":"outline"),XE(),Yg(e.prompt.enabled?"Enabled":"Disabled"),XE(3),bg("variant",e.scope==="platform"?"neutral":"accent"),XE(),Yg(e.scope==="platform"?"Platform":"Namespace"),XE(),eC(e.scope==="platform"?14:-1),XE(2),eC(e.scope==="namespace"?16:17);}}function J(n,t){if(n&1&&(ws(0,"div",4)(1,"table",5)(2,"thead")(3,"tr")(4,"th"),GC(5,"Name"),pl(),ws(6,"th"),GC(7,"Schedule"),pl(),ws(8,"th"),GC(9,"Status"),pl(),ws(10,"th"),GC(11,"Scope"),pl(),ws(12,"th")(13,"span",6),GC(14,"Actions"),pl()()()(),ws(15,"tbody"),rC(16,H,18,9,"tr",null,z),pl()()()),n&2){let e=gC();XE(16),oC(e.rows());}}var U=class n{route=g(W$1);router=g(F);destroyRef=g(Ce);state=g(c);namespaceId=this.route.snapshot.params.namespaceId;rows=Gi([]);isLoading=Gi(true);constructor(){By({platform:this.state.listPlatform().pipe(ya(()=>br([]))),namespace:this.state.listByNamespace(this.namespaceId)}).pipe(U$1(this.destroyRef)).subscribe({next:({platform:t,namespace:e})=>{this.rows.set([...t.map((r,d)=>({key:`platform:${r.id??d}`,prompt:r,scope:"platform"})),...e.map((r,d)=>({key:`namespace:${r.id??d}`,prompt:r,scope:"namespace"}))]),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"scheduled-prompts","new"]);}edit(t){t.scope==="platform"||!t.prompt.id||this.router.navigate(["/agentos",this.namespaceId,"scheduled-prompts",t.prompt.id,"edit"]);}toggle(t){if(t.scope==="platform")return;(t.prompt.enabled?this.state.disable(t.prompt.id??""):this.state.enable(t.prompt.id??"")).pipe(U$1(this.destroyRef)).subscribe(r=>this.rows.update(d=>d.map(l=>l.key===t.key?x(w({},l),{prompt:r}):l)));}delete(t){t.scope==="platform"||!t.prompt.id||!confirm(`Delete scheduled prompt \u201C${t.prompt.name}\u201D?`)||this.state.delete(t.prompt.id).pipe(U$1(this.destroyRef)).subscribe(()=>this.rows.update(e=>e.filter(r=>r.key!==t.key)));}scheduleLabel(t){let e=t.recurrence,r=e.unit===Re.WEEK?"week":"month",d=e.unit===Re.WEEK&&e.days?.length?` (${e.days.map(l=>Ve[l]??l).join(", ")})`:"";return `Every ${r}${d} at ${e.timeUtc} UTC`}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=xw({type:n,selectors:[["agentos-scheduled-prompt-list"]],decls:6,vars:1,consts:[["title","Scheduled prompts","description","Scheduled prompts for this namespace, including schedules inherited from the platform."],["type","button",1,"scheduled-prompts__new",3,"click"],["role","status",1,"scheduled-prompts__status"],[1,"scheduled-prompts__status"],[1,"scheduled-prompts__table-wrap"],["dsTable",""],[1,"sr-only"],[1,"scheduled-prompts__name"],[1,"scheduled-prompts__description"],[3,"variant"],[1,"scheduled-prompts__tags"],["variant","outline"],[1,"scheduled-prompts__actions"],["type","button","disabled",""],["type","button",3,"click"],["type","button",1,"scheduled-prompts__delete",3,"click"]],template:function(e,r){e&1&&(ws(0,"ds-section-header",0)(1,"button",1),Rg("click",function(){return r.openCreateForm()}),GC(2," New scheduled prompt "),pl()(),Jw(3,A,2,0,"p",2)(4,j,2,0,"p",3)(5,J,18,0,"div",4)),e&2&&(XE(3),eC(r.isLoading()?3:r.rows().length===0?4:5));},dependencies:[Kn,Jn,Yn],styles:[".scheduled-prompts__new[_ngcontent-%COMP%]{padding:7px 12px;border:1px solid var(--color-accent);border-radius:0;background:var(--color-accent);color:var(--color-bg);cursor:pointer;font-family:var(--font-heading);font-size:14px;font-weight:600}.scheduled-prompts__status[_ngcontent-%COMP%]{margin:20px 8px;color:var(--color-text-secondary)}.scheduled-prompts__table-wrap[_ngcontent-%COMP%]{overflow-x:auto}table.ds-table[_ngcontent-%COMP%]{width:100%;border-collapse:collapse;font-size:14px}table.ds-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid var(--color-divider);color:var(--color-neutral-600);font-size:11px;letter-spacing:.08em;text-align:left;text-transform:uppercase}table.ds-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid color-mix(in srgb,var(--color-text) 8%,transparent)}table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.scheduled-prompts__name[_ngcontent-%COMP%]{display:block;font-weight:500}.scheduled-prompts__description[_ngcontent-%COMP%]{display:block;color:var(--color-text-secondary);font-size:12px}.scheduled-prompts__tags[_ngcontent-%COMP%]{display:flex;gap:4px;flex-wrap:wrap}.scheduled-prompts__actions[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;gap:4px;white-space:nowrap}.scheduled-prompts__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{padding:4px 7px;border:1px solid transparent;background:transparent;color:var(--color-accent);cursor:pointer;font:inherit}.scheduled-prompts__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-100)}.scheduled-prompts__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:disabled{color:var(--color-neutral-600);cursor:default}.scheduled-prompts__actions[_ngcontent-%COMP%] .scheduled-prompts__delete[_ngcontent-%COMP%]{color:var(--color-error)}.sr-only[_ngcontent-%COMP%]{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}"]})};export{U as ScheduledPromptListComponent};
@@ -1 +1 @@
1
- import {g,bm as Mm,a as Gi,m as mT,cF as Pb,e as xw,h as hr,j as Gn,k as ws,q as Rg,n as GC,o as pl,a3 as VI,J as Jw,X as XE,v as bg,a6 as UI,y as eC,C as Ce,x,w,Q as By,b as U,Y as x$1,b1 as On,bf as aT,ac as gC,a8 as Yg,bi as lT,cG as dT,t as rC,cH as Kw,S as Sg,z as oC,H as py,cI as xt,aw as hl,ax as gl,c9 as kf,b6 as _g,ck as Ff,T as Tg,a5 as vl,a9 as lC,cJ as Og,aa as If,ab as wf,ad as Hg}from'./main-A4H3MFZY.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,A as At,Z as Zn,c as cn,y as yt,w as wt}from'./chunk-CFuJNk7Q.js';var Ae=(o,t)=>t.date,He=(o,t)=>t.x,$e=(o,t)=>t.label;function Ve(o,t){o&1&&(hl(0,"div",0),GC(1,"No daily data points for this period."),gl());}function Le(o,t){if(o&1&&(kf(),_g(0,"rect",18)),o&2){let e=gC().$implicit,n=gC(2);Tg("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH);}}function Ge(o,t){if(o&1&&(kf(),_g(0,"rect",19)(1,"rect",20)),o&2){let e=gC().$implicit,n=gC(2);Tg("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),XE(),Tg("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0);}}function Ye(o,t){if(o&1){let e=lC();kf(),hl(0,"g",15),Og("mouseenter",function(i){let d=If(e).$implicit,u=gC(2);return wf(u.showTooltip(i,d.point))})("mousemove",function(i){let d=If(e).$implicit,u=gC(2);return wf(u.showTooltip(i,d.point))})("mouseleave",function(){If(e);let i=gC(2);return wf(i.hideTooltip())}),_g(1,"rect",16)(2,"rect",17),Jw(3,Le,1,4,":svg:rect",18)(4,Ge,2,8),gl();}if(o&2){let e=t.$implicit,n=gC(2);Tg("transform","translate("+e.xGroup+",0)"),XE(),Tg("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),XE(),Tg("y",n.yBase-e.costH)("width",e.w)("height",e.costH),XE(),eC(e.tokensStubH!==null?3:4);}}function We(o,t){if(o&1&&(kf(),hl(0,"text",5),GC(1),gl()),o&2){let e=t.$implicit,n=gC(2);Tg("x",e.x)("y",n.yAxis),XE(),Yg(e.label);}}function je(o,t){if(o&1&&(hl(0,"div",24),GC(1),gl(),hl(2,"div",25),GC(3),gl()),o&2){let e=t.$implicit;XE(),Yg(e.label),XE(2),Yg(e.value);}}function ze(o,t){if(o&1&&(hl(0,"div",21)(1,"div",22),GC(2),gl(),hl(3,"div",23),rC(4,je,4,2,null,null,$e),gl()()),o&2){let e=gC(2);Hg("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),XE(2),Yg(e.tooltip().data.date),XE(2),oC(e.tooltipLines());}}function Xe(o,t){if(o&1&&(hl(0,"div",8)(1,"span",10),GC(2),gl()()),o&2){let e=gC(2);XE(2),Yg(e.tokenCoverageLabel());}}function Je(o,t){if(o&1&&(hl(0,"div",1),kf(),hl(1,"svg",2),_g(2,"line",3)(3,"line",3),rC(4,Ye,5,8,":svg:g",4,Ae),rC(6,We,2,3,":svg:text",5,He),gl(),Jw(8,ze,6,5,"div",6),Ff(),hl(9,"div",7)(10,"div",8),_g(11,"span",9),hl(12,"span",10),GC(13,"Cost (per day)"),gl(),hl(14,"span",11),GC(15),gl()(),hl(16,"div",8),_g(17,"span",12),hl(18,"span",10),GC(19,"Prompt tokens"),gl()(),hl(20,"div",8),_g(21,"span",13),hl(22,"span",10),GC(23,"Completion tokens"),gl()(),hl(24,"div",8),_g(25,"span",14),hl(26,"span",10),GC(27,"Tokens missing"),gl()(),hl(28,"div",8)(29,"span",10),GC(30,"Tokens scale"),gl(),hl(31,"span",11),GC(32),gl()(),Jw(33,Xe,3,1,"div",8),gl()()),o&2){let e=gC();XE(),Tg("viewBox",e.viewBox),XE(),Tg("y1",e.yTop)("x2",720)("y2",e.yTop),XE(),Tg("y1",e.yBase)("x2",720)("y2",e.yBase),XE(),oC(e.bars()),XE(2),oC(e.axisLabels()),XE(2),eC(e.tooltip().visible&&e.tooltip().data?8:-1),XE(7),vl("max ",e.maxCostLabel()),XE(17),vl("max ",e.maxTokensLabel()),XE(),eC(e.tokenCoverageLabel()?33:-1);}}var j=class o{points=[];width=720;height=240;paddingX=12;paddingY=16;bottomAxisH=48;viewBox=`0 0 ${this.width} ${this.height}`;innerW=this.width-this.paddingX*2;innerH=this.height-this.paddingY*2-this.bottomAxisH;barGap=6;groupGap=14;safePoints=mT(()=>(this.points??[]).filter(t=>!!t.date));maxCost=mT(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=mT(()=>{let t=this.safePoints().map(e=>{let n=e.promptTokens??null,i=e.completionTokens??null;return n===null&&i===null?null:(n??0)+(i??0)}).filter(e=>e!==null);return Math.max(0,...t)});tokenCoverageLabel=mT(()=>{let t=this.safePoints();return t.length===0?"":`Tokens available for ${t.filter(n=>n.promptTokens!==null||n.completionTokens!==null).length}/${t.length} days`});maxCostLabel=mT(()=>"$"+(new Pb("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=mT(()=>new Pb("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=Gi({visible:false,x:0,y:0,data:null});toTooltipData(t){let e=t.promptTokens,n=t.completionTokens,i=e===null&&n===null?null:(e??0)+(n??0);return {date:t.date,cost:t.cost??0,promptTokens:e,completionTokens:n,totalTokens:i,callCount:t.callCount??0}}showTooltip(t,e){let i=t.currentTarget?.closest(".chart")?.getBoundingClientRect(),d=i?t.clientX-i.left:t.clientX,u=i?t.clientY-i.top:t.clientY,f=320,k=170,U=12,C=i?Math.max(0,i.width-f-U):d,B=i?Math.max(0,i.height-k-U):u,F=i?Math.min(Math.max(0,d),C):d,ne=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:true,x:F,y:ne,data:this.toTooltipData(e)});}hideTooltip(){this.tooltip.update(t=>x(w({},t),{visible:false}));}formatTokens(t){return t===null?"\u2014":new Pb("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return "$"+(new Pb("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=mT(()=>{let t=this.tooltip(),e=t.data;return !t.visible||!e?[]:[{label:"Cost",value:this.formatCost(e.cost)},{label:"Prompt tokens",value:this.formatTokens(e.promptTokens)},{label:"Completion tokens",value:this.formatTokens(e.completionTokens)},{label:"Total tokens",value:this.formatTokens(e.totalTokens)},{label:"Calls",value:`${e.callCount}`}]});bars=mT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let n=(this.innerW-(e-1)*this.groupGap)/e,i=Math.max(2,n),d=(i-this.barGap)/2,u=Math.max(1,d),f=this.maxCost()||1,k=this.maxTokens()||1,U=45;return t.map((C,B)=>{let F=this.paddingX+B*(i+this.groupGap),Ie=(C.cost??0)/f*this.innerH,oe=C.promptTokens,ae=C.completionTokens,Z=oe!==null||ae!==null,Ne=oe??0,Ue=ae??0,Be=Z?Ne/k*this.innerH:null,Fe=Z?Ue/k*this.innerH:null;return {date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ie,xTokens:F+u+this.barGap,promptH:Be,completionH:Fe,tokensStubH:Z?null:U}})});axisLabels=mT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let i=Math.max(1,Math.ceil(e/8)),d=(this.innerW-(e-1)*this.groupGap)/e,u=Math.max(2,d);return t.map((f,k)=>({p:f,i:k})).filter(({i:f})=>f%i===0||f===e-1).map(({p:f,i:k})=>{let C=this.paddingX+k*(u+this.groupGap)+u/2,B=f.date.slice(5);return {x:C,label:B}})});yTop=this.paddingY;yBase=this.paddingY+this.innerH;yAxis=this.yBase+28;static \u0275fac=function(e){return new(e||o)};static \u0275cmp=xw({type:o,selectors:[["app-daily-series-chart"]],inputs:{points:"points"},decls:2,vars:1,consts:[[1,"muted"],[1,"chart"],["preserveAspectRatio","none","role","img","aria-label","Daily token and cost usage",1,"chart__svg"],["x1","0",1,"chart__grid"],[1,"chart__day"],["text-anchor","middle",1,"chart__axis-label"],[1,"chart__tooltip",3,"left","top"],[1,"chart__legend"],[1,"chart__legend-item"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--cost"],[1,"chart__legend-label"],[1,"chart__legend-value"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--prompt"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--completion"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--tokens-missing"],[1,"chart__day",3,"mouseenter","mousemove","mouseleave"],["x","0",1,"chart__hover"],["x","0",1,"chart__bar","chart__bar--cost"],[1,"chart__bar","chart__bar--tokens-missing"],[1,"chart__bar","chart__bar--prompt"],[1,"chart__bar","chart__bar--completion"],[1,"chart__tooltip"],[1,"chart__tooltip-title"],[1,"chart__tooltip-grid"],[1,"chart__tooltip-label"],[1,"chart__tooltip-value"]],template:function(e,n){e&1&&Jw(0,Ve,2,0,"div",0)(1,Je,34,11,"div",1),e&2&&eC(n.safePoints().length===0?0:1);},styles:[".chart[_ngcontent-%COMP%]{display:grid;gap:.5rem;position:relative}.chart__svg[_ngcontent-%COMP%]{width:100%;height:260px;display:block;border-radius:12px;background:var(--color-bg-secondary, rgba(255, 255, 255, .72));border:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.chart__grid[_ngcontent-%COMP%]{stroke:var(--color-border-light, rgba(0, 0, 0, .08));stroke-width:1}.chart__day[_ngcontent-%COMP%]{cursor:default}.chart__hover[_ngcontent-%COMP%]{fill:transparent}.chart__day[_ngcontent-%COMP%]:hover .chart__hover[_ngcontent-%COMP%]{fill:var(--color-bg-hover, rgba(0, 0, 0, .03))}.chart__tooltip[_ngcontent-%COMP%]{position:absolute;z-index:2;min-width:220px;max-width:320px;padding:10px 12px;border-radius:12px;background:rgb(var(--color-bg-secondary-rgb, 255 255 255)/1);border:1px solid var(--color-border-light, rgba(0, 0, 0, .08));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .12));pointer-events:none}.chart__tooltip-title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:6px}.chart__tooltip-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr auto;column-gap:10px;row-gap:4px}.chart__tooltip-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__tooltip-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums;text-align:right}.chart__bar[_ngcontent-%COMP%]{shape-rendering:geometricPrecision;rx:2;ry:2}.chart__bar--cost[_ngcontent-%COMP%]{fill:var(--color-primary, #007aff);opacity:.85}.chart__bar--prompt[_ngcontent-%COMP%]{fill:var(--color-success, #34c759);opacity:.85}.chart__bar--completion[_ngcontent-%COMP%]{fill:var(--color-warning, #ff9500);opacity:.85}.chart__bar--tokens-missing[_ngcontent-%COMP%]{fill:transparent;stroke:var(--color-text-secondary, rgba(29, 29, 31, .55));stroke-width:1.5;stroke-dasharray:4 3}.chart__axis-label[_ngcontent-%COMP%]{fill:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:12px;font-variant-numeric:tabular-nums}.chart__legend[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:.75rem;flex-wrap:wrap}.chart__legend-item[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:baseline}.chart__legend-swatch[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:3px;align-self:center}.chart__legend-swatch--cost[_ngcontent-%COMP%]{background:var(--color-primary, #007aff)}.chart__legend-swatch--prompt[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.chart__legend-swatch--completion[_ngcontent-%COMP%]{background:var(--color-warning, #ff9500)}.chart__legend-swatch--tokens-missing[_ngcontent-%COMP%]{background:transparent;border:1px dashed var(--color-text-secondary, rgba(29, 29, 31, .55))}.chart__legend-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__legend-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}"]})};var X=class o{http=g(py);getTokenUsage(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage",{params:e})}getTokenUsageSeries(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage/series",{params:e})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x$1({token:o,factory:o.\u0275fac,providedIn:"root"})};function Pe(o){return `${o}`.padStart(2,"0")}function we(o){return `${o.getUTCFullYear()}-${Pe(o.getUTCMonth()+1)}-${Pe(o.getUTCDate())}`}function qe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Ke(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var J=class o{api=g(X);destroyRef=g(Ce);defaultFrom=we(qe());defaultTo=we(Ke());draftFilters=Gi({from:this.defaultFrom,to:this.defaultTo});appliedFilters=Gi({from:this.defaultFrom,to:this.defaultTo});loading=Gi(false);error=Gi(null);aggregation=Gi(null);seriesResponse=Gi(null);series=Gi(null);tokenDataPartial=Gi(false);aggregationByModelId=Gi(null);seriesByModelId=Gi(null);init(){this.reload();}setDraftFrom(t){this.draftFilters.update(e=>x(w({},e),{from:t}));}setDraftTo(t){this.draftFilters.update(e=>x(w({},e),{to:t}));}clearDraftFrom(){this.setDraftFrom(null);}clearDraftTo(){this.setDraftTo(null);}apply(){this.appliedFilters.set(this.draftFilters()),this.reload();}addNullableTokens(t,e){return t===null&&e===null?null:(t??0)+(e??0)}aggregateByModelId(t){let e=new Map;for(let n of t){let i=n.modelId,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>(i.totalTokens??0)-(n.totalTokens??0))}aggregateSeriesByModelId(t){let e=new Map;for(let n of t){let i=`${n.date}|${n.modelId}`,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{date:n.date,agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}reload(){let{from:t,to:e}=this.appliedFilters();this.loading.set(true),this.error.set(null),By({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(U(this.destroyRef)).subscribe({next:({aggregation:n,series:i})=>{this.aggregation.set(n),this.seriesResponse.set(i);let d=i.points??[];this.series.set(d),this.tokenDataPartial.set(n.tokenDataPartial||i.tokenDataPartial);let u=this.aggregateByModelId(n.models??[]);this.aggregationByModelId.set(u),this.seriesByModelId.set(this.aggregateSeriesByModelId(d)),this.loading.set(false);},error:n=>{this.loading.set(false),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(false),this.aggregationByModelId.set(null),this.seriesByModelId.set(null),this.error.set(n instanceof Error?n.message:"Failed to load token usage");}});}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x$1({token:o,factory:o.\u0275fac,providedIn:"root"})};var q=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},De=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:q,set:q,deleteProperty:q,has:q}),K=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(De,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"call",type:o,pure:true})},Q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(De,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"apply",type:o,pure:true})};function Qe(o,t){o&1&&(ws(0,"div",23),GC(1," Partial data \u2014 token counts may not cover the full period "),pl());}function Ze(o,t){o&1&&(ws(0,"div",24),GC(1," No token data collected for this period "),pl());}function et(o,t){if(o&1&&(ws(0,"div",19)(1,"div",20)(2,"div",21),GC(3,"Total tokens"),pl(),ws(4,"div",22),GC(5),aT(6,"call"),pl()(),ws(7,"div",20)(8,"div",21),GC(9,"Total calls"),pl(),ws(10,"div",22),GC(11),pl()(),ws(12,"div",20)(13,"div",21),GC(14,"Total cost"),pl(),ws(15,"div",22),GC(16),aT(17,"apply"),pl()()(),Jw(18,Qe,2,0,"div",23),Jw(19,Ze,2,0,"div",24)),o&2){let e=gC();XE(5),Yg(lT(6,5,e.totalRow().totalTokens,e.formatTokenValue)),XE(6),Yg(e.totalRow().callCount),XE(5),Yg(dT(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),XE(2),eC(e.isPartialPeriod()?18:-1),XE(),eC(e.isMissingPeriod()?19:-1);}}function tt(o,t){o&1&&(ws(0,"div",16)(1,"div",25),GC(2,"Loading token usage\u2026"),pl()());}function nt(o,t){if(o&1&&(ws(0,"div",17)(1,"div",26),GC(2,"Failed to load"),pl(),ws(3,"div",25),GC(4),pl()()),o&2){let e=gC();XE(4),Yg(e.state.error());}}function ot(o,t){o&1&&(ws(0,"div",16)(1,"div",26),GC(2,"No data"),pl(),ws(3,"div",25),GC(4,"No token usage recorded yet for this period."),pl()());}function at(o,t){if(o&1&&(ws(0,"div",32)(1,"div",29),GC(2),pl(),ws(3,"div",29),GC(4),pl(),ws(5,"div",29),GC(6),pl(),ws(7,"div",30),GC(8),aT(9,"call"),pl(),ws(10,"div",30),GC(11),aT(12,"call"),pl(),ws(13,"div",30),GC(14),aT(15,"call"),pl(),ws(16,"div",30),GC(17),pl(),ws(18,"div",30),GC(19),aT(20,"apply"),pl()()),o&2){let e=t.$implicit,n=gC(2);XE(2),Yg(e.agentName),XE(2),Yg(e.providerName),XE(2),Yg(e.modelId),XE(2),Yg(lT(9,8,e.promptTokens,n.formatTokenValue)),XE(3),Yg(lT(12,11,e.completionTokens,n.formatTokenValue)),XE(3),Yg(lT(15,14,e.totalTokens,n.formatTokenValue)),XE(3),Yg(e.callCount),XE(2),vl(" ",dT(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ");}}function it(o,t){if(o&1&&(ws(0,"div",33)(1,"div",29),GC(2),pl(),ws(3,"div",29),GC(4),pl(),ws(5,"div",29),GC(6),pl(),ws(7,"div",30),GC(8),aT(9,"call"),pl(),ws(10,"div",30),GC(11),aT(12,"call"),pl(),ws(13,"div",30),GC(14),aT(15,"call"),pl(),ws(16,"div",30),GC(17),pl(),ws(18,"div",30),GC(19),aT(20,"apply"),pl()()),o&2){let e=gC(2);XE(2),Yg(e.totalRow().agentName),XE(2),Yg(e.totalRow().providerName),XE(2),Yg(e.totalRow().modelId),XE(2),Yg(lT(9,8,e.totalRow().promptTokens,e.formatTokenValue)),XE(3),vl(" ",lT(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),XE(3),Yg(lT(15,14,e.totalRow().totalTokens,e.formatTokenValue)),XE(3),Yg(e.totalRow().callCount),XE(2),vl(" ",dT(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ");}}function rt(o,t){if(o&1&&(ws(0,"div",18)(1,"section",16)(2,"div",26),GC(3,"Summary"),pl(),ws(4,"div",27)(5,"div",28)(6,"div",29),GC(7,"agentName"),pl(),ws(8,"div",29),GC(9,"providerName"),pl(),ws(10,"div",29),GC(11,"modelId"),pl(),ws(12,"div",30),GC(13,"promptTokens"),pl(),ws(14,"div",30),GC(15,"completionTokens"),pl(),ws(16,"div",30),GC(17,"totalTokens"),pl(),ws(18,"div",30),GC(19,"callCount"),pl(),ws(20,"div",30),GC(21,"cost"),pl()(),ws(22,"div",31),rC(23,at,21,21,"div",32,Kw().trackRow,true),Jw(25,it,21,21,"div",33),pl()()(),ws(26,"section",16)(27,"div",26),GC(28,"Daily series"),pl(),Sg(29,"app-daily-series-chart",34),pl()()),o&2){let e=gC();XE(23),oC(e.rows()),XE(2),eC(e.totalRow()?25:-1),XE(4),bg("points",e.chartPoints());}}var Ee="\u2014",Oe=class o{location=g(Mm);state=g(J);view=Gi("byModel");rowsByAgent=mT(()=>this.state.aggregation()?.models??[]);totalRow=mT(()=>this.state.aggregation()?.total??null);rowsByModel=mT(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=mT(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=mT(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=mT(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=mT(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=mT(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:false});ngOnInit(){this.state.init();}onFromChange(t){this.state.setDraftFrom(t||null);}onToChange(t){this.state.setDraftTo(t||null);}clearFrom(){this.state.clearDraftFrom();}clearTo(){this.state.clearDraftTo();}apply(){this.state.apply();}aggregateDailyPoints(t){let e=new Map;for(let n of t){let i=e.get(n.date);if(!i)e.set(n.date,{date:n.date,promptTokens:n.promptTokens,completionTokens:n.completionTokens,cost:n.cost??0,callCount:n.callCount??0});else {let d=(u,f)=>u===null&&f===null?null:(u??0)+(f??0);i.promptTokens=d(i.promptTokens,n.promptTokens),i.completionTokens=d(i.completionTokens,n.completionTokens),i.cost=(i.cost??0)+(n.cost??0),i.callCount=(i.callCount??0)+(n.callCount??0);}}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}trackRow(t,e){return `${e.agentName}|${e.providerName}|${e.modelId}`}isMissingPeriod=mT(()=>{if(this.state.loading())return false;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):false});isPartialPeriod=mT(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back();}formatTokenValue(t){return t===null?Ee:new Pb("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?Ee:"$"+(new Pb("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=xw({type:o,selectors:[["app-token-usage"]],decls:41,vars:8,consts:[[1,"page"],[1,"page__header"],[1,"page__title-block"],["mat-icon-button","","title","Back",3,"click"],[1,"page__title"],[1,"page__subtitle"],[1,"filters"],[1,"filters__field"],[1,"filters__label"],[1,"filters__control"],["type","date",1,"filters__input",3,"ngModelChange","ngModel"],["type","button",1,"filters__clear",3,"click","disabled"],[1,"filters__select",3,"ngModelChange","ngModel"],["value","byModel"],["value","byAgent"],["type","button",1,"filters__apply",3,"click","disabled"],[1,"card"],[1,"card","card--error"],[1,"grid"],[1,"kpis"],[1,"kpi"],[1,"kpi__label"],[1,"kpi__value"],["title","Some calls in this period were recorded before token tracking was enabled. Token counts reflect only the portion where data was collected.",1,"hint"],["title","No token usage data was collected for this period.",1,"hint"],[1,"muted"],[1,"card__title"],[1,"table"],[1,"table__head"],[1,"table__cell"],[1,"table__cell","table__cell--num"],[1,"table__body"],[1,"table__row"],[1,"table__row","table__row--total"],[3,"points"]],template:function(e,n){e&1&&(ws(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),Rg("click",function(){return n.navigateBack()}),ws(4,"mat-icon"),GC(5,"chevron_left"),pl()(),ws(6,"div")(7,"h1",4),GC(8,"Token Usage"),pl(),ws(9,"p",5),GC(10,"Track prompt and completion token usage by agent and model."),pl()()(),ws(11,"div",6)(12,"label",7)(13,"span",8),GC(14,"From"),pl(),ws(15,"div",9)(16,"input",10),Rg("ngModelChange",function(d){return n.onFromChange(d)}),pl(),VI(),ws(17,"button",11),Rg("click",function(){return n.clearFrom()}),GC(18," Clear "),pl()()(),ws(19,"label",7)(20,"span",8),GC(21,"To"),pl(),ws(22,"div",9)(23,"input",10),Rg("ngModelChange",function(d){return n.onToChange(d)}),pl(),VI(),ws(24,"button",11),Rg("click",function(){return n.clearTo()}),GC(25," Clear "),pl()()(),ws(26,"label",7)(27,"span",8),GC(28,"View"),pl(),ws(29,"select",12),Rg("ngModelChange",function(d){return n.view.set(d)}),ws(30,"option",13),GC(31,"By model"),pl(),ws(32,"option",14),GC(33,"By agent"),pl()(),VI(),pl(),ws(34,"button",15),Rg("click",function(){return n.apply()}),GC(35,"Apply"),pl()()(),Jw(36,et,20,12),Jw(37,tt,3,0,"div",16)(38,nt,5,1,"div",17)(39,ot,5,0,"div",16)(40,rt,30,2,"div",18),pl()),e&2&&(XE(16),bg("ngModel",n.state.draftFilters().from),UI(),XE(),bg("disabled",!n.state.draftFilters().from),XE(6),bg("ngModel",n.state.draftFilters().to),UI(),XE(),bg("disabled",!n.state.draftFilters().to),XE(5),bg("ngModel",n.view()),UI(),XE(5),bg("disabled",n.state.loading()),XE(2),eC(n.totalRow()?36:-1),XE(),eC(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40));},dependencies:[ti,Qn,ei,Ye$1,At,Zn,cn,j,hr,Gn,yt,wt,K,Q],styles:[".page[_ngcontent-%COMP%]{padding:1.5rem;color:var(--color-text, #1d1d1f)}.page__header[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:1.5rem;margin-bottom:1rem}.page__title-block[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem}.page__title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:650}.page__subtitle[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.95rem}.filters[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:flex-end;gap:.75rem}.filters__field[_ngcontent-%COMP%]{display:grid;gap:.25rem}.filters__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.filters__control[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.filters__input[_ngcontent-%COMP%], .filters__select[_ngcontent-%COMP%]{height:34px;padding:0 .5rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f)}.filters__apply[_ngcontent-%COMP%], .filters__clear[_ngcontent-%COMP%]{height:34px;padding:0 .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f);cursor:pointer}.kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:.75rem 0 1rem}@media(max-width:900px){.kpis[_ngcontent-%COMP%]{grid-template-columns:1fr}}.kpi[_ngcontent-%COMP%]{border-radius:14px;padding:.75rem 1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.kpi__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.kpi__value[_ngcontent-%COMP%]{margin-top:.25rem;font-size:1.2rem;font-weight:650;font-variant-numeric:tabular-nums}.filters__apply[_ngcontent-%COMP%]{border-color:var(--color-primary, #007aff);background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff)}.filters__apply[_ngcontent-%COMP%]:disabled, .filters__clear[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1.5fr 1fr;gap:1rem;align-items:start}@media(max-width:1100px){.grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.card[_ngcontent-%COMP%]{border-radius:14px;padding:1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.card--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.card__title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:.75rem}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.table[_ngcontent-%COMP%]{overflow-x:auto}.table__head[_ngcontent-%COMP%], .table__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr 2fr 1fr 1fr 1fr .7fr 1fr;gap:.5rem;align-items:center}.table__head[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));padding:.25rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row[_ngcontent-%COMP%]{padding:.5rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row--total[_ngcontent-%COMP%]{font-weight:650;background:var(--color-bg-hover, rgba(0, 0, 0, .03));border-radius:10px;padding:.6rem .5rem;border-bottom:none;margin-top:.5rem}.table__cell[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.table__cell--num[_ngcontent-%COMP%]{text-align:right;font-variant-numeric:tabular-nums}.hint[_ngcontent-%COMP%]{margin:.25rem 0 1rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}"],changeDetection:1})};export{Oe as TokenUsageComponent};
1
+ import {g,bm as Mm,G as Gi,m as mT,cF as Pb,e as xw,h as hr,j as Gn,k as ws,q as Rg,n as GC,o as pl,a3 as VI,J as Jw,X as XE,u as bg,a6 as UI,v as eC,C as Ce,x,w,M as By,b as U,W as x$1,b1 as On,bf as aT,ac as gC,a8 as Yg,bi as lT,cG as dT,s as rC,cH as Kw,S as Sg,y as oC,D as py,cI as xt,aw as hl,ax as gl,c9 as kf,b6 as _g,ck as Ff,T as Tg,a5 as vl,a9 as lC,cJ as Og,aa as If,ab as wf,ad as Hg}from'./main-IZL5CRF5.js';import {t as ti,Q as Qn,e as ei,Y as Ye$1,A as At,Z as Zn,c as cn,y as yt,w as wt}from'./chunk-C2h5l5r_.js';var Ae=(o,t)=>t.date,He=(o,t)=>t.x,$e=(o,t)=>t.label;function Ve(o,t){o&1&&(hl(0,"div",0),GC(1,"No daily data points for this period."),gl());}function Le(o,t){if(o&1&&(kf(),_g(0,"rect",18)),o&2){let e=gC().$implicit,n=gC(2);Tg("x",e.w+6)("y",n.yBase-e.tokensStubH)("width",e.w)("height",e.tokensStubH);}}function Ge(o,t){if(o&1&&(kf(),_g(0,"rect",19)(1,"rect",20)),o&2){let e=gC().$implicit,n=gC(2);Tg("x",e.w+6)("y",n.yBase-(e.promptH??0))("width",e.w)("height",e.promptH??0),XE(),Tg("x",e.w+6)("y",n.yBase-((e.promptH??0)+(e.completionH??0)))("width",e.w)("height",e.completionH??0);}}function Ye(o,t){if(o&1){let e=lC();kf(),hl(0,"g",15),Og("mouseenter",function(i){let d=If(e).$implicit,u=gC(2);return wf(u.showTooltip(i,d.point))})("mousemove",function(i){let d=If(e).$implicit,u=gC(2);return wf(u.showTooltip(i,d.point))})("mouseleave",function(){If(e);let i=gC(2);return wf(i.hideTooltip())}),_g(1,"rect",16)(2,"rect",17),Jw(3,Le,1,4,":svg:rect",18)(4,Ge,2,8),gl();}if(o&2){let e=t.$implicit,n=gC(2);Tg("transform","translate("+e.xGroup+",0)"),XE(),Tg("y",n.yTop)("width",e.groupW)("height",n.yBase-n.yTop),XE(),Tg("y",n.yBase-e.costH)("width",e.w)("height",e.costH),XE(),eC(e.tokensStubH!==null?3:4);}}function We(o,t){if(o&1&&(kf(),hl(0,"text",5),GC(1),gl()),o&2){let e=t.$implicit,n=gC(2);Tg("x",e.x)("y",n.yAxis),XE(),Yg(e.label);}}function je(o,t){if(o&1&&(hl(0,"div",24),GC(1),gl(),hl(2,"div",25),GC(3),gl()),o&2){let e=t.$implicit;XE(),Yg(e.label),XE(2),Yg(e.value);}}function ze(o,t){if(o&1&&(hl(0,"div",21)(1,"div",22),GC(2),gl(),hl(3,"div",23),rC(4,je,4,2,null,null,$e),gl()()),o&2){let e=gC(2);Hg("left",e.tooltip().x+12,"px")("top",e.tooltip().y+12,"px"),XE(2),Yg(e.tooltip().data.date),XE(2),oC(e.tooltipLines());}}function Xe(o,t){if(o&1&&(hl(0,"div",8)(1,"span",10),GC(2),gl()()),o&2){let e=gC(2);XE(2),Yg(e.tokenCoverageLabel());}}function Je(o,t){if(o&1&&(hl(0,"div",1),kf(),hl(1,"svg",2),_g(2,"line",3)(3,"line",3),rC(4,Ye,5,8,":svg:g",4,Ae),rC(6,We,2,3,":svg:text",5,He),gl(),Jw(8,ze,6,5,"div",6),Ff(),hl(9,"div",7)(10,"div",8),_g(11,"span",9),hl(12,"span",10),GC(13,"Cost (per day)"),gl(),hl(14,"span",11),GC(15),gl()(),hl(16,"div",8),_g(17,"span",12),hl(18,"span",10),GC(19,"Prompt tokens"),gl()(),hl(20,"div",8),_g(21,"span",13),hl(22,"span",10),GC(23,"Completion tokens"),gl()(),hl(24,"div",8),_g(25,"span",14),hl(26,"span",10),GC(27,"Tokens missing"),gl()(),hl(28,"div",8)(29,"span",10),GC(30,"Tokens scale"),gl(),hl(31,"span",11),GC(32),gl()(),Jw(33,Xe,3,1,"div",8),gl()()),o&2){let e=gC();XE(),Tg("viewBox",e.viewBox),XE(),Tg("y1",e.yTop)("x2",720)("y2",e.yTop),XE(),Tg("y1",e.yBase)("x2",720)("y2",e.yBase),XE(),oC(e.bars()),XE(2),oC(e.axisLabels()),XE(2),eC(e.tooltip().visible&&e.tooltip().data?8:-1),XE(7),vl("max ",e.maxCostLabel()),XE(17),vl("max ",e.maxTokensLabel()),XE(),eC(e.tokenCoverageLabel()?33:-1);}}var j=class o{points=[];width=720;height=240;paddingX=12;paddingY=16;bottomAxisH=48;viewBox=`0 0 ${this.width} ${this.height}`;innerW=this.width-this.paddingX*2;innerH=this.height-this.paddingY*2-this.bottomAxisH;barGap=6;groupGap=14;safePoints=mT(()=>(this.points??[]).filter(t=>!!t.date));maxCost=mT(()=>Math.max(0,...this.safePoints().map(t=>t.cost??0)));maxTokens=mT(()=>{let t=this.safePoints().map(e=>{let n=e.promptTokens??null,i=e.completionTokens??null;return n===null&&i===null?null:(n??0)+(i??0)}).filter(e=>e!==null);return Math.max(0,...t)});tokenCoverageLabel=mT(()=>{let t=this.safePoints();return t.length===0?"":`Tokens available for ${t.filter(n=>n.promptTokens!==null||n.completionTokens!==null).length}/${t.length} days`});maxCostLabel=mT(()=>"$"+(new Pb("en-US").transform(this.maxCost(),"1.2-2")??"0.00"));maxTokensLabel=mT(()=>new Pb("en-US").transform(this.maxTokens(),"1.0-2")??"0");tooltip=Gi({visible:false,x:0,y:0,data:null});toTooltipData(t){let e=t.promptTokens,n=t.completionTokens,i=e===null&&n===null?null:(e??0)+(n??0);return {date:t.date,cost:t.cost??0,promptTokens:e,completionTokens:n,totalTokens:i,callCount:t.callCount??0}}showTooltip(t,e){let i=t.currentTarget?.closest(".chart")?.getBoundingClientRect(),d=i?t.clientX-i.left:t.clientX,u=i?t.clientY-i.top:t.clientY,f=320,k=170,U=12,C=i?Math.max(0,i.width-f-U):d,B=i?Math.max(0,i.height-k-U):u,F=i?Math.min(Math.max(0,d),C):d,ne=i?Math.min(Math.max(0,u),B):u;this.tooltip.set({visible:true,x:F,y:ne,data:this.toTooltipData(e)});}hideTooltip(){this.tooltip.update(t=>x(w({},t),{visible:false}));}formatTokens(t){return t===null?"\u2014":new Pb("en-US").transform(t,"1.0-2")??"0"}formatCost(t){return "$"+(new Pb("en-US").transform(t??0,"1.2-2")??"0.00")}tooltipLines=mT(()=>{let t=this.tooltip(),e=t.data;return !t.visible||!e?[]:[{label:"Cost",value:this.formatCost(e.cost)},{label:"Prompt tokens",value:this.formatTokens(e.promptTokens)},{label:"Completion tokens",value:this.formatTokens(e.completionTokens)},{label:"Total tokens",value:this.formatTokens(e.totalTokens)},{label:"Calls",value:`${e.callCount}`}]});bars=mT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let n=(this.innerW-(e-1)*this.groupGap)/e,i=Math.max(2,n),d=(i-this.barGap)/2,u=Math.max(1,d),f=this.maxCost()||1,k=this.maxTokens()||1,U=45;return t.map((C,B)=>{let F=this.paddingX+B*(i+this.groupGap),Ie=(C.cost??0)/f*this.innerH,oe=C.promptTokens,ae=C.completionTokens,Z=oe!==null||ae!==null,Ne=oe??0,Ue=ae??0,Be=Z?Ne/k*this.innerH:null,Fe=Z?Ue/k*this.innerH:null;return {date:C.date,point:C,xGroup:F,groupW:i,xCost:F,w:u,costH:Ie,xTokens:F+u+this.barGap,promptH:Be,completionH:Fe,tokensStubH:Z?null:U}})});axisLabels=mT(()=>{let t=this.safePoints(),e=t.length;if(e===0)return [];let i=Math.max(1,Math.ceil(e/8)),d=(this.innerW-(e-1)*this.groupGap)/e,u=Math.max(2,d);return t.map((f,k)=>({p:f,i:k})).filter(({i:f})=>f%i===0||f===e-1).map(({p:f,i:k})=>{let C=this.paddingX+k*(u+this.groupGap)+u/2,B=f.date.slice(5);return {x:C,label:B}})});yTop=this.paddingY;yBase=this.paddingY+this.innerH;yAxis=this.yBase+28;static \u0275fac=function(e){return new(e||o)};static \u0275cmp=xw({type:o,selectors:[["app-daily-series-chart"]],inputs:{points:"points"},decls:2,vars:1,consts:[[1,"muted"],[1,"chart"],["preserveAspectRatio","none","role","img","aria-label","Daily token and cost usage",1,"chart__svg"],["x1","0",1,"chart__grid"],[1,"chart__day"],["text-anchor","middle",1,"chart__axis-label"],[1,"chart__tooltip",3,"left","top"],[1,"chart__legend"],[1,"chart__legend-item"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--cost"],[1,"chart__legend-label"],[1,"chart__legend-value"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--prompt"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--completion"],["aria-hidden","true",1,"chart__legend-swatch","chart__legend-swatch--tokens-missing"],[1,"chart__day",3,"mouseenter","mousemove","mouseleave"],["x","0",1,"chart__hover"],["x","0",1,"chart__bar","chart__bar--cost"],[1,"chart__bar","chart__bar--tokens-missing"],[1,"chart__bar","chart__bar--prompt"],[1,"chart__bar","chart__bar--completion"],[1,"chart__tooltip"],[1,"chart__tooltip-title"],[1,"chart__tooltip-grid"],[1,"chart__tooltip-label"],[1,"chart__tooltip-value"]],template:function(e,n){e&1&&Jw(0,Ve,2,0,"div",0)(1,Je,34,11,"div",1),e&2&&eC(n.safePoints().length===0?0:1);},styles:[".chart[_ngcontent-%COMP%]{display:grid;gap:.5rem;position:relative}.chart__svg[_ngcontent-%COMP%]{width:100%;height:260px;display:block;border-radius:12px;background:var(--color-bg-secondary, rgba(255, 255, 255, .72));border:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.chart__grid[_ngcontent-%COMP%]{stroke:var(--color-border-light, rgba(0, 0, 0, .08));stroke-width:1}.chart__day[_ngcontent-%COMP%]{cursor:default}.chart__hover[_ngcontent-%COMP%]{fill:transparent}.chart__day[_ngcontent-%COMP%]:hover .chart__hover[_ngcontent-%COMP%]{fill:var(--color-bg-hover, rgba(0, 0, 0, .03))}.chart__tooltip[_ngcontent-%COMP%]{position:absolute;z-index:2;min-width:220px;max-width:320px;padding:10px 12px;border-radius:12px;background:rgb(var(--color-bg-secondary-rgb, 255 255 255)/1);border:1px solid var(--color-border-light, rgba(0, 0, 0, .08));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .12));pointer-events:none}.chart__tooltip-title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:6px}.chart__tooltip-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr auto;column-gap:10px;row-gap:4px}.chart__tooltip-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__tooltip-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums;text-align:right}.chart__bar[_ngcontent-%COMP%]{shape-rendering:geometricPrecision;rx:2;ry:2}.chart__bar--cost[_ngcontent-%COMP%]{fill:var(--color-primary, #007aff);opacity:.85}.chart__bar--prompt[_ngcontent-%COMP%]{fill:var(--color-success, #34c759);opacity:.85}.chart__bar--completion[_ngcontent-%COMP%]{fill:var(--color-warning, #ff9500);opacity:.85}.chart__bar--tokens-missing[_ngcontent-%COMP%]{fill:transparent;stroke:var(--color-text-secondary, rgba(29, 29, 31, .55));stroke-width:1.5;stroke-dasharray:4 3}.chart__axis-label[_ngcontent-%COMP%]{fill:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:12px;font-variant-numeric:tabular-nums}.chart__legend[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:.75rem;flex-wrap:wrap}.chart__legend-item[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:baseline}.chart__legend-swatch[_ngcontent-%COMP%]{width:10px;height:10px;border-radius:3px;align-self:center}.chart__legend-swatch--cost[_ngcontent-%COMP%]{background:var(--color-primary, #007aff)}.chart__legend-swatch--prompt[_ngcontent-%COMP%]{background:var(--color-success, #34c759)}.chart__legend-swatch--completion[_ngcontent-%COMP%]{background:var(--color-warning, #ff9500)}.chart__legend-swatch--tokens-missing[_ngcontent-%COMP%]{background:transparent;border:1px dashed var(--color-text-secondary, rgba(29, 29, 31, .55))}.chart__legend-label[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}.chart__legend-value[_ngcontent-%COMP%]{font-variant-numeric:tabular-nums}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}"]})};var X=class o{http=g(py);getTokenUsage(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage",{params:e})}getTokenUsageSeries(t){let e=new xt;return t.from&&(e=e.set("from",t.from)),t.to&&(e=e.set("to",t.to)),this.http.get("/api/token-usage/series",{params:e})}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x$1({token:o,factory:o.\u0275fac,providedIn:"root"})};function Pe(o){return `${o}`.padStart(2,"0")}function we(o){return `${o.getUTCFullYear()}-${Pe(o.getUTCMonth()+1)}-${Pe(o.getUTCDate())}`}function qe(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1))}function Ke(o=new Date){return new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth()+1,1))}var J=class o{api=g(X);destroyRef=g(Ce);defaultFrom=we(qe());defaultTo=we(Ke());draftFilters=Gi({from:this.defaultFrom,to:this.defaultTo});appliedFilters=Gi({from:this.defaultFrom,to:this.defaultTo});loading=Gi(false);error=Gi(null);aggregation=Gi(null);seriesResponse=Gi(null);series=Gi(null);tokenDataPartial=Gi(false);aggregationByModelId=Gi(null);seriesByModelId=Gi(null);init(){this.reload();}setDraftFrom(t){this.draftFilters.update(e=>x(w({},e),{from:t}));}setDraftTo(t){this.draftFilters.update(e=>x(w({},e),{to:t}));}clearDraftFrom(){this.setDraftFrom(null);}clearDraftTo(){this.setDraftTo(null);}apply(){this.appliedFilters.set(this.draftFilters()),this.reload();}addNullableTokens(t,e){return t===null&&e===null?null:(t??0)+(e??0)}aggregateByModelId(t){let e=new Map;for(let n of t){let i=n.modelId,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>(i.totalTokens??0)-(n.totalTokens??0))}aggregateSeriesByModelId(t){let e=new Map;for(let n of t){let i=`${n.date}|${n.modelId}`,d=e.get(i);d?(d.promptTokens=this.addNullableTokens(d.promptTokens,n.promptTokens),d.completionTokens=this.addNullableTokens(d.completionTokens,n.completionTokens),d.totalTokens=this.addNullableTokens(d.totalTokens,n.totalTokens),d.callCount+=n.callCount??0,d.cost=(d.cost??0)+(n.cost??0)):e.set(i,{date:n.date,agentName:"All agents",providerName:"all",modelId:n.modelId,promptTokens:n.promptTokens,completionTokens:n.completionTokens,totalTokens:n.totalTokens,callCount:n.callCount??0,cost:n.cost??0});}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}reload(){let{from:t,to:e}=this.appliedFilters();this.loading.set(true),this.error.set(null),By({aggregation:this.api.getTokenUsage({from:t,to:e}),series:this.api.getTokenUsageSeries({from:t,to:e})}).pipe(U(this.destroyRef)).subscribe({next:({aggregation:n,series:i})=>{this.aggregation.set(n),this.seriesResponse.set(i);let d=i.points??[];this.series.set(d),this.tokenDataPartial.set(n.tokenDataPartial||i.tokenDataPartial);let u=this.aggregateByModelId(n.models??[]);this.aggregationByModelId.set(u),this.seriesByModelId.set(this.aggregateSeriesByModelId(d)),this.loading.set(false);},error:n=>{this.loading.set(false),this.aggregation.set(null),this.seriesResponse.set(null),this.series.set(null),this.tokenDataPartial.set(false),this.aggregationByModelId.set(null),this.seriesByModelId.set(null),this.error.set(n instanceof Error?n.message:"Failed to load token usage");}});}static \u0275fac=function(e){return new(e||o)};static \u0275prov=x$1({token:o,factory:o.\u0275fac,providedIn:"root"})};var q=function(){throw new Error("DON'T USE this INSIDE A FUNCTION CALLED BY | call OR | apply IT MUST BE A PURE FUNCTION!")},De=typeof Proxy!="function"?Object.seal({}):new Proxy({},{get:q,set:q,deleteProperty:q,has:q}),K=class o{transform(t,e){if(typeof e!="function")throw new TypeError("You must pass a PURE function to | call");return e?.call(De,t)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"call",type:o,pure:true})},Q=class o{transform(t,...e){if(typeof t!="function")throw new TypeError("You must use | apply on a PURE function");return t.apply(De,e)}static \u0275fac=function(e){return new(e||o)};static \u0275pipe=On({name:"apply",type:o,pure:true})};function Qe(o,t){o&1&&(ws(0,"div",23),GC(1," Partial data \u2014 token counts may not cover the full period "),pl());}function Ze(o,t){o&1&&(ws(0,"div",24),GC(1," No token data collected for this period "),pl());}function et(o,t){if(o&1&&(ws(0,"div",19)(1,"div",20)(2,"div",21),GC(3,"Total tokens"),pl(),ws(4,"div",22),GC(5),aT(6,"call"),pl()(),ws(7,"div",20)(8,"div",21),GC(9,"Total calls"),pl(),ws(10,"div",22),GC(11),pl()(),ws(12,"div",20)(13,"div",21),GC(14,"Total cost"),pl(),ws(15,"div",22),GC(16),aT(17,"apply"),pl()()(),Jw(18,Qe,2,0,"div",23),Jw(19,Ze,2,0,"div",24)),o&2){let e=gC();XE(5),Yg(lT(6,5,e.totalRow().totalTokens,e.formatTokenValue)),XE(6),Yg(e.totalRow().callCount),XE(5),Yg(dT(17,8,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)),XE(2),eC(e.isPartialPeriod()?18:-1),XE(),eC(e.isMissingPeriod()?19:-1);}}function tt(o,t){o&1&&(ws(0,"div",16)(1,"div",25),GC(2,"Loading token usage\u2026"),pl()());}function nt(o,t){if(o&1&&(ws(0,"div",17)(1,"div",26),GC(2,"Failed to load"),pl(),ws(3,"div",25),GC(4),pl()()),o&2){let e=gC();XE(4),Yg(e.state.error());}}function ot(o,t){o&1&&(ws(0,"div",16)(1,"div",26),GC(2,"No data"),pl(),ws(3,"div",25),GC(4,"No token usage recorded yet for this period."),pl()());}function at(o,t){if(o&1&&(ws(0,"div",32)(1,"div",29),GC(2),pl(),ws(3,"div",29),GC(4),pl(),ws(5,"div",29),GC(6),pl(),ws(7,"div",30),GC(8),aT(9,"call"),pl(),ws(10,"div",30),GC(11),aT(12,"call"),pl(),ws(13,"div",30),GC(14),aT(15,"call"),pl(),ws(16,"div",30),GC(17),pl(),ws(18,"div",30),GC(19),aT(20,"apply"),pl()()),o&2){let e=t.$implicit,n=gC(2);XE(2),Yg(e.agentName),XE(2),Yg(e.providerName),XE(2),Yg(e.modelId),XE(2),Yg(lT(9,8,e.promptTokens,n.formatTokenValue)),XE(3),Yg(lT(12,11,e.completionTokens,n.formatTokenValue)),XE(3),Yg(lT(15,14,e.totalTokens,n.formatTokenValue)),XE(3),Yg(e.callCount),XE(2),vl(" ",dT(20,17,n.formatCostValue,n.isMissingPeriod(),e.cost)," ");}}function it(o,t){if(o&1&&(ws(0,"div",33)(1,"div",29),GC(2),pl(),ws(3,"div",29),GC(4),pl(),ws(5,"div",29),GC(6),pl(),ws(7,"div",30),GC(8),aT(9,"call"),pl(),ws(10,"div",30),GC(11),aT(12,"call"),pl(),ws(13,"div",30),GC(14),aT(15,"call"),pl(),ws(16,"div",30),GC(17),pl(),ws(18,"div",30),GC(19),aT(20,"apply"),pl()()),o&2){let e=gC(2);XE(2),Yg(e.totalRow().agentName),XE(2),Yg(e.totalRow().providerName),XE(2),Yg(e.totalRow().modelId),XE(2),Yg(lT(9,8,e.totalRow().promptTokens,e.formatTokenValue)),XE(3),vl(" ",lT(12,11,e.totalRow().completionTokens,e.formatTokenValue)," "),XE(3),Yg(lT(15,14,e.totalRow().totalTokens,e.formatTokenValue)),XE(3),Yg(e.totalRow().callCount),XE(2),vl(" ",dT(20,17,e.formatCostValue,e.isMissingPeriod(),e.totalRow().cost)," ");}}function rt(o,t){if(o&1&&(ws(0,"div",18)(1,"section",16)(2,"div",26),GC(3,"Summary"),pl(),ws(4,"div",27)(5,"div",28)(6,"div",29),GC(7,"agentName"),pl(),ws(8,"div",29),GC(9,"providerName"),pl(),ws(10,"div",29),GC(11,"modelId"),pl(),ws(12,"div",30),GC(13,"promptTokens"),pl(),ws(14,"div",30),GC(15,"completionTokens"),pl(),ws(16,"div",30),GC(17,"totalTokens"),pl(),ws(18,"div",30),GC(19,"callCount"),pl(),ws(20,"div",30),GC(21,"cost"),pl()(),ws(22,"div",31),rC(23,at,21,21,"div",32,Kw().trackRow,true),Jw(25,it,21,21,"div",33),pl()()(),ws(26,"section",16)(27,"div",26),GC(28,"Daily series"),pl(),Sg(29,"app-daily-series-chart",34),pl()()),o&2){let e=gC();XE(23),oC(e.rows()),XE(2),eC(e.totalRow()?25:-1),XE(4),bg("points",e.chartPoints());}}var Ee="\u2014",Oe=class o{location=g(Mm);state=g(J);view=Gi("byModel");rowsByAgent=mT(()=>this.state.aggregation()?.models??[]);totalRow=mT(()=>this.state.aggregation()?.total??null);rowsByModel=mT(()=>this.state.aggregationByModelId()??[]);chartPointsByAgent=mT(()=>{let t=this.state.series()??[];return this.aggregateDailyPoints(t)});chartPointsByModel=mT(()=>{let t=this.state.seriesByModelId()??[];return this.aggregateDailyPoints(t)});chartPoints=mT(()=>this.view()==="byAgent"?this.chartPointsByAgent():this.chartPointsByModel());rows=mT(()=>this.view()==="byAgent"?this.rowsByAgent():this.rowsByModel());isEmpty=mT(()=>{let t=this.state.aggregation();return t?(t.models?.length??0)===0&&(t.total?.callCount??0)===0:false});ngOnInit(){this.state.init();}onFromChange(t){this.state.setDraftFrom(t||null);}onToChange(t){this.state.setDraftTo(t||null);}clearFrom(){this.state.clearDraftFrom();}clearTo(){this.state.clearDraftTo();}apply(){this.state.apply();}aggregateDailyPoints(t){let e=new Map;for(let n of t){let i=e.get(n.date);if(!i)e.set(n.date,{date:n.date,promptTokens:n.promptTokens,completionTokens:n.completionTokens,cost:n.cost??0,callCount:n.callCount??0});else {let d=(u,f)=>u===null&&f===null?null:(u??0)+(f??0);i.promptTokens=d(i.promptTokens,n.promptTokens),i.completionTokens=d(i.completionTokens,n.completionTokens),i.cost=(i.cost??0)+(n.cost??0),i.callCount=(i.callCount??0)+(n.callCount??0);}}return [...e.values()].sort((n,i)=>n.date<i.date?-1:1)}trackRow(t,e){return `${e.agentName}|${e.providerName}|${e.modelId}`}isMissingPeriod=mT(()=>{if(this.state.loading())return false;let t=this.state.aggregation()?.total;return t?t.totalTokens===null&&(t.cost===null||t.cost===void 0):false});isPartialPeriod=mT(()=>!this.isMissingPeriod()&&this.state.tokenDataPartial());navigateBack(){this.location.back();}formatTokenValue(t){return t===null?Ee:new Pb("en-US").transform(t,"1.0-2")??"0"}formatCostValue(t,e){return t?Ee:"$"+(new Pb("en-US").transform(e??0,"1.2-2")??"0.00")}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=xw({type:o,selectors:[["app-token-usage"]],decls:41,vars:8,consts:[[1,"page"],[1,"page__header"],[1,"page__title-block"],["mat-icon-button","","title","Back",3,"click"],[1,"page__title"],[1,"page__subtitle"],[1,"filters"],[1,"filters__field"],[1,"filters__label"],[1,"filters__control"],["type","date",1,"filters__input",3,"ngModelChange","ngModel"],["type","button",1,"filters__clear",3,"click","disabled"],[1,"filters__select",3,"ngModelChange","ngModel"],["value","byModel"],["value","byAgent"],["type","button",1,"filters__apply",3,"click","disabled"],[1,"card"],[1,"card","card--error"],[1,"grid"],[1,"kpis"],[1,"kpi"],[1,"kpi__label"],[1,"kpi__value"],["title","Some calls in this period were recorded before token tracking was enabled. Token counts reflect only the portion where data was collected.",1,"hint"],["title","No token usage data was collected for this period.",1,"hint"],[1,"muted"],[1,"card__title"],[1,"table"],[1,"table__head"],[1,"table__cell"],[1,"table__cell","table__cell--num"],[1,"table__body"],[1,"table__row"],[1,"table__row","table__row--total"],[3,"points"]],template:function(e,n){e&1&&(ws(0,"section",0)(1,"header",1)(2,"div",2)(3,"button",3),Rg("click",function(){return n.navigateBack()}),ws(4,"mat-icon"),GC(5,"chevron_left"),pl()(),ws(6,"div")(7,"h1",4),GC(8,"Token Usage"),pl(),ws(9,"p",5),GC(10,"Track prompt and completion token usage by agent and model."),pl()()(),ws(11,"div",6)(12,"label",7)(13,"span",8),GC(14,"From"),pl(),ws(15,"div",9)(16,"input",10),Rg("ngModelChange",function(d){return n.onFromChange(d)}),pl(),VI(),ws(17,"button",11),Rg("click",function(){return n.clearFrom()}),GC(18," Clear "),pl()()(),ws(19,"label",7)(20,"span",8),GC(21,"To"),pl(),ws(22,"div",9)(23,"input",10),Rg("ngModelChange",function(d){return n.onToChange(d)}),pl(),VI(),ws(24,"button",11),Rg("click",function(){return n.clearTo()}),GC(25," Clear "),pl()()(),ws(26,"label",7)(27,"span",8),GC(28,"View"),pl(),ws(29,"select",12),Rg("ngModelChange",function(d){return n.view.set(d)}),ws(30,"option",13),GC(31,"By model"),pl(),ws(32,"option",14),GC(33,"By agent"),pl()(),VI(),pl(),ws(34,"button",15),Rg("click",function(){return n.apply()}),GC(35,"Apply"),pl()()(),Jw(36,et,20,12),Jw(37,tt,3,0,"div",16)(38,nt,5,1,"div",17)(39,ot,5,0,"div",16)(40,rt,30,2,"div",18),pl()),e&2&&(XE(16),bg("ngModel",n.state.draftFilters().from),UI(),XE(),bg("disabled",!n.state.draftFilters().from),XE(6),bg("ngModel",n.state.draftFilters().to),UI(),XE(),bg("disabled",!n.state.draftFilters().to),XE(5),bg("ngModel",n.view()),UI(),XE(5),bg("disabled",n.state.loading()),XE(2),eC(n.totalRow()?36:-1),XE(),eC(n.state.loading()?37:n.state.error()?38:n.isEmpty()?39:40));},dependencies:[ti,Qn,ei,Ye$1,At,Zn,cn,j,hr,Gn,yt,wt,K,Q],styles:[".page[_ngcontent-%COMP%]{padding:1.5rem;color:var(--color-text, #1d1d1f)}.page__header[_ngcontent-%COMP%]{display:flex;align-items:flex-start;justify-content:space-between;gap:1.5rem;margin-bottom:1rem}.page__title-block[_ngcontent-%COMP%]{display:flex;align-items:flex-start;gap:.75rem}.page__title[_ngcontent-%COMP%]{margin:0;font-size:1.25rem;font-weight:650}.page__subtitle[_ngcontent-%COMP%]{margin:.25rem 0 0;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.95rem}.filters[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:flex-end;gap:.75rem}.filters__field[_ngcontent-%COMP%]{display:grid;gap:.25rem}.filters__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.filters__control[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.filters__input[_ngcontent-%COMP%], .filters__select[_ngcontent-%COMP%]{height:34px;padding:0 .5rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f)}.filters__apply[_ngcontent-%COMP%], .filters__clear[_ngcontent-%COMP%]{height:34px;padding:0 .75rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .12));background:var(--color-bg-secondary, rgba(255, 255, 255, .72));color:var(--color-text, #1d1d1f);cursor:pointer}.kpis[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:.75rem 0 1rem}@media(max-width:900px){.kpis[_ngcontent-%COMP%]{grid-template-columns:1fr}}.kpi[_ngcontent-%COMP%]{border-radius:14px;padding:.75rem 1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.kpi__label[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.kpi__value[_ngcontent-%COMP%]{margin-top:.25rem;font-size:1.2rem;font-weight:650;font-variant-numeric:tabular-nums}.filters__apply[_ngcontent-%COMP%]{border-color:var(--color-primary, #007aff);background:var(--color-primary, #007aff);color:var(--color-text-inverse, #ffffff)}.filters__apply[_ngcontent-%COMP%]:disabled, .filters__clear[_ngcontent-%COMP%]:disabled{opacity:.6;cursor:not-allowed}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:1.5fr 1fr;gap:1rem;align-items:start}@media(max-width:1100px){.grid[_ngcontent-%COMP%]{grid-template-columns:1fr}}.card[_ngcontent-%COMP%]{border-radius:14px;padding:1rem;background:var(--glass-bg, rgba(255, 255, 255, .72));border:1px solid var(--glass-border, rgba(255, 255, 255, .18));box-shadow:var(--glass-shadow, 0 8px 24px rgba(0, 0, 0, .08))}.card--error[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.card__title[_ngcontent-%COMP%]{font-weight:650;margin-bottom:.75rem}.muted[_ngcontent-%COMP%]{color:var(--color-text-secondary, rgba(29, 29, 31, .7))}.table[_ngcontent-%COMP%]{overflow-x:auto}.table__head[_ngcontent-%COMP%], .table__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr 2fr 1fr 1fr 1fr .7fr 1fr;gap:.5rem;align-items:center}.table__head[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));padding:.25rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row[_ngcontent-%COMP%]{padding:.5rem 0;border-bottom:1px solid var(--color-border-light, rgba(0, 0, 0, .08))}.table__row--total[_ngcontent-%COMP%]{font-weight:650;background:var(--color-bg-hover, rgba(0, 0, 0, .03));border-radius:10px;padding:.6rem .5rem;border-bottom:none;margin-top:.5rem}.table__cell[_ngcontent-%COMP%]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.table__cell--num[_ngcontent-%COMP%]{text-align:right;font-variant-numeric:tabular-nums}.hint[_ngcontent-%COMP%]{margin:.25rem 0 1rem;color:var(--color-text-secondary, rgba(29, 29, 31, .7));font-size:.85rem}"],changeDetection:1})};export{Oe as TokenUsageComponent};
@@ -0,0 +1 @@
1
+ import {S as St}from'./chunk-DpSFD5A1.js';import {an as ue,g,L,ao as W,F,N as N$1,ap as Cd,e as xw,aq as a,ar as S,as as F$1,at as c,k as ws,q as Rg,J as Jw,o as pl,u as bg,X as XE,v as eC,B as Pg,E as EC,I as IC,au as tv,ae as kt,av as B,W as x,aw as hl,n as GC,ax as gl,a8 as Yg,a9 as lC,aa as If,ac as gC,ab as wf,S as Sg}from'./main-IZL5CRF5.js';import {a as at,s as st,r as rt,_ as _i}from'./chunk-CZkJE1B4.js';import'./chunk-rDVpfvvv.js';import {G as Ge}from'./chunk-aZLcrpJC.js';import'./chunk-4OgRX34W.js';import'./chunk-DbQl4qcz.js';import'./chunk-ZcJ6UNEM.js';import'./chunk-CB09vhCC.js';import'./chunk-JL-a2GkC.js';import'./chunk-JKBba9WI.js';import'./chunk-Co47-WQ-.js';import'./chunk-C2h5l5r_.js';var T=class o{welcomeMessages=["Welcome to Coday","Bienvenue sur Coday","Bienvenido a Coday","Willkommen bei Coday","Benvenuto su Coday","Bem-vindo ao Coday","Welkom bij Coday","\u0414\u043E\u0431\u0440\u043E \u043F\u043E\u0436\u0430\u043B\u043E\u0432\u0430\u0442\u044C \u0432 Coday","Coday \u3078\u3088\u3046\u3053\u305D","\u6B22\u8FCE\u6765\u5230 Coday","Coday \uC5D0 \uC624\uC2E0 \uAC83\uC744 \uD658\uC601\uD569\uB2C8\uB2E4","\u0645\u0631\u062D\u0628\u064B\u0627 \u0628\u0643 \u0641\u064A Coday"];currentWelcomeIndex=0;currentWelcomeMessage=this.welcomeMessages[0];welcomeRotationInterval;ngOnInit(){this.startWelcomeRotation();}ngOnDestroy(){this.stopWelcomeRotation();}startWelcomeRotation(){this.welcomeRotationInterval=window.setInterval(()=>{this.currentWelcomeIndex=(this.currentWelcomeIndex+1)%this.welcomeMessages.length,this.currentWelcomeMessage=this.welcomeMessages[this.currentWelcomeIndex];},3e3);}stopWelcomeRotation(){this.welcomeRotationInterval&&(clearInterval(this.welcomeRotationInterval),this.welcomeRotationInterval=void 0);}static \u0275fac=function(t){return new(t||o)};static \u0275cmp=xw({type:o,selectors:[["app-welcome-message"]],decls:2,vars:1,consts:[[1,"welcome-title"]],template:function(t,i){t&1&&(hl(0,"h1",0),GC(1),gl()),t&2&&(XE(),Yg(i.currentWelcomeMessage));},styles:[".welcome-title[_ngcontent-%COMP%]{font-size:clamp(1.5rem,4vw,4rem);font-weight:700;background:linear-gradient(90deg,var(--color-primary, #3b82f6) 0%,var(--color-accent, #8b5cf6) 50%,var(--color-primary, #3b82f6) 100%);background-size:200% auto;background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent;animation:_ngcontent-%COMP%_gradientShift 3s ease-in-out infinite;margin:0;padding:0;line-height:1.2;transition:opacity .5s ease-in-out;display:block;min-height:1.2em;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@keyframes _ngcontent-%COMP%_gradientShift{0%{background-position:0% center}50%{background-position:100% center}to{background-position:0% center}}"],changeDetection:1})};var N=class o{destroy$=new ue;isSetup=false;codayService=g(Ge);preferencesService=g(L);setup(){if(this.isSetup){console.warn("[AGENT-NOTIFICATION] Service already set up");return}console.log("[AGENT-NOTIFICATION] Setting up agent notification service"),this.codayService.isThinking$.pipe(Cd(this.destroy$),tv(),kt(([e,t])=>e===true&&t===false)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Agent stopped thinking, notifying task finished"),this.notifyTaskFinishedIfEnabled();}),this.preferencesService.browserNotificationEnabled$.pipe(Cd(this.destroy$),tv(),kt(([e,t])=>e===false&&t===true)).subscribe(()=>{console.log("[AGENT-NOTIFICATION] Browser notifications enabled, checking permission"),this.handleBrowserNotificationEnabled();}),this.isSetup=true;}notifyTaskFinishedIfEnabled(){this.preferencesService.getAgentNotificationEnabled()&&(this.preferencesService.getNotificationSoundEnabled()&&this.playCompletionSound(),this.preferencesService.getBrowserNotificationEnabled()&&this.sendBrowserNotification());}playCompletionSound(){try{let e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),i=e.createGain();t.connect(i),i.connect(e.destination),t.frequency.setValueAtTime(700,e.currentTime),i.gain.setValueAtTime(.1,e.currentTime),i.gain.exponentialRampToValueAtTime(.01,e.currentTime+.08),t.start(e.currentTime),t.stop(e.currentTime+.08);let n=e.createOscillator(),r=e.createGain();n.connect(r),r.connect(e.destination);let l=e.currentTime+.11;n.frequency.setValueAtTime(950,l),r.gain.setValueAtTime(.1,l),r.gain.exponentialRampToValueAtTime(.01,l+.09),n.start(l),n.stop(l+.09),console.log("[AGENT-NOTIFICATION] Completion sound played");}catch(e){console.error("[AGENT-NOTIFICATION] Failed to play completion sound:",e);}}handleBrowserNotificationEnabled(){return B(this,null,function*(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications"),this.preferencesService.setBrowserNotificationEnabled(false);return}if(Notification.permission==="denied"){console.warn("[AGENT-NOTIFICATION] Permission denied, disabling browser notifications"),this.preferencesService.setBrowserNotificationEnabled(false);return}if(Notification.permission==="granted"){console.log("[AGENT-NOTIFICATION] Permission already granted, showing confirmation"),this.createConfirmationNotification();return}try{(yield Notification.requestPermission())==="granted"?(console.log("[AGENT-NOTIFICATION] Permission granted, showing confirmation"),this.createConfirmationNotification()):(console.log("[AGENT-NOTIFICATION] Permission denied or dismissed"),this.preferencesService.setBrowserNotificationEnabled(!1));}catch(e){console.error("[AGENT-NOTIFICATION] Error requesting permission:",e),this.preferencesService.setBrowserNotificationEnabled(false);}})}sendBrowserNotification(){if(!("Notification"in window)){console.warn("[AGENT-NOTIFICATION] Browser does not support notifications");return}if(document.hasFocus()){console.warn("[AGENT-NOTIFICATION] Document is focused, skipping browser notification");return}Notification.permission==="granted"?this.createTaskCompleteNotification():console.warn("[AGENT-NOTIFICATION] Permission not granted, cannot send notification");}createConfirmationNotification(){let e=new Notification("Coday - Notifications Enabled",{body:"You will be notified when the agent completes tasks",icon:"/favicon.ico",tag:"coday-notifications-enabled",requireInteraction:false});setTimeout(()=>e.close(),4e3),e.onclick=()=>{window.focus(),e.close();},console.log("[AGENT-NOTIFICATION] Confirmation notification sent");}createTaskCompleteNotification(){let e=new Notification("Coday - Task Complete",{body:"The agent has finished and is waiting for your input",icon:"/favicon.ico",tag:"coday-task-complete",requireInteraction:false});setTimeout(()=>e.close(),5e3),e.onclick=()=>{window.focus(),e.close();},console.log("[AGENT-NOTIFICATION] Task complete notification sent");}ngOnDestroy(){console.log("[AGENT-NOTIFICATION] Service destroyed"),this.destroy$.next(),this.destroy$.complete();}static \u0275fac=function(t){return new(t||o)};static \u0275prov=x({token:o,factory:o.\u0275fac,providedIn:"root"})};var Z=["inputSection"];function ee(o,e){if(o&1){let t=lC();ws(0,"app-thread",4),Rg("chatFocused",function(){If(t);let n=gC();return wf(n.onChatFocusedOnMobile())})("drawerStateChange",function(n){If(t);let r=gC();return wf(r.onDrawerStateChange(n))}),pl();}if(o&2){let t=gC();bg("projectName",t.projectName)("threadId",t.threadId);}}function te(o,e){if(o&1){let t=lC();ws(0,"div",5),Sg(1,"app-welcome-message"),pl(),ws(2,"div",6,0)(4,"div",7)(5,"div",8)(6,"app-chat-textarea",9),Rg("messageSubmitted",function(n){If(t);let r=gC();return wf(r.onMessageSubmitted(n))})("voiceMessageReady",function(n){If(t);let r=gC();return wf(r.onVoiceMessageReady(n))})("voiceRecordingToggled",function(n){If(t);let r=gC();return wf(r.onVoiceToggled(n))})("heightChanged",function(n){If(t);let r=gC();return wf(r.onInputHeightChanged(n))})("textareaFocused",function(){If(t);let n=gC();return wf(n.onChatFocusedOnMobile())}),pl()()()();}if(o&2){let t=gC();XE(6),bg("isDisabled",t.isSessionInitializing)("isSessionInitializing",t.isSessionInitializing)("showWelcome",true)("isThinking",false)("isStarting",t.isStartingFirstMessage);}}var K=class o{destroy$=new ue;inputSection;sidenav;projectName="";threadId=null;isSessionInitializing=false;isStartingFirstMessage=false;inputSectionHeight=80;codayService=g(Ge);titleService=g(at);preferencesService=g(L);route=g(W);router=g(F);threadApiService=g(N$1);agentNotificationService=g(N);firstMessageState=g(st);constructor(){console.log("[MAIN-APP] Using new thread-based architecture (no clientId needed)");}ngOnInit(){this.agentNotificationService.setup(),this.setupPrintHandlers(),this.route.params.pipe(Cd(this.destroy$)).subscribe(e=>{let t=e.projectName,i=e.threadId||null;console.log("[MAIN-APP] Route params updated:",{project:t,thread:i,previousProject:this.projectName,previousThread:this.threadId}),this.projectName=t,this.threadId=i,this.threadId?console.log("[MAIN-APP] Thread selected - ThreadComponent will display"):(console.log("[MAIN-APP] No thread selected - showing welcome view"),this.initializeWelcomeView());});}initializeWelcomeView(){this.codayService.setTabTitleService(this.titleService);}ngAfterViewInit(){setTimeout(()=>this.updateInputSectionHeight(),100);}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete(),window.removeEventListener("beforeprint",this.handleBeforePrint),window.removeEventListener("afterprint",this.handleAfterPrint);}onMessageSubmitted(e){console.log("[MAIN-APP] First message submitted from welcome view:",e),this.isSessionInitializing=true,this.isStartingFirstMessage=true,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created:",t.thread.id),this.firstMessageState.setPendingFirstMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id]);},error:t=>{console.error("[MAIN-APP] Failed to create thread:",t),this.isSessionInitializing=false,this.isStartingFirstMessage=false,alert("Failed to create conversation: "+(t.message||"Unknown error"));}});}onVoiceToggled(e){console.log("[VOICE] Recording in welcome view:",e);}onVoiceMessageReady(e){console.log("[MAIN-APP] Voice message ready from welcome view"),this.isSessionInitializing=true,this.isStartingFirstMessage=true,this.threadApiService.createThread().subscribe({next:t=>{console.log("[MAIN-APP] Thread created for voice message:",t.thread.id),this.firstMessageState.setPendingVoiceMessage(e),this.router.navigate(["project",this.projectName,"thread",t.thread.id]);},error:t=>{console.error("[MAIN-APP] Failed to create thread for voice message:",t),this.isSessionInitializing=false,this.isStartingFirstMessage=false,alert("Failed to create conversation: "+(t.message||"Unknown error"));}});}isDrawerOpen=false;onDrawerStateChange(e){this.isDrawerOpen=e;}onChatFocusedOnMobile(){window.innerWidth<1024&&this.sidenav?.close();}onInputHeightChanged(e){console.log("[MAIN-APP] Input height changed:",e),this.inputSectionHeight=e;}updateInputSectionHeight(){if(this.inputSection?.nativeElement){let e=this.inputSection.nativeElement.offsetHeight;e!==this.inputSectionHeight&&(console.log("[MAIN-APP] Input section height updated:",e),this.inputSectionHeight=e);}}setupPrintHandlers(){window.addEventListener("beforeprint",this.handleBeforePrint),window.addEventListener("afterprint",this.handleAfterPrint);}handleBeforePrint=()=>{console.log("[PRINT] Before print event triggered");let e=this.preferencesService.getPrintTechnicalMessages();console.log("[PRINT] Print technical messages:",e),e?document.body.classList.add("print-include-technical"):document.body.classList.remove("print-include-technical");};handleAfterPrint=()=>{console.log("[PRINT] After print event triggered"),document.body.classList.remove("print-include-technical");};static \u0275fac=function(t){return new(t||o)};static \u0275cmp=xw({type:o,selectors:[["app-main"]],viewQuery:function(t,i){if(t&1&&Pg(Z,5)(St,5),t&2){let n;EC(n=IC())&&(i.inputSection=n.first),EC(n=IC())&&(i.sidenav=n.first);}},decls:4,vars:2,consts:[["inputSection",""],[3,"drawerOpen"],[1,"app",3,"mousedown","touchstart"],[3,"projectName","threadId"],[3,"chatFocused","drawerStateChange","projectName","threadId"],[1,"welcome-section"],[1,"input-section"],[1,"input-center"],[1,"input-glass"],[3,"messageSubmitted","voiceMessageReady","voiceRecordingToggled","heightChanged","textareaFocused","isDisabled","isSessionInitializing","showWelcome","isThinking","isStarting"]],template:function(t,i){t&1&&(ws(0,"app-sidenav",1)(1,"div",2),Rg("mousedown",function(){return i.onChatFocusedOnMobile()})("touchstart",function(){return i.onChatFocusedOnMobile()}),Jw(2,ee,1,2,"app-thread",3)(3,te,7,5),pl()()),t&2&&(bg("drawerOpen",i.isDrawerOpen),XE(2),eC(i.threadId?2:3));},dependencies:[rt,_i,T,St],styles:["[_nghost-%COMP%]{display:flex;height:100vh;width:100%;overflow:hidden;justify-content:center}.app[_ngcontent-%COMP%]{width:100%;max-width:100%;min-width:0;height:100%;display:flex;flex-direction:column;background:var(--color-bg);color:var(--color-text);transition:all .3s ease;position:relative;justify-content:center;overflow:hidden}.chat-wrapper[_ngcontent-%COMP%]{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;background:transparent;width:100%;padding:2.5rem 0 1.5rem;display:flex;justify-content:center}.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem}@media(max-width:768px){.chat-wrapper[_ngcontent-%COMP%] .chat-center[_ngcontent-%COMP%]{padding:0 1rem}}.welcome-section[_ngcontent-%COMP%]{flex-shrink:0;text-align:center;padding:2rem 1rem;animation:_ngcontent-%COMP%_fadeInUp .8s ease-out;display:flex;justify-content:center;align-items:center;width:100%;min-width:0;overflow:hidden}@keyframes _ngcontent-%COMP%_fadeInUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}.input-section[_ngcontent-%COMP%]{flex-shrink:0;position:relative;border-top:none;background:transparent;box-shadow:none;padding:2.5rem 0 2rem;overflow-y:visible;max-height:none;width:100%;z-index:10;pointer-events:none;display:flex;justify-content:center}.input-center[_ngcontent-%COMP%]{max-width:760px;width:100%;margin:0;padding:0 2rem;display:flex;justify-content:center;align-items:end;position:relative;pointer-events:auto}@media(max-width:768px){.input-center[_ngcontent-%COMP%]{padding:0 1rem}}.input-glass[_ngcontent-%COMP%]{background:none;box-shadow:none;width:100%;min-height:64px;display:flex;align-items:stretch;gap:0;pointer-events:auto;position:relative;overflow:visible}.input-glass[_ngcontent-%COMP%] app-chat-textarea[_ngcontent-%COMP%]{width:100%;min-width:0;flex:1 1 auto;align-self:stretch;display:flex}body.dark[_nghost-%COMP%], body.dark [_nghost-%COMP%], [_ngcontent-%COMP%]:root[data-theme=dark] .input-glass[_ngcontent-%COMP%]{background:#24283073;border-color:#b4c8ff17;box-shadow:0 8px 32px #0000002b,0 1.5px 8px #00000012}.choice-overlay[_ngcontent-%COMP%]{z-index:10;width:100%;display:flex;justify-content:center;align-items:center}.upload-status[_ngcontent-%COMP%]{position:fixed;bottom:100px;left:50%;transform:translate(-50%);z-index:1000;display:flex;align-items:center;padding:12px 20px;background:var(--glass-bg);backdrop-filter:var(--glass-backdrop-blur);-webkit-backdrop-filter:var(--glass-backdrop-blur);border:1px solid var(--glass-border);border-radius:16px;font-size:.9em;color:var(--color-text);box-shadow:var(--glass-shadow);max-width:300px;text-align:center}.upload-status.error[_ngcontent-%COMP%]{background:#ff3b3026;color:var(--color-error);border-color:#ff3b304d}@media(max-width:768px){.welcome-section[_ngcontent-%COMP%]{padding:1.5rem 1rem}.input-section[_ngcontent-%COMP%]{padding:1.5rem .75rem 1rem}.input-center[_ngcontent-%COMP%]{padding:0 .5rem}}@media print{[_nghost-%COMP%]{display:block!important;height:auto!important;overflow:visible!important}.app[_ngcontent-%COMP%]{height:auto!important;overflow:visible!important;display:block!important}.input-section[_ngcontent-%COMP%], .welcome-section[_ngcontent-%COMP%]{display:none!important}}"],data:{animation:[a("slideIn",[S(":enter",[F$1({transform:"translateY(100%)",opacity:0}),c("300ms ease-out",F$1({transform:"translateY(0)",opacity:1}))]),S(":leave",[c("200ms ease-in",F$1({transform:"translateY(100%)",opacity:0}))])])]},changeDetection:1})};export{K as MainAppComponent};
@@ -0,0 +1 @@
1
+ import {z}from'./chunk-SNYHeawQ.js';import {s}from'./chunk-DbQl4qcz.js';import {g as g$1,F,P,R as Re,C as Ce,a as F$1,m as mT,x,w,ae as kt,b as U,e as xw,j as Gn,$ as $t,k as ws,q as Rg,S as Sg,o as pl,af as Eg,ag as fT,t as CC,X as XE,u as bg,a9 as lC,aa as If,ac as gC,ab as wf,n as GC,ah as rT}from'./main-IZL5CRF5.js';import'./chunk-CMB6fOce.js';import {$ as $n,o as ot}from'./chunk-JKBba9WI.js';import'./chunk-Co47-WQ-.js';import {y as yt,w as wt}from'./chunk-C2h5l5r_.js';var ee=()=>[];function te(u,t){if(u&1){let o=lC();ws(0,"div",5)(1,"ds-entity-card",6),Rg("selected",function(r){If(o);let i=gC();return wf(i.onItemSelected(r))}),pl(),ws(2,"button",7),Rg("click",function(r){let i=If(o).$implicit,f=gC();return r.stopPropagation(),wf(f.onDeleteRequested(i.id))}),ws(3,"mat-icon"),GC(4,"close"),pl()()();}if(u&2){let o=t.$implicit;XE(),bg("id",o.id)("name",o.name)("description",o.description)("badges",o.badges??rT(4,ee));}}var g="__",Y=class u{router=g$1(F);projectStateService=g$1(P);dialog=g$1(Re);destroyRef=g$1(Ce);notification=g$1(s);projects=F$1(this.projectStateService.projectList$);forcedProject=F$1(this.projectStateService.forcedProject$,{initialValue:null});isLoading=F$1(this.projectStateService.isLoading$,{initialValue:false});projectItems=mT(()=>{let t=this.projects();if(!t)return [];let o=t.filter(e=>!e.name.includes(g)),n=t.filter(e=>e.name.includes(g)),r=new Set(o.map(e=>e.name)),i=e=>e.split(g)[0]??null,f=new Set(n.map(e=>i(e.name)).filter(e=>e!==null&&r.has(e))),l=[],G=[...f].sort((e,a)=>e.localeCompare(a));for(let e of G){let a=o.find(s=>s.name===e);l.push(x(w({},this.toEntityListItem(a)),{groupKey:e,groupLabel:e}));let Z=n.filter(s=>i(s.name)===e).sort((s,C)=>s.name.localeCompare(C.name));for(let s of Z){let C=s.name.slice(e.length+g.length);l.push(x(w({},this.toEntityListItem(s)),{name:C,description:s.name,groupKey:e,groupLabel:e}));}}let H=[...o].filter(e=>!f.has(e.name)&&!e.volatile).sort((e,a)=>e.name.localeCompare(a.name));for(let e of H)l.push(x(w({},this.toEntityListItem(e)),{groupKey:"__standalone__",groupLabel:"Projects"}));let Q=[...o].filter(e=>!f.has(e.name)&&e.volatile).sort((e,a)=>e.name.localeCompare(a.name));for(let e of Q)l.push(x(w({},this.toEntityListItem(e)),{groupKey:"__volatile__",groupLabel:"Temporary"}));let X=n.filter(e=>{let a=i(e.name);return a!==null&&!r.has(a)}).sort((e,a)=>e.name.localeCompare(a.name));for(let e of X)l.push(x(w({},this.toEntityListItem(e)),{groupKey:"__orphaned__",groupLabel:"Orphaned worktrees"}));return l});showCreateButton=mT(()=>!this.forcedProject());constructor(){}onItemSelected(t){this.projectStateService.selectProject(t),this.router.navigate(["project",t]);}onCreateRequested(){this.router.navigate(["project","new"]);}onDeleteRequested(t){let o=t.includes(g);this.dialog.open(z,{width:"400px",panelClass:"confirm-dialog-panel",data:w({title:"Delete project",message:`This will remove the project "${t}" from Coday and archive its configuration. The project source code on disk is not affected.`,confirmLabel:"Delete",cancelLabel:"Cancel",isDestructive:true},o?{checkboxLabel:"Also remove git worktree from disk"}:{})}).afterClosed().pipe(kt(r=>r?.confirmed===true),U(this.destroyRef)).subscribe(r=>{this.notification.info("Deleting project\u2026"),this.projectStateService.deleteProject(t,r.checkboxChecked).pipe(U(this.destroyRef)).subscribe({next:()=>{this.notification.success(`Project "${t}" deleted`),this.router.url.includes(`/project/${encodeURIComponent(t)}`)&&this.router.navigate(["/"]);},error:i=>{console.error("[PROJECT-LIST] Failed to delete project:",i),this.notification.error(i?.error?.error??"Failed to delete project");}});});}toEntityListItem(t){return {id:t.name,name:t.name,badges:t.volatile?[{label:"temp",variant:"warning"}]:[]}}static \u0275fac=function(o){return new(o||u)};static \u0275cmp=xw({type:u,selectors:[["app-project-selection"]],decls:6,vars:5,consts:[["projectCard",""],[1,"project-page-layout"],["title","Projects","contentMaxWidth","1400px","searchPlaceholder","Filter projects\u2026","emptyMessage","No projects found.",3,"itemSelected","createRequested","items","loading","itemTemplate","showCreate","autoFocusSearch"],["toolbar-start","","routerLink","/","title","Back to tasks",1,"project-list__logo"],["src","CODAY-Logo.png","alt","Coday"],[1,"project-card-wrapper"],[3,"selected","id","name","description","badges"],["mat-icon-button","","title","Delete project",1,"project-card-wrapper__delete",3,"click"]],template:function(o,n){if(o&1&&(ws(0,"div",1)(1,"ds-entity-list",2),Rg("itemSelected",function(i){return n.onItemSelected(i)})("createRequested",function(){return n.onCreateRequested()}),ws(2,"a",3),Sg(3,"img",4),pl()()(),Eg(4,te,5,5,"ng-template",null,0,fT)),o&2){let r=CC(5);XE(),bg("items",n.projectItems())("loading",n.isLoading())("itemTemplate",r)("showCreate",n.showCreateButton())("autoFocusSearch",true);}},dependencies:[$n,ot,yt,wt,Gn,$t],styles:["[_nghost-%COMP%]{display:block;width:100%;min-height:100vh;background:var(--color-bg);overflow-y:auto}.project-page-layout[_ngcontent-%COMP%]{display:flex;flex-direction:column;width:100%}.project-list__logo[_ngcontent-%COMP%]{display:flex;align-items:center;flex-shrink:0;border-radius:4px;opacity:.85;transition:opacity .15s ease;cursor:pointer}.project-list__logo[_ngcontent-%COMP%]:hover{opacity:1}.project-list__logo[_ngcontent-%COMP%] img[_ngcontent-%COMP%]{width:40px;height:40px;object-fit:contain;border-radius:4px}.project-card-wrapper[_ngcontent-%COMP%]{position:relative}.project-card-wrapper__delete[_ngcontent-%COMP%]{position:absolute;top:4px;right:4px;width:28px;height:28px;line-height:28px;padding:0;opacity:0;transition:opacity .15s ease;color:var(--color-text-secondary, #6e6e73)}.project-card-wrapper__delete[_ngcontent-%COMP%] .mat-icon[_ngcontent-%COMP%]{font-size:16px;width:16px;height:16px}.project-card-wrapper__delete[_ngcontent-%COMP%]:hover{color:var(--color-error, #ff3b30)}.project-card-wrapper[_ngcontent-%COMP%]:hover .project-card-wrapper__delete[_ngcontent-%COMP%]{opacity:1}"],changeDetection:1})};export{Y as ProjectListComponent};
@@ -0,0 +1 @@
1
+ import {o as o$1,r,i,l}from'./chunk-1nyEsjkY.js';import {o}from'./chunk-d0lmTRlE.js';import {N}from'./chunk-Ck2uBFpB.js';import {g,ao as W,F,C as Ce,da as $,dp as U,G as Gi,dq as Y,d8 as W$1,a as F$1,m as mT,dr as we$1,b as U$1,a7 as ya,Q as br,M as By,r as re,x,w,e as xw,$ as $t$1,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,a8 as Yg,v as eC,ac as gC,u as bg,a9 as lC,S as Sg,a3 as VI,a6 as UI,T as Tg,a5 as vl,s as rC,y as oC,bo as tC,aa as If,ab as wf,b0 as Qg}from'./main-IZL5CRF5.js';import'./chunk-WMGAW86u.js';import {o as z,k as _t,b as _e,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye$1,f as fn,a as wt,A as At,Z as Zn,l as Xn,$ as $t,W as Wt,C as Cn,E as En}from'./chunk-C2h5l5r_.js';import'./chunk-CM_kdC9n.js';import'./chunk-4OgRX34W.js';import'./chunk-JKBba9WI.js';import'./chunk-Co47-WQ-.js';var we=(n,t)=>t.config.id,ke=(n,t)=>t.type,Ee=(n,t)=>t.selector;function Me(n,t){if(n&1&&(ws(0,"a",5),GC(1,"View resolved definition \u2192"),pl()),n&2){let e=gC();bg("routerLink",e.inspectRoute());}}function Ae(n,t){n&1&&(ws(0,"span",6),GC(1,"Platform level"),pl());}function Ie(n,t){n&1&&(ws(0,"p",7),GC(1,"Loading\u2026"),pl());}function Oe(n,t){if(n&1&&(ws(0,"span",57),GC(1),pl()),n&2){let e=gC().$implicit;XE(),Yg(e.config.integrationType);}}function Pe(n,t){if(n&1&&(Sg(0,"input",58),VI()),n&2){let e=gC().$implicit;bg("formControl",e.toolsControl),UI();}}function Te(n,t){if(n&1){let e=lC();ws(0,"div",52)(1,"label",54)(2,"input",55),Rg("change",function(){let c=If(e).$implicit,s=gC(3);return wf(s.toggleIntegration(c))}),pl(),ws(3,"span",56),GC(4),pl(),Jw(5,Oe,2,1,"span",57),pl(),Jw(6,Pe,1,1,"input",58),pl();}if(n&2){let e=t.$implicit;XE(2),bg("checked",e.enabled()),XE(2),Yg(e.config.name),XE(),eC(e.config.integrationType?5:-1),XE(),eC(e.enabled()?6:-1);}}function Re(n,t){if(n&1&&(ws(0,"p",64),GC(1),pl()),n&2){let e=gC().$implicit;XE(),vl(" Restricted to: ",e.restrictedTools.join(", ")," (set outside this form, preserved on save) ");}}function Fe(n,t){if(n&1){let e=lC();ws(0,"div",52)(1,"label",54)(2,"span",56),GC(3),pl(),ws(4,"span",57),GC(5,"built-in"),pl()(),ws(6,"select",60),Rg("change",function(c){let s=If(e).$implicit,_=gC(4);return wf(_.setBuiltInState(s,c.target.value))}),ws(7,"option",61),GC(8),pl(),ws(9,"option",62),GC(10,"Enabled"),pl(),ws(11,"option",63),GC(12,"Disabled"),pl()(),Jw(13,Re,2,1,"p",64),ws(14,"p",65),GC(15),pl()();}if(n&2){let e=t.$implicit,a=gC(4);XE(),Tg("for","built-in-"+e.type),XE(2),Yg(e.displayName),XE(3),bg("id","built-in-"+e.type)("value",e.state()),XE(2),Yg(a.builtInDefaultLabel(e)),XE(5),eC(e.state()==="on"&&e.restrictedTools?13:-1),XE(2),Yg(e.description);}}function De(n,t){if(n&1&&(ws(0,"p",59),GC(1,"Built-in integrations"),pl(),rC(2,Fe,16,7,"div",52,ke)),n&2){let e=gC(3);XE(2),oC(e.builtInRows());}}function Ne(n,t){n&1&&(ws(0,"p",53),GC(1," This agent can read the AgentOS configuration and also has a network integration or sub-agents: what it reads could be sent outside without any confirmation. Prefer a dedicated configuration agent without them. "),pl());}function Ve(n,t){if(n&1&&(ws(0,"fieldset",20)(1,"legend",22),GC(2,"Integrations"),pl(),ws(3,"p",51),GC(4," Select which integrations this agent can use. Leave tool names empty to allow all tools from an integration. "),pl(),rC(5,Te,7,4,"div",52,we),Jw(7,De,4,0),Jw(8,Ne,2,0,"p",53),pl()),n&2){let e=gC(2);XE(5),oC(e.integrationRows()),XE(2),eC(e.builtInRows().length>0?7:-1),XE(),eC(e.configAgentExposureWarning()?8:-1);}}function Le(n,t){n&1&&GC(0," A platform config can only list platform skills here: namespace skills are resolved per namespace when the agent runs. ");}function ze(n,t){n&1&&(ws(0,"p",29),GC(1," Saving with this on replaces the selection below with "),ws(2,"code",24),GC(3,"*"),pl(),GC(4,". "),pl());}function Be(n,t){n&1&&(ws(0,"p",29),GC(1," The skill catalogue could not be loaded. What this agent already declares is listed below and preserved on save. "),pl());}function $e(n,t){n&1&&(ws(0,"p",30),GC(1,"No skill available in this scope yet."),pl());}function Ge(n,t){n&1&&(ws(0,"span",69),GC(1,"platform"),pl());}function je(n,t){if(n&1&&(ws(0,"span",70),GC(1),pl()),n&2){let e=gC(4);XE(),vl(" ",e.skillCatalogueUnavailable()?"not verified":"no matching skill"," ");}}function Ue(n,t){if(n&1&&(ws(0,"p",71),GC(1),pl()),n&2){let e=gC().$implicit;XE(),Yg(e.description);}}function We(n,t){if(n&1){let e=lC();ws(0,"div",66)(1,"label",67)(2,"input",68),Rg("change",function(){let c=If(e).$implicit,s=gC(3);return wf(s.toggleSkill(c))}),pl(),ws(3,"span",27),GC(4),pl(),Jw(5,Ge,2,0,"span",69),Jw(6,je,2,1,"span",70),pl(),Jw(7,Ue,2,1,"p",71),pl();}if(n&2){let e=t.$implicit,a=gC(3);XE(2),bg("checked",e.selected())("disabled",a.allSkillsSelected()),XE(2),Yg(e.name),XE(),eC(e.platform?5:-1),XE(),eC(e.unresolved?6:-1),XE(),eC(e.description?7:-1);}}function Je(n,t){if(n&1&&rC(0,We,8,6,"div",66,Ee),n&2){let e=gC(2);oC(e.skillRows());}}function Ye(n,t){n&1&&(ws(0,"p",74),GC(1,"Invalid JSON \u2014 please fix the syntax."),pl());}function Ke(n,t){if(n&1&&(ws(0,"div",10)(1,"label",72),GC(2,"Loop configuration (JSON)"),pl(),Sg(3,"textarea",73),VI(),Jw(4,Ye,2,0,"p",74),ws(5,"p",28),GC(6," Default payload for this loop agent. Overridden at launch time if the first message contains a valid "),ws(7,"code",24),GC(8,"AgentLoopPayload"),pl(),GC(9,". Leave empty if you always provide the payload at launch. "),pl()()),n&2){let e=gC(2);XE(3),bg("placeholder",e.loopConfigPlaceholder)("formControl",e.loopConfigControl),UI(),XE(),eC(e.loopConfigControl.invalid&&e.loopConfigControl.touched?4:-1);}}function He(n,t){if(n&1){let e=lC();ws(0,"li",75),Sg(1,"input",76),VI(),ws(2,"button",77),Rg("click",function(){let c=If(e).$implicit,s=gC(3);return wf(s.removeSubAgent(c))}),GC(3," \u{1F5D1} "),pl()();}if(n&2){let e=t.$implicit;XE(),bg("formControl",e.control),UI();}}function qe(n,t){if(n&1&&(ws(0,"ul",38),rC(1,He,4,1,"li",75,tC),pl()),n&2){let e=gC(2);XE(),oC(e.subAgentRows());}}function Xe(n,t){if(n&1&&GC(0),n&2){let e=gC(2);Qg(" : ",e.defaultDelegationTimeoutSeconds()," s (",e.defaultDelegationTimeoutSeconds()/60," min) ");}}function Qe(n,t){n&1&&(ws(0,"p",45),GC(1," Enter a valid positive whole number of seconds, or leave empty to inherit the server default. "),pl());}function Ze(n,t){if(n&1){let e=lC();ws(0,"button",78),Rg("click",function(){If(e);let c=gC(2);return wf(c.useDefaultDelegationTimeout())}),GC(1," Use server default "),pl();}}function et(n,t){if(n&1){let e=lC();ws(0,"button",79),Rg("click",function(){If(e);let c=gC(2);return wf(c.exportYaml())}),GC(1),pl();}if(n&2){let e=gC(2);bg("disabled",e.isExporting()),XE(),vl(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function tt(n,t){if(n&1){let e=lC();ws(0,"form",9),Rg("ngSubmit",function(){If(e);let c=gC();return wf(c.submit())}),ws(1,"div",10)(2,"label",11),GC(3,"Name "),ws(4,"span",12),GC(5,"*"),pl()(),Sg(6,"input",13),VI(),pl(),ws(7,"div",10)(8,"label",14),GC(9,"Description"),pl(),Sg(10,"input",15),VI(),pl(),ws(11,"div",10)(12,"label",16),GC(13,"Model name"),pl(),Sg(14,"input",17),VI(),pl(),ws(15,"div",10)(16,"label",18),GC(17,"Instructions"),pl(),Sg(18,"textarea",19),VI(),pl(),Jw(19,Ve,9,2,"fieldset",20),ws(20,"fieldset",21)(21,"legend",22),GC(22,"Skills"),pl(),ws(23,"p",23),GC(24," Instruction bundles this agent can read on demand. Selecting at least one grants it the "),ws(25,"code",24),GC(26,"readSkill"),pl(),GC(27," and "),ws(28,"code",24),GC(29,"readSkillResource"),pl(),GC(30," tools; selecting none grants neither. "),Jw(31,Le,1,0),pl(),ws(32,"label",25)(33,"input",26),Rg("change",function(){If(e);let c=gC();return wf(c.toggleAllSkills())}),pl(),ws(34,"span",27),GC(35," Every skill in the catalogue ("),ws(36,"code",24),GC(37,"*"),pl(),GC(38,") "),pl()(),ws(39,"p",28),GC(40," Resolved at run time, so skills added later are granted too, without editing this agent. "),pl(),Jw(41,ze,5,0,"p",29),Jw(42,Be,2,0,"p",29),Jw(43,$e,2,0,"p",30)(44,Je,2,0),pl(),ws(45,"div",10)(46,"label",31),GC(47,"Execution mode"),pl(),ws(48,"select",32)(49,"option",33),GC(50,"SIMPLE \u2014 Standard agent (single LLM call)"),pl(),ws(51,"option",33),GC(52,"ADVANCED \u2014 Multi-step reasoning loop"),pl(),ws(53,"option",33),GC(54,"LOOP \u2014 Bulk loop agent (no LLM, experimental)"),pl()(),VI(),ws(55,"p",28),GC(56,' SIMPLE runs a single LLM pass. ADVANCED uses an intention loop for complex tasks. LOOP (experimental) starts one case per result of a tool, without an LLM \u2014 run it with "Launch loop" in the agent list menu. '),pl()(),Jw(57,Ke,10,3,"div",10),ws(58,"div",10)(59,"label",34),Sg(60,"input",35),VI(),ws(61,"span",36),GC(62,"Enabled"),pl()(),ws(63,"p",37),GC(64,"Disabled agents are excluded from namespace resolution."),pl()(),ws(65,"div",10)(66,"span",22),GC(67,"Sub-agents"),pl(),ws(68,"p",28),GC(69," Glob patterns for agents this agent may delegate to. "),ws(70,"code",24),GC(71,"*"),pl(),GC(72," matches any sequence of characters (e.g. "),ws(73,"code",24),GC(74,"*Fixer"),pl(),GC(75,", "),ws(76,"code",24),GC(77,"*"),pl(),GC(78," for all). Leave empty to disable delegation. "),pl(),Jw(79,qe,3,0,"ul",38),ws(80,"div",39)(81,"input",40),Rg("keydown.enter",function(){If(e);let c=gC();return wf(c.addSubAgent())}),pl(),VI(),ws(82,"button",41),Rg("click",function(){If(e);let c=gC();return wf(c.addSubAgent())}),GC(83," + "),pl()()(),ws(84,"div",10)(85,"label",42),GC(86,"Delegation timeout (seconds)"),pl(),ws(87,"p",43),GC(88," How long each delegation launched by this agent waits without activity from the sub-agent, including its own delegations. When it runs out, the sub-agent and its active descendants are stopped and can be resumed. Leave empty to use the server default "),Jw(89,Xe,1,2),GC(90," . "),pl(),Sg(91,"input",44),VI(),Jw(92,Qe,2,0,"p",45),Jw(93,Ze,2,0,"button",46),pl(),ws(94,"div",47)(95,"button",48),GC(96),pl(),Jw(97,et,2,2,"button",49),ws(98,"button",50),Rg("click",function(){If(e);let c=gC();return wf(c.cancel())}),GC(99,"Cancel"),pl()()();}if(n&2){let e=gC();bg("formGroup",e.form),XE(6),bg("formControl",e.nameControl),UI(),XE(4),bg("formControl",e.descriptionControl),UI(),XE(4),bg("formControl",e.modelNameControl),UI(),XE(4),bg("formControl",e.instructionsControl),UI(),XE(),eC(e.integrationRows().length>0||e.builtInRows().length>0?19:-1),XE(12),eC(e.isPlatformMode?31:-1),XE(2),bg("checked",e.allSkillsSelected()),XE(8),eC(e.namedSkillSelectionDropped()?41:-1),XE(),eC(e.skillCatalogueUnavailable()?42:-1),XE(),eC(e.skillRows().length===0?43:44),XE(5),bg("formControl",e.executionModeControl),UI(),XE(),bg("value",e.ExecutionMode.SIMPLE),XE(2),bg("value",e.ExecutionMode.ADVANCED),XE(2),bg("value",e.ExecutionMode.LOOP),XE(4),eC(e.isLoopMode()?57:-1),XE(3),bg("formControl",e.enabledControl),UI(),XE(19),eC(e.subAgentRows().length>0?79:-1),XE(2),bg("formControl",e.newSubAgentControl),UI(),XE(),bg("disabled",!e.newSubAgentControl.value.trim()),XE(7),eC(e.defaultDelegationTimeoutSeconds()!==null?89:-1),XE(2),bg("formControl",e.delegationTimeoutControl),Tg("aria-invalid",e.delegationTimeoutControl.invalid),UI(),XE(),eC(e.delegationTimeoutControl.invalid?92:-1),XE(),eC(e.delegationTimeoutControl.value!==null?93:-1),XE(2),bg("disabled",e.form.invalid||e.isSubmitting()),XE(),vl(" ",e.isEditMode()?"Save changes":"Create"," "),XE(),eC(e.isEditMode()?97:-1);}}var nt="AGENTOS_CONFIG",ot=new Set(["HTTP_API","MCP_HTTP","MCP_STDIO","BASH","TMUX","GIT"]),Se=class n{route=g(W);router=g(F);destroyRef=g(Ce);agentConfigController=g($);defaultsController=g(U);defaultDelegationTimeoutSeconds=Gi(null);exportService=g(Y);integrationConfigState=g(N);integrationTypeController=g(W$1);skillState=g(o);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new z({name:new _t("",{nonNullable:true,validators:[_e.required,_e.minLength(1)]}),description:new _t(null),modelName:new _t(null),instructions:new _t(null),executionMode:new _t("SIMPLE",{nonNullable:true}),delegationTimeoutSeconds:new _t(null,{validators:[_e.min(1),_e.max(2147483647),_e.pattern(/^\d+$/)]}),enabled:new _t(false,{nonNullable:true}),loopConfig:new _t(null,{validators:[n.jsonValidator]})});static jsonValidator(t){let e=t.value?.trim();if(!e)return null;try{return JSON.parse(e),null}catch(a){return {invalidJson:true}}}get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get modelNameControl(){return this.form.controls.modelName}get instructionsControl(){return this.form.controls.instructions}get executionModeControl(){return this.form.controls.executionMode}get delegationTimeoutControl(){return this.form.controls.delegationTimeoutSeconds}useDefaultDelegationTimeout(){this.delegationTimeoutControl.setValue(null),this.delegationTimeoutControl.markAsDirty();}get enabledControl(){return this.form.controls.enabled}get loopConfigControl(){return this.form.controls.loopConfig}executionModeValue=F$1(this.form.controls.executionMode.valueChanges,{initialValue:this.form.controls.executionMode.value});isLoopMode=mT(()=>this.executionModeValue()==="LOOP");subAgentRows=Gi([]);newSubAgentControl=new _t("",{nonNullable:true});isEditMode=Gi(false);isSubmitting=Gi(false);isLoading=Gi(false);isExporting=Gi(false);ExecutionMode=we$1;loopConfigPlaceholder=JSON.stringify({search:{tool:"SearchTalents",params:{talentId:["6ac76692a909eaaae0b078d6"],resolveTargets:["MANAGER"],next:null}},act:{agentName:"ProfileCaretaker",promptTemplate:"This talent has not completed their profile. As their manager, I need you to help me review and improve it."}},null,2);builtInRows=Gi([]);inspectRoute(){let t=this.route.snapshot.paramMap.get("agentConfigId")??"";return this.isPlatformMode?["/agentos","admin","agent-configs",t,"inspect"]:["/agentos",this.namespaceId,"agent-configs",t,"inspect"]}configAgentExposureWarning=mT(()=>this.builtInRows().some(a=>a.type===nt&&a.state()==="on")?this.integrationRows().some(a=>a.enabled()&&ot.has(a.config.integrationType))||this.subAgentRows().length>0:false);integrationRows=Gi([]);skillRows=Gi([]);allSkillsSelected=Gi(false);skillCatalogueUnavailable=Gi(false);namedSkillSelectionDropped=mT(()=>this.allSkillsSelected()&&this.skillRows().some(t=>t.selected()));existingConfig=null;ngOnInit(){this.defaultsController.getAgentConfigDefaults().pipe(U$1(this.destroyRef),ya(()=>br(null))).subscribe(e=>this.defaultDelegationTimeoutSeconds.set(e?.delegationTimeoutSeconds??null));let t=this.route.snapshot.paramMap.get("agentConfigId");t?(this.isEditMode.set(true),this.loadConfigAndIntegrations(t)):this.loadIntegrations(void 0);}loadConfigAndIntegrations(t){this.isLoading.set(true),By({config:this.agentConfigController.getByIdAgentConfig(t),namespaceIntegrations:this.namespaceId?this.integrationConfigState.loadNamespaceConfigs(this.namespaceId):br([]),platformIntegrations:this.integrationConfigState.loadPlatformConfigs(),builtInTypes:this.loadBuiltInTypes(),skillCatalogue:this.loadSkillCatalogue()}).pipe(U$1(this.destroyRef)).subscribe({next:({config:e,namespaceIntegrations:a,platformIntegrations:c,builtInTypes:s,skillCatalogue:_})=>{this.existingConfig=e,this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.modelNameControl.setValue(e.modelName??null),this.instructionsControl.setValue(e.instructions??null);let M=e.executionMode??(e.advancedExecution?"ADVANCED":"SIMPLE");this.executionModeControl.setValue(M),this.delegationTimeoutControl.setValue(e.delegationTimeoutSeconds??null),this.enabledControl.setValue(e.enabled??true),this.loopConfigControl.setValue(e.loopConfig!=null?JSON.stringify(e.loopConfig,null,2):null);let F=[...c,...a];this.integrationRows.set(this.buildIntegrationRows(F,e.integrations??void 0)),this.builtInRows.set(this.buildBuiltInRows(s,e.integrations??void 0)),this.subAgentRows.set((e.subAgents??[]).map(u=>({control:new _t(u,{nonNullable:true})}))),this.allSkillsSelected.set(o$1(e.skillSelectors)),this.skillRows.set(this.buildSkillRows(_,e.skillSelectors)),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}loadIntegrations(t){By({namespaceIntegrations:this.namespaceId?this.integrationConfigState.loadNamespaceConfigs(this.namespaceId):br([]),platformIntegrations:this.integrationConfigState.loadPlatformConfigs(),builtInTypes:this.loadBuiltInTypes(),skillCatalogue:this.loadSkillCatalogue()}).pipe(U$1(this.destroyRef)).subscribe({next:({namespaceIntegrations:e,platformIntegrations:a,builtInTypes:c,skillCatalogue:s})=>{let _=[...a,...e];this.integrationRows.set(this.buildIntegrationRows(_,t??void 0)),this.builtInRows.set(this.buildBuiltInRows(c,t??void 0)),this.allSkillsSelected.set(false),this.skillRows.set(this.buildSkillRows(s,void 0));}});}loadSkillCatalogue(){return (this.namespaceId?this.skillState.listEffective(this.namespaceId):this.skillState.listPlatform().pipe(re(e=>e.map(a=>({id:a.id??"",name:a.name,description:a.description,namespaceId:a.namespaceId??null,readOnly:a.readOnly===true}))))).pipe(ya(e=>(console.error("[agent-config-form] failed to load the skill catalogue",e),this.skillCatalogueUnavailable.set(true),br([]))))}buildSkillRows(t,e){let c=(e??[]).map(u=>u.trim()).filter(u=>u.length>0).filter(u=>u!==r),s=i(c),_=new Set(t.map(u=>u.name.toLowerCase())),M=t.map(u=>({selector:u.name,name:u.name,description:u.description,platform:u.namespaceId==null,unresolved:false,selected:Gi(s.has(u.name.toLowerCase()))})),F=new Set;for(let u of c){let V=l(u).toLowerCase();_.has(V)||F.has(V)||(F.add(V),M.push({selector:u,name:u,description:"",platform:false,unresolved:true,selected:Gi(true)}));}return M}toggleSkill(t){t.selected.update(e=>!e);}toggleAllSkills(){this.allSkillsSelected.update(t=>!t);}buildSkillSelectorsPayload(){if(this.allSkillsSelected())return [r];let t=this.skillRows().filter(e=>e.selected()).map(e=>e.selector);return t.length>0?t:void 0}loadBuiltInTypes(){return this.integrationTypeController.listTypesIntegrationType().pipe(re(t=>t.filter(e=>!e.configSchema)),ya(t=>(console.error("[agent-config-form] failed to load integration types",t),br([]))))}buildIntegrationRows(t,e){return t.map(a=>{let c=a.name??"",s=e?.[c],_=e!=null&&c in e,M=Array.isArray(s)?s.join(", "):"";return {config:a,enabled:Gi(_),toolsControl:new _t(M,{nonNullable:true})}})}buildBuiltInRows(t,e){return t.map(a=>{let c=e!=null&&a.type in e,s=e?.[a.type],_=c?Array.isArray(s)&&s.length===0?"off":"on":"default";return {type:a.type,displayName:a.displayName,description:a.description,enabledByDefault:a.enabledByDefault===true,state:Gi(_),restrictedTools:Array.isArray(s)&&s.length>0?s:null}})}toggleIntegration(t){t.enabled.update(e=>!e);}setBuiltInState(t,e){t.state.set(e);}builtInDefaultLabel(t){return t.enabledByDefault?"Platform default (enabled)":"Platform default (disabled)"}addSubAgent(){let t=this.newSubAgentControl.value.trim();t&&(this.subAgentRows.update(e=>[...e,{control:new _t(t,{nonNullable:true})}]),this.newSubAgentControl.reset(""));}removeSubAgent(t){this.subAgentRows.update(e=>e.filter(a=>a!==t));}buildSubAgentsPayload(){let t=this.subAgentRows().map(e=>e.control.value.trim()).filter(e=>e.length>0);return t.length>0?t:void 0}buildIntegrationsPayload(){let t={};for(let a of this.integrationRows().filter(c=>c.enabled())){let c=a.config.name??"",s=a.toolsControl.value.trim();t[c]=s===""?null:s.split(",").map(_=>_.trim()).filter(_=>_.length>0);}for(let a of this.builtInRows()){let c=a.state();c==="on"?t[a.type]=a.restrictedTools??null:c==="off"&&(t[a.type]=[]);}let e=new Set([...this.integrationRows().map(a=>a.config.name??""),...this.builtInRows().map(a=>a.type)]);for(let[a,c]of Object.entries(this.existingConfig?.integrations??{}))e.has(a)||(t[a]=c);return Object.keys(t).length>0?t:void 0}submit(){if(this.form.invalid||this.isSubmitting())return;this.addSubAgent(),this.isSubmitting.set(true);let t=x(w({},this.existingConfig??{}),{createdOn:this.existingConfig?.createdOn,updatedOn:this.existingConfig?.updatedOn,namespaceId:this.namespaceId,name:this.nameControl.value.trim(),description:this.descriptionControl.value?.trim()||void 0,modelName:this.modelNameControl.value?.trim()||void 0,instructions:this.instructionsControl.value?.trim()||void 0,integrations:this.buildIntegrationsPayload(),executionMode:this.executionModeControl.value,advancedExecution:this.executionModeControl.value==="ADVANCED",enabled:this.enabledControl.value,subAgents:this.buildSubAgentsPayload(),skillSelectors:this.buildSkillSelectorsPayload(),delegationTimeoutSeconds:this.delegationTimeoutControl.value,loopConfig:this.buildLoopConfigPayload()});(this.isEditMode()?this.agentConfigController.updateAgentConfig(this.existingConfig.id??"",t):this.agentConfigController.createAgentConfig(t)).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}exportYaml(){let t=this.existingConfig?.id;!t||this.isExporting()||(this.isExporting.set(true),this.exportService.exportAsYaml(t).pipe(U$1(this.destroyRef)).subscribe({next:e=>{let a=new Blob([e],{type:"application/yaml"}),c=URL.createObjectURL(a),s=document.createElement("a");s.href=c,s.download=`${this.existingConfig?.name??"agent"}.yaml`,s.click(),URL.revokeObjectURL(c),this.isExporting.set(false);},error:()=>this.isExporting.set(false)}));}buildLoopConfigPayload(){let t=this.loopConfigControl.value?.trim();if(!t)return this.existingConfig?.loopConfig!=null?null:void 0;try{return JSON.parse(t)}catch(e){return}}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","agent-configs"]):this.router.navigate(["/agentos",this.namespaceId,"agent-configs"]);}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=xw({type:n,selectors:[["agentos-agent-config-form"]],decls:12,vars:4,consts:[[1,"agent-config-form"],[1,"agent-config-form__header"],["type","button","title","Back to agent configs",1,"agent-config-form__back",3,"click"],[1,"agent-config-form__back-icon"],[1,"agent-config-form__title"],[1,"agent-config-form__sibling-link",3,"routerLink"],[1,"agent-config-form__platform-badge"],[1,"agent-config-form__loading"],[1,"agent-config-form__form",3,"formGroup"],[1,"agent-config-form__form",3,"ngSubmit","formGroup"],[1,"agent-config-form__field"],["for","agent-config-name",1,"agent-config-form__label"],["aria-hidden","true"],["id","agent-config-name","type","text","placeholder","e.g. Support agent","autocomplete","off",1,"agent-config-form__input",3,"formControl"],["for","agent-config-description",1,"agent-config-form__label"],["id","agent-config-description","type","text","placeholder","Optional \u2014 short description of this agent","autocomplete","off",1,"agent-config-form__input",3,"formControl"],["for","agent-config-model-name",1,"agent-config-form__label"],["id","agent-config-model-name","type","text","placeholder","Optional \u2014 model alias or name to use","autocomplete","off",1,"agent-config-form__input",3,"formControl"],["for","agent-config-instructions",1,"agent-config-form__label"],["id","agent-config-instructions","rows","6","placeholder","Optional \u2014 system instructions for this agent",1,"agent-config-form__textarea",3,"formControl"],[1,"agent-config-form__integrations"],[1,"agent-config-form__skills"],[1,"agent-config-form__label"],[1,"agent-config-form__skills-hint"],[1,"agent-config-form__code"],[1,"agent-config-form__skill-all"],["type","checkbox",1,"agent-config-form__skill-checkbox",3,"change","checked"],[1,"agent-config-form__skill-name"],[1,"agent-config-form__field-hint"],["role","alert",1,"agent-config-form__skills-warning"],[1,"agent-config-form__skills-empty"],["for","agent-config-execution-mode",1,"agent-config-form__label"],["id","agent-config-execution-mode",1,"agent-config-form__select",3,"formControl"],[3,"value"],[1,"agent-config-form__toggle-label"],["type","checkbox",1,"agent-config-form__toggle-checkbox",3,"formControl"],[1,"agent-config-form__toggle-text"],[1,"agent-config-form__toggle-hint"],[1,"agent-config-form__sub-agent-list"],[1,"agent-config-form__sub-agent-add"],["type","text","placeholder","e.g. *Fixer or *","autocomplete","off",1,"agent-config-form__input","agent-config-form__sub-agent-input",3,"keydown.enter","formControl"],["type","button","title","Add pattern",1,"agent-config-form__sub-agent-btn","agent-config-form__sub-agent-btn--add",3,"click","disabled"],["for","delegation-timeout",1,"agent-config-form__label"],["id","delegation-timeout-hint",1,"agent-config-form__field-hint"],["id","delegation-timeout","type","number","min","1","max","2147483647","step","1","placeholder","Server default","aria-describedby","delegation-timeout-hint delegation-timeout-error",1,"agent-config-form__input",3,"formControl"],["id","delegation-timeout-error","role","alert",1,"agent-config-form__field-hint"],["type","button",1,"agent-config-form__sub-agent-btn"],[1,"agent-config-form__actions"],["type","submit",1,"agent-config-form__btn","agent-config-form__btn--primary",3,"disabled"],["type","button",1,"agent-config-form__btn","agent-config-form__btn--export",3,"disabled"],["type","button",1,"agent-config-form__btn",3,"click"],[1,"agent-config-form__integrations-hint"],[1,"agent-config-form__integration-row"],["role","note",1,"agent-config-form__integration-warning"],[1,"agent-config-form__integration-toggle"],["type","checkbox",1,"agent-config-form__integration-checkbox",3,"change","checked"],[1,"agent-config-form__integration-name"],[1,"agent-config-form__integration-type"],["type","text","placeholder","Tool names, comma-separated (empty = all tools)","autocomplete","off",1,"agent-config-form__input","agent-config-form__integration-tools",3,"formControl"],[1,"agent-config-form__integrations-separator"],[1,"agent-config-form__integration-state",3,"change","id","value"],["value","default"],["value","on"],["value","off"],[1,"agent-config-form__integration-restriction"],[1,"agent-config-form__integration-builtin-desc"],[1,"agent-config-form__skill-row"],[1,"agent-config-form__skill-toggle"],["type","checkbox",1,"agent-config-form__skill-checkbox",3,"change","checked","disabled"],[1,"agent-config-form__skill-badge"],[1,"agent-config-form__skill-badge","agent-config-form__skill-badge--unresolved"],[1,"agent-config-form__skill-desc"],["for","agent-config-loop-config",1,"agent-config-form__label"],["id","agent-config-loop-config","rows","10","spellcheck","false","autocomplete","off",1,"agent-config-form__textarea","agent-config-form__textarea--mono",3,"placeholder","formControl"],["role","alert",1,"agent-config-form__field-error"],[1,"agent-config-form__sub-agent-row"],["type","text","autocomplete","off",1,"agent-config-form__input","agent-config-form__sub-agent-input",3,"formControl"],["type","button","title","Remove",1,"agent-config-form__sub-agent-btn","agent-config-form__sub-agent-btn--danger",3,"click"],["type","button",1,"agent-config-form__sub-agent-btn",3,"click"],["type","button",1,"agent-config-form__btn","agent-config-form__btn--export",3,"click","disabled"]],template:function(e,a){e&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return a.cancel()}),ws(3,"span",3),GC(4,"\u2190"),pl(),GC(5," Agent Configs "),pl(),ws(6,"h1",4),GC(7),pl(),Jw(8,Me,2,1,"a",5),Jw(9,Ae,2,0,"span",6),pl(),Jw(10,Ie,2,0,"p",7)(11,tt,100,28,"form",8),pl()),e&2&&(XE(7),Yg(a.isEditMode()?"Edit agent config":"New agent config"),XE(),eC(a.isEditMode()?8:-1),XE(),eC(a.isPlatformMode?9:-1),XE(),eC(a.isLoading()?10:11));},dependencies:[ni,Jn,Qn,ei,Ye$1,fn,wt,At,Zn,Xn,$t,Wt,Cn,En,$t$1],styles:[".agent-config-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.agent-config-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.agent-config-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.agent-config-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.agent-config-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.agent-config-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.agent-config-form__sibling-link[_ngcontent-%COMP%]{font-size:.8125rem;color:var(--color-accent);text-decoration:none}.agent-config-form__sibling-link[_ngcontent-%COMP%]:hover{text-decoration:underline}.agent-config-form__platform-badge[_ngcontent-%COMP%]{display:inline-block;font-size:.75rem;font-weight:500;color:var(--color-text-secondary);background:var(--color-surface);border:1px solid var(--color-divider);border-radius:0;padding:.125rem .5rem;letter-spacing:.02em;align-self:flex-start}.agent-config-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.agent-config-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.agent-config-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.agent-config-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.agent-config-form__input[_ngcontent-%COMP%], .agent-config-form__textarea[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.agent-config-form__input[_ngcontent-%COMP%]:focus, .agent-config-form__textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.agent-config-form__input[_ngcontent-%COMP%]::placeholder, .agent-config-form__textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.agent-config-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:120px;line-height:1.5}.agent-config-form__textarea--mono[_ngcontent-%COMP%]{font-family:monospace;font-size:.8125rem}.agent-config-form__field-error[_ngcontent-%COMP%]{margin:.25rem 0 0;font-size:.8rem;color:var(--color-error, var(--red, #dc2626));line-height:1.4}.agent-config-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;cursor:pointer;transition:border-color .15s ease;appearance:auto}.agent-config-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.agent-config-form__integrations[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:.75rem}.agent-config-form__integrations-hint[_ngcontent-%COMP%]{margin:0;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.agent-config-form__integration-row[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.agent-config-form__integration-toggle[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.agent-config-form__integration-checkbox[_ngcontent-%COMP%]{width:1rem;height:1rem;flex-shrink:0;accent-color:var(--color-accent);cursor:pointer}.agent-config-form__integration-name[_ngcontent-%COMP%]{font-size:.9rem;font-weight:500;color:var(--color-text)}.agent-config-form__integration-type[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary);font-family:monospace}.agent-config-form__integration-tools[_ngcontent-%COMP%]{margin-left:1.5rem;font-size:.875rem}.agent-config-form__integrations-separator[_ngcontent-%COMP%]{margin:.25rem 0 0;padding-top:.5rem;border-top:1px solid var(--color-divider);font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.12em;color:var(--color-neutral-500);font-family:var(--font-heading)}.agent-config-form__integration-state[_ngcontent-%COMP%]{margin-left:1.5rem;padding:.375rem .625rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.875rem;font-family:inherit;outline:none;transition:border-color .15s ease}.agent-config-form__integration-state[_ngcontent-%COMP%]:focus{border-color:var(--color-primary, #007aff)}.agent-config-form__integration-warning[_ngcontent-%COMP%]{margin:.5rem 0 0;font-size:.8rem;color:var(--color-warning, #b25000);line-height:1.4}.agent-config-form__integration-restriction[_ngcontent-%COMP%]{margin:0 0 0 1.5rem;font-size:.8rem;font-style:italic;color:var(--color-text-secondary, #6e6e73);line-height:1.4}.agent-config-form__integration-builtin-desc[_ngcontent-%COMP%]{margin:0 0 0 1.5rem;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.agent-config-form__skills[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:.5rem}.agent-config-form__skills-hint[_ngcontent-%COMP%]{margin:0;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.agent-config-form__skills-warning[_ngcontent-%COMP%]{margin:0;font-size:.8rem;line-height:1.4;color:var(--color-error, var(--red, #dc2626))}.agent-config-form__skills-empty[_ngcontent-%COMP%]{margin:0;font-size:.8rem;font-style:italic;color:var(--color-text-secondary)}.agent-config-form__skill-all[_ngcontent-%COMP%], .agent-config-form__skill-toggle[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer}.agent-config-form__skill-row[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.25rem}.agent-config-form__skill-checkbox[_ngcontent-%COMP%]{flex:0 0 auto}.agent-config-form__skill-name[_ngcontent-%COMP%]{font-size:.875rem}.agent-config-form__skill-badge[_ngcontent-%COMP%]{font-size:.75rem;font-family:monospace;color:var(--color-text-secondary)}.agent-config-form__skill-badge--unresolved[_ngcontent-%COMP%]{color:var(--color-error, var(--red, #dc2626))}.agent-config-form__skill-desc[_ngcontent-%COMP%]{margin:0 0 0 1.5rem;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.agent-config-form__field-hint[_ngcontent-%COMP%]{margin:.25rem 0 0;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.agent-config-form__code[_ngcontent-%COMP%]{font-family:monospace;font-size:.85em;background:var(--color-surface-muted, rgba(0, 0, 0, .06));padding:.1em .3em;border-radius:0}.agent-config-form__sub-agent-list[_ngcontent-%COMP%]{list-style:none;margin:.5rem 0 0;padding:0;display:flex;flex-direction:column;gap:.375rem}.agent-config-form__sub-agent-row[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem}.agent-config-form__sub-agent-input[_ngcontent-%COMP%]{flex:1;min-width:0}.agent-config-form__sub-agent-add[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem;margin-top:.5rem}.agent-config-form__sub-agent-btn[_ngcontent-%COMP%]{flex-shrink:0;width:2rem;height:2rem;padding:0;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text-secondary);font-size:.9rem;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s ease,border-color .15s ease,color .15s ease}.agent-config-form__sub-agent-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500);color:var(--color-text)}.agent-config-form__sub-agent-btn[_ngcontent-%COMP%]:disabled{opacity:.35;cursor:not-allowed}.agent-config-form__sub-agent-btn--add[_ngcontent-%COMP%]{width:2rem;height:2rem;font-size:1.25rem;font-weight:300;border-color:var(--color-accent);color:var(--color-accent)}.agent-config-form__sub-agent-btn--add[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent);color:#fff}.agent-config-form__sub-agent-btn--danger[_ngcontent-%COMP%]{border:1px solid transparent;color:var(--color-neutral-500)}.agent-config-form__sub-agent-btn--danger[_ngcontent-%COMP%]:hover:not(:disabled){border-color:var(--red);color:var(--red);background:color-mix(in srgb,var(--red) 10%,transparent)}.agent-config-form__toggle-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.agent-config-form__toggle-checkbox[_ngcontent-%COMP%]{width:1rem;height:1rem;flex-shrink:0;accent-color:var(--color-accent);cursor:pointer}.agent-config-form__toggle-text[_ngcontent-%COMP%]{font-size:.9rem;font-weight:500;color:var(--color-text)}.agent-config-form__toggle-hint[_ngcontent-%COMP%]{margin:.25rem 0 0 1.5rem;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.agent-config-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.agent-config-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.agent-config-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.agent-config-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.agent-config-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.agent-config-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{Se as AgentConfigFormComponent};
@@ -0,0 +1 @@
1
+ import {c}from'./chunk-cAni-AV8.js';import {g,ao as W,F,C as Ce$1,da as $,db as Ee$1,dc as Re$1,G as Gi,dd as Oe$1,a as F$1,bR as wd,m as mT,M as By,b as U,a7 as ya,Q as br,x,w,e as xw,k as ws,q as Rg,n as GC,o as pl,J as Jw,X as XE,a5 as vl,v as eC,a9 as lC,S as Sg,a3 as VI,s as rC,ac as gC,u as bg,z as Ug,a6 as UI,y as oC,a8 as Yg,aa as If,ab as wf,bk as yh}from'./main-IZL5CRF5.js';import {o as z,k as _t,b as _e$1,n as ni,J as Jn,Q as Qn,e as ei,Y as Ye,f as fn,a as wt,A as At,Z as Zn,l as Xn,$ as $t,C as Cn,E as En}from'./chunk-C2h5l5r_.js';var A=(n,t)=>t.value,me=(n,t)=>t.id;function pe(n,t){n&1&&(ws(0,"p",5),GC(1,"Loading\u2026"),pl());}function ue(n,t){n&1&&(ws(0,"span",12),GC(1," Name is required. "),pl());}function fe(n,t){if(n&1&&(ws(0,"p",42),GC(1),pl(),ws(2,"span",13),GC(3,"Agent Config cannot be changed after creation."),pl()),n&2){let e=gC(2);XE(),Yg(e.resolveAgentConfigName(e.agentConfigIdControl.value));}}function _e(n,t){if(n&1&&(ws(0,"a",43),GC(1,"Add an agent config"),pl(),GC(2," first. ")),n&2){let e=gC(3);bg("href","/agentos/"+e.namespaceId+"/agent-configs/new",yh);}}function he(n,t){if(n&1&&(ws(0,"p",13),GC(1," No agent configs available in this scope yet. "),Jw(2,_e,3,1),pl()),n&2){let e=gC(2);XE(2),eC(e.isPlatformMode?-1:2);}}function ge(n,t){if(n&1&&(ws(0,"option",23),GC(1),pl()),n&2){let e=t.$implicit;bg("value",e.id),XE(),Yg(e.name);}}function Ce(n,t){n&1&&(ws(0,"span",12),GC(1,"Agent Config is required."),pl());}function ve(n,t){if(n&1&&(ws(0,"select",44)(1,"option",45),GC(2,"Select an agent config\u2026"),pl(),rC(3,ge,2,2,"option",23,me),pl(),VI(),Jw(5,Ce,2,0,"span",12),ws(6,"span",13),GC(7,"Immutable after creation."),pl()),n&2){let e=gC(2);bg("formControl",e.agentConfigIdControl),UI(),XE(3),oC(e.availableAgentConfigs()),XE(2),eC(e.agentConfigIdControl.invalid&&e.agentConfigIdControl.touched?5:-1);}}function xe(n,t){n&1&&(ws(0,"span",12),GC(1,"Opening message is required."),pl());}function ye(n,t){if(n&1&&(ws(0,"option",23),GC(1),pl()),n&2){let e=t.$implicit;bg("value",e.value),XE(),Yg(e.label);}}function be(n,t){if(n&1){let e=lC();ws(0,"label",48)(1,"input",49),Rg("change",function(){let g=If(e).$implicit,v=gC(3);return wf(v.toggleDay(g.value))}),pl(),ws(2,"span",50),GC(3),pl()();}if(n&2){let e=t.$implicit,d=gC(3);XE(),bg("checked",d.isDaySelected(e.value)),XE(2),Yg(e.label);}}function Se(n,t){if(n&1&&(ws(0,"div",8)(1,"span",46),GC(2,"Days of week"),pl(),ws(3,"div",47),rC(4,be,4,2,"label",48,A),pl(),ws(6,"span",13),GC(7,"Leave empty to run every day of the week."),pl()()),n&2){let e=gC(2);XE(4),oC(e.dayOptions);}}function Ee(n,t){n&1&&(ws(0,"span",12),GC(1,"Valid time is required (HH:mm)."),pl());}function Pe(n,t){n&1&&(ws(0,"span",12),GC(1,"Start date is required."),pl());}function Me(n,t){if(n&1&&(ws(0,"option",23),GC(1),pl()),n&2){let e=t.$implicit;bg("value",e.value),XE(),Yg(e.label);}}function Oe(n,t){n&1&&(ws(0,"span",12),GC(1,"End date is required."),pl());}function De(n,t){if(n&1&&(ws(0,"div",8)(1,"label",51),GC(2," End date "),ws(3,"span",10),GC(4,"*"),pl()(),Sg(5,"input",52),VI(),Jw(6,Oe,2,0,"span",12),pl()),n&2){let e=gC(2);XE(5),Ug("scheduled-prompt-form__input--invalid",e.form.hasError("endDateRequired")&&e.endDateControl.touched),bg("formControl",e.endDateControl),UI(),XE(),eC(e.form.hasError("endDateRequired")&&e.endDateControl.touched?6:-1);}}function Te(n,t){n&1&&(ws(0,"span",12),GC(1,"Must be at least 1."),pl());}function we(n,t){if(n&1&&(ws(0,"div",8)(1,"label",53),GC(2," Number of occurrences "),ws(3,"span",10),GC(4,"*"),pl()(),Sg(5,"input",54),VI(),Jw(6,Te,2,0,"span",12),pl()),n&2){let e=gC(2);XE(5),Ug("scheduled-prompt-form__input--invalid",e.form.hasError("occurrenceCountRequired")&&e.occurrenceCountControl.touched),bg("formControl",e.occurrenceCountControl),UI(),XE(),eC(e.form.hasError("occurrenceCountRequired")&&e.occurrenceCountControl.touched?6:-1);}}function ke(n,t){n&1&&(ws(0,"span",12),GC(1,"Invalid JSON."),pl());}function Ne(n,t){if(n&1&&(ws(0,"p",38),GC(1),pl()),n&2){let e=gC(2);XE(),Yg(e.errorMessage());}}function Fe(n,t){if(n&1){let e=lC();ws(0,"form",7),Rg("ngSubmit",function(){If(e);let g=gC();return wf(g.submit())}),ws(1,"div",8)(2,"label",9),GC(3," Name "),ws(4,"span",10),GC(5,"*"),pl()(),Sg(6,"input",11),VI(),Jw(7,ue,2,0,"span",12),ws(8,"span",13),GC(9,'Free-form name (e.g. "Weekly Report"). Cannot be changed after creation.'),pl()(),ws(10,"div",8)(11,"label",14),GC(12,"Description"),pl(),Sg(13,"input",15),VI(),pl(),ws(14,"div",8)(15,"label",16),GC(16," Agent Config "),ws(17,"span",10),GC(18,"*"),pl()(),Jw(19,fe,4,1)(20,he,3,1,"p",13)(21,ve,8,2),pl(),ws(22,"div",8)(23,"label",17),GC(24," Opening message "),ws(25,"span",10),GC(26,"*"),pl()(),Sg(27,"textarea",18),VI(),Jw(28,xe,2,0,"span",12),ws(29,"span",13),GC(30," The message sent to the agent when the scheduled prompt fires. "),pl()(),ws(31,"fieldset",19)(32,"legend",20),GC(33,"Recurrence"),pl(),ws(34,"div",8)(35,"label",21),GC(36," Unit "),ws(37,"span",10),GC(38,"*"),pl()(),ws(39,"select",22),rC(40,ye,2,2,"option",23,A),pl(),VI(),pl(),Jw(42,Se,8,0,"div",8),ws(43,"div",8)(44,"label",24),GC(45," Time (UTC) "),ws(46,"span",10),GC(47,"*"),pl()(),ws(48,"div",25),Sg(49,"input",26),VI(),ws(50,"span",27),GC(51,"UTC"),pl()(),Jw(52,Ee,2,0,"span",12),pl()(),ws(53,"fieldset",19)(54,"legend",20),GC(55,"Planning"),pl(),ws(56,"div",8)(57,"label",28),GC(58," Start date "),ws(59,"span",10),GC(60,"*"),pl()(),Sg(61,"input",29),VI(),Jw(62,Pe,2,0,"span",12),pl(),ws(63,"div",8)(64,"label",30),GC(65," Ends "),ws(66,"span",10),GC(67,"*"),pl()(),ws(68,"select",31),rC(69,Me,2,2,"option",23,A),pl(),VI(),pl(),Jw(71,De,7,4,"div",8),Jw(72,we,7,4,"div",8),pl(),ws(73,"div",8)(74,"label",32),Sg(75,"input",33),VI(),ws(76,"span",34),GC(77,"Enabled"),pl()(),ws(78,"p",35),GC(79," When disabled, the scheduled prompt is saved but will not run on schedule. "),pl()(),ws(80,"div",8)(81,"label",36),GC(82,"External Metadata"),pl(),Sg(83,"textarea",37),VI(),Jw(84,ke,2,0,"span",12),ws(85,"span",13),GC(86,"Optional. Opaque JSON object stored as-is. Leave empty to clear."),pl()(),Jw(87,Ne,2,1,"p",38),ws(88,"div",39)(89,"button",40),GC(90),pl(),ws(91,"button",41),Rg("click",function(){If(e);let g=gC();return wf(g.cancel())}),GC(92,"Cancel"),pl()()();}if(n&2){let e=gC();bg("formGroup",e.form),XE(6),Ug("scheduled-prompt-form__input--invalid",e.nameControl.invalid&&e.nameControl.touched),bg("formControl",e.nameControl),UI(),XE(),eC(e.nameControl.invalid&&e.nameControl.touched?7:-1),XE(6),bg("formControl",e.descriptionControl),UI(),XE(6),eC(e.isEditMode()?19:e.availableAgentConfigs().length===0?20:21),XE(8),Ug("scheduled-prompt-form__textarea--invalid",e.promptContentControl.invalid&&e.promptContentControl.touched),bg("formControl",e.promptContentControl),UI(),XE(),eC(e.promptContentControl.invalid&&e.promptContentControl.touched?28:-1),XE(11),bg("formControl",e.unitControl),UI(),XE(),oC(e.schedulerUnits),XE(2),eC(e.showDayFilter()?42:-1),XE(7),bg("formControl",e.timeUtcControl),UI(),XE(3),eC(e.timeUtcControl.invalid&&e.timeUtcControl.touched?52:-1),XE(9),Ug("scheduled-prompt-form__input--invalid",e.startDateControl.invalid&&e.startDateControl.touched),bg("formControl",e.startDateControl),UI(),XE(),eC(e.startDateControl.invalid&&e.startDateControl.touched?62:-1),XE(6),bg("formControl",e.endTypeControl),UI(),XE(),oC(e.endTypes),XE(2),eC(e.showEndDate()?71:-1),XE(),eC(e.showOccurrenceCount()?72:-1),XE(3),bg("formControl",e.enabledControl),UI(),XE(8),bg("formControl",e.externalMetadataJsonControl),UI(),XE(),eC(e.externalMetadataJsonControl.invalid&&e.externalMetadataJsonControl.touched?84:-1),XE(3),eC(e.errorMessage()?87:-1),XE(2),bg("disabled",e.form.invalid||e.isSubmitting()),XE(),vl(" ",e.isEditMode()?"Save changes":"Create scheduled prompt"," ");}}var se=class n{route=g(W);router=g(F);destroyRef=g(Ce$1);state=g(c);agentConfigController=g($);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new z({name:new _t("",{nonNullable:true,validators:[_e$1.required]}),description:new _t(null),agentConfigId:new _t("",{nonNullable:true,validators:[_e$1.required]}),promptContent:new _t("",{nonNullable:true,validators:[_e$1.required]}),unit:new _t(Re$1.WEEK,{nonNullable:true,validators:[_e$1.required]}),days:new _t([],{nonNullable:true}),timeUtc:new _t("09:00",{nonNullable:true,validators:[_e$1.required,_e$1.pattern(/^([01]\d|2[0-3]):[0-5]\d$/)]}),startDate:new _t("",{nonNullable:true,validators:[_e$1.required]}),endType:new _t(Ee$1.NEVER,{nonNullable:true,validators:[_e$1.required]}),endDate:new _t(null),occurrenceCount:new _t(null),enabled:new _t(true,{nonNullable:true}),externalMetadataJson:new _t("",{nonNullable:true,validators:[Ae]})},{validators:[Ie,Ve]});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get agentConfigIdControl(){return this.form.controls.agentConfigId}get promptContentControl(){return this.form.controls.promptContent}get unitControl(){return this.form.controls.unit}get daysControl(){return this.form.controls.days}get timeUtcControl(){return this.form.controls.timeUtc}get startDateControl(){return this.form.controls.startDate}get endTypeControl(){return this.form.controls.endType}get endDateControl(){return this.form.controls.endDate}get occurrenceCountControl(){return this.form.controls.occurrenceCount}get enabledControl(){return this.form.controls.enabled}get externalMetadataJsonControl(){return this.form.controls.externalMetadataJson}isEditMode=Gi(false);isSubmitting=Gi(false);isLoading=Gi(false);errorMessage=Gi(null);SchedulerUnit=Re$1;SchedulerEndType=Ee$1;schedulerUnits=[{value:Re$1.WEEK,label:"Week(s)"},{value:Re$1.MONTH,label:"Month(s)"}];endTypes=[{value:Ee$1.NEVER,label:"Never"},{value:Ee$1.ON_DATE,label:"On date"},{value:Ee$1.OCCURRENCES,label:"After N occurrences"}];dayOptions=Object.entries(Oe$1).map(([t,e])=>({value:t,label:e}));unitSignal=F$1(this.unitControl.valueChanges.pipe(wd(this.unitControl.value)));endTypeSignal=F$1(this.endTypeControl.valueChanges.pipe(wd(this.endTypeControl.value)));showDayFilter=mT(()=>this.unitSignal()===Re$1.WEEK);showEndDate=mT(()=>this.endTypeSignal()===Ee$1.ON_DATE);showOccurrenceCount=mT(()=>this.endTypeSignal()===Ee$1.OCCURRENCES);agentConfigs=Gi([]);availableAgentConfigs=this.agentConfigs.asReadonly();existingPrompt=null;ngOnInit(){this.startDateControl.setValue(Re());let t=this.route.snapshot.paramMap.get("scheduledPromptId");t?(this.isEditMode.set(true),this.loadPromptAndResources(t)):this.loadResources();}loadPromptAndResources(t){this.isLoading.set(true),By({prompt:this.state.getById(t),agentConfigs:this.agentConfigs$()}).pipe(U(this.destroyRef)).subscribe({next:({prompt:e,agentConfigs:d})=>{this.existingPrompt=e,this.agentConfigs.set(d),this.hydrateForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}loadResources(){this.agentConfigs$().pipe(U(this.destroyRef)).subscribe(t=>this.agentConfigs.set(t));}agentConfigs$(){return (this.isPlatformMode?this.agentConfigController.listPlatformAgentsAgentConfig():this.agentConfigController.listByParentAgentConfig(this.namespaceId)).pipe(ya(()=>br([])))}hydrateForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.agentConfigIdControl.setValue(t.agentConfigId),this.promptContentControl.setValue(t.promptContent),this.unitControl.setValue(t.recurrence.unit),this.daysControl.setValue(t.recurrence.days??[]),this.timeUtcControl.setValue(t.recurrence.timeUtc),this.startDateControl.setValue(t.planning.startDate),this.endTypeControl.setValue(t.planning.endType),this.endDateControl.setValue(t.planning.endDate??null),this.occurrenceCountControl.setValue(t.planning.maxOccurrenceCount??null),this.enabledControl.setValue(t.enabled),this.externalMetadataJsonControl.setValue(t.externalMetadata?JSON.stringify(t.externalMetadata,null,2):"");}isDaySelected(t){return this.daysControl.value.includes(t)}toggleDay(t){let e=this.daysControl.value,d=e.includes(t)?e.filter(g=>g!==t):[...e,t];this.daysControl.setValue(d);}resolveAgentConfigName(t){return this.agentConfigs().find(e=>e.id===t)?.name??t}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true),this.errorMessage.set(null);let t=this.isEditMode()&&!!this.existingPrompt?.id,e=this.endTypeControl.value,d=x(w({},this.existingPrompt??{}),{namespaceId:this.namespaceId??null,name:this.nameControl.value.trim(),description:this.descriptionControl.value?.trim()||void 0,agentConfigId:t?this.existingPrompt.agentConfigId:this.agentConfigIdControl.value,promptContent:this.promptContentControl.value.trim(),recurrence:{unit:this.unitControl.value,days:this.daysControl.value,timeUtc:this.timeUtcControl.value},planning:{startDate:this.startDateControl.value,endType:e,endDate:e===Ee$1.ON_DATE?this.endDateControl.value??void 0:void 0,maxOccurrenceCount:e===Ee$1.OCCURRENCES?this.occurrenceCountControl.value??void 0:void 0},enabled:this.enabledControl.value,removed:this.existingPrompt?.removed??false,externalMetadata:(()=>{let v=this.externalMetadataJsonControl.value.trim();return v?JSON.parse(v):null})()});(t?this.state.update(this.existingPrompt.id,d):this.state.create(d)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:v=>{this.isSubmitting.set(false),v.status===409?this.errorMessage.set(`A scheduled prompt named "${d.name}" already exists in this scope.`):v.status===400?this.errorMessage.set(v.error?.message??"Invalid scheduled prompt data."):this.errorMessage.set("An unexpected error occurred. Please try again.");}});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","scheduled-prompts"]):this.router.navigate(["/agentos",this.namespaceId,"scheduled-prompts"]);}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=xw({type:n,selectors:[["agentos-scheduled-prompt-form"]],decls:10,vars:3,consts:[[1,"scheduled-prompt-form"],[1,"scheduled-prompt-form__header"],["type","button","title","Back to scheduled prompts",1,"scheduled-prompt-form__back",3,"click"],[1,"scheduled-prompt-form__back-icon"],[1,"scheduled-prompt-form__title"],[1,"scheduled-prompt-form__loading"],[1,"scheduled-prompt-form__form",3,"formGroup"],[1,"scheduled-prompt-form__form",3,"ngSubmit","formGroup"],[1,"scheduled-prompt-form__field"],["for","sp-name",1,"scheduled-prompt-form__label"],["aria-hidden","true"],["id","sp-name","type","text","placeholder","e.g. Weekly Report","autocomplete","off",1,"scheduled-prompt-form__input",3,"formControl"],[1,"scheduled-prompt-form__field-error"],[1,"scheduled-prompt-form__field-hint"],["for","sp-description",1,"scheduled-prompt-form__label"],["id","sp-description","type","text","placeholder","Optional \u2014 short description","autocomplete","off",1,"scheduled-prompt-form__input",3,"formControl"],["for","sp-agent-config",1,"scheduled-prompt-form__label"],["for","sp-prompt-content",1,"scheduled-prompt-form__label"],["id","sp-prompt-content","rows","6","placeholder","Enter the message sent to the agent when the scheduled prompt fires\u2026",1,"scheduled-prompt-form__textarea",3,"formControl"],[1,"scheduled-prompt-form__fieldset"],[1,"scheduled-prompt-form__legend"],["for","sp-unit",1,"scheduled-prompt-form__label"],["id","sp-unit",1,"scheduled-prompt-form__select",3,"formControl"],[3,"value"],["for","sp-time",1,"scheduled-prompt-form__label"],[1,"scheduled-prompt-form__time-wrapper"],["id","sp-time","type","time",1,"scheduled-prompt-form__input","scheduled-prompt-form__input--time",3,"formControl"],[1,"scheduled-prompt-form__utc-badge"],["for","sp-start-date",1,"scheduled-prompt-form__label"],["id","sp-start-date","type","date",1,"scheduled-prompt-form__input",3,"formControl"],["for","sp-end-type",1,"scheduled-prompt-form__label"],["id","sp-end-type",1,"scheduled-prompt-form__select",3,"formControl"],[1,"scheduled-prompt-form__toggle-label"],["type","checkbox",1,"scheduled-prompt-form__toggle-checkbox",3,"formControl"],[1,"scheduled-prompt-form__toggle-text"],[1,"scheduled-prompt-form__toggle-hint"],["for","sp-external-metadata",1,"scheduled-prompt-form__label"],["id","sp-external-metadata","rows","6","placeholder",'{ "key": "value" }',"spellcheck","false","autocomplete","off",1,"scheduled-prompt-form__textarea","scheduled-prompt-form__textarea--code",3,"formControl"],[1,"scheduled-prompt-form__error"],[1,"scheduled-prompt-form__actions"],["type","submit",1,"scheduled-prompt-form__btn","scheduled-prompt-form__btn--primary",3,"disabled"],["type","button",1,"scheduled-prompt-form__btn",3,"click"],[1,"scheduled-prompt-form__readonly-value"],[3,"href"],["id","sp-agent-config",1,"scheduled-prompt-form__select",3,"formControl"],["value","","disabled",""],[1,"scheduled-prompt-form__label"],[1,"scheduled-prompt-form__day-grid"],[1,"scheduled-prompt-form__day-label"],["type","checkbox",1,"scheduled-prompt-form__day-checkbox",3,"change","checked"],[1,"scheduled-prompt-form__day-text"],["for","sp-end-date",1,"scheduled-prompt-form__label"],["id","sp-end-date","type","date",1,"scheduled-prompt-form__input",3,"formControl"],["for","sp-occurrence-count",1,"scheduled-prompt-form__label"],["id","sp-occurrence-count","type","number","min","1",1,"scheduled-prompt-form__input","scheduled-prompt-form__input--number",3,"formControl"]],template:function(e,d){e&1&&(ws(0,"div",0)(1,"header",1)(2,"button",2),Rg("click",function(){return d.cancel()}),ws(3,"span",3),GC(4,"\u2190"),pl(),GC(5),pl(),ws(6,"h1",4),GC(7),pl()(),Jw(8,pe,2,0,"p",5)(9,Fe,93,28,"form",6),pl()),e&2&&(XE(5),vl(" ",d.isPlatformMode?"Platform Scheduled Prompts":"Scheduled Prompts"," "),XE(2),vl(" ",d.isEditMode()?"Edit scheduled prompt":"New scheduled prompt"," "),XE(),eC(d.isLoading()?8:9));},dependencies:[ni,Jn,Qn,ei,Ye,fn,wt,At,Zn,Xn,$t,Cn,En],styles:[".scheduled-prompt-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.scheduled-prompt-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.scheduled-prompt-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.scheduled-prompt-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.scheduled-prompt-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.scheduled-prompt-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.scheduled-prompt-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.9rem;margin:0}.scheduled-prompt-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.scheduled-prompt-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.scheduled-prompt-form__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.scheduled-prompt-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text, #1d1d1f)}.scheduled-prompt-form__input[_ngcontent-%COMP%], .scheduled-prompt-form__select[_ngcontent-%COMP%], .scheduled-prompt-form__textarea[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.scheduled-prompt-form__input[_ngcontent-%COMP%]:focus, .scheduled-prompt-form__select[_ngcontent-%COMP%]:focus, .scheduled-prompt-form__textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-primary, #007aff)}.scheduled-prompt-form__input[_ngcontent-%COMP%]::placeholder, .scheduled-prompt-form__select[_ngcontent-%COMP%]::placeholder, .scheduled-prompt-form__textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary, #6e6e73)}.scheduled-prompt-form__select[_ngcontent-%COMP%]{cursor:pointer;appearance:auto}.scheduled-prompt-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:100px;line-height:1.5}.scheduled-prompt-form__input--time[_ngcontent-%COMP%]{flex:1;min-width:0}.scheduled-prompt-form__input--number[_ngcontent-%COMP%]{max-width:120px}.scheduled-prompt-form__time-wrapper[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.scheduled-prompt-form__utc-badge[_ngcontent-%COMP%]{flex-shrink:0;font-size:.75rem;font-weight:600;font-family:monospace;color:var(--color-text-secondary, #6e6e73);background:var(--color-surface, rgba(0, 0, 0, .05));padding:.25rem .5rem;border-radius:4px;text-transform:uppercase;letter-spacing:.06em}.scheduled-prompt-form__fieldset[_ngcontent-%COMP%]{border:1px solid var(--color-border, rgba(0, 0, 0, .1));border-radius:8px;padding:1rem 1.25rem 1.25rem;margin:0;display:flex;flex-direction:column;gap:1.25rem}.scheduled-prompt-form__legend[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--color-text-secondary, #6e6e73);padding:0 .375rem}.scheduled-prompt-form__day-grid[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:.5rem}.scheduled-prompt-form__day-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem;cursor:pointer;-webkit-user-select:none;user-select:none}.scheduled-prompt-form__day-checkbox[_ngcontent-%COMP%]{width:1rem;height:1rem;flex-shrink:0;accent-color:var(--color-primary, #007aff);cursor:pointer}.scheduled-prompt-form__day-text[_ngcontent-%COMP%]{font-size:.875rem;color:var(--color-text, #1d1d1f)}.scheduled-prompt-form__hint[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text-secondary, #6e6e73)}.scheduled-prompt-form__hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:var(--color-primary, #007aff);text-decoration:none}.scheduled-prompt-form__hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}.scheduled-prompt-form__error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-error, #ff3b30);margin:0}.scheduled-prompt-form__field-error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-error, #ff3b30)}.scheduled-prompt-form__field-hint[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, #6e6e73);line-height:1.4}.scheduled-prompt-form__field-hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:var(--color-primary, #007aff);text-decoration:none}.scheduled-prompt-form__field-hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}.scheduled-prompt-form__readonly-value[_ngcontent-%COMP%]{margin:0;font-size:.9375rem;color:var(--color-text, #1d1d1f);padding:.625rem .875rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .08));background:var(--color-surface, rgba(0, 0, 0, .03))}.scheduled-prompt-form__input--invalid[_ngcontent-%COMP%], .scheduled-prompt-form__textarea--invalid[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.scheduled-prompt-form__toggle-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.scheduled-prompt-form__toggle-checkbox[_ngcontent-%COMP%]{width:1rem;height:1rem;flex-shrink:0;accent-color:var(--color-primary, #007aff);cursor:pointer}.scheduled-prompt-form__toggle-text[_ngcontent-%COMP%]{font-size:.9rem;font-weight:500;color:var(--color-text, #1d1d1f)}.scheduled-prompt-form__toggle-hint[_ngcontent-%COMP%]{margin:.25rem 0 0 1.5rem;font-size:.8rem;color:var(--color-text-secondary, #6e6e73);line-height:1.4}.scheduled-prompt-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.scheduled-prompt-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.scheduled-prompt-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-surface-hover, rgba(0, 0, 0, .04))}.scheduled-prompt-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.scheduled-prompt-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary, #007aff);border-color:var(--color-primary, #007aff);color:#fff}.scheduled-prompt-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, #0051d5);border-color:var(--color-primary-hover, #0051d5)}"]})};function Ie(n){let t=n.get("endType")?.value,e=n.get("endDate")?.value;return t===Ee$1.ON_DATE&&!e?{endDateRequired:true}:null}function Ve(n){let t=n.get("endType")?.value,e=n.get("occurrenceCount")?.value;return t===Ee$1.OCCURRENCES&&(e==null||e<1)?{occurrenceCountRequired:true}:null}function Ae(n){let t=n.value?.trim();if(!t)return null;try{return JSON.parse(t),null}catch(e){return {invalidJson:true}}}function Re(){let n=new Date,t=n.getFullYear(),e=String(n.getMonth()+1).padStart(2,"0"),d=String(n.getDate()).padStart(2,"0");return `${t}-${e}-${d}`}export{se as ScheduledPromptFormComponent};