@whoz-oss/coday-client 0.0.0-workstream-messaging.2 → 0.0.0-workstream-messaging.4

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 (96) hide show
  1. package/browser/chunk-B7jX7zgs.js +1 -0
  2. package/browser/chunk-BDVgHP1k.js +1 -0
  3. package/browser/chunk-BITDsEPS.js +1 -0
  4. package/browser/chunk-BMfdBnfJ.js +1 -0
  5. package/browser/chunk-BT-f7pOo.js +1 -0
  6. package/browser/chunk-BUVHuntB.js +2 -0
  7. package/browser/chunk-BeJGuL-w.js +1 -0
  8. package/browser/chunk-BfmxY0U2.js +1 -0
  9. package/browser/chunk-BkHh71pt.js +1 -0
  10. package/browser/chunk-BvRDo1Xd.js +1 -0
  11. package/browser/chunk-BvgKYsgP.js +1 -0
  12. package/browser/chunk-Bvjz4EuH.js +2 -0
  13. package/browser/chunk-C1OYQ9z3.js +1 -0
  14. package/browser/chunk-CCUIsU71.js +1 -0
  15. package/browser/chunk-CCZ1b0na.js +674 -0
  16. package/browser/chunk-CEFBjtqS.js +1 -0
  17. package/browser/chunk-CVAz4Lko.js +1 -0
  18. package/browser/chunk-CYowS7ps.js +1 -0
  19. package/browser/{chunk-WwdM1pqC.js → chunk-C_m8f_OQ.js} +1 -1
  20. package/browser/chunk-CaLaUzUo.js +1 -0
  21. package/browser/chunk-CasQE1P8.js +1 -0
  22. package/browser/chunk-CfeR-40i.js +1 -0
  23. package/browser/chunk-Cvh22V1I.js +1 -0
  24. package/browser/{chunk-CfifMtwC.js → chunk-D6na643q.js} +1 -1
  25. package/browser/chunk-D7cDcWU_.js +1 -0
  26. package/browser/chunk-DJYg-Uvg.js +2 -0
  27. package/browser/chunk-DQEn5_2f.js +1 -0
  28. package/browser/chunk-DQRocvRJ.js +1 -0
  29. package/browser/chunk-DSeOF-b7.js +1 -0
  30. package/browser/chunk-DdcAhCFt.js +1 -0
  31. package/browser/chunk-Df_pypwY.js +1 -0
  32. package/browser/chunk-DloTeM9a.js +1 -0
  33. package/browser/chunk-DqQwkTmj.js +1 -0
  34. package/browser/chunk-Dyc4B4N5.js +1 -0
  35. package/browser/chunk-DyrGPeSh.js +1 -0
  36. package/browser/chunk-DzlYU9Mb.js +1 -0
  37. package/browser/{chunk-zfSbYfDB.js → chunk-Jcjs0qUP.js} +1 -1
  38. package/browser/chunk-L1iy-QYW.js +1 -0
  39. package/browser/chunk-MmNnob5o.js +1 -0
  40. package/browser/chunk-OGl61xgu.js +1 -0
  41. package/browser/chunk-XCYDtfAr.js +1 -0
  42. package/browser/chunk-YazOGc5y.js +1 -0
  43. package/browser/chunk-_4rWzEoG.js +1 -0
  44. package/browser/chunk-cAmP4Ess.js +1 -0
  45. package/browser/chunk-go60iT_m.js +1 -0
  46. package/browser/chunk-m2Qa9RC5.js +1 -0
  47. package/browser/chunk-ns52VA45.js +1 -0
  48. package/browser/chunk-tHzqEHGj.js +1 -0
  49. package/browser/chunk-xMNw9k_r.js +1 -0
  50. package/browser/index.html +1 -1
  51. package/browser/main-63IEQS3X.js +1254 -0
  52. package/package.json +1 -1
  53. package/browser/chunk-8SxX32rO.js +0 -1
  54. package/browser/chunk-B6rPUjlK.js +0 -1
  55. package/browser/chunk-BH7OLSx0.js +0 -1
  56. package/browser/chunk-BKnj9uiw.js +0 -1
  57. package/browser/chunk-BLR-ZTHh.js +0 -1
  58. package/browser/chunk-BMpFwNrL.js +0 -1
  59. package/browser/chunk-BbYQjxBb.js +0 -2
  60. package/browser/chunk-Bo2-yEbp.js +0 -1
  61. package/browser/chunk-BwqiXXvR.js +0 -1
  62. package/browser/chunk-Bz9_W213.js +0 -1
  63. package/browser/chunk-C1CvCiQs.js +0 -1
  64. package/browser/chunk-C2LkuBYd.js +0 -1
  65. package/browser/chunk-C3AaPoyZ.js +0 -1
  66. package/browser/chunk-C4CyLTkA.js +0 -2
  67. package/browser/chunk-C8Q6ccMm.js +0 -1
  68. package/browser/chunk-CBtsWofj.js +0 -1
  69. package/browser/chunk-CNBrzP9I.js +0 -1
  70. package/browser/chunk-CTrUVP-N.js +0 -1
  71. package/browser/chunk-CX2oEBf9.js +0 -1
  72. package/browser/chunk-C_TR3rI-.js +0 -1
  73. package/browser/chunk-CcI4CWl6.js +0 -1
  74. package/browser/chunk-CoWzfbqL.js +0 -1
  75. package/browser/chunk-CyIUjRWT.js +0 -1
  76. package/browser/chunk-D0jMQDes.js +0 -1
  77. package/browser/chunk-D8BMEvrt.js +0 -1
  78. package/browser/chunk-DAiaXy53.js +0 -1
  79. package/browser/chunk-DNefc5l8.js +0 -1
  80. package/browser/chunk-DV5IlfBq.js +0 -1
  81. package/browser/chunk-DbN0_APN.js +0 -1
  82. package/browser/chunk-DlJR_onX.js +0 -1
  83. package/browser/chunk-DtJYpVtU.js +0 -2
  84. package/browser/chunk-DwXfEpcA.js +0 -1
  85. package/browser/chunk-E81L_Bla.js +0 -1
  86. package/browser/chunk-GUDFMaEy.js +0 -1
  87. package/browser/chunk-GaJWiH82.js +0 -1
  88. package/browser/chunk-MZXI10vX.js +0 -1
  89. package/browser/chunk-RGb_eFD5.js +0 -1
  90. package/browser/chunk-Uf57QzfJ.js +0 -674
  91. package/browser/chunk-cIF5t9Db.js +0 -1
  92. package/browser/chunk-dgHw3CIi.js +0 -1
  93. package/browser/chunk-kO5zS3K9.js +0 -1
  94. package/browser/chunk-mgh7hiln.js +0 -1
  95. package/browser/chunk-ogAJa2CM.js +0 -1
  96. package/browser/main-DYDARBQQ.js +0 -1253
