@whoz-oss/coday-client 0.0.0-workstream-messaging.5 → 0.0.0-workstream-messaging.6

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 (57) hide show
  1. package/browser/{chunk-Bvjz4EuH.js → chunk-5j6qVmNr.js} +1 -1
  2. package/browser/{chunk-CfeR-40i.js → chunk-BRlHxogh.js} +1 -1
  3. package/browser/{chunk-DqQwkTmj.js → chunk-BZzn53bQ.js} +1 -1
  4. package/browser/{chunk-go60iT_m.js → chunk-BeT-E8P2.js} +1 -1
  5. package/browser/{chunk-D7cDcWU_.js → chunk-Bp_ymzom.js} +1 -1
  6. package/browser/chunk-BsJuusWB.js +1 -0
  7. package/browser/{chunk-DzlYU9Mb.js → chunk-BtrZ-Mv4.js} +1 -1
  8. package/browser/{chunk-CEFBjtqS.js → chunk-BvPY6zMm.js} +1 -1
  9. package/browser/{chunk-BMfdBnfJ.js → chunk-Bz76f5F9.js} +1 -1
  10. package/browser/{chunk-Dyc4B4N5.js → chunk-C3ILbsIC.js} +1 -1
  11. package/browser/{chunk-MmNnob5o.js → chunk-C3IqVFBm.js} +1 -1
  12. package/browser/{chunk-m2Qa9RC5.js → chunk-CH4u_0xa.js} +1 -1
  13. package/browser/{chunk-YazOGc5y.js → chunk-CIXkHX9u.js} +1 -1
  14. package/browser/chunk-COmLfT0N.js +674 -0
  15. package/browser/{chunk-BeJGuL-w.js → chunk-Cc0MCjmC.js} +1 -1
  16. package/browser/{chunk-DyrGPeSh.js → chunk-CgBP6cXi.js} +1 -1
  17. package/browser/{chunk-Df_pypwY.js → chunk-Cmjv1U23.js} +1 -1
  18. package/browser/{chunk-tHzqEHGj.js → chunk-CoioEeqa.js} +1 -1
  19. package/browser/{chunk-DQEn5_2f.js → chunk-Cq9jD9x7.js} +1 -1
  20. package/browser/{chunk-_4rWzEoG.js → chunk-Cs7JPANX.js} +1 -1
  21. package/browser/{chunk-BUVHuntB.js → chunk-Ct5SlLjd.js} +1 -1
  22. package/browser/{chunk-D6na643q.js → chunk-D0vHzITV.js} +1 -1
  23. package/browser/{chunk-OGl61xgu.js → chunk-D1kq6J6C.js} +1 -1
  24. package/browser/{chunk-XCYDtfAr.js → chunk-D2xRGvgz.js} +1 -1
  25. package/browser/{chunk-C_m8f_OQ.js → chunk-DGEz4p7l.js} +1 -1
  26. package/browser/{chunk-BT-f7pOo.js → chunk-DIVQtNVn.js} +1 -1
  27. package/browser/{chunk-BDVgHP1k.js → chunk-DKL6wv8w.js} +1 -1
  28. package/browser/{chunk-cAmP4Ess.js → chunk-DSMx6Y5L.js} +1 -1
  29. package/browser/chunk-DTS0hzha.js +1 -0
  30. package/browser/chunk-DX8h3arb.js +1 -0
  31. package/browser/{chunk-L1iy-QYW.js → chunk-DkBkSmvX.js} +1 -1
  32. package/browser/{chunk-Jcjs0qUP.js → chunk-DmRaBKc6.js} +1 -1
  33. package/browser/{chunk-BfmxY0U2.js → chunk-DnB0tF3N.js} +1 -1
  34. package/browser/{chunk-DJYg-Uvg.js → chunk-DnkCIZhe.js} +1 -1
  35. package/browser/{chunk-BvgKYsgP.js → chunk-Dx9mLY6-.js} +1 -1
  36. package/browser/chunk-DxIOAne_.js +1 -0
  37. package/browser/{chunk-B7jX7zgs.js → chunk-Dzy8eQLO.js} +1 -1
  38. package/browser/{chunk-CaLaUzUo.js → chunk-GF2Xn6bl.js} +1 -1
  39. package/browser/{chunk-CYowS7ps.js → chunk-YrkvQ7uA.js} +1 -1
  40. package/browser/{chunk-DSeOF-b7.js → chunk-ZPs3mDFS.js} +1 -1
  41. package/browser/{chunk-DloTeM9a.js → chunk-_RBJYLm-.js} +1 -1
  42. package/browser/{chunk-CCUIsU71.js → chunk-_VwpOjoS.js} +1 -1
  43. package/browser/{chunk-Cvh22V1I.js → chunk-aqEkIRN7.js} +1 -1
  44. package/browser/{chunk-BvRDo1Xd.js → chunk-b_xoWNAu.js} +1 -1
  45. package/browser/{chunk-CasQE1P8.js → chunk-m4ODhjhI.js} +1 -1
  46. package/browser/{chunk-DQRocvRJ.js → chunk-rLH5JBfe.js} +1 -1
  47. package/browser/{chunk-xMNw9k_r.js → chunk-sEql4aGA.js} +1 -1
  48. package/browser/{chunk-BITDsEPS.js → chunk-vEjTDtHB.js} +1 -1
  49. package/browser/{chunk-BkHh71pt.js → chunk-v_8QrHNJ.js} +1 -1
  50. package/browser/index.html +1 -1
  51. package/browser/{main-63IEQS3X.js → main-B6UJJXO7.js} +7 -7
  52. package/package.json +1 -1
  53. package/browser/chunk-C1OYQ9z3.js +0 -1
  54. package/browser/chunk-CCZ1b0na.js +0 -674
  55. package/browser/chunk-CVAz4Lko.js +0 -1
  56. package/browser/chunk-DdcAhCFt.js +0 -1
  57. package/browser/chunk-ns52VA45.js +0 -1
