@whoz-oss/coday-client 0.0.0-workstream-forge.150 → 0.0.0-workstream-forge.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/{chunk-Cx7xIq5f.js → chunk--bHVSLeo.js} +1 -1
- package/browser/{chunk-C9WjWw7H.js → chunk-7yVp_Uq2.js} +1 -1
- package/browser/{chunk-CR00BQez.js → chunk-B4IZfhzA.js} +1 -1
- package/browser/{chunk-BY_MA-MK.js → chunk-B9NNTWdp.js} +1 -1
- package/browser/{chunk-CyAgKEyG.js → chunk-BHGOzB83.js} +1 -1
- package/browser/{chunk-BzOgvaxD.js → chunk-BIthZmMx.js} +1 -1
- package/browser/{chunk-DNMYSlFd.js → chunk-BMD8wLGz.js} +1 -1
- package/browser/{chunk-JmQJ3CVi.js → chunk-BOdjiZK6.js} +1 -1
- package/browser/{chunk-CwNa91EL.js → chunk-BRWchw6J.js} +1 -1
- package/browser/{chunk-BWAj0rSN.js → chunk-BTjNj_8C.js} +1 -1
- package/browser/{chunk-qaD2n8u_.js → chunk-BW7mvGdi.js} +1 -1
- package/browser/{chunk-ujoCYdYF.js → chunk-BYHP3slz.js} +1 -1
- package/browser/{chunk-DqBE6CNm.js → chunk-Bm6INvWQ.js} +1 -1
- package/browser/chunk-Bvlf_PXn.js +1 -0
- package/browser/chunk-C1BNh9jc.js +1 -0
- package/browser/{chunk-DxQHsSbG.js → chunk-CGxOdZWL.js} +1 -1
- package/browser/{chunk-BR73EwqQ.js → chunk-CPsR3XIc.js} +1 -1
- package/browser/{chunk-DPc9xAYs.js → chunk-CUIUEK1z.js} +1 -1
- package/browser/{chunk-BcYv2wJ9.js → chunk-CY_kwpSV.js} +1 -1
- package/browser/{chunk-CxJkkUeP.js → chunk-CjXgRwGe.js} +1 -1
- package/browser/{chunk-Pezwe8-Y.js → chunk-CkXBKBqj.js} +1 -1
- package/browser/{chunk-Cpa4GG3R.js → chunk-Cl8g4x8z.js} +1 -1
- package/browser/{chunk-D4zxyoC1.js → chunk-Cp1T7BMx.js} +1 -1
- package/browser/{chunk-wofrz1qV.js → chunk-CtUCMRyL.js} +1 -1
- package/browser/{chunk-BTpPupFp.js → chunk-Czf8CT4u.js} +1 -1
- package/browser/{chunk-Dw0BJEuQ.js → chunk-D5NljUW4.js} +1 -1
- package/browser/{chunk-Df3oB5zl.js → chunk-D5T9WGY8.js} +1 -1
- package/browser/{chunk-C4i_zGQp.js → chunk-Dbd8Oz1E.js} +1 -1
- package/browser/{chunk-BdnHH8q-.js → chunk-DfIyIzl1.js} +3 -3
- package/browser/{chunk-DhFD8pei.js → chunk-Di67jBuj.js} +1 -1
- package/browser/{chunk-CjIsEiKL.js → chunk-DixiRVQh.js} +1 -1
- package/browser/{chunk-D5xDtFv2.js → chunk-Dka3vETG.js} +1 -1
- package/browser/{chunk-pCaEb0Sb.js → chunk-Dl95giFc.js} +1 -1
- package/browser/{chunk-SwepUtI6.js → chunk-DnPDsY68.js} +1 -1
- package/browser/{chunk-PH1xCUi9.js → chunk-DrhgorP8.js} +1 -1
- package/browser/{chunk-DAEuADwB.js → chunk-EuVDcJLv.js} +1 -1
- package/browser/{chunk-B2DG1wyc.js → chunk-GzNEC2B6.js} +1 -1
- package/browser/{chunk-DGMjo00Z.js → chunk-NbUA7gq-.js} +1 -1
- package/browser/{chunk-aDye58OO.js → chunk-Vi0DNn3Z.js} +1 -1
- package/browser/{chunk-ZCWL_klb.js → chunk-gy3l7dZs.js} +1 -1
- package/browser/{chunk-D38WrTi8.js → chunk-iTK_TLYu.js} +1 -1
- package/browser/{chunk-CTuJ4_Bp.js → chunk-js26hsw-.js} +1 -1
- package/browser/{chunk-BxxJEBXU.js → chunk-lN4tQUL_.js} +1 -1
- package/browser/{chunk-D82t3TyC.js → chunk-olz3d5om.js} +1 -1
- package/browser/{chunk-BSd9r5_N.js → chunk-teiyUr4d.js} +1 -1
- package/browser/index.html +2 -2
- package/browser/{main-C4DDTIV5.js → main-CIN22H6E.js} +1 -1
- package/package.json +1 -1
- package/browser/chunk-_m0zdf13.js +0 -1
- package/browser/chunk-rykYRXds.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import {i,O,h as vi,x as xi,C as Ci,P,M}from'./chunk-BdnHH8q-.js';import {c}from'./chunk-qaD2n8u_.js';import {p,$ as $t,f as It,F as Me,d as ie,ae as pw,af as Wn,U as U$1,J as x,H as w,ab as Ee,ag as Se,D as Df,a3 as _,z as za,K as dc,b as bf,r as r_,h as hT,y as yb,O as tv,a as pT,N as NT,I as Iv,e as yT,v as vT,k as bT,o as ig,s as sg}from'./main-C4DDTIV5.js';var U=(n,t)=>t.key;function B(n,t){if(n&1&&(za(0,"p",3),r_(1),bf()),n&2){let e=NT();yb(),Iv(e.deletion.error());}}function W(n,t){n&1&&(za(0,"p",4),r_(1,"Loading scheduled prompts\u2026"),bf());}function H(n,t){n&1&&(za(0,"p",5),r_(1,"No scheduled prompts available."),bf());}function J(n,t){n&1&&(za(0,"p",4),r_(1,"No scheduled prompts match the current filter."),bf());}function Y(n,t){if(n&1&&(za(0,"span",14),r_(1),bf()),n&2){let e=NT().$implicit;yb(),Iv(e.prompt.description);}}function G(n,t){n&1&&(za(0,"ds-tag",20),r_(1,"Read-only"),bf());}function Q(n,t){if(n&1){let e=bT();za(0,"button",24),dc("click",function(){ig(e);let l=NT(2).$implicit,c=NT(2);return sg(c.toggle(l))}),r_(1),bf(),za(2,"button",24),dc("click",function(){ig(e);let l=NT(2).$implicit,c=NT(2);return sg(c.edit(l))}),r_(3,"Edit"),bf();}if(n&2){let e=NT(2).$implicit;yb(),Iv(e.prompt.enabled?"Disable":"Enable");}}function X(n,t){if(n&1){let e=bT();hT(0,Q,4,1),za(1,"agentos-row-delete-action",23),dc("deleteRequested",function(){ig(e);let l=NT().$implicit,c=NT(2);return sg(c.deletion.request(l.key))})("deleteConfirmed",function(){ig(e);let l=NT().$implicit,c=NT(2);return sg(c.confirmDelete(l))})("deleteCancelled",function(){ig(e);let l=NT(3);return sg(l.deletion.cancel())}),bf();}if(n&2){let e=NT().$implicit,o=NT(2);pT(o.deletion.confirmingId()!==e.key?0:-1),yb(),tv("rowKey",e.key)("rowLabel",e.prompt.name)("state",o.deletion);}}function Z(n,t){n&1&&(za(0,"button",22),r_(1,"Inherited"),bf());}function ee(n,t){if(n&1&&(za(0,"tr",9)(1,"td",12)(2,"span",13),r_(3),bf(),hT(4,Y,2,1,"span",14),bf(),za(5,"td",15),r_(6),bf(),za(7,"td",16)(8,"ds-tag",17),r_(9),bf()(),za(10,"td",18)(11,"div",19)(12,"ds-tag",17),r_(13),bf(),hT(14,G,2,0,"ds-tag",20),bf()(),za(15,"td",21),hT(16,X,2,4)(17,Z,2,0,"button",22),bf()()),n&2){let e=t.$implicit,o=NT(2);yb(3),Iv(e.prompt.name),yb(),pT(e.prompt.description?4:-1),yb(2),Iv(o.scheduleLabel(e.prompt)),yb(2),tv("variant",e.prompt.enabled?"accent":"outline"),yb(),Iv(e.prompt.enabled?"Enabled":"Disabled"),yb(3),tv("variant",e.scope==="platform"?"neutral":"accent"),yb(),Iv(e.scope==="platform"?"Platform":"Namespace"),yb(),pT(e.scope==="platform"?14:-1),yb(2),pT(e.scope==="namespace"?16:17);}}function te(n,t){if(n&1&&(za(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),r_(5,"Name"),bf(),za(6,"th",10),r_(7,"Schedule"),bf(),za(8,"th",10),r_(9,"Status"),bf(),za(10,"th",10),r_(11,"Scope"),bf(),za(12,"th",10)(13,"span",11),r_(14,"Actions"),bf()()()(),za(15,"tbody",8),yT(16,ee,18,9,"tr",9,U),bf()()()),n&2){let e=NT();yb(16),vT(e.rowFilter.filteredRows());}}var K=class n{route=p($t);router=p(It);destroyRef=p(Me);state=p(c);namespaceId=this.route.snapshot.params.namespaceId;rows=ie([]);isLoading=ie(true);deletion=i();rowFilter=O(this.rows,t=>[t.prompt.name,t.prompt.description,this.scheduleLabel(t.prompt),t.prompt.enabled?"Enabled":"Disabled",t.scope].filter(Boolean).join(" "));constructor(){pw({platform:this.state.listPlatform().pipe(Wn(()=>_([]))),namespace:this.state.listByNamespace(this.namespaceId)}).pipe(U$1(this.destroyRef)).subscribe({next:({platform:t,namespace:e})=>{this.rows.set([...t.map((o,l)=>({key:`platform:${o.id??l}`,prompt:o,scope:"platform"})),...e.map((o,l)=>({key:`namespace:${o.id??l}`,prompt:o,scope:"namespace"}))]),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"scheduled-prompts","new"]);}edit(t){t.scope==="platform"||!t.prompt.id||this.router.navigate(["/agentos",this.namespaceId,"scheduled-prompts",t.prompt.id,"edit"]);}toggle(t){if(t.scope==="platform")return;(t.prompt.enabled?this.state.disable(t.prompt.id??""):this.state.enable(t.prompt.id??"")).pipe(U$1(this.destroyRef)).subscribe(o=>this.rows.update(l=>l.map(c=>c.key===t.key?x(w({},c),{prompt:o}):c)));}confirmDelete(t){t.scope==="platform"||!t.prompt.id||this.deletion.execute(t.key,{request$:this.state.delete(t.prompt.id).pipe(U$1(this.destroyRef)),onSuccess:()=>this.rows.update(e=>e.filter(o=>o.key!==t.key)),errorMessage:`Deleting "${t.prompt.name}" failed. Try again.`});}scheduleLabel(t){let e=t.recurrence,o=e.unit===Ee.WEEK?"week":"month",l=e.unit===Ee.WEEK&&e.days?.length?` (${e.days.map(c=>Se[c]??c).join(", ")})`:"";return `Every ${o}${l} at ${e.timeUtc} UTC`}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=Df({type:n,selectors:[["agentos-scheduled-prompt-list"]],decls:9,vars:3,consts:[["title","Scheduled prompts","description","Scheduled prompts for this namespace, including schedules inherited from the platform."],["label","Filter scheduled prompts","placeholder","Filter scheduled prompts\u2026",3,"queryChange","query"],["type","button",1,"scheduled-prompts__new",3,"click"],["role","alert",1,"scheduled-prompts__error"],["role","status",1,"scheduled-prompts__status"],[1,"scheduled-prompts__status"],[1,"scheduled-prompts__table-wrap"],["dsTable","","role","table","aria-label","Scheduled prompts"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title",""],[1,"scheduled-prompts__name"],[1,"scheduled-prompts__description"],["role","cell","data-label","Schedule"],["role","cell","data-label","Status"],[3,"variant"],["role","cell","data-label","Scope"],[1,"scheduled-prompts__tags"],["variant","outline"],["role","cell","data-label","Actions","data-actions","",1,"scheduled-prompts__actions"],["type","button","disabled",""],["deleteClass","scheduled-prompts__delete",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"],["type","button",3,"click"]],template:function(e,o){e&1&&(za(0,"ds-section-header",0)(1,"agentos-table-filter",1),dc("queryChange",function(c){return o.rowFilter.query.set(c)}),bf(),za(2,"button",2),dc("click",function(){return o.openCreateForm()}),r_(3," New scheduled prompt "),bf()(),hT(4,B,2,1,"p",3),hT(5,W,2,0,"p",4)(6,H,2,0,"p",5)(7,J,2,0,"p",4)(8,te,18,0,"div",6)),e&2&&(yb(),tv("query",o.rowFilter.query()),yb(3),pT(o.deletion.error()?4:-1),yb(),pT(o.isLoading()?5:o.rows().length===0?6:o.rowFilter.filteredRows().length===0?7:8));},dependencies:[vi,xi,Ci,P,M],styles:['.scheduled-prompts__new[_ngcontent-%COMP%]{white-space:nowrap;padding:7px 12px;border:1px solid var(--color-accent);border-radius:0;background:var(--color-accent);color:var(--color-bg);cursor:pointer;font-family:var(--font-heading);font-size:14px;font-weight:600}.scheduled-prompts__status[_ngcontent-%COMP%]{margin:20px 8px;color:var(--color-text-secondary)}.scheduled-prompts__error[_ngcontent-%COMP%]{margin:0 0 .75rem;color:var(--color-error)}.scheduled-prompts__table-wrap[_ngcontent-%COMP%]{overflow-x:auto}table.ds-table[_ngcontent-%COMP%]{width:100%;border-collapse:collapse;font-size:14px}table.ds-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid var(--color-divider);color:var(--color-neutral-600);font-size:11px;letter-spacing:.08em;text-align:left;text-transform:uppercase}table.ds-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid color-mix(in srgb,var(--color-text) 8%,transparent)}table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.scheduled-prompts__name[_ngcontent-%COMP%]{display:block;font-weight:500}.scheduled-prompts__description[_ngcontent-%COMP%]{display:block;color:var(--color-text-secondary);font-size:12px}.scheduled-prompts__tags[_ngcontent-%COMP%]{display:flex;gap:4px;flex-wrap:wrap}.scheduled-prompts__actions[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;gap:4px;white-space:nowrap}.scheduled-prompts__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{padding:4px 7px;border:1px solid transparent;background:transparent;color:var(--color-accent);cursor:pointer;font:inherit}.scheduled-prompts__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-100)}.scheduled-prompts__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:disabled{color:var(--color-neutral-600);cursor:default}.scheduled-prompts__actions[_ngcontent-%COMP%] .scheduled-prompts__delete[_ngcontent-%COMP%]{color:var(--color-error)}.sr-only[_ngcontent-%COMP%]{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(max-width:760px){table.ds-table[_ngcontent-%COMP%]{position:relative;display:block;width:100%}table.ds-table[_ngcontent-%COMP%] thead[_ngcontent-%COMP%]{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:14px;padding-top:12px}table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%], table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover{display:flex;flex-direction:column;padding:12px;background:var(--color-surface);border:1px solid var(--color-divider)}table.ds-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{display:grid;grid-template-columns:minmax(88px,30%) minmax(0,1fr);align-items:baseline;gap:4px 12px;padding:5px 0;border-bottom:0;overflow-wrap:anywhere;white-space:normal}table.ds-table[_ngcontent-%COMP%] td[data-label][_ngcontent-%COMP%]:before{content:attr(data-label);content:attr(data-label) / "";color:var(--color-neutral-600);font-size:11px;letter-spacing:.08em;text-transform:uppercase}table.ds-table[_ngcontent-%COMP%] td[data-title][_ngcontent-%COMP%]{display:block;margin-bottom:4px;padding:0 0 6px;border-bottom:0;font-size:15px}table.ds-table[_ngcontent-%COMP%] td[data-title][_ngcontent-%COMP%]:before{display:none}table.ds-table[_ngcontent-%COMP%] td[data-actions][_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:4px;margin-top:6px;padding:10px 0 0;border-top:1px solid var(--color-divider);text-align:right}table.ds-table[_ngcontent-%COMP%] td[data-actions][_ngcontent-%COMP%]:before{display:none}table.ds-table[_ngcontent-%COMP%] td[data-actions][_ngcontent-%COMP%] .settings-table__actions[_ngcontent-%COMP%]{flex-wrap:wrap;width:100%;white-space:normal}table.ds-table[_ngcontent-%COMP%] td[data-actions][_ngcontent-%COMP%] button[_ngcontent-%COMP%]{min-width:44px;min-height:44px;padding:0 12px}}']})};export{K as ScheduledPromptListComponent};
|
|
1
|
+
import {i,O,h as vi,x as xi,C as Ci,P,M}from'./chunk-DfIyIzl1.js';import {c}from'./chunk-BW7mvGdi.js';import {p,$ as $t,f as It,F as Me,d as ie,ae as pw,af as Wn,U as U$1,J as x,H as w,ab as Ee,ag as Se,D as Df,a3 as _,z as za,K as dc,b as bf,r as r_,h as hT,y as yb,O as tv,a as pT,N as NT,I as Iv,e as yT,v as vT,k as bT,o as ig,s as sg}from'./main-CIN22H6E.js';var U=(n,t)=>t.key;function B(n,t){if(n&1&&(za(0,"p",3),r_(1),bf()),n&2){let e=NT();yb(),Iv(e.deletion.error());}}function W(n,t){n&1&&(za(0,"p",4),r_(1,"Loading scheduled prompts\u2026"),bf());}function H(n,t){n&1&&(za(0,"p",5),r_(1,"No scheduled prompts available."),bf());}function J(n,t){n&1&&(za(0,"p",4),r_(1,"No scheduled prompts match the current filter."),bf());}function Y(n,t){if(n&1&&(za(0,"span",14),r_(1),bf()),n&2){let e=NT().$implicit;yb(),Iv(e.prompt.description);}}function G(n,t){n&1&&(za(0,"ds-tag",20),r_(1,"Read-only"),bf());}function Q(n,t){if(n&1){let e=bT();za(0,"button",24),dc("click",function(){ig(e);let l=NT(2).$implicit,c=NT(2);return sg(c.toggle(l))}),r_(1),bf(),za(2,"button",24),dc("click",function(){ig(e);let l=NT(2).$implicit,c=NT(2);return sg(c.edit(l))}),r_(3,"Edit"),bf();}if(n&2){let e=NT(2).$implicit;yb(),Iv(e.prompt.enabled?"Disable":"Enable");}}function X(n,t){if(n&1){let e=bT();hT(0,Q,4,1),za(1,"agentos-row-delete-action",23),dc("deleteRequested",function(){ig(e);let l=NT().$implicit,c=NT(2);return sg(c.deletion.request(l.key))})("deleteConfirmed",function(){ig(e);let l=NT().$implicit,c=NT(2);return sg(c.confirmDelete(l))})("deleteCancelled",function(){ig(e);let l=NT(3);return sg(l.deletion.cancel())}),bf();}if(n&2){let e=NT().$implicit,o=NT(2);pT(o.deletion.confirmingId()!==e.key?0:-1),yb(),tv("rowKey",e.key)("rowLabel",e.prompt.name)("state",o.deletion);}}function Z(n,t){n&1&&(za(0,"button",22),r_(1,"Inherited"),bf());}function ee(n,t){if(n&1&&(za(0,"tr",9)(1,"td",12)(2,"span",13),r_(3),bf(),hT(4,Y,2,1,"span",14),bf(),za(5,"td",15),r_(6),bf(),za(7,"td",16)(8,"ds-tag",17),r_(9),bf()(),za(10,"td",18)(11,"div",19)(12,"ds-tag",17),r_(13),bf(),hT(14,G,2,0,"ds-tag",20),bf()(),za(15,"td",21),hT(16,X,2,4)(17,Z,2,0,"button",22),bf()()),n&2){let e=t.$implicit,o=NT(2);yb(3),Iv(e.prompt.name),yb(),pT(e.prompt.description?4:-1),yb(2),Iv(o.scheduleLabel(e.prompt)),yb(2),tv("variant",e.prompt.enabled?"accent":"outline"),yb(),Iv(e.prompt.enabled?"Enabled":"Disabled"),yb(3),tv("variant",e.scope==="platform"?"neutral":"accent"),yb(),Iv(e.scope==="platform"?"Platform":"Namespace"),yb(),pT(e.scope==="platform"?14:-1),yb(2),pT(e.scope==="namespace"?16:17);}}function te(n,t){if(n&1&&(za(0,"div",6)(1,"table",7)(2,"thead",8)(3,"tr",9)(4,"th",10),r_(5,"Name"),bf(),za(6,"th",10),r_(7,"Schedule"),bf(),za(8,"th",10),r_(9,"Status"),bf(),za(10,"th",10),r_(11,"Scope"),bf(),za(12,"th",10)(13,"span",11),r_(14,"Actions"),bf()()()(),za(15,"tbody",8),yT(16,ee,18,9,"tr",9,U),bf()()()),n&2){let e=NT();yb(16),vT(e.rowFilter.filteredRows());}}var K=class n{route=p($t);router=p(It);destroyRef=p(Me);state=p(c);namespaceId=this.route.snapshot.params.namespaceId;rows=ie([]);isLoading=ie(true);deletion=i();rowFilter=O(this.rows,t=>[t.prompt.name,t.prompt.description,this.scheduleLabel(t.prompt),t.prompt.enabled?"Enabled":"Disabled",t.scope].filter(Boolean).join(" "));constructor(){pw({platform:this.state.listPlatform().pipe(Wn(()=>_([]))),namespace:this.state.listByNamespace(this.namespaceId)}).pipe(U$1(this.destroyRef)).subscribe({next:({platform:t,namespace:e})=>{this.rows.set([...t.map((o,l)=>({key:`platform:${o.id??l}`,prompt:o,scope:"platform"})),...e.map((o,l)=>({key:`namespace:${o.id??l}`,prompt:o,scope:"namespace"}))]),this.isLoading.set(false);},error:()=>this.isLoading.set(false)});}openCreateForm(){this.router.navigate(["/agentos",this.namespaceId,"scheduled-prompts","new"]);}edit(t){t.scope==="platform"||!t.prompt.id||this.router.navigate(["/agentos",this.namespaceId,"scheduled-prompts",t.prompt.id,"edit"]);}toggle(t){if(t.scope==="platform")return;(t.prompt.enabled?this.state.disable(t.prompt.id??""):this.state.enable(t.prompt.id??"")).pipe(U$1(this.destroyRef)).subscribe(o=>this.rows.update(l=>l.map(c=>c.key===t.key?x(w({},c),{prompt:o}):c)));}confirmDelete(t){t.scope==="platform"||!t.prompt.id||this.deletion.execute(t.key,{request$:this.state.delete(t.prompt.id).pipe(U$1(this.destroyRef)),onSuccess:()=>this.rows.update(e=>e.filter(o=>o.key!==t.key)),errorMessage:`Deleting "${t.prompt.name}" failed. Try again.`});}scheduleLabel(t){let e=t.recurrence,o=e.unit===Ee.WEEK?"week":"month",l=e.unit===Ee.WEEK&&e.days?.length?` (${e.days.map(c=>Se[c]??c).join(", ")})`:"";return `Every ${o}${l} at ${e.timeUtc} UTC`}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=Df({type:n,selectors:[["agentos-scheduled-prompt-list"]],decls:9,vars:3,consts:[["title","Scheduled prompts","description","Scheduled prompts for this namespace, including schedules inherited from the platform."],["label","Filter scheduled prompts","placeholder","Filter scheduled prompts\u2026",3,"queryChange","query"],["type","button",1,"scheduled-prompts__new",3,"click"],["role","alert",1,"scheduled-prompts__error"],["role","status",1,"scheduled-prompts__status"],[1,"scheduled-prompts__status"],[1,"scheduled-prompts__table-wrap"],["dsTable","","role","table","aria-label","Scheduled prompts"],["role","rowgroup"],["role","row"],["role","columnheader"],[1,"sr-only"],["role","cell","data-label","Name","data-title",""],[1,"scheduled-prompts__name"],[1,"scheduled-prompts__description"],["role","cell","data-label","Schedule"],["role","cell","data-label","Status"],[3,"variant"],["role","cell","data-label","Scope"],[1,"scheduled-prompts__tags"],["variant","outline"],["role","cell","data-label","Actions","data-actions","",1,"scheduled-prompts__actions"],["type","button","disabled",""],["deleteClass","scheduled-prompts__delete",3,"deleteRequested","deleteConfirmed","deleteCancelled","rowKey","rowLabel","state"],["type","button",3,"click"]],template:function(e,o){e&1&&(za(0,"ds-section-header",0)(1,"agentos-table-filter",1),dc("queryChange",function(c){return o.rowFilter.query.set(c)}),bf(),za(2,"button",2),dc("click",function(){return o.openCreateForm()}),r_(3," New scheduled prompt "),bf()(),hT(4,B,2,1,"p",3),hT(5,W,2,0,"p",4)(6,H,2,0,"p",5)(7,J,2,0,"p",4)(8,te,18,0,"div",6)),e&2&&(yb(),tv("query",o.rowFilter.query()),yb(3),pT(o.deletion.error()?4:-1),yb(),pT(o.isLoading()?5:o.rows().length===0?6:o.rowFilter.filteredRows().length===0?7:8));},dependencies:[vi,xi,Ci,P,M],styles:['.scheduled-prompts__new[_ngcontent-%COMP%]{white-space:nowrap;padding:7px 12px;border:1px solid var(--color-accent);border-radius:0;background:var(--color-accent);color:var(--color-bg);cursor:pointer;font-family:var(--font-heading);font-size:14px;font-weight:600}.scheduled-prompts__status[_ngcontent-%COMP%]{margin:20px 8px;color:var(--color-text-secondary)}.scheduled-prompts__error[_ngcontent-%COMP%]{margin:0 0 .75rem;color:var(--color-error)}.scheduled-prompts__table-wrap[_ngcontent-%COMP%]{overflow-x:auto}table.ds-table[_ngcontent-%COMP%]{width:100%;border-collapse:collapse;font-size:14px}table.ds-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid var(--color-divider);color:var(--color-neutral-600);font-size:11px;letter-spacing:.08em;text-align:left;text-transform:uppercase}table.ds-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:7px;border-bottom:1px solid color-mix(in srgb,var(--color-text) 8%,transparent)}table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover)}.scheduled-prompts__name[_ngcontent-%COMP%]{display:block;font-weight:500}.scheduled-prompts__description[_ngcontent-%COMP%]{display:block;color:var(--color-text-secondary);font-size:12px}.scheduled-prompts__tags[_ngcontent-%COMP%]{display:flex;gap:4px;flex-wrap:wrap}.scheduled-prompts__actions[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;gap:4px;white-space:nowrap}.scheduled-prompts__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{padding:4px 7px;border:1px solid transparent;background:transparent;color:var(--color-accent);cursor:pointer;font:inherit}.scheduled-prompts__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-100)}.scheduled-prompts__actions[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:disabled{color:var(--color-neutral-600);cursor:default}.scheduled-prompts__actions[_ngcontent-%COMP%] .scheduled-prompts__delete[_ngcontent-%COMP%]{color:var(--color-error)}.sr-only[_ngcontent-%COMP%]{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(max-width:760px){table.ds-table[_ngcontent-%COMP%]{position:relative;display:block;width:100%}table.ds-table[_ngcontent-%COMP%] thead[_ngcontent-%COMP%]{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:14px;padding-top:12px}table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%], table.ds-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:hover{display:flex;flex-direction:column;padding:12px;background:var(--color-surface);border:1px solid var(--color-divider)}table.ds-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{display:grid;grid-template-columns:minmax(88px,30%) minmax(0,1fr);align-items:baseline;gap:4px 12px;padding:5px 0;border-bottom:0;overflow-wrap:anywhere;white-space:normal}table.ds-table[_ngcontent-%COMP%] td[data-label][_ngcontent-%COMP%]:before{content:attr(data-label);content:attr(data-label) / "";color:var(--color-neutral-600);font-size:11px;letter-spacing:.08em;text-transform:uppercase}table.ds-table[_ngcontent-%COMP%] td[data-title][_ngcontent-%COMP%]{display:block;margin-bottom:4px;padding:0 0 6px;border-bottom:0;font-size:15px}table.ds-table[_ngcontent-%COMP%] td[data-title][_ngcontent-%COMP%]:before{display:none}table.ds-table[_ngcontent-%COMP%] td[data-actions][_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:4px;margin-top:6px;padding:10px 0 0;border-top:1px solid var(--color-divider);text-align:right}table.ds-table[_ngcontent-%COMP%] td[data-actions][_ngcontent-%COMP%]:before{display:none}table.ds-table[_ngcontent-%COMP%] td[data-actions][_ngcontent-%COMP%] .settings-table__actions[_ngcontent-%COMP%]{flex-wrap:wrap;width:100%;white-space:normal}table.ds-table[_ngcontent-%COMP%] td[data-actions][_ngcontent-%COMP%] button[_ngcontent-%COMP%]{min-width:44px;min-height:44px;padding:0 12px}}']})};export{K as ScheduledPromptListComponent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {v}from'./chunk-ujoCYdYF.js';import {R,q,J}from'./chunk-CR00BQez.js';import {p,$ as $t,f as It,F as Me,d as ie,a2 as F,M as Mi,j as Sg,U,J as x,H as w,D as Df,z as za,K as dc,r as r_,b as bf,h as hT,y as yb,I as Iv,a as pT,k as bT,e as yT,a5 as mT,L as sS,l as lc,N as NT,O as tv,Q as cS,v as vT,A as Af,a4 as dT,o as ig,s as sg,m as WT,u as uc}from'./main-C4DDTIV5.js';import {v as vt,a as ve,$,K as Kn,z as zn,Z as Zn,X as Xn,Y as Ye,c as bt,e as fn,L as Ln,W as Wn,b as pn,V as Vn}from'./chunk-BdnHH8q-.js';import'./chunk-rykYRXds.js';function se(i,t){i&1&&(za(0,"p",5),r_(1,"Loading\u2026"),bf());}function ce(i,t){if(i&1&&(za(0,"label",23),lc(1,"input",24),sS(),za(2,"span"),r_(3),bf()()),i&2){let e=t.$implicit,o=NT(3);yb(),tv("formControl",o.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!o.isAdmin()),cS(),yb(2),Iv(e.label);}}function de(i,t){if(i&1&&(za(0,"fieldset",8)(1,"legend",22),r_(2,"Configuration scope"),bf(),yT(3,ce,4,4,"label",23,dT().trackByScope,true),bf()),i&2){let e=NT(2);tv("disabled",e.isEditMode()),yb(3),vT(e.scopeOptions);}}function ue(i,t){if(i&1&&(za(0,"option",13),r_(1),bf()),i&2){let e=t.$implicit,o=NT(2);tv("value",e),yb(),Iv(o.authTypeLabel[e]);}}function pe(i,t){i&1&&r_(0," Leave a field unchanged to keep the stored credential. ");}function he(i,t){i&1&&(za(0,"span",11),r_(1,"*"),bf());}function me(i,t){if(i&1&&(za(0,"p",28),r_(1),bf()),i&2){let e=NT(2).$implicit;tv("id","as-hint-"+e.key),yb(),Iv(e.hint);}}function ge(i,t){if(i&1&&(lc(0,"input",27),sS(),hT(1,me,2,2,"p",28)),i&2){let e=NT().$implicit;WT("auth-setting-form__input"+(e.secret?" auth-setting-form__input--secret":"")),tv("id","as-cred-"+e.key)("type",e.secret?"password":"text")("placeholder",e.placeholder)("formControl",t)("autocomplete",e.secret?"new-password":"off"),uc("aria-describedby",e.hint?"as-hint-"+e.key:null),cS(),yb(),pT(e.hint?1:-1);}}function Ce(i,t){if(i&1&&(za(0,"div",9)(1,"label",26),r_(2),hT(3,he,2,0,"span",11),bf(),hT(4,ge,2,9),bf()),i&2){let e,o=t.$implicit,l=NT(3);yb(),tv("for","as-cred-"+o.key),yb(),Af(" ",o.label," "),yb(),pT(o.required?3:-1),yb(),pT((e=l.controlForField(o.key))?4:-1,e);}}function fe(i,t){if(i&1&&(za(0,"fieldset",18)(1,"legend",22),r_(2,"Credentials"),bf(),za(3,"p",25),r_(4," Values are stored encrypted and masked on read. "),hT(5,pe,1,0),bf(),yT(6,Ce,5,4,"div",9,dT().trackByField,true),bf()),i&2){let e=NT(2);yb(5),pT(e.isEditMode()?5:-1),yb(),vT(e.credentialFields());}}function ye(i,t){if(i&1){let e=bT();za(0,"form",7),dc("ngSubmit",function(){ig(e);let l=NT();return sg(l.submit())}),hT(1,de,5,1,"fieldset",8),za(2,"div",9)(3,"label",10),r_(4,"Auth type "),za(5,"span",11),r_(6,"*"),bf()(),za(7,"select",12),yT(8,ue,2,2,"option",13,mT),bf(),sS(),bf(),za(10,"div",9)(11,"label",14),r_(12,"Name "),za(13,"span",11),r_(14,"*"),bf()(),lc(15,"input",15),sS(),bf(),za(16,"div",9)(17,"label",16),r_(18,"Description"),bf(),lc(19,"input",17),sS(),bf(),hT(20,fe,8,1,"fieldset",18),za(21,"div",19)(22,"button",20),r_(23),bf(),za(24,"button",21),dc("click",function(){ig(e);let l=NT();return sg(l.cancel())}),r_(25,"Cancel"),bf()()();}if(i&2){let e=NT();tv("formGroup",e.form),yb(),pT(e.isPlatformMode?-1:1),yb(6),tv("formControl",e.authTypeControl),cS(),yb(),vT(e.authTypeOptions),yb(7),tv("formControl",e.nameControl),cS(),yb(4),tv("formControl",e.descriptionControl),cS(),yb(),pT(e.credentialFields().length>0?20:-1),yb(2),tv("disabled",e.form.invalid||e.isSubmitting()),yb(),Af(" ",e.isEditMode()?"Save changes":"Create"," ");}}var _e=new Set(["namespace","userOnNs","userGlobal"]),P=Object.freeze({platform:"Platform (read-only)",namespace:"Namespace configuration",userOnNs:"Personal \u2014 this namespace only",userGlobal:"Personal \u2014 all namespaces"}),Se={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}]},le=class i{route=p($t);router=p(It);destroyRef=p(Me);state=p(R);namespaceRole=p(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?ie(true):F(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});authTypeOptions=q;authTypeLabel=J;scopeOptions=[{value:"namespace",label:P.namespace},{value:"userOnNs",label:P.userOnNs},{value:"userGlobal",label:P.userGlobal}];nameControl=new vt("",{nonNullable:true,validators:[ve.required,ve.minLength(1)]});descriptionControl=new vt(null);authTypeControl=new vt("ApiKeyAuthSetting",{nonNullable:true,validators:[ve.required]});scopeControl=new vt("namespace",{nonNullable:true});form=new $({name:this.nameControl,description:this.descriptionControl,authType:this.authTypeControl,scope:this.scopeControl});apiKeyControl=new vt("",{nonNullable:true});usernameControl=new vt("",{nonNullable:true});passwordControl=new vt("",{nonNullable:true});tokenControl=new vt("",{nonNullable:true});discoveryUrlControl=new vt("",{nonNullable:true});authorizationUrlControl=new vt("",{nonNullable:true});tokenUrlControl=new vt("",{nonNullable:true});clientIdControl=new vt("",{nonNullable:true});clientSecretControl=new vt("",{nonNullable:true});scopesControl=new vt("",{nonNullable:true});resourceUrlControl=new vt("",{nonNullable:true});selectedAuthType=F(this.authTypeControl.valueChanges,{initialValue:this.authTypeControl.value});credentialFields=Mi(()=>Se[this.selectedAuthType()]);isEditMode=ie(false);isSubmitting=ie(false);isLoading=ie(false);existingConfig=null;initialCredentials={};constructor(){this.isPlatformMode||Sg(()=>{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,o=t.get("authSettingId");if(o){this.isEditMode.set(true),this.scopeControl.disable(),this.authTypeControl.disable(),this.loadConfig(o);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let l=this.parseScope(e.get("scope"));this.scopeControl.setValue(l);let v=e.get("template");v&&this.hydrateFromTemplate(v);}parseScope(t){return t&&_e.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,o=e.username??"",l=e.password??"";this.usernameControl.setValue(o),this.passwordControl.setValue(l),this.initialCredentials.username=o,this.initialCredentials.password=l;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,o=this.authTypeControl.value,l=this.form.getRawValue().scope,v=this.isPlatformMode?null:this.namespaceId??null,w=this.buildTypedPayload(o,t,e);(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,w,this.existingConfig):this.state.create(w,l,v)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}buildTypedPayload(t,e,o){let l={name:e,description:o};switch(t){case "ApiKeyAuthSetting":return x(w({},l),{authType:"ApiKeyAuthSetting",apiKey:this.credentialValue("apiKey",this.apiKeyControl.value)});case "BasicAuthAuthSetting":return x(w({},l),{authType:"BasicAuthAuthSetting",username:this.credentialValue("username",this.usernameControl.value),password:this.credentialValue("password",this.passwordControl.value)});case "BearerTokenAuthSetting":return x(w({},l),{authType:"BearerTokenAuthSetting",token:this.credentialValue("token",this.tokenControl.value)});case "OAuthDiscoverableAuthSetting":return x(w({},l),{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({},l),{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({},l),{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({},l),{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=Df({type:i,selectors:[["agentos-auth-setting-form"]],decls:10,vars:2,consts:[[1,"auth-setting-form"],[1,"auth-setting-form__header"],["type","button","title","Back to auth settings",1,"auth-setting-form__back",3,"click"],[1,"auth-setting-form__back-icon"],[1,"auth-setting-form__title"],[1,"auth-setting-form__loading"],[1,"auth-setting-form__form",3,"formGroup"],[1,"auth-setting-form__form",3,"ngSubmit","formGroup"],[1,"auth-setting-form__scope",3,"disabled"],[1,"auth-setting-form__field"],["for","as-auth-type",1,"auth-setting-form__label"],["aria-hidden","true"],["id","as-auth-type",1,"auth-setting-form__select",3,"formControl"],[3,"value"],["for","as-name",1,"auth-setting-form__label"],["id","as-name","type","text","placeholder","e.g. GitHub OAuth App","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],["for","as-description",1,"auth-setting-form__label"],["id","as-description","type","text","placeholder","Optional \u2014 short description of this auth setting","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],[1,"auth-setting-form__credentials"],[1,"auth-setting-form__actions"],["type","submit",1,"auth-setting-form__btn","auth-setting-form__btn--primary",3,"disabled"],["type","button",1,"auth-setting-form__btn",3,"click"],[1,"auth-setting-form__label"],[1,"auth-setting-form__scope-option"],["type","radio",3,"formControl","value","disabled"],[1,"auth-setting-form__credentials-hint"],[1,"auth-setting-form__label",3,"for"],[3,"id","type","placeholder","formControl","autocomplete"],[1,"auth-setting-form__field-hint",3,"id"]],template:function(e,o){e&1&&(za(0,"div",0)(1,"header",1)(2,"button",2),dc("click",function(){return o.cancel()}),za(3,"span",3),r_(4,"\u2190"),bf(),r_(5," Auth Settings "),bf(),za(6,"h1",4),r_(7),bf()(),hT(8,se,2,0,"p",5)(9,ye,26,8,"form",6),bf()),e&2&&(yb(7),Iv(o.isEditMode()?"Edit auth setting":"New auth setting"),yb(),pT(o.isLoading()?8:9));},dependencies:[Kn,zn,Zn,Xn,Ye,bt,fn,Ln,Wn,pn,Vn],styles:[".auth-setting-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;padding:1.5rem;max-width:640px}.auth-setting-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.4rem;background:none;border:none;cursor:pointer;color:var(--color-text-secondary);font-size:.85rem;padding:0}.auth-setting-form__back[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.auth-setting-form__back-icon[_ngcontent-%COMP%]{font-size:1rem}.auth-setting-form__title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:600;color:var(--color-text);margin:0}.auth-setting-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem}.auth-setting-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.auth-setting-form__scope[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem;display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__scope[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9rem;color:var(--color-text)}.auth-setting-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem}.auth-setting-form__field-hint[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary);margin:0;line-height:1.4}.auth-setting-form__label[_ngcontent-%COMP%]{font-size:.85rem;font-weight:500;color:var(--color-text-secondary)}.auth-setting-form__input[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;transition:border-color .15s ease;width:100%;box-sizing:border-box}.auth-setting-form__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.auth-setting-form__select[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;cursor:pointer;transition:border-color .15s ease}.auth-setting-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__credentials[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem 1rem;display:flex;flex-direction:column;gap:.75rem;margin:0}.auth-setting-form__credentials[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__credentials-hint[_ngcontent-%COMP%]{font-size:.78rem;color:var(--color-text-secondary);margin:0}.auth-setting-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center;padding-top:.5rem}.auth-setting-form__btn[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem 1.25rem;cursor:pointer;font-size:.9rem;font-weight:500;background:var(--color-bg-secondary);color:var(--color-text);transition:background .15s ease}.auth-setting-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.auth-setting-form__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.auth-setting-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-on-primary, #fff);border-color:var(--color-primary)}.auth-setting-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, var(--color-primary))}"]})};
|
|
1
|
+
import {v}from'./chunk-BYHP3slz.js';import {R,q,J}from'./chunk-B4IZfhzA.js';import {p,$ as $t,f as It,F as Me,d as ie,a2 as F,M as Mi,j as Sg,U,J as x,H as w,D as Df,z as za,K as dc,r as r_,b as bf,h as hT,y as yb,I as Iv,a as pT,k as bT,e as yT,a5 as mT,L as sS,l as lc,N as NT,O as tv,Q as cS,v as vT,A as Af,a4 as dT,o as ig,s as sg,m as WT,u as uc}from'./main-CIN22H6E.js';import {v as vt,a as ve,$,K as Kn,z as zn,Z as Zn,X as Xn,Y as Ye,c as bt,e as fn,L as Ln,W as Wn,b as pn,V as Vn}from'./chunk-DfIyIzl1.js';import'./chunk-C1BNh9jc.js';function se(i,t){i&1&&(za(0,"p",5),r_(1,"Loading\u2026"),bf());}function ce(i,t){if(i&1&&(za(0,"label",23),lc(1,"input",24),sS(),za(2,"span"),r_(3),bf()()),i&2){let e=t.$implicit,o=NT(3);yb(),tv("formControl",o.scopeControl)("value",e.value)("disabled",e.value==="namespace"&&!o.isAdmin()),cS(),yb(2),Iv(e.label);}}function de(i,t){if(i&1&&(za(0,"fieldset",8)(1,"legend",22),r_(2,"Configuration scope"),bf(),yT(3,ce,4,4,"label",23,dT().trackByScope,true),bf()),i&2){let e=NT(2);tv("disabled",e.isEditMode()),yb(3),vT(e.scopeOptions);}}function ue(i,t){if(i&1&&(za(0,"option",13),r_(1),bf()),i&2){let e=t.$implicit,o=NT(2);tv("value",e),yb(),Iv(o.authTypeLabel[e]);}}function pe(i,t){i&1&&r_(0," Leave a field unchanged to keep the stored credential. ");}function he(i,t){i&1&&(za(0,"span",11),r_(1,"*"),bf());}function me(i,t){if(i&1&&(za(0,"p",28),r_(1),bf()),i&2){let e=NT(2).$implicit;tv("id","as-hint-"+e.key),yb(),Iv(e.hint);}}function ge(i,t){if(i&1&&(lc(0,"input",27),sS(),hT(1,me,2,2,"p",28)),i&2){let e=NT().$implicit;WT("auth-setting-form__input"+(e.secret?" auth-setting-form__input--secret":"")),tv("id","as-cred-"+e.key)("type",e.secret?"password":"text")("placeholder",e.placeholder)("formControl",t)("autocomplete",e.secret?"new-password":"off"),uc("aria-describedby",e.hint?"as-hint-"+e.key:null),cS(),yb(),pT(e.hint?1:-1);}}function Ce(i,t){if(i&1&&(za(0,"div",9)(1,"label",26),r_(2),hT(3,he,2,0,"span",11),bf(),hT(4,ge,2,9),bf()),i&2){let e,o=t.$implicit,l=NT(3);yb(),tv("for","as-cred-"+o.key),yb(),Af(" ",o.label," "),yb(),pT(o.required?3:-1),yb(),pT((e=l.controlForField(o.key))?4:-1,e);}}function fe(i,t){if(i&1&&(za(0,"fieldset",18)(1,"legend",22),r_(2,"Credentials"),bf(),za(3,"p",25),r_(4," Values are stored encrypted and masked on read. "),hT(5,pe,1,0),bf(),yT(6,Ce,5,4,"div",9,dT().trackByField,true),bf()),i&2){let e=NT(2);yb(5),pT(e.isEditMode()?5:-1),yb(),vT(e.credentialFields());}}function ye(i,t){if(i&1){let e=bT();za(0,"form",7),dc("ngSubmit",function(){ig(e);let l=NT();return sg(l.submit())}),hT(1,de,5,1,"fieldset",8),za(2,"div",9)(3,"label",10),r_(4,"Auth type "),za(5,"span",11),r_(6,"*"),bf()(),za(7,"select",12),yT(8,ue,2,2,"option",13,mT),bf(),sS(),bf(),za(10,"div",9)(11,"label",14),r_(12,"Name "),za(13,"span",11),r_(14,"*"),bf()(),lc(15,"input",15),sS(),bf(),za(16,"div",9)(17,"label",16),r_(18,"Description"),bf(),lc(19,"input",17),sS(),bf(),hT(20,fe,8,1,"fieldset",18),za(21,"div",19)(22,"button",20),r_(23),bf(),za(24,"button",21),dc("click",function(){ig(e);let l=NT();return sg(l.cancel())}),r_(25,"Cancel"),bf()()();}if(i&2){let e=NT();tv("formGroup",e.form),yb(),pT(e.isPlatformMode?-1:1),yb(6),tv("formControl",e.authTypeControl),cS(),yb(),vT(e.authTypeOptions),yb(7),tv("formControl",e.nameControl),cS(),yb(4),tv("formControl",e.descriptionControl),cS(),yb(),pT(e.credentialFields().length>0?20:-1),yb(2),tv("disabled",e.form.invalid||e.isSubmitting()),yb(),Af(" ",e.isEditMode()?"Save changes":"Create"," ");}}var _e=new Set(["namespace","userOnNs","userGlobal"]),P=Object.freeze({platform:"Platform (read-only)",namespace:"Namespace configuration",userOnNs:"Personal \u2014 this namespace only",userGlobal:"Personal \u2014 all namespaces"}),Se={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}]},le=class i{route=p($t);router=p(It);destroyRef=p(Me);state=p(R);namespaceRole=p(v);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;isAdmin=this.isPlatformMode?ie(true):F(this.namespaceRole.isAdminOfNamespace$(this.namespaceId),{initialValue:false});authTypeOptions=q;authTypeLabel=J;scopeOptions=[{value:"namespace",label:P.namespace},{value:"userOnNs",label:P.userOnNs},{value:"userGlobal",label:P.userGlobal}];nameControl=new vt("",{nonNullable:true,validators:[ve.required,ve.minLength(1)]});descriptionControl=new vt(null);authTypeControl=new vt("ApiKeyAuthSetting",{nonNullable:true,validators:[ve.required]});scopeControl=new vt("namespace",{nonNullable:true});form=new $({name:this.nameControl,description:this.descriptionControl,authType:this.authTypeControl,scope:this.scopeControl});apiKeyControl=new vt("",{nonNullable:true});usernameControl=new vt("",{nonNullable:true});passwordControl=new vt("",{nonNullable:true});tokenControl=new vt("",{nonNullable:true});discoveryUrlControl=new vt("",{nonNullable:true});authorizationUrlControl=new vt("",{nonNullable:true});tokenUrlControl=new vt("",{nonNullable:true});clientIdControl=new vt("",{nonNullable:true});clientSecretControl=new vt("",{nonNullable:true});scopesControl=new vt("",{nonNullable:true});resourceUrlControl=new vt("",{nonNullable:true});selectedAuthType=F(this.authTypeControl.valueChanges,{initialValue:this.authTypeControl.value});credentialFields=Mi(()=>Se[this.selectedAuthType()]);isEditMode=ie(false);isSubmitting=ie(false);isLoading=ie(false);existingConfig=null;initialCredentials={};constructor(){this.isPlatformMode||Sg(()=>{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,o=t.get("authSettingId");if(o){this.isEditMode.set(true),this.scopeControl.disable(),this.authTypeControl.disable(),this.loadConfig(o);return}if(this.isPlatformMode){this.scopeControl.setValue("platform"),this.scopeControl.disable();return}let l=this.parseScope(e.get("scope"));this.scopeControl.setValue(l);let v=e.get("template");v&&this.hydrateFromTemplate(v);}parseScope(t){return t&&_e.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,o=e.username??"",l=e.password??"";this.usernameControl.setValue(o),this.passwordControl.setValue(l),this.initialCredentials.username=o,this.initialCredentials.password=l;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,o=this.authTypeControl.value,l=this.form.getRawValue().scope,v=this.isPlatformMode?null:this.namespaceId??null,w=this.buildTypedPayload(o,t,e);(this.isEditMode()&&this.existingConfig?.id?this.state.update(this.existingConfig.id,w,this.existingConfig):this.state.create(w,l,v)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:()=>this.isSubmitting.set(false)});}buildTypedPayload(t,e,o){let l={name:e,description:o};switch(t){case "ApiKeyAuthSetting":return x(w({},l),{authType:"ApiKeyAuthSetting",apiKey:this.credentialValue("apiKey",this.apiKeyControl.value)});case "BasicAuthAuthSetting":return x(w({},l),{authType:"BasicAuthAuthSetting",username:this.credentialValue("username",this.usernameControl.value),password:this.credentialValue("password",this.passwordControl.value)});case "BearerTokenAuthSetting":return x(w({},l),{authType:"BearerTokenAuthSetting",token:this.credentialValue("token",this.tokenControl.value)});case "OAuthDiscoverableAuthSetting":return x(w({},l),{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({},l),{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({},l),{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({},l),{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=Df({type:i,selectors:[["agentos-auth-setting-form"]],decls:10,vars:2,consts:[[1,"auth-setting-form"],[1,"auth-setting-form__header"],["type","button","title","Back to auth settings",1,"auth-setting-form__back",3,"click"],[1,"auth-setting-form__back-icon"],[1,"auth-setting-form__title"],[1,"auth-setting-form__loading"],[1,"auth-setting-form__form",3,"formGroup"],[1,"auth-setting-form__form",3,"ngSubmit","formGroup"],[1,"auth-setting-form__scope",3,"disabled"],[1,"auth-setting-form__field"],["for","as-auth-type",1,"auth-setting-form__label"],["aria-hidden","true"],["id","as-auth-type",1,"auth-setting-form__select",3,"formControl"],[3,"value"],["for","as-name",1,"auth-setting-form__label"],["id","as-name","type","text","placeholder","e.g. GitHub OAuth App","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],["for","as-description",1,"auth-setting-form__label"],["id","as-description","type","text","placeholder","Optional \u2014 short description of this auth setting","autocomplete","off",1,"auth-setting-form__input",3,"formControl"],[1,"auth-setting-form__credentials"],[1,"auth-setting-form__actions"],["type","submit",1,"auth-setting-form__btn","auth-setting-form__btn--primary",3,"disabled"],["type","button",1,"auth-setting-form__btn",3,"click"],[1,"auth-setting-form__label"],[1,"auth-setting-form__scope-option"],["type","radio",3,"formControl","value","disabled"],[1,"auth-setting-form__credentials-hint"],[1,"auth-setting-form__label",3,"for"],[3,"id","type","placeholder","formControl","autocomplete"],[1,"auth-setting-form__field-hint",3,"id"]],template:function(e,o){e&1&&(za(0,"div",0)(1,"header",1)(2,"button",2),dc("click",function(){return o.cancel()}),za(3,"span",3),r_(4,"\u2190"),bf(),r_(5," Auth Settings "),bf(),za(6,"h1",4),r_(7),bf()(),hT(8,se,2,0,"p",5)(9,ye,26,8,"form",6),bf()),e&2&&(yb(7),Iv(o.isEditMode()?"Edit auth setting":"New auth setting"),yb(),pT(o.isLoading()?8:9));},dependencies:[Kn,zn,Zn,Xn,Ye,bt,fn,Ln,Wn,pn,Vn],styles:[".auth-setting-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.5rem;padding:1.5rem;max-width:640px}.auth-setting-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.4rem;background:none;border:none;cursor:pointer;color:var(--color-text-secondary);font-size:.85rem;padding:0}.auth-setting-form__back[_ngcontent-%COMP%]:hover{color:var(--color-primary)}.auth-setting-form__back-icon[_ngcontent-%COMP%]{font-size:1rem}.auth-setting-form__title[_ngcontent-%COMP%]{font-size:1.4rem;font-weight:600;color:var(--color-text);margin:0}.auth-setting-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem}.auth-setting-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.auth-setting-form__scope[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem;display:flex;flex-direction:column;gap:.5rem}.auth-setting-form__scope[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__scope-option[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;font-size:.9rem;color:var(--color-text)}.auth-setting-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.35rem}.auth-setting-form__field-hint[_ngcontent-%COMP%]{font-size:.75rem;color:var(--color-text-secondary);margin:0;line-height:1.4}.auth-setting-form__label[_ngcontent-%COMP%]{font-size:.85rem;font-weight:500;color:var(--color-text-secondary)}.auth-setting-form__input[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;transition:border-color .15s ease;width:100%;box-sizing:border-box}.auth-setting-form__input[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__input--secret[_ngcontent-%COMP%]{font-family:monospace;letter-spacing:.05em}.auth-setting-form__select[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem .75rem;background:var(--color-bg-secondary);color:var(--color-text);font-size:.9rem;outline:none;cursor:pointer;transition:border-color .15s ease}.auth-setting-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-primary)}.auth-setting-form__credentials[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:8px;padding:.75rem 1rem 1rem;display:flex;flex-direction:column;gap:.75rem;margin:0}.auth-setting-form__credentials[_ngcontent-%COMP%] legend[_ngcontent-%COMP%]{padding:0 .25rem}.auth-setting-form__credentials-hint[_ngcontent-%COMP%]{font-size:.78rem;color:var(--color-text-secondary);margin:0}.auth-setting-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;align-items:center;padding-top:.5rem}.auth-setting-form__btn[_ngcontent-%COMP%]{border:1px solid var(--color-border);border-radius:6px;padding:.5rem 1.25rem;cursor:pointer;font-size:.9rem;font-weight:500;background:var(--color-bg-secondary);color:var(--color-text);transition:background .15s ease}.auth-setting-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover)}.auth-setting-form__btn[_ngcontent-%COMP%]:disabled{opacity:.5;cursor:not-allowed}.auth-setting-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary);color:var(--color-on-primary, #fff);border-color:var(--color-primary)}.auth-setting-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, var(--color-primary))}"]})};
|
|
2
2
|
export{le as AuthSettingFormComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {$,v as vt,a as ve$1,K as Kn,z as zn,Z as Zn,X as Xn,Y as Ye,d as dn,c as bt,L as Ln,W as Wn$1,q as qt,t as Lt,b as pn,V as Vn,y as yn}from'./chunk-BdnHH8q-.js';import {p,$ as $t,f as It,F as Me,ap as N,aj as k,a2 as F,af as Wn,aq as Re,M as Mi,d as ie,j as Sg,U,J as x,H as w,D as Df,a3 as _,z as za,K as dc,r as r_,b as bf,h as hT,y as yb,I as Iv,a as pT,k as bT,l as lc,L as sS,e as yT,a5 as mT,N as NT,O as tv,Q as cS,v as vT,A as Af,a4 as dT,ar as Cv,o as ig,s as sg}from'./main-C4DDTIV5.js';function me(l,t){l&1&&(za(0,"p",5),r_(1,"Loading\u2026"),bf());}function ce(l,t){if(l&1&&lc(0,"input",11),l&2){let e=NT(2);tv("value",e.selectedProviderLabel());}}function se(l,t){if(l&1&&(za(0,"option",48),r_(1),bf()),l&2){let e=t.$implicit;tv("value",e.id),yb(),Cv("",e.name," (",e.apiType,")");}}function pe(l,t){if(l&1&&(za(0,"select",12)(1,"option",47),r_(2,"Select provider"),bf(),yT(3,se,2,3,"option",48,dT().trackByProvider,true),bf(),sS()),l&2){let e=NT(2);tv("formControl",e.aiProviderIdControl),cS(),yb(3),vT(e.providers());}}function ue(l,t){if(l&1&&(za(0,"option",30),r_(1),bf()),l&2){let e=t.$implicit;tv("ngValue",e),yb(),Iv(e.toLowerCase());}}function fe(l,t){l&1&&(za(0,"span",31),r_(1,"Not supported yet for Anthropic and Gemini providers."),bf());}function _e(l,t){l&1&&(za(0,"span",31),r_(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. "),bf());}function ge(l,t){l&1&&(za(0,"span",32),r_(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. "),bf());}function Ce(l,t){if(l&1){let e=bT();za(0,"form",7),dc("ngSubmit",function(){ig(e);let u=NT();return sg(u.submit())}),za(1,"div",8)(2,"label",9),r_(3," Provider "),za(4,"span",10),r_(5,"*"),bf()(),hT(6,ce,1,1,"input",11)(7,pe,5,1,"select",12),bf(),za(8,"div",8)(9,"label",13),r_(10," API name "),za(11,"span",10),r_(12,"*"),bf()(),lc(13,"input",14),sS(),bf(),za(14,"div",8)(15,"label",15),r_(16,"Description"),bf(),lc(17,"input",16),sS(),bf(),za(18,"div",8)(19,"label",17),r_(20,"Alias"),bf(),lc(21,"input",18),sS(),bf(),za(22,"div",8)(23,"label",19),r_(24,"Priority"),bf(),lc(25,"input",20),sS(),bf(),za(26,"div",21)(27,"div",8)(28,"label",22),r_(29,"Temperature"),bf(),lc(30,"input",23),sS(),bf(),za(31,"div",8)(32,"label",24),r_(33,"Context window"),bf(),lc(34,"input",25),sS(),bf()(),za(35,"div",8)(36,"label",26),r_(37,"Max completion tokens"),bf(),lc(38,"input",27),sS(),bf(),za(39,"div",8)(40,"label",28),r_(41,"Reasoning effort"),bf(),za(42,"select",29)(43,"option",30),r_(44,"Provider default"),bf(),yT(45,ue,2,2,"option",30,mT),bf(),sS(),hT(47,fe,2,0,"span",31)(48,_e,2,0,"span",31),hT(49,ge,2,0,"span",32),bf(),za(50,"fieldset",33)(51,"legend",34),r_(52," Pricing "),za(53,"span",35),r_(54,"(per million tokens \u2014 leave blank to skip cost monitoring)"),bf()(),za(55,"div",21)(56,"div",8)(57,"label",36),r_(58,"Input"),bf(),lc(59,"input",37),sS(),bf(),za(60,"div",8)(61,"label",38),r_(62,"Output"),bf(),lc(63,"input",39),sS(),bf()(),za(64,"div",21)(65,"div",8)(66,"label",40),r_(67,"Cache write"),bf(),lc(68,"input",41),sS(),bf(),za(69,"div",8)(70,"label",42),r_(71,"Cache read"),bf(),lc(72,"input",43),sS(),bf()()(),za(73,"div",44)(74,"button",45),r_(75),bf(),za(76,"button",46),dc("click",function(){ig(e);let u=NT();return sg(u.cancel())}),r_(77,"Cancel"),bf()()();}if(l&2){let e=NT();tv("formGroup",e.form),yb(6),pT(e.isEditMode()?6:7),yb(7),tv("formControl",e.apiModelNameControl),cS(),yb(4),tv("formControl",e.descriptionControl),cS(),yb(4),tv("formControl",e.aliasControl),cS(),yb(4),tv("formControl",e.priorityControl),cS(),yb(5),tv("formControl",e.temperatureControl),cS(),yb(4),tv("formControl",e.contextWindowControl),cS(),yb(4),tv("formControl",e.maxCompletionTokensControl),cS(),yb(4),tv("formControl",e.reasoningEffortControl),cS(),yb(),tv("ngValue",null),yb(2),vT(e.reasoningEffortOptions),yb(2),pT(e.reasoningEffortUnsupported()?47:48),yb(2),pT(e.temperatureMayConflictWithEffort()?49:-1),yb(),tv("formGroup",e.pricingGroup),yb(9),cS(),yb(4),cS(),yb(5),cS(),yb(4),cS(),yb(2),tv("disabled",e.form.invalid||e.isSubmitting()),yb(),Af(" ",e.isEditMode()?"Save changes":"Create"," ");}}var ve=["Anthropic","Gemini"],de=class l{route=p($t);router=p(It);destroyRef=p(Me);aiModelController=p(N);aiProviderController=p(k);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;providers=F(this.aiProviderController.listAiProvider(this.isPlatformMode?"none":this.namespaceId).pipe(Wn(()=>_([]))),{initialValue:[]});form=new $({aiProviderId:new vt("",{nonNullable:true,validators:[ve$1.required]}),apiModelName:new vt("",{nonNullable:true,validators:[ve$1.required,ve$1.minLength(1)]}),description:new vt(null),alias:new vt("",{nonNullable:true}),priority:new vt(0,{nonNullable:true}),temperature:new vt(null),contextWindow:new vt(null),maxCompletionTokens:new vt(null),reasoningEffort:new vt(null),pricing:new $({inputMTokens:new vt(null),outputMTokens:new vt(null),cacheWrite:new vt(null),cacheRead:new vt(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 pricingGroup(){return this.form.controls.pricing}reasoningEffortOptions=Object.values(Re);selectedProviderId=F(this.form.controls.aiProviderId.valueChanges,{initialValue:this.form.controls.aiProviderId.value});reasoningEffortUnsupported=Mi(()=>{let t=this.providers().find(e=>e.id===this.selectedProviderId())?.apiType;return t!==void 0&&ve.includes(t)});temperatureValue=F(this.form.controls.temperature.valueChanges,{initialValue:this.form.controls.temperature.value});reasoningEffortValue=F(this.form.controls.reasoningEffort.valueChanges,{initialValue:this.form.controls.reasoningEffort.value});temperatureMayConflictWithEffort=Mi(()=>{let t=this.temperatureValue();return this.reasoningEffortValue()!=null&&t!=null&&t!==1});isEditMode=ie(false);isSubmitting=ie(false);isLoading=ie(false);selectedProviderLabel=Mi(()=>{let t=this.aiProviderIdControl.value,e=this.providers().find(p=>p.id===t);return e?`${e.name} (${e.apiType})`:t});existingModel=null;constructor(){Sg(()=>{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.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,T=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,pricing:u});(this.isEditMode()?this.aiModelController.updateAiModel(this.existingModel.id??"",T):this.aiModelController.createAiModel(T)).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||l)};static \u0275cmp=Df({type:l,selectors:[["agentos-ai-model-form"]],decls:10,vars:2,consts:[[1,"ai-model-form"],[1,"ai-model-form__header"],["type","button","title","Back to AI models",1,"ai-model-form__back",3,"click"],[1,"ai-model-form__back-icon"],[1,"ai-model-form__title"],[1,"ai-model-form__loading"],[1,"ai-model-form__form",3,"formGroup"],[1,"ai-model-form__form",3,"ngSubmit","formGroup"],[1,"ai-model-form__field"],["for","model-provider",1,"ai-model-form__label"],["aria-hidden","true"],["id","model-provider","type","text","readonly","","tabindex","-1",1,"ai-model-form__input","ai-model-form__input--readonly",3,"value"],["id","model-provider",1,"ai-model-form__select",3,"formControl"],["for","model-api-name",1,"ai-model-form__label"],["id","model-api-name","type","text","placeholder","e.g. gpt-4o, claude-3-5-sonnet-20241022","autocomplete","off",1,"ai-model-form__input","ai-model-form__input--mono",3,"formControl"],["for","model-description",1,"ai-model-form__label"],["id","model-description","type","text","placeholder","Optional \u2014 short description of this model config","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-alias",1,"ai-model-form__label"],["id","model-alias","type","text","placeholder","e.g. fast, smart \u2014 short identifier used internally","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-priority",1,"ai-model-form__label"],["id","model-priority","type","number","placeholder","0 \u2014 higher wins when multiple configs share the same alias","min","0","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__row"],["for","model-temperature",1,"ai-model-form__label"],["id","model-temperature","type","number","placeholder","0 \u2013 2","min","0","max","2","step","0.1",1,"ai-model-form__input",3,"formControl"],["for","model-context-window",1,"ai-model-form__label"],["id","model-context-window","type","number","placeholder","e.g. 128000","min","1","step","1",1,"ai-model-form__input",3,"formControl"],["for","model-max-completion-tokens",1,"ai-model-form__label"],["id","model-max-completion-tokens","type","number","placeholder","e.g. 4096","min","1","step","1",1,"ai-model-form__input",3,"formControl"],["for","model-reasoning-effort",1,"ai-model-form__label"],["id","model-reasoning-effort",1,"ai-model-form__select",3,"formControl"],[3,"ngValue"],[1,"ai-model-form__hint"],[1,"ai-model-form__hint","ai-model-form__hint--warning"],[1,"ai-model-form__section",3,"formGroup"],[1,"ai-model-form__section-title"],[1,"ai-model-form__section-hint"],["for","pricing-input",1,"ai-model-form__label"],["id","pricing-input","type","number","placeholder","e.g. 2.50","min","0","step","0.01","formControlName","inputMTokens",1,"ai-model-form__input"],["for","pricing-output",1,"ai-model-form__label"],["id","pricing-output","type","number","placeholder","e.g. 10.00","min","0","step","0.01","formControlName","outputMTokens",1,"ai-model-form__input"],["for","pricing-cache-write",1,"ai-model-form__label"],["id","pricing-cache-write","type","number","placeholder","e.g. 3.75","min","0","step","0.01","formControlName","cacheWrite",1,"ai-model-form__input"],["for","pricing-cache-read",1,"ai-model-form__label"],["id","pricing-cache-read","type","number","placeholder","e.g. 0.30","min","0","step","0.01","formControlName","cacheRead",1,"ai-model-form__input"],[1,"ai-model-form__actions"],["type","submit",1,"ai-model-form__btn","ai-model-form__btn--primary",3,"disabled"],["type","button",1,"ai-model-form__btn",3,"click"],["value","","disabled",""],[3,"value"]],template:function(e,p){e&1&&(za(0,"div",0)(1,"header",1)(2,"button",2),dc("click",function(){return p.cancel()}),za(3,"span",3),r_(4,"\u2190"),bf(),r_(5," AI models "),bf(),za(6,"h1",4),r_(7),bf()(),hT(8,me,2,0,"p",5)(9,Ce,78,16,"form",6),bf()),e&2&&(yb(7),Iv(p.isEditMode()?"Edit AI model":"New AI model"),yb(),pT(p.isLoading()?8:9));},dependencies:[Kn,zn,Zn,Xn,Ye,dn,bt,Ln,Wn$1,qt,Lt,pn,Vn,yn],styles:[".ai-model-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:480px;margin:0 auto;padding:2rem 1rem}.ai-model-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-model-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.ai-model-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-model-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.ai-model-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.ai-model-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.ai-model-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.ai-model-form__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.ai-model-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.ai-model-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.ai-model-form__input[_ngcontent-%COMP%], .ai-model-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.ai-model-form__input[_ngcontent-%COMP%]:focus, .ai-model-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.ai-model-form__input[_ngcontent-%COMP%]::placeholder, .ai-model-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.ai-model-form__input--mono[_ngcontent-%COMP%]{font-family:monospace}.ai-model-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:1rem}.ai-model-form__section-title[_ngcontent-%COMP%]{font-size:.875rem;font-weight:600;color:var(--color-text);padding:0 .25rem}.ai-model-form__section-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);font-size:.8125rem}.ai-model-form__hint[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.8125rem}.ai-model-form__hint--warning[_ngcontent-%COMP%]{color:var(--color-warning)}.ai-model-form__input--readonly[_ngcontent-%COMP%]{color:var(--color-text-secondary);cursor:default;background:var(--color-surface-muted, rgba(0, 0, 0, .03))}.ai-model-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.ai-model-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.ai-model-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.ai-model-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.ai-model-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.ai-model-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{de as AiModelFormComponent};
|
|
1
|
+
import {$,v as vt,a as ve$1,K as Kn,z as zn,Z as Zn,X as Xn,Y as Ye,d as dn,c as bt,L as Ln,W as Wn$1,q as qt,t as Lt,b as pn,V as Vn,y as yn}from'./chunk-DfIyIzl1.js';import {p,$ as $t,f as It,F as Me,ap as N,aj as k,a2 as F,af as Wn,aq as Re,M as Mi,d as ie,j as Sg,U,J as x,H as w,D as Df,a3 as _,z as za,K as dc,r as r_,b as bf,h as hT,y as yb,I as Iv,a as pT,k as bT,l as lc,L as sS,e as yT,a5 as mT,N as NT,O as tv,Q as cS,v as vT,A as Af,a4 as dT,ar as Cv,o as ig,s as sg}from'./main-CIN22H6E.js';function me(l,t){l&1&&(za(0,"p",5),r_(1,"Loading\u2026"),bf());}function ce(l,t){if(l&1&&lc(0,"input",11),l&2){let e=NT(2);tv("value",e.selectedProviderLabel());}}function se(l,t){if(l&1&&(za(0,"option",48),r_(1),bf()),l&2){let e=t.$implicit;tv("value",e.id),yb(),Cv("",e.name," (",e.apiType,")");}}function pe(l,t){if(l&1&&(za(0,"select",12)(1,"option",47),r_(2,"Select provider"),bf(),yT(3,se,2,3,"option",48,dT().trackByProvider,true),bf(),sS()),l&2){let e=NT(2);tv("formControl",e.aiProviderIdControl),cS(),yb(3),vT(e.providers());}}function ue(l,t){if(l&1&&(za(0,"option",30),r_(1),bf()),l&2){let e=t.$implicit;tv("ngValue",e),yb(),Iv(e.toLowerCase());}}function fe(l,t){l&1&&(za(0,"span",31),r_(1,"Not supported yet for Anthropic and Gemini providers."),bf());}function _e(l,t){l&1&&(za(0,"span",31),r_(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. "),bf());}function ge(l,t){l&1&&(za(0,"span",32),r_(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. "),bf());}function Ce(l,t){if(l&1){let e=bT();za(0,"form",7),dc("ngSubmit",function(){ig(e);let u=NT();return sg(u.submit())}),za(1,"div",8)(2,"label",9),r_(3," Provider "),za(4,"span",10),r_(5,"*"),bf()(),hT(6,ce,1,1,"input",11)(7,pe,5,1,"select",12),bf(),za(8,"div",8)(9,"label",13),r_(10," API name "),za(11,"span",10),r_(12,"*"),bf()(),lc(13,"input",14),sS(),bf(),za(14,"div",8)(15,"label",15),r_(16,"Description"),bf(),lc(17,"input",16),sS(),bf(),za(18,"div",8)(19,"label",17),r_(20,"Alias"),bf(),lc(21,"input",18),sS(),bf(),za(22,"div",8)(23,"label",19),r_(24,"Priority"),bf(),lc(25,"input",20),sS(),bf(),za(26,"div",21)(27,"div",8)(28,"label",22),r_(29,"Temperature"),bf(),lc(30,"input",23),sS(),bf(),za(31,"div",8)(32,"label",24),r_(33,"Context window"),bf(),lc(34,"input",25),sS(),bf()(),za(35,"div",8)(36,"label",26),r_(37,"Max completion tokens"),bf(),lc(38,"input",27),sS(),bf(),za(39,"div",8)(40,"label",28),r_(41,"Reasoning effort"),bf(),za(42,"select",29)(43,"option",30),r_(44,"Provider default"),bf(),yT(45,ue,2,2,"option",30,mT),bf(),sS(),hT(47,fe,2,0,"span",31)(48,_e,2,0,"span",31),hT(49,ge,2,0,"span",32),bf(),za(50,"fieldset",33)(51,"legend",34),r_(52," Pricing "),za(53,"span",35),r_(54,"(per million tokens \u2014 leave blank to skip cost monitoring)"),bf()(),za(55,"div",21)(56,"div",8)(57,"label",36),r_(58,"Input"),bf(),lc(59,"input",37),sS(),bf(),za(60,"div",8)(61,"label",38),r_(62,"Output"),bf(),lc(63,"input",39),sS(),bf()(),za(64,"div",21)(65,"div",8)(66,"label",40),r_(67,"Cache write"),bf(),lc(68,"input",41),sS(),bf(),za(69,"div",8)(70,"label",42),r_(71,"Cache read"),bf(),lc(72,"input",43),sS(),bf()()(),za(73,"div",44)(74,"button",45),r_(75),bf(),za(76,"button",46),dc("click",function(){ig(e);let u=NT();return sg(u.cancel())}),r_(77,"Cancel"),bf()()();}if(l&2){let e=NT();tv("formGroup",e.form),yb(6),pT(e.isEditMode()?6:7),yb(7),tv("formControl",e.apiModelNameControl),cS(),yb(4),tv("formControl",e.descriptionControl),cS(),yb(4),tv("formControl",e.aliasControl),cS(),yb(4),tv("formControl",e.priorityControl),cS(),yb(5),tv("formControl",e.temperatureControl),cS(),yb(4),tv("formControl",e.contextWindowControl),cS(),yb(4),tv("formControl",e.maxCompletionTokensControl),cS(),yb(4),tv("formControl",e.reasoningEffortControl),cS(),yb(),tv("ngValue",null),yb(2),vT(e.reasoningEffortOptions),yb(2),pT(e.reasoningEffortUnsupported()?47:48),yb(2),pT(e.temperatureMayConflictWithEffort()?49:-1),yb(),tv("formGroup",e.pricingGroup),yb(9),cS(),yb(4),cS(),yb(5),cS(),yb(4),cS(),yb(2),tv("disabled",e.form.invalid||e.isSubmitting()),yb(),Af(" ",e.isEditMode()?"Save changes":"Create"," ");}}var ve=["Anthropic","Gemini"],de=class l{route=p($t);router=p(It);destroyRef=p(Me);aiModelController=p(N);aiProviderController=p(k);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=this.namespaceId===void 0;providers=F(this.aiProviderController.listAiProvider(this.isPlatformMode?"none":this.namespaceId).pipe(Wn(()=>_([]))),{initialValue:[]});form=new $({aiProviderId:new vt("",{nonNullable:true,validators:[ve$1.required]}),apiModelName:new vt("",{nonNullable:true,validators:[ve$1.required,ve$1.minLength(1)]}),description:new vt(null),alias:new vt("",{nonNullable:true}),priority:new vt(0,{nonNullable:true}),temperature:new vt(null),contextWindow:new vt(null),maxCompletionTokens:new vt(null),reasoningEffort:new vt(null),pricing:new $({inputMTokens:new vt(null),outputMTokens:new vt(null),cacheWrite:new vt(null),cacheRead:new vt(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 pricingGroup(){return this.form.controls.pricing}reasoningEffortOptions=Object.values(Re);selectedProviderId=F(this.form.controls.aiProviderId.valueChanges,{initialValue:this.form.controls.aiProviderId.value});reasoningEffortUnsupported=Mi(()=>{let t=this.providers().find(e=>e.id===this.selectedProviderId())?.apiType;return t!==void 0&&ve.includes(t)});temperatureValue=F(this.form.controls.temperature.valueChanges,{initialValue:this.form.controls.temperature.value});reasoningEffortValue=F(this.form.controls.reasoningEffort.valueChanges,{initialValue:this.form.controls.reasoningEffort.value});temperatureMayConflictWithEffort=Mi(()=>{let t=this.temperatureValue();return this.reasoningEffortValue()!=null&&t!=null&&t!==1});isEditMode=ie(false);isSubmitting=ie(false);isLoading=ie(false);selectedProviderLabel=Mi(()=>{let t=this.aiProviderIdControl.value,e=this.providers().find(p=>p.id===t);return e?`${e.name} (${e.apiType})`:t});existingModel=null;constructor(){Sg(()=>{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.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,T=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,pricing:u});(this.isEditMode()?this.aiModelController.updateAiModel(this.existingModel.id??"",T):this.aiModelController.createAiModel(T)).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||l)};static \u0275cmp=Df({type:l,selectors:[["agentos-ai-model-form"]],decls:10,vars:2,consts:[[1,"ai-model-form"],[1,"ai-model-form__header"],["type","button","title","Back to AI models",1,"ai-model-form__back",3,"click"],[1,"ai-model-form__back-icon"],[1,"ai-model-form__title"],[1,"ai-model-form__loading"],[1,"ai-model-form__form",3,"formGroup"],[1,"ai-model-form__form",3,"ngSubmit","formGroup"],[1,"ai-model-form__field"],["for","model-provider",1,"ai-model-form__label"],["aria-hidden","true"],["id","model-provider","type","text","readonly","","tabindex","-1",1,"ai-model-form__input","ai-model-form__input--readonly",3,"value"],["id","model-provider",1,"ai-model-form__select",3,"formControl"],["for","model-api-name",1,"ai-model-form__label"],["id","model-api-name","type","text","placeholder","e.g. gpt-4o, claude-3-5-sonnet-20241022","autocomplete","off",1,"ai-model-form__input","ai-model-form__input--mono",3,"formControl"],["for","model-description",1,"ai-model-form__label"],["id","model-description","type","text","placeholder","Optional \u2014 short description of this model config","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-alias",1,"ai-model-form__label"],["id","model-alias","type","text","placeholder","e.g. fast, smart \u2014 short identifier used internally","autocomplete","off",1,"ai-model-form__input",3,"formControl"],["for","model-priority",1,"ai-model-form__label"],["id","model-priority","type","number","placeholder","0 \u2014 higher wins when multiple configs share the same alias","min","0","step","1",1,"ai-model-form__input",3,"formControl"],[1,"ai-model-form__row"],["for","model-temperature",1,"ai-model-form__label"],["id","model-temperature","type","number","placeholder","0 \u2013 2","min","0","max","2","step","0.1",1,"ai-model-form__input",3,"formControl"],["for","model-context-window",1,"ai-model-form__label"],["id","model-context-window","type","number","placeholder","e.g. 128000","min","1","step","1",1,"ai-model-form__input",3,"formControl"],["for","model-max-completion-tokens",1,"ai-model-form__label"],["id","model-max-completion-tokens","type","number","placeholder","e.g. 4096","min","1","step","1",1,"ai-model-form__input",3,"formControl"],["for","model-reasoning-effort",1,"ai-model-form__label"],["id","model-reasoning-effort",1,"ai-model-form__select",3,"formControl"],[3,"ngValue"],[1,"ai-model-form__hint"],[1,"ai-model-form__hint","ai-model-form__hint--warning"],[1,"ai-model-form__section",3,"formGroup"],[1,"ai-model-form__section-title"],[1,"ai-model-form__section-hint"],["for","pricing-input",1,"ai-model-form__label"],["id","pricing-input","type","number","placeholder","e.g. 2.50","min","0","step","0.01","formControlName","inputMTokens",1,"ai-model-form__input"],["for","pricing-output",1,"ai-model-form__label"],["id","pricing-output","type","number","placeholder","e.g. 10.00","min","0","step","0.01","formControlName","outputMTokens",1,"ai-model-form__input"],["for","pricing-cache-write",1,"ai-model-form__label"],["id","pricing-cache-write","type","number","placeholder","e.g. 3.75","min","0","step","0.01","formControlName","cacheWrite",1,"ai-model-form__input"],["for","pricing-cache-read",1,"ai-model-form__label"],["id","pricing-cache-read","type","number","placeholder","e.g. 0.30","min","0","step","0.01","formControlName","cacheRead",1,"ai-model-form__input"],[1,"ai-model-form__actions"],["type","submit",1,"ai-model-form__btn","ai-model-form__btn--primary",3,"disabled"],["type","button",1,"ai-model-form__btn",3,"click"],["value","","disabled",""],[3,"value"]],template:function(e,p){e&1&&(za(0,"div",0)(1,"header",1)(2,"button",2),dc("click",function(){return p.cancel()}),za(3,"span",3),r_(4,"\u2190"),bf(),r_(5," AI models "),bf(),za(6,"h1",4),r_(7),bf()(),hT(8,me,2,0,"p",5)(9,Ce,78,16,"form",6),bf()),e&2&&(yb(7),Iv(p.isEditMode()?"Edit AI model":"New AI model"),yb(),pT(p.isLoading()?8:9));},dependencies:[Kn,zn,Zn,Xn,Ye,dn,bt,Ln,Wn$1,qt,Lt,pn,Vn,yn],styles:[".ai-model-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:480px;margin:0 auto;padding:2rem 1rem}.ai-model-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.ai-model-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.ai-model-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.ai-model-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.ai-model-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.ai-model-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.ai-model-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.ai-model-form__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.ai-model-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.ai-model-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.ai-model-form__input[_ngcontent-%COMP%], .ai-model-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.ai-model-form__input[_ngcontent-%COMP%]:focus, .ai-model-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.ai-model-form__input[_ngcontent-%COMP%]::placeholder, .ai-model-form__select[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.ai-model-form__input--mono[_ngcontent-%COMP%]{font-family:monospace}.ai-model-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:1rem}.ai-model-form__section-title[_ngcontent-%COMP%]{font-size:.875rem;font-weight:600;color:var(--color-text);padding:0 .25rem}.ai-model-form__section-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);font-size:.8125rem}.ai-model-form__hint[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.8125rem}.ai-model-form__hint--warning[_ngcontent-%COMP%]{color:var(--color-warning)}.ai-model-form__input--readonly[_ngcontent-%COMP%]{color:var(--color-text-secondary);cursor:default;background:var(--color-surface-muted, rgba(0, 0, 0, .03))}.ai-model-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.ai-model-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.ai-model-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.ai-model-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.ai-model-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.ai-model-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}"]})};export{de as AiModelFormComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {p as p$1}from'./chunk-
|
|
1
|
+
import {p as p$1}from'./chunk-DfIyIzl1.js';import {p,$ as $t,x as jD,C as y,D as Df,S as Sf,r as r_,T as Tf,y as yb,I as Iv}from'./main-CIN22H6E.js';var A=class r{route=p($t);http=p(jD);config=p(y);message="Authentication in progress\u2026";ngOnInit(){let e=this.route.snapshot.queryParamMap.get("code"),t=this.route.snapshot.queryParamMap.get("state"),o=this.route.snapshot.queryParamMap.get("error"),i=this.route.snapshot.queryParamMap.get("error_description");if(o){console.warn("[AgentOS OAuth Callback] OAuth error:",o,i),this.notifyParentAndClose({success:false,error:i||o});return}if(!e){console.error("[AgentOS OAuth Callback] Missing authorization code"),this.message="OAuth callback error: missing authorization code.",this.notifyParentAndClose({success:false,error:"Missing authorization code"});return}this.http.post(`${this.config.basePath}/api/oauth/callback`,{code:e,state:t}).subscribe({next:()=>{console.log("[AgentOS OAuth Callback] Backend callback resolved"),this.notifyParentAndClose({success:true});},error:a=>{console.error("[AgentOS OAuth Callback] Backend callback failed:",a),this.notifyParentAndClose({success:false,error:a?.error?.message||a?.message||"Token exchange failed"});}});}notifyParentAndClose(e){if(this.message=e.success?"Authentication complete. You can close this window.":`Authentication failed: ${e.error??"unknown error"}. You can close this window.`,window.opener)try{window.opener.postMessage(e,window.location.origin);}catch(t){console.error("[AgentOS OAuth Callback] postMessage failed:",t),localStorage.setItem(p$1,JSON.stringify(e));}else console.warn("[AgentOS OAuth Callback] No window.opener \u2014 localStorage fallback"),localStorage.setItem(p$1,JSON.stringify(e));setTimeout(()=>window.close(),1e3);}static \u0275fac=function(t){return new(t||r)};static \u0275cmp=Df({type:r,selectors:[["agentos-oauth-callback"]],decls:2,vars:1,consts:[[2,"font-family","sans-serif","padding","2rem","text-align","center"]],template:function(t,o){t&1&&(Sf(0,"p",0),r_(1),Tf()),t&2&&(yb(),Iv(o.message));},encapsulation:2,changeDetection:1})};export{A as OAuthCallbackComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {c}from'./chunk-qaD2n8u_.js';import {$ as $$1,v as vt,a as ve$1,K as Kn,z as zn,Z as Zn,X as Xn,Y as Ye,d as dn,F as Ft,c as bt,L as Ln,W as Wn$1,q as qt,b as pn,V as Vn}from'./chunk-BdnHH8q-.js';import {p,$ as $t,f as It,F as Me$1,a9 as $,aa as Oe$1,ab as Ee$1,d as ie,ac as Ve$1,a2 as F,ad as Os,M as Mi,ae as pw,U,af as Wn,J as x,H as w,D as Df,a3 as _,z as za,K as dc,r as r_,b as bf,h as hT,y as yb,A as Af,a as pT,k as bT,l as lc,L as sS,e as yT,N as NT,O as tv,q as gv,Q as cS,v as vT,I as Iv,o as ig,s as sg,X as Xm}from'./main-C4DDTIV5.js';var A=(n,t)=>t.value,me=(n,t)=>t.id;function pe(n,t){n&1&&(za(0,"p",5),r_(1,"Loading\u2026"),bf());}function ue(n,t){n&1&&(za(0,"span",12),r_(1," Name is required. "),bf());}function fe(n,t){if(n&1&&(za(0,"p",42),r_(1),bf(),za(2,"span",13),r_(3,"Agent Config cannot be changed after creation."),bf()),n&2){let e=NT(2);yb(),Iv(e.resolveAgentConfigName(e.agentConfigIdControl.value));}}function _e(n,t){if(n&1&&(za(0,"a",43),r_(1,"Add an agent config"),bf(),r_(2," first. ")),n&2){let e=NT(3);tv("href","/agentos/"+e.namespaceId+"/agent-configs/new",Xm);}}function he(n,t){if(n&1&&(za(0,"p",13),r_(1," No agent configs available in this scope yet. "),hT(2,_e,3,1),bf()),n&2){let e=NT(2);yb(2),pT(e.isPlatformMode?-1:2);}}function ge(n,t){if(n&1&&(za(0,"option",23),r_(1),bf()),n&2){let e=t.$implicit;tv("value",e.id),yb(),Iv(e.name);}}function Ce(n,t){n&1&&(za(0,"span",12),r_(1,"Agent Config is required."),bf());}function ve(n,t){if(n&1&&(za(0,"select",44)(1,"option",45),r_(2,"Select an agent config\u2026"),bf(),yT(3,ge,2,2,"option",23,me),bf(),sS(),hT(5,Ce,2,0,"span",12),za(6,"span",13),r_(7,"Immutable after creation."),bf()),n&2){let e=NT(2);tv("formControl",e.agentConfigIdControl),cS(),yb(3),vT(e.availableAgentConfigs()),yb(2),pT(e.agentConfigIdControl.invalid&&e.agentConfigIdControl.touched?5:-1);}}function xe(n,t){n&1&&(za(0,"span",12),r_(1,"Opening message is required."),bf());}function ye(n,t){if(n&1&&(za(0,"option",23),r_(1),bf()),n&2){let e=t.$implicit;tv("value",e.value),yb(),Iv(e.label);}}function be(n,t){if(n&1){let e=bT();za(0,"label",48)(1,"input",49),dc("change",function(){let g=ig(e).$implicit,v=NT(3);return sg(v.toggleDay(g.value))}),bf(),za(2,"span",50),r_(3),bf()();}if(n&2){let e=t.$implicit,d=NT(3);yb(),tv("checked",d.isDaySelected(e.value)),yb(2),Iv(e.label);}}function Se(n,t){if(n&1&&(za(0,"div",8)(1,"span",46),r_(2,"Days of week"),bf(),za(3,"div",47),yT(4,be,4,2,"label",48,A),bf(),za(6,"span",13),r_(7,"Leave empty to run every day of the week."),bf()()),n&2){let e=NT(2);yb(4),vT(e.dayOptions);}}function Ee(n,t){n&1&&(za(0,"span",12),r_(1,"Valid time is required (HH:mm)."),bf());}function Pe(n,t){n&1&&(za(0,"span",12),r_(1,"Start date is required."),bf());}function Me(n,t){if(n&1&&(za(0,"option",23),r_(1),bf()),n&2){let e=t.$implicit;tv("value",e.value),yb(),Iv(e.label);}}function Oe(n,t){n&1&&(za(0,"span",12),r_(1,"End date is required."),bf());}function De(n,t){if(n&1&&(za(0,"div",8)(1,"label",51),r_(2," End date "),za(3,"span",10),r_(4,"*"),bf()(),lc(5,"input",52),sS(),hT(6,Oe,2,0,"span",12),bf()),n&2){let e=NT(2);yb(5),gv("scheduled-prompt-form__input--invalid",e.form.hasError("endDateRequired")&&e.endDateControl.touched),tv("formControl",e.endDateControl),cS(),yb(),pT(e.form.hasError("endDateRequired")&&e.endDateControl.touched?6:-1);}}function Te(n,t){n&1&&(za(0,"span",12),r_(1,"Must be at least 1."),bf());}function we(n,t){if(n&1&&(za(0,"div",8)(1,"label",53),r_(2," Number of occurrences "),za(3,"span",10),r_(4,"*"),bf()(),lc(5,"input",54),sS(),hT(6,Te,2,0,"span",12),bf()),n&2){let e=NT(2);yb(5),gv("scheduled-prompt-form__input--invalid",e.form.hasError("occurrenceCountRequired")&&e.occurrenceCountControl.touched),tv("formControl",e.occurrenceCountControl),cS(),yb(),pT(e.form.hasError("occurrenceCountRequired")&&e.occurrenceCountControl.touched?6:-1);}}function ke(n,t){n&1&&(za(0,"span",12),r_(1,"Invalid JSON."),bf());}function Ne(n,t){if(n&1&&(za(0,"p",38),r_(1),bf()),n&2){let e=NT(2);yb(),Iv(e.errorMessage());}}function Fe(n,t){if(n&1){let e=bT();za(0,"form",7),dc("ngSubmit",function(){ig(e);let g=NT();return sg(g.submit())}),za(1,"div",8)(2,"label",9),r_(3," Name "),za(4,"span",10),r_(5,"*"),bf()(),lc(6,"input",11),sS(),hT(7,ue,2,0,"span",12),za(8,"span",13),r_(9,'Free-form name (e.g. "Weekly Report"). Cannot be changed after creation.'),bf()(),za(10,"div",8)(11,"label",14),r_(12,"Description"),bf(),lc(13,"input",15),sS(),bf(),za(14,"div",8)(15,"label",16),r_(16," Agent Config "),za(17,"span",10),r_(18,"*"),bf()(),hT(19,fe,4,1)(20,he,3,1,"p",13)(21,ve,8,2),bf(),za(22,"div",8)(23,"label",17),r_(24," Opening message "),za(25,"span",10),r_(26,"*"),bf()(),lc(27,"textarea",18),sS(),hT(28,xe,2,0,"span",12),za(29,"span",13),r_(30," The message sent to the agent when the scheduled prompt fires. "),bf()(),za(31,"fieldset",19)(32,"legend",20),r_(33,"Recurrence"),bf(),za(34,"div",8)(35,"label",21),r_(36," Unit "),za(37,"span",10),r_(38,"*"),bf()(),za(39,"select",22),yT(40,ye,2,2,"option",23,A),bf(),sS(),bf(),hT(42,Se,8,0,"div",8),za(43,"div",8)(44,"label",24),r_(45," Time (UTC) "),za(46,"span",10),r_(47,"*"),bf()(),za(48,"div",25),lc(49,"input",26),sS(),za(50,"span",27),r_(51,"UTC"),bf()(),hT(52,Ee,2,0,"span",12),bf()(),za(53,"fieldset",19)(54,"legend",20),r_(55,"Planning"),bf(),za(56,"div",8)(57,"label",28),r_(58," Start date "),za(59,"span",10),r_(60,"*"),bf()(),lc(61,"input",29),sS(),hT(62,Pe,2,0,"span",12),bf(),za(63,"div",8)(64,"label",30),r_(65," Ends "),za(66,"span",10),r_(67,"*"),bf()(),za(68,"select",31),yT(69,Me,2,2,"option",23,A),bf(),sS(),bf(),hT(71,De,7,4,"div",8),hT(72,we,7,4,"div",8),bf(),za(73,"div",8)(74,"label",32),lc(75,"input",33),sS(),za(76,"span",34),r_(77,"Enabled"),bf()(),za(78,"p",35),r_(79," When disabled, the scheduled prompt is saved but will not run on schedule. "),bf()(),za(80,"div",8)(81,"label",36),r_(82,"External Metadata"),bf(),lc(83,"textarea",37),sS(),hT(84,ke,2,0,"span",12),za(85,"span",13),r_(86,"Optional. Opaque JSON object stored as-is. Leave empty to clear."),bf()(),hT(87,Ne,2,1,"p",38),za(88,"div",39)(89,"button",40),r_(90),bf(),za(91,"button",41),dc("click",function(){ig(e);let g=NT();return sg(g.cancel())}),r_(92,"Cancel"),bf()()();}if(n&2){let e=NT();tv("formGroup",e.form),yb(6),gv("scheduled-prompt-form__input--invalid",e.nameControl.invalid&&e.nameControl.touched),tv("formControl",e.nameControl),cS(),yb(),pT(e.nameControl.invalid&&e.nameControl.touched?7:-1),yb(6),tv("formControl",e.descriptionControl),cS(),yb(6),pT(e.isEditMode()?19:e.availableAgentConfigs().length===0?20:21),yb(8),gv("scheduled-prompt-form__textarea--invalid",e.promptContentControl.invalid&&e.promptContentControl.touched),tv("formControl",e.promptContentControl),cS(),yb(),pT(e.promptContentControl.invalid&&e.promptContentControl.touched?28:-1),yb(11),tv("formControl",e.unitControl),cS(),yb(),vT(e.schedulerUnits),yb(2),pT(e.showDayFilter()?42:-1),yb(7),tv("formControl",e.timeUtcControl),cS(),yb(3),pT(e.timeUtcControl.invalid&&e.timeUtcControl.touched?52:-1),yb(9),gv("scheduled-prompt-form__input--invalid",e.startDateControl.invalid&&e.startDateControl.touched),tv("formControl",e.startDateControl),cS(),yb(),pT(e.startDateControl.invalid&&e.startDateControl.touched?62:-1),yb(6),tv("formControl",e.endTypeControl),cS(),yb(),vT(e.endTypes),yb(2),pT(e.showEndDate()?71:-1),yb(),pT(e.showOccurrenceCount()?72:-1),yb(3),tv("formControl",e.enabledControl),cS(),yb(8),tv("formControl",e.externalMetadataJsonControl),cS(),yb(),pT(e.externalMetadataJsonControl.invalid&&e.externalMetadataJsonControl.touched?84:-1),yb(3),pT(e.errorMessage()?87:-1),yb(2),tv("disabled",e.form.invalid||e.isSubmitting()),yb(),Af(" ",e.isEditMode()?"Save changes":"Create scheduled prompt"," ");}}var se=class n{route=p($t);router=p(It);destroyRef=p(Me$1);state=p(c);agentConfigController=p($);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new $$1({name:new vt("",{nonNullable:true,validators:[ve$1.required]}),description:new vt(null),agentConfigId:new vt("",{nonNullable:true,validators:[ve$1.required]}),promptContent:new vt("",{nonNullable:true,validators:[ve$1.required]}),unit:new vt(Ee$1.WEEK,{nonNullable:true,validators:[ve$1.required]}),days:new vt([],{nonNullable:true}),timeUtc:new vt("09:00",{nonNullable:true,validators:[ve$1.required,ve$1.pattern(/^([01]\d|2[0-3]):[0-5]\d$/)]}),startDate:new vt("",{nonNullable:true,validators:[ve$1.required]}),endType:new vt(Oe$1.NEVER,{nonNullable:true,validators:[ve$1.required]}),endDate:new vt(null),occurrenceCount:new vt(null),enabled:new vt(true,{nonNullable:true}),externalMetadataJson:new vt("",{nonNullable:true,validators:[Ae]})},{validators:[Ie,Ve]});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get agentConfigIdControl(){return this.form.controls.agentConfigId}get promptContentControl(){return this.form.controls.promptContent}get unitControl(){return this.form.controls.unit}get daysControl(){return this.form.controls.days}get timeUtcControl(){return this.form.controls.timeUtc}get startDateControl(){return this.form.controls.startDate}get endTypeControl(){return this.form.controls.endType}get endDateControl(){return this.form.controls.endDate}get occurrenceCountControl(){return this.form.controls.occurrenceCount}get enabledControl(){return this.form.controls.enabled}get externalMetadataJsonControl(){return this.form.controls.externalMetadataJson}isEditMode=ie(false);isSubmitting=ie(false);isLoading=ie(false);errorMessage=ie(null);SchedulerUnit=Ee$1;SchedulerEndType=Oe$1;schedulerUnits=[{value:Ee$1.WEEK,label:"Week(s)"},{value:Ee$1.MONTH,label:"Month(s)"}];endTypes=[{value:Oe$1.NEVER,label:"Never"},{value:Oe$1.ON_DATE,label:"On date"},{value:Oe$1.OCCURRENCES,label:"After N occurrences"}];dayOptions=Object.entries(Ve$1).map(([t,e])=>({value:t,label:e}));unitSignal=F(this.unitControl.valueChanges.pipe(Os(this.unitControl.value)));endTypeSignal=F(this.endTypeControl.valueChanges.pipe(Os(this.endTypeControl.value)));showDayFilter=Mi(()=>this.unitSignal()===Ee$1.WEEK);showEndDate=Mi(()=>this.endTypeSignal()===Oe$1.ON_DATE);showOccurrenceCount=Mi(()=>this.endTypeSignal()===Oe$1.OCCURRENCES);agentConfigs=ie([]);availableAgentConfigs=this.agentConfigs.asReadonly();existingPrompt=null;ngOnInit(){this.startDateControl.setValue(Re());let t=this.route.snapshot.paramMap.get("scheduledPromptId");t?(this.isEditMode.set(true),this.loadPromptAndResources(t)):this.loadResources();}loadPromptAndResources(t){this.isLoading.set(true),pw({prompt:this.state.getById(t),agentConfigs:this.agentConfigs$()}).pipe(U(this.destroyRef)).subscribe({next:({prompt:e,agentConfigs:d})=>{this.existingPrompt=e,this.agentConfigs.set(d),this.hydrateForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}loadResources(){this.agentConfigs$().pipe(U(this.destroyRef)).subscribe(t=>this.agentConfigs.set(t));}agentConfigs$(){return (this.isPlatformMode?this.agentConfigController.listPlatformAgentsAgentConfig():this.agentConfigController.listByParentAgentConfig(this.namespaceId)).pipe(Wn(()=>_([])))}hydrateForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.agentConfigIdControl.setValue(t.agentConfigId),this.promptContentControl.setValue(t.promptContent),this.unitControl.setValue(t.recurrence.unit),this.daysControl.setValue(t.recurrence.days??[]),this.timeUtcControl.setValue(t.recurrence.timeUtc),this.startDateControl.setValue(t.planning.startDate),this.endTypeControl.setValue(t.planning.endType),this.endDateControl.setValue(t.planning.endDate??null),this.occurrenceCountControl.setValue(t.planning.maxOccurrenceCount??null),this.enabledControl.setValue(t.enabled),this.externalMetadataJsonControl.setValue(t.externalMetadata?JSON.stringify(t.externalMetadata,null,2):"");}isDaySelected(t){return this.daysControl.value.includes(t)}toggleDay(t){let e=this.daysControl.value,d=e.includes(t)?e.filter(g=>g!==t):[...e,t];this.daysControl.setValue(d);}resolveAgentConfigName(t){return this.agentConfigs().find(e=>e.id===t)?.name??t}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true),this.errorMessage.set(null);let t=this.isEditMode()&&!!this.existingPrompt?.id,e=this.endTypeControl.value,d=x(w({},this.existingPrompt??{}),{namespaceId:this.namespaceId??null,name:this.nameControl.value.trim(),description:this.descriptionControl.value?.trim()||void 0,agentConfigId:t?this.existingPrompt.agentConfigId:this.agentConfigIdControl.value,promptContent:this.promptContentControl.value.trim(),recurrence:{unit:this.unitControl.value,days:this.daysControl.value,timeUtc:this.timeUtcControl.value},planning:{startDate:this.startDateControl.value,endType:e,endDate:e===Oe$1.ON_DATE?this.endDateControl.value??void 0:void 0,maxOccurrenceCount:e===Oe$1.OCCURRENCES?this.occurrenceCountControl.value??void 0:void 0},enabled:this.enabledControl.value,removed:this.existingPrompt?.removed??false,externalMetadata:(()=>{let v=this.externalMetadataJsonControl.value.trim();return v?JSON.parse(v):null})()});(t?this.state.update(this.existingPrompt.id,d):this.state.create(d)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:v=>{this.isSubmitting.set(false),v.status===409?this.errorMessage.set(`A scheduled prompt named "${d.name}" already exists in this scope.`):v.status===400?this.errorMessage.set(v.error?.message??"Invalid scheduled prompt data."):this.errorMessage.set("An unexpected error occurred. Please try again.");}});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","scheduled-prompts"]):this.router.navigate(["/agentos",this.namespaceId,"scheduled-prompts"]);}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=Df({type:n,selectors:[["agentos-scheduled-prompt-form"]],decls:10,vars:3,consts:[[1,"scheduled-prompt-form"],[1,"scheduled-prompt-form__header"],["type","button","title","Back to scheduled prompts",1,"scheduled-prompt-form__back",3,"click"],[1,"scheduled-prompt-form__back-icon"],[1,"scheduled-prompt-form__title"],[1,"scheduled-prompt-form__loading"],[1,"scheduled-prompt-form__form",3,"formGroup"],[1,"scheduled-prompt-form__form",3,"ngSubmit","formGroup"],[1,"scheduled-prompt-form__field"],["for","sp-name",1,"scheduled-prompt-form__label"],["aria-hidden","true"],["id","sp-name","type","text","placeholder","e.g. Weekly Report","autocomplete","off",1,"scheduled-prompt-form__input",3,"formControl"],[1,"scheduled-prompt-form__field-error"],[1,"scheduled-prompt-form__field-hint"],["for","sp-description",1,"scheduled-prompt-form__label"],["id","sp-description","type","text","placeholder","Optional \u2014 short description","autocomplete","off",1,"scheduled-prompt-form__input",3,"formControl"],["for","sp-agent-config",1,"scheduled-prompt-form__label"],["for","sp-prompt-content",1,"scheduled-prompt-form__label"],["id","sp-prompt-content","rows","6","placeholder","Enter the message sent to the agent when the scheduled prompt fires\u2026",1,"scheduled-prompt-form__textarea",3,"formControl"],[1,"scheduled-prompt-form__fieldset"],[1,"scheduled-prompt-form__legend"],["for","sp-unit",1,"scheduled-prompt-form__label"],["id","sp-unit",1,"scheduled-prompt-form__select",3,"formControl"],[3,"value"],["for","sp-time",1,"scheduled-prompt-form__label"],[1,"scheduled-prompt-form__time-wrapper"],["id","sp-time","type","time",1,"scheduled-prompt-form__input","scheduled-prompt-form__input--time",3,"formControl"],[1,"scheduled-prompt-form__utc-badge"],["for","sp-start-date",1,"scheduled-prompt-form__label"],["id","sp-start-date","type","date",1,"scheduled-prompt-form__input",3,"formControl"],["for","sp-end-type",1,"scheduled-prompt-form__label"],["id","sp-end-type",1,"scheduled-prompt-form__select",3,"formControl"],[1,"scheduled-prompt-form__toggle-label"],["type","checkbox",1,"scheduled-prompt-form__toggle-checkbox",3,"formControl"],[1,"scheduled-prompt-form__toggle-text"],[1,"scheduled-prompt-form__toggle-hint"],["for","sp-external-metadata",1,"scheduled-prompt-form__label"],["id","sp-external-metadata","rows","6","placeholder",'{ "key": "value" }',"spellcheck","false","autocomplete","off",1,"scheduled-prompt-form__textarea","scheduled-prompt-form__textarea--code",3,"formControl"],[1,"scheduled-prompt-form__error"],[1,"scheduled-prompt-form__actions"],["type","submit",1,"scheduled-prompt-form__btn","scheduled-prompt-form__btn--primary",3,"disabled"],["type","button",1,"scheduled-prompt-form__btn",3,"click"],[1,"scheduled-prompt-form__readonly-value"],[3,"href"],["id","sp-agent-config",1,"scheduled-prompt-form__select",3,"formControl"],["value","","disabled",""],[1,"scheduled-prompt-form__label"],[1,"scheduled-prompt-form__day-grid"],[1,"scheduled-prompt-form__day-label"],["type","checkbox",1,"scheduled-prompt-form__day-checkbox",3,"change","checked"],[1,"scheduled-prompt-form__day-text"],["for","sp-end-date",1,"scheduled-prompt-form__label"],["id","sp-end-date","type","date",1,"scheduled-prompt-form__input",3,"formControl"],["for","sp-occurrence-count",1,"scheduled-prompt-form__label"],["id","sp-occurrence-count","type","number","min","1",1,"scheduled-prompt-form__input","scheduled-prompt-form__input--number",3,"formControl"]],template:function(e,d){e&1&&(za(0,"div",0)(1,"header",1)(2,"button",2),dc("click",function(){return d.cancel()}),za(3,"span",3),r_(4,"\u2190"),bf(),r_(5),bf(),za(6,"h1",4),r_(7),bf()(),hT(8,pe,2,0,"p",5)(9,Fe,93,28,"form",6),bf()),e&2&&(yb(5),Af(" ",d.isPlatformMode?"Platform Scheduled Prompts":"Scheduled Prompts"," "),yb(2),Af(" ",d.isEditMode()?"Edit scheduled prompt":"New scheduled prompt"," "),yb(),pT(d.isLoading()?8:9));},dependencies:[Kn,zn,Zn,Xn,Ye,dn,Ft,bt,Ln,Wn$1,qt,pn,Vn],styles:[".scheduled-prompt-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.scheduled-prompt-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.scheduled-prompt-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.scheduled-prompt-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.scheduled-prompt-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.scheduled-prompt-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.scheduled-prompt-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.9rem;margin:0}.scheduled-prompt-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.scheduled-prompt-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.scheduled-prompt-form__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.scheduled-prompt-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text, #1d1d1f)}.scheduled-prompt-form__input[_ngcontent-%COMP%], .scheduled-prompt-form__select[_ngcontent-%COMP%], .scheduled-prompt-form__textarea[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.scheduled-prompt-form__input[_ngcontent-%COMP%]:focus, .scheduled-prompt-form__select[_ngcontent-%COMP%]:focus, .scheduled-prompt-form__textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-primary, #007aff)}.scheduled-prompt-form__input[_ngcontent-%COMP%]::placeholder, .scheduled-prompt-form__select[_ngcontent-%COMP%]::placeholder, .scheduled-prompt-form__textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary, #6e6e73)}.scheduled-prompt-form__select[_ngcontent-%COMP%]{cursor:pointer;appearance:auto}.scheduled-prompt-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:100px;line-height:1.5}.scheduled-prompt-form__input--time[_ngcontent-%COMP%]{flex:1;min-width:0}.scheduled-prompt-form__input--number[_ngcontent-%COMP%]{max-width:120px}.scheduled-prompt-form__time-wrapper[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.scheduled-prompt-form__utc-badge[_ngcontent-%COMP%]{flex-shrink:0;font-size:.75rem;font-weight:600;font-family:monospace;color:var(--color-text-secondary, #6e6e73);background:var(--color-surface, rgba(0, 0, 0, .05));padding:.25rem .5rem;border-radius:4px;text-transform:uppercase;letter-spacing:.06em}.scheduled-prompt-form__fieldset[_ngcontent-%COMP%]{border:1px solid var(--color-border, rgba(0, 0, 0, .1));border-radius:8px;padding:1rem 1.25rem 1.25rem;margin:0;display:flex;flex-direction:column;gap:1.25rem}.scheduled-prompt-form__legend[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--color-text-secondary, #6e6e73);padding:0 .375rem}.scheduled-prompt-form__day-grid[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:.5rem}.scheduled-prompt-form__day-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem;cursor:pointer;-webkit-user-select:none;user-select:none}.scheduled-prompt-form__day-checkbox[_ngcontent-%COMP%]{width:1rem;height:1rem;flex-shrink:0;accent-color:var(--color-primary, #007aff);cursor:pointer}.scheduled-prompt-form__day-text[_ngcontent-%COMP%]{font-size:.875rem;color:var(--color-text, #1d1d1f)}.scheduled-prompt-form__hint[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text-secondary, #6e6e73)}.scheduled-prompt-form__hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:var(--color-primary, #007aff);text-decoration:none}.scheduled-prompt-form__hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}.scheduled-prompt-form__error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-error, #ff3b30);margin:0}.scheduled-prompt-form__field-error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-error, #ff3b30)}.scheduled-prompt-form__field-hint[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, #6e6e73);line-height:1.4}.scheduled-prompt-form__field-hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:var(--color-primary, #007aff);text-decoration:none}.scheduled-prompt-form__field-hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}.scheduled-prompt-form__readonly-value[_ngcontent-%COMP%]{margin:0;font-size:.9375rem;color:var(--color-text, #1d1d1f);padding:.625rem .875rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .08));background:var(--color-surface, rgba(0, 0, 0, .03))}.scheduled-prompt-form__input--invalid[_ngcontent-%COMP%], .scheduled-prompt-form__textarea--invalid[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.scheduled-prompt-form__toggle-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.scheduled-prompt-form__toggle-checkbox[_ngcontent-%COMP%]{width:1rem;height:1rem;flex-shrink:0;accent-color:var(--color-primary, #007aff);cursor:pointer}.scheduled-prompt-form__toggle-text[_ngcontent-%COMP%]{font-size:.9rem;font-weight:500;color:var(--color-text, #1d1d1f)}.scheduled-prompt-form__toggle-hint[_ngcontent-%COMP%]{margin:.25rem 0 0 1.5rem;font-size:.8rem;color:var(--color-text-secondary, #6e6e73);line-height:1.4}.scheduled-prompt-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.scheduled-prompt-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.scheduled-prompt-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-surface-hover, rgba(0, 0, 0, .04))}.scheduled-prompt-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.scheduled-prompt-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary, #007aff);border-color:var(--color-primary, #007aff);color:#fff}.scheduled-prompt-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, #0051d5);border-color:var(--color-primary-hover, #0051d5)}"]})};function Ie(n){let t=n.get("endType")?.value,e=n.get("endDate")?.value;return t===Oe$1.ON_DATE&&!e?{endDateRequired:true}:null}function Ve(n){let t=n.get("endType")?.value,e=n.get("occurrenceCount")?.value;return t===Oe$1.OCCURRENCES&&(e==null||e<1)?{occurrenceCountRequired:true}:null}function Ae(n){let t=n.value?.trim();if(!t)return null;try{return JSON.parse(t),null}catch(e){return {invalidJson:true}}}function Re(){let n=new Date,t=n.getFullYear(),e=String(n.getMonth()+1).padStart(2,"0"),d=String(n.getDate()).padStart(2,"0");return `${t}-${e}-${d}`}export{se as ScheduledPromptFormComponent};
|
|
1
|
+
import {c}from'./chunk-BW7mvGdi.js';import {$ as $$1,v as vt,a as ve$1,K as Kn,z as zn,Z as Zn,X as Xn,Y as Ye,d as dn,F as Ft,c as bt,L as Ln,W as Wn$1,q as qt,b as pn,V as Vn}from'./chunk-DfIyIzl1.js';import {p,$ as $t,f as It,F as Me$1,a9 as $,aa as Oe$1,ab as Ee$1,d as ie,ac as Ve$1,a2 as F,ad as Os,M as Mi,ae as pw,U,af as Wn,J as x,H as w,D as Df,a3 as _,z as za,K as dc,r as r_,b as bf,h as hT,y as yb,A as Af,a as pT,k as bT,l as lc,L as sS,e as yT,N as NT,O as tv,q as gv,Q as cS,v as vT,I as Iv,o as ig,s as sg,X as Xm}from'./main-CIN22H6E.js';var A=(n,t)=>t.value,me=(n,t)=>t.id;function pe(n,t){n&1&&(za(0,"p",5),r_(1,"Loading\u2026"),bf());}function ue(n,t){n&1&&(za(0,"span",12),r_(1," Name is required. "),bf());}function fe(n,t){if(n&1&&(za(0,"p",42),r_(1),bf(),za(2,"span",13),r_(3,"Agent Config cannot be changed after creation."),bf()),n&2){let e=NT(2);yb(),Iv(e.resolveAgentConfigName(e.agentConfigIdControl.value));}}function _e(n,t){if(n&1&&(za(0,"a",43),r_(1,"Add an agent config"),bf(),r_(2," first. ")),n&2){let e=NT(3);tv("href","/agentos/"+e.namespaceId+"/agent-configs/new",Xm);}}function he(n,t){if(n&1&&(za(0,"p",13),r_(1," No agent configs available in this scope yet. "),hT(2,_e,3,1),bf()),n&2){let e=NT(2);yb(2),pT(e.isPlatformMode?-1:2);}}function ge(n,t){if(n&1&&(za(0,"option",23),r_(1),bf()),n&2){let e=t.$implicit;tv("value",e.id),yb(),Iv(e.name);}}function Ce(n,t){n&1&&(za(0,"span",12),r_(1,"Agent Config is required."),bf());}function ve(n,t){if(n&1&&(za(0,"select",44)(1,"option",45),r_(2,"Select an agent config\u2026"),bf(),yT(3,ge,2,2,"option",23,me),bf(),sS(),hT(5,Ce,2,0,"span",12),za(6,"span",13),r_(7,"Immutable after creation."),bf()),n&2){let e=NT(2);tv("formControl",e.agentConfigIdControl),cS(),yb(3),vT(e.availableAgentConfigs()),yb(2),pT(e.agentConfigIdControl.invalid&&e.agentConfigIdControl.touched?5:-1);}}function xe(n,t){n&1&&(za(0,"span",12),r_(1,"Opening message is required."),bf());}function ye(n,t){if(n&1&&(za(0,"option",23),r_(1),bf()),n&2){let e=t.$implicit;tv("value",e.value),yb(),Iv(e.label);}}function be(n,t){if(n&1){let e=bT();za(0,"label",48)(1,"input",49),dc("change",function(){let g=ig(e).$implicit,v=NT(3);return sg(v.toggleDay(g.value))}),bf(),za(2,"span",50),r_(3),bf()();}if(n&2){let e=t.$implicit,d=NT(3);yb(),tv("checked",d.isDaySelected(e.value)),yb(2),Iv(e.label);}}function Se(n,t){if(n&1&&(za(0,"div",8)(1,"span",46),r_(2,"Days of week"),bf(),za(3,"div",47),yT(4,be,4,2,"label",48,A),bf(),za(6,"span",13),r_(7,"Leave empty to run every day of the week."),bf()()),n&2){let e=NT(2);yb(4),vT(e.dayOptions);}}function Ee(n,t){n&1&&(za(0,"span",12),r_(1,"Valid time is required (HH:mm)."),bf());}function Pe(n,t){n&1&&(za(0,"span",12),r_(1,"Start date is required."),bf());}function Me(n,t){if(n&1&&(za(0,"option",23),r_(1),bf()),n&2){let e=t.$implicit;tv("value",e.value),yb(),Iv(e.label);}}function Oe(n,t){n&1&&(za(0,"span",12),r_(1,"End date is required."),bf());}function De(n,t){if(n&1&&(za(0,"div",8)(1,"label",51),r_(2," End date "),za(3,"span",10),r_(4,"*"),bf()(),lc(5,"input",52),sS(),hT(6,Oe,2,0,"span",12),bf()),n&2){let e=NT(2);yb(5),gv("scheduled-prompt-form__input--invalid",e.form.hasError("endDateRequired")&&e.endDateControl.touched),tv("formControl",e.endDateControl),cS(),yb(),pT(e.form.hasError("endDateRequired")&&e.endDateControl.touched?6:-1);}}function Te(n,t){n&1&&(za(0,"span",12),r_(1,"Must be at least 1."),bf());}function we(n,t){if(n&1&&(za(0,"div",8)(1,"label",53),r_(2," Number of occurrences "),za(3,"span",10),r_(4,"*"),bf()(),lc(5,"input",54),sS(),hT(6,Te,2,0,"span",12),bf()),n&2){let e=NT(2);yb(5),gv("scheduled-prompt-form__input--invalid",e.form.hasError("occurrenceCountRequired")&&e.occurrenceCountControl.touched),tv("formControl",e.occurrenceCountControl),cS(),yb(),pT(e.form.hasError("occurrenceCountRequired")&&e.occurrenceCountControl.touched?6:-1);}}function ke(n,t){n&1&&(za(0,"span",12),r_(1,"Invalid JSON."),bf());}function Ne(n,t){if(n&1&&(za(0,"p",38),r_(1),bf()),n&2){let e=NT(2);yb(),Iv(e.errorMessage());}}function Fe(n,t){if(n&1){let e=bT();za(0,"form",7),dc("ngSubmit",function(){ig(e);let g=NT();return sg(g.submit())}),za(1,"div",8)(2,"label",9),r_(3," Name "),za(4,"span",10),r_(5,"*"),bf()(),lc(6,"input",11),sS(),hT(7,ue,2,0,"span",12),za(8,"span",13),r_(9,'Free-form name (e.g. "Weekly Report"). Cannot be changed after creation.'),bf()(),za(10,"div",8)(11,"label",14),r_(12,"Description"),bf(),lc(13,"input",15),sS(),bf(),za(14,"div",8)(15,"label",16),r_(16," Agent Config "),za(17,"span",10),r_(18,"*"),bf()(),hT(19,fe,4,1)(20,he,3,1,"p",13)(21,ve,8,2),bf(),za(22,"div",8)(23,"label",17),r_(24," Opening message "),za(25,"span",10),r_(26,"*"),bf()(),lc(27,"textarea",18),sS(),hT(28,xe,2,0,"span",12),za(29,"span",13),r_(30," The message sent to the agent when the scheduled prompt fires. "),bf()(),za(31,"fieldset",19)(32,"legend",20),r_(33,"Recurrence"),bf(),za(34,"div",8)(35,"label",21),r_(36," Unit "),za(37,"span",10),r_(38,"*"),bf()(),za(39,"select",22),yT(40,ye,2,2,"option",23,A),bf(),sS(),bf(),hT(42,Se,8,0,"div",8),za(43,"div",8)(44,"label",24),r_(45," Time (UTC) "),za(46,"span",10),r_(47,"*"),bf()(),za(48,"div",25),lc(49,"input",26),sS(),za(50,"span",27),r_(51,"UTC"),bf()(),hT(52,Ee,2,0,"span",12),bf()(),za(53,"fieldset",19)(54,"legend",20),r_(55,"Planning"),bf(),za(56,"div",8)(57,"label",28),r_(58," Start date "),za(59,"span",10),r_(60,"*"),bf()(),lc(61,"input",29),sS(),hT(62,Pe,2,0,"span",12),bf(),za(63,"div",8)(64,"label",30),r_(65," Ends "),za(66,"span",10),r_(67,"*"),bf()(),za(68,"select",31),yT(69,Me,2,2,"option",23,A),bf(),sS(),bf(),hT(71,De,7,4,"div",8),hT(72,we,7,4,"div",8),bf(),za(73,"div",8)(74,"label",32),lc(75,"input",33),sS(),za(76,"span",34),r_(77,"Enabled"),bf()(),za(78,"p",35),r_(79," When disabled, the scheduled prompt is saved but will not run on schedule. "),bf()(),za(80,"div",8)(81,"label",36),r_(82,"External Metadata"),bf(),lc(83,"textarea",37),sS(),hT(84,ke,2,0,"span",12),za(85,"span",13),r_(86,"Optional. Opaque JSON object stored as-is. Leave empty to clear."),bf()(),hT(87,Ne,2,1,"p",38),za(88,"div",39)(89,"button",40),r_(90),bf(),za(91,"button",41),dc("click",function(){ig(e);let g=NT();return sg(g.cancel())}),r_(92,"Cancel"),bf()()();}if(n&2){let e=NT();tv("formGroup",e.form),yb(6),gv("scheduled-prompt-form__input--invalid",e.nameControl.invalid&&e.nameControl.touched),tv("formControl",e.nameControl),cS(),yb(),pT(e.nameControl.invalid&&e.nameControl.touched?7:-1),yb(6),tv("formControl",e.descriptionControl),cS(),yb(6),pT(e.isEditMode()?19:e.availableAgentConfigs().length===0?20:21),yb(8),gv("scheduled-prompt-form__textarea--invalid",e.promptContentControl.invalid&&e.promptContentControl.touched),tv("formControl",e.promptContentControl),cS(),yb(),pT(e.promptContentControl.invalid&&e.promptContentControl.touched?28:-1),yb(11),tv("formControl",e.unitControl),cS(),yb(),vT(e.schedulerUnits),yb(2),pT(e.showDayFilter()?42:-1),yb(7),tv("formControl",e.timeUtcControl),cS(),yb(3),pT(e.timeUtcControl.invalid&&e.timeUtcControl.touched?52:-1),yb(9),gv("scheduled-prompt-form__input--invalid",e.startDateControl.invalid&&e.startDateControl.touched),tv("formControl",e.startDateControl),cS(),yb(),pT(e.startDateControl.invalid&&e.startDateControl.touched?62:-1),yb(6),tv("formControl",e.endTypeControl),cS(),yb(),vT(e.endTypes),yb(2),pT(e.showEndDate()?71:-1),yb(),pT(e.showOccurrenceCount()?72:-1),yb(3),tv("formControl",e.enabledControl),cS(),yb(8),tv("formControl",e.externalMetadataJsonControl),cS(),yb(),pT(e.externalMetadataJsonControl.invalid&&e.externalMetadataJsonControl.touched?84:-1),yb(3),pT(e.errorMessage()?87:-1),yb(2),tv("disabled",e.form.invalid||e.isSubmitting()),yb(),Af(" ",e.isEditMode()?"Save changes":"Create scheduled prompt"," ");}}var se=class n{route=p($t);router=p(It);destroyRef=p(Me$1);state=p(c);agentConfigController=p($);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new $$1({name:new vt("",{nonNullable:true,validators:[ve$1.required]}),description:new vt(null),agentConfigId:new vt("",{nonNullable:true,validators:[ve$1.required]}),promptContent:new vt("",{nonNullable:true,validators:[ve$1.required]}),unit:new vt(Ee$1.WEEK,{nonNullable:true,validators:[ve$1.required]}),days:new vt([],{nonNullable:true}),timeUtc:new vt("09:00",{nonNullable:true,validators:[ve$1.required,ve$1.pattern(/^([01]\d|2[0-3]):[0-5]\d$/)]}),startDate:new vt("",{nonNullable:true,validators:[ve$1.required]}),endType:new vt(Oe$1.NEVER,{nonNullable:true,validators:[ve$1.required]}),endDate:new vt(null),occurrenceCount:new vt(null),enabled:new vt(true,{nonNullable:true}),externalMetadataJson:new vt("",{nonNullable:true,validators:[Ae]})},{validators:[Ie,Ve]});get nameControl(){return this.form.controls.name}get descriptionControl(){return this.form.controls.description}get agentConfigIdControl(){return this.form.controls.agentConfigId}get promptContentControl(){return this.form.controls.promptContent}get unitControl(){return this.form.controls.unit}get daysControl(){return this.form.controls.days}get timeUtcControl(){return this.form.controls.timeUtc}get startDateControl(){return this.form.controls.startDate}get endTypeControl(){return this.form.controls.endType}get endDateControl(){return this.form.controls.endDate}get occurrenceCountControl(){return this.form.controls.occurrenceCount}get enabledControl(){return this.form.controls.enabled}get externalMetadataJsonControl(){return this.form.controls.externalMetadataJson}isEditMode=ie(false);isSubmitting=ie(false);isLoading=ie(false);errorMessage=ie(null);SchedulerUnit=Ee$1;SchedulerEndType=Oe$1;schedulerUnits=[{value:Ee$1.WEEK,label:"Week(s)"},{value:Ee$1.MONTH,label:"Month(s)"}];endTypes=[{value:Oe$1.NEVER,label:"Never"},{value:Oe$1.ON_DATE,label:"On date"},{value:Oe$1.OCCURRENCES,label:"After N occurrences"}];dayOptions=Object.entries(Ve$1).map(([t,e])=>({value:t,label:e}));unitSignal=F(this.unitControl.valueChanges.pipe(Os(this.unitControl.value)));endTypeSignal=F(this.endTypeControl.valueChanges.pipe(Os(this.endTypeControl.value)));showDayFilter=Mi(()=>this.unitSignal()===Ee$1.WEEK);showEndDate=Mi(()=>this.endTypeSignal()===Oe$1.ON_DATE);showOccurrenceCount=Mi(()=>this.endTypeSignal()===Oe$1.OCCURRENCES);agentConfigs=ie([]);availableAgentConfigs=this.agentConfigs.asReadonly();existingPrompt=null;ngOnInit(){this.startDateControl.setValue(Re());let t=this.route.snapshot.paramMap.get("scheduledPromptId");t?(this.isEditMode.set(true),this.loadPromptAndResources(t)):this.loadResources();}loadPromptAndResources(t){this.isLoading.set(true),pw({prompt:this.state.getById(t),agentConfigs:this.agentConfigs$()}).pipe(U(this.destroyRef)).subscribe({next:({prompt:e,agentConfigs:d})=>{this.existingPrompt=e,this.agentConfigs.set(d),this.hydrateForm(e),this.isLoading.set(false);},error:()=>{this.isLoading.set(false),this.navigateBack();}});}loadResources(){this.agentConfigs$().pipe(U(this.destroyRef)).subscribe(t=>this.agentConfigs.set(t));}agentConfigs$(){return (this.isPlatformMode?this.agentConfigController.listPlatformAgentsAgentConfig():this.agentConfigController.listByParentAgentConfig(this.namespaceId)).pipe(Wn(()=>_([])))}hydrateForm(t){this.nameControl.setValue(t.name),this.descriptionControl.setValue(t.description??null),this.agentConfigIdControl.setValue(t.agentConfigId),this.promptContentControl.setValue(t.promptContent),this.unitControl.setValue(t.recurrence.unit),this.daysControl.setValue(t.recurrence.days??[]),this.timeUtcControl.setValue(t.recurrence.timeUtc),this.startDateControl.setValue(t.planning.startDate),this.endTypeControl.setValue(t.planning.endType),this.endDateControl.setValue(t.planning.endDate??null),this.occurrenceCountControl.setValue(t.planning.maxOccurrenceCount??null),this.enabledControl.setValue(t.enabled),this.externalMetadataJsonControl.setValue(t.externalMetadata?JSON.stringify(t.externalMetadata,null,2):"");}isDaySelected(t){return this.daysControl.value.includes(t)}toggleDay(t){let e=this.daysControl.value,d=e.includes(t)?e.filter(g=>g!==t):[...e,t];this.daysControl.setValue(d);}resolveAgentConfigName(t){return this.agentConfigs().find(e=>e.id===t)?.name??t}submit(){if(this.form.invalid||this.isSubmitting())return;this.isSubmitting.set(true),this.errorMessage.set(null);let t=this.isEditMode()&&!!this.existingPrompt?.id,e=this.endTypeControl.value,d=x(w({},this.existingPrompt??{}),{namespaceId:this.namespaceId??null,name:this.nameControl.value.trim(),description:this.descriptionControl.value?.trim()||void 0,agentConfigId:t?this.existingPrompt.agentConfigId:this.agentConfigIdControl.value,promptContent:this.promptContentControl.value.trim(),recurrence:{unit:this.unitControl.value,days:this.daysControl.value,timeUtc:this.timeUtcControl.value},planning:{startDate:this.startDateControl.value,endType:e,endDate:e===Oe$1.ON_DATE?this.endDateControl.value??void 0:void 0,maxOccurrenceCount:e===Oe$1.OCCURRENCES?this.occurrenceCountControl.value??void 0:void 0},enabled:this.enabledControl.value,removed:this.existingPrompt?.removed??false,externalMetadata:(()=>{let v=this.externalMetadataJsonControl.value.trim();return v?JSON.parse(v):null})()});(t?this.state.update(this.existingPrompt.id,d):this.state.create(d)).pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:v=>{this.isSubmitting.set(false),v.status===409?this.errorMessage.set(`A scheduled prompt named "${d.name}" already exists in this scope.`):v.status===400?this.errorMessage.set(v.error?.message??"Invalid scheduled prompt data."):this.errorMessage.set("An unexpected error occurred. Please try again.");}});}cancel(){this.navigateBack();}navigateBack(){this.isPlatformMode?this.router.navigate(["/agentos","admin","scheduled-prompts"]):this.router.navigate(["/agentos",this.namespaceId,"scheduled-prompts"]);}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=Df({type:n,selectors:[["agentos-scheduled-prompt-form"]],decls:10,vars:3,consts:[[1,"scheduled-prompt-form"],[1,"scheduled-prompt-form__header"],["type","button","title","Back to scheduled prompts",1,"scheduled-prompt-form__back",3,"click"],[1,"scheduled-prompt-form__back-icon"],[1,"scheduled-prompt-form__title"],[1,"scheduled-prompt-form__loading"],[1,"scheduled-prompt-form__form",3,"formGroup"],[1,"scheduled-prompt-form__form",3,"ngSubmit","formGroup"],[1,"scheduled-prompt-form__field"],["for","sp-name",1,"scheduled-prompt-form__label"],["aria-hidden","true"],["id","sp-name","type","text","placeholder","e.g. Weekly Report","autocomplete","off",1,"scheduled-prompt-form__input",3,"formControl"],[1,"scheduled-prompt-form__field-error"],[1,"scheduled-prompt-form__field-hint"],["for","sp-description",1,"scheduled-prompt-form__label"],["id","sp-description","type","text","placeholder","Optional \u2014 short description","autocomplete","off",1,"scheduled-prompt-form__input",3,"formControl"],["for","sp-agent-config",1,"scheduled-prompt-form__label"],["for","sp-prompt-content",1,"scheduled-prompt-form__label"],["id","sp-prompt-content","rows","6","placeholder","Enter the message sent to the agent when the scheduled prompt fires\u2026",1,"scheduled-prompt-form__textarea",3,"formControl"],[1,"scheduled-prompt-form__fieldset"],[1,"scheduled-prompt-form__legend"],["for","sp-unit",1,"scheduled-prompt-form__label"],["id","sp-unit",1,"scheduled-prompt-form__select",3,"formControl"],[3,"value"],["for","sp-time",1,"scheduled-prompt-form__label"],[1,"scheduled-prompt-form__time-wrapper"],["id","sp-time","type","time",1,"scheduled-prompt-form__input","scheduled-prompt-form__input--time",3,"formControl"],[1,"scheduled-prompt-form__utc-badge"],["for","sp-start-date",1,"scheduled-prompt-form__label"],["id","sp-start-date","type","date",1,"scheduled-prompt-form__input",3,"formControl"],["for","sp-end-type",1,"scheduled-prompt-form__label"],["id","sp-end-type",1,"scheduled-prompt-form__select",3,"formControl"],[1,"scheduled-prompt-form__toggle-label"],["type","checkbox",1,"scheduled-prompt-form__toggle-checkbox",3,"formControl"],[1,"scheduled-prompt-form__toggle-text"],[1,"scheduled-prompt-form__toggle-hint"],["for","sp-external-metadata",1,"scheduled-prompt-form__label"],["id","sp-external-metadata","rows","6","placeholder",'{ "key": "value" }',"spellcheck","false","autocomplete","off",1,"scheduled-prompt-form__textarea","scheduled-prompt-form__textarea--code",3,"formControl"],[1,"scheduled-prompt-form__error"],[1,"scheduled-prompt-form__actions"],["type","submit",1,"scheduled-prompt-form__btn","scheduled-prompt-form__btn--primary",3,"disabled"],["type","button",1,"scheduled-prompt-form__btn",3,"click"],[1,"scheduled-prompt-form__readonly-value"],[3,"href"],["id","sp-agent-config",1,"scheduled-prompt-form__select",3,"formControl"],["value","","disabled",""],[1,"scheduled-prompt-form__label"],[1,"scheduled-prompt-form__day-grid"],[1,"scheduled-prompt-form__day-label"],["type","checkbox",1,"scheduled-prompt-form__day-checkbox",3,"change","checked"],[1,"scheduled-prompt-form__day-text"],["for","sp-end-date",1,"scheduled-prompt-form__label"],["id","sp-end-date","type","date",1,"scheduled-prompt-form__input",3,"formControl"],["for","sp-occurrence-count",1,"scheduled-prompt-form__label"],["id","sp-occurrence-count","type","number","min","1",1,"scheduled-prompt-form__input","scheduled-prompt-form__input--number",3,"formControl"]],template:function(e,d){e&1&&(za(0,"div",0)(1,"header",1)(2,"button",2),dc("click",function(){return d.cancel()}),za(3,"span",3),r_(4,"\u2190"),bf(),r_(5),bf(),za(6,"h1",4),r_(7),bf()(),hT(8,pe,2,0,"p",5)(9,Fe,93,28,"form",6),bf()),e&2&&(yb(5),Af(" ",d.isPlatformMode?"Platform Scheduled Prompts":"Scheduled Prompts"," "),yb(2),Af(" ",d.isEditMode()?"Edit scheduled prompt":"New scheduled prompt"," "),yb(),pT(d.isLoading()?8:9));},dependencies:[Kn,zn,Zn,Xn,Ye,dn,Ft,bt,Ln,Wn$1,qt,pn,Vn],styles:[".scheduled-prompt-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.scheduled-prompt-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.scheduled-prompt-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-primary, #007aff);font-family:inherit}.scheduled-prompt-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.scheduled-prompt-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.scheduled-prompt-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:600;color:var(--color-text, #1d1d1f);letter-spacing:-.02em}.scheduled-prompt-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary, #6e6e73);font-size:.9rem;margin:0}.scheduled-prompt-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.scheduled-prompt-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.scheduled-prompt-form__row[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.scheduled-prompt-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text, #1d1d1f)}.scheduled-prompt-form__input[_ngcontent-%COMP%], .scheduled-prompt-form__select[_ngcontent-%COMP%], .scheduled-prompt-form__textarea[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.scheduled-prompt-form__input[_ngcontent-%COMP%]:focus, .scheduled-prompt-form__select[_ngcontent-%COMP%]:focus, .scheduled-prompt-form__textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-primary, #007aff)}.scheduled-prompt-form__input[_ngcontent-%COMP%]::placeholder, .scheduled-prompt-form__select[_ngcontent-%COMP%]::placeholder, .scheduled-prompt-form__textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-text-secondary, #6e6e73)}.scheduled-prompt-form__select[_ngcontent-%COMP%]{cursor:pointer;appearance:auto}.scheduled-prompt-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:100px;line-height:1.5}.scheduled-prompt-form__input--time[_ngcontent-%COMP%]{flex:1;min-width:0}.scheduled-prompt-form__input--number[_ngcontent-%COMP%]{max-width:120px}.scheduled-prompt-form__time-wrapper[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem}.scheduled-prompt-form__utc-badge[_ngcontent-%COMP%]{flex-shrink:0;font-size:.75rem;font-weight:600;font-family:monospace;color:var(--color-text-secondary, #6e6e73);background:var(--color-surface, rgba(0, 0, 0, .05));padding:.25rem .5rem;border-radius:4px;text-transform:uppercase;letter-spacing:.06em}.scheduled-prompt-form__fieldset[_ngcontent-%COMP%]{border:1px solid var(--color-border, rgba(0, 0, 0, .1));border-radius:8px;padding:1rem 1.25rem 1.25rem;margin:0;display:flex;flex-direction:column;gap:1.25rem}.scheduled-prompt-form__legend[_ngcontent-%COMP%]{font-size:.8125rem;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--color-text-secondary, #6e6e73);padding:0 .375rem}.scheduled-prompt-form__day-grid[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:.5rem}.scheduled-prompt-form__day-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.375rem;cursor:pointer;-webkit-user-select:none;user-select:none}.scheduled-prompt-form__day-checkbox[_ngcontent-%COMP%]{width:1rem;height:1rem;flex-shrink:0;accent-color:var(--color-primary, #007aff);cursor:pointer}.scheduled-prompt-form__day-text[_ngcontent-%COMP%]{font-size:.875rem;color:var(--color-text, #1d1d1f)}.scheduled-prompt-form__hint[_ngcontent-%COMP%]{margin:0;font-size:.875rem;color:var(--color-text-secondary, #6e6e73)}.scheduled-prompt-form__hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:var(--color-primary, #007aff);text-decoration:none}.scheduled-prompt-form__hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}.scheduled-prompt-form__error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-error, #ff3b30);margin:0}.scheduled-prompt-form__field-error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-error, #ff3b30)}.scheduled-prompt-form__field-hint[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary, #6e6e73);line-height:1.4}.scheduled-prompt-form__field-hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{color:var(--color-primary, #007aff);text-decoration:none}.scheduled-prompt-form__field-hint[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:underline}.scheduled-prompt-form__readonly-value[_ngcontent-%COMP%]{margin:0;font-size:.9375rem;color:var(--color-text, #1d1d1f);padding:.625rem .875rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .08));background:var(--color-surface, rgba(0, 0, 0, .03))}.scheduled-prompt-form__input--invalid[_ngcontent-%COMP%], .scheduled-prompt-form__textarea--invalid[_ngcontent-%COMP%]{border-color:var(--color-error, #ff3b30)}.scheduled-prompt-form__toggle-label[_ngcontent-%COMP%]{display:flex;align-items:center;gap:.5rem;cursor:pointer;-webkit-user-select:none;user-select:none}.scheduled-prompt-form__toggle-checkbox[_ngcontent-%COMP%]{width:1rem;height:1rem;flex-shrink:0;accent-color:var(--color-primary, #007aff);cursor:pointer}.scheduled-prompt-form__toggle-text[_ngcontent-%COMP%]{font-size:.9rem;font-weight:500;color:var(--color-text, #1d1d1f)}.scheduled-prompt-form__toggle-hint[_ngcontent-%COMP%]{margin:.25rem 0 0 1.5rem;font-size:.8rem;color:var(--color-text-secondary, #6e6e73);line-height:1.4}.scheduled-prompt-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.scheduled-prompt-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:8px;border:1px solid var(--color-border, rgba(0, 0, 0, .1));background:transparent;color:var(--color-text, #1d1d1f);font-size:.9375rem;font-family:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.scheduled-prompt-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-surface-hover, rgba(0, 0, 0, .04))}.scheduled-prompt-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.scheduled-prompt-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-primary, #007aff);border-color:var(--color-primary, #007aff);color:#fff}.scheduled-prompt-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-primary-hover, #0051d5);border-color:var(--color-primary-hover, #0051d5)}"]})};function Ie(n){let t=n.get("endType")?.value,e=n.get("endDate")?.value;return t===Oe$1.ON_DATE&&!e?{endDateRequired:true}:null}function Ve(n){let t=n.get("endType")?.value,e=n.get("occurrenceCount")?.value;return t===Oe$1.OCCURRENCES&&(e==null||e<1)?{occurrenceCountRequired:true}:null}function Ae(n){let t=n.value?.trim();if(!t)return null;try{return JSON.parse(t),null}catch(e){return {invalidJson:true}}}function Re(){let n=new Date,t=n.getFullYear(),e=String(n.getMonth()+1).padStart(2,"0"),d=String(n.getDate()).padStart(2,"0");return `${t}-${e}-${d}`}export{se as ScheduledPromptFormComponent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {m,$ as $$1,j as ze,v as vt,a as ve$1,K as Kn,z as zn,Z as Zn,X as Xn,Y as Ye,c as bt,L as Ln,W as Wn$1,b as pn,V as Vn,y as yn,k as yt,n as Ct}from'./chunk-BdnHH8q-.js';import {p,$ as $t,f as It,F as Me,a9 as $,d as ie$1,U,af as Wn,J as x,H as w,D as Df,a3 as _,z as za,K as dc,r as r_,b as bf,h as hT,y as yb,A as Af,I as Iv,a as pT,k as bT,l as lc,L as sS,e as yT,ah as gT,N as NT,O as tv,q as gv,Q as cS,v as vT,o as ig,s as sg}from'./main-C4DDTIV5.js';var ne=(i,t)=>t.id;function ie(i,t){i&1&&(za(0,"p",5),r_(1,"Loading\u2026"),bf());}function ae(i,t){i&1&&(za(0,"span",12),r_(1,"Name is required."),bf());}function le(i,t){if(i&1&&(za(0,"p",32),r_(1),bf(),za(2,"span",26),r_(3,"Agent Config cannot be changed after creation."),bf()),i&2){let e=NT(3);yb(),Iv(e.resolveAgentConfigName(e.agentConfigIdControl.value));}}function me(i,t){if(i&1&&(za(0,"option",34),r_(1),bf()),i&2){let e=t.$implicit;tv("ngValue",e.id),yb(),Iv(e.name);}}function pe(i,t){if(i&1&&(za(0,"select",33)(1,"option",34),r_(2,"\u2014 None \u2014"),bf(),yT(3,me,2,2,"option",34,ne),bf(),sS(),za(5,"span",26),r_(6,"Optional. Links this prompt to an agent as a starter. Immutable after creation."),bf()),i&2){let e=NT(3);tv("formControl",e.agentConfigIdControl),cS(),yb(),tv("ngValue",null),yb(2),vT(e.availableAgentConfigs());}}function de(i,t){if(i&1&&(za(0,"div",8)(1,"label",31),r_(2,"Agent Config"),bf(),hT(3,le,4,1)(4,pe,7,2),bf()),i&2){let e=NT(2);yb(3),pT(e.isEditMode()&&e.agentConfigIdControl.value?3:e.isEditMode()?-1:4);}}function ce(i,t){i&1&&(za(0,"p",19),r_(1,"No parameters defined."),bf());}function se(i,t){i&1&&(za(0,"span",12),r_(1,"Parameter name is required."),bf());}function _e(i,t){if(i&1){let e=bT();za(0,"div",20)(1,"div",35)(2,"div",36)(3,"label",37),r_(4,"Name "),za(5,"span",10),r_(6,"*"),bf()(),lc(7,"input",38),sS(),hT(8,se,2,0,"span",12),bf(),za(9,"div",36)(10,"label",37),r_(11,"Description"),bf(),lc(12,"input",39),sS(),bf(),za(13,"div",36)(14,"label",37),r_(15,"Default value"),bf(),lc(16,"input",40),sS(),bf()(),za(17,"button",41),dc("click",function(){let m=ig(e).$index,d=NT(2);return sg(d.removeParameter(m))}),r_(18," \xD7 "),bf()();}if(i&2){let e=t.$implicit,l=t.$index;tv("formGroupName",l),yb(3),tv("for","param-name-"+l),yb(4),gv("prompt-form__input--invalid",e.controls.name.invalid&&e.controls.name.touched),tv("id","param-name-"+l),cS(),yb(),pT(e.controls.name.invalid&&e.controls.name.touched?8:-1),yb(2),tv("for","param-desc-"+l),yb(2),tv("id","param-desc-"+l),cS(),yb(2),tv("for","param-default-"+l),yb(2),tv("id","param-default-"+l),cS();}}function fe(i,t){i&1&&(za(0,"span",12),r_(1,"Content entry must not be blank."),bf());}function ue(i,t){if(i&1){let e=bT();za(0,"div",22)(1,"span",42),r_(2),bf(),za(3,"div",43),lc(4,"textarea",44),sS(),hT(5,fe,2,0,"span",12),bf(),za(6,"button",45),dc("click",function(){let m=ig(e).$index,d=NT(2);return sg(d.removeContentEntry(m))}),r_(7," \xD7 "),bf()();}if(i&2){let e=t.$implicit,l=t.$index,m=NT(2);yb(2),Iv(l+1),yb(2),gv("prompt-form__textarea--invalid",e.invalid&&e.touched),tv("formControlName",l),cS(),yb(),pT(e.invalid&&e.touched?5:-1),yb(),tv("disabled",m.contentArray.length===1);}}function ge(i,t){if(i&1&&(za(0,"p",23),r_(1),bf()),i&2){let e=NT(2);yb(),Iv(e.errorMessage());}}function Ce(i,t){i&1&&(za(0,"span",12),r_(1,"Invalid JSON."),bf());}function xe(i,t){if(i&1){let e=bT();za(0,"button",46),dc("click",function(){ig(e);let m=NT(2);return sg(m.exportYaml())}),r_(1),bf();}if(i&2){let e=NT(2);tv("disabled",e.isExporting()),yb(),Af(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function ve(i,t){if(i&1){let e=bT();za(0,"form",7),dc("ngSubmit",function(){ig(e);let m=NT();return sg(m.submit())}),za(1,"div",8)(2,"label",9),r_(3,"Name "),za(4,"span",10),r_(5,"*"),bf()(),lc(6,"input",11),sS(),hT(7,ae,2,0,"span",12),bf(),za(8,"div",8)(9,"label",13),r_(10,"Description"),bf(),lc(11,"input",14),sS(),bf(),hT(12,de,5,1,"div",8),za(13,"fieldset",15)(14,"legend",16),r_(15," Parameters "),za(16,"span",17),r_(17,"Named placeholders used in content"),bf()(),za(18,"p",18),r_(19," Each parameter must have a name and a default value. Use "),za(20,"code"),r_(21),bf(),r_(22," in content entries to reference them. "),bf(),hT(23,ce,2,0,"p",19),yT(24,_e,19,10,"div",20,gT),za(26,"button",21),dc("click",function(){ig(e);let m=NT();return sg(m.addParameter())}),r_(27,"+ Add parameter"),bf()(),za(28,"fieldset",15)(29,"legend",16),r_(30," Content "),za(31,"span",10),r_(32,"*"),bf(),za(33,"span",17),r_(34,"Ordered list of text commands"),bf()(),za(35,"p",18),r_(36," Each content entry is a command. Use "),za(37,"code"),r_(38,"@AgentName"),bf(),r_(39," to target an agent, "),za(40,"code"),r_(41,"/promptName param1 param2"),bf(),r_(42," to call another prompt, and "),za(43,"code"),r_(44),bf(),r_(45," for parameter placeholders. "),bf(),yT(46,ue,8,6,"div",22,gT),za(48,"button",21),dc("click",function(){ig(e);let m=NT();return sg(m.addContentEntry())}),r_(49,"+ Add content entry"),bf()(),hT(50,ge,2,1,"p",23),za(51,"div",8)(52,"label",24),r_(53,"External Metadata"),bf(),lc(54,"textarea",25),sS(),hT(55,Ce,2,0,"span",12),za(56,"span",26),r_(57,"Optional. Opaque JSON object stored as-is. Leave empty to clear."),bf()(),za(58,"div",27)(59,"button",28),r_(60),bf(),hT(61,xe,2,2,"button",29),za(62,"button",30),dc("click",function(){ig(e);let m=NT();return sg(m.cancel())}),r_(63,"Cancel"),bf()()();}if(i&2){let e=NT();tv("formGroup",e.form),yb(6),gv("prompt-form__input--invalid",e.nameControl.invalid&&e.nameControl.touched),tv("formControl",e.nameControl),cS(),yb(),pT(e.nameControl.invalid&&e.nameControl.touched?7:-1),yb(4),tv("formControl",e.descriptionControl),cS(),yb(),pT(e.availableAgentConfigs().length>0?12:-1),yb(),tv("formArrayName","parameters"),yb(8),Iv(e.paramPlaceholderSyntax),yb(2),pT(e.parametersArray.length===0?23:-1),yb(),vT(e.parametersArray.controls),yb(4),tv("formArrayName","content"),yb(16),Iv(e.paramPlaceholderSyntax),yb(2),vT(e.contentArray.controls),yb(4),pT(e.errorMessage()?50:-1),yb(4),tv("formControl",e.externalMetadataJsonControl),cS(),yb(),pT(e.externalMetadataJsonControl.invalid&&e.externalMetadataJsonControl.touched?55:-1),yb(4),tv("disabled",e.form.invalid||e.isSubmitting()),yb(),Af(" ",e.isEditMode()?"Save changes":"Create"," "),yb(),pT(e.isEditMode()?61:-1);}}var re=class i{route=p($t);router=p(It);destroyRef=p(Me);promptState=p(m);agentConfigController=p($);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new $$1({name:new vt("",{nonNullable:true,validators:[ve$1.required,ve$1.minLength(1)]}),description:new vt(null),agentConfigId:new vt(null),externalMetadataJson:new vt("",{nonNullable:true,validators:[be]}),content:new ze([this.createContentControl()],{validators:[ve$1.required]}),parameters:new ze([])});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=ie$1(false);isSubmitting=ie$1(false);isLoading=ie$1(false);isExporting=ie$1(false);errorMessage=ie$1(null);paramPlaceholderSyntax="{{paramName}}";agentConfigs=ie$1([]);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(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(this.destroyRef),Wn(()=>_([]))).subscribe(e=>this.agentConfigs.set(e));}loadPlatformAgentConfigs(){this.agentConfigController.listPlatformAgentsAgentConfig().pipe(U(this.destroyRef),Wn(()=>_([]))).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(l=>this.contentArray.push(this.createContentControl(l))),this.parametersArray.clear(),(t.parameters??[]).forEach(l=>this.parametersArray.push(this.createParameterGroup(l))),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 vt(t,{nonNullable:true,validators:[ve$1.required,ve$1.pattern(/\S/)]})}addContentEntry(){this.contentArray.push(this.createContentControl());}removeContentEntry(t){this.contentArray.length>1&&this.contentArray.removeAt(t);}createParameterGroup(t){return new $$1({name:new vt(t?.name??"",{nonNullable:true,validators:[ve$1.required,ve$1.minLength(1)]}),description:new vt(t?.description??null),defaultValue:new vt(t?.defaultValue??"",{nonNullable:true,validators:[ve$1.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(d=>d.value.trim()),parameters:this.parametersArray.controls.map(d=>({name:d.controls.name.value.trim(),description:d.controls.description.value?.trim()||void 0,defaultValue:d.controls.defaultValue.value.trim()}))});t||(e.agentConfigId=this.agentConfigIdControl.value||null);let l=this.externalMetadataJsonControl.value.trim();e.externalMetadata=l?JSON.parse(l):null;let m=t?this.promptState.update(this.existingPrompt.id,e):this.promptState.create(e);this.errorMessage.set(null),m.pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:d=>{this.isSubmitting.set(false),d.status===409?this.errorMessage.set(`A prompt named "${e.name}" already exists in this scope.`):d.status===400?this.errorMessage.set(d.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(this.destroyRef)).subscribe({next:e=>{let l=new Blob([e],{type:"application/yaml"}),m=URL.createObjectURL(l),d=document.createElement("a");d.href=m,d.download=`${this.existingPrompt?.name??"prompt"}.yaml`,d.click(),URL.revokeObjectURL(m),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||i)};static \u0275cmp=Df({type:i,selectors:[["agentos-prompt-form"]],decls:10,vars:3,consts:[[1,"prompt-form"],[1,"prompt-form__header"],["type","button","title","Back to prompts",1,"prompt-form__back",3,"click"],[1,"prompt-form__back-icon"],[1,"prompt-form__title"],[1,"prompt-form__loading"],[1,"prompt-form__form",3,"formGroup"],[1,"prompt-form__form",3,"ngSubmit","formGroup"],[1,"prompt-form__field"],["for","prompt-name",1,"prompt-form__label"],["aria-hidden","true"],["id","prompt-name","type","text","placeholder","e.g. Summarise meeting notes","autocomplete","off",1,"prompt-form__input",3,"formControl"],[1,"prompt-form__field-error"],["for","prompt-description",1,"prompt-form__label"],["id","prompt-description","type","text","placeholder","Optional \u2014 short description of this prompt","autocomplete","off",1,"prompt-form__input",3,"formControl"],[1,"prompt-form__section",3,"formArrayName"],[1,"prompt-form__label"],[1,"prompt-form__label-hint"],[1,"prompt-form__section-hint"],[1,"prompt-form__empty-hint"],[1,"prompt-form__param-row",3,"formGroupName"],["type","button",1,"prompt-form__add-btn",3,"click"],[1,"prompt-form__content-row"],[1,"prompt-form__error"],["for","prompt-external-metadata",1,"prompt-form__label"],["id","prompt-external-metadata","rows","6","placeholder",'{ "key": "value" }',"spellcheck","false","autocomplete","off",1,"prompt-form__textarea","prompt-form__textarea--code",3,"formControl"],[1,"prompt-form__field-hint"],[1,"prompt-form__actions"],["type","submit",1,"prompt-form__btn","prompt-form__btn--primary",3,"disabled"],["type","button",1,"prompt-form__btn","prompt-form__btn--export",3,"disabled"],["type","button",1,"prompt-form__btn",3,"click"],["for","prompt-agent-config",1,"prompt-form__label"],[1,"prompt-form__readonly-value"],["id","prompt-agent-config",1,"prompt-form__select",3,"formControl"],[3,"ngValue"],[1,"prompt-form__param-fields"],[1,"prompt-form__field","prompt-form__field--inline"],[1,"prompt-form__label",3,"for"],["type","text","placeholder","e.g. language","formControlName","name","autocomplete","off",1,"prompt-form__input",3,"id"],["type","text","placeholder","Optional","formControlName","description","autocomplete","off",1,"prompt-form__input",3,"id"],["type","text","placeholder","e.g. English","formControlName","defaultValue","autocomplete","off",1,"prompt-form__input",3,"id"],["type","button","title","Remove this parameter",1,"prompt-form__remove-btn",3,"click"],[1,"prompt-form__content-index"],[1,"prompt-form__content-field"],["rows","4","placeholder","Enter a command\u2026",1,"prompt-form__textarea",3,"formControlName"],["type","button","title","Remove this entry",1,"prompt-form__remove-btn",3,"click","disabled"],["type","button",1,"prompt-form__btn","prompt-form__btn--export",3,"click","disabled"]],template:function(e,l){e&1&&(za(0,"div",0)(1,"header",1)(2,"button",2),dc("click",function(){return l.cancel()}),za(3,"span",3),r_(4,"\u2190"),bf(),r_(5),bf(),za(6,"h1",4),r_(7),bf()(),hT(8,ie,2,0,"p",5)(9,ve,64,18,"form",6),bf()),e&2&&(yb(5),Af(" ",l.isPlatformMode?"Platform prompts":"Prompts"," "),yb(2),Iv(l.isEditMode()?"Edit prompt":"New prompt"),yb(),pT(l.isLoading()?8:9));},dependencies:[Kn,zn,Zn,Xn,Ye,bt,Ln,Wn$1,pn,Vn,yn,yt,Ct],styles:[".prompt-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.prompt-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.prompt-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.prompt-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.prompt-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.prompt-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.prompt-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.prompt-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.prompt-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.prompt-form__field--inline[_ngcontent-%COMP%]{flex:1}.prompt-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.prompt-form__label-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);margin-left:.375rem}.prompt-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;cursor:pointer;appearance:auto;transition:border-color .15s ease}.prompt-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.prompt-form__field-hint[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.prompt-form__readonly-value[_ngcontent-%COMP%]{margin:0;padding:.5rem .875rem;border-radius:0;background:var(--color-bg-hover);border:1px solid var(--color-divider);color:var(--color-text);font-size:.9375rem}.prompt-form__input[_ngcontent-%COMP%], .prompt-form__textarea[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.prompt-form__input[_ngcontent-%COMP%]:focus, .prompt-form__textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.prompt-form__input[_ngcontent-%COMP%]::placeholder, .prompt-form__textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.prompt-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:100px;line-height:1.5}.prompt-form__textarea--code[_ngcontent-%COMP%]{font-family:monospace;font-size:.85rem;resize:vertical}.prompt-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:.75rem}.prompt-form__section-hint[_ngcontent-%COMP%]{margin:0;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.prompt-form__empty-hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.prompt-form__content-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-start}.prompt-form__content-field[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;gap:.25rem}.prompt-form__content-index[_ngcontent-%COMP%]{flex-shrink:0;width:1.5rem;padding-top:.6rem;font-size:.8rem;font-weight:600;color:var(--color-text-secondary);text-align:right;-webkit-user-select:none;user-select:none}.prompt-form__param-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-end;padding:.75rem;border-radius:0;background:var(--color-bg-hover)}.prompt-form__param-fields[_ngcontent-%COMP%]{flex:1;display:flex;gap:.75rem;flex-wrap:wrap}.prompt-form__add-btn[_ngcontent-%COMP%]{align-self:flex-start;padding:.4rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-accent);font-size:.875rem;font-family:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.prompt-form__add-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover);border-color:var(--color-accent)}.prompt-form__remove-btn[_ngcontent-%COMP%]{flex-shrink:0;width:1.75rem;height:1.75rem;display:flex;align-items:center;justify-content:center;border-radius:0;border:1px solid transparent;background:transparent;color:var(--color-neutral-500);font-size:1rem;line-height:1;cursor:pointer;transition:background .15s ease,color .15s ease,border-color .15s ease}.prompt-form__remove-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:color-mix(in srgb,var(--red) 10%,transparent);color:var(--red);border-color:var(--red)}.prompt-form__remove-btn[_ngcontent-%COMP%]:disabled{opacity:.3;cursor:not-allowed}.prompt-form__error[_ngcontent-%COMP%]{margin:0;padding:.625rem .875rem;border-radius:0;background:color-mix(in srgb,var(--red) 10%,transparent);border:1px solid var(--red);color:var(--red);font-size:.875rem;line-height:1.4}.prompt-form__field-error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--red);line-height:1.3}.prompt-form__input--invalid[_ngcontent-%COMP%], .prompt-form__textarea--invalid[_ngcontent-%COMP%]{border-color:var(--red)}.prompt-form__input--invalid[_ngcontent-%COMP%]:focus, .prompt-form__textarea--invalid[_ngcontent-%COMP%]:focus{border-color:var(--red)}.prompt-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.prompt-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.prompt-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.prompt-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.prompt-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.prompt-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}.prompt-form__btn--export[_ngcontent-%COMP%]{border-color:var(--color-divider);color:var(--color-text-secondary)}.prompt-form__btn--export[_ngcontent-%COMP%]:hover:not(:disabled){border-color:var(--color-accent);color:var(--color-accent)}"]})};function be(i){let t=i.value?.trim();if(!t)return null;try{return JSON.parse(t),null}catch(e){return {invalidJson:true}}}export{re as PromptFormComponent};
|
|
1
|
+
import {m,$ as $$1,j as ze,v as vt,a as ve$1,K as Kn,z as zn,Z as Zn,X as Xn,Y as Ye,c as bt,L as Ln,W as Wn$1,b as pn,V as Vn,y as yn,k as yt,n as Ct}from'./chunk-DfIyIzl1.js';import {p,$ as $t,f as It,F as Me,a9 as $,d as ie$1,U,af as Wn,J as x,H as w,D as Df,a3 as _,z as za,K as dc,r as r_,b as bf,h as hT,y as yb,A as Af,I as Iv,a as pT,k as bT,l as lc,L as sS,e as yT,ah as gT,N as NT,O as tv,q as gv,Q as cS,v as vT,o as ig,s as sg}from'./main-CIN22H6E.js';var ne=(i,t)=>t.id;function ie(i,t){i&1&&(za(0,"p",5),r_(1,"Loading\u2026"),bf());}function ae(i,t){i&1&&(za(0,"span",12),r_(1,"Name is required."),bf());}function le(i,t){if(i&1&&(za(0,"p",32),r_(1),bf(),za(2,"span",26),r_(3,"Agent Config cannot be changed after creation."),bf()),i&2){let e=NT(3);yb(),Iv(e.resolveAgentConfigName(e.agentConfigIdControl.value));}}function me(i,t){if(i&1&&(za(0,"option",34),r_(1),bf()),i&2){let e=t.$implicit;tv("ngValue",e.id),yb(),Iv(e.name);}}function pe(i,t){if(i&1&&(za(0,"select",33)(1,"option",34),r_(2,"\u2014 None \u2014"),bf(),yT(3,me,2,2,"option",34,ne),bf(),sS(),za(5,"span",26),r_(6,"Optional. Links this prompt to an agent as a starter. Immutable after creation."),bf()),i&2){let e=NT(3);tv("formControl",e.agentConfigIdControl),cS(),yb(),tv("ngValue",null),yb(2),vT(e.availableAgentConfigs());}}function de(i,t){if(i&1&&(za(0,"div",8)(1,"label",31),r_(2,"Agent Config"),bf(),hT(3,le,4,1)(4,pe,7,2),bf()),i&2){let e=NT(2);yb(3),pT(e.isEditMode()&&e.agentConfigIdControl.value?3:e.isEditMode()?-1:4);}}function ce(i,t){i&1&&(za(0,"p",19),r_(1,"No parameters defined."),bf());}function se(i,t){i&1&&(za(0,"span",12),r_(1,"Parameter name is required."),bf());}function _e(i,t){if(i&1){let e=bT();za(0,"div",20)(1,"div",35)(2,"div",36)(3,"label",37),r_(4,"Name "),za(5,"span",10),r_(6,"*"),bf()(),lc(7,"input",38),sS(),hT(8,se,2,0,"span",12),bf(),za(9,"div",36)(10,"label",37),r_(11,"Description"),bf(),lc(12,"input",39),sS(),bf(),za(13,"div",36)(14,"label",37),r_(15,"Default value"),bf(),lc(16,"input",40),sS(),bf()(),za(17,"button",41),dc("click",function(){let m=ig(e).$index,d=NT(2);return sg(d.removeParameter(m))}),r_(18," \xD7 "),bf()();}if(i&2){let e=t.$implicit,l=t.$index;tv("formGroupName",l),yb(3),tv("for","param-name-"+l),yb(4),gv("prompt-form__input--invalid",e.controls.name.invalid&&e.controls.name.touched),tv("id","param-name-"+l),cS(),yb(),pT(e.controls.name.invalid&&e.controls.name.touched?8:-1),yb(2),tv("for","param-desc-"+l),yb(2),tv("id","param-desc-"+l),cS(),yb(2),tv("for","param-default-"+l),yb(2),tv("id","param-default-"+l),cS();}}function fe(i,t){i&1&&(za(0,"span",12),r_(1,"Content entry must not be blank."),bf());}function ue(i,t){if(i&1){let e=bT();za(0,"div",22)(1,"span",42),r_(2),bf(),za(3,"div",43),lc(4,"textarea",44),sS(),hT(5,fe,2,0,"span",12),bf(),za(6,"button",45),dc("click",function(){let m=ig(e).$index,d=NT(2);return sg(d.removeContentEntry(m))}),r_(7," \xD7 "),bf()();}if(i&2){let e=t.$implicit,l=t.$index,m=NT(2);yb(2),Iv(l+1),yb(2),gv("prompt-form__textarea--invalid",e.invalid&&e.touched),tv("formControlName",l),cS(),yb(),pT(e.invalid&&e.touched?5:-1),yb(),tv("disabled",m.contentArray.length===1);}}function ge(i,t){if(i&1&&(za(0,"p",23),r_(1),bf()),i&2){let e=NT(2);yb(),Iv(e.errorMessage());}}function Ce(i,t){i&1&&(za(0,"span",12),r_(1,"Invalid JSON."),bf());}function xe(i,t){if(i&1){let e=bT();za(0,"button",46),dc("click",function(){ig(e);let m=NT(2);return sg(m.exportYaml())}),r_(1),bf();}if(i&2){let e=NT(2);tv("disabled",e.isExporting()),yb(),Af(" ",e.isExporting()?"Exporting\u2026":"Export as YAML"," ");}}function ve(i,t){if(i&1){let e=bT();za(0,"form",7),dc("ngSubmit",function(){ig(e);let m=NT();return sg(m.submit())}),za(1,"div",8)(2,"label",9),r_(3,"Name "),za(4,"span",10),r_(5,"*"),bf()(),lc(6,"input",11),sS(),hT(7,ae,2,0,"span",12),bf(),za(8,"div",8)(9,"label",13),r_(10,"Description"),bf(),lc(11,"input",14),sS(),bf(),hT(12,de,5,1,"div",8),za(13,"fieldset",15)(14,"legend",16),r_(15," Parameters "),za(16,"span",17),r_(17,"Named placeholders used in content"),bf()(),za(18,"p",18),r_(19," Each parameter must have a name and a default value. Use "),za(20,"code"),r_(21),bf(),r_(22," in content entries to reference them. "),bf(),hT(23,ce,2,0,"p",19),yT(24,_e,19,10,"div",20,gT),za(26,"button",21),dc("click",function(){ig(e);let m=NT();return sg(m.addParameter())}),r_(27,"+ Add parameter"),bf()(),za(28,"fieldset",15)(29,"legend",16),r_(30," Content "),za(31,"span",10),r_(32,"*"),bf(),za(33,"span",17),r_(34,"Ordered list of text commands"),bf()(),za(35,"p",18),r_(36," Each content entry is a command. Use "),za(37,"code"),r_(38,"@AgentName"),bf(),r_(39," to target an agent, "),za(40,"code"),r_(41,"/promptName param1 param2"),bf(),r_(42," to call another prompt, and "),za(43,"code"),r_(44),bf(),r_(45," for parameter placeholders. "),bf(),yT(46,ue,8,6,"div",22,gT),za(48,"button",21),dc("click",function(){ig(e);let m=NT();return sg(m.addContentEntry())}),r_(49,"+ Add content entry"),bf()(),hT(50,ge,2,1,"p",23),za(51,"div",8)(52,"label",24),r_(53,"External Metadata"),bf(),lc(54,"textarea",25),sS(),hT(55,Ce,2,0,"span",12),za(56,"span",26),r_(57,"Optional. Opaque JSON object stored as-is. Leave empty to clear."),bf()(),za(58,"div",27)(59,"button",28),r_(60),bf(),hT(61,xe,2,2,"button",29),za(62,"button",30),dc("click",function(){ig(e);let m=NT();return sg(m.cancel())}),r_(63,"Cancel"),bf()()();}if(i&2){let e=NT();tv("formGroup",e.form),yb(6),gv("prompt-form__input--invalid",e.nameControl.invalid&&e.nameControl.touched),tv("formControl",e.nameControl),cS(),yb(),pT(e.nameControl.invalid&&e.nameControl.touched?7:-1),yb(4),tv("formControl",e.descriptionControl),cS(),yb(),pT(e.availableAgentConfigs().length>0?12:-1),yb(),tv("formArrayName","parameters"),yb(8),Iv(e.paramPlaceholderSyntax),yb(2),pT(e.parametersArray.length===0?23:-1),yb(),vT(e.parametersArray.controls),yb(4),tv("formArrayName","content"),yb(16),Iv(e.paramPlaceholderSyntax),yb(2),vT(e.contentArray.controls),yb(4),pT(e.errorMessage()?50:-1),yb(4),tv("formControl",e.externalMetadataJsonControl),cS(),yb(),pT(e.externalMetadataJsonControl.invalid&&e.externalMetadataJsonControl.touched?55:-1),yb(4),tv("disabled",e.form.invalid||e.isSubmitting()),yb(),Af(" ",e.isEditMode()?"Save changes":"Create"," "),yb(),pT(e.isEditMode()?61:-1);}}var re=class i{route=p($t);router=p(It);destroyRef=p(Me);promptState=p(m);agentConfigController=p($);namespaceId=this.route.snapshot.params.namespaceId;isPlatformMode=!this.namespaceId;form=new $$1({name:new vt("",{nonNullable:true,validators:[ve$1.required,ve$1.minLength(1)]}),description:new vt(null),agentConfigId:new vt(null),externalMetadataJson:new vt("",{nonNullable:true,validators:[be]}),content:new ze([this.createContentControl()],{validators:[ve$1.required]}),parameters:new ze([])});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=ie$1(false);isSubmitting=ie$1(false);isLoading=ie$1(false);isExporting=ie$1(false);errorMessage=ie$1(null);paramPlaceholderSyntax="{{paramName}}";agentConfigs=ie$1([]);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(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(this.destroyRef),Wn(()=>_([]))).subscribe(e=>this.agentConfigs.set(e));}loadPlatformAgentConfigs(){this.agentConfigController.listPlatformAgentsAgentConfig().pipe(U(this.destroyRef),Wn(()=>_([]))).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(l=>this.contentArray.push(this.createContentControl(l))),this.parametersArray.clear(),(t.parameters??[]).forEach(l=>this.parametersArray.push(this.createParameterGroup(l))),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 vt(t,{nonNullable:true,validators:[ve$1.required,ve$1.pattern(/\S/)]})}addContentEntry(){this.contentArray.push(this.createContentControl());}removeContentEntry(t){this.contentArray.length>1&&this.contentArray.removeAt(t);}createParameterGroup(t){return new $$1({name:new vt(t?.name??"",{nonNullable:true,validators:[ve$1.required,ve$1.minLength(1)]}),description:new vt(t?.description??null),defaultValue:new vt(t?.defaultValue??"",{nonNullable:true,validators:[ve$1.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(d=>d.value.trim()),parameters:this.parametersArray.controls.map(d=>({name:d.controls.name.value.trim(),description:d.controls.description.value?.trim()||void 0,defaultValue:d.controls.defaultValue.value.trim()}))});t||(e.agentConfigId=this.agentConfigIdControl.value||null);let l=this.externalMetadataJsonControl.value.trim();e.externalMetadata=l?JSON.parse(l):null;let m=t?this.promptState.update(this.existingPrompt.id,e):this.promptState.create(e);this.errorMessage.set(null),m.pipe(U(this.destroyRef)).subscribe({next:()=>this.navigateBack(),error:d=>{this.isSubmitting.set(false),d.status===409?this.errorMessage.set(`A prompt named "${e.name}" already exists in this scope.`):d.status===400?this.errorMessage.set(d.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(this.destroyRef)).subscribe({next:e=>{let l=new Blob([e],{type:"application/yaml"}),m=URL.createObjectURL(l),d=document.createElement("a");d.href=m,d.download=`${this.existingPrompt?.name??"prompt"}.yaml`,d.click(),URL.revokeObjectURL(m),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||i)};static \u0275cmp=Df({type:i,selectors:[["agentos-prompt-form"]],decls:10,vars:3,consts:[[1,"prompt-form"],[1,"prompt-form__header"],["type","button","title","Back to prompts",1,"prompt-form__back",3,"click"],[1,"prompt-form__back-icon"],[1,"prompt-form__title"],[1,"prompt-form__loading"],[1,"prompt-form__form",3,"formGroup"],[1,"prompt-form__form",3,"ngSubmit","formGroup"],[1,"prompt-form__field"],["for","prompt-name",1,"prompt-form__label"],["aria-hidden","true"],["id","prompt-name","type","text","placeholder","e.g. Summarise meeting notes","autocomplete","off",1,"prompt-form__input",3,"formControl"],[1,"prompt-form__field-error"],["for","prompt-description",1,"prompt-form__label"],["id","prompt-description","type","text","placeholder","Optional \u2014 short description of this prompt","autocomplete","off",1,"prompt-form__input",3,"formControl"],[1,"prompt-form__section",3,"formArrayName"],[1,"prompt-form__label"],[1,"prompt-form__label-hint"],[1,"prompt-form__section-hint"],[1,"prompt-form__empty-hint"],[1,"prompt-form__param-row",3,"formGroupName"],["type","button",1,"prompt-form__add-btn",3,"click"],[1,"prompt-form__content-row"],[1,"prompt-form__error"],["for","prompt-external-metadata",1,"prompt-form__label"],["id","prompt-external-metadata","rows","6","placeholder",'{ "key": "value" }',"spellcheck","false","autocomplete","off",1,"prompt-form__textarea","prompt-form__textarea--code",3,"formControl"],[1,"prompt-form__field-hint"],[1,"prompt-form__actions"],["type","submit",1,"prompt-form__btn","prompt-form__btn--primary",3,"disabled"],["type","button",1,"prompt-form__btn","prompt-form__btn--export",3,"disabled"],["type","button",1,"prompt-form__btn",3,"click"],["for","prompt-agent-config",1,"prompt-form__label"],[1,"prompt-form__readonly-value"],["id","prompt-agent-config",1,"prompt-form__select",3,"formControl"],[3,"ngValue"],[1,"prompt-form__param-fields"],[1,"prompt-form__field","prompt-form__field--inline"],[1,"prompt-form__label",3,"for"],["type","text","placeholder","e.g. language","formControlName","name","autocomplete","off",1,"prompt-form__input",3,"id"],["type","text","placeholder","Optional","formControlName","description","autocomplete","off",1,"prompt-form__input",3,"id"],["type","text","placeholder","e.g. English","formControlName","defaultValue","autocomplete","off",1,"prompt-form__input",3,"id"],["type","button","title","Remove this parameter",1,"prompt-form__remove-btn",3,"click"],[1,"prompt-form__content-index"],[1,"prompt-form__content-field"],["rows","4","placeholder","Enter a command\u2026",1,"prompt-form__textarea",3,"formControlName"],["type","button","title","Remove this entry",1,"prompt-form__remove-btn",3,"click","disabled"],["type","button",1,"prompt-form__btn","prompt-form__btn--export",3,"click","disabled"]],template:function(e,l){e&1&&(za(0,"div",0)(1,"header",1)(2,"button",2),dc("click",function(){return l.cancel()}),za(3,"span",3),r_(4,"\u2190"),bf(),r_(5),bf(),za(6,"h1",4),r_(7),bf()(),hT(8,ie,2,0,"p",5)(9,ve,64,18,"form",6),bf()),e&2&&(yb(5),Af(" ",l.isPlatformMode?"Platform prompts":"Prompts"," "),yb(2),Iv(l.isEditMode()?"Edit prompt":"New prompt"),yb(),pT(l.isLoading()?8:9));},dependencies:[Kn,zn,Zn,Xn,Ye,bt,Ln,Wn$1,pn,Vn,yn,yt,Ct],styles:[".prompt-form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:2rem;max-width:560px;margin:0 auto;padding:2rem 1rem}.prompt-form__header[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.5rem}.prompt-form__back[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:.375rem;background:none;border:none;padding:0;cursor:pointer;font-size:.875rem;color:var(--color-accent)}.prompt-form__back[_ngcontent-%COMP%]:hover{text-decoration:underline}.prompt-form__back-icon[_ngcontent-%COMP%]{font-size:1rem;line-height:1}.prompt-form__title[_ngcontent-%COMP%]{margin:0;font-size:1.5rem;font-weight:700;color:var(--color-text);letter-spacing:-.02em}.prompt-form__loading[_ngcontent-%COMP%]{color:var(--color-text-secondary);font-size:.9rem;margin:0}.prompt-form__form[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:1.25rem}.prompt-form__field[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:.375rem}.prompt-form__field--inline[_ngcontent-%COMP%]{flex:1}.prompt-form__label[_ngcontent-%COMP%]{font-size:.875rem;font-weight:500;color:var(--color-text)}.prompt-form__label-hint[_ngcontent-%COMP%]{font-weight:400;color:var(--color-text-secondary);margin-left:.375rem}.prompt-form__select[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;cursor:pointer;appearance:auto;transition:border-color .15s ease}.prompt-form__select[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.prompt-form__field-hint[_ngcontent-%COMP%]{font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.prompt-form__readonly-value[_ngcontent-%COMP%]{margin:0;padding:.5rem .875rem;border-radius:0;background:var(--color-bg-hover);border:1px solid var(--color-divider);color:var(--color-text);font-size:.9375rem}.prompt-form__input[_ngcontent-%COMP%], .prompt-form__textarea[_ngcontent-%COMP%]{width:100%;padding:.625rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:var(--color-surface);color:var(--color-text);font-size:.9375rem;font-family:inherit;outline:none;box-sizing:border-box;transition:border-color .15s ease}.prompt-form__input[_ngcontent-%COMP%]:focus, .prompt-form__textarea[_ngcontent-%COMP%]:focus{border-color:var(--color-accent)}.prompt-form__input[_ngcontent-%COMP%]::placeholder, .prompt-form__textarea[_ngcontent-%COMP%]::placeholder{color:var(--color-neutral-500)}.prompt-form__textarea[_ngcontent-%COMP%]{resize:vertical;min-height:100px;line-height:1.5}.prompt-form__textarea--code[_ngcontent-%COMP%]{font-family:monospace;font-size:.85rem;resize:vertical}.prompt-form__section[_ngcontent-%COMP%]{border:1px solid var(--color-divider);border-radius:0;padding:1rem;margin:0;display:flex;flex-direction:column;gap:.75rem}.prompt-form__section-hint[_ngcontent-%COMP%]{margin:0;font-size:.8rem;color:var(--color-text-secondary);line-height:1.4}.prompt-form__empty-hint[_ngcontent-%COMP%]{margin:0;font-size:.85rem;color:var(--color-text-secondary);font-style:italic}.prompt-form__content-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-start}.prompt-form__content-field[_ngcontent-%COMP%]{flex:1;display:flex;flex-direction:column;gap:.25rem}.prompt-form__content-index[_ngcontent-%COMP%]{flex-shrink:0;width:1.5rem;padding-top:.6rem;font-size:.8rem;font-weight:600;color:var(--color-text-secondary);text-align:right;-webkit-user-select:none;user-select:none}.prompt-form__param-row[_ngcontent-%COMP%]{display:flex;gap:.5rem;align-items:flex-end;padding:.75rem;border-radius:0;background:var(--color-bg-hover)}.prompt-form__param-fields[_ngcontent-%COMP%]{flex:1;display:flex;gap:.75rem;flex-wrap:wrap}.prompt-form__add-btn[_ngcontent-%COMP%]{align-self:flex-start;padding:.4rem .875rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-accent);font-size:.875rem;font-family:inherit;cursor:pointer;transition:background .15s ease,border-color .15s ease}.prompt-form__add-btn[_ngcontent-%COMP%]:hover{background:var(--color-bg-hover);border-color:var(--color-accent)}.prompt-form__remove-btn[_ngcontent-%COMP%]{flex-shrink:0;width:1.75rem;height:1.75rem;display:flex;align-items:center;justify-content:center;border-radius:0;border:1px solid transparent;background:transparent;color:var(--color-neutral-500);font-size:1rem;line-height:1;cursor:pointer;transition:background .15s ease,color .15s ease,border-color .15s ease}.prompt-form__remove-btn[_ngcontent-%COMP%]:hover:not(:disabled){background:color-mix(in srgb,var(--red) 10%,transparent);color:var(--red);border-color:var(--red)}.prompt-form__remove-btn[_ngcontent-%COMP%]:disabled{opacity:.3;cursor:not-allowed}.prompt-form__error[_ngcontent-%COMP%]{margin:0;padding:.625rem .875rem;border-radius:0;background:color-mix(in srgb,var(--red) 10%,transparent);border:1px solid var(--red);color:var(--red);font-size:.875rem;line-height:1.4}.prompt-form__field-error[_ngcontent-%COMP%]{font-size:.8rem;color:var(--red);line-height:1.3}.prompt-form__input--invalid[_ngcontent-%COMP%], .prompt-form__textarea--invalid[_ngcontent-%COMP%]{border-color:var(--red)}.prompt-form__input--invalid[_ngcontent-%COMP%]:focus, .prompt-form__textarea--invalid[_ngcontent-%COMP%]:focus{border-color:var(--red)}.prompt-form__actions[_ngcontent-%COMP%]{display:flex;gap:.75rem;padding-top:.5rem}.prompt-form__btn[_ngcontent-%COMP%]{padding:.6rem 1.25rem;border-radius:0;border:1px solid var(--color-divider);background:transparent;color:var(--color-text);font-size:13px;font-family:var(--font-heading);font-weight:600;cursor:pointer;transition:background .15s ease,border-color .15s ease}.prompt-form__btn[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-bg-hover);border-color:var(--color-neutral-500)}.prompt-form__btn[_ngcontent-%COMP%]:disabled{opacity:.45;cursor:not-allowed}.prompt-form__btn--primary[_ngcontent-%COMP%]{background:var(--color-accent);border-color:var(--color-accent);color:#fff}.prompt-form__btn--primary[_ngcontent-%COMP%]:hover:not(:disabled){background:var(--color-accent-700);border-color:var(--color-accent-700)}.prompt-form__btn--export[_ngcontent-%COMP%]{border-color:var(--color-divider);color:var(--color-text-secondary)}.prompt-form__btn--export[_ngcontent-%COMP%]:hover:not(:disabled){border-color:var(--color-accent);color:var(--color-accent)}"]})};function be(i){let t=i.value?.trim();if(!t)return null;try{return JSON.parse(t),null}catch(e){return {invalidJson:true}}}export{re as PromptFormComponent};
|