@@ -0,0 +1 @@
1
+ import {O as O$1}from'./chunk-BT-f7pOo.js';import {g,F,w as we,aj as G$1,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,n as Aw,d as Bh,q as Pd,L as Ld}from'./main-63IEQS3X.js';import {B as k,k as O$2,e as at,c as fn,l as ko,P,D as P$1}from'./chunk-CCZ1b0na.js';import'./chunk-CVAz4Lko.js';var j=(t,e)=>e.id??e.name;function A(t,e){if(t&1&&(os(0,"p",3),fC(1),zu()),t&2){let n=Pw();EE(),lg(n.deletion.error());}}function K(t,e){t&1&&(os(0,"p",4),fC(1,"Loading integrations\u2026"),zu());}function H(t,e){t&1&&(os(0,"p",5),fC(1,"No platform integrations defined yet."),zu());}function U(t,e){t&1&&(os(0,"p",4),fC(1,"No integrations match the current filter."),zu());}function z(t,e){if(t&1){let n=Aw();os(0,"button",18),qh("click",function(){Pd(n);let d=Pw().$implicit,m=Pw(2);return Ld(m.edit(d))}),fC(1,"Edit"),zu();}if(t&2){let n=Pw().$implicit;Bh("aria-label","Edit "+n.name);}}function G(t,e){if(t&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.confirmDelete(d))})("deleteCancelled",function(){Pd(n);let d=Pw(3);return Ld(d.deletion.cancel())}),zu();}if(t&2){let n=Pw().$implicit,r=Pw(2);Vh("rowKey",n.id)("rowLabel",n.name)("state",r.deletion);}}function J(t,e){if(t&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()()()),t&2){let n=e.$implicit,r=Pw(2);EE(2),lg(n.name),EE(2),lg(n.integrationType),EE(3),Iw(r.deletion.confirmingId()!==n.id?7:-1),EE(),Iw(n.id?8:-1);}}function O(t,e){if(t&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,"Type"),zu(),os(8,"th",10)(9,"span",11),fC(10,"Actions"),zu()()()(),os(11,"tbody",8),bw(12,J,9,4,"tr",9,j),zu()()()),t&2){let n=Pw();EE(12),Tw(n.rowFilter.filteredRows());}}var B=class t{router=g(F);destroyRef=g(we);state=g(O$1);integrationConfigController=g(G$1);refresh$=new vr(void 0);isLoading=Mi(true);deletion=k();configs=Mi([]);rowFilter=O$2(this.configs,e=>[e.name,e.integrationType].filter(Boolean).join(" "));constructor(){this.refresh$.pipe(Ys(()=>(this.isLoading.set(true),this.state.loadPlatformConfigs())),U$1(this.destroyRef)).subscribe({next:e=>{this.configs.set(e),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos","admin","integration-configs","new"]);}edit(e){this.router.navigate(["/agentos","admin","integration-configs",e.id??"","edit"]);}confirmDelete(e){e.id&&this.deletion.execute(e.id,{request$:this.integrationConfigController.deleteIntegrationConfig(e.id).pipe(U$1(this.destroyRef)),onSuccess:()=>this.refresh$.next(),errorMessage:`Deleting "${e.name}" failed. Try again.`});}static \u0275fac=function(n){return new(n||t)};static \u0275cmp=JI({type:t,selectors:[["agentos-platform-integration-configs"]],decls:9,vars:3,consts:[["title","Platform integrations","description","Integration configurations shared across every namespace."],["label","Filter integrations","placeholder","Filter integrations\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 integrations"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title","",1,"settings-table__name"],["role","cell","data-label","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,r){n&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(m){return r.rowFilter.query.set(m)}),zu(),os(2,"button",2),qh("click",function(){return r.openCreateForm()}),fC(3,"New integration"),zu()(),Ew(4,A,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",r.rowFilter.query()),EE(3),Iw(r.deletion.error()?4:-1),EE(),Iw(r.isLoading()?5:r.configs().length===0?6:r.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,P,P$1],encapsulation:2})};export{B as PlatformIntegrationConfigsComponent};
@@ -0,0 +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};
@@ -0,0 +1 @@
1
+ import {g as g$1}from'./chunk-OGl61xgu.js';import {j as e}from'./chunk-CCZ1b0na.js';import {g,w as we,M as Mi,h as BC,x as U,J as JI,_ as Qb,G as Gu,f as fC,b as Wu,E as Ew,a as EE,Y as Yu,$ as dg,I as Iw,n as Aw,a0 as AC,U as Uh,Z as Zh,q as Pd,P as Pw,L as Ld,l as lg,a1 as kC,c as Gh}from'./main-63IEQS3X.js';function R(r,n){if(r&1){let e=Aw();Gu(0,"span",11),fC(1,"Remove it? The bots it created stay."),Wu(),Gu(2,"button",15),Zh("click",function(){Pd(e);let t=Pw(2);return Ld(t.remove())}),fC(3," Remove "),Wu(),Gu(4,"button",13),Zh("click",function(){Pd(e);let t=Pw(2);return Ld(t.confirmingRemove.set(false))}),fC(5,"Cancel"),Wu();}if(r&2){let e=Pw(2);EE(2),Gh("disabled",e.busy());}}function I(r,n){if(r&1){let e=Aw();Gu(0,"button",13),Zh("click",function(){Pd(e);let t=Pw(2);return Ld(t.confirmingRemove.set(true))}),fC(1,"Remove"),Wu();}}function V(r,n){if(r&1){let e=Aw();Gu(0,"div",5)(1,"span",9),fC(2),Wu(),Gu(3,"span",10),fC(4),Wu(),Gu(5,"span",11),fC(6),AC(7,"date"),Wu(),Uh(8,"span",12),Gu(9,"button",13),Zh("click",function(){Pd(e);let t=Pw();return Ld(t.replacing.set(!t.replacing()))}),fC(10,"Replace"),Wu(),Ew(11,R,6,1)(12,I,2,0,"button",14),Wu();}if(r&2){let e=n,o=Pw();EE(2),Yu("@",e.username),EE(2),lg(o.statusLabel(e.status)),EE(2),Yu("since ",kC(7,4,e.createdAt,"mediumDate")),EE(5),Iw(o.confirmingRemove()?11:12);}}function z(r,n){if(r&1&&(Gu(0,"ol",6)(1,"li"),fC(2),Wu(),Gu(3,"li"),fC(4,"In BotFather's Mini App, open the bot's settings and turn Bot Management Mode on."),Wu(),Gu(5,"li"),fC(6,"Paste the bot's token below. It is stored encrypted and never shown again."),Wu()()),r&2){let e=Pw();EE(2),Yu("In ",e.platformName,', create a bot with @BotFather (/newbot), for example "AgentOS".');}}function B(r,n){if(r&1){let e=Aw();Gu(0,"form",16),Zh("submit",function(t){Pd(e);let p=Pw();return t.preventDefault(),Ld(p.save())}),Gu(1,"label",17),fC(2,"Bot manager token"),Wu(),Gu(3,"input",18),Zh("input",function(t){Pd(e);let p=Pw();return Ld(p.token.set(t.target.value))}),Wu(),Gu(4,"button",19),fC(5),Wu()();}if(r&2){let e=Pw();EE(3),Gh("value",e.token()),EE(),Gh("disabled",e.busy()||!e.token().trim()),EE(),Yu(" ",e.manager()?"Replace":"Set"," ");}}function L(r,n){r&1&&(Gu(0,"p",8),fC(1),Wu()),r&2&&(EE(),lg(n));}var D=class r{botConfig=g(g$1);destroyRef=g(we);platform="TELEGRAM";platformName=e("TELEGRAM");managers=Mi([]);manager=BC(()=>this.managers().find(n=>n.platform===this.platform)??null);replacing=Mi(false);confirmingRemove=Mi(false);token=Mi("");busy=Mi(false);error=Mi(null);ngOnInit(){this.run(this.botConfig.managers(),n=>this.managers.set(n),"Could not load the bot managers.");}statusLabel(n){return n==="RUNNING"?"Running":n.replace("_"," ").toLowerCase()}save(){let n=this.token().trim();n&&this.run(this.botConfig.setManager(this.platform,n),e=>{this.token.set(""),this.replacing.set(false),this.managers.update(o=>[...o.filter(t=>t.platform!==e.platform),e]);},`${this.platformName} refused this token, or the bot cannot manage other bots yet.`);}remove(){this.confirmingRemove.set(false),this.run(this.botConfig.removeManager(this.platform),()=>this.managers.update(n=>n.filter(e=>e.platform!==this.platform)),"Could not remove the bot manager.");}run(n,e,o){this.error.set(null),this.busy.set(true),n.pipe(U(this.destroyRef)).subscribe({next:t=>{this.busy.set(false),e(t);},error:t=>{console.error("[AdminMessaging]",o,t),this.busy.set(false),this.error.set(t?.error?.message??o);}});}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=JI({type:r,selectors:[["agentos-admin-messaging"]],decls:12,vars:6,consts:[[1,"admin-messaging"],[1,"admin-messaging__title"],[1,"admin-messaging__section"],[1,"admin-messaging__section-title"],[1,"admin-messaging__hint"],[1,"admin-messaging__row"],[1,"admin-messaging__steps"],[1,"admin-messaging__token"],["role","alert",1,"admin-messaging__error"],[1,"admin-messaging__bot"],[1,"admin-messaging__status"],[1,"admin-messaging__note"],[1,"admin-messaging__spacer"],["type","button",1,"admin-messaging__btn",3,"click"],["type","button",1,"admin-messaging__btn"],["type","button",1,"admin-messaging__btn","admin-messaging__btn--danger",3,"click","disabled"],[1,"admin-messaging__token",3,"submit"],["for","admin-messaging-token",1,"admin-messaging__label"],["id","admin-messaging-token","type","password","name","token","autocomplete","off","placeholder","123456789:AA\u2026",1,"admin-messaging__input",3,"input","value"],["type","submit",1,"admin-messaging__btn","admin-messaging__btn--primary",3,"disabled"]],template:function(e,o){if(e&1&&(Gu(0,"div",0)(1,"h1",1),fC(2,"Messaging"),Wu(),Gu(3,"section",2)(4,"h2",3),fC(5),Wu(),Gu(6,"p",4),fC(7),Wu(),Ew(8,V,13,7,"div",5)(9,z,7,1,"ol",6),Ew(10,B,6,3,"form",7),Ew(11,L,2,1,"p",8),Wu()()),e&2){let t,p;EE(5),Yu("",o.platformName," bot manager"),EE(2),dg(" The bot manager creates the ",o.platformName," bots of agents for the admins of their namespace: on an agent's page, Create a bot opens ",o.platformName,", the admin confirms, and the bot answers as the agent. Nobody copies a token. Without a bot manager, an agent can still get a bot created with @BotFather, from its token. "),EE(),Iw((t=o.manager())?8:9,t),EE(2),Iw(!o.manager()||o.replacing()?10:-1),EE(),Iw((p=o.error())?11:-1,p);}},dependencies:[Qb],styles:[".admin-messaging[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.admin-messaging__title[_ngcontent-%COMP%]{margin:0;font-family:var(--font-heading);font-size:1.25rem;font-weight:600;color:var(--color-text)}.admin-messaging__hint[_ngcontent-%COMP%], .admin-messaging__note[_ngcontent-%COMP%]{margin:0;font-size:.8125rem;color:var(--color-text-secondary)}.admin-messaging__warning[_ngcontent-%COMP%]{margin:0;font-size:.8125rem;color:var(--color-warning, #b26a00)}.admin-messaging__error[_ngcontent-%COMP%]{margin:0;font-size:.8125rem;color:var(--color-error, #c62828)}.admin-messaging__row[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.admin-messaging__spacer[_ngcontent-%COMP%]{flex:1}.admin-messaging__bot[_ngcontent-%COMP%]{font-family:var(--font-mono, monospace);font-size:.9375rem;color:var(--color-accent);text-decoration:none}.admin-messaging__bot[_ngcontent-%COMP%]:hover{text-decoration:underline}.admin-messaging__status[_ngcontent-%COMP%]{padding:.1rem .5rem;border:1px solid var(--color-divider);border-radius:var(--radius-sm, 0);font-size:.75rem;font-weight:600}.admin-messaging__status--ok[_ngcontent-%COMP%]{border-color:var(--color-success, #2e7d32);color:var(--color-success, #2e7d32)}.admin-messaging__status--off[_ngcontent-%COMP%]{color:var(--color-text-secondary)}.admin-messaging__status--warn[_ngcontent-%COMP%]{border-color:var(--color-warning, #b26a00);color:var(--color-warning, #b26a00)}.admin-messaging__token[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem}.admin-messaging__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text-secondary)}.admin-messaging__input[_ngcontent-%COMP%]{flex:1;min-width:16rem;padding:.4rem .6rem;border:1px solid var(--color-divider);border-radius:var(--radius-sm, 0);background:var(--color-bg);color:var(--color-text);font-family:var(--font-mono, monospace);font-size:.875rem}.admin-messaging__btn[_ngcontent-%COMP%]{padding:.4rem .9rem;border:1px solid var(--color-divider);border-radius:var(--radius-sm, 0);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;text-decoration:none;cursor:pointer}.admin-messaging__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.admin-messaging__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:default}.admin-messaging__btn--primary[_ngcontent-%COMP%]{border-color:var(--color-accent);color:var(--color-accent)}.admin-messaging__btn--danger[_ngcontent-%COMP%]{border-color:var(--color-error, #c62828);color:var(--color-error, #c62828)}.admin-messaging__section[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.75rem}.admin-messaging__section-title[_ngcontent-%COMP%]{margin:0;font-family:var(--font-heading);font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.12em;color:var(--color-neutral-500);border-bottom:1px solid var(--color-divider);padding-bottom:.5rem}.admin-messaging__steps[_ngcontent-%COMP%]{margin:0;padding-left:1.25rem;font-size:.875rem;color:var(--color-text);line-height:1.6}"]})};export{D as AdminMessagingComponent};
@@ -0,0 +1 @@
1
+ import {e}from'./chunk-C6dIhkYp.js';import {O as O$1}from'./chunk-BT-f7pOo.js';import {g,W,w as we,M as Mi,x as U,J as JI,o as os,H as Hh,E as Ew,z as zu,a as EE,I as Iw,f as fC,P as Pw,l as lg}from'./main-63IEQS3X.js';import {b as hn,c as fn,r as rn,E as pn,o as ln,n as Fo}from'./chunk-CCZ1b0na.js';import'./chunk-CVAz4Lko.js';function O(r,e){r&1&&(os(0,"p",1),fC(1,"Loading integration\u2026"),zu());}function T(r,e){r&1&&(os(0,"ds-notice"),fC(1,"Failed to load this integration configuration."),zu());}function L(r,e){r&1&&(os(0,"div",3)(1,"ds-tag",9),fC(2,"YAML"),zu(),os(3,"ds-tag",10),fC(4,"Read-only"),zu()());}function k(r,e){if(r&1&&(os(0,"ds-card",2),Ew(1,L,5,0,"div",3),os(2,"dl",4)(3,"dt"),fC(4,"Name"),zu(),os(5,"dd"),fC(6),zu(),os(7,"dt"),fC(8,"Type"),zu(),os(9,"dd",5),fC(10),zu(),os(11,"dt"),fC(12,"Description"),zu(),os(13,"dd"),fC(14),zu(),os(15,"dt"),fC(16,"Scope"),zu(),os(17,"dd"),fC(18),zu(),os(19,"dt"),fC(20,"Source"),zu(),os(21,"dd"),fC(22),zu(),os(23,"dt"),fC(24,"Auto grant"),zu(),os(25,"dd"),fC(26),zu(),os(27,"dt"),fC(28,"Auth setting"),zu(),os(29,"dd"),fC(30),zu()()(),os(31,"ds-card",6)(32,"p",7),fC(33,"Sensitive values are always redacted."),zu(),os(34,"pre",8),fC(35),zu()()),r&2){let o=e,a=Pw();EE(),Iw(a.source()==="FILESYSTEM"?1:-1),EE(5),lg(o.name),EE(4),lg(o.integrationType),EE(4),lg(o.description||"\u2014"),EE(4),lg(a.scopeOf(o)),EE(4),lg(a.source()),EE(4),lg(o.autoGrant?"Enabled":"Disabled"),EE(4),lg(o.authSettingName||"None"),EE(5),lg(a.parameters());}}var w="\u2022\u2022\u2022\u2022\u2022\u2022",A=/(?:api[-_]?key|token|secret|password|passphrase|credential|private[-_]?key|client[-_]?secret|authorization|cookie)/i,V=class r{route=g(W);destroyRef=g(we);state=g(O$1);integrationId=this.route.snapshot.params.integrationId;isLoading=Mi(true);hasError=Mi(false);config=Mi(null);source=Mi("NEO4J");parameters=Mi("{}");ngOnInit(){this.state.getById(this.integrationId).pipe(U(this.destroyRef)).subscribe({next:e$1=>{this.config.set(e$1),this.source.set(e(e$1)),this.parameters.set(JSON.stringify(this.redact(e$1.parameters),null,2)),this.isLoading.set(false);},error:()=>{this.hasError.set(true),this.isLoading.set(false);}});}scopeOf(e){let o=e.userId?e.namespaceId?"userOnNs":"userGlobal":e.namespaceId?"namespace":"platform";return {platform:"Platform",namespace:"Namespace",userOnNs:"Personal on namespace",userGlobal:"Personal global"}[o]}redact(e,o=""){return A.test(o)?w:e===null||typeof e=="boolean"||typeof e=="number"?e:typeof e=="string"?this.containsCredential(e)?w:e:Array.isArray(e)?e.map(a=>this.redact(a,o)):typeof e=="object"?Object.fromEntries(Object.entries(e).map(([a,m])=>[a,this.redact(m,a)])):String(e??"")}containsCredential(e){return /^(?:bearer\s+|basic\s+|sk[-_]|gh[opusr]_|xox[baprs]-|-----begin (?:rsa |ec |openssh )?private key-----)/i.test(e.trim())}static \u0275fac=function(o){return new(o||r)};static \u0275cmp=JI({type:r,selectors:[["agentos-integration-config-view"]],decls:5,vars:1,consts:[["title","Integration configuration"],["role","status",1,"ds-hint"],["heading","General"],[1,"settings-table__tags"],["dsDefinitionList",""],[1,"ds-mono"],["heading","Parameters"],[1,"ds-hint"],[1,"ds-pre"],["variant","neutral"],["variant","outline"]],template:function(o,a){if(o&1&&(os(0,"ds-page"),Hh(1,"ds-section-header",0),Ew(2,O,2,0,"p",1)(3,T,2,0,"ds-notice")(4,k,36,9),zu()),o&2){let m;EE(2),Iw(a.isLoading()?2:a.hasError()?3:(m=a.config())?4:-1,m);}},dependencies:[hn,fn,rn,pn,ln,Fo],encapsulation:2})};export{V as IntegrationConfigViewComponent};
@@ -0,0 +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};
@@ -0,0 +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})};
2
+ export{ne as NamespaceGitComponent};
@@ -0,0 +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};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-1nyEsjkY.js';import {o}from'./chunk-Jcjs0qUP.js';import {J as s,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,F,w as we,a3 as vr,M as Mi,a5 as Ys,ag as Gm,a6 as Zs,ae as Dr,ah as te$1,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,$ as dg,n as Aw,q as Pd,L as Ld,d as Bh}from'./main-63IEQS3X.js';var Y=(n,e)=>e.key;function Z(n,e){if(n&1&&(os(0,"p",3),fC(1),zu()),n&2){let t=Pw();EE(),lg(t.deletion.error());}}function ee(n,e){n&1&&(os(0,"p",4),fC(1,"Loading skills\u2026"),zu());}function te(n,e){n&1&&(os(0,"p",5),fC(1," No skills defined yet. Add one above, or drop a SKILL.md under the namespace config path. "),zu());}function ne(n,e){n&1&&(os(0,"p",4),fC(1,"No skills match the current filter."),zu());}function ie(n,e){if(n&1&&(os(0,"span",14),fC(1),zu()),n&2){let t=Pw().$implicit;EE(),dg(" named by ",t.namedByAgents," ",t.namedByAgents===1?"agent":"agents"," ");}}function ae(n,e){n&1&&(os(0,"ds-tag",20),fC(1,"Read-only"),zu());}function oe(n,e){n&1&&(os(0,"ds-tag",21),fC(1,"SKILL.md"),zu());}function le(n,e){if(n&1){let t=Aw();os(0,"button",25),qh("click",function(){Pd(t);let d=Pw(2).$implicit,c=Pw(2);return Ld(c.edit(d))}),fC(1,"Edit"),zu();}if(n&2){let t=Pw(2).$implicit;Bh("aria-label","Edit "+t.skill.name);}}function re(n,e){if(n&1){let t=Aw();os(0,"button",25),qh("click",function(){Pd(t);let d=Pw().$implicit,c=Pw(2);return Ld(c.inspect(d))}),fC(1," View "),zu(),Ew(2,le,2,1,"button",26);}if(n&2){let t=Pw().$implicit,a=Pw(2);Bh("aria-label","View "+t.skill.name),EE(2),Iw(a.isMutable(t)?2:-1);}}function se(n,e){if(n&1){let t=Aw();os(0,"agentos-row-delete-action",27),qh("deleteRequested",function(){Pd(t);let d=Pw().$implicit,c=Pw(2);return Ld(c.requestDelete(d))})("deleteConfirmed",function(){Pd(t);let d=Pw().$implicit,c=Pw(2);return Ld(c.confirmDelete(d))})("deleteCancelled",function(){Pd(t);let d=Pw(3);return Ld(d.deletion.cancel())}),zu();}if(n&2){let t=Pw().$implicit,a=Pw(2);Vh("rowKey",t.key)("rowLabel",t.skill.name)("state",a.deletion);}}function ce(n,e){if(n&1&&(os(0,"tr",9)(1,"td",12)(2,"span",13),fC(3),zu(),Ew(4,ie,2,2,"span",14),zu(),os(5,"td",15),fC(6),zu(),os(7,"td",16),fC(8),zu(),os(9,"td",17)(10,"div",18)(11,"ds-tag",19),fC(12),zu(),Ew(13,ae,2,0,"ds-tag",20),Ew(14,oe,2,0,"ds-tag",21),zu()(),os(15,"td",22)(16,"div",23),Ew(17,re,3,2),Ew(18,se,1,3,"agentos-row-delete-action",24),zu()()()),n&2){let t=e.$implicit,a=Pw(2);EE(3),lg(t.skill.name),EE(),Iw(t.namedByAgents>0?4:-1),EE(2),Yu(" ",t.skill.description||"\u2014"," "),EE(2),lg(a.resourceCount(t.skill)),EE(3),Vh("variant",t.scope==="platform"?"neutral":"accent"),EE(),lg(t.scope==="platform"?"Platform":"Namespace"),EE(),Iw(t.scope==="platform"?13:-1),EE(),Iw(t.skill.readOnly?14:-1),EE(3),Iw(a.deletion.confirmingId()!==t.key?17:-1),EE(),Iw(a.isMutable(t)?18:-1);}}function de(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,"Resources"),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,ce,19,10,"tr",9,Y),zu()()()),n&2){let t=Pw();EE(16),Tw(t.rowFilter.filteredRows());}}var Q=class n{route=g(W);router=g(F);destroyRef=g(we);skillState=g(o);agentState=g(s);namespaceId=this.route.snapshot.params.namespaceId;refresh$=new vr(void 0);isLoading=Mi(true);deletion=k();rows=Mi([]);rowFilter=O(this.rows,e=>[e.skill.name,e.skill.description,e.scope].filter(Boolean).join(" "));constructor(){this.refresh$.pipe(Ys(()=>(this.isLoading.set(true),Gm({platform:this.skillState.listPlatform().pipe(Zs(()=>Dr([]))),namespace:this.skillState.listByNamespace(this.namespaceId),agents:Gm({namespace:this.agentState.listByNamespace(this.namespaceId),platform:this.agentState.listPlatform().pipe(Zs(()=>Dr([])))}).pipe(te$1(({namespace:e,platform:t})=>[...e,...t]),Zs(()=>Dr([])))}))),U(this.destroyRef)).subscribe({next:({platform:e,namespace:t,agents:a$1})=>{let d=(c,_,W)=>({key:`${_}:${c.id??W}`,skill:c,scope:_,namedByAgents:a$1.filter(X=>a(X.skillSelectors,c.name)==="named").length});this.rows.set([...e.map((c,_)=>d(c,"platform",_)),...t.map((c,_)=>d(c,"namespace",_))]),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}resourceCount(e){return Object.keys(e.resources??{}).length}isMutable(e){return e.scope==="namespace"&&e.skill.readOnly!==true&&!!e.skill.id}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"skills","new"]);}inspect(e){e.skill.id&&this.router.navigate(e.scope==="platform"?["/agentos","admin","skills",e.skill.id,"inspect"]:["/agentos",this.namespaceId,"skills",e.skill.id,"inspect"]);}edit(e){!this.isMutable(e)||!e.skill.id||this.router.navigate(["/agentos",this.namespaceId,"skills",e.skill.id,"edit"]);}requestDelete(e){this.deletion.request(e.key);}confirmDelete(e){if(!this.isMutable(e)||!e.skill.id)return;let t=e.namedByAgents;this.deletion.execute(e.key,{request$:this.skillState.delete(e.skill.id).pipe(U(this.destroyRef)),onSuccess:()=>this.refresh$.next(),errorMessage:a=>a.status===400?`"${e.skill.name}" is defined by a SKILL.md file and cannot be deleted through the API.`:`Deleting "${e.skill.name}" failed.${t>0?` ${t} agent(s) still name it.`:""}`});}static \u0275fac=function(t){return new(t||n)};static \u0275cmp=JI({type:n,selectors:[["agentos-namespace-skills"]],decls:9,vars:3,consts:[["title","Skills","description","Skills available in this namespace, including skills inherited from the platform."],["label","Filter skills","placeholder","Filter skills\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","Skills"],["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","Description",1,"settings-table__secondary"],["role","cell","data-label","Resources"],["role","cell","data-label","Scope"],[1,"settings-table__tags"],[3,"variant"],["variant","outline"],["variant","neutral"],["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,a){t&1&&(os(0,"ds-section-header",0)(1,"agentos-table-filter",1),qh("queryChange",function(c){return a.rowFilter.query.set(c)}),zu(),os(2,"button",2),qh("click",function(){return a.openCreateForm()}),fC(3,"New skill"),zu()(),Ew(4,Z,2,1,"p",3),Ew(5,ee,2,0,"p",4)(6,te,2,0,"p",5)(7,ne,2,0,"p",4)(8,de,18,0,"div",6)),t&2&&(EE(),Vh("query",a.rowFilter.query()),EE(3),Iw(a.deletion.error()?4:-1),EE(),Iw(a.isLoading()?5:a.rows().length===0?6:a.rowFilter.filteredRows().length===0?7:8));},dependencies:[at,fn,ko,Fo,P,P$1],encapsulation:2})};export{Q as NamespaceSkillsComponent};
@@ -0,0 +1 @@
1
+ import {ae as N,b as hn,c as fn,u as un,d as cn,E as pn,e as at,i as sn}from'./chunk-CCZ1b0na.js';import {g,W,F,a_ as D,ak as U,w as we,M as Mi,x as U$1,B,a$ as Fm,J as JI,o as os,Q as qh,f as fC,z as zu,H as Hh,E as Ew,a as EE,N as Vh,I as Iw,Y as Yu,P as Pw,l as lg}from'./main-63IEQS3X.js';function P(l,t){if(l&1&&(os(0,"ds-notice"),fC(1),zu()),l&2){let n=Pw();EE(),lg(n.launchError());}}var T=class l{route=g(W);router=g(F);caseController=g(D);caseState=g(N);agentConfigController=g(U);destroyRef=g(we);namespaceId=this.route.snapshot.params.namespaceId;agentConfigId=this.route.snapshot.params.agentConfigId;resolvedAgentConfig=null;payloadJson=Mi("");launchError=Mi(null);isLaunching=Mi(false);isLoading=Mi(false);ngOnInit(){this.isLoading.set(true),this.agentConfigController.getByIdAgentConfig(this.agentConfigId).pipe(U$1(this.destroyRef)).subscribe({next:t=>{this.resolvedAgentConfig=t,t.loopConfig!=null&&this.payloadJson.set(JSON.stringify(t.loopConfig,null,2)),this.isLoading.set(false);},error:()=>{this.isLoading.set(false);}});}launch(){return B(this,null,function*(){this.launchError.set(null),this.isLaunching.set(true);try{let t=this.resolvedAgentConfig??(yield Fm(this.agentConfigController.getByIdAgentConfig(this.agentConfigId))),n=yield Fm(this.caseController.createCase({namespaceId:this.namespaceId}));this.caseState.addCase(n);let e=n.id??"",d={content:`@${t.name} start`};yield Fm(this.caseController.addMessageCase(e,d)),this.router.navigate(["/agentos/home"],{queryParams:{ns:this.namespaceId,case:e}});}catch(t){console.error("[AgentConfigLaunch] Failed to launch loop agent",t),this.launchError.set("Failed to launch the agent loop. Please check the console for details."),this.isLaunching.set(false);}})}back(){this.router.navigate(["/agentos",this.namespaceId,"agent-configs",this.agentConfigId,"edit"]);}static \u0275fac=function(n){return new(n||l)};static \u0275cmp=JI({type:l,selectors:[["agentos-agent-config-launch"]],decls:17,vars:6,consts:[["title","Launch loop agent"],["dsButton","","variant","ghost","type","button","title","Back to agent config",3,"click"],[1,"ds-hint"],["label","Loop configuration (read-only)","controlId","agent-loop-payload"],["dsControl","","mono","","id","agent-loop-payload","rows","15","readonly","","spellcheck","false","autocomplete","off",3,"value","disabled"],["dsButton","","variant","primary","type","button",3,"click","disabled"],["dsButton","","type","button",3,"click","disabled"]],template:function(n,e){n&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return e.back()}),fC(3," \u2190 Edit agent config "),zu()(),os(4,"p",2),fC(5," The loop configuration below is read from "),os(6,"code"),fC(7,"AgentConfig.loopConfig"),zu(),fC(8," and will be used by the backend when the agent loop starts. A new Case will be created and one child case will be launched per entity found. "),zu(),os(9,"ds-form-field",3),Hh(10,"textarea",4),zu(),Ew(11,P,2,1,"ds-notice"),os(12,"ds-form-actions")(13,"button",5),qh("click",function(){return e.launch()}),fC(14),zu(),os(15,"button",6),qh("click",function(){return e.back()}),fC(16,"Cancel"),zu()()()),n&2&&(EE(10),Vh("value",e.payloadJson())("disabled",e.isLaunching()||e.isLoading()),EE(),Iw(e.launchError()?11:-1),EE(2),Vh("disabled",e.isLaunching()),EE(),Yu(" ",e.isLaunching()?"Launching\u2026":"Launch"," "),EE(),Vh("disabled",e.isLaunching()));},dependencies:[hn,fn,un,cn,pn,at,sn],encapsulation:2})};export{T as AgentConfigLaunchComponent};
@@ -0,0 +1 @@
1
+ import {G as m,p as pt,L as Lt,T as Te,g as gn,q as qt,m as md,C as Co,M as Mo,H as Ht,U as Ut,a as po,h as ho,A as An,O as On,w as wa,_ as _o,I as vo,b as hn,c as fn,u as un,t as dn,d as cn,E as pn,e as at,i as sn}from'./chunk-CCZ1b0na.js';import {g,W,F,w as we,ak as U,M as Mi,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,aq as ww,P as Pw,S as dI,l as lg,T as Tw,d as Bh,q as Pd,L as Ld}from'./main-63IEQS3X.js';var ce=(o,t)=>t.id;function ue(o,t){o&1&&(os(0,"p",2),fC(1,"Loading\u2026"),zu());}function fe(o,t){if(o&1&&(os(0,"ds-form-field",20),Hh(1,"input",22),zu()),o&2){let e=Pw(3);EE(),Vh("value",e.resolveAgentConfigName(e.agentConfigIdControl.value));}}function ge(o,t){if(o&1&&(os(0,"option",24),fC(1),zu()),o&2){let e=t.$implicit;Vh("ngValue",e.id),EE(),lg(e.name);}}function Ce(o,t){if(o&1&&(os(0,"ds-form-field",21)(1,"select",23)(2,"option",24),fC(3,"\u2014 None \u2014"),zu(),bw(4,ge,2,2,"option",24,ce),zu(),uI(),zu()),o&2){let e=Pw(3);EE(),Vh("formControl",e.agentConfigIdControl),dI(),EE(),Vh("ngValue",null),EE(2),Tw(e.availableAgentConfigs());}}function ye(o,t){if(o&1&&Ew(0,fe,2,1,"ds-form-field",20)(1,Ce,6,2,"ds-form-field",21),o&2){let e=Pw(2);Iw(e.isEditMode()&&e.agentConfigIdControl.value?0:e.isEditMode()?-1:1);}}function ve(o,t){o&1&&(os(0,"p",2),fC(1,"No parameters defined."),zu());}function he(o,t){if(o&1){let e=Aw();os(0,"div",11)(1,"div",25)(2,"ds-form-field",26),Hh(3,"input",27),uI(),zu(),os(4,"ds-form-field",28),Hh(5,"input",29),uI(),zu(),os(6,"ds-form-field",30),Hh(7,"input",31),uI(),zu()(),os(8,"button",32),qh("click",function(){let d=Pd(e).$index,m=Pw(2);return Ld(m.removeParameter(d))}),fC(9," \xD7 "),zu()();}if(o&2){let e=t.$implicit,r=t.$index;Vh("formGroupName",r),EE(2),Vh("controlId","param-name-"+r)("error",e.controls.name.invalid&&e.controls.name.touched?"Parameter name is required.":null),EE(),Vh("id","param-name-"+r),dI(),EE(),Vh("controlId","param-desc-"+r),EE(),Vh("id","param-desc-"+r),dI(),EE(),Vh("controlId","param-default-"+r),EE(),Vh("id","param-default-"+r),dI();}}function _e(o,t){if(o&1){let e=Aw();os(0,"div",14)(1,"span",33),fC(2),zu(),os(3,"ds-form-field",34),Hh(4,"textarea",35),uI(),zu(),os(5,"button",36),qh("click",function(){let d=Pd(e).$index,m=Pw(2);return Ld(m.removeContentEntry(d))}),fC(6," \xD7 "),zu()();}if(o&2){let e=t.$implicit,r=t.$index,d=Pw(2);EE(2),lg(r+1),EE(),Vh("error",e.invalid&&e.touched?"Content entry must not be blank.":null),EE(),Vh("formControlName",r),Bh("aria-label","Content entry "+(r+1)),dI(),EE(),Vh("disabled",d.contentArray.length===1);}}function xe(o,t){if(o&1&&(os(0,"ds-notice"),fC(1),zu()),o&2){let e=Pw(2);EE(),lg(e.errorMessage());}}function be(o,t){if(o&1){let e=Aw();os(0,"button",37),qh("click",function(){Pd(e);let d=Pw(2);return Ld(d.exportYaml())}),fC(1),zu();}if(o&2){let e=Pw(2);Vh("disabled",e.isExporting()),EE(),Yu(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function Ee(o,t){if(o&1){let e=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(e);let d=Pw();return Ld(d.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,ye,2,1),os(6,"ds-fieldset",9)(7,"p",2),fC(8," Each parameter must have a name and a default value. Use "),os(9,"code"),fC(10),zu(),fC(11," in content entries to reference them. "),zu(),os(12,"div",10),Ew(13,ve,2,0,"p",2),bw(14,he,10,8,"div",11,ww),os(16,"div")(17,"button",12),qh("click",function(){Pd(e);let d=Pw();return Ld(d.addParameter())}),fC(18,"+ Add parameter"),zu()()()(),os(19,"ds-fieldset",13)(20,"p",2),fC(21," Each content entry is a command. Use "),os(22,"code"),fC(23,"@AgentName"),zu(),fC(24," to target an agent, "),os(25,"code"),fC(26,"/promptName param1 param2"),zu(),fC(27," to call another prompt, and "),os(28,"code"),fC(29),zu(),fC(30," for parameter placeholders. "),zu(),os(31,"div",10),bw(32,_e,7,5,"div",14,ww),os(34,"div")(35,"button",12),qh("click",function(){Pd(e);let d=Pw();return Ld(d.addContentEntry())}),fC(36,"+ Add content entry"),zu()()()(),Ew(37,xe,2,1,"ds-notice"),os(38,"ds-form-field",15),Hh(39,"textarea",16),uI(),zu(),os(40,"ds-form-actions")(41,"button",17),fC(42),zu(),Ew(43,be,2,2,"button",18),os(44,"button",19),qh("click",function(){Pd(e);let d=Pw();return Ld(d.cancel())}),fC(45,"Cancel"),zu()()();}if(o&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.availableAgentConfigs().length>0?5:-1),EE(5),lg(e.paramPlaceholderSyntax),EE(2),Vh("formArrayName","parameters"),EE(),Iw(e.parametersArray.length===0?13:-1),EE(),Tw(e.parametersArray.controls),EE(15),lg(e.paramPlaceholderSyntax),EE(2),Vh("formArrayName","content"),EE(),Tw(e.contentArray.controls),EE(5),Iw(e.errorMessage()?37:-1),EE(),Vh("error",e.externalMetadataJsonControl.invalid&&e.externalMetadataJsonControl.touched?"Invalid JSON.":null),EE(),Vh("formControl",e.externalMetadataJsonControl),dI(),EE(2),Vh("disabled",e.form.invalid||e.isSubmitting()),EE(),Yu(" ",e.isEditMode()?"Save changes":"Create"," "),EE(),Iw(e.isEditMode()?43:-1);}}var pe=class o{route=g(W);router=g(F);destroyRef=g(we);promptState=g(m);agentConfigController=g(U);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new pt({name:new Te("",{nonNullable:true,validators:[gn.required,gn.minLength(1)]}),description:new Te(null),agentConfigId:new Te(null),externalMetadataJson:new Te("",{nonNullable:true,validators:[Pe]}),content:new Lt([this.createContentControl()],{validators:[gn.required]}),parameters:new Lt([])});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get agentConfigIdControl(){return this.form.controls.agentConfigId}get externalMetadataJsonControl(){return this.form.controls.externalMetadataJson}get contentArray(){return this.form.controls.content}get parametersArray(){return this.form.controls.parameters}isEditMode=Mi(false);isSubmitting=Mi(false);isLoading=Mi(false);isExporting=Mi(false);errorMessage=Mi(null);paramPlaceholderSyntax="{{paramName}}";agentConfigs=Mi([]);availableAgentConfigs=this.agentConfigs.asReadonly();existingPrompt=null;ngOnInit(){let t=this.route.snapshot.paramMap.get("promptId");t&&(this.isEditMode.set(true),this.loadPrompt(t)),this.isPlatformMode?this.loadPlatformAgentConfigs():this.namespaceId&&this.loadAgentConfigs(this.namespaceId);}loadPrompt(t){this.isLoading.set(true),this.promptState.getById(t).pipe(U$1(this.destroyRef)).subscribe({next:e=>{this.existingPrompt=e,this.hydrateForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}loadAgentConfigs(t){this.agentConfigController.listByParentAgentConfig(t).pipe(U$1(this.destroyRef),Zs(()=>Dr([]))).subscribe(e=>this.agentConfigs.set(e));}loadPlatformAgentConfigs(){this.agentConfigController.listPlatformAgentsAgentConfig().pipe(U$1(this.destroyRef),Zs(()=>Dr([]))).subscribe(t=>this.agentConfigs.set(t));}hydrateForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.agentConfigIdControl.setValue(t.agentConfigId??null),this.contentArray.clear(),(t.content.length>0?t.content:[""]).forEach(r=>this.contentArray.push(this.createContentControl(r))),this.parametersArray.clear(),(t.parameters??[]).forEach(r=>this.parametersArray.push(this.createParameterGroup(r))),this.externalMetadataJsonControl.setValue(t.externalMetadata?JSON.stringify(t.externalMetadata,null,2):"");}resolveAgentConfigName(t){return this.agentConfigs().find(e=>e.id===t)?.name??t}createContentControl(t=""){return new Te(t,{nonNullable:true,validators:[gn.required,gn.pattern(/\S/)]})}addContentEntry(){this.contentArray.push(this.createContentControl());}removeContentEntry(t){this.contentArray.length>1&&this.contentArray.removeAt(t);}createParameterGroup(t){return new pt({name:new Te(t?.name??"",{nonNullable:true,validators:[gn.required,gn.minLength(1)]}),description:new Te(t?.description??null),defaultValue:new Te(t?.defaultValue??"",{nonNullable:true,validators:[gn.required]})})}addParameter(){this.parametersArray.push(this.createParameterGroup());}removeParameter(t){this.parametersArray.removeAt(t);}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true);let t=this.isEditMode()&&!!this.existingPrompt?.id,e=x(w({},this.existingPrompt??{}),{namespaceId:this.namespaceId,sourceLanguage:this.existingPrompt?.sourceLanguage??"en",name:this.nameControl.value.trim(),description:this.descriptionControl.value?.trim()||void 0,content:this.contentArray.controls.map(m=>m.value.trim()),parameters:this.parametersArray.controls.map(m=>({name:m.controls.name.value.trim(),description:m.controls.description.value?.trim()||void 0,defaultValue:m.controls.defaultValue.value.trim()}))});t||(e.agentConfigId=this.agentConfigIdControl.value||null);let r=this.externalMetadataJsonControl.value.trim();e.externalMetadata=r?JSON.parse(r):null;let d=t?this.promptState.update(this.existingPrompt.id,e):this.promptState.create(e);this.errorMessage.set(null),d.pipe(U$1(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:m=>{this.isSubmitting.set(false),m.status===409?this.errorMessage.set(`A prompt named "${e.name}" already exists in this scope.`):m.status===400?this.errorMessage.set(m.error?.message??"Invalid prompt data."):this.errorMessage.set("An unexpected error occurred. Please try again.");}});}exportYaml(){let t=this.existingPrompt?.id;!t||this.isExporting()||(this.isExporting.set(true),this.promptState.exportAsYaml(t).pipe(U$1(this.destroyRef)).subscribe({next:e=>{let r=new Blob([e],{type:"application/yaml"}),d=URL.createObjectURL(r),m=document.createElement("a");m.href=d,m.download=`${this.existingPrompt?.name??"prompt"}.yaml`,m.click(),URL.revokeObjectURL(d),this.isExporting.set(false);},error:()=>this.isExporting.set(false)}));}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","prompts"]):this.router.navigate(["/agentos",this.namespaceId,"prompts"]);}static \u0275fac=function(e){return new(e||o)};static \u0275cmp=JI({type:o,selectors:[["agentos-prompt-form"]],decls:6,vars:3,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to prompts",3,"click"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["label","Name","controlId","prompt-name","required","",3,"error"],["dsControl","","id","prompt-name","type","text","placeholder","e.g. Summarise meeting notes","autocomplete","off",3,"formControl"],["label","Description","controlId","prompt-description"],["dsControl","","id","prompt-description","type","text","placeholder","Optional \u2014 short description of this prompt","autocomplete","off",3,"formControl"],["legend","Parameters","legendHint","Named placeholders used in content"],[1,"ds-stack",3,"formArrayName"],[1,"ds-panel","ds-inline","ds-inline--start",3,"formGroupName"],["dsButton","","variant","ghost","type","button",3,"click"],["legend","Content","legendHint","Ordered list of text commands"],[1,"ds-inline","ds-inline--start"],["label","External Metadata","controlId","prompt-external-metadata","hint","Optional. Opaque JSON object stored as-is. Leave empty to clear.",3,"error"],["dsControl","","mono","","id","prompt-external-metadata","rows","6","placeholder",'{ "key": "value" }',"spellcheck","false","autocomplete","off",3,"formControl"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"disabled"],["dsButton","","type","button",3,"click"],["label","Agent Config","hint","Agent Config cannot be changed after creation."],["label","Agent Config","controlId","prompt-agent-config","hint","Optional. Links this prompt to an agent as a starter. Immutable after creation."],["dsControl","","type","text","readonly","",3,"value"],["dsControl","","id","prompt-agent-config",3,"formControl"],[3,"ngValue"],[1,"ds-stack","ds-grow"],["label","Name","required","",3,"controlId","error"],["dsControl","","type","text","placeholder","e.g. language","formControlName","name","autocomplete","off",3,"id"],["label","Description",3,"controlId"],["dsControl","","type","text","placeholder","Optional","formControlName","description","autocomplete","off",3,"id"],["label","Default value",3,"controlId"],["dsControl","","type","text","placeholder","e.g. English","formControlName","defaultValue","autocomplete","off",3,"id"],["dsButton","","variant","icon-danger","type","button","title","Remove this parameter","aria-label","Remove this parameter",3,"click"],[1,"ds-index"],["grow","",3,"error"],["dsControl","","rows","4","placeholder","Enter a command\u2026",3,"formControlName"],["dsButton","","variant","icon-danger","type","button","title","Remove this entry","aria-label","Remove this entry",3,"click","disabled"],["dsButton","","type","button",3,"click","disabled"]],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),zu()(),Ew(4,ue,2,0,"p",2)(5,Ee,46,16,"form",3),zu()),e&2&&(EE(),Vh("title",r.isEditMode()?"Edit prompt":"New prompt"),EE(2),Yu(" \u2190 ",r.isPlatformMode?"Platform prompts":"Prompts"," "),EE(),Iw(r.isLoading()?4:5));},dependencies:[qt,md,Co,Mo,Ht,Ut,po,ho,An,On,wa,_o,vo,hn,fn,un,dn,cn,pn,at,sn],encapsulation:2})};function Pe(o){let t=o.value?.trim();if(!t)return null;try{return JSON.parse(t),null}catch(e){return {invalidJson:true}}}export{pe as PromptFormComponent};
@@ -0,0 +1 @@
1
+ import {i}from'./chunk-CVAz4Lko.js';import {y}from'./chunk-CCZ1b0na.js';import {g as g$1,at as F,a3 as vr,aw as $m,a5 as Ys,a6 as Zs,ae as Dr,ah as te,aK as my,a9 as Hl,C as w,aa as k}from'./main-63IEQS3X.js';var g="none",N="me",O=class p{nsController=g$1(F);userState=g$1(y);refresh$=new vr(void 0);namespaceId$=new vr(null);vm$=$m([this.namespaceId$,this.refresh$]).pipe(Ys(([e])=>{let r=this.loadPlatformProviders().pipe(Zs(()=>Dr([])));return e?$m([r,this.loadNamespaceProviders(e).pipe(Zs(()=>Dr([]))),this.loadUserProviders(e).pipe(Zs(()=>Dr([]))),this.loadUserProviders("global").pipe(Zs(()=>Dr([])))]).pipe(te(([i,n,s,t])=>({platform:i,namespace:n,userOnNs:s,userGlobal:t}))):$m([r,this.loadNamespaceProviders("").pipe(Zs(()=>Dr([]))),this.loadUserProviders("global").pipe(Zs(()=>Dr([])))]).pipe(te(([i,n,s])=>({platform:i,namespace:n,userOnNs:[],userGlobal:s})))}),my({bufferSize:1,refCount:true}));setNamespace(e){this.namespaceId$.value!==e&&this.namespaceId$.next(e);}refresh(){this.refresh$.next();}loadUserProviders(e){let r=e==="global"?g:e;return this.nsController.listAiProvider(r,N)}userGlobal$=i(this.refresh$,()=>this.loadUserProviders("global"),[]);loadPlatformProviders(){return this.nsController.listAiProvider(g)}loadNamespaceProviders(e){return e?this.nsController.listAiProvider(e):Dr([])}getById(e,r){return this.nsController.getByIdAiProvider(e)}create(e,r,i){let s=this.userState.currentUser()?.id;if((r==="userOnNs"||r==="userGlobal")&&!s)throw new Error(`Cannot create ${r} provider before UserStateService.loadMe() resolves \u2014 call loadMe() at app init`);if(r==="namespace"){if(i===void 0||i==="")throw new Error("Cannot create namespace-scoped provider without a namespaceId");let S={name:e.name,apiType:e.apiType,description:e.description,baseUrl:e.baseUrl,apiKey:e.apiKey,headers:e.headers??void 0,namespaceId:i??void 0};return this.nsController.createAiProvider(S).pipe(Hl(()=>this.refresh()))}if(r==="userOnNs"&&!i)throw new Error("Cannot create userOnNs provider without a namespaceId");let t={name:e.name,apiType:e.apiType,description:e.description,baseUrl:e.baseUrl,apiKey:e.apiKey,headers:e.headers??void 0,userId:s,namespaceId:r==="userOnNs"?i:void 0};return this.nsController.createAiProvider(t).pipe(Hl(()=>this.refresh()))}update(e,r,i,n){let s=r.apiKey===null?{}:{apiKey:r.apiKey},t=w({name:r.name,apiType:r.apiType,description:r.description,baseUrl:r.baseUrl,headers:r.headers??void 0,namespaceId:n.namespaceId,userId:n.userId},s);return this.nsController.updateAiProvider(e,t).pipe(Hl(()=>this.refresh()))}delete(e,r){return this.nsController.deleteAiProvider(e).pipe(Hl(()=>this.refresh()))}static \u0275fac=function(r){return new(r||p)};static \u0275prov=k({token:p,factory:p.\u0275fac,providedIn:"root"})};export{O};
@@ -0,0 +1,2 @@
1
+ import {v}from'./chunk-Cvh22V1I.js';import {I,n as nt,i as it}from'./chunk-DQEn5_2f.js';import {g,W,F,w as we,M as Mi,ad as F$1,h as BC,s as sf,x as U,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,I as Iw,n as Aw,i as bw,as as Cw,R as uI,H as Hh,P as Pw,S as dI,T as Tw,Y as Yu,ai as vw,l as lg,d as Bh,q as Pd,L as Ld}from'./main-63IEQS3X.js';import {T as Te,g as gn,p as pt,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}from'./chunk-CCZ1b0na.js';import'./chunk-CVAz4Lko.js';function Ce(i,t){i&1&&(os(0,"p",2),fC(1,"Loading\u2026"),zu());}function ye(i,t){if(i&1&&(os(0,"label",16),Hh(1,"input",17),uI(),fC(2),zu()),i&2){let e=t.$implicit,n=Pw(3);EE(),Vh("formControl",n.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!n.isAdmin()),dI(),EE(),Yu(" ",e.label," ");}}function ge(i,t){if(i&1&&(os(0,"ds-fieldset",5),bw(1,ye,3,4,"label",16,vw().trackByScope,true),zu()),i&2){let e=Pw(2);Vh("disabled",e.isEditMode()),EE(),Tw(e.scopeOptions);}}function fe(i,t){if(i&1&&(os(0,"option",8),fC(1),zu()),i&2){let e=t.$implicit,n=Pw(2);Vh("value",e),EE(),lg(n.authTypeLabel[e]);}}function Se(i,t){if(i&1&&(os(0,"ds-form-field",18),Hh(1,"input",19),uI(),zu()),i&2){let e=Pw().$implicit;Vh("label",e.label)("controlId","as-cred-"+e.key)("required",e.required)("hint",e.hint??null)("hintId","as-hint-"+e.key),EE(),Vh("id","as-cred-"+e.key)("type",e.secret?"password":"text")("placeholder",e.placeholder)("formControl",t)("autocomplete",e.secret?"new-password":"off"),Bh("aria-describedby",e.hint?"as-hint-"+e.key:null),dI();}}function Ae(i,t){if(i&1&&Ew(0,Se,2,11,"ds-form-field",18),i&2){let e,n=t.$implicit,o=Pw(3);Iw((e=o.controlForField(n.key))?0:-1,e);}}function ve(i,t){if(i&1&&(os(0,"ds-fieldset",13),bw(1,Ae,1,1,null,null,vw().trackByField,true),zu()),i&2){let e=Pw(2);Vh("hint","Values are stored encrypted and masked on read."+(e.isEditMode()?" Leave a field unchanged to keep the stored credential.":"")),EE(),Tw(e.credentialFields());}}function be(i,t){if(i&1){let e=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(e);let o=Pw();return Ld(o.submit())}),Ew(1,ge,3,1,"ds-fieldset",5),os(2,"ds-form-field",6)(3,"select",7),bw(4,fe,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(),Ew(10,ve,3,1,"ds-fieldset",13),os(11,"ds-form-actions")(12,"button",14),fC(13),zu(),os(14,"button",15),qh("click",function(){Pd(e);let o=Pw();return Ld(o.cancel())}),fC(15,"Cancel"),zu()()();}if(i&2){let e=Pw();Vh("formGroup",e.form),EE(),Iw(e.isPlatformMode?-1:1),EE(2),Vh("formControl",e.authTypeControl),dI(),EE(),Tw(e.authTypeOptions),EE(3),Vh("formControl",e.nameControl),dI(),EE(2),Vh("formControl",e.descriptionControl),dI(),EE(),Iw(e.credentialFields().length>0?10:-1),EE(2),Vh("disabled",e.form.invalid||e.isSubmitting()),EE(),Yu(" ",e.isEditMode()?"Save changes":"Create"," ");}}var ke=new Set(["namespace","userOnNs","userGlobal"]),D=Object.freeze({platform:"Platform (read-only)",namespace:"Namespace configuration",userOnNs:"Personal \u2014 this namespace only",userGlobal:"Personal \u2014 all namespaces"}),_e={ApiKeyAuthSetting:[{key:"apiKey",label:"API Key",placeholder:"sk-\u2026",secret:true,required:false}],BasicAuthAuthSetting:[{key:"username",label:"Username",placeholder:"user@example.com",secret:false,required:false},{key:"password",label:"Password",placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",secret:true,required:false}],BearerTokenAuthSetting:[{key:"token",label:"Bearer token",placeholder:"eyJ\u2026",secret:true,required:false}],OAuthDiscoverableAuthSetting:[{key:"discoveryUrl",label:"Discovery URL",placeholder:"https://\u2026/.well-known/openid-configuration",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthCustomAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthRegisteredAuthSetting:[{key:"authorizationUrl",label:"Authorization URL",placeholder:"https://\u2026/authorize",secret:false,required:false},{key:"tokenUrl",label:"Token URL",placeholder:"https://\u2026/token",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Space-separated OAuth scopes to request (e.g. openid profile email). Check your provider's documentation for the exact values.",secret:false,required:false}],OAuthMcpDiscoverableAuthSetting:[{key:"resourceUrl",label:"Resource URL",placeholder:"https://mcp.example.com",hint:"Use the base URL exactly as documented by your provider \u2014 do not append a path suffix. Examples: https://mcp.hubspot.com (HubSpot), https://mcp.atlassian.com/v1/mcp (Atlassian).",secret:false,required:false},{key:"clientId",label:"Client ID",placeholder:"",hint:"Leave empty to let the server register an OAuth client automatically (RFC 7591 dynamic registration). Fill in only if you have a pre-registered client ID from your provider.",secret:false,required:false},{key:"clientSecret",label:"Client secret",placeholder:"",secret:true,required:false},{key:"scopes",label:"Scopes",placeholder:"",hint:"Leave empty in most cases \u2014 the MCP server declares the required scopes itself. Fill in only if your provider explicitly requires client-declared scopes.",secret:false,required:false}]},me=class i{route=g(W);router=g(F);destroyRef=g(we);state=g(I);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});authTypeOptions=nt;authTypeLabel=it;scopeOptions=[{value:"namespace",label:D.namespace},{value:"userOnNs",label:D.userOnNs},{value:"userGlobal",label:D.userGlobal}];nameControl=new Te("",{nonNullable:true,validators:[gn.required,gn.minLength(1)]});descriptionControl=new Te(null);authTypeControl=new Te("ApiKeyAuthSetting",{nonNullable:true,validators:[gn.required]});scopeControl=new Te("namespace",{nonNullable:true});form=new pt({name:this.nameControl,description:this.descriptionControl,authType:this.authTypeControl,scope:this.scopeControl});apiKeyControl=new Te("",{nonNullable:true});usernameControl=new Te("",{nonNullable:true});passwordControl=new Te("",{nonNullable:true});tokenControl=new Te("",{nonNullable:true});discoveryUrlControl=new Te("",{nonNullable:true});authorizationUrlControl=new Te("",{nonNullable:true});tokenUrlControl=new Te("",{nonNullable:true});clientIdControl=new Te("",{nonNullable:true});clientSecretControl=new Te("",{nonNullable:true});scopesControl=new Te("",{nonNullable:true});resourceUrlControl=new Te("",{nonNullable:true});selectedAuthType=F$1(this.authTypeControl.valueChanges,{initialValue:this.authTypeControl.value});credentialFields=BC(()=>_e[this.selectedAuthType()]);isEditMode=Mi(false);isSubmitting=Mi(false);isLoading=Mi(false);existingConfig=null;initialCredentials={};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,n=t.get("authSettingId");if(n){this.isEditMode.set(true),this.scopeControl.disable(),this.authTypeControl.disable(),this.loadConfig(n);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let o=this.parseScope(e.get("scope"));this.scopeControl.setValue(o);let v=e.get("template");v&&this.hydrateFromTemplate(v);}parseScope(t){return t&&ke.has(t)?t:"namespace"}deriveScopeFromConfig(t){return !t.userId&&!t.namespaceId?"platform":t.userId?t.namespaceId?"userOnNs":"userGlobal":"namespace"}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(`[AuthSettingForm] Could not load auth setting '${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.authTypeControl.setValue(e.authType),this.clearCredentialControls(),this.initialCredentials={},this.isLoading.set(false),this.router.navigate([],{relativeTo:this.route,queryParams:{template:null,templateScope:null},queryParamsHandling:"merge",replaceUrl:true});},error:e=>{console.warn(`[AuthSettingForm] 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){switch(this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.authTypeControl.setValue(t.authType),this.clearCredentialControls(),this.initialCredentials={},t.authType){case "ApiKeyAuthSetting":{let e=t.apiKey??"";this.apiKeyControl.setValue(e),this.initialCredentials.apiKey=e;break}case "BasicAuthAuthSetting":{let e=t,n=e.username??"",o=e.password??"";this.usernameControl.setValue(n),this.passwordControl.setValue(o),this.initialCredentials.username=n,this.initialCredentials.password=o;break}case "BearerTokenAuthSetting":{let e=t.token??"";this.tokenControl.setValue(e),this.initialCredentials.token=e;break}case "OAuthDiscoverableAuthSetting":{let e=t;this.discoveryUrlControl.setValue(e.discoveryUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.discoveryUrl=e.discoveryUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthCustomAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthRegisteredAuthSetting":{let e=t;this.authorizationUrlControl.setValue(e.authorizationUrl??""),this.tokenUrlControl.setValue(e.tokenUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.authorizationUrl=e.authorizationUrl??"",this.initialCredentials.tokenUrl=e.tokenUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}case "OAuthMcpDiscoverableAuthSetting":{let e=t;this.resourceUrlControl.setValue(e.resourceUrl??""),this.clientIdControl.setValue(e.clientId??""),this.clientSecretControl.setValue(e.clientSecret??""),this.scopesControl.setValue(e.scopes??""),this.initialCredentials.resourceUrl=e.resourceUrl??"",this.initialCredentials.clientId=e.clientId??"",this.initialCredentials.clientSecret=e.clientSecret??"",this.initialCredentials.scopes=e.scopes??"";break}}}clearCredentialControls(){this.apiKeyControl.setValue(""),this.usernameControl.setValue(""),this.passwordControl.setValue(""),this.tokenControl.setValue(""),this.discoveryUrlControl.setValue(""),this.authorizationUrlControl.setValue(""),this.tokenUrlControl.setValue(""),this.clientIdControl.setValue(""),this.clientSecretControl.setValue(""),this.scopesControl.setValue(""),this.resourceUrlControl.setValue("");}credentialValue(t,e){if(!(this.isEditMode()&&e===this.initialCredentials[t]))return e||void 0}submit(){if(this.form.invalid||this.isSubmitting())return;if(this.isEditMode()&&!this.existingConfig?.id){this.navigateBack();return}this.isSubmitting.set(true);let t=this.nameControl.value.trim(),e=this.descriptionControl.value?.trim()||void 0,n=this.authTypeControl.value,o=this.form.getRawValue().scope,v=this.isPlatformMode?null:this.namespaceId??null,w=this.buildTypedPayload(n,t,e);(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,w,this.existingConfig):this.state.create(w,o,v)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}buildTypedPayload(t,e,n){let o={name:e,description:n};switch(t){case "ApiKeyAuthSetting":return x(w({},o),{authType:"ApiKeyAuthSetting",apiKey:this.credentialValue("apiKey",this.apiKeyControl.value)});case "BasicAuthAuthSetting":return x(w({},o),{authType:"BasicAuthAuthSetting",username:this.credentialValue("username",this.usernameControl.value),password:this.credentialValue("password",this.passwordControl.value)});case "BearerTokenAuthSetting":return x(w({},o),{authType:"BearerTokenAuthSetting",token:this.credentialValue("token",this.tokenControl.value)});case "OAuthDiscoverableAuthSetting":return x(w({},o),{authType:"OAuthDiscoverableAuthSetting",discoveryUrl:this.credentialValue("discoveryUrl",this.discoveryUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthCustomAuthSetting":return x(w({},o),{authType:"OAuthCustomAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthRegisteredAuthSetting":return x(w({},o),{authType:"OAuthRegisteredAuthSetting",authorizationUrl:this.credentialValue("authorizationUrl",this.authorizationUrlControl.value),tokenUrl:this.credentialValue("tokenUrl",this.tokenUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)});case "OAuthMcpDiscoverableAuthSetting":return x(w({},o),{authType:"OAuthMcpDiscoverableAuthSetting",resourceUrl:this.credentialValue("resourceUrl",this.resourceUrlControl.value),clientId:this.credentialValue("clientId",this.clientIdControl.value),clientSecret:this.credentialValue("clientSecret",this.clientSecretControl.value),scopes:this.credentialValue("scopes",this.scopesControl.value)})}}controlForField(t){return {apiKey:this.apiKeyControl,username:this.usernameControl,password:this.passwordControl,token:this.tokenControl,discoveryUrl:this.discoveryUrlControl,authorizationUrl:this.authorizationUrlControl,tokenUrl:this.tokenUrlControl,clientId:this.clientIdControl,clientSecret:this.clientSecretControl,scopes:this.scopesControl,resourceUrl:this.resourceUrlControl}[t]}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","auth-settings"]):this.router.navigate(["/agentos",this.namespaceId,"auth-settings"]);}trackByScope(t,e){return e.value}trackByField(t,e){return e.key}static \u0275fac=function(e){return new(e||i)};static \u0275cmp=JI({type:i,selectors:[["agentos-auth-setting-form"]],decls:6,vars:2,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to auth settings",3,"click"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["legend","Configuration scope",3,"disabled"],["label","Auth type","controlId","as-auth-type","required",""],["dsControl","","id","as-auth-type",3,"formControl"],[3,"value"],["label","Name","controlId","as-name","required",""],["dsControl","","id","as-name","type","text","placeholder","e.g. GitHub OAuth App","autocomplete","off",3,"formControl"],["label","Description","controlId","as-description"],["dsControl","","id","as-description","type","text","placeholder","Optional \u2014 short description of this auth setting","autocomplete","off",3,"formControl"],["legend","Credentials",3,"hint"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"click"],["dsCheck",""],["type","radio",3,"formControl","value","disabled"],[3,"label","controlId","required","hint","hintId"],["dsControl","",3,"id","type","placeholder","formControl","autocomplete"]],template:function(e,n){e&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return n.cancel()}),fC(3," \u2190 Auth settings "),zu()(),Ew(4,Ce,2,0,"p",2)(5,be,16,8,"form",3),zu()),e&2&&(EE(),Vh("title",n.isEditMode()?"Edit auth setting":"New auth setting"),EE(3),Iw(n.isLoading()?4:5));},dependencies:[hn,fn,un,dn,cn,at,sn,an,qt,md,Co,Mo,Ht,Ut,ya,po,ho,An,On],encapsulation:2})};
2
+ export{me as AuthSettingFormComponent};
@@ -0,0 +1 @@
1
+ import {o as o$1,r,i,l}from'./chunk-1nyEsjkY.js';import {o}from'./chunk-Jcjs0qUP.js';import {q}from'./chunk-CYowS7ps.js';import'./chunk-OGl61xgu.js';import'./chunk-Cvh22V1I.js';import {O}from'./chunk-BT-f7pOo.js';import {g,W,F as F$1,w as we,ak as U,aA as N,M as Mi,aB as K,ac as _,h as BC,ad as F$2,aC as Be,x as U$1,a6 as Zs,ae as Dr,ag as Gm,ah as te,K as x,C as w,J as JI,ax as $t$1,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,S as dI,d as Bh,Y as Yu,i as bw,T as Tw,l as lg,q as Pd,L as Ld,$ as dg}from'./main-63IEQS3X.js';import {Q as A,p as pt$1,T as Te,g as gn,R as E,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,Y as Yr,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$1,i as sn,v as an,n as Fo}from'./chunk-CCZ1b0na.js';import'./chunk-CVAz4Lko.js';var F="*";function $e(n){return (n??[]).some(t=>t.trim()===F)}function Ge(n){let t=(n??[]).map(e=>e.trim()).filter(e=>e.length>0&&e!==F).map(e=>e.toLowerCase());return new Set(t)}function j(n){return n.includes(F)}function Je(n){let t=n.replace(/[\\.[\]{}()^$|]/g,"\\$&").replace(/\*/g,".*");try{return new RegExp(`^${t}$`,"i")}catch(e){return null}}function Y(n,t){return (t??[]).map(e=>e.trim()).filter(e=>e.length>0&&e!==F&&j(e)).some(e=>Je(e)?.test(n)??false)}var Ue="AGENTOS_CONFIG",Ye=new Set(["HTTP_API","MCP_HTTP","MCP_STDIO","BASH","TMUX","GIT"]);function Ke(n){return n.configEnabled&&(n.hasSubAgents||n.integrationTypes.some(t=>Ye.has(t)))}var We=(n,t)=>t.value,qe=(n,t)=>t.config.id,ze=(n,t)=>t.type,He=(n,t)=>t.selector;function Xe(n,t){if(n&1&&(os(0,"a",2),fC(1,"View resolved definition \u2192"),zu()),n&2){let e=Pw();Vh("routerLink",e.inspectRoute());}}function Qe(n,t){n&1&&(os(0,"ds-tag",3),fC(1,"Platform level"),zu());}function Ze(n,t){n&1&&(os(0,"p",4),fC(1,"Loading\u2026"),zu());}function et(n,t){if(n&1&&(Hh(0,"input",16),uI()),n&2){let e=Pw(2);Vh("formControl",e.modelNameControl),dI();}}function tt(n,t){if(n&1&&(os(0,"option",41),fC(1),zu()),n&2){let e=t;Vh("ngValue",e.value),EE(),lg(e.label);}}function nt(n,t){if(n&1&&(os(0,"option",41),fC(1),zu()),n&2){let e=t.$implicit;Vh("ngValue",e.value),EE(),lg(e.label);}}function it(n,t){if(n&1&&(os(0,"optgroup",42),bw(1,nt,2,2,"option",41,We),zu()),n&2){let e=Pw(3);EE(),Tw(e.modelOptions().aliases);}}function ot(n,t){if(n&1&&(os(0,"option",41),fC(1),zu()),n&2){let e=t.$implicit;Vh("ngValue",e.value),EE(),lg(e.label);}}function at(n,t){if(n&1&&(os(0,"optgroup",43),bw(1,ot,2,2,"option",41,We),zu()),n&2){let e=Pw(3);EE(),Tw(e.modelOptions().apiNames);}}function lt(n,t){if(n&1&&(os(0,"select",17)(1,"option",40),fC(2,"Select a model"),zu(),Ew(3,tt,2,2,"option",41),Ew(4,it,3,0,"optgroup",42),Ew(5,at,3,0,"optgroup",43),zu(),uI()),n&2){let e,i=Pw(2);Vh("formControl",i.modelNameControl),dI(),EE(),Vh("ngValue",null),EE(2),Iw((e=i.modelOptions().current)?3:-1,e),EE(),Iw(i.modelOptions().aliases.length>0?4:-1),EE(),Iw(i.modelOptions().apiNames.length>0?5:-1);}}function rt(n,t){if(n&1&&(os(0,"span",44),fC(1),zu()),n&2){let e=Pw().$implicit;EE(),lg(e.config.integrationType);}}function st(n,t){if(n&1&&(Hh(0,"input",45),uI()),n&2){let e=Pw().$implicit;Vh("formControl",e.toolsControl),Bh("aria-label","Tools of "+e.config.name),dI();}}function dt(n,t){if(n&1){let e=Aw();os(0,"div",9)(1,"label",10)(2,"input",22),qh("change",function(){let s=Pd(e).$implicit,m=Pw(3);return Ld(m.toggleIntegration(s))}),zu(),os(3,"span",23),fC(4),zu(),Ew(5,rt,2,1,"span",44),zu(),Ew(6,st,1,2,"input",45),zu();}if(n&2){let e=t.$implicit;EE(2),Vh("checked",e.enabled()),EE(2),lg(e.config.name),EE(),Iw(e.config.integrationType?5:-1),EE(),Iw(e.enabled()?6:-1);}}function ct(n,t){if(n&1&&(os(0,"p",12),fC(1),zu()),n&2){let e=Pw().$implicit;EE(),Yu(" Restricted to: ",e.restrictedTools.join(", ")," (set outside this form, preserved on save) ");}}function mt(n,t){if(n&1){let e=Aw();os(0,"div",9)(1,"label",23),fC(2),os(3,"span",44),fC(4,"built-in"),zu()(),os(5,"select",47),qh("change",function(s){let m=Pd(e).$implicit,C=Pw(4);return Ld(C.setBuiltInState(m,s.target.value))}),os(6,"option",48),fC(7),zu(),os(8,"option",49),fC(9,"Enabled"),zu(),os(10,"option",50),fC(11,"Disabled"),zu()(),Ew(12,ct,2,1,"p",12),os(13,"p",12),fC(14),zu()();}if(n&2){let e=t.$implicit,i=Pw(4);EE(),Bh("for","built-in-"+e.type),EE(),Yu(" ",e.displayName," "),EE(3),Vh("id","built-in-"+e.type)("value",e.state()),EE(2),lg(i.builtInDefaultLabel(e)),EE(5),Iw(e.state()==="on"&&e.restrictedTools?12:-1),EE(2),lg(e.description);}}function gt(n,t){if(n&1&&(os(0,"span",46),fC(1,"Built-in integrations"),zu(),bw(2,mt,15,7,"div",9,ze)),n&2){let e=Pw(3);EE(2),Tw(e.builtInRows());}}function ut(n,t){n&1&&(os(0,"ds-notice",25),fC(1," This agent can read the AgentOS configuration and also has a network integration or sub-agents: what it reads could be sent outside without any confirmation. Prefer a dedicated configuration agent without them. "),zu());}function pt(n,t){if(n&1&&(os(0,"ds-fieldset",20),bw(1,dt,7,4,"div",9,qe),Ew(3,gt,4,0),Ew(4,ut,2,0,"ds-notice",25),zu()),n&2){let e=Pw(2);EE(),Tw(e.integrationRows()),EE(2),Iw(e.builtInRows().length>0?3:-1),EE(),Iw(e.configAgentExposureWarning()?4:-1);}}function ft(n,t){n&1&&fC(0," A platform config can only list platform skills here: namespace skills are resolved per namespace when the agent runs. ");}function Ct(n,t){n&1&&(os(0,"ds-notice",25),fC(1," Saving with this on replaces the selection below with "),os(2,"code",24),fC(3,"*"),zu(),fC(4,". "),zu());}function _t(n,t){n&1&&(os(0,"ds-notice"),fC(1," The skill catalogue could not be loaded. What this agent already declares is listed below and preserved on save. "),zu());}function bt(n,t){n&1&&(os(0,"p",4),fC(1,"No skill available in this scope yet."),zu());}function ht(n,t){n&1&&(os(0,"span",44),fC(1,"platform"),zu());}function yt(n,t){if(n&1&&(os(0,"span",44),fC(1),zu()),n&2){let e=Pw(4);EE(),Yu(" ",e.skillCatalogueUnavailable()?"not verified":"no matching skill"," ");}}function xt(n,t){if(n&1&&(os(0,"p",12),fC(1),zu()),n&2){let e=Pw().$implicit;EE(),lg(e.description);}}function vt(n,t){if(n&1){let e=Aw();os(0,"div",9)(1,"label",10)(2,"input",51),qh("change",function(){let s=Pd(e).$implicit,m=Pw(3);return Ld(m.toggleSkill(s))}),zu(),os(3,"span",23),fC(4),zu(),Ew(5,ht,2,0,"span",44),Ew(6,yt,2,1,"span",44),zu(),Ew(7,xt,2,1,"p",12),zu();}if(n&2){let e=t.$implicit,i=Pw(3);EE(2),Vh("checked",e.selected())("disabled",i.allSkillsSelected()),EE(2),lg(e.name),EE(),Iw(e.platform?5:-1),EE(),Iw(e.unresolved?6:-1),EE(),Iw(e.description?7:-1);}}function St(n,t){if(n&1&&bw(0,vt,8,6,"div",9,He),n&2){let e=Pw(2);Tw(e.skillRows());}}function At(n,t){if(n&1&&(os(0,"ds-form-field",29),Hh(1,"textarea",52),uI(),os(2,"p",4),fC(3," Default payload for this loop agent. Overridden at launch time if the first message contains a valid "),os(4,"code"),fC(5,"AgentLoopPayload"),zu(),fC(6,". Leave empty if you always provide the payload at launch. "),zu()()),n&2){let e=Pw(2);Vh("error",e.loopConfigControl.invalid&&e.loopConfigControl.touched?"Invalid JSON \u2014 please fix the syntax.":null),EE(),Vh("placeholder",e.loopConfigPlaceholder)("formControl",e.loopConfigControl),dI();}}function wt(n,t){n&1&&fC(0," A platform config can only list platform agents here: a namespace's agents are resolved per namespace when the agent runs. ");}function Et(n,t){if(n&1&&fC(0),n&2){let e=Pw(3);dg(" That deletes ",e.droppedUnresolvedSubAgents()," flagged ",e.droppedUnresolvedSubAgents()===1?"selector":"selectors"," nothing matched, which this form cannot restore. ");}}function Tt(n,t){if(n&1&&(os(0,"ds-notice",25),fC(1," Saving with this on replaces the selection below with "),os(2,"code",24),fC(3,"*"),zu(),fC(4,". "),Ew(5,Et,1,2),zu()),n&2){let e=Pw(2);EE(5),Iw(e.droppedUnresolvedSubAgents()>0?5:-1);}}function It(n,t){n&1&&(os(0,"ds-notice"),fC(1," The list of agents could not be loaded. What this agent already declares is listed below and preserved on save. "),zu());}function kt(n,t){n&1&&(os(0,"p",4),fC(1,"No other agent is available in this scope yet."),zu());}function Rt(n,t){n&1&&(os(0,"span",44),fC(1,"pattern"),zu());}function Mt(n,t){n&1&&(os(0,"span",44),fC(1,"via pattern"),zu());}function Ft(n,t){if(n&1&&(os(0,"span",44),fC(1),zu()),n&2){let e=Pw(4);EE(),Yu(" ",e.subAgentCandidatesUnavailable()?"not verified":"no matching agent"," ");}}function Nt(n,t){if(n&1){let e=Aw();os(0,"button",55),qh("click",function(){Pd(e);let s=Pw().$implicit,m=Pw(3);return Ld(m.removeSubAgent(s))}),fC(1," \xD7 "),zu();}if(n&2){let e=Pw().$implicit;Bh("aria-label","Remove "+e.selector);}}function Dt(n,t){if(n&1){let e=Aw();os(0,"div",31)(1,"label",53)(2,"input",51),qh("change",function(){let s=Pd(e).$implicit,m=Pw(3);return Ld(m.toggleSubAgent(s))}),zu(),os(3,"span",23),fC(4),zu(),Ew(5,Rt,2,0,"span",44)(6,Mt,2,0,"span",44)(7,Ft,2,1,"span",44),zu(),Ew(8,Nt,2,1,"button",54),zu();}if(n&2){let e=t.$implicit,i=Pw(3);EE(2),Vh("checked",e.selected())("disabled",i.allSubAgentsSelected()),EE(2),lg(e.name),EE(),Iw(e.pattern?5:e.grantedByPattern?6:e.unresolved?7:-1),EE(3),Iw(e.unresolved?8:-1);}}function Lt(n,t){if(n&1&&bw(0,Dt,9,5,"div",31,He),n&2){let e=Pw(2);Tw(e.subAgentRows());}}function Vt(n,t){if(n&1){let e=Aw();os(0,"div")(1,"button",56),qh("click",function(){Pd(e);let s=Pw(2);return Ld(s.useDefaultDelegationTimeout())}),fC(2," Use server default "),zu()();}}function Pt(n,t){n&1&&(os(0,"ds-notice"),fC(1),zu()),n&2&&(EE(),lg(t));}function Ot(n,t){if(n&1){let e=Aw();os(0,"button",57),qh("click",function(){Pd(e);let s=Pw(2);return Ld(s.exportYaml())}),fC(1),zu();}if(n&2){let e=Pw(2);Vh("disabled",e.isExporting()),EE(),Yu(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function Bt(n,t){if(n&1&&Hh(0,"agentos-agent-messaging",39),n&2){let e=Pw(2);Vh("namespaceId",e.namespaceId)("agentId",e.agentConfigId);}}function $t(n,t){if(n&1){let e=Aw();os(0,"form",5),qh("ngSubmit",function(){Pd(e);let s=Pw();return Ld(s.submit())}),os(1,"ds-fieldset",6)(2,"ds-form-field",7),Hh(3,"input",8),uI(),zu(),os(4,"div",9)(5,"label",10),Hh(6,"input",11),uI(),fC(7," Enabled "),zu(),os(8,"p",12),fC(9,"Disabled agents are excluded from namespace resolution."),zu()(),os(10,"ds-form-field",13),Hh(11,"input",14),uI(),zu(),os(12,"ds-form-field",15),Ew(13,et,1,1,"input",16)(14,lt,6,5,"select",17),zu(),os(15,"ds-form-field",18),Hh(16,"textarea",19),uI(),zu()(),Ew(17,pt,5,2,"ds-fieldset",20),os(18,"ds-fieldset",21)(19,"p",4),fC(20," Instruction bundles this agent can read on demand. Selecting at least one grants it the "),os(21,"code"),fC(22,"readSkill"),zu(),fC(23," and "),os(24,"code"),fC(25,"readSkillResource"),zu(),fC(26," tools; selecting none grants neither. "),Ew(27,ft,1,0),zu(),os(28,"label",10)(29,"input",22),qh("change",function(){Pd(e);let s=Pw();return Ld(s.toggleAllSkills())}),zu(),os(30,"span",23),fC(31,"Every skill in the catalogue ("),os(32,"code",24),fC(33,"*"),zu(),fC(34,")"),zu()(),os(35,"p",12),fC(36," Resolved at run time, so skills added later are granted too, without editing this agent. "),zu(),Ew(37,Ct,5,0,"ds-notice",25),Ew(38,_t,2,0,"ds-notice"),Ew(39,bt,2,0,"p",4)(40,St,2,0),zu(),os(41,"ds-form-field",26)(42,"select",27)(43,"option",28),fC(44,"SIMPLE \u2014 Standard agent (single LLM call)"),zu(),os(45,"option",28),fC(46,"ADVANCED \u2014 Multi-step reasoning loop"),zu(),os(47,"option",28),fC(48,"LOOP \u2014 Bulk loop agent (no LLM, experimental)"),zu()(),uI(),zu(),Ew(49,At,7,3,"ds-form-field",29),os(50,"ds-fieldset",30)(51,"p",4),fC(52," The agents this one may delegate to. Selecting at least one grants it the "),os(53,"code"),fC(54,"DELEGATE__delegate"),zu(),fC(55," tool; selecting none grants it no way to delegate. Entries are matched against agent names, never ids. "),Ew(56,wt,1,0),zu(),os(57,"label",10)(58,"input",22),qh("change",function(){Pd(e);let s=Pw();return Ld(s.toggleAllSubAgents())}),zu(),os(59,"span",23),fC(60,"Every agent it can reach ("),os(61,"code",24),fC(62,"*"),zu(),fC(63,")"),zu()(),os(64,"p",12),fC(65," Resolved at run time, so agents added later can be delegated to as well, without editing this agent. "),zu(),Ew(66,Tt,6,1,"ds-notice",25),Ew(67,It,2,0,"ds-notice"),Ew(68,kt,2,0,"p",4)(69,Lt,2,0),os(70,"p",4),fC(71," Advanced \u2014 add a glob instead of picking a name, for example "),os(72,"code"),fC(73,"*Fixer"),zu(),fC(74," to cover BugFixer and StoryFixer. "),zu(),os(75,"div",31)(76,"input",32),qh("keydown.enter",function(){Pd(e);let s=Pw();return Ld(s.addSubAgent())}),zu(),uI(),os(77,"button",33),qh("click",function(){Pd(e);let s=Pw();return Ld(s.addSubAgent())}),fC(78," + "),zu()(),os(79,"ds-form-field",34),Hh(80,"input",35),uI(),Ew(81,Vt,3,0,"div"),zu()(),Ew(82,Pt,2,1,"ds-notice"),os(83,"ds-form-actions")(84,"button",36),fC(85),zu(),Ew(86,Ot,2,2,"button",37),os(87,"button",38),qh("click",function(){Pd(e);let s=Pw();return Ld(s.cancel())}),fC(88,"Cancel"),zu()()(),Ew(89,Bt,1,2,"agentos-agent-messaging",39);}if(n&2){let e,i=Pw();Vh("formGroup",i.form),EE(3),Vh("formControl",i.nameControl),dI(),EE(3),Vh("formControl",i.enabledControl),dI(),EE(5),Vh("formControl",i.descriptionControl),dI(),EE(2),Iw(i.modelAsFreeText()?13:14),EE(3),Vh("formControl",i.instructionsControl),dI(),EE(),Iw(i.integrationRows().length>0||i.builtInRows().length>0?17:-1),EE(10),Iw(i.isPlatformMode?27:-1),EE(2),Vh("checked",i.allSkillsSelected()),EE(8),Iw(i.namedSkillSelectionDropped()?37:-1),EE(),Iw(i.skillCatalogueUnavailable()?38:-1),EE(),Iw(i.skillRows().length===0?39:40),EE(3),Vh("formControl",i.executionModeControl),dI(),EE(),Vh("value",i.ExecutionMode.SIMPLE),EE(2),Vh("value",i.ExecutionMode.ADVANCED),EE(2),Vh("value",i.ExecutionMode.LOOP),EE(2),Iw(i.isLoopMode()?49:-1),EE(7),Iw(i.isPlatformMode?56:-1),EE(2),Vh("checked",i.allSubAgentsSelected()),EE(8),Iw(i.namedSubAgentSelectionDropped()?66:-1),EE(),Iw(i.subAgentCandidatesUnavailable()?67:-1),EE(),Iw(i.subAgentRows().length===0?68:69),EE(8),Vh("formControl",i.newSubAgentControl),dI(),EE(),Vh("disabled",!i.newSubAgentControl.value.trim()),EE(2),Vh("hint",i.delegationTimeoutHint())("error",i.delegationTimeoutControl.invalid?"Enter a valid positive whole number of seconds, or leave empty to inherit the server default.":null),EE(),Vh("formControl",i.delegationTimeoutControl),Bh("aria-invalid",i.delegationTimeoutControl.invalid),dI(),EE(),Iw(i.delegationTimeoutControl.value!==null?81:-1),EE(),Iw((e=i.submitError())?82:-1,e),EE(2),Vh("disabled",i.form.invalid||i.isSubmitting()),EE(),Yu(" ",i.isEditMode()?"Save changes":"Create"," "),EE(),Iw(i.isEditMode()?86:-1),EE(3),Iw(i.isEditMode()&&i.namespaceId?89:-1);}}var je=class n{route=g(W);router=g(F$1);destroyRef=g(we);agentConfigController=g(U);defaultsController=g(N);defaultDelegationTimeoutSeconds=Mi(null);exportService=g(K);integrationConfigState=g(O);integrationTypeController=g(_);skillState=g(o);aiModelState=g(A);namespaceId=this.route.snapshot.params.namespaceId;agentConfigId=this.route.snapshot.paramMap.get("agentConfigId")??"";isPlatformMode=!this.namespaceId;form=new pt$1({name:new Te("",{nonNullable:true,validators:[gn.required,gn.minLength(1)]}),description:new Te(null),modelName:new Te(null,{validators:[gn.required,n.notBlankValidator]}),instructions:new Te(null),executionMode:new Te("SIMPLE",{nonNullable:true}),delegationTimeoutSeconds:new Te(null,{validators:[gn.min(1),gn.max(2147483647),gn.pattern(/^\d+$/)]}),enabled:new Te(false,{nonNullable:true}),loopConfig:new Te(null,{validators:[n.jsonValidator]})});static notBlankValidator(t){let e=t.value;return typeof e=="string"&&e.length>0&&e.trim().length===0?{required:true}:null}static jsonValidator(t){let e=t.value?.trim();if(!e)return null;try{return JSON.parse(e),null}catch(i){return {invalidJson:true}}}get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get modelNameControl(){return this.form.controls.modelName}get instructionsControl(){return this.form.controls.instructions}get executionModeControl(){return this.form.controls.executionMode}get delegationTimeoutControl(){return this.form.controls.delegationTimeoutSeconds}useDefaultDelegationTimeout(){this.delegationTimeoutControl.setValue(null),this.delegationTimeoutControl.markAsDirty();}delegationTimeoutHint=BC(()=>{let t=this.defaultDelegationTimeoutSeconds();return `How long each delegation launched by this agent waits without activity from the sub-agent, including its own delegations. When it runs out, the sub-agent and its active descendants are stopped and can be resumed. Leave empty to use the server default${t!==null?`: ${t} s (${t/60} min)`:""}.`});get enabledControl(){return this.form.controls.enabled}get loopConfigControl(){return this.form.controls.loopConfig}executionModeValue=F$2(this.form.controls.executionMode.valueChanges,{initialValue:this.form.controls.executionMode.value});isLoopMode=BC(()=>this.executionModeValue()==="LOOP");subAgentRows=Mi([]);allSubAgentsSelected=Mi(false);subAgentCandidatesUnavailable=Mi(false);namedSubAgentSelectionDropped=BC(()=>this.allSubAgentsSelected()&&this.subAgentRows().some(t=>t.selected()));droppedUnresolvedSubAgents=BC(()=>this.allSubAgentsSelected()?this.subAgentRows().filter(t=>t.unresolved&&t.selected()).length:0);hasAnySubAgent=BC(()=>this.allSubAgentsSelected()||this.subAgentRows().some(t=>t.selected()));newSubAgentControl=new Te("",{nonNullable:true});isEditMode=Mi(false);isSubmitting=Mi(false);isLoading=Mi(false);isExporting=Mi(false);submitError=Mi(null);ExecutionMode=Be;loopConfigPlaceholder=JSON.stringify({search:{tool:"SearchTalents",params:{talentId:["6ac76692a909eaaae0b078d6"],resolveTargets:["MANAGER"],next:null}},act:{agentName:"ProfileCaretaker",promptTemplate:"This talent has not completed their profile. As their manager, I need you to help me review and improve it."}},null,2);builtInRows=Mi([]);inspectRoute(){let t=this.route.snapshot.paramMap.get("agentConfigId")??"";return this.isPlatformMode?["/agentos","admin","agent-configs",t,"inspect"]:["/agentos",this.namespaceId,"agent-configs",t,"inspect"]}configAgentExposureWarning=BC(()=>Ke({configEnabled:this.builtInRows().some(t=>t.type===Ue&&t.state()==="on"),integrationTypes:this.integrationRows().filter(t=>t.enabled()).map(t=>t.config.integrationType),hasSubAgents:this.hasAnySubAgent()}));modelOptions=Mi({aliases:[],apiNames:[],current:null});modelCatalogueLoaded=Mi(false);modelAsFreeText=BC(()=>{let{aliases:t,apiNames:e}=this.modelOptions();return this.modelCatalogueLoaded()&&t.length+e.length===0});applyModelCatalogue(t,e){this.modelOptions.set(E(t,e)),this.modelCatalogueLoaded.set(true);}integrationRows=Mi([]);skillRows=Mi([]);allSkillsSelected=Mi(false);skillCatalogueUnavailable=Mi(false);namedSkillSelectionDropped=BC(()=>this.allSkillsSelected()&&this.skillRows().some(t=>t.selected()));existingConfig=null;ngOnInit(){this.defaultsController.getAgentConfigDefaults().pipe(U$1(this.destroyRef),Zs(()=>Dr(null))).subscribe(e=>this.defaultDelegationTimeoutSeconds.set(e?.delegationTimeoutSeconds??null));let t=this.route.snapshot.paramMap.get("agentConfigId");t?(this.isEditMode.set(true),this.loadConfigAndIntegrations(t)):this.loadIntegrations(void 0);}loadConfigAndIntegrations(t){this.isLoading.set(true),Gm({config:this.agentConfigController.getByIdAgentConfig(t),namespaceIntegrations:this.namespaceId?this.integrationConfigState.loadNamespaceConfigs(this.namespaceId):Dr([]),platformIntegrations:this.integrationConfigState.loadPlatformConfigs(),builtInTypes:this.loadBuiltInTypes(),skillCatalogue:this.loadSkillCatalogue(),delegationCandidates:this.loadDelegationCandidates(),models:this.aiModelState.listAvailable(this.namespaceId)}).pipe(U$1(this.destroyRef)).subscribe({next:({config:e,namespaceIntegrations:i,platformIntegrations:s,builtInTypes:m,skillCatalogue:C,delegationCandidates:E,models:I})=>{this.existingConfig=e,this.applyModelCatalogue(I,e.modelName??null),this.nameControl.setValue(e.name),this.descriptionControl.setValue(e.description??null),this.modelNameControl.setValue(e.modelName??null),this.instructionsControl.setValue(e.instructions??null);let f=e.executionMode??(e.advancedExecution?"ADVANCED":"SIMPLE");this.executionModeControl.setValue(f),this.delegationTimeoutControl.setValue(e.delegationTimeoutSeconds??null),this.enabledControl.setValue(e.enabled??true),this.loopConfigControl.setValue(e.loopConfig!=null?JSON.stringify(e.loopConfig,null,2):null);let N=[...s,...i];this.integrationRows.set(this.buildIntegrationRows(N,e.integrations??void 0)),this.builtInRows.set(this.buildBuiltInRows(m,e.integrations??void 0)),this.allSubAgentsSelected.set($e(e.subAgents)),this.subAgentRows.set(this.buildSubAgentRows(E,e.subAgents,e.name)),this.allSkillsSelected.set(o$1(e.skillSelectors)),this.skillRows.set(this.buildSkillRows(C,e.skillSelectors)),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}loadIntegrations(t){Gm({namespaceIntegrations:this.namespaceId?this.integrationConfigState.loadNamespaceConfigs(this.namespaceId):Dr([]),platformIntegrations:this.integrationConfigState.loadPlatformConfigs(),builtInTypes:this.loadBuiltInTypes(),skillCatalogue:this.loadSkillCatalogue(),delegationCandidates:this.loadDelegationCandidates(),models:this.aiModelState.listAvailable(this.namespaceId)}).pipe(U$1(this.destroyRef)).subscribe({next:({namespaceIntegrations:e,platformIntegrations:i,builtInTypes:s,skillCatalogue:m,delegationCandidates:C,models:E})=>{this.applyModelCatalogue(E,null);let I=[...i,...e];this.integrationRows.set(this.buildIntegrationRows(I,t??void 0)),this.builtInRows.set(this.buildBuiltInRows(s,t??void 0)),this.allSubAgentsSelected.set(false),this.subAgentRows.set(this.buildSubAgentRows(C,void 0,null)),this.allSkillsSelected.set(false),this.skillRows.set(this.buildSkillRows(m,void 0));}});}loadSkillCatalogue(){return (this.namespaceId?this.skillState.listEffective(this.namespaceId):this.skillState.listPlatform().pipe(te(e=>e.map(i=>({id:i.id??"",name:i.name,description:i.description,namespaceId:i.namespaceId??null,readOnly:i.readOnly===true}))))).pipe(Zs(e=>(console.error("[agent-config-form] failed to load the skill catalogue",e),this.skillCatalogueUnavailable.set(true),Dr([]))))}buildSkillRows(t,e){let s=(e??[]).map(f=>f.trim()).filter(f=>f.length>0).filter(f=>f!==r),m=i(s),C=new Set(t.map(f=>f.name.toLowerCase())),E=t.map(f=>({selector:f.name,name:f.name,description:f.description,platform:f.namespaceId==null,unresolved:false,selected:Mi(m.has(f.name.toLowerCase()))})),I=new Set;for(let f of s){let N=l(f).toLowerCase();C.has(N)||I.has(N)||(I.add(N),E.push({selector:f,name:f,description:"",platform:false,unresolved:true,selected:Mi(true)}));}return E}toggleSkill(t){t.selected.update(e=>!e);}toggleAllSkills(){this.allSkillsSelected.update(t=>!t);}buildSkillSelectorsPayload(){if(this.allSkillsSelected())return [r];let t=this.skillRows().filter(e=>e.selected()).map(e=>e.selector);return t.length>0?t:void 0}loadDelegationCandidates(){let t=this.agentConfigController.listPlatformAgentsAgentConfig(false).pipe(this.orNoCandidates()),e=this.namespaceId?this.agentConfigController.listByParentAgentConfig(this.namespaceId,false).pipe(this.orNoCandidates()):Dr([]);return Gm({platform:t,namespace:e}).pipe(te(({platform:i,namespace:s})=>[...i,...s]),te(i=>i.map(s=>s.name).filter(s=>s.length>0)),te(i=>n.dedupeByKey(i)))}orNoCandidates(){return Zs(t=>(console.error("[agent-config-form] failed to load the delegation candidates",t),this.subAgentCandidatesUnavailable.set(true),Dr([])))}static dedupeByKey(t){let e=new Set;return t.filter(i=>{let s=i.toLowerCase();return e.has(s)?false:(e.add(s),true)})}buildSubAgentRows(t,e,i){let s=Ge(e),m=i?.toLowerCase()??null,C=t.filter(_=>{let O=_.toLowerCase();return O!==m||s.has(O)}),E=new Set(C.map(_=>_.toLowerCase())),I=C.map(_=>({selector:_,name:_,unresolved:false,pattern:false,grantedByPattern:Y(_,e),selected:Mi(s.has(_.toLowerCase()))})),f=new Set,N=(e??[]).map(_=>_.trim()).filter(_=>_.length>0&&_!==F);for(let _ of N){let O=_.toLowerCase();E.has(O)||f.has(O)||(f.add(O),I.push({selector:_,name:_,unresolved:true,pattern:j(_),grantedByPattern:false,selected:Mi(true)}));}return I}loadBuiltInTypes(){return this.integrationTypeController.listTypesIntegrationType().pipe(te(t=>t.filter(e=>!e.configSchema)),Zs(t=>(console.error("[agent-config-form] failed to load integration types",t),Dr([]))))}buildIntegrationRows(t,e){return t.map(i=>{let s=i.name??"",m=e?.[s],C=e!=null&&s in e,E=Array.isArray(m)?m.join(", "):"";return {config:i,enabled:Mi(C),toolsControl:new Te(E,{nonNullable:true})}})}buildBuiltInRows(t,e){return t.map(i=>{let s=e!=null&&i.type in e,m=e?.[i.type],C=s?Array.isArray(m)&&m.length===0?"off":"on":"default";return {type:i.type,displayName:i.displayName,description:i.description,enabledByDefault:i.enabledByDefault===true,state:Mi(C),restrictedTools:Array.isArray(m)&&m.length>0?m:null}})}toggleIntegration(t){t.enabled.update(e=>!e);}setBuiltInState(t,e){t.state.set(e);}builtInDefaultLabel(t){return t.enabledByDefault?"Platform default (enabled)":"Platform default (disabled)"}addSubAgent(){let t=this.newSubAgentControl.value.trim();if(!t)return;let e=this.subAgentRows().find(i=>i.selector.toLowerCase()===t.toLowerCase());e?e.selected.set(true):t===F?this.allSubAgentsSelected.set(true):this.subAgentRows.update(i=>this.withPatternGrants([...i,{selector:t,name:t,unresolved:true,pattern:j(t),grantedByPattern:false,selected:Mi(true)}])),this.newSubAgentControl.reset("");}removeSubAgent(t){let e=t.selector.toLowerCase();this.subAgentRows.update(i=>this.withPatternGrants(i.filter(s=>s.selector.toLowerCase()!==e)));}toggleSubAgent(t){t.selected.update(e=>!e),t.pattern&&this.subAgentRows.update(e=>this.withPatternGrants(e));}withPatternGrants(t){let e=this.allSubAgentsSelected()?[]:t.filter(i=>i.selected()).map(i=>i.selector);return t.map(i=>i.unresolved?i:x(w({},i),{grantedByPattern:Y(i.name,e)}))}toggleAllSubAgents(){this.allSubAgentsSelected.update(t=>!t),this.subAgentRows.update(t=>this.withPatternGrants(t));}buildSubAgentsPayload(){if(this.allSubAgentsSelected())return [F];let t=this.subAgentRows().filter(e=>e.selected()).map(e=>e.selector);return t.length>0?t:void 0}buildIntegrationsPayload(){let t={};for(let i of this.integrationRows().filter(s=>s.enabled())){let s=i.config.name??"",m=i.toolsControl.value.trim();t[s]=m===""?null:m.split(",").map(C=>C.trim()).filter(C=>C.length>0);}for(let i of this.builtInRows()){let s=i.state();s==="on"?t[i.type]=i.restrictedTools??null:s==="off"&&(t[i.type]=[]);}let e=new Set([...this.integrationRows().map(i=>i.config.name??""),...this.builtInRows().map(i=>i.type)]);for(let[i,s]of Object.entries(this.existingConfig?.integrations??{}))e.has(i)||(t[i]=s);return Object.keys(t).length>0?t:void 0}submit(){if(this.form.invalid||this.isSubmitting())return;this.addSubAgent(),this.submitError.set(null),this.isSubmitting.set(true);let t=x(w({},this.existingConfig??{}),{createdOn:this.existingConfig?.createdOn,updatedOn:this.existingConfig?.updatedOn,namespaceId:this.namespaceId,name:this.nameControl.value.trim(),description:this.descriptionControl.value?.trim()||void 0,modelName:this.modelNameControl.value?.trim()||void 0,instructions:this.instructionsControl.value?.trim()||void 0,integrations:this.buildIntegrationsPayload(),executionMode:this.executionModeControl.value,advancedExecution:this.executionModeControl.value==="ADVANCED",enabled:this.enabledControl.value,subAgents:this.buildSubAgentsPayload(),skillSelectors:this.buildSkillSelectorsPayload(),delegationTimeoutSeconds:this.delegationTimeoutControl.value,loopConfig:this.buildLoopConfigPayload()});(this.isEditMode()?this.agentConfigController.updateAgentConfig(this.existingConfig.id??"",t):this.agentConfigController.createAgentConfig(t)).pipe(U$1(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:i=>{this.isSubmitting.set(false),this.submitError.set(n.serverMessage(i));}});}static serverMessage(t){let i=t?.error?.message;if(typeof i=="string"&&i.trim().length>0)return i;let s=t?.status;return s===0?"The server could not be reached. The agent was not saved.":typeof s=="number"&&s>=500?`The server failed to save the agent (HTTP ${s}). Nothing was changed.`:"The server refused the save and gave no reason. Check the values and try again."}exportYaml(){let t=this.existingConfig?.id;!t||this.isExporting()||(this.isExporting.set(true),this.exportService.exportAsYaml(t).pipe(U$1(this.destroyRef)).subscribe({next:e=>{let i=new Blob([e],{type:"application/yaml"}),s=URL.createObjectURL(i),m=document.createElement("a");m.href=s,m.download=`${this.existingConfig?.name??"agent"}.yaml`,m.click(),URL.revokeObjectURL(s),this.isExporting.set(false);},error:()=>this.isExporting.set(false)}));}buildLoopConfigPayload(){let t=this.loopConfigControl.value?.trim();if(!t)return this.existingConfig?.loopConfig!=null?null:void 0;try{return JSON.parse(t)}catch(e){return}}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","agent-configs"]):this.router.navigate(["/agentos",this.namespaceId,"agent-configs"]);}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=JI({type:n,selectors:[["agentos-agent-config-form"]],decls:8,vars:4,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to agent configs",3,"click"],["headerMeta","",1,"ds-link",3,"routerLink"],["headerMeta","","variant","outline"],[1,"ds-hint"],[1,"ds-form",3,"ngSubmit","formGroup"],["legend","Agent"],["label","Name","controlId","agent-config-name","required",""],["dsControl","","id","agent-config-name","type","text","placeholder","e.g. Support agent","autocomplete","off",3,"formControl"],[1,"ds-stack","ds-stack--sm"],["dsCheck",""],["type","checkbox",3,"formControl"],[1,"ds-hint","ds-indent"],["label","Description","controlId","agent-config-description"],["dsControl","","id","agent-config-description","type","text","placeholder","Optional \u2014 short description of this agent","autocomplete","off",3,"formControl"],["label","Model","controlId","agent-config-model-name","required","","hint","Aliases are matched first, then API model names. Resolved when the agent runs."],["dsControl","","id","agent-config-model-name","type","text","placeholder","Model alias or name to use, e.g. BIG","autocomplete","off",3,"formControl"],["dsControl","","id","agent-config-model-name",3,"formControl"],["label","Instructions","controlId","agent-config-instructions"],["dsControl","","id","agent-config-instructions","rows","6","placeholder","Optional \u2014 system instructions for this agent",3,"formControl"],["legend","Integrations","hint","Select which integrations this agent can use. Leave tool names empty to allow all tools from an integration."],["legend","Skills"],["type","checkbox",3,"change","checked"],[1,"ds-strong"],[1,"ds-code"],["tone","warning"],["label","Execution mode","controlId","agent-config-execution-mode","hint",'SIMPLE runs a single LLM pass. ADVANCED uses an intention loop for complex tasks and requires a model that supports advanced execution, otherwise the agent fails to run. LOOP (experimental) starts one case per result of a tool, without an LLM \u2014 run it with "Launch loop" in the agent list menu.'],["dsControl","","id","agent-config-execution-mode",3,"formControl"],[3,"value"],["label","Loop configuration (JSON)","controlId","agent-config-loop-config",3,"error"],["legend","Sub-agents"],[1,"ds-inline"],["dsControl","","type","text","aria-label","New sub-agent pattern","placeholder","e.g. *Fixer","autocomplete","off",3,"keydown.enter","formControl"],["dsButton","","variant","icon","type","button","title","Add pattern","aria-label","Add pattern",3,"click","disabled"],["label","Delegation timeout (seconds)","controlId","delegation-timeout","hintId","delegation-timeout-hint","errorId","delegation-timeout-error",3,"hint","error"],["dsControl","","id","delegation-timeout","type","number","min","1","max","2147483647","step","1","placeholder","Server default","aria-describedby","delegation-timeout-hint delegation-timeout-error",3,"formControl"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"disabled"],["dsButton","","type","button",3,"click"],[3,"namespaceId","agentId"],["disabled","",3,"ngValue"],[3,"ngValue"],["label","Aliases"],["label","API model names"],[1,"ds-meta"],["dsControl","","type","text","placeholder","Tool names, comma-separated (empty = all tools)","autocomplete","off",1,"ds-indent",3,"formControl"],[1,"ds-micro"],["dsControl","",1,"ds-indent","ds-control--auto",3,"change","id","value"],["value","default"],["value","on"],["value","off"],["type","checkbox",3,"change","checked","disabled"],["dsControl","","mono","","id","agent-config-loop-config","rows","10","spellcheck","false","autocomplete","off",3,"placeholder","formControl"],["dsCheck","",1,"ds-grow"],["dsButton","","variant","icon-danger","type","button","title","Remove"],["dsButton","","variant","icon-danger","type","button","title","Remove",3,"click"],["dsButton","","variant","ghost","type","button",3,"click"],["dsButton","","type","button",3,"click","disabled"]],template:function(e,i){e&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return i.cancel()}),fC(3," \u2190 Agent configs "),zu(),Ew(4,Xe,2,1,"a",2),Ew(5,Qe,2,0,"ds-tag",3),zu(),Ew(6,Ze,2,0,"p",4)(7,$t,90,34),zu()),e&2&&(EE(),Vh("title",i.isEditMode()?"Edit agent config":"New agent config"),EE(3),Iw(i.isEditMode()?4:-1),EE(),Iw(i.isPlatformMode?5:-1),EE(),Iw(i.isLoading()?6:7));},dependencies:[qt,md,Co,Mo,Ht,Fn,yn,Ut,po,ho,Zr,Yr,An,On,$t$1,hn,fn,un,dn,cn,pn,at$1,sn,an,Fo,q],encapsulation:2})};export{je as AgentConfigFormComponent};
@@ -0,0 +1 @@
1
+ import {p as pt,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,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,Y as Yr,A as An,O as On,w as wa}from'./chunk-CCZ1b0na.js';import {g,W,F,w as we,au as k,at as F$1,ad as F$2,a6 as Zs,ae as Dr,av as ke,h as BC,M as Mi,s as sf,x as U,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,I as Iw,n as Aw,H as Hh,R as uI,i as bw,as as Cw,P as Pw,S as dI,T as Tw,Y as Yu,ai as vw,l as lg,$ as dg,q as Pd,L as Ld}from'./main-63IEQS3X.js';function he(r,t){r&1&&(os(0,"p",2),fC(1,"Loading\u2026"),zu());}function ve(r,t){if(r&1&&Hh(0,"input",6),r&2){let e=Pw(2);Vh("value",e.selectedProviderLabel());}}function ye(r,t){if(r&1&&(os(0,"option",44),fC(1),zu()),r&2){let e=t.$implicit;Vh("value",e.id),EE(),dg("",e.name," (",e.apiType,")");}}function be(r,t){if(r&1&&(os(0,"select",7)(1,"option",43),fC(2,"Select provider"),zu(),bw(3,ye,2,3,"option",44,vw().trackByProvider,true),zu(),uI()),r&2){let e=Pw(2);Vh("formControl",e.aiProviderIdControl),dI(),EE(3),Tw(e.providers());}}function xe(r,t){if(r&1&&(os(0,"option",25),fC(1),zu()),r&2){let e=t.$implicit;Vh("ngValue",e),EE(),lg(e.toLowerCase());}}function _e(r,t){r&1&&(os(0,"p",2),fC(1,"Not supported yet for Anthropic and Gemini providers."),zu());}function Me(r,t){r&1&&(os(0,"p",2),fC(1," Sent as is to OpenAI-compatible providers, which reject levels the model does not support. Through Requesty, Claude models do not apply it faithfully. "),zu());}function Ee(r,t){r&1&&(os(0,"p",26),fC(1," OpenAI reasoning models (GPT-5.1 and later) reject a temperature other than 1 with an effort: leave Temperature empty or set it to 1. "),zu());}function Ae(r,t){if(r&1){let e=Aw();os(0,"form",4),qh("ngSubmit",function(){Pd(e);let u=Pw();return Ld(u.submit())}),os(1,"ds-form-field",5),Ew(2,ve,1,1,"input",6)(3,be,5,1,"select",7),zu(),os(4,"ds-form-field",8),Hh(5,"input",9),uI(),zu(),os(6,"ds-form-field",10),Hh(7,"input",11),uI(),zu(),os(8,"ds-form-field",12),Hh(9,"input",13),uI(),zu(),os(10,"ds-form-field",14),Hh(11,"input",15),uI(),zu(),os(12,"div",16)(13,"ds-form-field",17),Hh(14,"input",18),uI(),zu(),os(15,"ds-form-field",19),Hh(16,"input",20),uI(),zu()(),os(17,"ds-form-field",21),Hh(18,"input",22),uI(),zu(),os(19,"ds-form-field",23)(20,"select",24)(21,"option",25),fC(22,"Provider default"),zu(),bw(23,xe,2,2,"option",25,Cw),zu(),uI(),Ew(25,_e,2,0,"p",2)(26,Me,2,0,"p",2),Ew(27,Ee,2,0,"p",26),zu(),os(28,"div",27)(29,"label",28),Hh(30,"input",29),uI(),os(31,"span",30),fC(32,"Supports advanced execution"),zu()(),os(33,"p",31),fC(34," Agents configured in ADVANCED execution mode fail to run on a model that does not support it. SIMPLE agents are not concerned. "),zu()(),os(35,"ds-fieldset",32)(36,"div",16)(37,"ds-form-field",33),Hh(38,"input",34),uI(),zu(),os(39,"ds-form-field",35),Hh(40,"input",36),uI(),zu()(),os(41,"div",16)(42,"ds-form-field",37),Hh(43,"input",38),uI(),zu(),os(44,"ds-form-field",39),Hh(45,"input",40),uI(),zu()()(),os(46,"ds-form-actions")(47,"button",41),fC(48),zu(),os(49,"button",42),qh("click",function(){Pd(e);let u=Pw();return Ld(u.cancel())}),fC(50,"Cancel"),zu()()();}if(r&2){let e=Pw();Vh("formGroup",e.form),EE(2),Iw(e.isEditMode()?2:3),EE(3),Vh("formControl",e.apiModelNameControl),dI(),EE(2),Vh("formControl",e.descriptionControl),dI(),EE(2),Vh("formControl",e.aliasControl),dI(),EE(2),Vh("formControl",e.priorityControl),dI(),EE(3),Vh("formControl",e.temperatureControl),dI(),EE(2),Vh("formControl",e.contextWindowControl),dI(),EE(2),Vh("formControl",e.maxCompletionTokensControl),dI(),EE(2),Vh("formControl",e.reasoningEffortControl),dI(),EE(),Vh("ngValue",null),EE(2),Tw(e.reasoningEffortOptions),EE(2),Iw(e.reasoningEffortUnsupported()?25:26),EE(2),Iw(e.temperatureMayConflictWithEffort()?27:-1),EE(3),Vh("formControl",e.supportsAdvancedExecutionControl),dI(),EE(5),Vh("formGroup",e.pricingGroup),EE(3),dI(),EE(2),dI(),EE(3),dI(),EE(2),dI(),EE(2),Vh("disabled",e.form.invalid||e.isSubmitting()),EE(),Yu(" ",e.isEditMode()?"Save changes":"Create"," ");}}var Ie=["Anthropic","Gemini"],ge=class r{route=g(W);router=g(F);destroyRef=g(we);aiModelController=g(k);aiProviderController=g(F$1);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;providers=F$2(this.aiProviderController.listAiProvider(this.isPlatformMode?"none":this.namespaceId).pipe(Zs(()=>Dr([]))),{initialValue:[]});form=new pt({aiProviderId:new Te("",{nonNullable:true,validators:[gn.required]}),apiModelName:new Te("",{nonNullable:true,validators:[gn.required,gn.minLength(1)]}),description:new Te(null),alias:new Te("",{nonNullable:true}),priority:new Te(0,{nonNullable:true}),temperature:new Te(null),contextWindow:new Te(null),maxCompletionTokens:new Te(null),reasoningEffort:new Te(null),supportsAdvancedExecution:new Te(false,{nonNullable:true}),pricing:new pt({inputMTokens:new Te(null),outputMTokens:new Te(null),cacheWrite:new Te(null),cacheRead:new Te(null)})});get aiProviderIdControl(){return this.form.controls.aiProviderId}get apiModelNameControl(){return this.form.controls.apiModelName}get descriptionControl(){return this.form.controls.description}get aliasControl(){return this.form.controls.alias}get priorityControl(){return this.form.controls.priority}get temperatureControl(){return this.form.controls.temperature}get contextWindowControl(){return this.form.controls.contextWindow}get maxCompletionTokensControl(){return this.form.controls.maxCompletionTokens}get reasoningEffortControl(){return this.form.controls.reasoningEffort}get supportsAdvancedExecutionControl(){return this.form.controls.supportsAdvancedExecution}get pricingGroup(){return this.form.controls.pricing}reasoningEffortOptions=Object.values(ke);selectedProviderId=F$2(this.form.controls.aiProviderId.valueChanges,{initialValue:this.form.controls.aiProviderId.value});reasoningEffortUnsupported=BC(()=>{let t=this.providers().find(e=>e.id===this.selectedProviderId())?.apiType;return t!==void 0&&Ie.includes(t)});temperatureValue=F$2(this.form.controls.temperature.valueChanges,{initialValue:this.form.controls.temperature.value});reasoningEffortValue=F$2(this.form.controls.reasoningEffort.valueChanges,{initialValue:this.form.controls.reasoningEffort.value});temperatureMayConflictWithEffort=BC(()=>{let t=this.temperatureValue();return this.reasoningEffortValue()!=null&&t!=null&&t!==1});isEditMode=Mi(false);isSubmitting=Mi(false);isLoading=Mi(false);selectedProviderLabel=BC(()=>{let t=this.aiProviderIdControl.value,e=this.providers().find(c=>c.id===t);return e?`${e.name} (${e.apiType})`:t});existingModel=null;constructor(){sf(()=>{this.reasoningEffortUnsupported()?(this.reasoningEffortControl.setValue(null),this.reasoningEffortControl.disable()):this.reasoningEffortControl.enable();});}ngOnInit(){let t=this.route.snapshot.paramMap.get("modelId");t&&(this.isEditMode.set(true),this.loadModel(t));}loadModel(t){this.isLoading.set(true),this.aiModelController.getByIdAiModel(t).pipe(U(this.destroyRef)).subscribe({next:e=>{this.existingModel=e,this.aiProviderIdControl.setValue(e.aiProviderId),this.aiProviderIdControl.disable(),this.apiModelNameControl.setValue(e.apiModelName),this.descriptionControl.setValue(e.description??null),this.aliasControl.setValue(e.alias??""),this.priorityControl.setValue(e.priority??0),this.temperatureControl.setValue(e.temperature??null),this.contextWindowControl.setValue(e.contextWindow??null),this.maxCompletionTokensControl.setValue(e.maxCompletionTokens??null),this.reasoningEffortControl.setValue(e.reasoningEffort??null),this.supportsAdvancedExecutionControl.setValue(e.supportsAdvancedExecution??false),this.pricingGroup.setValue({inputMTokens:e.pricing?.inputMTokens??null,outputMTokens:e.pricing?.outputMTokens??null,cacheWrite:e.pricing?.cacheWrite??null,cacheRead:e.pricing?.cacheRead??null}),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true);let t=this.form.getRawValue(),e=t.pricing,u=e.inputMTokens!=null||e.outputMTokens!=null||e.cacheWrite!=null||e.cacheRead!=null?{isEmpty:false,inputMTokens:e.inputMTokens??void 0,outputMTokens:e.outputMTokens??void 0,cacheWrite:e.cacheWrite??void 0,cacheRead:e.cacheRead??void 0}:void 0,w$1=x(w({},this.existingModel??{}),{aiProviderId:t.aiProviderId,namespaceId:this.isPlatformMode?void 0:this.existingModel?.namespaceId??this.namespaceId,apiModelName:t.apiModelName.trim(),description:t.description?.trim()||void 0,alias:t.alias.trim()||void 0,priority:t.priority,temperature:t.temperature??void 0,contextWindow:t.contextWindow??void 0,maxCompletionTokens:t.maxCompletionTokens??void 0,reasoningEffort:t.reasoningEffort??void 0,supportsAdvancedExecution:t.supportsAdvancedExecution,pricing:u});(this.isEditMode()?this.aiModelController.updateAiModel(this.existingModel.id??"",w$1):this.aiModelController.createAiModel(w$1)).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-models"]):this.router.navigate(["/agentos",this.namespaceId,"ai-models"]);}trackByProvider(t,e){return e.id??""}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=JI({type:r,selectors:[["agentos-ai-model-form"]],decls:6,vars:2,consts:[[3,"title"],["dsButton","","variant","ghost","type","button","title","Back to AI models",3,"click"],[1,"ds-hint"],[1,"ds-form",3,"formGroup"],[1,"ds-form",3,"ngSubmit","formGroup"],["label","Provider","controlId","model-provider","required",""],["dsControl","","id","model-provider","type","text","readonly","","tabindex","-1",3,"value"],["dsControl","","id","model-provider",3,"formControl"],["label","API name","controlId","model-api-name","required",""],["dsControl","","mono","","id","model-api-name","type","text","placeholder","e.g. gpt-4o, claude-3-5-sonnet-20241022","autocomplete","off",3,"formControl"],["label","Description","controlId","model-description"],["dsControl","","id","model-description","type","text","placeholder","Optional \u2014 short description of this model config","autocomplete","off",3,"formControl"],["label","Alias","controlId","model-alias"],["dsControl","","id","model-alias","type","text","placeholder","e.g. fast, smart \u2014 short identifier used internally","autocomplete","off",3,"formControl"],["label","Priority","controlId","model-priority"],["dsControl","","id","model-priority","type","number","placeholder","0 \u2014 higher wins when multiple configs share the same alias","min","0","step","1",3,"formControl"],[1,"ds-grid-2"],["label","Temperature","controlId","model-temperature"],["dsControl","","id","model-temperature","type","number","placeholder","0 \u2013 2","min","0","max","2","step","0.1",3,"formControl"],["label","Context window","controlId","model-context-window"],["dsControl","","id","model-context-window","type","number","placeholder","e.g. 128000","min","1","step","1",3,"formControl"],["label","Max completion tokens","controlId","model-max-completion-tokens"],["dsControl","","id","model-max-completion-tokens","type","number","placeholder","e.g. 4096","min","1","step","1",3,"formControl"],["label","Reasoning effort","controlId","model-reasoning-effort"],["dsControl","","id","model-reasoning-effort",3,"formControl"],[3,"ngValue"],[1,"ds-hint","ds-hint--warning"],[1,"ai-model-form__field"],[1,"ai-model-form__toggle-label"],["type","checkbox",1,"ai-model-form__toggle-checkbox",3,"formControl"],[1,"ai-model-form__toggle-text"],[1,"ai-model-form__toggle-hint"],["legend","Pricing","legendHint","per million tokens \u2014 leave blank to skip cost monitoring",3,"formGroup"],["label","Input","controlId","pricing-input"],["dsControl","","id","pricing-input","type","number","placeholder","e.g. 2.50","min","0","step","0.01","formControlName","inputMTokens"],["label","Output","controlId","pricing-output"],["dsControl","","id","pricing-output","type","number","placeholder","e.g. 10.00","min","0","step","0.01","formControlName","outputMTokens"],["label","Cache write","controlId","pricing-cache-write"],["dsControl","","id","pricing-cache-write","type","number","placeholder","e.g. 3.75","min","0","step","0.01","formControlName","cacheWrite"],["label","Cache read","controlId","pricing-cache-read"],["dsControl","","id","pricing-cache-read","type","number","placeholder","e.g. 0.30","min","0","step","0.01","formControlName","cacheRead"],["dsButton","","variant","primary","type","submit",3,"disabled"],["dsButton","","type","button",3,"click"],["value","","disabled",""],[3,"value"]],template:function(e,c){e&1&&(os(0,"ds-page")(1,"ds-section-header",0)(2,"button",1),qh("click",function(){return c.cancel()}),fC(3," \u2190 AI models "),zu()(),Ew(4,he,2,0,"p",2)(5,Ae,51,17,"form",3),zu()),e&2&&(EE(),Vh("title",c.isEditMode()?"Edit AI model":"New AI model"),EE(3),Iw(c.isLoading()?4:5));},dependencies:[hn,fn,un,dn,cn,at,sn,qt,md,Co,Mo,Ht,Fn,yn,Ut,po,ho,Zr,Yr,An,On,wa],encapsulation:2})};export{ge as AiModelFormComponent};