@@ -1 +1 @@
1
- import {O}from'./chunk-BvgKYsgP.js';import {v}from'./chunk-Cvh22V1I.js';import {g,W,F,w as we,M as Mi,ad as F$1,ar as $e,s as sf,x as U,J as JI,o as os,Q as qh,f as fC,z as zu,E as Ew,a as EE,N as Vh,I as Iw,n as Aw,i as bw,as as Cw,R as uI,H as Hh,aq as ww,P as Pw,S as dI,T as Tw,Y as Yu,ai as vw,l as lg,q as Pd,L as Ld}from'./main-63IEQS3X.js';import {p as pt,L as Lt,T as Te,g as gn,b as hn,c as fn,u as un,t as dn,d as cn,e as at,i as sn,v as an,q as qt,m as md,C as Co,M as Mo,H as Ht,U as Ut,z as ya,a as po,h as ho,A as An,O as On,w as wa,_ as _o,I as vo}from'./chunk-CCZ1b0na.js';import'./chunk-CVAz4Lko.js';function ge(o,t){o&1&&(os(0,"p",2),fC(1,"Loading\u2026"),zu());}function be(o,t){if(o&1&&(os(0,"label",23),Hh(1,"input",24),uI(),fC(2),zu()),o&2){let e=t.$implicit,r=Pw(3);EE(),Vh("formControl",r.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!r.isAdmin()),dI(),EE(),Yu(" ",e.label," ");}}function _e(o,t){if(o&1&&(os(0,"ds-fieldset",5),bw(1,be,3,4,"label",23,vw().trackByScope,true),zu()),o&2){let e=Pw(2);Vh("disabled",e.isEditMode()),EE(),Tw(e.scopeOptions);}}function Ae(o,t){if(o&1&&(os(0,"option",8),fC(1),zu()),o&2){let e=t.$implicit;Vh("value",e),EE(),lg(e);}}function Se(o,t){if(o&1){let e=Aw();os(0,"div",19),Hh(1,"input",25),uI(),Hh(2,"input",26),uI(),os(3,"button",27),qh("click",function(){let l=Pd(e).$index,f=Pw(2);return Ld(f.removeHeader(l))}),fC(4," \xD7 "),zu()();}if(o&2){let e=t.$index;Vh("formGroupName",e),EE(),dI(),EE(),dI();}}function Pe(o,t){if(o&1){let e=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(e);let l=Pw();return Ld(l.submit())}),Ew(1,_e,3,1,"ds-fieldset",5),os(2,"ds-form-field",6)(3,"select",7),bw(4,Ae,2,2,"option",8,Cw),zu(),uI(),zu(),os(6,"ds-form-field",9),Hh(7,"input",10),uI(),zu(),os(8,"ds-form-field",11),Hh(9,"input",12),uI(),zu(),os(10,"ds-form-field",13),Hh(11,"input",14),uI(),zu(),os(12,"ds-form-field",15),Hh(13,"input",16),uI(),zu(),os(14,"ds-form-field",17)(15,"div",18),bw(16,Se,5,1,"div",19,ww),os(18,"div")(19,"button",20),qh("click",function(){Pd(e);let l=Pw();return Ld(l.addHeader())}),fC(20,"+ Add header"),zu()()()(),os(21,"ds-form-actions")(22,"button",21),fC(23),zu(),os(24,"button",22),qh("click",function(){Pd(e);let l=Pw();return Ld(l.cancel())}),fC(25,"Cancel"),zu()()();}if(o&2){let e=Pw();Vh("formGroup",e.form),EE(),Iw(e.isPlatformMode?-1:1),EE(2),Vh("formControl",e.apiTypeControl),dI(),EE(),Tw(e.apiTypeOptions),EE(3),Vh("formControl",e.nameControl),dI(),EE(2),Vh("formControl",e.descriptionControl),dI(),EE(2),Vh("formControl",e.baseUrlControl),dI(),EE(2),Vh("formControl",e.apiKeyControl),dI(),EE(2),Vh("formArrayName","headers"),EE(),Tw(e.headersArray.controls),EE(6),Vh("disabled",e.form.invalid||e.isSubmitting()),EE(),Yu(" ",e.isEditMode()?"Save changes":"Create"," ");}}var xe=new Set(["namespace","userOnNs","userGlobal"]),E=Object.freeze({platform:"Configuration de niveau plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ye=class o{route=g(W);router=g(F);destroyRef=g(we);state=g(O);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?Mi(true):F$1(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});apiTypeOptions=Object.values($e);scopeOptions=[{value:"namespace",label:E.namespace},{value:"userOnNs",label:E.userOnNs},{value:"userGlobal",label:E.userGlobal}];form=new pt({name:new Te("",{nonNullable:true,validators:[gn.required,gn.minLength(1)]}),description:new Te(null),apiType:new Te("OpenAI",{nonNullable:true,validators:[gn.required]}),baseUrl:new Te("",{nonNullable:true}),apiKey:new Te("",{nonNullable:true}),scope:new Te("namespace",{nonNullable:true}),headers:new Lt([],{validators:[]})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get apiTypeControl(){return this.form.controls.apiType}get baseUrlControl(){return this.form.controls.baseUrl}get apiKeyControl(){return this.form.controls.apiKey}get scopeControl(){return this.form.controls.scope}get headersArray(){return this.form.controls.headers}addHeader(){this.headersArray.push(new pt({key:new Te("",{nonNullable:true,validators:[gn.required]}),value:new Te("",{nonNullable:true})}));}removeHeader(t){this.headersArray.removeAt(t);}isEditMode=Mi(false);isSubmitting=Mi(false);isLoading=Mi(false);existingConfig=null;initialApiKey="";constructor(){this.isPlatformMode||sf(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,r=t.get("aiProviderId"),l=this.isPlatformMode?"namespace":this.parseScope(e.get("scope"));if(r){this.isEditMode.set(true),this.scopeControl.disable(),this.apiTypeControl.disable(),this.loadConfig(r);return}this.scopeControl.setValue(l);let f=e.get("template");f&&this.hydrateFromTemplate(f);}parseScope(t){return t&&xe.has(t)?t:"namespace"}deriveScopeFromConfig(t){return !t.userId?"namespace":t.namespaceId?"userOnNs":"userGlobal"}loadConfig(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[AiProviderForm] Could not load provider '${t}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.apiTypeControl.setValue(e.apiType),this.baseUrlControl.setValue(e.baseUrl??""),this.apiKeyControl.setValue(""),this.initialApiKey="",this.apiKeyControl.markAsTouched(),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[AiProviderForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.apiTypeControl.setValue(t.apiType),this.baseUrlControl.setValue(t.baseUrl??"");let e=t.apiKey??"";this.apiKeyControl.setValue(e),this.initialApiKey=e,this.headersArray.clear();for(let[r,l]of Object.entries(t.headers??{}))this.headersArray.push(new pt({key:new Te(r,{nonNullable:true,validators:[gn.required]}),value:new Te(l,{nonNullable:true})}));}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let t=this.descriptionControl.value?.trim(),e=this.baseUrlControl.value.trim(),r=this.apiKeyControl.value,l=this.isEditMode()&&r===this.initialApiKey?null:r,f=this.headersArray.controls.filter(A=>A.controls.key.value.trim()).map(A=>[A.controls.key.value.trim(),A.controls.value.value]),Ce=f.length>0?Object.fromEntries(f):null,V={name:this.nameControl.value.trim(),apiType:this.apiTypeControl.value,description:t||null,baseUrl:e||null,apiKey:l,headers:Ce},w=this.form.getRawValue().scope,he=this.isPlatformMode?null:this.namespaceId??null;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,V,w,this.existingConfig):this.state.create(V,w,he)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","ai-providers"]):this.router.navigate(["/agentos",this.namespaceId,"ai-providers"]);}trackByScope(t,e){return e.value}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JI({type:o,selectors:[["agentos-ai-provider-form"]],decls:6,vars:2,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to AI providers",3,"click"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["legend","Configuration scope",3,"disabled"],["label","API type","controlId","llm-api-type","required",""],["dsControl","","id","llm-api-type",3,"formControl"],[3,"value"],["label","Name","controlId","llm-name","required",""],["dsControl","","id","llm-name","type","text","placeholder","e.g. OpenAI prod","autocomplete","off",3,"formControl"],["label","Description","controlId","llm-description"],["dsControl","","id","llm-description","type","text","placeholder","Optional \u2014 short description of this provider","autocomplete","off",3,"formControl"],["label","Base URL","controlId","llm-base-url"],["dsControl","","id","llm-base-url","type","url","placeholder","Optional \u2014 leave empty for default endpoint","autocomplete","off",3,"formControl"],["label","API key","controlId","llm-api-key"],["dsControl","","id","llm-api-key","type","password","placeholder","sk-\u2026","autocomplete","new-password",3,"formControl"],["label","Custom headers"],[1,"ds-stack","ds-stack--sm",3,"formArrayName"],[1,"ds-inline",3,"formGroupName"],["dsButton","","variant","ghost","type","button",3,"click"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"click"],["dsCheck",""],["type","radio",3,"formControl","value","disabled"],["dsControl","","type","text","placeholder","Header name","formControlName","key","autocomplete","off"],["dsControl","","type","text","placeholder","Value","formControlName","value","autocomplete","off"],["dsButton","","variant","icon-danger","type","button","title","Remove header","aria-label","Remove header",3,"click"]],template:function(e,r){e&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return r.cancel()}),fC(3," \u2190 AI providers "),zu()(),Ew(4,ge,2,0,"p",2)(5,Pe,26,10,"form",3),zu()),e&2&&(EE(),Vh("title",r.isEditMode()?"Edit AI provider":"New AI provider"),EE(3),Iw(r.isLoading()?4:5));},dependencies:[hn,fn,un,dn,cn,at,sn,an,qt,md,Co,Mo,Ht,Ut,ya,po,ho,An,On,wa,_o,vo],encapsulation:2})};export{ye as AiProviderFormComponent};
1
+ import {O}from'./chunk-Dx9mLY6-.js';import {v}from'./chunk-aqEkIRN7.js';import {g,W,F,w as we,M as Mi,ad as F$1,ar as Ue,s as sf,x as U,J as JI,o as os,Q as qh,f as fC,z as zu,E as Ew,a as EE,N as Vh,I as Iw,n as Aw,i as bw,as as Cw,R as uI,H as Hh,aq as ww,P as Pw,S as dI,T as Tw,Y as Yu,ai as vw,l as lg,q as Pd,L as Ld}from'./main-B6UJJXO7.js';import {p as pt,L as Lt,T as Te,g as gn,b as hn,c as fn,u as un,t as dn,d as cn,e as at,i as sn,v as an,q as qt,m as md,C as Co,M as Mo,H as Ht,U as Ut,z as ya,a as po,h as ho,A as An,O as On,w as wa,_ as _o,I as vo}from'./chunk-COmLfT0N.js';import'./chunk-DxIOAne_.js';function ge(o,t){o&1&&(os(0,"p",2),fC(1,"Loading\u2026"),zu());}function be(o,t){if(o&1&&(os(0,"label",23),Hh(1,"input",24),uI(),fC(2),zu()),o&2){let e=t.$implicit,r=Pw(3);EE(),Vh("formControl",r.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!r.isAdmin()),dI(),EE(),Yu(" ",e.label," ");}}function _e(o,t){if(o&1&&(os(0,"ds-fieldset",5),bw(1,be,3,4,"label",23,vw().trackByScope,true),zu()),o&2){let e=Pw(2);Vh("disabled",e.isEditMode()),EE(),Tw(e.scopeOptions);}}function Ae(o,t){if(o&1&&(os(0,"option",8),fC(1),zu()),o&2){let e=t.$implicit;Vh("value",e),EE(),lg(e);}}function Se(o,t){if(o&1){let e=Aw();os(0,"div",19),Hh(1,"input",25),uI(),Hh(2,"input",26),uI(),os(3,"button",27),qh("click",function(){let l=Pd(e).$index,f=Pw(2);return Ld(f.removeHeader(l))}),fC(4," \xD7 "),zu()();}if(o&2){let e=t.$index;Vh("formGroupName",e),EE(),dI(),EE(),dI();}}function Pe(o,t){if(o&1){let e=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(e);let l=Pw();return Ld(l.submit())}),Ew(1,_e,3,1,"ds-fieldset",5),os(2,"ds-form-field",6)(3,"select",7),bw(4,Ae,2,2,"option",8,Cw),zu(),uI(),zu(),os(6,"ds-form-field",9),Hh(7,"input",10),uI(),zu(),os(8,"ds-form-field",11),Hh(9,"input",12),uI(),zu(),os(10,"ds-form-field",13),Hh(11,"input",14),uI(),zu(),os(12,"ds-form-field",15),Hh(13,"input",16),uI(),zu(),os(14,"ds-form-field",17)(15,"div",18),bw(16,Se,5,1,"div",19,ww),os(18,"div")(19,"button",20),qh("click",function(){Pd(e);let l=Pw();return Ld(l.addHeader())}),fC(20,"+ Add header"),zu()()()(),os(21,"ds-form-actions")(22,"button",21),fC(23),zu(),os(24,"button",22),qh("click",function(){Pd(e);let l=Pw();return Ld(l.cancel())}),fC(25,"Cancel"),zu()()();}if(o&2){let e=Pw();Vh("formGroup",e.form),EE(),Iw(e.isPlatformMode?-1:1),EE(2),Vh("formControl",e.apiTypeControl),dI(),EE(),Tw(e.apiTypeOptions),EE(3),Vh("formControl",e.nameControl),dI(),EE(2),Vh("formControl",e.descriptionControl),dI(),EE(2),Vh("formControl",e.baseUrlControl),dI(),EE(2),Vh("formControl",e.apiKeyControl),dI(),EE(2),Vh("formArrayName","headers"),EE(),Tw(e.headersArray.controls),EE(6),Vh("disabled",e.form.invalid||e.isSubmitting()),EE(),Yu(" ",e.isEditMode()?"Save changes":"Create"," ");}}var xe=new Set(["namespace","userOnNs","userGlobal"]),E=Object.freeze({platform:"Configuration de niveau plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ye=class o{route=g(W);router=g(F);destroyRef=g(we);state=g(O);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?Mi(true):F$1(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});apiTypeOptions=Object.values(Ue);scopeOptions=[{value:"namespace",label:E.namespace},{value:"userOnNs",label:E.userOnNs},{value:"userGlobal",label:E.userGlobal}];form=new pt({name:new Te("",{nonNullable:true,validators:[gn.required,gn.minLength(1)]}),description:new Te(null),apiType:new Te("OpenAI",{nonNullable:true,validators:[gn.required]}),baseUrl:new Te("",{nonNullable:true}),apiKey:new Te("",{nonNullable:true}),scope:new Te("namespace",{nonNullable:true}),headers:new Lt([],{validators:[]})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get apiTypeControl(){return this.form.controls.apiType}get baseUrlControl(){return this.form.controls.baseUrl}get apiKeyControl(){return this.form.controls.apiKey}get scopeControl(){return this.form.controls.scope}get headersArray(){return this.form.controls.headers}addHeader(){this.headersArray.push(new pt({key:new Te("",{nonNullable:true,validators:[gn.required]}),value:new Te("",{nonNullable:true})}));}removeHeader(t){this.headersArray.removeAt(t);}isEditMode=Mi(false);isSubmitting=Mi(false);isLoading=Mi(false);existingConfig=null;initialApiKey="";constructor(){this.isPlatformMode||sf(()=>{this.isAdmin()||this.isEditMode()||this.scopeControl.value==="namespace"&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let t=this.route.snapshot.paramMap,e=this.route.snapshot.queryParamMap,r=t.get("aiProviderId"),l=this.isPlatformMode?"namespace":this.parseScope(e.get("scope"));if(r){this.isEditMode.set(true),this.scopeControl.disable(),this.apiTypeControl.disable(),this.loadConfig(r);return}this.scopeControl.setValue(l);let f=e.get("template");f&&this.hydrateFromTemplate(f);}parseScope(t){return t&&xe.has(t)?t:"namespace"}deriveScopeFromConfig(t){return !t.userId?"namespace":t.namespaceId?"userOnNs":"userGlobal"}loadConfig(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingConfig=e,this.scopeControl.setValue(this.deriveScopeFromConfig(e)),this.applyConfigToForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[AiProviderForm] Could not load provider '${t}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(t){this.isLoading.set(true),this.state.getById(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.apiTypeControl.setValue(e.apiType),this.baseUrlControl.setValue(e.baseUrl??""),this.apiKeyControl.setValue(""),this.initialApiKey="",this.apiKeyControl.markAsTouched(),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[AiProviderForm] Could not hydrate from template ${t}:`,e),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.apiTypeControl.setValue(t.apiType),this.baseUrlControl.setValue(t.baseUrl??"");let e=t.apiKey??"";this.apiKeyControl.setValue(e),this.initialApiKey=e,this.headersArray.clear();for(let[r,l]of Object.entries(t.headers??{}))this.headersArray.push(new pt({key:new Te(r,{nonNullable:true,validators:[gn.required]}),value:new Te(l,{nonNullable:true})}));}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let t=this.descriptionControl.value?.trim(),e=this.baseUrlControl.value.trim(),r=this.apiKeyControl.value,l=this.isEditMode()&&r===this.initialApiKey?null:r,f=this.headersArray.controls.filter(A=>A.controls.key.value.trim()).map(A=>[A.controls.key.value.trim(),A.controls.value.value]),Ce=f.length>0?Object.fromEntries(f):null,V={name:this.nameControl.value.trim(),apiType:this.apiTypeControl.value,description:t||null,baseUrl:e||null,apiKey:l,headers:Ce},w=this.form.getRawValue().scope,he=this.isPlatformMode?null:this.namespaceId??null;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,V,w,this.existingConfig):this.state.create(V,w,he)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","ai-providers"]):this.router.navigate(["/agentos",this.namespaceId,"ai-providers"]);}trackByScope(t,e){return e.value}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JI({type:o,selectors:[["agentos-ai-provider-form"]],decls:6,vars:2,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to AI providers",3,"click"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["legend","Configuration scope",3,"disabled"],["label","API type","controlId","llm-api-type","required",""],["dsControl","","id","llm-api-type",3,"formControl"],[3,"value"],["label","Name","controlId","llm-name","required",""],["dsControl","","id","llm-name","type","text","placeholder","e.g. OpenAI prod","autocomplete","off",3,"formControl"],["label","Description","controlId","llm-description"],["dsControl","","id","llm-description","type","text","placeholder","Optional \u2014 short description of this provider","autocomplete","off",3,"formControl"],["label","Base URL","controlId","llm-base-url"],["dsControl","","id","llm-base-url","type","url","placeholder","Optional \u2014 leave empty for default endpoint","autocomplete","off",3,"formControl"],["label","API key","controlId","llm-api-key"],["dsControl","","id","llm-api-key","type","password","placeholder","sk-\u2026","autocomplete","new-password",3,"formControl"],["label","Custom headers"],[1,"ds-stack","ds-stack--sm",3,"formArrayName"],[1,"ds-inline",3,"formGroupName"],["dsButton","","variant","ghost","type","button",3,"click"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"click"],["dsCheck",""],["type","radio",3,"formControl","value","disabled"],["dsControl","","type","text","placeholder","Header name","formControlName","key","autocomplete","off"],["dsControl","","type","text","placeholder","Value","formControlName","value","autocomplete","off"],["dsButton","","variant","icon-danger","type","button","title","Remove header","aria-label","Remove header",3,"click"]],template:function(e,r){e&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return r.cancel()}),fC(3," \u2190 AI providers "),zu()(),Ew(4,ge,2,0,"p",2)(5,Pe,26,10,"form",3),zu()),e&2&&(EE(),Vh("title",r.isEditMode()?"Edit AI provider":"New AI provider"),EE(3),Iw(r.isLoading()?4:5));},dependencies:[hn,fn,un,dn,cn,at,sn,an,qt,md,Co,Mo,Ht,Ut,ya,po,ho,An,On,wa,_o,vo],encapsulation:2})};export{ye as AiProviderFormComponent};
@@ -1 +1 @@
1
- import {f,a9 as pd,m as md,H as Ht,a as po,h as ho,aa as lo,ab as fa,ac as ua,b as hn,c as fn,u as un,E as pn,e as at,i as sn,l as ko,ad as f$1}from'./chunk-CCZ1b0na.js';import {g,W,aT as Y,M as Mi,af as ue$1,s as sf,J as JI,aU as Xb,o as os,H as Hh,E as Ew,z as zu,a as EE,I as Iw,ao as Vl,a5 as Ys,a7 as Kt,ag as Gm,a6 as Zs,f as fC,n as Aw,Q as qh,aV as mg,R as uI,P as Pw,aW as gg,S as dI,i as bw,T as Tw,aX as _C,aY as TC,l as lg,d as Bh,a0 as AC,ay as OC,$ as dg,Y as Yu,a1 as kC,q as Pd,L as Ld,aZ as vC}from'./main-63IEQS3X.js';var ce=e=>({title:"By agent",rows:e}),pe=e=>({title:"By model",rows:e}),ge=(e,a)=>[e,a],ue=(e,a)=>a.title,_e=(e,a)=>a.key;function Ce(e,a){e&1&&(os(0,"p",2),fC(1,"Loading usage settings\u2026"),zu());}function fe(e,a){if(e&1){let t=Aw();os(0,"ds-notice"),fC(1,"Could not load usage settings. Please try again."),zu(),os(2,"div")(3,"button",3),qh("click",function(){Pd(t);let s=Pw();return Ld(s.configuration.retry())}),fC(4,"Retry usage settings"),zu()();}}function ye(e,a){e&1&&(os(0,"p",2),fC(1,"Usage tracking is disabled."),zu());}function be(e,a){e&1&&(os(0,"ds-notice"),fC(1),zu()),e&2&&(EE(),lg(a));}function xe(e,a){e&1&&(os(0,"p",2),fC(1,"Loading usage\u2026"),zu());}function he(e,a){e&1&&(os(0,"p",12),fC(1,"No recorded usage for this period."),zu());}function Se(e,a){if(e&1&&(os(0,"p",10),fC(1),zu()),e&2){let t=Pw().$implicit;EE(),Yu("",t.aggregate.unknownCostCount," record(s) with unknown cost");}}function we(e,a){if(e&1&&(os(0,"tr",16)(1,"td",18),fC(2),zu(),os(3,"td",19),fC(4),AC(5,"number"),zu(),os(6,"td",20),fC(7),AC(8,"number"),AC(9,"number"),zu(),os(10,"td",21),fC(11),AC(12,"number"),AC(13,"number"),zu(),os(14,"td",22),fC(15),AC(16,"agentosCost"),Ew(17,Se,2,1,"p",10),zu()()),e&2){let t=a.$implicit;EE(2),lg(t.key),EE(2),lg(OC(5,8,t.aggregate.totalTokens)),EE(3),dg(" ",OC(8,10,t.aggregate.inputTokens)," / ",OC(9,12,t.aggregate.outputTokens)," "),EE(4),dg(" ",OC(12,14,t.aggregate.cacheReadTokens)," / ",OC(13,16,t.aggregate.cacheWriteTokens)," "),EE(4),Yu(" ",kC(16,18,t.aggregate.cost,t.aggregate.unknownCostCount)," "),EE(2),Iw(t.aggregate.unknownCostCount>0?17:-1);}}function ve(e,a){if(e&1&&(os(0,"div",13)(1,"table",14)(2,"thead",15)(3,"tr",16)(4,"th",17),fC(5,"Name"),zu(),os(6,"th",17),fC(7,"Tokens"),zu(),os(8,"th",17),fC(9,"Input / output"),zu(),os(10,"th",17),fC(11,"Cache read / write"),zu(),os(12,"th",17),fC(13,"Estimated cost"),zu()()(),os(14,"tbody",15),bw(15,we,18,21,"tr",16,_e),zu()()()),e&2){let t=Pw().$implicit;EE(),Bh("aria-label","Usage "+t.title.toLowerCase()),EE(14),Tw(t.rows);}}function Ne(e,a){if(e&1&&(os(0,"h3",11),fC(1),zu(),Ew(2,he,2,0,"p",12)(3,ve,17,1,"div",13)),e&2){let t=a.$implicit;EE(),lg(t.title),EE(),Iw(t.rows.length===0?2:3);}}function Te(e,a){if(e&1&&(bw(0,Ne,4,2,null,null,ue),os(2,"p",10),fC(3," Unpriced usage is kept separate from known costs. Active agent runs appear here after they finish. "),zu()),e&2){let t=Pw(2);Tw(_C(4,ge,TC(0,ce,t.agents()),TC(2,pe,t.models())));}}function Ee(e,a){if(e&1){let t=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(t);let s=Pw();return Ld(s.load())}),os(1,"ds-form-field",5)(2,"input",6),mg("ngModelChange",function(s){Pd(t);let m=Pw();return vC(m.from,s)||(m.from=s),Ld(s)}),zu(),uI(),zu(),os(3,"ds-form-field",7)(4,"input",8),mg("ngModelChange",function(s){Pd(t);let m=Pw();return vC(m.to,s)||(m.to=s),Ld(s)}),zu(),uI(),zu(),os(5,"button",9),fC(6,"Refresh"),zu()(),Ew(7,be,2,1,"ds-notice"),Ew(8,xe,2,0,"p",2)(9,Te,4,7);}if(e&2){let t,r=Pw();EE(2),gg("ngModel",r.from),dI(),EE(2),gg("ngModel",r.to),dI(),EE(3),Iw((t=r.error())?7:-1,t),EE(),Iw(r.loading()?8:r.error()?-1:9);}}var me=class e{route=g(W);api=g(Y);configuration=g(f);namespaceId=this.route.snapshot.params.namespaceId;agents=Mi([]);models=Mi([]);error=Mi(null);loading=Mi(false);from=new Date(Date.now()-30*864e5).toISOString().slice(0,10);to=new Date().toISOString().slice(0,10);refresh=new ue$1;constructor(){sf(a=>{if(!this.configuration.enabled())return;let t=this.refresh.pipe(Vl(void 0),Ys(()=>{this.error.set(null),this.agents.set([]),this.models.set([]);let r=new Date(`${this.from}T00:00:00.000Z`),s=new Date(`${this.to}T23:59:59.999Z`);return !Number.isFinite(r.getTime())||!Number.isFinite(s.getTime())||r>s?(this.error.set("Select a valid date range."),this.loading.set(false),Kt):(this.loading.set(true),Gm({agents:this.api.aggregateByAgentUsageRecord(this.namespaceId,r.toISOString(),s.toISOString()),models:this.api.aggregateByModelUsageRecord(this.namespaceId,r.toISOString(),s.toISOString())}).pipe(Zs(m=>(this.loading.set(false),this.error.set(m.status===403?"Namespace admin permission is required to view this report.":"Could not load usage. Please try again."),Kt))))})).subscribe(({agents:r,models:s})=>{this.agents.set(r),this.models.set(s),this.loading.set(false);});a(()=>t.unsubscribe());});}load(){this.configuration.enabled()&&this.refresh.next();}static \u0275fac=function(t){return new(t||e)};static \u0275cmp=JI({type:e,selectors:[["agentos-namespace-usage"]],decls:6,vars:1,consts:[["full",""],["title","Usage and costs","description","Recorded LLM usage across this namespace. Costs are estimates in the platform currency."],["role","status",1,"settings-table__status"],["dsButton","","type","button",3,"click"],[1,"ds-inline","ds-inline--wrap","ds-inline--end",3,"ngSubmit"],["label","From (UTC)","controlId","usage-from"],["dsControl","","id","usage-from","type","date","name","from","required","",3,"ngModelChange","ngModel"],["label","To (UTC)","controlId","usage-to"],["dsControl","","id","usage-to","type","date","name","to","required","",3,"ngModelChange","ngModel"],["dsButton","","variant","primary","type","submit"],[1,"ds-hint"],[1,"ds-micro"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table"],["role","rowgroup"],["role","row"],["role","columnheader"],["role","cell","data-label","Name","data-title","",1,"settings-table__name"],["role","cell","data-label","Tokens"],["role","cell","data-label","Input / output"],["role","cell","data-label","Cache read / write"],["role","cell","data-label","Estimated cost"]],template:function(t,r){t&1&&(os(0,"ds-page",0),Hh(1,"ds-section-header",1),Ew(2,Ce,2,0,"p",2)(3,fe,5,0)(4,ye,2,0,"p",2)(5,Ee,10,4),zu()),t&2&&(EE(2),Iw(r.configuration.state()==="loading"?2:r.configuration.state()==="error"?3:r.configuration.state()==="disabled"?4:5));},dependencies:[pd,md,Ht,po,ho,lo,fa,ua,hn,fn,un,pn,at,sn,ko,Xb,f$1],encapsulation:2})};export{me as NamespaceUsageComponent};
1
+ import {f,a9 as pd,m as md,H as Ht,a as po,h as ho,aa as lo,ab as fa,ac as ua,b as hn,c as fn,u as un,E as pn,e as at,i as sn,l as ko,ad as f$1}from'./chunk-COmLfT0N.js';import {g,W,aT as Y,M as Mi,af as ue$1,s as sf,J as JI,aU as Xb,o as os,H as Hh,E as Ew,z as zu,a as EE,I as Iw,ao as Vl,a5 as Ys,a7 as Kt,ag as Gm,a6 as Zs,f as fC,n as Aw,Q as qh,aV as mg,R as uI,P as Pw,aW as gg,S as dI,i as bw,T as Tw,aX as _C,aY as TC,l as lg,d as Bh,a0 as AC,ay as OC,$ as dg,Y as Yu,a1 as kC,q as Pd,L as Ld,aZ as vC}from'./main-B6UJJXO7.js';var ce=e=>({title:"By agent",rows:e}),pe=e=>({title:"By model",rows:e}),ge=(e,a)=>[e,a],ue=(e,a)=>a.title,_e=(e,a)=>a.key;function Ce(e,a){e&1&&(os(0,"p",2),fC(1,"Loading usage settings\u2026"),zu());}function fe(e,a){if(e&1){let t=Aw();os(0,"ds-notice"),fC(1,"Could not load usage settings. Please try again."),zu(),os(2,"div")(3,"button",3),qh("click",function(){Pd(t);let s=Pw();return Ld(s.configuration.retry())}),fC(4,"Retry usage settings"),zu()();}}function ye(e,a){e&1&&(os(0,"p",2),fC(1,"Usage tracking is disabled."),zu());}function be(e,a){e&1&&(os(0,"ds-notice"),fC(1),zu()),e&2&&(EE(),lg(a));}function xe(e,a){e&1&&(os(0,"p",2),fC(1,"Loading usage\u2026"),zu());}function he(e,a){e&1&&(os(0,"p",12),fC(1,"No recorded usage for this period."),zu());}function Se(e,a){if(e&1&&(os(0,"p",10),fC(1),zu()),e&2){let t=Pw().$implicit;EE(),Yu("",t.aggregate.unknownCostCount," record(s) with unknown cost");}}function we(e,a){if(e&1&&(os(0,"tr",16)(1,"td",18),fC(2),zu(),os(3,"td",19),fC(4),AC(5,"number"),zu(),os(6,"td",20),fC(7),AC(8,"number"),AC(9,"number"),zu(),os(10,"td",21),fC(11),AC(12,"number"),AC(13,"number"),zu(),os(14,"td",22),fC(15),AC(16,"agentosCost"),Ew(17,Se,2,1,"p",10),zu()()),e&2){let t=a.$implicit;EE(2),lg(t.key),EE(2),lg(OC(5,8,t.aggregate.totalTokens)),EE(3),dg(" ",OC(8,10,t.aggregate.inputTokens)," / ",OC(9,12,t.aggregate.outputTokens)," "),EE(4),dg(" ",OC(12,14,t.aggregate.cacheReadTokens)," / ",OC(13,16,t.aggregate.cacheWriteTokens)," "),EE(4),Yu(" ",kC(16,18,t.aggregate.cost,t.aggregate.unknownCostCount)," "),EE(2),Iw(t.aggregate.unknownCostCount>0?17:-1);}}function ve(e,a){if(e&1&&(os(0,"div",13)(1,"table",14)(2,"thead",15)(3,"tr",16)(4,"th",17),fC(5,"Name"),zu(),os(6,"th",17),fC(7,"Tokens"),zu(),os(8,"th",17),fC(9,"Input / output"),zu(),os(10,"th",17),fC(11,"Cache read / write"),zu(),os(12,"th",17),fC(13,"Estimated cost"),zu()()(),os(14,"tbody",15),bw(15,we,18,21,"tr",16,_e),zu()()()),e&2){let t=Pw().$implicit;EE(),Bh("aria-label","Usage "+t.title.toLowerCase()),EE(14),Tw(t.rows);}}function Ne(e,a){if(e&1&&(os(0,"h3",11),fC(1),zu(),Ew(2,he,2,0,"p",12)(3,ve,17,1,"div",13)),e&2){let t=a.$implicit;EE(),lg(t.title),EE(),Iw(t.rows.length===0?2:3);}}function Te(e,a){if(e&1&&(bw(0,Ne,4,2,null,null,ue),os(2,"p",10),fC(3," Unpriced usage is kept separate from known costs. Active agent runs appear here after they finish. "),zu()),e&2){let t=Pw(2);Tw(_C(4,ge,TC(0,ce,t.agents()),TC(2,pe,t.models())));}}function Ee(e,a){if(e&1){let t=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(t);let s=Pw();return Ld(s.load())}),os(1,"ds-form-field",5)(2,"input",6),mg("ngModelChange",function(s){Pd(t);let m=Pw();return vC(m.from,s)||(m.from=s),Ld(s)}),zu(),uI(),zu(),os(3,"ds-form-field",7)(4,"input",8),mg("ngModelChange",function(s){Pd(t);let m=Pw();return vC(m.to,s)||(m.to=s),Ld(s)}),zu(),uI(),zu(),os(5,"button",9),fC(6,"Refresh"),zu()(),Ew(7,be,2,1,"ds-notice"),Ew(8,xe,2,0,"p",2)(9,Te,4,7);}if(e&2){let t,r=Pw();EE(2),gg("ngModel",r.from),dI(),EE(2),gg("ngModel",r.to),dI(),EE(3),Iw((t=r.error())?7:-1,t),EE(),Iw(r.loading()?8:r.error()?-1:9);}}var me=class e{route=g(W);api=g(Y);configuration=g(f);namespaceId=this.route.snapshot.params.namespaceId;agents=Mi([]);models=Mi([]);error=Mi(null);loading=Mi(false);from=new Date(Date.now()-30*864e5).toISOString().slice(0,10);to=new Date().toISOString().slice(0,10);refresh=new ue$1;constructor(){sf(a=>{if(!this.configuration.enabled())return;let t=this.refresh.pipe(Vl(void 0),Ys(()=>{this.error.set(null),this.agents.set([]),this.models.set([]);let r=new Date(`${this.from}T00:00:00.000Z`),s=new Date(`${this.to}T23:59:59.999Z`);return !Number.isFinite(r.getTime())||!Number.isFinite(s.getTime())||r>s?(this.error.set("Select a valid date range."),this.loading.set(false),Kt):(this.loading.set(true),Gm({agents:this.api.aggregateByAgentUsageRecord(this.namespaceId,r.toISOString(),s.toISOString()),models:this.api.aggregateByModelUsageRecord(this.namespaceId,r.toISOString(),s.toISOString())}).pipe(Zs(m=>(this.loading.set(false),this.error.set(m.status===403?"Namespace admin permission is required to view this report.":"Could not load usage. Please try again."),Kt))))})).subscribe(({agents:r,models:s})=>{this.agents.set(r),this.models.set(s),this.loading.set(false);});a(()=>t.unsubscribe());});}load(){this.configuration.enabled()&&this.refresh.next();}static \u0275fac=function(t){return new(t||e)};static \u0275cmp=JI({type:e,selectors:[["agentos-namespace-usage"]],decls:6,vars:1,consts:[["full",""],["title","Usage and costs","description","Recorded LLM usage across this namespace. Costs are estimates in the platform currency."],["role","status",1,"settings-table__status"],["dsButton","","type","button",3,"click"],[1,"ds-inline","ds-inline--wrap","ds-inline--end",3,"ngSubmit"],["label","From (UTC)","controlId","usage-from"],["dsControl","","id","usage-from","type","date","name","from","required","",3,"ngModelChange","ngModel"],["label","To (UTC)","controlId","usage-to"],["dsControl","","id","usage-to","type","date","name","to","required","",3,"ngModelChange","ngModel"],["dsButton","","variant","primary","type","submit"],[1,"ds-hint"],[1,"ds-micro"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table"],["role","rowgroup"],["role","row"],["role","columnheader"],["role","cell","data-label","Name","data-title","",1,"settings-table__name"],["role","cell","data-label","Tokens"],["role","cell","data-label","Input / output"],["role","cell","data-label","Cache read / write"],["role","cell","data-label","Estimated cost"]],template:function(t,r){t&1&&(os(0,"ds-page",0),Hh(1,"ds-section-header",1),Ew(2,Ce,2,0,"p",2)(3,fe,5,0)(4,ye,2,0,"p",2)(5,Ee,10,4),zu()),t&2&&(EE(2),Iw(r.configuration.state()==="loading"?2:r.configuration.state()==="error"?3:r.configuration.state()==="disabled"?4:5));},dependencies:[pd,md,Ht,po,ho,lo,fa,ua,hn,fn,un,pn,at,sn,ko,Xb,f$1],encapsulation:2})};export{me as NamespaceUsageComponent};
@@ -1 +1 @@
1
- import {v}from'./chunk-Cvh22V1I.js';import {I}from'./chunk-DQEn5_2f.js';import {O}from'./chunk-BT-f7pOo.js';import {g,W,F,w as we,ac as _,ad as F$1,ae as Dr,M as Mi,af as ue,h as BC,a5 as Ys,x as U,s as sf,ag as Gm,J as JI,o as os,Q as qh,f as fC,z as zu,E as Ew,a as EE,N as Vh,I as Iw,a6 as Zs,ah as te,n as Aw,i as bw,ai as vw,R as uI,H as Hh,P as Pw,T as Tw,S as dI,Y as Yu,l as lg,q as Pd,L as Ld}from'./main-63IEQS3X.js';import {p as pt,T as Te$1,g as gn,b as hn,c as fn,u as un,t as dn,d as cn,r as rn,e as at,i as sn,v as an,q as qt,m as md,C as Co,M as Mo,H as Ht,x as yn,U as Ut,z as ya,a as po,h as ho,A as An,O as On,W as Wt}from'./chunk-CCZ1b0na.js';import'./chunk-CVAz4Lko.js';var be=(i,e)=>e.value;function _e(i,e){i&1&&(os(0,"p",2),fC(1,"Loading\u2026"),zu());}function xe(i,e){if(i&1&&(os(0,"label",6),Hh(1,"input",22),uI(),fC(2),zu()),i&2){let t=e.$implicit,n=Pw(2);EE(),Vh("value",t.value)("formControl",n.scopeControl)("disabled",t.value==="namespace"&&!n.isAdmin()),dI(),EE(),Yu(" ",t.label," ");}}function Ie(i,e){if(i&1&&(os(0,"option",10),fC(1),zu()),i&2){let t=e.$implicit;Vh("value",t.type),EE(),lg(t.displayName);}}function Ne(i,e){if(i&1&&(os(0,"option",10),fC(1),zu()),i&2){let t=e.$implicit;Vh("value",t.value),EE(),lg(t.label);}}function Ae(i,e){if(i&1&&(os(0,"div",18)(1,"label",6),Hh(2,"input",23),uI(),fC(3," Grant automatically "),zu(),os(4,"p",2),fC(5),zu()()),i&2){let t=Pw(2);EE(2),Vh("formControl",t.autoGrantControl),dI(),EE(3),Yu(" Give this integration to ",t.autoGrantReach(),", without each agent having to declare it. An agent can still opt out by mapping this configuration to an empty tool list. ");}}function Ee(i,e){if(i&1){let t=Aw();os(0,"ds-card")(1,"ds-json-schema-form",24),qh("valueChange",function(a){Pd(t);let p=Pw(2);return Ld(p.onParamsChange(a))}),zu()();}if(i&2){let t=Pw(2);EE(),Vh("schema",e)("value",t.initialParams());}}function Fe(i,e){if(i&1){let t=Aw();os(0,"button",25),qh("click",function(){Pd(t);let a=Pw(2);return Ld(a.exportYaml())}),fC(1),zu();}if(i&2){let t=Pw(2);Vh("disabled",t.isExporting()),EE(),Yu(" ",t.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function Te(i,e){if(i&1){let t=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(t);let a=Pw();return Ld(a.submit())}),os(1,"ds-fieldset",5),bw(2,xe,3,4,"label",6,vw().trackByScope,true),zu(),os(4,"ds-form-field",7)(5,"select",8)(6,"option",9),fC(7,"Select type"),zu(),bw(8,Ie,2,2,"option",10,vw().trackByType,true),zu(),uI(),zu(),os(10,"ds-form-field",11),Hh(11,"input",12),uI(),zu(),os(12,"ds-form-field",13),Hh(13,"textarea",14),uI(),zu(),os(14,"ds-form-field",15)(15,"select",16)(16,"option",17),fC(17,"None"),zu(),bw(18,Ne,2,2,"option",10,be),zu(),uI(),zu(),Ew(20,Ae,6,2,"div",18),Ew(21,Ee,2,2,"ds-card"),os(22,"ds-form-actions")(23,"button",19),fC(24),zu(),Ew(25,Fe,2,2,"button",20),os(26,"button",21),qh("click",function(){Pd(t);let a=Pw();return Ld(a.cancel())}),fC(27,"Cancel"),zu()()();}if(i&2){let t,n=Pw();Vh("formGroup",n.form),EE(),Vh("disabled",n.isEditMode()),EE(),Tw(n.scopeOptions),EE(3),Vh("formControl",n.typeControl),dI(),EE(3),Tw(n.integrationTypes()),EE(3),Vh("formControl",n.nameControl),dI(),EE(2),Vh("formControl",n.descriptionControl),dI(),EE(2),Vh("formControl",n.authSettingNameControl),dI(),EE(),Vh("ngValue",null),EE(2),Tw(n.authSettingOptions()),EE(2),Iw(n.isAutoGrantable()?20:-1),EE(),Iw((t=n.schema())?21:-1,t),EE(2),Vh("disabled",n.nameControl.invalid||n.typeControl.invalid||n.isSubmitting()),EE(),Yu(" ",n.isEditMode()?"Save changes":"Create"," "),EE(),Iw(n.isEditMode()?25:-1);}}var Ve=new Set(["platform","namespace","userOnNs","userGlobal"]),w=Object.freeze({platform:"Configuration plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ve=class i{route=g(W);router=g(F);destroyRef=g(we);state=g(O);integrationTypeController=g(_);authSettingState=g(I);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isAdmin=F$1(this.isPlatformMode?Dr(true):this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:this.isPlatformMode});form=new pt({name:new Te$1("",{nonNullable:true,validators:[gn.required,gn.minLength(1)]}),description:new Te$1(null),type:new Te$1("",{nonNullable:true,validators:[gn.required]}),scope:new Te$1("namespace",{nonNullable:true}),autoGrant:new Te$1(false,{nonNullable:true})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get typeControl(){return this.form.controls.type}get scopeControl(){return this.form.controls.scope}get autoGrantControl(){return this.form.controls.autoGrant}isEditMode=Mi(false);isSubmitting=Mi(false);isLoading=Mi(false);isExporting=Mi(false);scopeOptions=[{value:"platform",label:w.platform},{value:"namespace",label:w.namespace},{value:"userOnNs",label:w.userOnNs},{value:"userGlobal",label:w.userGlobal}];authSettingNameControl=new Te$1(null);loadedAuthSettings=Mi([]);authSettingsLoaded=Mi(false);savedAuthSettingName=Mi(null);authSettingsScope$=new ue;authSettingOptions=BC(()=>{let e=this.loadedAuthSettings(),t=this.savedAuthSettingName();return !t||!this.authSettingsLoaded()||e.some(n=>n.value===t)?e:[...e,{value:t,label:`${t} (not found)`}]});paramsValue=Mi(null);initialParams=Mi(null);integrationTypes=F$1(this.integrationTypeController.listTypesIntegrationType(),{initialValue:[]});selectedType=F$1(this.form.controls.type.valueChanges,{initialValue:this.form.controls.type.value});scopeValue=F$1(this.form.controls.scope.valueChanges,{initialValue:this.form.controls.scope.value});schema=BC(()=>{let e=this.selectedType();return e?this.integrationTypes().find(n=>n.type===e)?.configSchema??null:null});isAutoGrantable=BC(()=>{let e=this.selectedType();return e?this.integrationTypes().find(t=>t.type===e)?.autoGrantable??false:false});autoGrantReach=BC(()=>{switch(this.scopeValue()){case "platform":return "every agent of this environment";case "namespace":return "every agent of this namespace";default:return "your own runs"}});existingConfig=null;constructor(){this.authSettingsScope$.pipe(Ys(e=>this.loadAuthSettingLayers(e)),U(this.destroyRef)).subscribe(e=>{this.loadedAuthSettings.set(this.toAuthSettingOptions(e)),this.authSettingsLoaded.set(true);}),sf(()=>{if(this.isAdmin()||this.isEditMode())return;["platform","namespace"].includes(this.scopeControl.value)&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let e=this.route.snapshot.paramMap,t=this.route.snapshot.queryParamMap,n=e.get("integrationId");if(n){this.isEditMode.set(true),this.scopeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable(),this.loadAuthSettingsForScope("platform");return}let a=this.parseScope(t.get("scope"));this.scopeControl.setValue(a),this.loadAuthSettingsForScope(a),this.scopeControl.valueChanges.pipe(U(this.destroyRef)).subscribe(D=>{this.loadAuthSettingsForScope(D);});let p=t.get("template");p&&this.hydrateFromTemplate(p);}parseScope(e){return e&&Ve.has(e)?e:"namespace"}deriveScopeFromConfig(e){return !e.userId&&!e.namespaceId?"platform":e.userId?e.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(e){this.isLoading.set(true),this.state.getById(e).pipe(U(this.destroyRef)).subscribe({next:t=>{this.existingConfig=t;let n=this.deriveScopeFromConfig(t);this.scopeControl.setValue(n),this.applyConfigToForm(t),this.loadAuthSettingsForScope(n),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[IntegrationForm] Could not load config '${e}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(e){this.isLoading.set(true),this.state.getById(e).pipe(U(this.destroyRef)).subscribe({next:t=>{this.applyConfigToForm(t),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:t=>{console.warn(`[IntegrationForm] Could not hydrate from template ${e}:`,t),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(e){this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.typeControl.setValue(e.integrationType),this.initialParams.set(e.parameters),this.paramsValue.set(e.parameters),this.authSettingNameControl.setValue(e.authSettingName??null),this.savedAuthSettingName.set(e.authSettingName??null),this.autoGrantControl.setValue(e.autoGrant??false);}loadAuthSettingsForScope(e){this.authSettingsLoaded.set(false),this.authSettingsScope$.next(e);}loadAuthSettingLayers(e){let t=(p,D)=>D.pipe(Zs(()=>Dr([])),te(Se=>({label:p,settings:Se}))),n=t("platform",this.authSettingState.loadPlatformSettings()),a=t("mine",this.authSettingState.loadUserSettings("global"));return e==="platform"||e==="userGlobal"?Gm([a,n]):Gm([t("mine",this.authSettingState.loadUserSettings(this.namespaceId)),t("namespace",this.authSettingState.loadNamespaceSettings(this.namespaceId)),a,n])}toAuthSettingOptions(e){let t=new Map;for(let{label:n,settings:a}of e)for(let{name:p}of a)p&&t.set(p,(t.get(p)??new Set).add(n));return [...t.entries()].sort(([n],[a])=>n.localeCompare(a)).map(([n,a])=>({value:n,label:`${n} (${[...a].join(", ")})`}))}onParamsChange(e){this.paramsValue.set(e);}submit(){if(this.nameControl.invalid||this.typeControl.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let e=this.descriptionControl.value?.trim(),t={name:this.nameControl.value.trim(),description:e||null,integrationType:this.typeControl.value,parameters:this.paramsValue(),authSettingName:this.authSettingNameControl.value||null,autoGrant:this.isAutoGrantable()&&this.autoGrantControl.value},n=this.form.getRawValue().scope;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,t,n,this.existingConfig):this.state.create(t,n,this.namespaceId??null)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}exportYaml(){let e=this.existingConfig?.id;!e||this.isExporting()||(this.isExporting.set(true),this.state.exportAsYaml(e).pipe(U(this.destroyRef)).subscribe({next:t=>{let n=new Blob([t],{type:"application/yaml"}),a=URL.createObjectURL(n),p=document.createElement("a");p.href=a,p.download=`${this.existingConfig?.name??"integration"}.yaml`,p.click(),URL.revokeObjectURL(a),this.isExporting.set(false);},error:()=>this.isExporting.set(false)}));}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","integration-configs"]):this.router.navigate(["/agentos",this.namespaceId,"integrations"]);}trackByType(e,t){return t.type}trackByScope(e,t){return t.value}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=JI({type:i,selectors:[["agentos-integration-form"]],decls:6,vars:2,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to integrations",3,"click"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["legend","Scope",3,"disabled"],["dsCheck",""],["label","Type","controlId","integration-type","required",""],["dsControl","","id","integration-type",3,"formControl"],["value","","disabled",""],[3,"value"],["label","Name","controlId","integration-name","required",""],["dsControl","","id","integration-name","type","text","placeholder","Integration name","autocomplete","off",3,"formControl"],["label","Description","controlId","integration-description"],["dsControl","","id","integration-description","placeholder","Optional description","rows","3",3,"formControl"],["label","Auth Setting","controlId","integration-auth-setting","hint","Only the name is saved. It is resolved at run time for the user running the case, the most specific layer winning (user on this namespace > namespace > user > platform), so a shared integration can rely on each user's own auth setting of that name."],["dsControl","","id","integration-auth-setting",3,"formControl"],[3,"ngValue"],[1,"ds-stack","ds-stack--sm"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"disabled"],["dsButton","","type","button",3,"click"],["type","radio",3,"value","formControl","disabled"],["type","checkbox",3,"formControl"],[3,"valueChange","schema","value"],["dsButton","","type","button",3,"click","disabled"]],template:function(t,n){t&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return n.cancel()}),fC(3," \u2190 Integrations "),zu()(),Ew(4,_e,2,0,"p",2)(5,Te,28,12,"form",3),zu()),t&2&&(EE(),Vh("title",n.isEditMode()?"Edit integration":"New integration"),EE(3),Iw(n.isLoading()?4:5));},dependencies:[hn,fn,un,dn,cn,rn,at,sn,an,qt,md,Co,Mo,Ht,yn,Ut,ya,po,ho,An,On,Wt],encapsulation:2})};export{ve as IntegrationFormComponent};
1
+ import {v}from'./chunk-aqEkIRN7.js';import {I}from'./chunk-Cq9jD9x7.js';import {O}from'./chunk-DIVQtNVn.js';import {g,W,F,w as we,ac as _,ad as F$1,ae as Dr,M as Mi,af as ue,h as BC,a5 as Ys,x as U,s as sf,ag as Gm,J as JI,o as os,Q as qh,f as fC,z as zu,E as Ew,a as EE,N as Vh,I as Iw,a6 as Zs,ah as te,n as Aw,i as bw,ai as vw,R as uI,H as Hh,P as Pw,T as Tw,S as dI,Y as Yu,l as lg,q as Pd,L as Ld}from'./main-B6UJJXO7.js';import {p as pt,T as Te$1,g as gn,b as hn,c as fn,u as un,t as dn,d as cn,r as rn,e as at,i as sn,v as an,q as qt,m as md,C as Co,M as Mo,H as Ht,x as yn,U as Ut,z as ya,a as po,h as ho,A as An,O as On,W as Wt}from'./chunk-COmLfT0N.js';import'./chunk-DxIOAne_.js';var be=(i,e)=>e.value;function _e(i,e){i&1&&(os(0,"p",2),fC(1,"Loading\u2026"),zu());}function xe(i,e){if(i&1&&(os(0,"label",6),Hh(1,"input",22),uI(),fC(2),zu()),i&2){let t=e.$implicit,n=Pw(2);EE(),Vh("value",t.value)("formControl",n.scopeControl)("disabled",t.value==="namespace"&&!n.isAdmin()),dI(),EE(),Yu(" ",t.label," ");}}function Ie(i,e){if(i&1&&(os(0,"option",10),fC(1),zu()),i&2){let t=e.$implicit;Vh("value",t.type),EE(),lg(t.displayName);}}function Ne(i,e){if(i&1&&(os(0,"option",10),fC(1),zu()),i&2){let t=e.$implicit;Vh("value",t.value),EE(),lg(t.label);}}function Ae(i,e){if(i&1&&(os(0,"div",18)(1,"label",6),Hh(2,"input",23),uI(),fC(3," Grant automatically "),zu(),os(4,"p",2),fC(5),zu()()),i&2){let t=Pw(2);EE(2),Vh("formControl",t.autoGrantControl),dI(),EE(3),Yu(" Give this integration to ",t.autoGrantReach(),", without each agent having to declare it. An agent can still opt out by mapping this configuration to an empty tool list. ");}}function Ee(i,e){if(i&1){let t=Aw();os(0,"ds-card")(1,"ds-json-schema-form",24),qh("valueChange",function(a){Pd(t);let p=Pw(2);return Ld(p.onParamsChange(a))}),zu()();}if(i&2){let t=Pw(2);EE(),Vh("schema",e)("value",t.initialParams());}}function Fe(i,e){if(i&1){let t=Aw();os(0,"button",25),qh("click",function(){Pd(t);let a=Pw(2);return Ld(a.exportYaml())}),fC(1),zu();}if(i&2){let t=Pw(2);Vh("disabled",t.isExporting()),EE(),Yu(" ",t.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function Te(i,e){if(i&1){let t=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(t);let a=Pw();return Ld(a.submit())}),os(1,"ds-fieldset",5),bw(2,xe,3,4,"label",6,vw().trackByScope,true),zu(),os(4,"ds-form-field",7)(5,"select",8)(6,"option",9),fC(7,"Select type"),zu(),bw(8,Ie,2,2,"option",10,vw().trackByType,true),zu(),uI(),zu(),os(10,"ds-form-field",11),Hh(11,"input",12),uI(),zu(),os(12,"ds-form-field",13),Hh(13,"textarea",14),uI(),zu(),os(14,"ds-form-field",15)(15,"select",16)(16,"option",17),fC(17,"None"),zu(),bw(18,Ne,2,2,"option",10,be),zu(),uI(),zu(),Ew(20,Ae,6,2,"div",18),Ew(21,Ee,2,2,"ds-card"),os(22,"ds-form-actions")(23,"button",19),fC(24),zu(),Ew(25,Fe,2,2,"button",20),os(26,"button",21),qh("click",function(){Pd(t);let a=Pw();return Ld(a.cancel())}),fC(27,"Cancel"),zu()()();}if(i&2){let t,n=Pw();Vh("formGroup",n.form),EE(),Vh("disabled",n.isEditMode()),EE(),Tw(n.scopeOptions),EE(3),Vh("formControl",n.typeControl),dI(),EE(3),Tw(n.integrationTypes()),EE(3),Vh("formControl",n.nameControl),dI(),EE(2),Vh("formControl",n.descriptionControl),dI(),EE(2),Vh("formControl",n.authSettingNameControl),dI(),EE(),Vh("ngValue",null),EE(2),Tw(n.authSettingOptions()),EE(2),Iw(n.isAutoGrantable()?20:-1),EE(),Iw((t=n.schema())?21:-1,t),EE(2),Vh("disabled",n.nameControl.invalid||n.typeControl.invalid||n.isSubmitting()),EE(),Yu(" ",n.isEditMode()?"Save changes":"Create"," "),EE(),Iw(n.isEditMode()?25:-1);}}var Ve=new Set(["platform","namespace","userOnNs","userGlobal"]),w=Object.freeze({platform:"Configuration plateforme",namespace:"Configuration du namespace",userOnNs:"Pour moi sur ce namespace",userGlobal:"Pour moi globalement"}),ve=class i{route=g(W);router=g(F);destroyRef=g(we);state=g(O);integrationTypeController=g(_);authSettingState=g(I);namespaceRole=g(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isAdmin=F$1(this.isPlatformMode?Dr(true):this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:this.isPlatformMode});form=new pt({name:new Te$1("",{nonNullable:true,validators:[gn.required,gn.minLength(1)]}),description:new Te$1(null),type:new Te$1("",{nonNullable:true,validators:[gn.required]}),scope:new Te$1("namespace",{nonNullable:true}),autoGrant:new Te$1(false,{nonNullable:true})});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get typeControl(){return this.form.controls.type}get scopeControl(){return this.form.controls.scope}get autoGrantControl(){return this.form.controls.autoGrant}isEditMode=Mi(false);isSubmitting=Mi(false);isLoading=Mi(false);isExporting=Mi(false);scopeOptions=[{value:"platform",label:w.platform},{value:"namespace",label:w.namespace},{value:"userOnNs",label:w.userOnNs},{value:"userGlobal",label:w.userGlobal}];authSettingNameControl=new Te$1(null);loadedAuthSettings=Mi([]);authSettingsLoaded=Mi(false);savedAuthSettingName=Mi(null);authSettingsScope$=new ue;authSettingOptions=BC(()=>{let e=this.loadedAuthSettings(),t=this.savedAuthSettingName();return !t||!this.authSettingsLoaded()||e.some(n=>n.value===t)?e:[...e,{value:t,label:`${t} (not found)`}]});paramsValue=Mi(null);initialParams=Mi(null);integrationTypes=F$1(this.integrationTypeController.listTypesIntegrationType(),{initialValue:[]});selectedType=F$1(this.form.controls.type.valueChanges,{initialValue:this.form.controls.type.value});scopeValue=F$1(this.form.controls.scope.valueChanges,{initialValue:this.form.controls.scope.value});schema=BC(()=>{let e=this.selectedType();return e?this.integrationTypes().find(n=>n.type===e)?.configSchema??null:null});isAutoGrantable=BC(()=>{let e=this.selectedType();return e?this.integrationTypes().find(t=>t.type===e)?.autoGrantable??false:false});autoGrantReach=BC(()=>{switch(this.scopeValue()){case "platform":return "every agent of this environment";case "namespace":return "every agent of this namespace";default:return "your own runs"}});existingConfig=null;constructor(){this.authSettingsScope$.pipe(Ys(e=>this.loadAuthSettingLayers(e)),U(this.destroyRef)).subscribe(e=>{this.loadedAuthSettings.set(this.toAuthSettingOptions(e)),this.authSettingsLoaded.set(true);}),sf(()=>{if(this.isAdmin()||this.isEditMode())return;["platform","namespace"].includes(this.scopeControl.value)&&this.scopeControl.setValue("userOnNs");});}ngOnInit(){this.namespaceId&&this.state.setNamespace(this.namespaceId);let e=this.route.snapshot.paramMap,t=this.route.snapshot.queryParamMap,n=e.get("integrationId");if(n){this.isEditMode.set(true),this.scopeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable(),this.loadAuthSettingsForScope("platform");return}let a=this.parseScope(t.get("scope"));this.scopeControl.setValue(a),this.loadAuthSettingsForScope(a),this.scopeControl.valueChanges.pipe(U(this.destroyRef)).subscribe(D=>{this.loadAuthSettingsForScope(D);});let p=t.get("template");p&&this.hydrateFromTemplate(p);}parseScope(e){return e&&Ve.has(e)?e:"namespace"}deriveScopeFromConfig(e){return !e.userId&&!e.namespaceId?"platform":e.userId?e.namespaceId?"userOnNs":"userGlobal":"namespace"}loadConfig(e){this.isLoading.set(true),this.state.getById(e).pipe(U(this.destroyRef)).subscribe({next:t=>{this.existingConfig=t;let n=this.deriveScopeFromConfig(t);this.scopeControl.setValue(n),this.applyConfigToForm(t),this.loadAuthSettingsForScope(n),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),console.warn(`[IntegrationForm] Could not load config '${e}' \u2014 navigating back`),this.navigateBack();}});}hydrateFromTemplate(e){this.isLoading.set(true),this.state.getById(e).pipe(U(this.destroyRef)).subscribe({next:t=>{this.applyConfigToForm(t),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:t=>{console.warn(`[IntegrationForm] Could not hydrate from template ${e}:`,t),this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});}});}applyConfigToForm(e){this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.typeControl.setValue(e.integrationType),this.initialParams.set(e.parameters),this.paramsValue.set(e.parameters),this.authSettingNameControl.setValue(e.authSettingName??null),this.savedAuthSettingName.set(e.authSettingName??null),this.autoGrantControl.setValue(e.autoGrant??false);}loadAuthSettingsForScope(e){this.authSettingsLoaded.set(false),this.authSettingsScope$.next(e);}loadAuthSettingLayers(e){let t=(p,D)=>D.pipe(Zs(()=>Dr([])),te(Se=>({label:p,settings:Se}))),n=t("platform",this.authSettingState.loadPlatformSettings()),a=t("mine",this.authSettingState.loadUserSettings("global"));return e==="platform"||e==="userGlobal"?Gm([a,n]):Gm([t("mine",this.authSettingState.loadUserSettings(this.namespaceId)),t("namespace",this.authSettingState.loadNamespaceSettings(this.namespaceId)),a,n])}toAuthSettingOptions(e){let t=new Map;for(let{label:n,settings:a}of e)for(let{name:p}of a)p&&t.set(p,(t.get(p)??new Set).add(n));return [...t.entries()].sort(([n],[a])=>n.localeCompare(a)).map(([n,a])=>({value:n,label:`${n} (${[...a].join(", ")})`}))}onParamsChange(e){this.paramsValue.set(e);}submit(){if(this.nameControl.invalid||this.typeControl.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let e=this.descriptionControl.value?.trim(),t={name:this.nameControl.value.trim(),description:e||null,integrationType:this.typeControl.value,parameters:this.paramsValue(),authSettingName:this.authSettingNameControl.value||null,autoGrant:this.isAutoGrantable()&&this.autoGrantControl.value},n=this.form.getRawValue().scope;(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,t,n,this.existingConfig):this.state.create(t,n,this.namespaceId??null)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}exportYaml(){let e=this.existingConfig?.id;!e||this.isExporting()||(this.isExporting.set(true),this.state.exportAsYaml(e).pipe(U(this.destroyRef)).subscribe({next:t=>{let n=new Blob([t],{type:"application/yaml"}),a=URL.createObjectURL(n),p=document.createElement("a");p.href=a,p.download=`${this.existingConfig?.name??"integration"}.yaml`,p.click(),URL.revokeObjectURL(a),this.isExporting.set(false);},error:()=>this.isExporting.set(false)}));}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","integration-configs"]):this.router.navigate(["/agentos",this.namespaceId,"integrations"]);}trackByType(e,t){return t.type}trackByScope(e,t){return t.value}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=JI({type:i,selectors:[["agentos-integration-form"]],decls:6,vars:2,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to integrations",3,"click"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["legend","Scope",3,"disabled"],["dsCheck",""],["label","Type","controlId","integration-type","required",""],["dsControl","","id","integration-type",3,"formControl"],["value","","disabled",""],[3,"value"],["label","Name","controlId","integration-name","required",""],["dsControl","","id","integration-name","type","text","placeholder","Integration name","autocomplete","off",3,"formControl"],["label","Description","controlId","integration-description"],["dsControl","","id","integration-description","placeholder","Optional description","rows","3",3,"formControl"],["label","Auth Setting","controlId","integration-auth-setting","hint","Only the name is saved. It is resolved at run time for the user running the case, the most specific layer winning (user on this namespace > namespace > user > platform), so a shared integration can rely on each user's own auth setting of that name."],["dsControl","","id","integration-auth-setting",3,"formControl"],[3,"ngValue"],[1,"ds-stack","ds-stack--sm"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"disabled"],["dsButton","","type","button",3,"click"],["type","radio",3,"value","formControl","disabled"],["type","checkbox",3,"formControl"],[3,"valueChange","schema","value"],["dsButton","","type","button",3,"click","disabled"]],template:function(t,n){t&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return n.cancel()}),fC(3," \u2190 Integrations "),zu()(),Ew(4,_e,2,0,"p",2)(5,Te,28,12,"form",3),zu()),t&2&&(EE(),Vh("title",n.isEditMode()?"Edit integration":"New integration"),EE(3),Iw(n.isLoading()?4:5));},dependencies:[hn,fn,un,dn,cn,rn,at,sn,an,qt,md,Co,Mo,Ht,yn,Ut,ya,po,ho,An,On,Wt],encapsulation:2})};export{ve as IntegrationFormComponent};
@@ -1 +1 @@
1
- import {o}from'./chunk-Jcjs0qUP.js';import {p as pt,T as Te,g as gn,q as qt,m as md,H as Ht,a as po,h as ho,A as An,O as On,b as hn,c as fn,u as un,d as cn,E as pn,e as at,i as sn,n as Fo}from'./chunk-CCZ1b0na.js';import {g,W,F,w as we,M as Mi,x as U,K as x,C as w,J as JI,ax as $t,o as os,Q as qh,f as fC,z as zu,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,n as Aw,H as Hh,R as uI,i as bw,aq as ww,S as dI,T as Tw,Y as Yu,q as Pd,L as Ld,l as lg}from'./main-63IEQS3X.js';function ie(i,t){if(i&1&&(os(0,"a",2),fC(1,"View skill \u2192"),zu()),i&2){let e=Pw();Vh("routerLink",e.inspectRoute());}}function oe(i,t){i&1&&(os(0,"ds-tag",3),fC(1,"Platform level"),zu());}function ne(i,t){i&1&&(os(0,"p",4),fC(1,"Loading\u2026"),zu());}function re(i,t){if(i&1){let e=Aw();os(0,"div",15)(1,"div",19),Hh(2,"input",20),uI(),os(3,"button",21),qh("click",function(){let l=Pd(e).$implicit,te=Pw(2);return Ld(te.removeResource(l))}),fC(4," \xD7 "),zu()(),Hh(5,"textarea",22),uI(),zu();}if(i&2){let e=t.$implicit;EE(2),Vh("formControl",e.path),dI(),EE(3),Vh("formControl",e.content),dI();}}function ae(i,t){if(i&1&&(os(0,"ds-notice"),fC(1),zu()),i&2){let e=Pw(2);EE(),lg(e.errorMessage());}}function se(i,t){if(i&1){let e=Aw();os(0,"form",6),qh("ngSubmit",function(){Pd(e);let l=Pw();return Ld(l.submit())}),os(1,"ds-form-field",7),Hh(2,"input",8),uI(),zu(),os(3,"ds-form-field",9),Hh(4,"textarea",10),uI(),zu(),os(5,"ds-form-field",11),Hh(6,"textarea",12),uI(),zu(),os(7,"ds-form-field",13)(8,"div",14),bw(9,re,6,2,"div",15,ww),os(11,"div")(12,"button",16),qh("click",function(){Pd(e);let l=Pw();return Ld(l.addResource())}),fC(13,"+ Add resource"),zu()()()(),Ew(14,ae,2,1,"ds-notice"),os(15,"ds-form-actions")(16,"button",17),fC(17),zu(),os(18,"button",18),qh("click",function(){Pd(e);let l=Pw();return Ld(l.cancel())}),fC(19,"Cancel"),zu()()();}if(i&2){let e=Pw();Vh("formGroup",e.form),EE(),Vh("error",e.nameControl.invalid&&e.nameControl.touched?"A valid, non-empty name is required.":null),EE(),Vh("formControl",e.nameControl),dI(),EE(2),Vh("formControl",e.descriptionControl),dI(),EE(2),Vh("formControl",e.bodyControl),dI(),EE(3),Tw(e.resourceRows()),EE(5),Iw(e.errorMessage()?14:-1),EE(2),Vh("disabled",e.form.invalid||e.isSubmitting()),EE(),Yu(" ",e.isSubmitting()?"Saving\u2026":e.isEditMode()?"Save changes":"Create"," ");}}var ee=class i{route=g(W);router=g(F);destroyRef=g(we);skillState=g(o);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isEditMode=Mi(false);isLoading=Mi(false);isSubmitting=Mi(false);errorMessage=Mi(null);existingSkill=null;form=new pt({name:new Te("",{nonNullable:true,validators:[gn.required,gn.maxLength(100),gn.pattern(/^[a-zA-Z0-9_.-]+( [a-zA-Z0-9_.-]+)*$/)]}),description:new Te("",{nonNullable:true,validators:[gn.required,gn.maxLength(500),gn.pattern(/\S/)]}),body:new Te("",{nonNullable:true,validators:[gn.required,gn.pattern(/\S/)]})});resourceRows=Mi([]);get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get bodyControl(){return this.form.controls.body}ngOnInit(){let t=this.route.snapshot.paramMap.get("skillId");t&&(this.isEditMode.set(true),this.isLoading.set(true),this.skillState.getById(t).pipe(U(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(([o,l])=>({path:new Te(o,{nonNullable:true}),content:new Te(l,{nonNullable:true})}))),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}}));}addResource(){this.resourceRows.update(t=>[...t,{path:new Te("",{nonNullable:true}),content:new Te("",{nonNullable:true})}]);}removeResource(t){this.resourceRows.update(e=>e.filter(o=>o!==t));}buildResourcesPayload(){let t=this.resourceRows().map(e=>[e.path.value.trim(),e.content.value]).filter(([e])=>e.length>0);return Object.fromEntries(t)}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true),this.errorMessage.set(null);let t=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??"",t):this.skillState.create(t)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:o=>{this.isSubmitting.set(false),o.status===409?this.errorMessage.set(`A skill named "${this.nameControl.value.trim()}" already exists in this scope.`):o.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 t=this.route.snapshot.paramMap.get("skillId")??"";return this.isPlatformMode?["/agentos","admin","skills",t,"inspect"]:["/agentos",this.namespaceId,"skills",t,"inspect"]}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","skills"]):this.router.navigate(["/agentos",this.namespaceId,"skills"]);}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JI({type:i,selectors:[["agentos-skill-form"]],decls:8,vars:4,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to skills",3,"click"],["headerMeta","",1,"ds-link",3,"routerLink"],["headerMeta","","variant","outline"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["label","Name","controlId","skill-name","hint","The value an agent's skillSelectors entry must match. Letters, digits, dash, dot, underscore and single spaces; 100 characters max.",3,"error"],["dsControl","","id","skill-name","type","text","autocomplete","off",3,"formControl"],["label","Description","controlId","skill-description","hint","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."],["dsControl","","id","skill-description","rows","2",3,"formControl"],["label","Body","controlId","skill-body","hint","Markdown instructions returned verbatim by the readSkill tool when the agent asks for this skill."],["dsControl","","mono","","id","skill-body","rows","16",3,"formControl"],["label","Resources","hint","Optional files the agent can read with readSkillResource, by relative path."],[1,"ds-stack"],[1,"ds-stack","ds-stack--sm"],["dsButton","","variant","ghost","type","button",3,"click"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"click"],[1,"ds-inline"],["dsControl","","mono","","type","text","placeholder","e.g. references/checklist.md","aria-label","Resource path","autocomplete","off",3,"formControl"],["dsButton","","variant","icon-danger","type","button","title","Remove","aria-label","Remove resource",3,"click"],["dsControl","","mono","","rows","4","aria-label","Resource content",3,"formControl"]],template:function(e,o){e&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return o.cancel()}),fC(3,"\u2190 Skills"),zu(),Ew(4,ie,2,1,"a",2),Ew(5,oe,2,0,"ds-tag",3),zu(),Ew(6,ne,2,0,"p",4)(7,se,20,8,"form",5),zu()),e&2&&(EE(),Vh("title",o.isEditMode()?"Edit skill":"New skill"),EE(3),Iw(o.isEditMode()?4:-1),EE(),Iw(o.isPlatformMode?5:-1),EE(),Iw(o.isLoading()?6:7));},dependencies:[qt,md,Ht,po,ho,An,On,$t,hn,fn,un,cn,pn,at,sn,Fo],encapsulation:2})};export{ee as SkillFormComponent};
1
+ import {o}from'./chunk-DmRaBKc6.js';import {p as pt,T as Te,g as gn,q as qt,m as md,H as Ht,a as po,h as ho,A as An,O as On,b as hn,c as fn,u as un,d as cn,E as pn,e as at,i as sn,n as Fo}from'./chunk-COmLfT0N.js';import {g,W,F,w as we,M as Mi,x as U,K as x,C as w,J as JI,ax as $t,o as os,Q as qh,f as fC,z as zu,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,n as Aw,H as Hh,R as uI,i as bw,aq as ww,S as dI,T as Tw,Y as Yu,q as Pd,L as Ld,l as lg}from'./main-B6UJJXO7.js';function ie(i,t){if(i&1&&(os(0,"a",2),fC(1,"View skill \u2192"),zu()),i&2){let e=Pw();Vh("routerLink",e.inspectRoute());}}function oe(i,t){i&1&&(os(0,"ds-tag",3),fC(1,"Platform level"),zu());}function ne(i,t){i&1&&(os(0,"p",4),fC(1,"Loading\u2026"),zu());}function re(i,t){if(i&1){let e=Aw();os(0,"div",15)(1,"div",19),Hh(2,"input",20),uI(),os(3,"button",21),qh("click",function(){let l=Pd(e).$implicit,te=Pw(2);return Ld(te.removeResource(l))}),fC(4," \xD7 "),zu()(),Hh(5,"textarea",22),uI(),zu();}if(i&2){let e=t.$implicit;EE(2),Vh("formControl",e.path),dI(),EE(3),Vh("formControl",e.content),dI();}}function ae(i,t){if(i&1&&(os(0,"ds-notice"),fC(1),zu()),i&2){let e=Pw(2);EE(),lg(e.errorMessage());}}function se(i,t){if(i&1){let e=Aw();os(0,"form",6),qh("ngSubmit",function(){Pd(e);let l=Pw();return Ld(l.submit())}),os(1,"ds-form-field",7),Hh(2,"input",8),uI(),zu(),os(3,"ds-form-field",9),Hh(4,"textarea",10),uI(),zu(),os(5,"ds-form-field",11),Hh(6,"textarea",12),uI(),zu(),os(7,"ds-form-field",13)(8,"div",14),bw(9,re,6,2,"div",15,ww),os(11,"div")(12,"button",16),qh("click",function(){Pd(e);let l=Pw();return Ld(l.addResource())}),fC(13,"+ Add resource"),zu()()()(),Ew(14,ae,2,1,"ds-notice"),os(15,"ds-form-actions")(16,"button",17),fC(17),zu(),os(18,"button",18),qh("click",function(){Pd(e);let l=Pw();return Ld(l.cancel())}),fC(19,"Cancel"),zu()()();}if(i&2){let e=Pw();Vh("formGroup",e.form),EE(),Vh("error",e.nameControl.invalid&&e.nameControl.touched?"A valid, non-empty name is required.":null),EE(),Vh("formControl",e.nameControl),dI(),EE(2),Vh("formControl",e.descriptionControl),dI(),EE(2),Vh("formControl",e.bodyControl),dI(),EE(3),Tw(e.resourceRows()),EE(5),Iw(e.errorMessage()?14:-1),EE(2),Vh("disabled",e.form.invalid||e.isSubmitting()),EE(),Yu(" ",e.isSubmitting()?"Saving\u2026":e.isEditMode()?"Save changes":"Create"," ");}}var ee=class i{route=g(W);router=g(F);destroyRef=g(we);skillState=g(o);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;isEditMode=Mi(false);isLoading=Mi(false);isSubmitting=Mi(false);errorMessage=Mi(null);existingSkill=null;form=new pt({name:new Te("",{nonNullable:true,validators:[gn.required,gn.maxLength(100),gn.pattern(/^[a-zA-Z0-9_.-]+( [a-zA-Z0-9_.-]+)*$/)]}),description:new Te("",{nonNullable:true,validators:[gn.required,gn.maxLength(500),gn.pattern(/\S/)]}),body:new Te("",{nonNullable:true,validators:[gn.required,gn.pattern(/\S/)]})});resourceRows=Mi([]);get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get bodyControl(){return this.form.controls.body}ngOnInit(){let t=this.route.snapshot.paramMap.get("skillId");t&&(this.isEditMode.set(true),this.isLoading.set(true),this.skillState.getById(t).pipe(U(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(([o,l])=>({path:new Te(o,{nonNullable:true}),content:new Te(l,{nonNullable:true})}))),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}}));}addResource(){this.resourceRows.update(t=>[...t,{path:new Te("",{nonNullable:true}),content:new Te("",{nonNullable:true})}]);}removeResource(t){this.resourceRows.update(e=>e.filter(o=>o!==t));}buildResourcesPayload(){let t=this.resourceRows().map(e=>[e.path.value.trim(),e.content.value]).filter(([e])=>e.length>0);return Object.fromEntries(t)}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true),this.errorMessage.set(null);let t=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??"",t):this.skillState.create(t)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:o=>{this.isSubmitting.set(false),o.status===409?this.errorMessage.set(`A skill named "${this.nameControl.value.trim()}" already exists in this scope.`):o.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 t=this.route.snapshot.paramMap.get("skillId")??"";return this.isPlatformMode?["/agentos","admin","skills",t,"inspect"]:["/agentos",this.namespaceId,"skills",t,"inspect"]}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","skills"]):this.router.navigate(["/agentos",this.namespaceId,"skills"]);}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JI({type:i,selectors:[["agentos-skill-form"]],decls:8,vars:4,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to skills",3,"click"],["headerMeta","",1,"ds-link",3,"routerLink"],["headerMeta","","variant","outline"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["label","Name","controlId","skill-name","hint","The value an agent's skillSelectors entry must match. Letters, digits, dash, dot, underscore and single spaces; 100 characters max.",3,"error"],["dsControl","","id","skill-name","type","text","autocomplete","off",3,"formControl"],["label","Description","controlId","skill-description","hint","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."],["dsControl","","id","skill-description","rows","2",3,"formControl"],["label","Body","controlId","skill-body","hint","Markdown instructions returned verbatim by the readSkill tool when the agent asks for this skill."],["dsControl","","mono","","id","skill-body","rows","16",3,"formControl"],["label","Resources","hint","Optional files the agent can read with readSkillResource, by relative path."],[1,"ds-stack"],[1,"ds-stack","ds-stack--sm"],["dsButton","","variant","ghost","type","button",3,"click"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"click"],[1,"ds-inline"],["dsControl","","mono","","type","text","placeholder","e.g. references/checklist.md","aria-label","Resource path","autocomplete","off",3,"formControl"],["dsButton","","variant","icon-danger","type","button","title","Remove","aria-label","Remove resource",3,"click"],["dsControl","","mono","","rows","4","aria-label","Resource content",3,"formControl"]],template:function(e,o){e&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return o.cancel()}),fC(3,"\u2190 Skills"),zu(),Ew(4,ie,2,1,"a",2),Ew(5,oe,2,0,"ds-tag",3),zu(),Ew(6,ne,2,0,"p",4)(7,se,20,8,"form",5),zu()),e&2&&(EE(),Vh("title",o.isEditMode()?"Edit skill":"New skill"),EE(3),Iw(o.isEditMode()?4:-1),EE(),Iw(o.isPlatformMode?5:-1),EE(),Iw(o.isLoading()?6:7));},dependencies:[qt,md,Ht,po,ho,An,On,$t,hn,fn,un,cn,pn,at,sn,Fo],encapsulation:2})};export{ee as SkillFormComponent};
@@ -1 +1 @@
1
- import {i}from'./chunk-CVAz4Lko.js';import {y}from'./chunk-CCZ1b0na.js';import {g,aL as X,a3 as vr,aw as $m,a5 as Ys,a6 as Zs,ae as Dr,ah as te,aK as my,K as x,C as w$1,a9 as Hl,aM as st,aN as bt,aO as en,aa as k$1}from'./main-63IEQS3X.js';var nt=["ApiKeyAuthSetting","BasicAuthAuthSetting","BearerTokenAuthSetting","OAuthDiscoverableAuthSetting","OAuthMcpDiscoverableAuthSetting","OAuthCustomAuthSetting","OAuthRegisteredAuthSetting"],it={ApiKeyAuthSetting:"API Key",BasicAuthAuthSetting:"Basic Auth (username / password)",BearerTokenAuthSetting:"Bearer Token",OAuthDiscoverableAuthSetting:"OAuth \u2014 Discovery URL",OAuthMcpDiscoverableAuthSetting:"OAuth \u2014 MCP Discoverable",OAuthCustomAuthSetting:"OAuth \u2014 Custom endpoints",OAuthRegisteredAuthSetting:"OAuth \u2014 Registered app"},R="none",w="me",b=2e3,M=15e4,P=3,L={ApiKeyAuthSetting:"API_KEY",BasicAuthAuthSetting:"BASIC_AUTH",BearerTokenAuthSetting:"BEARER_TOKEN",OAuthDiscoverableAuthSetting:"OAUTH_DISCOVERABLE",OAuthMcpDiscoverableAuthSetting:"OAUTH_MCP_DISCOVERABLE",OAuthCustomAuthSetting:"OAUTH_CUSTOM",OAuthRegisteredAuthSetting:"OAUTH_REGISTERED"},k={API_KEY:"ApiKeyAuthSetting",BASIC_AUTH:"BasicAuthAuthSetting",BEARER_TOKEN:"BearerTokenAuthSetting",OAUTH_DISCOVERABLE:"OAuthDiscoverableAuthSetting",OAUTH_MCP_DISCOVERABLE:"OAuthMcpDiscoverableAuthSetting",OAUTH_CUSTOM:"OAuthCustomAuthSetting",OAUTH_REGISTERED:"OAuthRegisteredAuthSetting"};function B(i){let t=L[i.authType];return t?x(w$1({},i),{authType:t}):i}function m(i){return U(i)}function f(i){return i.map(U)}function U(i){let t=i;if(typeof t.authType=="string"){let e=k[t.authType];if(e)return x(w$1({},t),{authType:e})}return i}function H(i,t){return t===null?true:i!==void 0&&Date.parse(i)>Date.parse(t)}var I=class i$1{controller=g(X);userState=g(y);refresh$=new vr(void 0);namespaceId$=new vr(null);vm$=$m([this.namespaceId$,this.refresh$]).pipe(Ys(([t])=>{let e=this.loadPlatformSettings().pipe(Zs(()=>Dr([])));return t?$m([e,this.loadNamespaceSettings(t).pipe(Zs(()=>Dr([]))),this.loadUserSettings(t).pipe(Zs(()=>Dr([]))),this.loadUserSettings("global").pipe(Zs(()=>Dr([])))]).pipe(te(([n,o,r,h])=>({platform:n,namespace:o,userOnNs:r,userGlobal:h}))):$m([e,this.loadNamespaceSettings("").pipe(Zs(()=>Dr([]))),this.loadUserSettings("global").pipe(Zs(()=>Dr([])))]).pipe(te(([n,o,r])=>({platform:n,namespace:o,userOnNs:[],userGlobal:r})))}),my({bufferSize:1,refCount:true}));setNamespace(t){this.namespaceId$.value!==t&&this.namespaceId$.next(t);}refresh(){this.refresh$.next();}loadUserSettings(t){let e=t==="global"?R:t;return this.controller.listAuthSetting(e,w).pipe(te(n=>f(n)))}userGlobal$=i(this.refresh$,()=>this.loadUserSettings("global"),[]);loadPlatformSettings(){return this.controller.listAuthSetting(R).pipe(te(t=>f(t)))}loadNamespaceSettings(t){return t?this.controller.listAuthSetting(t).pipe(te(e=>f(e))):Dr([])}getById(t,e){return this.controller.getByIdAuthSetting(t).pipe(te(n=>m(n)))}create(t,e,n){let r=this.userState.currentUser()?.id;if((e==="userOnNs"||e==="userGlobal")&&!r)throw new Error(`Cannot create ${e} auth setting before UserStateService.loadMe() resolves \u2014 call loadMe() at app init`);if(e==="namespace"&&(n===void 0||n===""))throw new Error("Cannot create namespace-scoped auth setting without a namespaceId");if(e==="userOnNs"&&!n)throw new Error("Cannot create userOnNs auth setting without a namespaceId");let h=B(x(w$1({},t),{namespaceId:e==="namespace"||e==="userOnNs"?n??void 0:void 0,userId:e==="userOnNs"||e==="userGlobal"?r:void 0}));return this.controller.createAuthSetting(h).pipe(te(A=>m(A)),Hl(()=>this.refresh()))}update(t,e,n){let o=B(x(w$1({},e),{namespaceId:n.namespaceId,userId:n.userId,authType:n.authType}));return this.controller.updateAuthSetting(t,o).pipe(te(r=>m(r)),Hl(()=>this.refresh()))}delete(t,e){return this.controller.deleteAuthSetting(t).pipe(Hl(()=>this.refresh()))}getConnection(t,e){return this.controller.getConnectionAuthSetting(t,e)}resetCredential(t,e){return this.controller.resetMyCredentialAuthSetting(t,e)}connect(t,e,n,o){return this.getConnection(t,e).pipe(Ys(r=>this.controller.connectAuthSetting(t,e).pipe(Hl(h=>n(h.authorizationUrl)),Ys(()=>this.awaitNewConnection(t,e,r.connected?r.connectedAt??null:null,o)))))}awaitNewConnection(t,e,n,o){let r=0,h=0;return st(b,b).pipe(Ys(()=>this.getConnection(t,e).pipe(Zs(()=>Dr(null)))),te(A=>(r++,A?.connected&&H(A.connectedAt,n)?"connected":r*b>=M?"timeout":o()&&++h>=P?"abandoned":null)),bt(A=>A!==null),en(1))}static \u0275fac=function(e){return new(e||i$1)};static \u0275prov=k$1({token:i$1,factory:i$1.\u0275fac,providedIn:"root"})};export{I,it as i,nt as n};
1
+ import {i}from'./chunk-DxIOAne_.js';import {y}from'./chunk-COmLfT0N.js';import {g,aL as X,a3 as vr,aw as $m,a5 as Ys,a6 as Zs,ae as Dr,ah as te,aK as my,K as x,C as w$1,a9 as Hl,aM as st,aN as bt,aO as en,aa as k$1}from'./main-B6UJJXO7.js';var nt=["ApiKeyAuthSetting","BasicAuthAuthSetting","BearerTokenAuthSetting","OAuthDiscoverableAuthSetting","OAuthMcpDiscoverableAuthSetting","OAuthCustomAuthSetting","OAuthRegisteredAuthSetting"],it={ApiKeyAuthSetting:"API Key",BasicAuthAuthSetting:"Basic Auth (username / password)",BearerTokenAuthSetting:"Bearer Token",OAuthDiscoverableAuthSetting:"OAuth \u2014 Discovery URL",OAuthMcpDiscoverableAuthSetting:"OAuth \u2014 MCP Discoverable",OAuthCustomAuthSetting:"OAuth \u2014 Custom endpoints",OAuthRegisteredAuthSetting:"OAuth \u2014 Registered app"},R="none",w="me",b=2e3,M=15e4,P=3,L={ApiKeyAuthSetting:"API_KEY",BasicAuthAuthSetting:"BASIC_AUTH",BearerTokenAuthSetting:"BEARER_TOKEN",OAuthDiscoverableAuthSetting:"OAUTH_DISCOVERABLE",OAuthMcpDiscoverableAuthSetting:"OAUTH_MCP_DISCOVERABLE",OAuthCustomAuthSetting:"OAUTH_CUSTOM",OAuthRegisteredAuthSetting:"OAUTH_REGISTERED"},k={API_KEY:"ApiKeyAuthSetting",BASIC_AUTH:"BasicAuthAuthSetting",BEARER_TOKEN:"BearerTokenAuthSetting",OAUTH_DISCOVERABLE:"OAuthDiscoverableAuthSetting",OAUTH_MCP_DISCOVERABLE:"OAuthMcpDiscoverableAuthSetting",OAUTH_CUSTOM:"OAuthCustomAuthSetting",OAUTH_REGISTERED:"OAuthRegisteredAuthSetting"};function B(i){let t=L[i.authType];return t?x(w$1({},i),{authType:t}):i}function m(i){return U(i)}function f(i){return i.map(U)}function U(i){let t=i;if(typeof t.authType=="string"){let e=k[t.authType];if(e)return x(w$1({},t),{authType:e})}return i}function H(i,t){return t===null?true:i!==void 0&&Date.parse(i)>Date.parse(t)}var I=class i$1{controller=g(X);userState=g(y);refresh$=new vr(void 0);namespaceId$=new vr(null);vm$=$m([this.namespaceId$,this.refresh$]).pipe(Ys(([t])=>{let e=this.loadPlatformSettings().pipe(Zs(()=>Dr([])));return t?$m([e,this.loadNamespaceSettings(t).pipe(Zs(()=>Dr([]))),this.loadUserSettings(t).pipe(Zs(()=>Dr([]))),this.loadUserSettings("global").pipe(Zs(()=>Dr([])))]).pipe(te(([n,o,r,h])=>({platform:n,namespace:o,userOnNs:r,userGlobal:h}))):$m([e,this.loadNamespaceSettings("").pipe(Zs(()=>Dr([]))),this.loadUserSettings("global").pipe(Zs(()=>Dr([])))]).pipe(te(([n,o,r])=>({platform:n,namespace:o,userOnNs:[],userGlobal:r})))}),my({bufferSize:1,refCount:true}));setNamespace(t){this.namespaceId$.value!==t&&this.namespaceId$.next(t);}refresh(){this.refresh$.next();}loadUserSettings(t){let e=t==="global"?R:t;return this.controller.listAuthSetting(e,w).pipe(te(n=>f(n)))}userGlobal$=i(this.refresh$,()=>this.loadUserSettings("global"),[]);loadPlatformSettings(){return this.controller.listAuthSetting(R).pipe(te(t=>f(t)))}loadNamespaceSettings(t){return t?this.controller.listAuthSetting(t).pipe(te(e=>f(e))):Dr([])}getById(t,e){return this.controller.getByIdAuthSetting(t).pipe(te(n=>m(n)))}create(t,e,n){let r=this.userState.currentUser()?.id;if((e==="userOnNs"||e==="userGlobal")&&!r)throw new Error(`Cannot create ${e} auth setting before UserStateService.loadMe() resolves \u2014 call loadMe() at app init`);if(e==="namespace"&&(n===void 0||n===""))throw new Error("Cannot create namespace-scoped auth setting without a namespaceId");if(e==="userOnNs"&&!n)throw new Error("Cannot create userOnNs auth setting without a namespaceId");let h=B(x(w$1({},t),{namespaceId:e==="namespace"||e==="userOnNs"?n??void 0:void 0,userId:e==="userOnNs"||e==="userGlobal"?r:void 0}));return this.controller.createAuthSetting(h).pipe(te(A=>m(A)),Hl(()=>this.refresh()))}update(t,e,n){let o=B(x(w$1({},e),{namespaceId:n.namespaceId,userId:n.userId,authType:n.authType}));return this.controller.updateAuthSetting(t,o).pipe(te(r=>m(r)),Hl(()=>this.refresh()))}delete(t,e){return this.controller.deleteAuthSetting(t).pipe(Hl(()=>this.refresh()))}getConnection(t,e){return this.controller.getConnectionAuthSetting(t,e)}resetCredential(t,e){return this.controller.resetMyCredentialAuthSetting(t,e)}connect(t,e,n,o){return this.getConnection(t,e).pipe(Ys(r=>this.controller.connectAuthSetting(t,e).pipe(Hl(h=>n(h.authorizationUrl)),Ys(()=>this.awaitNewConnection(t,e,r.connected?r.connectedAt??null:null,o)))))}awaitNewConnection(t,e,n,o){let r=0,h=0;return st(b,b).pipe(Ys(()=>this.getConnection(t,e).pipe(Zs(()=>Dr(null)))),te(A=>(r++,A?.connected&&H(A.connectedAt,n)?"connected":r*b>=M?"timeout":o()&&++h>=P?"abandoned":null)),bt(A=>A!==null),en(1))}static \u0275fac=function(e){return new(e||i$1)};static \u0275prov=k$1({token:i$1,factory:i$1.\u0275fac,providedIn:"root"})};export{I,it as i,nt as n};
@@ -1 +1 @@
1
- import {B as k,k as O,e as at,c as fn,l as ko,n as Fo,P,D as P$1}from'./chunk-CCZ1b0na.js';import {g,W as W$1,F,w as we,ak as U$1,a3 as vr,M as Mi,a5 as Ys,ag as Gm,a6 as Zs,ae as Dr,x as U$2,J as JI,o as os,Q as qh,z as zu,f as fC,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,l as lg,i as bw,T as Tw,Y as Yu,n as Aw,q as Pd,L as Ld,d as Bh}from'./main-63IEQS3X.js';var J=(n,e)=>e.key;function U(n,e){if(n&1&&(os(0,"p",3),fC(1),zu()),n&2){let t=Pw();EE(),lg(t.deletion.error());}}function z(n,e){n&1&&(os(0,"p",4),fC(1,"Loading agent configs\u2026"),zu());}function G(n,e){n&1&&(os(0,"p",5),fC(1,"No agent configs available."),zu());}function Q(n,e){n&1&&(os(0,"p",4),fC(1,"No agent configs match the current filter."),zu());}function W(n,e){n&1&&(os(0,"ds-tag",18),fC(1,"Read-only"),zu());}function X(n,e){if(n&1){let t=Aw();os(0,"button",22),qh("click",function(){Pd(t);let s=Pw(2).$implicit,d=Pw(2);return Ld(d.launch(s))}),fC(1," Launch "),zu();}if(n&2){let t=Pw(2).$implicit;Bh("aria-label","Launch "+t.config.name);}}function Y(n,e){if(n&1){let t=Aw();os(0,"button",22),qh("click",function(){Pd(t);let s=Pw(2).$implicit,d=Pw(2);return Ld(d.edit(s))}),fC(1," Edit "),zu();}if(n&2){let t=Pw(2).$implicit;Bh("aria-label","Edit "+t.config.name);}}function Z(n,e){if(n&1){let t=Aw();os(0,"button",22),qh("click",function(){Pd(t);let s=Pw().$implicit,d=Pw(2);return Ld(d.inspect(s))}),fC(1," Inspect "),zu(),Ew(2,X,2,1,"button",23),Ew(3,Y,2,1,"button",23);}if(n&2){let t=Pw().$implicit,i=Pw(2);Bh("aria-label","Inspect "+t.config.name),EE(2),Iw(i.canLaunch(t)?2:-1),EE(),Iw(t.scope==="namespace"?3:-1);}}function ee(n,e){if(n&1){let t=Aw();os(0,"agentos-row-delete-action",24),qh("deleteRequested",function(){Pd(t);let s=Pw().$implicit,d=Pw(2);return Ld(d.deletion.request(s.key))})("deleteConfirmed",function(){Pd(t);let s=Pw().$implicit,d=Pw(2);return Ld(d.confirmDelete(s))})("deleteCancelled",function(){Pd(t);let s=Pw(3);return Ld(s.deletion.cancel())}),zu();}if(n&2){let t=Pw().$implicit,i=Pw(2);Vh("rowKey",t.key)("rowLabel",t.config.name)("state",i.deletion);}}function te(n,e){if(n&1&&(os(0,"tr",9)(1,"td",12),fC(2),zu(),os(3,"td",13),fC(4),zu(),os(5,"td",14),fC(6),zu(),os(7,"td",15)(8,"div",16)(9,"ds-tag",17),fC(10),zu(),Ew(11,W,2,0,"ds-tag",18),zu()(),os(12,"td",19)(13,"div",20),Ew(14,Z,4,3),Ew(15,ee,1,3,"agentos-row-delete-action",21),zu()()()),n&2){let t=e.$implicit,i=Pw(2);EE(2),lg(t.config.name),EE(2),Yu(" ",t.config.description||"\u2014"," "),EE(2),lg(i.mode(t)),EE(3),Vh("variant",t.scope==="platform"?"neutral":"accent"),EE(),lg(t.scope==="platform"?"Platform":"Namespace"),EE(),Iw(t.scope==="platform"?11:-1),EE(3),Iw(i.deletion.confirmingId()!==t.key?14:-1),EE(),Iw(t.scope==="namespace"?15:-1);}}function ne(n,e){if(n&1&&(os(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),fC(5,"Name"),zu(),os(6,"th",10),fC(7,"Description"),zu(),os(8,"th",10),fC(9,"Execution mode"),zu(),os(10,"th",10),fC(11,"Scope"),zu(),os(12,"th",10)(13,"span",11),fC(14,"Actions"),zu()()()(),os(15,"tbody",8),bw(16,te,16,8,"tr",9,J),zu()()()),n&2){let t=Pw();EE(16),Tw(t.rowFilter.filteredRows());}}var H=class n{route=g(W$1);router=g(F);destroyRef=g(we);controller=g(U$1);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new vr(void 0);isLoading=Mi(true);deletion=k();rows=Mi([]);rowFilter=O(this.rows,e=>[e.config.name,e.config.description,this.mode(e),e.scope].filter(Boolean).join(" "));allConfigs$=this.refresh$.pipe(Ys(()=>(this.isLoading.set(true),Gm({namespace:this.controller.listByParentAgentConfig(this.namespaceId),platform:this.controller.listPlatformAgentsAgentConfig().pipe(Zs(()=>Dr([])))}))));constructor(){this.allConfigs$.pipe(U$2(this.destroyRef)).subscribe({next:({namespace:e,platform:t})=>{this.rows.set([...t.map((i,s)=>({key:`platform:${i.id??s}`,config:i,scope:"platform"})),...e.map((i,s)=>({key:`namespace:${i.id??s}`,config:i,scope:"namespace"}))]),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"agent-configs","new"]);}inspect(e){e.config.id&&this.router.navigate(e.scope==="platform"?["/agentos","admin","agent-configs",e.config.id,"inspect"]:["/agentos",this.namespaceId,"agent-configs",e.config.id,"inspect"]);}launch(e){e.scope==="platform"||!e.config.id||this.router.navigate(["/agentos",this.namespaceId,"agent-configs",e.config.id,"launch"]);}edit(e){e.scope==="platform"||!e.config.id||this.router.navigate(["/agentos",this.namespaceId,"agent-configs",e.config.id,"edit"]);}confirmDelete(e){e.scope==="platform"||!e.config.id||this.deletion.execute(e.key,{request$:this.controller.deleteAgentConfig(e.config.id).pipe(U$2(this.destroyRef)),onSuccess:()=>this.refresh$.next(),errorMessage:`Deleting "${e.config.name}" failed. Try again.`});}canLaunch(e){return e.scope==="namespace"&&e.config.executionMode==="LOOP"}mode(e){return e.config.executionMode??(e.config.advancedExecution?"ADVANCED":"SIMPLE")}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JI({type:n,selectors:[["agentos-namespace-agent-configs"]],decls:9,vars:3,consts:[["title","Agent configs","description","Agent configurations available in this namespace, including configurations inherited from the platform."],["label","Filter agent configs","placeholder","Filter agent configs\u2026",3,"queryChange","query"],["dsButton","","variant","primary","type","button",3,"click"],["role","alert",1,"settings-table__error"],["role","status",1,"settings-table__status"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table","aria-label","Agent configs"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title","",1,"settings-table__name"],["role","cell","data-label","Description",1,"settings-table__secondary"],["role","cell","data-label","Execution mode"],["role","cell","data-label","Scope"],[1,"settings-table__tags"],[3,"variant"],["variant","outline"],["role","cell","data-label","Actions","data-actions",""],[1,"settings-table__actions"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"rowKey","rowLabel","state"],["type","button",3,"click"],["type","button"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"]],template:function(t,i){t&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(d){return i.rowFilter.query.set(d)}),zu(),os(2,"button",2),qh("click",function(){return i.openCreateForm()}),fC(3,"New agent config"),zu()(),Ew(4,U,2,1,"p",3),Ew(5,z,2,0,"p",4)(6,G,2,0,"p",5)(7,Q,2,0,"p",4)(8,ne,18,0,"div",6)),t&2&&(EE(),Vh("query",i.rowFilter.query()),EE(3),Iw(i.deletion.error()?4:-1),EE(),Iw(i.isLoading()?5:i.rows().length===0?6:i.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,Fo,P,P$1],encapsulation:2})};export{H as NamespaceAgentConfigsComponent};
1
+ import {B as k,k as O,e as at,c as fn,l as ko,n as Fo,P,D as P$1}from'./chunk-COmLfT0N.js';import {g,W as W$1,F,w as we,ak as U$1,a3 as vr,M as Mi,a5 as Ys,ag as Gm,a6 as Zs,ae as Dr,x as U$2,J as JI,o as os,Q as qh,z as zu,f as fC,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,l as lg,i as bw,T as Tw,Y as Yu,n as Aw,q as Pd,L as Ld,d as Bh}from'./main-B6UJJXO7.js';var J=(n,e)=>e.key;function U(n,e){if(n&1&&(os(0,"p",3),fC(1),zu()),n&2){let t=Pw();EE(),lg(t.deletion.error());}}function z(n,e){n&1&&(os(0,"p",4),fC(1,"Loading agent configs\u2026"),zu());}function G(n,e){n&1&&(os(0,"p",5),fC(1,"No agent configs available."),zu());}function Q(n,e){n&1&&(os(0,"p",4),fC(1,"No agent configs match the current filter."),zu());}function W(n,e){n&1&&(os(0,"ds-tag",18),fC(1,"Read-only"),zu());}function X(n,e){if(n&1){let t=Aw();os(0,"button",22),qh("click",function(){Pd(t);let s=Pw(2).$implicit,d=Pw(2);return Ld(d.launch(s))}),fC(1," Launch "),zu();}if(n&2){let t=Pw(2).$implicit;Bh("aria-label","Launch "+t.config.name);}}function Y(n,e){if(n&1){let t=Aw();os(0,"button",22),qh("click",function(){Pd(t);let s=Pw(2).$implicit,d=Pw(2);return Ld(d.edit(s))}),fC(1," Edit "),zu();}if(n&2){let t=Pw(2).$implicit;Bh("aria-label","Edit "+t.config.name);}}function Z(n,e){if(n&1){let t=Aw();os(0,"button",22),qh("click",function(){Pd(t);let s=Pw().$implicit,d=Pw(2);return Ld(d.inspect(s))}),fC(1," Inspect "),zu(),Ew(2,X,2,1,"button",23),Ew(3,Y,2,1,"button",23);}if(n&2){let t=Pw().$implicit,i=Pw(2);Bh("aria-label","Inspect "+t.config.name),EE(2),Iw(i.canLaunch(t)?2:-1),EE(),Iw(t.scope==="namespace"?3:-1);}}function ee(n,e){if(n&1){let t=Aw();os(0,"agentos-row-delete-action",24),qh("deleteRequested",function(){Pd(t);let s=Pw().$implicit,d=Pw(2);return Ld(d.deletion.request(s.key))})("deleteConfirmed",function(){Pd(t);let s=Pw().$implicit,d=Pw(2);return Ld(d.confirmDelete(s))})("deleteCancelled",function(){Pd(t);let s=Pw(3);return Ld(s.deletion.cancel())}),zu();}if(n&2){let t=Pw().$implicit,i=Pw(2);Vh("rowKey",t.key)("rowLabel",t.config.name)("state",i.deletion);}}function te(n,e){if(n&1&&(os(0,"tr",9)(1,"td",12),fC(2),zu(),os(3,"td",13),fC(4),zu(),os(5,"td",14),fC(6),zu(),os(7,"td",15)(8,"div",16)(9,"ds-tag",17),fC(10),zu(),Ew(11,W,2,0,"ds-tag",18),zu()(),os(12,"td",19)(13,"div",20),Ew(14,Z,4,3),Ew(15,ee,1,3,"agentos-row-delete-action",21),zu()()()),n&2){let t=e.$implicit,i=Pw(2);EE(2),lg(t.config.name),EE(2),Yu(" ",t.config.description||"\u2014"," "),EE(2),lg(i.mode(t)),EE(3),Vh("variant",t.scope==="platform"?"neutral":"accent"),EE(),lg(t.scope==="platform"?"Platform":"Namespace"),EE(),Iw(t.scope==="platform"?11:-1),EE(3),Iw(i.deletion.confirmingId()!==t.key?14:-1),EE(),Iw(t.scope==="namespace"?15:-1);}}function ne(n,e){if(n&1&&(os(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),fC(5,"Name"),zu(),os(6,"th",10),fC(7,"Description"),zu(),os(8,"th",10),fC(9,"Execution mode"),zu(),os(10,"th",10),fC(11,"Scope"),zu(),os(12,"th",10)(13,"span",11),fC(14,"Actions"),zu()()()(),os(15,"tbody",8),bw(16,te,16,8,"tr",9,J),zu()()()),n&2){let t=Pw();EE(16),Tw(t.rowFilter.filteredRows());}}var H=class n{route=g(W$1);router=g(F);destroyRef=g(we);controller=g(U$1);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new vr(void 0);isLoading=Mi(true);deletion=k();rows=Mi([]);rowFilter=O(this.rows,e=>[e.config.name,e.config.description,this.mode(e),e.scope].filter(Boolean).join(" "));allConfigs$=this.refresh$.pipe(Ys(()=>(this.isLoading.set(true),Gm({namespace:this.controller.listByParentAgentConfig(this.namespaceId),platform:this.controller.listPlatformAgentsAgentConfig().pipe(Zs(()=>Dr([])))}))));constructor(){this.allConfigs$.pipe(U$2(this.destroyRef)).subscribe({next:({namespace:e,platform:t})=>{this.rows.set([...t.map((i,s)=>({key:`platform:${i.id??s}`,config:i,scope:"platform"})),...e.map((i,s)=>({key:`namespace:${i.id??s}`,config:i,scope:"namespace"}))]),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"agent-configs","new"]);}inspect(e){e.config.id&&this.router.navigate(e.scope==="platform"?["/agentos","admin","agent-configs",e.config.id,"inspect"]:["/agentos",this.namespaceId,"agent-configs",e.config.id,"inspect"]);}launch(e){e.scope==="platform"||!e.config.id||this.router.navigate(["/agentos",this.namespaceId,"agent-configs",e.config.id,"launch"]);}edit(e){e.scope==="platform"||!e.config.id||this.router.navigate(["/agentos",this.namespaceId,"agent-configs",e.config.id,"edit"]);}confirmDelete(e){e.scope==="platform"||!e.config.id||this.deletion.execute(e.key,{request$:this.controller.deleteAgentConfig(e.config.id).pipe(U$2(this.destroyRef)),onSuccess:()=>this.refresh$.next(),errorMessage:`Deleting "${e.config.name}" failed. Try again.`});}canLaunch(e){return e.scope==="namespace"&&e.config.executionMode==="LOOP"}mode(e){return e.config.executionMode??(e.config.advancedExecution?"ADVANCED":"SIMPLE")}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JI({type:n,selectors:[["agentos-namespace-agent-configs"]],decls:9,vars:3,consts:[["title","Agent configs","description","Agent configurations available in this namespace, including configurations inherited from the platform."],["label","Filter agent configs","placeholder","Filter agent configs\u2026",3,"queryChange","query"],["dsButton","","variant","primary","type","button",3,"click"],["role","alert",1,"settings-table__error"],["role","status",1,"settings-table__status"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table","aria-label","Agent configs"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title","",1,"settings-table__name"],["role","cell","data-label","Description",1,"settings-table__secondary"],["role","cell","data-label","Execution mode"],["role","cell","data-label","Scope"],[1,"settings-table__tags"],[3,"variant"],["variant","outline"],["role","cell","data-label","Actions","data-actions",""],[1,"settings-table__actions"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"rowKey","rowLabel","state"],["type","button",3,"click"],["type","button"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"]],template:function(t,i){t&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(d){return i.rowFilter.query.set(d)}),zu(),os(2,"button",2),qh("click",function(){return i.openCreateForm()}),fC(3,"New agent config"),zu()(),Ew(4,U,2,1,"p",3),Ew(5,z,2,0,"p",4)(6,G,2,0,"p",5)(7,Q,2,0,"p",4)(8,ne,18,0,"div",6)),t&2&&(EE(),Vh("query",i.rowFilter.query()),EE(3),Iw(i.deletion.error()?4:-1),EE(),Iw(i.isLoading()?5:i.rows().length===0?6:i.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,Fo,P,P$1],encapsulation:2})};export{H as NamespaceAgentConfigsComponent};
@@ -1,2 +1,2 @@
1
- import {I}from'./chunk-DQEn5_2f.js';import {g,W,b0 as J,w as we,M as Mi,h as BC,b1 as Ne,ag as Gm,x as U,a6 as Zs,ae as Dr,J as JI,o as os,H as Hh,E as Ew,z as zu,Q as qh,a as EE,I as Iw,N as Vh,f as fC,n as Aw,R as uI,i as bw,P as Pw,S as dI,T as Tw,Y as Yu,$ as dg,q as Pd,L as Ld,l as lg}from'./main-63IEQS3X.js';import {a9 as pd,C as Co,M as Mo,H as Ht,x as yn,U as Ut,a as po,ab as fa,af as Ri,b as hn,c as fn,u as un,t as dn,d as cn,E as pn,e as at,i as sn,v as an}from'./chunk-CCZ1b0na.js';import'./chunk-CVAz4Lko.js';var oe=(i,t)=>t.id;function ae(i,t){i&1&&(os(0,"p",1),fC(1,"Loading\u2026"),zu());}function se(i,t){if(i&1&&(os(0,"ds-notice"),fC(1),zu()),i&2){let e=Pw(2);EE(),lg(e.errorMessage());}}function re(i,t){if(i&1){let e=Aw();os(0,"div")(1,"button",23),qh("click",function(){Pd(e);let s=Pw(2);return Ld(s.retryLoad())}),fC(2,"Retry loading"),zu()();}}function ce(i,t){if(i&1&&(Hh(0,"br"),fC(1)),i&2){let e=Pw(3);EE(),Yu("",e.association()?.checkoutFailureReason," ");}}function de(i,t){if(i&1&&(os(0,"ds-notice",3),fC(1),Ew(2,ce,2,1),zu()),i&2){let e=Pw(2);Vh("tone",e.checkoutStatus()===e.CheckoutStatus.FAILED?"error":e.checkoutStatus()===e.CheckoutStatus.READY?"success":"neutral"),EE(),Yu(" Repository: ",e.checkoutStatus()," "),EE(),Iw(e.association()?.checkoutFailureReason?2:-1);}}function le(i,t){if(i&1&&(os(0,"option",12),fC(1),zu()),i&2){let e=t.$implicit,c=Pw(2);Vh("value",e.id),EE(),dg("",e.name," (",c.authTypeLabel(e.authType),")");}}function me(i,t){i&1&&(os(0,"p",13),fC(1," No usable auth setting in this namespace. Create a BEARER_TOKEN one first. "),zu());}function pe(i,t){if(i&1){let e=Aw();os(0,"button",24),qh("click",function(){Pd(e);let s=Pw(2);return Ld(s.remove())}),fC(1," Remove association "),zu();}if(i&2){let e=Pw(2);Vh("disabled",!e.associationLoaded()||e.isSaving());}}function ue(i,t){if(i&1){let e=Aw();Ew(0,se,2,1,"ds-notice"),Ew(1,re,3,0,"div"),Ew(2,de,3,3,"ds-notice",3),os(3,"ds-fieldset",4)(4,"ds-form-field",5)(5,"input",6),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.repositoryUrl.set(s))}),zu(),uI(),zu(),os(6,"ds-form-field",7)(7,"input",8),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.mainBranch.set(s))}),zu(),uI(),zu(),os(8,"ds-form-field",9)(9,"select",10),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.serviceAuthSettingId.set(s))}),os(10,"option",11),fC(11,"Select an auth setting\u2026"),zu(),bw(12,le,2,3,"option",12,oe),zu(),uI(),Ew(14,me,2,0,"p",13),zu()(),os(15,"ds-fieldset",14)(16,"div",15)(17,"label",16)(18,"input",17),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.autoWorktree.set(s))}),zu(),uI(),fC(19," Offer a worktree to every new top-level case "),zu(),os(20,"p",18),fC(21," The creator checks the box when creating the case; it is unchecked by default, and a case created without it has no Git. Applies to cases created from now on: turning this on later never equips existing cases, and turning it off never removes a worktree already created. "),zu()(),os(22,"ds-form-field",19)(23,"input",20),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.setupCommand.set(s))}),zu(),uI(),os(24,"p",13),fC(25," Runs on the server, as the service user, in each new worktree. It executes code from the branch \u2014 prefer a command that disables lifecycle scripts. "),zu()()(),os(26,"ds-form-actions")(27,"button",21),qh("click",function(){Pd(e);let s=Pw();return Ld(s.save())}),fC(28),zu(),Ew(29,pe,2,1,"button",22),zu();}if(i&2){let e=Pw();Iw(e.errorMessage()?0:-1),EE(),Iw(e.associationLoaded()?-1:1),EE(),Iw(e.isAssociated()&&e.checkoutStatus()?2:-1),EE(),Vh("disabled",!e.associationLoaded()||e.isSaving()),EE(2),Vh("ngModel",e.repositoryUrl()),dI(),EE(2),Vh("ngModel",e.mainBranch()),dI(),EE(2),Vh("ngModel",e.serviceAuthSettingId()),dI(),EE(3),Tw(e.eligibleAuthSettings()),EE(2),Iw(e.eligibleAuthSettings().length===0?14:-1),EE(),Vh("disabled",!e.associationLoaded()||e.isSaving()),EE(3),Vh("ngModel",e.autoWorktree()),dI(),EE(5),Vh("ngModel",e.setupCommand()),dI(),EE(4),Vh("disabled",!e.canSave()),EE(),Yu(" ",e.isSaving()?"Saving\u2026":e.isAssociated()?"Update":"Associate"," "),EE(),Iw(e.isAssociated()?29:-1);}}var ge=["BearerTokenAuthSetting","BasicAuthAuthSetting","ApiKeyAuthSetting"],he={BearerTokenAuthSetting:"token",BasicAuthAuthSetting:"basic auth",ApiKeyAuthSetting:"API key"},ne=class i{route=g(W);gitApi=g(J);authSettingState=g(I);destroyRef=g(we);isLoading=Mi(true);isSaving=Mi(false);confirmingRemove=Mi(false);associationLoaded=Mi(false);errorMessage=Mi(null);association=Mi(null);authSettings=Mi([]);repositoryUrl=Mi("");mainBranch=Mi("main");serviceAuthSettingId=Mi("");autoWorktree=Mi(false);setupCommand=Mi("");namespaceId="";isAssociated=BC(()=>this.association()?.associated===true);eligibleAuthSettings=BC(()=>this.authSettings().filter(t=>ge.includes(t.authType)));authTypeLabel(t){return he[t??""]??t??"unknown"}canSave=BC(()=>this.associationLoaded()&&!this.isLoading()&&!this.isSaving()&&this.repositoryUrl().trim().length>0&&this.serviceAuthSettingId().length>0);checkoutStatus=BC(()=>this.association()?.checkoutStatus??null);CheckoutStatus=Ne;ngOnInit(){this.namespaceId=this.route.snapshot.paramMap.get("namespaceId")??"",this.load();}retryLoad(){this.isLoading()||this.isSaving()||this.load();}load(){this.isLoading.set(true),this.associationLoaded.set(false),this.errorMessage.set(null),Gm({association:this.gitApi.getAssociationNamespaceGit(this.namespaceId),authSettings:this.authSettingState.loadNamespaceSettings(this.namespaceId)}).pipe(U(this.destroyRef)).subscribe({next:({association:t,authSettings:e})=>{this.authSettings.set(e??[]),this.acceptAssociation(t),this.isLoading.set(false);},error:t=>{console.error("Failed to load the Git repository settings",t),this.errorMessage.set(this.messageOf(t)),this.isLoading.set(false);}});}acceptAssociation(t){this.association.set(t);let e=t?.associated===false||t?.associated===true&&typeof t.repositoryUrl=="string"&&typeof t.mainBranch=="string"&&typeof t.serviceAuthSettingId=="string"&&typeof t.autoWorktreeForRootCases=="boolean"&&(t.setupCommand==null||typeof t.setupCommand=="string");this.associationLoaded.set(e),e?this.applyToForm(t):this.errorMessage.set("The repository settings could not be loaded completely. Retry before making changes.");}applyToForm(t){this.repositoryUrl.set(t.repositoryUrl??""),this.mainBranch.set(t.mainBranch??"main"),this.serviceAuthSettingId.set(t.serviceAuthSettingId??""),this.autoWorktree.set(t.autoWorktreeForRootCases??false),this.setupCommand.set(t.setupCommand??"");}save(){this.canSave()&&(this.isSaving.set(true),this.errorMessage.set(null),this.gitApi.setAssociationNamespaceGit(this.namespaceId,{repositoryUrl:this.repositoryUrl().trim(),mainBranch:this.mainBranch().trim()||void 0,serviceAuthSettingId:this.serviceAuthSettingId(),autoWorktreeForRootCases:this.autoWorktree(),setupCommand:this.setupCommand().trim()||void 0}).pipe(U(this.destroyRef),Zs(t=>(console.error("Failed to save the Git association",t),this.errorMessage.set(this.messageOf(t)),this.isSaving.set(false),Dr(null)))).subscribe(t=>{t&&this.acceptAssociation(t),this.isSaving.set(false);}));}remove(){!this.associationLoaded()||this.isLoading()||this.isSaving()||!this.isAssociated()||this.confirmingRemove.set(true);}confirmRemove(){this.confirmingRemove.set(false),!(!this.associationLoaded()||this.isLoading()||this.isSaving()||!this.isAssociated())&&(this.isSaving.set(true),this.gitApi.removeAssociationNamespaceGit(this.namespaceId).pipe(U(this.destroyRef),Zs(t=>(console.error("Failed to remove the Git association",t),this.errorMessage.set(this.messageOf(t)),this.isSaving.set(false),Dr(null)))).subscribe(t=>{t&&this.acceptAssociation(t),this.isSaving.set(false);}));}messageOf(t){return t.error?.message??t.message??"Unexpected error"}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JI({type:i,selectors:[["agentos-namespace-git"]],decls:5,vars:2,consts:[["title","Git repository","description","Associating a repository enables Git workspaces for this namespace. When worktree creation is enabled, the new-case form offers a worktree, and a case created with one gets a repo/ directory shared by its sub-cases. Namespace files remain shared documents outside Git. Agents create branches and pull requests in their workflows."],[1,"ds-hint"],["title","Remove the repository association?","message","Existing workspaces keep their worktree.","confirmLabel","Remove","cancelLabel","Cancel",3,"confirmed","cancelled","open"],[3,"tone"],["legend","Repository",3,"disabled"],["label","Repository URL","controlId","git-url","hint","HTTPS only, without credentials in the URL."],["dsControl","","id","git-url","type","url","placeholder","https://forge.example/org/project.git","name","repositoryUrl",3,"ngModelChange","ngModel"],["label","Main branch","controlId","git-branch","hint","New worktrees start at this branch\u2019s commit, without creating a branch."],["dsControl","","id","git-branch","type","text","placeholder","main","name","mainBranch",3,"ngModelChange","ngModel"],["label","Service account","controlId","git-auth","hint","Shared by the namespace. Every Git operation uses this identity, never the identity of whoever opened the case."],["dsControl","","id","git-auth","name","serviceAuthSettingId",3,"ngModelChange","ngModel"],["value",""],[3,"value"],[1,"ds-hint","ds-hint--warning"],["legend","Automation",3,"disabled"],[1,"ds-stack","ds-stack--sm"],["dsCheck",""],["type","checkbox","name","autoWorktree",3,"ngModelChange","ngModel"],[1,"ds-hint","ds-indent"],["label","Setup command (optional)","controlId","git-setup"],["dsControl","","mono","","id","git-setup","type","text","placeholder","pnpm install --ignore-scripts","name","setupCommand",3,"ngModelChange","ngModel"],["id","git-save","dsButton","","variant","primary","type","button",3,"click","disabled"],["id","git-remove","dsButton","","variant","danger","type","button",3,"disabled"],["id","git-retry","dsButton","","type","button",3,"click"],["id","git-remove","dsButton","","variant","danger","type","button",3,"click","disabled"]],template:function(e,c){e&1&&(os(0,"ds-page"),Hh(1,"ds-section-header",0),Ew(2,ae,2,0,"p",1)(3,ue,30,14),zu(),os(4,"ds-confirm-dialog",2),qh("confirmed",function(){return c.confirmRemove()})("cancelled",function(){return c.confirmingRemove.set(false)}),zu()),e&2&&(EE(2),Iw(c.isLoading()?2:3),EE(2),Vh("open",c.confirmingRemove()));},dependencies:[pd,Co,Mo,Ht,yn,Ut,po,fa,Ri,hn,fn,un,dn,cn,pn,at,sn,an],encapsulation:2})};
1
+ import {I}from'./chunk-Cq9jD9x7.js';import {g,W,b0 as J,w as we,M as Mi,h as BC,b1 as ke,ag as Gm,x as U,a6 as Zs,ae as Dr,J as JI,o as os,H as Hh,E as Ew,z as zu,Q as qh,a as EE,I as Iw,N as Vh,f as fC,n as Aw,R as uI,i as bw,P as Pw,S as dI,T as Tw,Y as Yu,$ as dg,q as Pd,L as Ld,l as lg}from'./main-B6UJJXO7.js';import {a9 as pd,C as Co,M as Mo,H as Ht,x as yn,U as Ut,a as po,ab as fa,af as Ri,b as hn,c as fn,u as un,t as dn,d as cn,E as pn,e as at,i as sn,v as an}from'./chunk-COmLfT0N.js';import'./chunk-DxIOAne_.js';var oe=(i,t)=>t.id;function ae(i,t){i&1&&(os(0,"p",1),fC(1,"Loading\u2026"),zu());}function se(i,t){if(i&1&&(os(0,"ds-notice"),fC(1),zu()),i&2){let e=Pw(2);EE(),lg(e.errorMessage());}}function re(i,t){if(i&1){let e=Aw();os(0,"div")(1,"button",23),qh("click",function(){Pd(e);let s=Pw(2);return Ld(s.retryLoad())}),fC(2,"Retry loading"),zu()();}}function ce(i,t){if(i&1&&(Hh(0,"br"),fC(1)),i&2){let e=Pw(3);EE(),Yu("",e.association()?.checkoutFailureReason," ");}}function de(i,t){if(i&1&&(os(0,"ds-notice",3),fC(1),Ew(2,ce,2,1),zu()),i&2){let e=Pw(2);Vh("tone",e.checkoutStatus()===e.CheckoutStatus.FAILED?"error":e.checkoutStatus()===e.CheckoutStatus.READY?"success":"neutral"),EE(),Yu(" Repository: ",e.checkoutStatus()," "),EE(),Iw(e.association()?.checkoutFailureReason?2:-1);}}function le(i,t){if(i&1&&(os(0,"option",12),fC(1),zu()),i&2){let e=t.$implicit,c=Pw(2);Vh("value",e.id),EE(),dg("",e.name," (",c.authTypeLabel(e.authType),")");}}function me(i,t){i&1&&(os(0,"p",13),fC(1," No usable auth setting in this namespace. Create a BEARER_TOKEN one first. "),zu());}function pe(i,t){if(i&1){let e=Aw();os(0,"button",24),qh("click",function(){Pd(e);let s=Pw(2);return Ld(s.remove())}),fC(1," Remove association "),zu();}if(i&2){let e=Pw(2);Vh("disabled",!e.associationLoaded()||e.isSaving());}}function ue(i,t){if(i&1){let e=Aw();Ew(0,se,2,1,"ds-notice"),Ew(1,re,3,0,"div"),Ew(2,de,3,3,"ds-notice",3),os(3,"ds-fieldset",4)(4,"ds-form-field",5)(5,"input",6),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.repositoryUrl.set(s))}),zu(),uI(),zu(),os(6,"ds-form-field",7)(7,"input",8),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.mainBranch.set(s))}),zu(),uI(),zu(),os(8,"ds-form-field",9)(9,"select",10),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.serviceAuthSettingId.set(s))}),os(10,"option",11),fC(11,"Select an auth setting\u2026"),zu(),bw(12,le,2,3,"option",12,oe),zu(),uI(),Ew(14,me,2,0,"p",13),zu()(),os(15,"ds-fieldset",14)(16,"div",15)(17,"label",16)(18,"input",17),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.autoWorktree.set(s))}),zu(),uI(),fC(19," Offer a worktree to every new top-level case "),zu(),os(20,"p",18),fC(21," The creator checks the box when creating the case; it is unchecked by default, and a case created without it has no Git. Applies to cases created from now on: turning this on later never equips existing cases, and turning it off never removes a worktree already created. "),zu()(),os(22,"ds-form-field",19)(23,"input",20),qh("ngModelChange",function(s){Pd(e);let u=Pw();return Ld(u.setupCommand.set(s))}),zu(),uI(),os(24,"p",13),fC(25," Runs on the server, as the service user, in each new worktree. It executes code from the branch \u2014 prefer a command that disables lifecycle scripts. "),zu()()(),os(26,"ds-form-actions")(27,"button",21),qh("click",function(){Pd(e);let s=Pw();return Ld(s.save())}),fC(28),zu(),Ew(29,pe,2,1,"button",22),zu();}if(i&2){let e=Pw();Iw(e.errorMessage()?0:-1),EE(),Iw(e.associationLoaded()?-1:1),EE(),Iw(e.isAssociated()&&e.checkoutStatus()?2:-1),EE(),Vh("disabled",!e.associationLoaded()||e.isSaving()),EE(2),Vh("ngModel",e.repositoryUrl()),dI(),EE(2),Vh("ngModel",e.mainBranch()),dI(),EE(2),Vh("ngModel",e.serviceAuthSettingId()),dI(),EE(3),Tw(e.eligibleAuthSettings()),EE(2),Iw(e.eligibleAuthSettings().length===0?14:-1),EE(),Vh("disabled",!e.associationLoaded()||e.isSaving()),EE(3),Vh("ngModel",e.autoWorktree()),dI(),EE(5),Vh("ngModel",e.setupCommand()),dI(),EE(4),Vh("disabled",!e.canSave()),EE(),Yu(" ",e.isSaving()?"Saving\u2026":e.isAssociated()?"Update":"Associate"," "),EE(),Iw(e.isAssociated()?29:-1);}}var ge=["BearerTokenAuthSetting","BasicAuthAuthSetting","ApiKeyAuthSetting"],he={BearerTokenAuthSetting:"token",BasicAuthAuthSetting:"basic auth",ApiKeyAuthSetting:"API key"},ne=class i{route=g(W);gitApi=g(J);authSettingState=g(I);destroyRef=g(we);isLoading=Mi(true);isSaving=Mi(false);confirmingRemove=Mi(false);associationLoaded=Mi(false);errorMessage=Mi(null);association=Mi(null);authSettings=Mi([]);repositoryUrl=Mi("");mainBranch=Mi("main");serviceAuthSettingId=Mi("");autoWorktree=Mi(false);setupCommand=Mi("");namespaceId="";isAssociated=BC(()=>this.association()?.associated===true);eligibleAuthSettings=BC(()=>this.authSettings().filter(t=>ge.includes(t.authType)));authTypeLabel(t){return he[t??""]??t??"unknown"}canSave=BC(()=>this.associationLoaded()&&!this.isLoading()&&!this.isSaving()&&this.repositoryUrl().trim().length>0&&this.serviceAuthSettingId().length>0);checkoutStatus=BC(()=>this.association()?.checkoutStatus??null);CheckoutStatus=ke;ngOnInit(){this.namespaceId=this.route.snapshot.paramMap.get("namespaceId")??"",this.load();}retryLoad(){this.isLoading()||this.isSaving()||this.load();}load(){this.isLoading.set(true),this.associationLoaded.set(false),this.errorMessage.set(null),Gm({association:this.gitApi.getAssociationNamespaceGit(this.namespaceId),authSettings:this.authSettingState.loadNamespaceSettings(this.namespaceId)}).pipe(U(this.destroyRef)).subscribe({next:({association:t,authSettings:e})=>{this.authSettings.set(e??[]),this.acceptAssociation(t),this.isLoading.set(false);},error:t=>{console.error("Failed to load the Git repository settings",t),this.errorMessage.set(this.messageOf(t)),this.isLoading.set(false);}});}acceptAssociation(t){this.association.set(t);let e=t?.associated===false||t?.associated===true&&typeof t.repositoryUrl=="string"&&typeof t.mainBranch=="string"&&typeof t.serviceAuthSettingId=="string"&&typeof t.autoWorktreeForRootCases=="boolean"&&(t.setupCommand==null||typeof t.setupCommand=="string");this.associationLoaded.set(e),e?this.applyToForm(t):this.errorMessage.set("The repository settings could not be loaded completely. Retry before making changes.");}applyToForm(t){this.repositoryUrl.set(t.repositoryUrl??""),this.mainBranch.set(t.mainBranch??"main"),this.serviceAuthSettingId.set(t.serviceAuthSettingId??""),this.autoWorktree.set(t.autoWorktreeForRootCases??false),this.setupCommand.set(t.setupCommand??"");}save(){this.canSave()&&(this.isSaving.set(true),this.errorMessage.set(null),this.gitApi.setAssociationNamespaceGit(this.namespaceId,{repositoryUrl:this.repositoryUrl().trim(),mainBranch:this.mainBranch().trim()||void 0,serviceAuthSettingId:this.serviceAuthSettingId(),autoWorktreeForRootCases:this.autoWorktree(),setupCommand:this.setupCommand().trim()||void 0}).pipe(U(this.destroyRef),Zs(t=>(console.error("Failed to save the Git association",t),this.errorMessage.set(this.messageOf(t)),this.isSaving.set(false),Dr(null)))).subscribe(t=>{t&&this.acceptAssociation(t),this.isSaving.set(false);}));}remove(){!this.associationLoaded()||this.isLoading()||this.isSaving()||!this.isAssociated()||this.confirmingRemove.set(true);}confirmRemove(){this.confirmingRemove.set(false),!(!this.associationLoaded()||this.isLoading()||this.isSaving()||!this.isAssociated())&&(this.isSaving.set(true),this.gitApi.removeAssociationNamespaceGit(this.namespaceId).pipe(U(this.destroyRef),Zs(t=>(console.error("Failed to remove the Git association",t),this.errorMessage.set(this.messageOf(t)),this.isSaving.set(false),Dr(null)))).subscribe(t=>{t&&this.acceptAssociation(t),this.isSaving.set(false);}));}messageOf(t){return t.error?.message??t.message??"Unexpected error"}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JI({type:i,selectors:[["agentos-namespace-git"]],decls:5,vars:2,consts:[["title","Git repository","description","Associating a repository enables Git workspaces for this namespace. When worktree creation is enabled, the new-case form offers a worktree, and a case created with one gets a repo/ directory shared by its sub-cases. Namespace files remain shared documents outside Git. Agents create branches and pull requests in their workflows."],[1,"ds-hint"],["title","Remove the repository association?","message","Existing workspaces keep their worktree.","confirmLabel","Remove","cancelLabel","Cancel",3,"confirmed","cancelled","open"],[3,"tone"],["legend","Repository",3,"disabled"],["label","Repository URL","controlId","git-url","hint","HTTPS only, without credentials in the URL."],["dsControl","","id","git-url","type","url","placeholder","https://forge.example/org/project.git","name","repositoryUrl",3,"ngModelChange","ngModel"],["label","Main branch","controlId","git-branch","hint","New worktrees start at this branch\u2019s commit, without creating a branch."],["dsControl","","id","git-branch","type","text","placeholder","main","name","mainBranch",3,"ngModelChange","ngModel"],["label","Service account","controlId","git-auth","hint","Shared by the namespace. Every Git operation uses this identity, never the identity of whoever opened the case."],["dsControl","","id","git-auth","name","serviceAuthSettingId",3,"ngModelChange","ngModel"],["value",""],[3,"value"],[1,"ds-hint","ds-hint--warning"],["legend","Automation",3,"disabled"],[1,"ds-stack","ds-stack--sm"],["dsCheck",""],["type","checkbox","name","autoWorktree",3,"ngModelChange","ngModel"],[1,"ds-hint","ds-indent"],["label","Setup command (optional)","controlId","git-setup"],["dsControl","","mono","","id","git-setup","type","text","placeholder","pnpm install --ignore-scripts","name","setupCommand",3,"ngModelChange","ngModel"],["id","git-save","dsButton","","variant","primary","type","button",3,"click","disabled"],["id","git-remove","dsButton","","variant","danger","type","button",3,"disabled"],["id","git-retry","dsButton","","type","button",3,"click"],["id","git-remove","dsButton","","variant","danger","type","button",3,"click","disabled"]],template:function(e,c){e&1&&(os(0,"ds-page"),Hh(1,"ds-section-header",0),Ew(2,ae,2,0,"p",1)(3,ue,30,14),zu(),os(4,"ds-confirm-dialog",2),qh("confirmed",function(){return c.confirmRemove()})("cancelled",function(){return c.confirmingRemove.set(false)}),zu()),e&2&&(EE(2),Iw(c.isLoading()?2:3),EE(2),Vh("open",c.confirmingRemove()));},dependencies:[pd,Co,Mo,Ht,yn,Ut,po,fa,Ri,hn,fn,un,dn,cn,pn,at,sn,an],encapsulation:2})};
2
2
  export{ne as NamespaceGitComponent};
@@ -1,4 +1,4 @@
1
- import {b2 as A,b3 as z$1}from'./main-63IEQS3X.js';var ut=z$1(Xe=>{"use strict";(function(i){var n=/\S/,t=/\"/g,e=/\n/g,r=/\r/g,a=/\\/g,s=/\u2028/,u=/\u2029/;i.tags={"#":1,"^":2,"<":3,$:4,"/":5,"!":6,">":7,"=":8,_v:9,"{":10,"&":11,_t:12},i.scan=function(h,g){var S=h.length,U=0,R=1,q=2,E=U,$=null,ee=null,B="",I=[],J=!1,O=0,C=0,L="{{",b="}}";function te(){B.length>0&&(I.push({tag:"_t",text:new String(B)}),B="");}function ge(){for(var A=!0,k=C;k<I.length;k++)if(A=i.tags[I[k].tag]<i.tags._v||I[k].tag=="_t"&&I[k].text.match(n)===null,!A)return !1;return A}function be(A,k){if(te(),A&&ge())for(var _=C,ie;_<I.length;_++)I[_].text&&((ie=I[_+1])&&ie.tag==">"&&(ie.indent=I[_].text.toString()),I.splice(_,1));else k||I.push({tag:`
1
+ import {b2 as A,b3 as z$1}from'./main-B6UJJXO7.js';var ut=z$1(Xe=>{"use strict";(function(i){var n=/\S/,t=/\"/g,e=/\n/g,r=/\r/g,a=/\\/g,s=/\u2028/,u=/\u2029/;i.tags={"#":1,"^":2,"<":3,$:4,"/":5,"!":6,">":7,"=":8,_v:9,"{":10,"&":11,_t:12},i.scan=function(h,g){var S=h.length,U=0,R=1,q=2,E=U,$=null,ee=null,B="",I=[],J=!1,O=0,C=0,L="{{",b="}}";function te(){B.length>0&&(I.push({tag:"_t",text:new String(B)}),B="");}function ge(){for(var A=!0,k=C;k<I.length;k++)if(A=i.tags[I[k].tag]<i.tags._v||I[k].tag=="_t"&&I[k].text.match(n)===null,!A)return !1;return A}function be(A,k){if(te(),A&&ge())for(var _=C,ie;_<I.length;_++)I[_].text&&((ie=I[_+1])&&ie.tag==">"&&(ie.indent=I[_].text.toString()),I.splice(_,1));else k||I.push({tag:`
2
2
  `});J=!1,C=I.length;}function ne(A,k){var _="="+b,ie=A.indexOf(_,k),De=f(A.substring(A.indexOf("=",k)+1,ie)).split(" ");return L=De[0],b=De[De.length-1],ie+_.length-1}for(g&&(g=g.split(" "),L=g[0],b=g[1]),O=0;O<S;O++)E==U?v(L,h,O)?(--O,te(),E=R):h.charAt(O)==`
3
3
  `?be(J):B+=h.charAt(O):E==R?(O+=L.length-1,ee=i.tags[h.charAt(O+1)],$=ee?h.charAt(O+1):"_v",$=="="?(O=ne(h,O),E=U):(ee&&O++,E=q),J=O):v(b,h,O)?(I.push({tag:$,n:f(B),otag:L,ctag:b,i:$=="/"?J-L.length:O+b.length}),B="",O+=b.length-1,E=U,$=="{"&&(b=="}}"?O++:d(I[I.length-1]))):B+=h.charAt(O);return be(J,!0),I};function d(l){l.n.substr(l.n.length-1)==="}"&&(l.n=l.n.substring(0,l.n.length-1));}function f(l){return l.trim?l.trim():l.replace(/^\s*|\s*$/g,"")}function v(l,h,g){if(h.charAt(g)!=l.charAt(0))return !1;for(var S=1,U=l.length;S<U;S++)if(h.charAt(g+S)!=l.charAt(S))return !1;return !0}var y={_t:!0,"\n":!0,$:!0,"/":!0};function o(l,h,g,S){var U=[],R=null,q=null,E=null;for(q=g[g.length-1];l.length>0;){if(E=l.shift(),q&&q.tag=="<"&&!(E.tag in y))throw new Error("Illegal content in < super tag.");if(i.tags[E.tag]<=i.tags.$||c(E,S))g.push(E),E.nodes=o(l,E.tag,g,S);else if(E.tag=="/"){if(g.length===0)throw new Error("Closing tag without opener: /"+E.n);if(R=g.pop(),E.n!=R.n&&!m(E.n,R.n,S))throw new Error("Nesting error: "+R.n+" vs. "+E.n);return R.end=E.i,U}else E.tag==`
4
4
  `&&(E.last=l.length==0||l[0].tag==`
@@ -1 +1 @@
1
- import {g as g$1,aH as se,aa as k}from'./main-63IEQS3X.js';var g=class r{botController=g$1(se);agentBots(t,e){return this.botController.listAgentMessagingBots(t,e)}attach(t,e,s,i,l){return this.botController.attachMessagingBot(t,e,{platform:s,token:i,appToken:l})}manifest(t,e,s){return this.botController.getMessagingBotAppManifest(t,e,s)}requestCreation(t,e,s){return this.botController.requestMessagingBotCreation(t,e,{platform:s})}setEnabled(t,e){return this.botController.updateMessagingBot(t,{enabled:e})}remove(t){return this.botController.deleteMessagingBot(t)}managers(){return this.botController.listMessagingBotManagers()}setManager(t,e){return this.botController.setMessagingBotManager({platform:t,token:e})}removeManager(t){return this.botController.deleteMessagingBotManager(t)}static \u0275fac=function(e){return new(e||r)};static \u0275prov=k({token:r,factory:r.\u0275fac,providedIn:"root"})};export{g};
1
+ import {g as g$1,aH as ie,aa as k}from'./main-B6UJJXO7.js';var g=class r{botController=g$1(ie);agentBots(t,e){return this.botController.listAgentMessagingBots(t,e)}attach(t,e,s,i,l){return this.botController.attachMessagingBot(t,e,{platform:s,token:i,appToken:l})}manifest(t,e,s){return this.botController.getMessagingBotAppManifest(t,e,s)}requestCreation(t,e,s){return this.botController.requestMessagingBotCreation(t,e,{platform:s})}setEnabled(t,e){return this.botController.updateMessagingBot(t,{enabled:e})}remove(t){return this.botController.deleteMessagingBot(t)}managers(){return this.botController.listMessagingBotManagers()}setManager(t,e){return this.botController.setMessagingBotManager({platform:t,token:e})}removeManager(t){return this.botController.deleteMessagingBotManager(t)}static \u0275fac=function(e){return new(e||r)};static \u0275prov=k({token:r,factory:r.\u0275fac,providedIn:"root"})};export{g};
@@ -1 +1 @@
1
- import {I as I$1}from'./chunk-DQEn5_2f.js';import {g,F,w as we,a3 as vr,M as Mi,a5 as Ys,x as U$1,J as JI,o as os,Q as qh,z as zu,f as fC,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,l as lg,i as bw,T as Tw,Y as Yu,n as Aw,d as Bh,q as Pd,L as Ld}from'./main-63IEQS3X.js';import {B as k,k as O$1,e as at,c as fn,l as ko,P,D as P$1}from'./chunk-CCZ1b0na.js';import'./chunk-CVAz4Lko.js';var B=(e,t)=>t.id??t.name;function j(e,t){if(e&1&&(os(0,"p",3),fC(1),zu()),e&2){let n=Pw();EE(),lg(n.deletion.error());}}function K(e,t){e&1&&(os(0,"p",4),fC(1,"Loading auth settings\u2026"),zu());}function H(e,t){e&1&&(os(0,"p",5),fC(1,"No platform auth settings defined yet."),zu());}function U(e,t){e&1&&(os(0,"p",4),fC(1,"No auth settings match the current filter."),zu());}function z(e,t){if(e&1){let n=Aw();os(0,"button",18),qh("click",function(){Pd(n);let d=Pw().$implicit,m=Pw(2);return Ld(m.onEdit(d))}),fC(1," Edit "),zu();}if(e&2){let n=Pw().$implicit;Bh("aria-label","Edit "+n.name);}}function G(e,t){if(e&1){let n=Aw();os(0,"agentos-row-delete-action",19),qh("deleteRequested",function(){Pd(n);let d=Pw().$implicit,m=Pw(2);return Ld(m.deletion.request(d.id))})("deleteConfirmed",function(){Pd(n);let d=Pw().$implicit,m=Pw(2);return Ld(m.onDelete(d))})("deleteCancelled",function(){Pd(n);let d=Pw(3);return Ld(d.deletion.cancel())}),zu();}if(e&2){let n=Pw().$implicit,a=Pw(2);Vh("rowKey",n.id)("rowLabel",n.name)("state",a.deletion);}}function J(e,t){if(e&1&&(os(0,"tr",9)(1,"td",12),fC(2),zu(),os(3,"td",13),fC(4),zu(),os(5,"td",14)(6,"div",15),Ew(7,z,2,1,"button",16),Ew(8,G,1,3,"agentos-row-delete-action",17),zu()()()),e&2){let n=t.$implicit,a=Pw(2);EE(2),lg(n.name),EE(2),Yu(" ",n.authType," "),EE(3),Iw(a.deletion.confirmingId()!==n.id?7:-1),EE(),Iw(n.id?8:-1);}}function O(e,t){if(e&1&&(os(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),fC(5,"Name"),zu(),os(6,"th",10),fC(7,"Authentication type"),zu(),os(8,"th",10)(9,"span",11),fC(10,"Actions"),zu()()()(),os(11,"tbody",8),bw(12,J,9,4,"tr",9,B),zu()()()),e&2){let n=Pw();EE(12),Tw(n.rowFilter.filteredRows());}}var I=class e{router=g(F);destroyRef=g(we);state=g(I$1);refresh$=new vr(void 0);isLoading=Mi(true);deletion=k();settings=Mi([]);rowFilter=O$1(this.settings,t=>[t.name,t.authType].filter(Boolean).join(" "));constructor(){this.refresh$.pipe(Ys(()=>(this.isLoading.set(true),this.state.loadPlatformSettings())),U$1(this.destroyRef)).subscribe({next:t=>{this.settings.set(t),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos","admin","auth-settings","new"]);}onEdit(t){t.id&&this.router.navigate(["/agentos","admin","auth-settings",t.id,"edit"]);}onDelete(t){t.id&&this.deletion.execute(t.id,{request$:this.state.delete(t.id,"platform").pipe(U$1(this.destroyRef)),onSuccess:()=>this.refresh$.next(),errorMessage:`Deleting "${t.name}" failed. Try again.`});}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=JI({type:e,selectors:[["agentos-platform-auth-settings"]],decls:9,vars:3,consts:[["title","Platform auth settings","description","Authentication settings shared across every namespace."],["label","Filter auth settings","placeholder","Filter auth settings\u2026",3,"queryChange","query"],["dsButton","","variant","primary","type","button",3,"click"],["role","alert",1,"settings-table__error"],["role","status",1,"settings-table__status"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table","aria-label","Platform auth settings"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title","",1,"settings-table__name"],["role","cell","data-label","Authentication type",1,"settings-table__secondary"],["role","cell","data-label","Actions","data-actions",""],[1,"settings-table__actions"],["type","button"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"rowKey","rowLabel","state"],["type","button",3,"click"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"]],template:function(n,a){n&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(m){return a.rowFilter.query.set(m)}),zu(),os(2,"button",2),qh("click",function(){return a.openCreateForm()}),fC(3,"New auth setting"),zu()(),Ew(4,j,2,1,"p",3),Ew(5,K,2,0,"p",4)(6,H,2,0,"p",5)(7,U,2,0,"p",4)(8,O,14,0,"div",6)),n&2&&(EE(),Vh("query",a.rowFilter.query()),EE(3),Iw(a.deletion.error()?4:-1),EE(),Iw(a.isLoading()?5:a.settings().length===0?6:a.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,P,P$1],encapsulation:2})};export{I as PlatformAuthSettingsComponent};
1
+ import {I as I$1}from'./chunk-Cq9jD9x7.js';import {g,F,w as we,a3 as vr,M as Mi,a5 as Ys,x as U$1,J as JI,o as os,Q as qh,z as zu,f as fC,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,l as lg,i as bw,T as Tw,Y as Yu,n as Aw,d as Bh,q as Pd,L as Ld}from'./main-B6UJJXO7.js';import {B as k,k as O$1,e as at,c as fn,l as ko,P,D as P$1}from'./chunk-COmLfT0N.js';import'./chunk-DxIOAne_.js';var B=(e,t)=>t.id??t.name;function j(e,t){if(e&1&&(os(0,"p",3),fC(1),zu()),e&2){let n=Pw();EE(),lg(n.deletion.error());}}function K(e,t){e&1&&(os(0,"p",4),fC(1,"Loading auth settings\u2026"),zu());}function H(e,t){e&1&&(os(0,"p",5),fC(1,"No platform auth settings defined yet."),zu());}function U(e,t){e&1&&(os(0,"p",4),fC(1,"No auth settings match the current filter."),zu());}function z(e,t){if(e&1){let n=Aw();os(0,"button",18),qh("click",function(){Pd(n);let d=Pw().$implicit,m=Pw(2);return Ld(m.onEdit(d))}),fC(1," Edit "),zu();}if(e&2){let n=Pw().$implicit;Bh("aria-label","Edit "+n.name);}}function G(e,t){if(e&1){let n=Aw();os(0,"agentos-row-delete-action",19),qh("deleteRequested",function(){Pd(n);let d=Pw().$implicit,m=Pw(2);return Ld(m.deletion.request(d.id))})("deleteConfirmed",function(){Pd(n);let d=Pw().$implicit,m=Pw(2);return Ld(m.onDelete(d))})("deleteCancelled",function(){Pd(n);let d=Pw(3);return Ld(d.deletion.cancel())}),zu();}if(e&2){let n=Pw().$implicit,a=Pw(2);Vh("rowKey",n.id)("rowLabel",n.name)("state",a.deletion);}}function J(e,t){if(e&1&&(os(0,"tr",9)(1,"td",12),fC(2),zu(),os(3,"td",13),fC(4),zu(),os(5,"td",14)(6,"div",15),Ew(7,z,2,1,"button",16),Ew(8,G,1,3,"agentos-row-delete-action",17),zu()()()),e&2){let n=t.$implicit,a=Pw(2);EE(2),lg(n.name),EE(2),Yu(" ",n.authType," "),EE(3),Iw(a.deletion.confirmingId()!==n.id?7:-1),EE(),Iw(n.id?8:-1);}}function O(e,t){if(e&1&&(os(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),fC(5,"Name"),zu(),os(6,"th",10),fC(7,"Authentication type"),zu(),os(8,"th",10)(9,"span",11),fC(10,"Actions"),zu()()()(),os(11,"tbody",8),bw(12,J,9,4,"tr",9,B),zu()()()),e&2){let n=Pw();EE(12),Tw(n.rowFilter.filteredRows());}}var I=class e{router=g(F);destroyRef=g(we);state=g(I$1);refresh$=new vr(void 0);isLoading=Mi(true);deletion=k();settings=Mi([]);rowFilter=O$1(this.settings,t=>[t.name,t.authType].filter(Boolean).join(" "));constructor(){this.refresh$.pipe(Ys(()=>(this.isLoading.set(true),this.state.loadPlatformSettings())),U$1(this.destroyRef)).subscribe({next:t=>{this.settings.set(t),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos","admin","auth-settings","new"]);}onEdit(t){t.id&&this.router.navigate(["/agentos","admin","auth-settings",t.id,"edit"]);}onDelete(t){t.id&&this.deletion.execute(t.id,{request$:this.state.delete(t.id,"platform").pipe(U$1(this.destroyRef)),onSuccess:()=>this.refresh$.next(),errorMessage:`Deleting "${t.name}" failed. Try again.`});}static \u0275fac=function(n){return new(n||e)};static \u0275cmp=JI({type:e,selectors:[["agentos-platform-auth-settings"]],decls:9,vars:3,consts:[["title","Platform auth settings","description","Authentication settings shared across every namespace."],["label","Filter auth settings","placeholder","Filter auth settings\u2026",3,"queryChange","query"],["dsButton","","variant","primary","type","button",3,"click"],["role","alert",1,"settings-table__error"],["role","status",1,"settings-table__status"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table","aria-label","Platform auth settings"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title","",1,"settings-table__name"],["role","cell","data-label","Authentication type",1,"settings-table__secondary"],["role","cell","data-label","Actions","data-actions",""],[1,"settings-table__actions"],["type","button"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"rowKey","rowLabel","state"],["type","button",3,"click"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"]],template:function(n,a){n&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(m){return a.rowFilter.query.set(m)}),zu(),os(2,"button",2),qh("click",function(){return a.openCreateForm()}),fC(3,"New auth setting"),zu()(),Ew(4,j,2,1,"p",3),Ew(5,K,2,0,"p",4)(6,H,2,0,"p",5)(7,U,2,0,"p",4)(8,O,14,0,"div",6)),n&2&&(EE(),Vh("query",a.rowFilter.query()),EE(3),Iw(a.deletion.error()?4:-1),EE(),Iw(a.isLoading()?5:a.settings().length===0?6:a.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,P,P$1],encapsulation:2})};export{I as PlatformAuthSettingsComponent};
@@ -1 +1 @@
1
- import {g,aQ as ue,aa as k}from'./main-63IEQS3X.js';var c=class r{api=g(ue);getById(e){return this.api.getByIdScheduledPrompt(e)}listPlatform(){return this.api.searchScheduledPrompt({namespaceId:null,userId:null})}listByNamespace(e){return this.api.searchScheduledPrompt({namespaceId:e,userId:null})}search(e){return this.api.searchScheduledPrompt(e)}listEffective(e){return this.api.resolveEffectiveScheduledPrompt(e)}create(e){return this.api.createScheduledPrompt(e)}update(e,t){return this.api.updateScheduledPrompt(e,t)}enable(e){return this.api.enableScheduledPrompt(e)}disable(e){return this.api.disableScheduledPrompt(e)}delete(e){return this.api.deleteScheduledPrompt(e)}static \u0275fac=function(t){return new(t||r)};static \u0275prov=k({token:r,factory:r.\u0275fac,providedIn:"root"})};export{c};
1
+ import {g,aQ as he,aa as k}from'./main-B6UJJXO7.js';var c=class r{api=g(he);getById(e){return this.api.getByIdScheduledPrompt(e)}listPlatform(){return this.api.searchScheduledPrompt({namespaceId:null,userId:null})}listByNamespace(e){return this.api.searchScheduledPrompt({namespaceId:e,userId:null})}search(e){return this.api.searchScheduledPrompt(e)}listEffective(e){return this.api.resolveEffectiveScheduledPrompt(e)}create(e){return this.api.createScheduledPrompt(e)}update(e,t){return this.api.updateScheduledPrompt(e,t)}enable(e){return this.api.enableScheduledPrompt(e)}disable(e){return this.api.disableScheduledPrompt(e)}delete(e){return this.api.deleteScheduledPrompt(e)}static \u0275fac=function(t){return new(t||r)};static \u0275prov=k({token:r,factory:r.\u0275fac,providedIn:"root"})};export{c};
@@ -1 +1 @@
1
- import {i}from'./chunk-CVAz4Lko.js';import {y}from'./chunk-CCZ1b0na.js';import {g,aj as G,aP as je,a3 as vr,aw as $m,a5 as Ys,a6 as Zs,ae as Dr,ah as te,aK as my,a9 as Hl,aa as k}from'./main-63IEQS3X.js';var u=s=>s,N="none",w="me",O=class s{nsController=g(G);exportService=g(je);userState=g(y);refresh$=new vr(void 0);namespaceId$=new vr(null);vm$=$m([this.namespaceId$,this.refresh$]).pipe(Ys(([e])=>{let n=this.loadPlatformConfigs().pipe(Zs(()=>Dr([]))),t=this.loadUserConfigs("global").pipe(Zs(()=>Dr([])));return e?$m([n,this.loadNamespaceConfigs(e).pipe(Zs(()=>Dr([]))),this.loadUserConfigs(e).pipe(Zs(()=>Dr([]))),t]).pipe(te(([i,r,c,g])=>({platform:i,namespace:r,userOnNs:c,userGlobal:g}))):$m([n,t]).pipe(te(([i,r])=>({platform:i,namespace:[],userOnNs:[],userGlobal:r})))}),my({bufferSize:1,refCount:true}));setNamespace(e){this.namespaceId$.value!==e&&this.namespaceId$.next(e);}refresh(){this.refresh$.next();}loadPlatformConfigs(){return this.nsController.listIntegrationConfig(N)}loadUserConfigs(e){let n=e==="global"?N:e;return this.nsController.listIntegrationConfig(n,w)}userGlobal$=i(this.refresh$,()=>this.loadUserConfigs("global"),[]);loadNamespaceConfigs(e){return e?this.nsController.listIntegrationConfig(e):Dr([])}getById(e,n){return this.nsController.getByIdIntegrationConfig(e)}create(e,n,t){let r=this.userState.currentUser()?.id;if((n==="userOnNs"||n==="userGlobal")&&!r)throw new Error(`Cannot create ${n} config before UserStateService.loadMe() resolves \u2014 call loadMe() at app init`);if(n==="platform"){let g={name:e.name,integrationType:e.integrationType,description:e.description,parameters:e.parameters,authSettingName:e.authSettingName??void 0,autoGrant:e.autoGrant??false};return this.nsController.createIntegrationConfig(u(g)).pipe(Hl(()=>this.refresh()))}if(n==="namespace"){if(!t)throw new Error("Cannot create namespace-scoped config without a namespaceId");let g={name:e.name,integrationType:e.integrationType,description:e.description,namespaceId:t,parameters:e.parameters,authSettingName:e.authSettingName??void 0,autoGrant:e.autoGrant??false};return this.nsController.createIntegrationConfig(u(g)).pipe(Hl(()=>this.refresh()))}if(n==="userOnNs"&&!t)throw new Error("Cannot create userOnNs config without a namespaceId");let c={name:e.name,integrationType:e.integrationType,description:e.description,userId:r,namespaceId:n==="userOnNs"?t:void 0,parameters:e.parameters,authSettingName:e.authSettingName??void 0,autoGrant:e.autoGrant??false};return this.nsController.createIntegrationConfig(u(c)).pipe(Hl(()=>this.refresh()))}update(e,n,t,i){let r={name:n.name,integrationType:n.integrationType,description:n.description,userId:i.userId,namespaceId:i.namespaceId,parameters:n.parameters,authSettingName:n.authSettingName??void 0,autoGrant:n.autoGrant??false};return this.nsController.updateIntegrationConfig(e,u(r)).pipe(Hl(()=>this.refresh()))}delete(e,n){return this.nsController.deleteIntegrationConfig(e).pipe(Hl(()=>this.refresh()))}exportAsYaml(e){return this.exportService.exportAsYaml(e)}static \u0275fac=function(n){return new(n||s)};static \u0275prov=k({token:s,factory:s.\u0275fac,providedIn:"root"})};export{O};
1
+ import {i}from'./chunk-DxIOAne_.js';import {y}from'./chunk-COmLfT0N.js';import {g,aj as G,aP as we,a3 as vr,aw as $m,a5 as Ys,a6 as Zs,ae as Dr,ah as te,aK as my,a9 as Hl,aa as k}from'./main-B6UJJXO7.js';var u=s=>s,N="none",w="me",O=class s{nsController=g(G);exportService=g(we);userState=g(y);refresh$=new vr(void 0);namespaceId$=new vr(null);vm$=$m([this.namespaceId$,this.refresh$]).pipe(Ys(([e])=>{let n=this.loadPlatformConfigs().pipe(Zs(()=>Dr([]))),t=this.loadUserConfigs("global").pipe(Zs(()=>Dr([])));return e?$m([n,this.loadNamespaceConfigs(e).pipe(Zs(()=>Dr([]))),this.loadUserConfigs(e).pipe(Zs(()=>Dr([]))),t]).pipe(te(([i,r,c,g])=>({platform:i,namespace:r,userOnNs:c,userGlobal:g}))):$m([n,t]).pipe(te(([i,r])=>({platform:i,namespace:[],userOnNs:[],userGlobal:r})))}),my({bufferSize:1,refCount:true}));setNamespace(e){this.namespaceId$.value!==e&&this.namespaceId$.next(e);}refresh(){this.refresh$.next();}loadPlatformConfigs(){return this.nsController.listIntegrationConfig(N)}loadUserConfigs(e){let n=e==="global"?N:e;return this.nsController.listIntegrationConfig(n,w)}userGlobal$=i(this.refresh$,()=>this.loadUserConfigs("global"),[]);loadNamespaceConfigs(e){return e?this.nsController.listIntegrationConfig(e):Dr([])}getById(e,n){return this.nsController.getByIdIntegrationConfig(e)}create(e,n,t){let r=this.userState.currentUser()?.id;if((n==="userOnNs"||n==="userGlobal")&&!r)throw new Error(`Cannot create ${n} config before UserStateService.loadMe() resolves \u2014 call loadMe() at app init`);if(n==="platform"){let g={name:e.name,integrationType:e.integrationType,description:e.description,parameters:e.parameters,authSettingName:e.authSettingName??void 0,autoGrant:e.autoGrant??false};return this.nsController.createIntegrationConfig(u(g)).pipe(Hl(()=>this.refresh()))}if(n==="namespace"){if(!t)throw new Error("Cannot create namespace-scoped config without a namespaceId");let g={name:e.name,integrationType:e.integrationType,description:e.description,namespaceId:t,parameters:e.parameters,authSettingName:e.authSettingName??void 0,autoGrant:e.autoGrant??false};return this.nsController.createIntegrationConfig(u(g)).pipe(Hl(()=>this.refresh()))}if(n==="userOnNs"&&!t)throw new Error("Cannot create userOnNs config without a namespaceId");let c={name:e.name,integrationType:e.integrationType,description:e.description,userId:r,namespaceId:n==="userOnNs"?t:void 0,parameters:e.parameters,authSettingName:e.authSettingName??void 0,autoGrant:e.autoGrant??false};return this.nsController.createIntegrationConfig(u(c)).pipe(Hl(()=>this.refresh()))}update(e,n,t,i){let r={name:n.name,integrationType:n.integrationType,description:n.description,userId:i.userId,namespaceId:i.namespaceId,parameters:n.parameters,authSettingName:n.authSettingName??void 0,autoGrant:n.autoGrant??false};return this.nsController.updateIntegrationConfig(e,u(r)).pipe(Hl(()=>this.refresh()))}delete(e,n){return this.nsController.deleteIntegrationConfig(e).pipe(Hl(()=>this.refresh()))}exportAsYaml(e){return this.exportService.exportAsYaml(e)}static \u0275fac=function(n){return new(n||s)};static \u0275prov=k({token:s,factory:s.\u0275fac,providedIn:"root"})};export{O};
@@ -1 +1 @@
1
- import {B as k$1,k as O,e as at,c as fn,l as ko,n as Fo,P,D as P$1}from'./chunk-CCZ1b0na.js';import {g,W as W$1,F,w as we,au as k,at as F$1,a3 as vr,M as Mi,a5 as Ys,ag as Gm,a6 as Zs,ae as Dr,x as U,J as JI,o as os,Q as qh,z as zu,f as fC,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,l as lg,i as bw,T as Tw,Y as Yu,n as Aw,q as Pd,L as Ld,d as Bh}from'./main-63IEQS3X.js';var G=(i,e)=>e.key;function Q(i,e){if(i&1&&(os(0,"p",3),fC(1),zu()),i&2){let t=Pw();EE(),lg(t.deletion.error());}}function W(i,e){i&1&&(os(0,"p",4),fC(1,"Loading AI models\u2026"),zu());}function X(i,e){i&1&&(os(0,"p",5),fC(1,"No AI models configured."),zu());}function Y(i,e){i&1&&(os(0,"p",4),fC(1,"No AI models match the current filter."),zu());}function Z(i,e){i&1&&(os(0,"ds-tag",18),fC(1,"Read-only"),zu());}function ee(i,e){if(i&1){let t=Aw();os(0,"button",24),qh("click",function(){Pd(t);let s=Pw(2).$implicit,m=Pw(2);return Ld(m.edit(s))}),fC(1,"Edit"),zu();}if(i&2){let t=Pw(2).$implicit,n=Pw(2);Bh("aria-label","Edit "+n.title(t));}}function te(i,e){if(i&1){let t=Aw();Ew(0,ee,2,1,"button",22),os(1,"agentos-row-delete-action",23),qh("deleteRequested",function(){Pd(t);let s=Pw().$implicit,m=Pw(2);return Ld(m.deletion.request(s.key))})("deleteConfirmed",function(){Pd(t);let s=Pw().$implicit,m=Pw(2);return Ld(m.confirmDelete(s))})("deleteCancelled",function(){Pd(t);let s=Pw(3);return Ld(s.deletion.cancel())}),zu();}if(i&2){let t=Pw().$implicit,n=Pw(2);Iw(n.deletion.confirmingId()!==t.key?0:-1),EE(),Vh("rowKey",t.key)("rowLabel",n.title(t))("state",n.deletion);}}function ie(i,e){i&1&&(os(0,"button",21),fC(1,"Inherited"),zu());}function ne(i,e){if(i&1&&(os(0,"tr",9)(1,"td",12),fC(2),zu(),os(3,"td",13),fC(4),zu(),os(5,"td",14),fC(6),zu(),os(7,"td",15)(8,"div",16)(9,"ds-tag",17),fC(10),zu(),Ew(11,Z,2,0,"ds-tag",18),zu()(),os(12,"td",19)(13,"div",20),Ew(14,te,2,4)(15,ie,2,0,"button",21),zu()()()),i&2){let t=e.$implicit,n=Pw(2);EE(2),lg(n.title(t)),EE(2),lg(t.providerName),EE(2),Yu(" ",t.model.apiModelName," "),EE(3),Vh("variant",t.scope==="platform"?"neutral":"accent"),EE(),lg(t.scope==="platform"?"Platform":"Namespace"),EE(),Iw(t.scope==="platform"?11:-1),EE(3),Iw(t.scope==="namespace"?14:15);}}function oe(i,e){if(i&1&&(os(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),fC(5,"Name"),zu(),os(6,"th",10),fC(7,"Provider"),zu(),os(8,"th",10),fC(9,"API model name"),zu(),os(10,"th",10),fC(11,"Scope"),zu(),os(12,"th",10)(13,"span",11),fC(14,"Actions"),zu()()()(),os(15,"tbody",8),bw(16,ne,16,7,"tr",9,G),zu()()()),i&2){let t=Pw();EE(16),Tw(t.rowFilter.filteredRows());}}var z=class i{route=g(W$1);router=g(F);destroyRef=g(we);aiModelController=g(k);aiProviderController=g(F$1);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new vr(void 0);isLoading=Mi(true);deletion=k$1();rows=Mi([]);rowFilter=O(this.rows,e=>[e.model.alias,e.model.apiModelName,e.providerName,e.scope].filter(Boolean).join(" "));data$=this.refresh$.pipe(Ys(()=>(this.isLoading.set(true),Gm({namespace:this.aiModelController.listByNamespaceIdAiModel(this.namespaceId),platform:this.aiModelController.listPlatformLevelAiModel().pipe(Zs(()=>Dr([]))),providers:this.aiProviderController.listAiProvider(this.namespaceId)}).pipe(Ys(({namespace:e,platform:t,providers:n})=>{let s=[...new Set([...t,...e].map(m=>m.aiProviderId))];return Gm({namespace:Dr(e),platform:Dr(t),providers:Dr(n),referencedProviders:this.aiProviderController.getByIdsAiProvider({ids:s,withRemoved:false}).pipe(Zs(()=>Dr([])))})})))));constructor(){this.data$.pipe(U(this.destroyRef)).subscribe({next:({namespace:e,platform:t,providers:n,referencedProviders:s})=>{let m=new Map([...s,...n].map(c=>[c.id??"",c.name]));this.rows.set([...t.map((c,g)=>({key:`platform:${c.id??g}`,model:c,providerName:m.get(c.aiProviderId)??c.aiProviderId,scope:"platform"})),...e.map((c,g)=>({key:`namespace:${c.id??g}`,model:c,providerName:m.get(c.aiProviderId)??c.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"]);}title(e){return e.model.alias??e.model.apiModelName}confirmDelete(e){e.scope==="platform"||!e.model.id||this.deletion.execute(e.key,{request$:this.aiModelController.deleteAiModel(e.model.id).pipe(U(this.destroyRef)),onSuccess:()=>this.refresh$.next(),errorMessage:`Deleting "${this.title(e)}" failed. Try again.`});}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=JI({type:i,selectors:[["agentos-namespace-ai-models"]],decls:9,vars:3,consts:[["title","AI models","description","AI models configured for this namespace, including models inherited from the platform."],["label","Filter AI models","placeholder","Filter AI models\u2026",3,"queryChange","query"],["dsButton","","variant","primary","type","button",3,"click"],["role","alert",1,"settings-table__error"],["role","status",1,"settings-table__status"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table","aria-label","AI models"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title","",1,"settings-table__name"],["role","cell","data-label","Provider"],["role","cell","data-label","API model name",1,"settings-table__secondary"],["role","cell","data-label","Scope"],[1,"settings-table__tags"],[3,"variant"],["variant","outline"],["role","cell","data-label","Actions","data-actions",""],[1,"settings-table__actions"],["type","button","disabled",""],["type","button"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"],["type","button",3,"click"]],template:function(t,n){t&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(m){return n.rowFilter.query.set(m)}),zu(),os(2,"button",2),qh("click",function(){return n.openCreateForm()}),fC(3,"New AI model"),zu()(),Ew(4,Q,2,1,"p",3),Ew(5,W,2,0,"p",4)(6,X,2,0,"p",5)(7,Y,2,0,"p",4)(8,oe,18,0,"div",6)),t&2&&(EE(),Vh("query",n.rowFilter.query()),EE(3),Iw(n.deletion.error()?4:-1),EE(),Iw(n.isLoading()?5:n.rows().length===0?6:n.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,Fo,P,P$1],encapsulation:2})};export{z as NamespaceAiModelsComponent};
1
+ import {B as k$1,k as O,e as at,c as fn,l as ko,n as Fo,P,D as P$1}from'./chunk-COmLfT0N.js';import {g,W as W$1,F,w as we,au as k,at as F$1,a3 as vr,M as Mi,a5 as Ys,ag as Gm,a6 as Zs,ae as Dr,x as U,J as JI,o as os,Q as qh,z as zu,f as fC,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,l as lg,i as bw,T as Tw,Y as Yu,n as Aw,q as Pd,L as Ld,d as Bh}from'./main-B6UJJXO7.js';var G=(i,e)=>e.key;function Q(i,e){if(i&1&&(os(0,"p",3),fC(1),zu()),i&2){let t=Pw();EE(),lg(t.deletion.error());}}function W(i,e){i&1&&(os(0,"p",4),fC(1,"Loading AI models\u2026"),zu());}function X(i,e){i&1&&(os(0,"p",5),fC(1,"No AI models configured."),zu());}function Y(i,e){i&1&&(os(0,"p",4),fC(1,"No AI models match the current filter."),zu());}function Z(i,e){i&1&&(os(0,"ds-tag",18),fC(1,"Read-only"),zu());}function ee(i,e){if(i&1){let t=Aw();os(0,"button",24),qh("click",function(){Pd(t);let s=Pw(2).$implicit,m=Pw(2);return Ld(m.edit(s))}),fC(1,"Edit"),zu();}if(i&2){let t=Pw(2).$implicit,n=Pw(2);Bh("aria-label","Edit "+n.title(t));}}function te(i,e){if(i&1){let t=Aw();Ew(0,ee,2,1,"button",22),os(1,"agentos-row-delete-action",23),qh("deleteRequested",function(){Pd(t);let s=Pw().$implicit,m=Pw(2);return Ld(m.deletion.request(s.key))})("deleteConfirmed",function(){Pd(t);let s=Pw().$implicit,m=Pw(2);return Ld(m.confirmDelete(s))})("deleteCancelled",function(){Pd(t);let s=Pw(3);return Ld(s.deletion.cancel())}),zu();}if(i&2){let t=Pw().$implicit,n=Pw(2);Iw(n.deletion.confirmingId()!==t.key?0:-1),EE(),Vh("rowKey",t.key)("rowLabel",n.title(t))("state",n.deletion);}}function ie(i,e){i&1&&(os(0,"button",21),fC(1,"Inherited"),zu());}function ne(i,e){if(i&1&&(os(0,"tr",9)(1,"td",12),fC(2),zu(),os(3,"td",13),fC(4),zu(),os(5,"td",14),fC(6),zu(),os(7,"td",15)(8,"div",16)(9,"ds-tag",17),fC(10),zu(),Ew(11,Z,2,0,"ds-tag",18),zu()(),os(12,"td",19)(13,"div",20),Ew(14,te,2,4)(15,ie,2,0,"button",21),zu()()()),i&2){let t=e.$implicit,n=Pw(2);EE(2),lg(n.title(t)),EE(2),lg(t.providerName),EE(2),Yu(" ",t.model.apiModelName," "),EE(3),Vh("variant",t.scope==="platform"?"neutral":"accent"),EE(),lg(t.scope==="platform"?"Platform":"Namespace"),EE(),Iw(t.scope==="platform"?11:-1),EE(3),Iw(t.scope==="namespace"?14:15);}}function oe(i,e){if(i&1&&(os(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),fC(5,"Name"),zu(),os(6,"th",10),fC(7,"Provider"),zu(),os(8,"th",10),fC(9,"API model name"),zu(),os(10,"th",10),fC(11,"Scope"),zu(),os(12,"th",10)(13,"span",11),fC(14,"Actions"),zu()()()(),os(15,"tbody",8),bw(16,ne,16,7,"tr",9,G),zu()()()),i&2){let t=Pw();EE(16),Tw(t.rowFilter.filteredRows());}}var z=class i{route=g(W$1);router=g(F);destroyRef=g(we);aiModelController=g(k);aiProviderController=g(F$1);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new vr(void 0);isLoading=Mi(true);deletion=k$1();rows=Mi([]);rowFilter=O(this.rows,e=>[e.model.alias,e.model.apiModelName,e.providerName,e.scope].filter(Boolean).join(" "));data$=this.refresh$.pipe(Ys(()=>(this.isLoading.set(true),Gm({namespace:this.aiModelController.listByNamespaceIdAiModel(this.namespaceId),platform:this.aiModelController.listPlatformLevelAiModel().pipe(Zs(()=>Dr([]))),providers:this.aiProviderController.listAiProvider(this.namespaceId)}).pipe(Ys(({namespace:e,platform:t,providers:n})=>{let s=[...new Set([...t,...e].map(m=>m.aiProviderId))];return Gm({namespace:Dr(e),platform:Dr(t),providers:Dr(n),referencedProviders:this.aiProviderController.getByIdsAiProvider({ids:s,withRemoved:false}).pipe(Zs(()=>Dr([])))})})))));constructor(){this.data$.pipe(U(this.destroyRef)).subscribe({next:({namespace:e,platform:t,providers:n,referencedProviders:s})=>{let m=new Map([...s,...n].map(c=>[c.id??"",c.name]));this.rows.set([...t.map((c,g)=>({key:`platform:${c.id??g}`,model:c,providerName:m.get(c.aiProviderId)??c.aiProviderId,scope:"platform"})),...e.map((c,g)=>({key:`namespace:${c.id??g}`,model:c,providerName:m.get(c.aiProviderId)??c.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"]);}title(e){return e.model.alias??e.model.apiModelName}confirmDelete(e){e.scope==="platform"||!e.model.id||this.deletion.execute(e.key,{request$:this.aiModelController.deleteAiModel(e.model.id).pipe(U(this.destroyRef)),onSuccess:()=>this.refresh$.next(),errorMessage:`Deleting "${this.title(e)}" failed. Try again.`});}static \u0275fac=function(t){return new(t||i)};static \u0275cmp=JI({type:i,selectors:[["agentos-namespace-ai-models"]],decls:9,vars:3,consts:[["title","AI models","description","AI models configured for this namespace, including models inherited from the platform."],["label","Filter AI models","placeholder","Filter AI models\u2026",3,"queryChange","query"],["dsButton","","variant","primary","type","button",3,"click"],["role","alert",1,"settings-table__error"],["role","status",1,"settings-table__status"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table","aria-label","AI models"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title","",1,"settings-table__name"],["role","cell","data-label","Provider"],["role","cell","data-label","API model name",1,"settings-table__secondary"],["role","cell","data-label","Scope"],[1,"settings-table__tags"],[3,"variant"],["variant","outline"],["role","cell","data-label","Actions","data-actions",""],[1,"settings-table__actions"],["type","button","disabled",""],["type","button"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"],["type","button",3,"click"]],template:function(t,n){t&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(m){return n.rowFilter.query.set(m)}),zu(),os(2,"button",2),qh("click",function(){return n.openCreateForm()}),fC(3,"New AI model"),zu()(),Ew(4,Q,2,1,"p",3),Ew(5,W,2,0,"p",4)(6,X,2,0,"p",5)(7,Y,2,0,"p",4)(8,oe,18,0,"div",6)),t&2&&(EE(),Vh("query",n.rowFilter.query()),EE(3),Iw(n.deletion.error()?4:-1),EE(),Iw(n.isLoading()?5:n.rows().length===0?6:n.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,Fo,P,P$1],encapsulation:2})};export{z as NamespaceAiModelsComponent};
@@ -1 +1 @@
1
- import {c}from'./chunk-C_m8f_OQ.js';import {B as k,k as O$1,e as at,c as fn,l as ko,n as Fo,P,D as P$1}from'./chunk-CCZ1b0na.js';import {g,F,w as we,M as Mi,x as U$1,am as Fe,ap as Ge,J as JI,o as os,Q as qh,z as zu,f as fC,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,l as lg,i as bw,T as Tw,n as Aw,q as Pd,L as Ld,d as Bh}from'./main-63IEQS3X.js';var M=(n,t)=>t.id??t.name;function U(n,t){if(n&1&&(os(0,"p",3),fC(1),zu()),n&2){let e=Pw();EE(),lg(e.deletion.error());}}function B(n,t){n&1&&(os(0,"p",4),fC(1,"Loading scheduled prompts\u2026"),zu());}function j(n,t){n&1&&(os(0,"p",5),fC(1,"No platform scheduled prompts defined yet."),zu());}function W(n,t){n&1&&(os(0,"p",4),fC(1,"No scheduled prompts match the current filter."),zu());}function H(n,t){if(n&1&&(os(0,"span",14),fC(1),zu()),n&2){let e=Pw().$implicit;EE(),lg(e.description);}}function O(n,t){if(n&1){let e=Aw();os(0,"button",21),qh("click",function(){Pd(e);let s=Pw().$implicit,c=Pw(2);return Ld(c.toggle(s))}),fC(1),zu(),os(2,"button",21),qh("click",function(){Pd(e);let s=Pw().$implicit,c=Pw(2);return Ld(c.edit(s))}),fC(3,"Edit"),zu();}if(n&2){let e=Pw().$implicit;EE(),lg(e.enabled?"Disable":"Enable"),EE(),Bh("aria-label","Edit "+e.name);}}function Y(n,t){if(n&1){let e=Aw();os(0,"agentos-row-delete-action",22),qh("deleteRequested",function(){Pd(e);let s=Pw().$implicit,c=Pw(2);return Ld(c.deletion.request(s.id))})("deleteConfirmed",function(){Pd(e);let s=Pw().$implicit,c=Pw(2);return Ld(c.confirmDelete(s))})("deleteCancelled",function(){Pd(e);let s=Pw(3);return Ld(s.deletion.cancel())}),zu();}if(n&2){let e=Pw().$implicit,i=Pw(2);Vh("rowKey",e.id)("rowLabel",e.name)("state",i.deletion);}}function z(n,t){if(n&1&&(os(0,"tr",9)(1,"td",12)(2,"span",13),fC(3),zu(),Ew(4,H,2,1,"span",14),zu(),os(5,"td",15),fC(6),zu(),os(7,"td",16)(8,"ds-tag",17),fC(9),zu()(),os(10,"td",18)(11,"div",19),Ew(12,O,4,2),Ew(13,Y,1,3,"agentos-row-delete-action",20),zu()()()),n&2){let e=t.$implicit,i=Pw(2);EE(3),lg(e.name),EE(),Iw(e.description?4:-1),EE(2),lg(i.scheduleLabel(e)),EE(2),Vh("variant",e.enabled?"accent":"outline"),EE(),lg(e.enabled?"Enabled":"Disabled"),EE(3),Iw(i.deletion.confirmingId()!==e.id?12:-1),EE(),Iw(e.id?13:-1);}}function G(n,t){if(n&1&&(os(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),fC(5,"Name"),zu(),os(6,"th",10),fC(7,"Schedule"),zu(),os(8,"th",10),fC(9,"Status"),zu(),os(10,"th",10)(11,"span",11),fC(12,"Actions"),zu()()()(),os(13,"tbody",8),bw(14,z,14,7,"tr",9,M),zu()()()),n&2){let e=Pw();EE(14),Tw(e.rowFilter.filteredRows());}}var A=class n{router=g(F);destroyRef=g(we);state=g(c);prompts=Mi([]);isLoading=Mi(true);deletion=k();rowFilter=O$1(this.prompts,t=>[t.name,t.description,this.scheduleLabel(t),t.enabled?"Enabled":"Disabled"].filter(Boolean).join(" "));constructor(){this.state.listPlatform().pipe(U$1(this.destroyRef)).subscribe({next:t=>{this.prompts.set(t),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}scheduleLabel(t){let{recurrence:e}=t,i=e.unit===Fe.WEEK?"week":"month",s=e.unit===Fe.WEEK&&e.days?.length?` (${e.days.map(c=>Ge[c]??c).join(", ")})`:"";return `Every ${i}${s} at ${e.timeUtc} UTC`}openCreateForm(){this.router.navigate(["/agentos","admin","scheduled-prompts","new"]);}edit(t){t.id&&this.router.navigate(["/agentos","admin","scheduled-prompts",t.id,"edit"]);}toggle(t){(t.enabled?this.state.disable(t.id??""):this.state.enable(t.id??"")).pipe(U$1(this.destroyRef)).subscribe(i=>this.patchPrompt(i));}confirmDelete(t){if(!t.id)return;let e=t.id;this.deletion.execute(e,{request$:this.state.delete(e).pipe(U$1(this.destroyRef)),onSuccess:()=>this.prompts.update(i=>i.filter(s=>s.id!==e)),errorMessage:`Deleting "${t.name}" failed. Try again.`});}patchPrompt(t){this.prompts.update(e=>e.map(i=>i.id===t.id?t:i));}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JI({type:n,selectors:[["agentos-platform-scheduled-prompts"]],decls:9,vars:3,consts:[["title","Platform scheduled prompts","description","Scheduled prompts shared across every namespace."],["label","Filter scheduled prompts","placeholder","Filter scheduled prompts\u2026",3,"queryChange","query"],["dsButton","","variant","primary","type","button",3,"click"],["role","alert",1,"settings-table__error"],["role","status",1,"settings-table__status"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table","aria-label","Platform scheduled prompts"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title",""],[1,"settings-table__name","settings-table__stacked"],[1,"settings-table__secondary","settings-table__stacked"],["role","cell","data-label","Schedule"],["role","cell","data-label","Status"],[3,"variant"],["role","cell","data-label","Actions","data-actions",""],[1,"settings-table__actions"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"rowKey","rowLabel","state"],["type","button",3,"click"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"]],template:function(e,i){e&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(c){return i.rowFilter.query.set(c)}),zu(),os(2,"button",2),qh("click",function(){return i.openCreateForm()}),fC(3,"New scheduled prompt"),zu()(),Ew(4,U,2,1,"p",3),Ew(5,B,2,0,"p",4)(6,j,2,0,"p",5)(7,W,2,0,"p",4)(8,G,16,0,"div",6)),e&2&&(EE(),Vh("query",i.rowFilter.query()),EE(3),Iw(i.deletion.error()?4:-1),EE(),Iw(i.isLoading()?5:i.prompts().length===0?6:i.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,Fo,P,P$1],encapsulation:2})};export{A as PlatformScheduledPromptsComponent};
1
+ import {c}from'./chunk-DGEz4p7l.js';import {B as k,k as O$1,e as at,c as fn,l as ko,n as Fo,P,D as P$1}from'./chunk-COmLfT0N.js';import {g,F,w as we,M as Mi,x as U$1,am as De,ap as _e,J as JI,o as os,Q as qh,z as zu,f as fC,E as Ew,a as EE,N as Vh,I as Iw,P as Pw,l as lg,i as bw,T as Tw,n as Aw,q as Pd,L as Ld,d as Bh}from'./main-B6UJJXO7.js';var M=(n,t)=>t.id??t.name;function U(n,t){if(n&1&&(os(0,"p",3),fC(1),zu()),n&2){let e=Pw();EE(),lg(e.deletion.error());}}function B(n,t){n&1&&(os(0,"p",4),fC(1,"Loading scheduled prompts\u2026"),zu());}function j(n,t){n&1&&(os(0,"p",5),fC(1,"No platform scheduled prompts defined yet."),zu());}function W(n,t){n&1&&(os(0,"p",4),fC(1,"No scheduled prompts match the current filter."),zu());}function H(n,t){if(n&1&&(os(0,"span",14),fC(1),zu()),n&2){let e=Pw().$implicit;EE(),lg(e.description);}}function O(n,t){if(n&1){let e=Aw();os(0,"button",21),qh("click",function(){Pd(e);let s=Pw().$implicit,c=Pw(2);return Ld(c.toggle(s))}),fC(1),zu(),os(2,"button",21),qh("click",function(){Pd(e);let s=Pw().$implicit,c=Pw(2);return Ld(c.edit(s))}),fC(3,"Edit"),zu();}if(n&2){let e=Pw().$implicit;EE(),lg(e.enabled?"Disable":"Enable"),EE(),Bh("aria-label","Edit "+e.name);}}function Y(n,t){if(n&1){let e=Aw();os(0,"agentos-row-delete-action",22),qh("deleteRequested",function(){Pd(e);let s=Pw().$implicit,c=Pw(2);return Ld(c.deletion.request(s.id))})("deleteConfirmed",function(){Pd(e);let s=Pw().$implicit,c=Pw(2);return Ld(c.confirmDelete(s))})("deleteCancelled",function(){Pd(e);let s=Pw(3);return Ld(s.deletion.cancel())}),zu();}if(n&2){let e=Pw().$implicit,i=Pw(2);Vh("rowKey",e.id)("rowLabel",e.name)("state",i.deletion);}}function z(n,t){if(n&1&&(os(0,"tr",9)(1,"td",12)(2,"span",13),fC(3),zu(),Ew(4,H,2,1,"span",14),zu(),os(5,"td",15),fC(6),zu(),os(7,"td",16)(8,"ds-tag",17),fC(9),zu()(),os(10,"td",18)(11,"div",19),Ew(12,O,4,2),Ew(13,Y,1,3,"agentos-row-delete-action",20),zu()()()),n&2){let e=t.$implicit,i=Pw(2);EE(3),lg(e.name),EE(),Iw(e.description?4:-1),EE(2),lg(i.scheduleLabel(e)),EE(2),Vh("variant",e.enabled?"accent":"outline"),EE(),lg(e.enabled?"Enabled":"Disabled"),EE(3),Iw(i.deletion.confirmingId()!==e.id?12:-1),EE(),Iw(e.id?13:-1);}}function G(n,t){if(n&1&&(os(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),fC(5,"Name"),zu(),os(6,"th",10),fC(7,"Schedule"),zu(),os(8,"th",10),fC(9,"Status"),zu(),os(10,"th",10)(11,"span",11),fC(12,"Actions"),zu()()()(),os(13,"tbody",8),bw(14,z,14,7,"tr",9,M),zu()()()),n&2){let e=Pw();EE(14),Tw(e.rowFilter.filteredRows());}}var A=class n{router=g(F);destroyRef=g(we);state=g(c);prompts=Mi([]);isLoading=Mi(true);deletion=k();rowFilter=O$1(this.prompts,t=>[t.name,t.description,this.scheduleLabel(t),t.enabled?"Enabled":"Disabled"].filter(Boolean).join(" "));constructor(){this.state.listPlatform().pipe(U$1(this.destroyRef)).subscribe({next:t=>{this.prompts.set(t),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}scheduleLabel(t){let{recurrence:e}=t,i=e.unit===De.WEEK?"week":"month",s=e.unit===De.WEEK&&e.days?.length?` (${e.days.map(c=>_e[c]??c).join(", ")})`:"";return `Every ${i}${s} at ${e.timeUtc} UTC`}openCreateForm(){this.router.navigate(["/agentos","admin","scheduled-prompts","new"]);}edit(t){t.id&&this.router.navigate(["/agentos","admin","scheduled-prompts",t.id,"edit"]);}toggle(t){(t.enabled?this.state.disable(t.id??""):this.state.enable(t.id??"")).pipe(U$1(this.destroyRef)).subscribe(i=>this.patchPrompt(i));}confirmDelete(t){if(!t.id)return;let e=t.id;this.deletion.execute(e,{request$:this.state.delete(e).pipe(U$1(this.destroyRef)),onSuccess:()=>this.prompts.update(i=>i.filter(s=>s.id!==e)),errorMessage:`Deleting "${t.name}" failed. Try again.`});}patchPrompt(t){this.prompts.update(e=>e.map(i=>i.id===t.id?t:i));}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JI({type:n,selectors:[["agentos-platform-scheduled-prompts"]],decls:9,vars:3,consts:[["title","Platform scheduled prompts","description","Scheduled prompts shared across every namespace."],["label","Filter scheduled prompts","placeholder","Filter scheduled prompts\u2026",3,"queryChange","query"],["dsButton","","variant","primary","type","button",3,"click"],["role","alert",1,"settings-table__error"],["role","status",1,"settings-table__status"],[1,"settings-table__status"],[1,"settings-table__wrap"],["dsTable","","role","table","aria-label","Platform scheduled prompts"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title",""],[1,"settings-table__name","settings-table__stacked"],[1,"settings-table__secondary","settings-table__stacked"],["role","cell","data-label","Schedule"],["role","cell","data-label","Status"],[3,"variant"],["role","cell","data-label","Actions","data-actions",""],[1,"settings-table__actions"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"rowKey","rowLabel","state"],["type","button",3,"click"],["deleteClass","settings-table__delete","confirmLabelClass","settings-table__confirm-label",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"]],template:function(e,i){e&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(c){return i.rowFilter.query.set(c)}),zu(),os(2,"button",2),qh("click",function(){return i.openCreateForm()}),fC(3,"New scheduled prompt"),zu()(),Ew(4,U,2,1,"p",3),Ew(5,B,2,0,"p",4)(6,j,2,0,"p",5)(7,W,2,0,"p",4)(8,G,16,0,"div",6)),e&2&&(EE(),Vh("query",i.rowFilter.query()),EE(3),Iw(i.deletion.error()?4:-1),EE(),Iw(i.isLoading()?5:i.prompts().length===0?6:i.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,Fo,P,P$1],encapsulation:2})};export{A as PlatformScheduledPromptsComponent};
@@ -0,0 +1 @@
1
+ import {c}from'./chunk-DGEz4p7l.js';import {p as pt,T as Te$1,g as gn,q as qt,m as md,C as Co,M as Mo,H as Ht,F as Fn,x as yn,U as Ut,a as po,h as ho,Z as Zr,A as An,O as On,b as hn,c as fn,u as un,t as dn,d as cn,E as pn,e as at,i as sn,v as an}from'./chunk-COmLfT0N.js';import {g,W,F,w as we$1,ak as U,al as We,am as De$1,M as Mi,an as Ge,ad as F$1,ao as Vl,h as BC,ag as Gm,x as U$1,a6 as Zs,ae as Dr,K as x,C as w,J as JI,o as os,Q as qh,f as fC,z as zu,E as Ew,a as EE,N as Vh,Y as Yu,I as Iw,n as Aw,H as Hh,R as uI,i as bw,P as Pw,S as dI,T as Tw,l as lg,q as Pd,L as Ld,O as Op}from'./main-B6UJJXO7.js';var V=(n,t)=>t.value,ve=(n,t)=>t.id;function be(n,t){n&1&&(os(0,"p",2),fC(1,"Loading\u2026"),zu());}function _e(n,t){if(n&1&&(os(0,"ds-form-field",9),Hh(1,"input",38),zu()),n&2){let e=Pw(2);EE(),Vh("value",e.resolveAgentConfigName(e.agentConfigIdControl.value));}}function Se(n,t){if(n&1&&(os(0,"a",39),fC(1,"Add an agent config"),zu(),fC(2," first. ")),n&2){let e=Pw(3);Vh("href","/agentos/"+e.namespaceId+"/agent-configs/new",Op);}}function xe(n,t){if(n&1&&(os(0,"ds-form-field",10)(1,"p",2),fC(2," No agent configs available in this scope yet. "),Ew(3,Se,3,1),zu()()),n&2){let e=Pw(2);EE(3),Iw(e.isPlatformMode?-1:3);}}function Ee(n,t){if(n&1&&(os(0,"option",17),fC(1),zu()),n&2){let e=t.$implicit;Vh("value",e.id),EE(),lg(e.name);}}function De(n,t){if(n&1&&(os(0,"ds-form-field",11)(1,"select",40)(2,"option",41),fC(3,"Select an agent config\u2026"),zu(),bw(4,Ee,2,2,"option",17,ve),zu(),uI(),zu()),n&2){let e=Pw(2);Vh("error",e.agentConfigIdControl.invalid&&e.agentConfigIdControl.touched?"Agent Config is required.":null),EE(),Vh("formControl",e.agentConfigIdControl),dI(),EE(3),Tw(e.availableAgentConfigs());}}function Te(n,t){if(n&1&&(os(0,"option",17),fC(1),zu()),n&2){let e=t.$implicit;Vh("value",e.value),EE(),lg(e.label);}}function Ne(n,t){if(n&1){let e=Aw();os(0,"label",31)(1,"input",43),qh("change",function(){let f=Pd(e).$implicit,h=Pw(3);return Ld(h.toggleDay(f.value))}),zu(),fC(2),zu();}if(n&2){let e=t.$implicit,l=Pw(3);EE(),Vh("checked",l.isDaySelected(e.value)),EE(),Yu(" ",e.label," ");}}function Ie(n,t){if(n&1&&(os(0,"ds-form-field",18)(1,"div",42),bw(2,Ne,3,2,"label",31,V),zu()()),n&2){let e=Pw(2);EE(2),Tw(e.dayOptions);}}function Me(n,t){if(n&1&&(os(0,"option",17),fC(1),zu()),n&2){let e=t.$implicit;Vh("value",e.value),EE(),lg(e.label);}}function Pe(n,t){if(n&1&&(os(0,"ds-form-field",28),Hh(1,"input",44),uI(),zu()),n&2){let e=Pw(2);Vh("error",e.form.hasError("endDateRequired")&&e.endDateControl.touched?"End date is required.":null),EE(),Vh("formControl",e.endDateControl),dI();}}function we(n,t){if(n&1&&(os(0,"ds-form-field",29),Hh(1,"input",45),uI(),zu()),n&2){let e=Pw(2);Vh("error",e.form.hasError("occurrenceCountRequired")&&e.occurrenceCountControl.touched?"Must be at least 1.":null),EE(),Vh("formControl",e.occurrenceCountControl),dI();}}function Fe(n,t){if(n&1&&(os(0,"ds-notice"),fC(1),zu()),n&2){let e=Pw(2);EE(),lg(e.errorMessage());}}function Oe(n,t){if(n&1){let e=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(e);let f=Pw();return Ld(f.submit())}),os(1,"ds-form-field",5),Hh(2,"input",6),uI(),zu(),os(3,"ds-form-field",7),Hh(4,"input",8),uI(),zu(),Ew(5,_e,2,1,"ds-form-field",9)(6,xe,4,1,"ds-form-field",10)(7,De,6,2,"ds-form-field",11),os(8,"ds-form-field",12),Hh(9,"textarea",13),uI(),zu(),os(10,"ds-fieldset",14)(11,"ds-form-field",15)(12,"select",16),bw(13,Te,2,2,"option",17,V),zu(),uI(),zu(),Ew(15,Ie,4,0,"ds-form-field",18),os(16,"ds-form-field",19)(17,"div",20),Hh(18,"input",21),uI(),os(19,"span",22),fC(20,"UTC"),zu()()()(),os(21,"ds-fieldset",23)(22,"ds-form-field",24),Hh(23,"input",25),uI(),zu(),os(24,"ds-form-field",26)(25,"select",27),bw(26,Me,2,2,"option",17,V),zu(),uI(),zu(),Ew(28,Pe,2,2,"ds-form-field",28),Ew(29,we,2,2,"ds-form-field",29),zu(),os(30,"div",30)(31,"label",31),Hh(32,"input",32),uI(),fC(33," Enabled "),zu(),os(34,"p",33),fC(35,"When disabled, the scheduled prompt is saved but will not run on schedule."),zu()(),os(36,"ds-form-field",34),Hh(37,"textarea",35),uI(),zu(),Ew(38,Fe,2,1,"ds-notice"),os(39,"ds-form-actions")(40,"button",36),fC(41),zu(),os(42,"button",37),qh("click",function(){Pd(e);let f=Pw();return Ld(f.cancel())}),fC(43,"Cancel"),zu()()();}if(n&2){let e=Pw();Vh("formGroup",e.form),EE(),Vh("error",e.nameControl.invalid&&e.nameControl.touched?"Name is required.":null),EE(),Vh("formControl",e.nameControl),dI(),EE(2),Vh("formControl",e.descriptionControl),dI(),EE(),Iw(e.isEditMode()?5:e.availableAgentConfigs().length===0?6:7),EE(3),Vh("error",e.promptContentControl.invalid&&e.promptContentControl.touched?"Opening message is required.":null),EE(),Vh("formControl",e.promptContentControl),dI(),EE(3),Vh("formControl",e.unitControl),dI(),EE(),Tw(e.schedulerUnits),EE(2),Iw(e.showDayFilter()?15:-1),EE(),Vh("error",e.timeUtcControl.invalid&&e.timeUtcControl.touched?"Valid time is required (HH:mm).":null),EE(2),Vh("formControl",e.timeUtcControl),dI(),EE(4),Vh("error",e.startDateControl.invalid&&e.startDateControl.touched?"Start date is required.":null),EE(),Vh("formControl",e.startDateControl),dI(),EE(2),Vh("formControl",e.endTypeControl),dI(),EE(),Tw(e.endTypes),EE(2),Iw(e.showEndDate()?28:-1),EE(),Iw(e.showOccurrenceCount()?29:-1),EE(3),Vh("formControl",e.enabledControl),dI(),EE(4),Vh("error",e.externalMetadataJsonControl.invalid&&e.externalMetadataJsonControl.touched?"Invalid JSON.":null),EE(),Vh("formControl",e.externalMetadataJsonControl),dI(),EE(),Iw(e.errorMessage()?38:-1),EE(2),Vh("disabled",e.form.invalid||e.isSubmitting()),EE(),Yu(" ",e.isEditMode()?"Save changes":"Create scheduled prompt"," ");}}var ye=class n{route=g(W);router=g(F);destroyRef=g(we$1);state=g(c);agentConfigController=g(U);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new pt({name:new Te$1("",{nonNullable:true,validators:[gn.required]}),description:new Te$1(null),agentConfigId:new Te$1("",{nonNullable:true,validators:[gn.required]}),promptContent:new Te$1("",{nonNullable:true,validators:[gn.required]}),unit:new Te$1(De$1.WEEK,{nonNullable:true,validators:[gn.required]}),days:new Te$1([],{nonNullable:true}),timeUtc:new Te$1("09:00",{nonNullable:true,validators:[gn.required,gn.pattern(/^([01]\d|2[0-3]):[0-5]\d$/)]}),startDate:new Te$1("",{nonNullable:true,validators:[gn.required]}),endType:new Te$1(We.NEVER,{nonNullable:true,validators:[gn.required]}),endDate:new Te$1(null),occurrenceCount:new Te$1(null),enabled:new Te$1(true,{nonNullable:true}),externalMetadataJson:new Te$1("",{nonNullable:true,validators:[ke]})},{validators:[Ae,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=Mi(false);isSubmitting=Mi(false);isLoading=Mi(false);errorMessage=Mi(null);SchedulerUnit=De$1;SchedulerEndType=We;schedulerUnits=[{value:De$1.WEEK,label:"Week(s)"},{value:De$1.MONTH,label:"Month(s)"}];endTypes=[{value:We.NEVER,label:"Never"},{value:We.ON_DATE,label:"On date"},{value:We.OCCURRENCES,label:"After N occurrences"}];dayOptions=Object.entries(Ge).map(([t,e])=>({value:t,label:e}));unitSignal=F$1(this.unitControl.valueChanges.pipe(Vl(this.unitControl.value)));endTypeSignal=F$1(this.endTypeControl.valueChanges.pipe(Vl(this.endTypeControl.value)));showDayFilter=BC(()=>this.unitSignal()===De$1.WEEK);showEndDate=BC(()=>this.endTypeSignal()===We.ON_DATE);showOccurrenceCount=BC(()=>this.endTypeSignal()===We.OCCURRENCES);agentConfigs=Mi([]);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),Gm({prompt:this.state.getById(t),agentConfigs:this.agentConfigs$()}).pipe(U$1(this.destroyRef)).subscribe({next:({prompt:e,agentConfigs:l})=>{this.existingPrompt=e,this.agentConfigs.set(l),this.hydrateForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}loadResources(){this.agentConfigs$().pipe(U$1(this.destroyRef)).subscribe(t=>this.agentConfigs.set(t));}agentConfigs$(){return (this.isPlatformMode?this.agentConfigController.listPlatformAgentsAgentConfig():this.agentConfigController.listByParentAgentConfig(this.namespaceId)).pipe(Zs(()=>Dr([])))}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,l=e.includes(t)?e.filter(f=>f!==t):[...e,t];this.daysControl.setValue(l);}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,l=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===We.ON_DATE?this.endDateControl.value??void 0:void 0,maxOccurrenceCount:e===We.OCCURRENCES?this.occurrenceCountControl.value??void 0:void 0},enabled:this.enabledControl.value,removed:this.existingPrompt?.removed??false,externalMetadata:(()=>{let h=this.externalMetadataJsonControl.value.trim();return h?JSON.parse(h):null})()});(t?this.state.update(this.existingPrompt.id,l):this.state.create(l)).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:h=>{this.isSubmitting.set(false),h.status===409?this.errorMessage.set(`A scheduled prompt named "${l.name}" already exists in this scope.`):h.status===400?this.errorMessage.set(h.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=JI({type:n,selectors:[["agentos-scheduled-prompt-form"]],decls:6,vars:3,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to scheduled prompts",3,"click"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["label","Name","controlId","sp-name","required","","hint",'Free-form name (e.g. "Weekly Report"). Cannot be changed after creation.',3,"error"],["dsControl","","id","sp-name","type","text","placeholder","e.g. Weekly Report","autocomplete","off",3,"formControl"],["label","Description","controlId","sp-description"],["dsControl","","id","sp-description","type","text","placeholder","Optional \u2014 short description","autocomplete","off",3,"formControl"],["label","Agent Config","required","","hint","Agent Config cannot be changed after creation."],["label","Agent Config","required",""],["label","Agent Config","controlId","sp-agent-config","required","","hint","Immutable after creation.",3,"error"],["label","Opening message","controlId","sp-prompt-content","required","","hint","The message sent to the agent when the scheduled prompt fires.",3,"error"],["dsControl","","id","sp-prompt-content","rows","6","placeholder","Enter the message sent to the agent when the scheduled prompt fires\u2026",3,"formControl"],["legend","Recurrence"],["label","Unit","controlId","sp-unit","required",""],["dsControl","","id","sp-unit",3,"formControl"],[3,"value"],["label","Days of week","hint","Leave empty to run every day of the week."],["label","Time (UTC)","controlId","sp-time","required","",3,"error"],[1,"ds-inline"],["dsControl","","id","sp-time","type","time",3,"formControl"],[1,"ds-meta"],["legend","Planning"],["label","Start date","controlId","sp-start-date","required","",3,"error"],["dsControl","","id","sp-start-date","type","date",3,"formControl"],["label","Ends","controlId","sp-end-type","required",""],["dsControl","","id","sp-end-type",3,"formControl"],["label","End date","controlId","sp-end-date","required","",3,"error"],["label","Number of occurrences","controlId","sp-occurrence-count","required","",3,"error"],[1,"ds-stack","ds-stack--sm"],["dsCheck",""],["type","checkbox",3,"formControl"],[1,"ds-hint","ds-indent"],["label","External Metadata","controlId","sp-external-metadata","hint","Optional. Opaque JSON object stored as-is. Leave empty to clear.",3,"error"],["dsControl","","mono","","id","sp-external-metadata","rows","6","placeholder",'{ "key": "value" }',"spellcheck","false","autocomplete","off",3,"formControl"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"click"],["dsControl","","type","text","readonly","",3,"value"],[3,"href"],["dsControl","","id","sp-agent-config",3,"formControl"],["value","","disabled",""],[1,"ds-inline","ds-inline--wrap"],["type","checkbox",3,"change","checked"],["dsControl","","id","sp-end-date","type","date",3,"formControl"],["dsControl","","id","sp-occurrence-count","type","number","min","1",1,"ds-control--narrow",3,"formControl"]],template:function(e,l){e&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return l.cancel()}),fC(3),zu()(),Ew(4,be,2,0,"p",2)(5,Oe,44,22,"form",3),zu()),e&2&&(EE(),Vh("title",l.isEditMode()?"Edit scheduled prompt":"New scheduled prompt"),EE(2),Yu(" \u2190 ",l.isPlatformMode?"Platform scheduled prompts":"Scheduled prompts"," "),EE(),Iw(l.isLoading()?4:5));},dependencies:[qt,md,Co,Mo,Ht,Fn,yn,Ut,po,ho,Zr,An,On,hn,fn,un,dn,cn,pn,at,sn,an],encapsulation:2})};function Ae(n){let t=n.get("endType")?.value,e=n.get("endDate")?.value;return t===We.ON_DATE&&!e?{endDateRequired:true}:null}function Ve(n){let t=n.get("endType")?.value,e=n.get("occurrenceCount")?.value;return t===We.OCCURRENCES&&(e==null||e<1)?{occurrenceCountRequired:true}:null}function ke(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"),l=String(n.getDate()).padStart(2,"0");return `${t}-${e}-${l}`}export{ye as ScheduledPromptFormComponent};