configure
Version:
Identity layer SDK for AI agents
53 lines (45 loc) • 400 kB
JavaScript
"use strict";var ConfigureComponents=(()=>{var Tt=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Zn=Object.prototype.hasOwnProperty;var Qn=(t,r)=>{for(var e in r)Tt(t,e,{get:r[e],enumerable:!0})},eo=(t,r,e,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Jn(r))!Zn.call(t,n)&&n!==e&&Tt(t,n,{get:()=>r[n],enumerable:!(i=qr(r,n))||i.enumerable});return t};var to=t=>eo(Tt({},"__esModule",{value:!0}),t),l=(t,r,e,i)=>{for(var n=i>1?void 0:i?qr(r,e):r,o=t.length-1,a;o>=0;o--)(a=t[o])&&(n=(i?a(r,e,n):a(n))||n);return i&&n&&Tt(r,e,n),n};var ul={};Qn(ul,{ConfigureAccessRequest:()=>Z,ConfigureAuth:()=>K,ConfigureAuthModal:()=>X,ConfigureBase:()=>$,ConfigureConfirmation:()=>ne,ConfigureConnectionList:()=>H,ConfigureConnectionRow:()=>W,ConfigureExportButton:()=>de,ConfigureExportPrompt:()=>fe,ConfigureMemoryCard:()=>re,ConfigureMemoryImport:()=>T,ConfigureOtpInput:()=>U,ConfigurePersonalizationButton:()=>A,ConfigurePhoneInput:()=>P,ConfigureProfileEditor:()=>L,ConfigureRuntimeReading:()=>le,ConfigureSingleConnector:()=>te,ConfigureSuccessCard:()=>ie,ConfigureToolApproval:()=>J,EXPORT_PROMPT:()=>se,PROVIDER_LABELS:()=>qe,PROVIDER_PROMPTS:()=>Ae,PROVIDER_URLS:()=>Ge});var At=globalThis,Ot=At.ShadowRoot&&(At.ShadyCSS===void 0||At.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Qt=Symbol(),Kr=new WeakMap,ze=class{constructor(r,e,i){if(this._$cssResult$=!0,i!==Qt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=r,this.t=e}get styleSheet(){let r=this.o,e=this.t;if(Ot&&r===void 0){let i=e!==void 0&&e.length===1;i&&(r=Kr.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),i&&Kr.set(e,r))}return r}toString(){return this.cssText}},zr=t=>new ze(typeof t=="string"?t:t+"",void 0,Qt),w=(t,...r)=>{let e=t.length===1?t[0]:r.reduce((i,n,o)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[o+1],t[0]);return new ze(e,t,Qt)},Yr=(t,r)=>{if(Ot)t.adoptedStyleSheets=r.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of r){let i=document.createElement("style"),n=At.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,t.appendChild(i)}},er=Ot?t=>t:t=>t instanceof CSSStyleSheet?(r=>{let e="";for(let i of r.cssRules)e+=i.cssText;return zr(e)})(t):t;var{is:ro,defineProperty:io,getOwnPropertyDescriptor:no,getOwnPropertyNames:oo,getOwnPropertySymbols:ao,getPrototypeOf:so}=Object,me=globalThis,Wr=me.trustedTypes,lo=Wr?Wr.emptyScript:"",co=me.reactiveElementPolyfillSupport,Ye=(t,r)=>t,We={toAttribute(t,r){switch(r){case Boolean:t=t?lo:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,r){let e=t;switch(r){case Boolean:e=t!==null;break;case Number:e=t===null?null:Number(t);break;case Object:case Array:try{e=JSON.parse(t)}catch{e=null}}return e}},Rt=(t,r)=>!ro(t,r),Xr={attribute:!0,type:String,converter:We,reflect:!1,useDefault:!1,hasChanged:Rt};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),me.litPropertyMetadata??(me.litPropertyMetadata=new WeakMap);var ce=class extends HTMLElement{static addInitializer(r){this._$Ei(),(this.l??(this.l=[])).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=Xr){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(r)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(r,e),!e.noAccessor){let i=Symbol(),n=this.getPropertyDescriptor(r,i,e);n!==void 0&&io(this.prototype,r,n)}}static getPropertyDescriptor(r,e,i){let{get:n,set:o}=no(this.prototype,r)??{get(){return this[e]},set(a){this[e]=a}};return{get:n,set(a){let s=n?.call(this);o?.call(this,a),this.requestUpdate(r,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(r){return this.elementProperties.get(r)??Xr}static _$Ei(){if(this.hasOwnProperty(Ye("elementProperties")))return;let r=so(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(Ye("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ye("properties"))){let e=this.properties,i=[...oo(e),...ao(e)];for(let n of i)this.createProperty(n,e[n])}let r=this[Symbol.metadata];if(r!==null){let e=litPropertyMetadata.get(r);if(e!==void 0)for(let[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(let[e,i]of this.elementProperties){let n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(r){let e=[];if(Array.isArray(r)){let i=new Set(r.flat(1/0).reverse());for(let n of i)e.unshift(er(n))}else r!==void 0&&e.push(er(r));return e}static _$Eu(r,e){let i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof r=="string"?r.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(r=>r(this))}addController(r){(this._$EO??(this._$EO=new Set)).add(r),this.renderRoot!==void 0&&this.isConnected&&r.hostConnected?.()}removeController(r){this._$EO?.delete(r)}_$E_(){let r=new Map,e=this.constructor.elementProperties;for(let i of e.keys())this.hasOwnProperty(i)&&(r.set(i,this[i]),delete this[i]);r.size>0&&(this._$Ep=r)}createRenderRoot(){let r=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Yr(r,this.constructor.elementStyles),r}connectedCallback(){this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),this._$EO?.forEach(r=>r.hostConnected?.())}enableUpdating(r){}disconnectedCallback(){this._$EO?.forEach(r=>r.hostDisconnected?.())}attributeChangedCallback(r,e,i){this._$AK(r,i)}_$ET(r,e){let i=this.constructor.elementProperties.get(r),n=this.constructor._$Eu(r,i);if(n!==void 0&&i.reflect===!0){let o=(i.converter?.toAttribute!==void 0?i.converter:We).toAttribute(e,i.type);this._$Em=r,o==null?this.removeAttribute(n):this.setAttribute(n,o),this._$Em=null}}_$AK(r,e){let i=this.constructor,n=i._$Eh.get(r);if(n!==void 0&&this._$Em!==n){let o=i.getPropertyOptions(n),a=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:We;this._$Em=n;let s=a.fromAttribute(e,o.type);this[n]=s??this._$Ej?.get(n)??s,this._$Em=null}}requestUpdate(r,e,i,n=!1,o){if(r!==void 0){let a=this.constructor;if(n===!1&&(o=this[r]),i??(i=a.getPropertyOptions(r)),!((i.hasChanged??Rt)(o,e)||i.useDefault&&i.reflect&&o===this._$Ej?.get(r)&&!this.hasAttribute(a._$Eu(r,i))))return;this.C(r,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(r,e,{useDefault:i,reflect:n,wrapped:o},a){i&&!(this._$Ej??(this._$Ej=new Map)).has(r)&&(this._$Ej.set(r,a??e??this[r]),o!==!0||a!==void 0)||(this._$AL.has(r)||(this.hasUpdated||i||(e=void 0),this._$AL.set(r,e)),n===!0&&this._$Em!==r&&(this._$Eq??(this._$Eq=new Set)).add(r))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let r=this.scheduleUpdate();return r!=null&&await r,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[n,o]of i){let{wrapped:a}=o,s=this[n];a!==!0||this._$AL.has(n)||s===void 0||this.C(n,void 0,o,s)}}let r=!1,e=this._$AL;try{r=this.shouldUpdate(e),r?(this.willUpdate(e),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(e)):this._$EM()}catch(i){throw r=!1,this._$EM(),i}r&&this._$AE(e)}willUpdate(r){}_$AE(r){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(r)),this.updated(r)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(r){return!0}update(r){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(r){}firstUpdated(r){}};ce.elementStyles=[],ce.shadowRootOptions={mode:"open"},ce[Ye("elementProperties")]=new Map,ce[Ye("finalized")]=new Map,co?.({ReactiveElement:ce}),(me.reactiveElementVersions??(me.reactiveElementVersions=[])).push("2.1.2");var Je=globalThis,Jr=t=>t,Lt=Je.trustedTypes,Zr=Lt?Lt.createPolicy("lit-html",{createHTML:t=>t}):void 0,ni="$lit$",ge=`lit$${Math.random().toFixed(9).slice(2)}$`,oi="?"+ge,uo=`<${oi}>`,xe=document,Ze=()=>xe.createComment(""),Qe=t=>t===null||typeof t!="object"&&typeof t!="function",sr=Array.isArray,po=t=>sr(t)||typeof t?.[Symbol.iterator]=="function",tr="[ \\t\\n\\f\\r]",Xe=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Qr=/-->/g,ei=/>/g,ve=RegExp(`>|${tr}(?:([^\\s"'>=/]+)(${tr}*=${tr}*(?:[^ \\t\\n\\f\\r"'\`<>=]|("|')|))|$)`,"g"),ti=/'/g,ri=/"/g,ai=/^(?:script|style|textarea|title)$/i,dr=t=>(r,...e)=>({_$litType$:t,strings:r,values:e}),c=dr(1),rt=dr(2),$l=dr(3),we=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),ii=new WeakMap,_e=xe.createTreeWalker(xe,129);function si(t,r){if(!sr(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Zr!==void 0?Zr.createHTML(r):r}var ho=(t,r)=>{let e=t.length-1,i=[],n,o=r===2?"<svg>":r===3?"<math>":"",a=Xe;for(let s=0;s<e;s++){let d=t[s],u,h,g=-1,v=0;for(;v<d.length&&(a.lastIndex=v,h=a.exec(d),h!==null);)v=a.lastIndex,a===Xe?h[1]==="!--"?a=Qr:h[1]!==void 0?a=ei:h[2]!==void 0?(ai.test(h[2])&&(n=RegExp("</"+h[2],"g")),a=ve):h[3]!==void 0&&(a=ve):a===ve?h[0]===">"?(a=n??Xe,g=-1):h[1]===void 0?g=-2:(g=a.lastIndex-h[2].length,u=h[1],a=h[3]===void 0?ve:h[3]==='"'?ri:ti):a===ri||a===ti?a=ve:a===Qr||a===ei?a=Xe:(a=ve,n=void 0);let x=a===ve&&t[s+1].startsWith("/>")?" ":"";o+=a===Xe?d+uo:g>=0?(i.push(u),d.slice(0,g)+ni+d.slice(g)+ge+x):d+ge+(g===-2?s:x)}return[si(t,o+(t[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),i]},et=class t{constructor({strings:r,_$litType$:e},i){let n;this.parts=[];let o=0,a=0,s=r.length-1,d=this.parts,[u,h]=ho(r,e);if(this.el=t.createElement(u,i),_e.currentNode=this.el.content,e===2||e===3){let g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(n=_e.nextNode())!==null&&d.length<s;){if(n.nodeType===1){if(n.hasAttributes())for(let g of n.getAttributeNames())if(g.endsWith(ni)){let v=h[a++],x=n.getAttribute(g).split(ge),N=/([.?@])?(.*)/.exec(v);d.push({type:1,index:o,name:N[2],strings:x,ctor:N[1]==="."?ir:N[1]==="?"?nr:N[1]==="@"?or:Re}),n.removeAttribute(g)}else g.startsWith(ge)&&(d.push({type:6,index:o}),n.removeAttribute(g));if(ai.test(n.tagName)){let g=n.textContent.split(ge),v=g.length-1;if(v>0){n.textContent=Lt?Lt.emptyScript:"";for(let x=0;x<v;x++)n.append(g[x],Ze()),_e.nextNode(),d.push({type:2,index:++o});n.append(g[v],Ze())}}}else if(n.nodeType===8)if(n.data===oi)d.push({type:2,index:o});else{let g=-1;for(;(g=n.data.indexOf(ge,g+1))!==-1;)d.push({type:7,index:o}),g+=ge.length-1}o++}}static createElement(r,e){let i=xe.createElement("template");return i.innerHTML=r,i}};function Oe(t,r,e=t,i){if(r===we)return r;let n=i!==void 0?e._$Co?.[i]:e._$Cl,o=Qe(r)?void 0:r._$litDirective$;return n?.constructor!==o&&(n?._$AO?.(!1),o===void 0?n=void 0:(n=new o(t),n._$AT(t,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=n:e._$Cl=n),n!==void 0&&(r=Oe(t,n._$AS(t,r.values),n,i)),r}var rr=class{constructor(r,e){this._$AV=[],this._$AN=void 0,this._$AD=r,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(r){let{el:{content:e},parts:i}=this._$AD,n=(r?.creationScope??xe).importNode(e,!0);_e.currentNode=n;let o=_e.nextNode(),a=0,s=0,d=i[0];for(;d!==void 0;){if(a===d.index){let u;d.type===2?u=new tt(o,o.nextSibling,this,r):d.type===1?u=new d.ctor(o,d.name,d.strings,this,r):d.type===6&&(u=new ar(o,this,r)),this._$AV.push(u),d=i[++s]}a!==d?.index&&(o=_e.nextNode(),a++)}return _e.currentNode=xe,n}p(r){let e=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(r,i,e),e+=i.strings.length-2):i._$AI(r[e])),e++}},tt=class t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,i,n){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=r,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let r=this._$AA.parentNode,e=this._$AM;return e!==void 0&&r?.nodeType===11&&(r=e.parentNode),r}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(r,e=this){r=Oe(this,r,e),Qe(r)?r===f||r==null||r===""?(this._$AH!==f&&this._$AR(),this._$AH=f):r!==this._$AH&&r!==we&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):po(r)?this.k(r):this._(r)}O(r){return this._$AA.parentNode.insertBefore(r,this._$AB)}T(r){this._$AH!==r&&(this._$AR(),this._$AH=this.O(r))}_(r){this._$AH!==f&&Qe(this._$AH)?this._$AA.nextSibling.data=r:this.T(xe.createTextNode(r)),this._$AH=r}$(r){let{values:e,_$litType$:i}=r,n=typeof i=="number"?this._$AC(r):(i.el===void 0&&(i.el=et.createElement(si(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{let o=new rr(n,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(r){let e=ii.get(r.strings);return e===void 0&&ii.set(r.strings,e=new et(r)),e}k(r){sr(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,i,n=0;for(let o of r)n===e.length?e.push(i=new t(this.O(Ze()),this.O(Ze()),this,this.options)):i=e[n],i._$AI(o),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$AR(r=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);r!==this._$AB;){let i=Jr(r).nextSibling;Jr(r).remove(),r=i}}setConnected(r){this._$AM===void 0&&(this._$Cv=r,this._$AP?.(r))}},Re=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,i,n,o){this.type=1,this._$AH=f,this._$AN=void 0,this.element=r,this.name=e,this._$AM=n,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=f}_$AI(r,e=this,i,n){let o=this.strings,a=!1;if(o===void 0)r=Oe(this,r,e,0),a=!Qe(r)||r!==this._$AH&&r!==we,a&&(this._$AH=r);else{let s=r,d,u;for(r=o[0],d=0;d<o.length-1;d++)u=Oe(this,s[i+d],e,d),u===we&&(u=this._$AH[d]),a||(a=!Qe(u)||u!==this._$AH[d]),u===f?r=f:r!==f&&(r+=(u??"")+o[d+1]),this._$AH[d]=u}a&&!n&&this.j(r)}j(r){r===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},ir=class extends Re{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===f?void 0:r}},nr=class extends Re{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==f)}},or=class extends Re{constructor(r,e,i,n,o){super(r,e,i,n,o),this.type=5}_$AI(r,e=this){if((r=Oe(this,r,e,0)??f)===we)return;let i=this._$AH,n=r===f&&i!==f||r.capture!==i.capture||r.once!==i.once||r.passive!==i.passive,o=r!==f&&(i===f||n);n&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,r),this._$AH=r}handleEvent(r){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,r):this._$AH.handleEvent(r)}},ar=class{constructor(r,e,i){this.element=r,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(r){Oe(this,r)}};var fo=Je.litHtmlPolyfillSupport;fo?.(et,tt),(Je.litHtmlVersions??(Je.litHtmlVersions=[])).push("3.3.2");var di=(t,r,e)=>{let i=e?.renderBefore??r,n=i._$litPart$;if(n===void 0){let o=e?.renderBefore??null;i._$litPart$=n=new tt(r.insertBefore(Ze(),o),o,void 0,e??{})}return n._$AI(t),n};var it=globalThis,$e=class extends ce{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;let r=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=r.firstChild),r}update(r){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(r),this._$Do=di(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return we}};$e._$litElement$=!0,$e.finalized=!0,it.litElementHydrateSupport?.({LitElement:$e});var mo=it.litElementPolyfillSupport;mo?.({LitElement:$e});(it.litElementVersions??(it.litElementVersions=[])).push("4.2.2");var k=t=>(r,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(t,r)}):customElements.define(t,r)};var go={attribute:!0,type:String,converter:We,reflect:!1,hasChanged:Rt},$o=(t=go,r,e)=>{let{kind:i,metadata:n}=e,o=globalThis.litPropertyMetadata.get(n);if(o===void 0&&globalThis.litPropertyMetadata.set(n,o=new Map),i==="setter"&&((t=Object.create(t)).wrapped=!0),o.set(e.name,t),i==="accessor"){let{name:a}=e;return{set(s){let d=r.get.call(this);r.set.call(this,s),this.requestUpdate(a,d,t,!0,s)},init(s){return s!==void 0&&this.C(a,void 0,t,s),s}}}if(i==="setter"){let{name:a}=e;return function(s){let d=this[a];r.call(this,s),this.requestUpdate(a,d,t,!0,s)}}throw Error("Unsupported decorator location: "+i)};function p(t){return(r,e)=>typeof e=="object"?$o(t,r,e):((i,n,o)=>{let a=n.hasOwnProperty(o);return n.constructor.createProperty(o,i),a?Object.getOwnPropertyDescriptor(n,o):void 0})(t,r,e)}function y(t){return p({...t,state:!0,attribute:!1})}var ke=(t,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(t,r,e),e);function nt(t,r){return(e,i,n)=>{let o=a=>a.renderRoot?.querySelector(t)??null;if(r){let{get:a,set:s}=typeof i=="object"?e:n??(()=>{let d=Symbol();return{get(){return this[d]},set(u){this[d]=u}}})();return ke(e,i,{get(){let d=a.call(this);return d===void 0&&(d=o(this),(d!==null||this.hasUpdated)&&s.call(this,d)),d}})}return ke(e,i,{get(){return o(this)}})}}function Le(t){return{name:t.name,description:t.description,input_schema:{...t.input_schema,properties:{...t.input_schema.properties},required:t.input_schema.required?[...t.input_schema.required]:void 0}}}var yo=[{name:"configure_profile_read",description:'Read compact approved profile context for the current user. Use this for a broad profile overview; use sections ["agents"] to inspect readable agent/source namespaces. This is not a raw file/path reader and not a connector list. Use configure_profile_search for source-attributed memories or facts.',input_schema:{type:"object",properties:{sections:{type:"array",items:{type:"string",enum:["identity","preferences","integrations","agents","summary"]},description:"Optional section filter. Omit to read the approved compact default profile. Allowed values: identity, preferences, integrations, agents, summary. This is not a path selector."}}}},{name:"configure_profile_search",description:'Search or list permitted attributed profile data for the current user. Omit query or pass "*" to list bounded permitted compact results. For "what does <source> know about me?", pass query "*" plus source, e.g. "tempo". For relative-date questions, resolve dates first and pass from/to. Compact results omit raw CFS paths; pass detail "full" only when you need inspectable metadata.',input_schema:{type:"object",properties:{query:{type:"string",description:'Optional search query. Omit or use "*" to list bounded permitted attributed profile results.'},source:{type:"string",description:'Optional explicit source handle filter, such as "tempo". This is not a path or connector and there is no magic self value.'},from:{type:"string",description:"Optional inclusive start date filter in YYYY-MM-DD format for date-attributed results."},to:{type:"string",description:"Optional inclusive end date filter in YYYY-MM-DD format for date-attributed results."},limit:{type:"number",description:"Optional maximum result count. The backend enforces a default and hard cap."},detail:{type:"string",enum:["compact","full"],description:"Optional result detail. Defaults to compact. Full includes safe path, markers, provenance, and updated_at metadata."}}}},{name:"configure_profile_remember",description:"Save one explicit durable user fact, preference, or memory for the current user under the API-key-resolved acting agent handle's namespace. Do not use for raw transcripts or message arrays.",input_schema:{type:"object",properties:{fact:{type:"string",description:"Required explicit durable memory text to save for the current user."}},required:["fact"]}}],bo={gmail:{name:"configure_gmail_search",description:"Search the user's connected Gmail account when Gmail is connected and this connector tool is enabled. Returns email search results, not stored profile memories.",input_schema:{type:"object",properties:{query:{type:"string",description:"Required Gmail search query."},max_results:{type:"number",description:"Optional maximum result count. The backend enforces a default and hard cap."}},required:["query"]}},calendar:{name:"configure_calendar_get",description:"Get events from the user's connected calendar when Calendar is connected and this connector tool is enabled.",input_schema:{type:"object",properties:{range:{type:"string",enum:["today","tomorrow","week","month"],description:"Optional bounded calendar range to retrieve. Omit to use week."}}}},drive:{name:"configure_drive_search",description:"Search the user's connected Google Drive files when Drive is connected and this connector tool is enabled. Returns file search results, not stored profile memories.",input_schema:{type:"object",properties:{query:{type:"string",description:"Required Drive search query."},max_results:{type:"number",description:"Optional maximum result count. The backend enforces a default and hard cap."}},required:["query"]}},notion:{name:"configure_notion_search",description:"Search the user's connected Notion pages when Notion is connected and this connector tool is enabled. Returns page search results, not stored profile memories.",input_schema:{type:"object",properties:{query:{type:"string",description:"Required Notion search query."},max_results:{type:"number",description:"Optional maximum result count. The backend enforces a default and hard cap."}},required:["query"]}}},vo={"email.send":{name:"configure_email_send",description:"Send an email from the user's connected Gmail account. This is an action and may require user or runtime approval.",input_schema:{type:"object",properties:{to:{type:"string",description:"Required recipient email address."},subject:{type:"string",description:"Required email subject."},body:{type:"string",description:"Required email body."}},required:["to","subject","body"]}},"calendar.create_event":{name:"configure_calendar_create_event",description:"Create an event in the user's connected calendar. This is an action and may require user or runtime approval.",input_schema:{type:"object",properties:{title:{type:"string",description:"Required event title."},start_time:{type:"string",description:"Required event start time in ISO 8601 format, including timezone or offset when known."},end_time:{type:"string",description:"Required event end time in ISO 8601 format, including timezone or offset when known."},description:{type:"string",description:"Optional event description."},location:{type:"string",description:"Optional event location."}},required:["title","start_time","end_time"]}}},_o={name:"configure_profile_commit",description:"Submit bounded source material for a prior Configure profile read/search. This is advanced adapter/runtime plumbing, not a default model tool and not a bulk import tool.",input_schema:{type:"object",properties:{read_id:{type:"string",description:"Optional read id returned by a prior profile read/search when the runtime provides one."},messages:{type:"array",items:{type:"object"},description:"Bounded surrounding turn messages to process for durable user memories."},memories:{type:"array",items:{type:"string"},description:"Explicit memory candidates to attribute to the API-key-resolved acting agent."}}}},xo=[{name:"configure_file_read",description:"Advanced: read a raw profile file path.",input_schema:{type:"object",properties:{path:{type:"string",description:"Profile file path to read."}},required:["path"]}},{name:"configure_file_write",description:"Advanced: write raw content to a profile file path.",input_schema:{type:"object",properties:{path:{type:"string",description:"Profile file path to write."},content:{type:"string",description:"Content to write."},type:{type:"string",enum:["markdown","json"],description:"Content type."},mode:{type:"string",enum:["overwrite","append","merge"],description:"Write mode."}},required:["path","content"]}},{name:"configure_file_list",description:"Advanced: list raw profile files under a profile file path.",input_schema:{type:"object",properties:{path:{type:"string",description:"Profile file path to list."},depth:{type:"number",description:"Listing depth."},limit:{type:"number",description:"Maximum number of entries."}}}},{name:"configure_file_search",description:"Advanced: search raw profile file contents.",input_schema:{type:"object",properties:{query:{type:"string",description:"Search query."},path:{type:"string",description:"Optional profile file path prefix."},limit:{type:"number",description:"Maximum number of results."}},required:["query"]}},{name:"configure_file_delete",description:"Advanced: delete a raw profile file path.",input_schema:{type:"object",properties:{path:{type:"string",description:"Profile file path to delete."}},required:["path"]}}],wo=[{name:"configure_web_search",description:"Search the web for current information. This is an opt-in utility, not a connector.",input_schema:{type:"object",properties:{query:{type:"string",description:"Required web search query."},max_results:{type:"number",description:"Optional maximum result count. The backend enforces a default and hard cap."}},required:["query"]}},{name:"configure_url_fetch",description:"Fetch readable text from a URL. This is an opt-in utility, not a connector.",input_schema:{type:"object",properties:{url:{type:"string",description:"Required URL to fetch."},max_length:{type:"number",description:"Optional maximum content length. The backend enforces a default and hard cap."}},required:["url"]}}];function lr(){return yo.map(Le)}function li(t=[]){return hi(t).map(r=>Le(bo[r]))}function ci(t=[]){return hi(t).map(r=>Le(vo[r]))}function ui(t={}){let r=[];return t.commit&&r.push(Le(_o)),t.files&&r.push(...xo.map(Le)),t.utilitySearch&&r.push(...wo.map(Le)),r}function pi(t={}){return[...lr(),...li(t.connectors),...ci(t.actions),...ui(t.advanced)]}function hi(t){return[...new Set(t)]}var b={API_KEY_MISSING:"API_KEY_MISSING",AUTH_REQUIRED:"AUTH_REQUIRED",INVALID_INPUT:"INVALID_INPUT",TOOL_NOT_CONNECTED:"TOOL_NOT_CONNECTED",NETWORK_ERROR:"NETWORK_ERROR",RATE_LIMITED:"RATE_LIMITED",NOT_FOUND:"NOT_FOUND",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",ACCESS_DENIED:"ACCESS_DENIED",TOOL_ERROR:"TOOL_ERROR",PAYMENT_REQUIRED:"PAYMENT_REQUIRED",COMMIT_REQUIRED:"COMMIT_REQUIRED"},m=class Ne extends Error{constructor(r,e,i,n){super(e),this.name="ConfigureError",this.code=r,this.statusCode=i,n&&(this.type=n.type,this.param=n.param,this.retryable=n.retryable,this.suggestedAction=n.suggestedAction,this.docUrl=n.docUrl,this.retryAfter=n.retryAfter,this.requestId=n.requestId)}static fromResponse(r,e){let i=e?.error;if(ko(i)){let o=Co(i.type,i.code),a=typeof i.message=="string"?i.message:"Request failed";return new Ne(o,a,r,{type:i.type,param:typeof i.param=="string"?i.param:i.param===null?null:void 0,retryable:typeof i.retryable=="boolean"?i.retryable:void 0,suggestedAction:typeof i.suggested_action=="string"?i.suggested_action:void 0,docUrl:typeof i.doc_url=="string"?i.doc_url:void 0,retryAfter:typeof i.retry_after=="number"?i.retry_after:void 0,requestId:typeof e.request_id=="string"?e.request_id:void 0})}let n=typeof i=="string"?i:typeof e?.message=="string"?e.message:"Request failed";return new Ne(No(r,n),n,r)}static fromCatch(r,e){return r instanceof Ne?r:r instanceof Error?r.name==="AbortError"?new Ne(b.TIMEOUT,"Request timed out"):new Ne(b.NETWORK_ERROR,r.message):new Ne(b.NETWORK_ERROR,e)}};function ko(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="string"&&typeof t.code=="string"}function Co(t,r){switch(t){case"authentication_error":return b.AUTH_REQUIRED;case"invalid_request_error":return b.INVALID_INPUT;case"permission_error":return r==="commit_required"?b.COMMIT_REQUIRED:b.ACCESS_DENIED;case"tool_error":return r==="tool_not_connected"?b.TOOL_NOT_CONNECTED:b.TOOL_ERROR;case"rate_limit_error":return r==="quota_exceeded"?b.PAYMENT_REQUIRED:b.RATE_LIMITED;case"api_error":return b.SERVER_ERROR;default:return b.SERVER_ERROR}}function No(t,r){if(t===401||t===403)return b.AUTH_REQUIRED;if(t===404)return b.NOT_FOUND;if(t===409&&r.toLowerCase().includes("commit"))return b.COMMIT_REQUIRED;if(t===429)return b.RATE_LIMITED;if(t>=500)return b.SERVER_ERROR;let e=r.toLowerCase();return e.includes("not connected")||e.includes("not linked")?b.TOOL_NOT_CONNECTED:b.INVALID_INPUT}var So=/^\+[1-9]\d{6,14}$/,Io=/^\d{6}$/,Po=/\.\.\//;function S(t,r){if(!t||!t.trim())throw new m(b.INVALID_INPUT,`${r} is required`)}function fi(t){S(t,"phone");let r=t.trim().replace(/[\s\-.()\u00A0]+/g,"");if(r.startsWith("+")||(r="+"+r),!So.test(r))throw new m(b.INVALID_INPUT,`Invalid phone number "${t}". Must be in E.164 format (e.g., "+14155551234").`);return r}function Eo(t){if(S(t,"code"),!Io.test(t))throw new m(b.INVALID_INPUT,"OTP code must be exactly 6 digits")}function To(t){if(S(t,"path"),Po.test(t))throw new m(b.INVALID_INPUT,'Path must not contain "../" (path traversal)')}var mi=new Set(["gmail","calendar","drive","notion"]);function Dt(t){if(S(t,"connector"),!mi.has(t))throw new m(b.INVALID_INPUT,`Invalid connector "${t}". Must be one of: ${[...mi].join(", ")}`)}var Ao=class{constructor(t,r,e,i,n){this.baseUrl=t,this.appKey=r,this.fetchFn=e,this.timeout=i,this.agent=n}createAbortSignal(){if(!this.timeout)return{clear:()=>{}};let t=new AbortController,r=setTimeout(()=>t.abort(),this.timeout);return{signal:t.signal,clear:()=>clearTimeout(r)}}async sendOtp(t){let r=fi(t),e=this.createAbortSignal();try{let i=await this.fetchFn(`${this.baseUrl}/v1/auth/otp/start`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.appKey},body:JSON.stringify({phone:r}),signal:e.signal});if(!i.ok){let n=await i.json().catch(()=>({}));throw m.fromResponse(i.status,n)}return{ok:!0}}catch(i){throw m.fromCatch(i,"OTP start failed")}finally{e.clear()}}async verifyOtp(t,r,e){let i=fi(t);Eo(r);let n=this.createAbortSignal();try{let o={"Content-Type":"application/json","X-API-Key":this.appKey};e?.embed&&(o["X-Configure-Embed"]="1");let a=await this.fetchFn(`${this.baseUrl}/v1/auth/otp/verify`,{method:"POST",headers:o,body:JSON.stringify({phone:i,code:r,...this.agent?{agent:this.agent}:{},...e?.externalId?{external_id:e.externalId}:{}}),signal:n.signal});if(!a.ok){let d=await a.json().catch(()=>({}));throw m.fromResponse(a.status,d)}let s=await a.json();return{token:s.token,userId:s.user_id,...s.embed_receipt?{embedReceipt:s.embed_receipt}:{}}}catch(o){throw m.fromCatch(o,"OTP verification failed")}finally{n.clear()}}async getDemo(){let t=this.createAbortSignal();try{let r=await this.fetchFn(`${this.baseUrl}/v1/auth/demo`,{method:"POST",headers:{"X-API-Key":this.appKey},signal:t.signal});if(!r.ok){let i=await r.json().catch(()=>({}));throw m.fromResponse(r.status,i)}return(await r.json()).user_token}catch(r){throw m.fromCatch(r,"Demo auth failed")}finally{t.clear()}}},Oo=class{constructor(t,r,e,i,n){this.baseUrl=t,this.appKey=r,this.fetchFn=e,this.timeout=i,this.defaultExternalId=n}getHeaders(t,r){let e={"Content-Type":"application/json","X-API-Key":this.appKey};return t?e.Authorization=`Bearer ${t}`:r&&(e["X-User-Id"]=r),e}resolveUserId(t,r){let e=t||r||this.defaultExternalId;if(!e)throw new m(b.INVALID_INPUT,"externalId or userId is required for raw file operations");return e}profileUrl(t,r){return`${this.baseUrl}/v1/profile/${encodeURIComponent(t)}${r}`}createAbortSignal(){if(!this.timeout)return{clear:()=>{}};let t=new AbortController,r=setTimeout(()=>t.abort(),this.timeout);return{signal:t.signal,clear:()=>clearTimeout(r)}}async list(t={}){let r=this.resolveUserId(t.userId,t.externalId),e=t.path??"/",i=this.getHeaders(t.token,r);if(!e||e==="/"){let a=this.createAbortSignal();try{let s=new URLSearchParams({path:"/"});t.depth!==void 0&&s.append("depth",String(t.depth)),t.limit!==void 0&&s.append("limit",String(t.limit));let d=await this.fetchFn(`${this.profileUrl(r,"")}?${s.toString()}`,{headers:i,signal:a.signal});if(!d.ok){let u=await d.json().catch(()=>({}));throw m.fromResponse(d.status,u)}return d.json()}catch(s){throw m.fromCatch(s,"Failed to list files")}finally{a.clear()}}let n=new URLSearchParams({path:e});t.depth!==void 0&&n.append("depth",String(t.depth)),t.limit!==void 0&&n.append("limit",String(t.limit));let o=this.createAbortSignal();try{let a=await this.fetchFn(`${this.profileUrl(r,"")}?${n.toString()}`,{headers:i,signal:o.signal});if(!a.ok){let s=await a.json().catch(()=>({}));throw m.fromResponse(a.status,s)}return a.json()}catch(a){throw m.fromCatch(a,"Failed to list files")}finally{o.clear()}}async read(t){let r=this.resolveUserId(t.userId,t.externalId);S(t.path,"path");let e=new URLSearchParams({path:t.path}),i=this.createAbortSignal();try{let n=await this.fetchFn(`${this.profileUrl(r,"/read")}?${e.toString()}`,{headers:this.getHeaders(t.token,r),signal:i.signal});if(!n.ok){if(n.status===404)return null;let a=await n.json().catch(()=>({}));throw m.fromResponse(n.status,a)}return await n.json()||null}catch(n){throw m.fromCatch(n,"Failed to read file")}finally{i.clear()}}async write(t){let r=this.resolveUserId(t.userId,t.externalId);S(t.path,"path"),To(t.path);let e=this.createAbortSignal();try{let i=await this.fetchFn(this.profileUrl(r,"/write"),{method:"PUT",headers:this.getHeaders(t.token,r),body:JSON.stringify({path:t.path,content:t.content,type:t.type||"markdown",mode:t.mode||"overwrite"}),signal:e.signal});if(!i.ok){let n=await i.json().catch(()=>({}));throw m.fromResponse(i.status,n)}return i.json()}catch(i){throw m.fromCatch(i,"Failed to write file")}finally{e.clear()}}async search(t){let r=this.resolveUserId(t.userId,t.externalId);S(t.query,"query");let e=new URLSearchParams({query:t.query}),i=t.path||t.scope;i&&e.append("scope",i),t.limit!==void 0&&e.append("limit",String(t.limit)),t.filesOnly!==void 0&&e.append("files_only",String(t.filesOnly));let n=this.createAbortSignal();try{let o=await this.fetchFn(`${this.profileUrl(r,"/search")}?${e.toString()}`,{headers:this.getHeaders(t.token,r),signal:n.signal});if(!o.ok){let a=await o.json().catch(()=>({}));throw m.fromResponse(o.status,a)}return o.json()}catch(o){throw m.fromCatch(o,"Failed to search files")}finally{n.clear()}}async delete(t){let r=this.resolveUserId(t.userId,t.externalId);S(t.path,"path");let e=new URLSearchParams({path:t.path}),i=this.createAbortSignal();try{let n=await this.fetchFn(`${this.profileUrl(r,"")}?${e.toString()}`,{method:"DELETE",headers:this.getHeaders(t.token,r),signal:i.signal});if(!n.ok){let o=await n.json().catch(()=>({}));throw m.fromResponse(n.status,o)}return n.json()}catch(n){throw m.fromCatch(n,"Failed to delete file")}finally{i.clear()}}},Ro=class{constructor(t,r,e,i){this.baseUrl=t,this.apiKey=r,this.fetchFn=e,this.timeout=i}async importProfiles(t){return(await this.request("/v1/import/profiles",{method:"POST",body:JSON.stringify(t)})).json()}async getJob(t){return(await this.request(`/v1/import/jobs/${encodeURIComponent(t)}`,{method:"GET"})).json()}async request(t,r){let e=this.createAbortSignal();try{let i=new Headers(r.headers);i.set("Content-Type","application/json"),i.set("X-API-Key",this.apiKey);let n=await this.fetchFn(`${this.baseUrl}${t}`,{...r,headers:i,signal:e.signal});if(!n.ok){let o=await n.json().catch(()=>({}));throw m.fromResponse(n.status,o)}return n}catch(i){throw m.fromCatch(i,"Failed to import profiles")}finally{e.clear()}}createAbortSignal(){if(!this.timeout)return{clear:()=>{}};let t=new AbortController,r=setTimeout(()=>t.abort(),this.timeout);return{signal:t.signal,clear:()=>clearTimeout(r)}}},Lo=class{constructor(t){this.requester=t}get(t){return this.requester.getJob(t)}},gi=`CONFIGURE GUIDELINES \u2014 handling personal data responsibly
GROUNDING:
- Only state specific facts (dates, names, amounts, locations) if they appear in the user's profile context or tool results.
- Never fabricate or assume personal information. If you lack data, say so.
- If the profile context seems incomplete, use profile or connector tools to retrieve data \u2014 do not guess.
- Resolve relative dates like "yesterday", "last week", and "last month" against the runtime's current date/time before searching profile or connector data.
TRANSPARENCY:
- When referencing personal data, briefly cite your source: "from your profile", "from another agent", "from your Gmail", "from your calendar", etc.
- If the user asks how you know something, explain clearly \u2014 you found it in their connected data.
- When using web search results, include source URLs so users can verify.
PROFILE SOURCES:
- For "what does <agent/source> know about me?", use configure_profile_search with query "*" and the explicit source handle.
- For "what did I talk about last week/month/yesterday?", search with date filters after resolving the date range.
- For "what agents have profile data about me?", use configure_profile_read with sections ["agents"] or list-style configure_profile_search with query "*".
- If results are filtered or hiddenSources is present, do not reveal hidden contents. It is okay to say that a source exists but is hidden from this agent.
- Do not confuse profile sources with connectors. Profile sources are agents that wrote profile data; connectors are external accounts like Gmail, Calendar, Drive, and Notion.
CONNECTORS:
- When a connector-backed tool returns a connection error or "not connected" status, do not echo the error. Let the user know naturally \u2014 e.g. "I'd need access to your calendar for that \u2014 would you like to connect it?"
- Do not repeatedly prompt the user to connect accounts they have already declined or been asked about.
CONVERSATION EFFICIENCY:
- Check conversation history before re-searching \u2014 you may have already retrieved the data.
- If a search didn't find what the user needs, try different queries with synonyms or alternative phrasing.`;function Ce(t){if(t!=null){if(typeof t=="string")return t;if(typeof t=="object"&&"value"in t)return t.value}}function Do(t,r){let e=[],i=r?.includeTools??!1,n=t.identity||{},o=[],a=[["Name",Ce(n.name)||""],["Email",Ce(n.email)||""],["Phone",Ce(n.phone_last4)?`...${Ce(n.phone_last4)}`:""],["Occupation",Ce(n.occupation)||""],["Location",Ce(n.location)||""],["Bio",Ce(n.bio)||""]];for(let[x,N]of a)N&&o.push(`${x}: ${N}`);let s=n.interests;Array.isArray(s)&&s.length>0&&o.push(`Interests: ${s.join(", ")}`),o.length>0&&e.push(`User:
${o.join(`
`)}`);let d=Object.entries(t.integrations||{}).filter(([,x])=>x.connected).map(([x])=>x);if(d.length>0&&e.push(`Connected: ${d.join(", ")}`),t.preferences&&t.preferences.length>0&&e.push(`Preferences:
${t.preferences.map(x=>`- ${x}`).join(`
`)}`),t.summary&&e.push(`About this user:
${t.summary}`),i){let x=t.integrations?.gmail;if(x?.connected){if(x.synthesis?.summary){let B=(x.synthesis.facts||[]).map(_=>`- ${_.fact}`).join(`
`);e.push(`Gmail insights:
${x.synthesis.summary}${B?`
Key facts:
${B}`:""}`)}if(x.ranked&&x.ranked.length>0){let B=x.ranked.slice(0,15).map(_=>{let R=_.subject||"",F=_.from||"",V=_.date||"";return`\u2022 ${R}${F?` (from: ${F})`:""}${V?` [${V}]`:""}`}).filter(Boolean);B.length>0&&e.push(`Gmail profile (top emails by importance):
${B.join(`
`)}`)}}let N=t.integrations?.calendar;if(N?.connected&&N.events&&N.events.length>0){let B=N.events.slice(0,5);e.push(`Calendar:
${B.map(_=>`\u2022 ${_.summary||_.title}`).join(`
`)}`)}let O=t.integrations?.drive;if(O?.connected&&O.files&&O.files.length>0){let B=O.files.slice(0,5);e.push(`Drive files:
${B.map(_=>`\u2022 ${_.name||_.title}`).join(`
`)}`)}let E=t.integrations?.notion;if(E?.connected&&E.pages&&E.pages.length>0){let B=E.pages.slice(0,5);e.push(`Notion pages:
${B.map(_=>`\u2022 ${_.title||_.name}`).join(`
`)}`)}}let u=t.agents||{},h=[];for(let[x,N]of Object.entries(u)){let O=N.memories;O&&O.length>0&&h.push({app:x,content:O.map(E=>E.content).join(`
`)})}if(h.length>0){let x=h.map(N=>`${N.app}:
${N.content}`).join(`
`);e.push(`Memories:
${x}`)}let g=e.join(`
`);return r?.guidelines??!0?g?`${g}
${gi}`:gi:g}var $i=20,yi=16e3,bi=5e4,ki=Symbol("configure.obligationMetadata"),Fo=class{constructor(t,r,e,i,n){this.baseUrl=t,this.appKey=r,this.fetchFn=e,this.timeout=i,this.defaultExternalId=n}getHeaders(t,r,e){let i={"Content-Type":"application/json","X-API-Key":this.appKey};return t?i.Authorization=`Bearer ${t}`:r&&(i["X-User-Id"]=r),e?.sessionId&&(i["X-Configure-Session-Id"]=e.sessionId),e?.runtimeScopeId&&(i["X-Configure-Runtime-Scope-Id"]=e.runtimeScopeId),e?.readId&&(i["X-Configure-Read-Id"]=e.readId),i}resolveSubject(t){if(t.token)return{token:t.token};let r=t.externalId||this.defaultExternalId;if(!r)throw new m(b.INVALID_INPUT,"profile requires token for linked users or externalId for unlinked users");return{externalId:r}}createAbortSignal(){if(!this.timeout)return{clear:()=>{}};let t=new AbortController,r=setTimeout(()=>t.abort(),this.timeout);return{signal:t.signal,clear:()=>clearTimeout(r)}}async read(t,r={},e){let i=this.resolveSubject(t),n=new URLSearchParams;r.sections&&n.append("sections",r.sections.join(","));let o=this.createAbortSignal();try{let a=n.toString(),s=await this.fetchFn(`${this.baseUrl}/v1/profile${a?`?${a}`:""}`,{method:"GET",headers:this.getHeaders(i.token,i.externalId,e),signal:o.signal});if(!s.ok){let N=await s.json().catch(()=>({}));throw m.fromResponse(s.status,N)}let d=await s.json(),{obligations:u,...h}=d,g=h,x={profile:Object.assign(g,{format(N){return Do(g,N)}}),portable:!!(h.portable??h.linked??i.token),filtered:!!h.filtered,hiddenSources:De(h.hidden_sources)||De(h.hiddenSources)};return vi(x,_i(s.headers)),x}catch(a){throw m.fromCatch(a,"Failed to read profile")}finally{o.clear()}}async search(t,r={},e){let i=this.resolveSubject(t),n=typeof r=="string"?{query:r}:r,o=new URLSearchParams;n.query&&o.append("query",n.query),n.source&&o.append("source",n.source),n.from&&o.append("from",n.from),n.to&&o.append("to",n.to),n.limit!==void 0&&o.append("limit",String(n.limit)),n.detail&&o.append("detail",n.detail);let a=this.createAbortSignal();try{let s=o.toString(),d=await this.fetchFn(`${this.baseUrl}/v1/profile/search${s?`?${s}`:""}`,{method:"GET",headers:this.getHeaders(i.token,i.externalId,e),signal:a.signal});if(!d.ok){let v=await d.json().catch(()=>({}));throw m.fromResponse(d.status,v)}let u=await d.json(),g={results:(Array.isArray(u.results)?u.results:Array.isArray(u.memories)?u.memories:[]).map((v,x)=>Ho(v,x)),filtered:!!u.filtered,hiddenSources:De(u.hidden_sources)||De(u.hiddenSources)||De(u.hiddenAgents)};return vi(g,_i(d.headers)),g}catch(s){throw m.fromCatch(s,"Failed to search profile")}finally{a.clear()}}async remember(t,r){let e=this.resolveSubject(t);if(typeof r!="string")throw new m(b.INVALID_INPUT,"profile.remember accepts one fact string, not messages");S(r,"fact");let i=this.createAbortSignal();try{let n=await this.fetchFn(`${this.baseUrl}/v1/profile/remember`,{method:"POST",headers:this.getHeaders(e.token,e.externalId),body:JSON.stringify({fact:r}),signal:i.signal});if(!n.ok){let o=await n.json().catch(()=>({}));throw m.fromResponse(n.status,o)}return n.json()}catch(n){throw m.fromCatch(n,"Failed to remember")}finally{i.clear()}}async commit(t,r,e){let i=this.resolveSubject(t),n=Uo(r),o=this.createAbortSignal();try{let a=await this.fetchFn(`${this.baseUrl}/v1/profile/commit`,{method:"POST",headers:this.getHeaders(i.token,i.externalId,e),body:JSON.stringify({...n.messages.length>0?{messages:n.messages}:{},...n.memories.length>0?{memories:n.memories}:{},...n.toolResults.length>0?{toolResults:n.toolResults}:{},...e?.readId?{read_id:e.readId}:{},...e?.sessionId?{session_id:e.sessionId}:{},...e?.runtimeScopeId?{runtime_scope_id:e.runtimeScopeId}:{},memory_criteria:"Extract durable user memories from this bounded runtime commit.",sync:r.sync}),signal:o.signal});if(!a.ok){let d=await a.json().catch(()=>({}));throw m.fromResponse(a.status,d)}let s=await a.json();return{status:s.status,facts_written:s.facts_written||s.memories_written||[],user_summary:s.user_summary,memories_written:s.memories_written||[],obligations_committed:s.obligations_committed||[],rejected_memories:s.rejected_memories||[]}}catch(a){throw m.fromCatch(a,"Failed to commit profile packet")}finally{o.clear()}}async generateDocuments(t,r){let e=this.resolveSubject(t),i=this.createAbortSignal();try{let n=await this.fetchFn(`${this.baseUrl}/v1/profile/documents/generate`,{method:"POST",headers:this.getHeaders(e.token,e.externalId),body:JSON.stringify({documents:r}),signal:i.signal});if(!n.ok){let o=await n.json().catch(()=>({}));throw m.fromResponse(n.status,o)}return n.json()}catch(n){throw m.fromCatch(n,"Failed to generate documents")}finally{i.clear()}}},Mo=class{constructor(t,r,e,i){this.requester=t,this.connectorRequester=r,this.filesRequester=e,this.runtime=i,this.enabledToolNames=new Set(lr().map(n=>n.name)),this.pendingReadIds=new Set,this.read=async n=>{let o=await this.requester.read(this.runtime,n,this.correlation());return this.recordObligations(xi(o)),o},this.search=async(n={})=>{let o=await this.requester.search(this.runtime,n,this.correlation());return this.recordObligations(xi(o)),o},this.remember=n=>this.requester.remember(this.runtime,n),this.commit=async n=>{let o=await this.requester.commit(this.runtime,n,this.correlation());return(o.status==="completed"||o.obligations_committed?.length||n.memories?.length)&&(this.pendingReadIds.clear(),this.runtimeScopeId=cr("scope")),o},this.tools=(n={})=>{let o=pi(n);return this.enabledToolNames=new Set(o.map(a=>a.name)),o},this.executeTool=async n=>{let{name:o,args:a}=jo(n);if(!this.enabledToolNames.has(o))throw new m(b.ACCESS_DENIED,`Tool ${o} is not enabled for this profile runtime`);switch(o){case"configure_profile_read":return this.read({sections:a.sections});case"configure_profile_search":return this.search({query:typeof a.query=="string"?a.query:void 0,source:a.source,from:a.from,to:a.to,limit:ye(a.limit),detail:a.detail==="full"?"full":a.detail==="compact"?"compact":void 0});case"configure_profile_remember":return this.remember(String(a.fact||""));case"configure_gmail_search":return this.connectorRequester.searchEmails(this.runtime.token,String(a.query||""),{maxResults:ye(a.max_results)});case"configure_calendar_get":return this.connectorRequester.getCalendar(this.runtime.token,a.range||"week");case"configure_drive_search":return this.connectorRequester.searchFiles(this.runtime.token,String(a.query||""),{maxResults:ye(a.max_results)});case"configure_notion_search":return this.connectorRequester.searchNotes(this.runtime.token,String(a.query||""),{maxResults:ye(a.max_results)});case"configure_email_send":return this.connectorRequester.sendEmail(this.runtime.token,{to:String(a.to||""),subject:String(a.subject||""),body:String(a.body||"")});case"configure_calendar_create_event":return this.connectorRequester.createCalendarEvent(this.runtime.token,{title:String(a.title||""),startTime:String(a.start_time||""),endTime:String(a.end_time||""),description:a.description,location:a.location});case"configure_profile_commit":return this.commit({messages:a.messages,memories:a.memories});case"configure_file_read":return this.filesRequester.read({token:this.runtime.token,externalId:this.runtime.externalId,path:String(a.path||"")});case"configure_file_write":return this.filesRequester.write({token:this.runtime.token,externalId:this.runtime.externalId,path:String(a.path||""),content:String(a.content||""),type:a.type,mode:a.mode});case"configure_file_list":return this.filesRequester.list({token:this.runtime.token,externalId:this.runtime.externalId,path:a.path,depth:ye(a.depth),limit:ye(a.limit)});case"configure_file_search":return this.filesRequester.search({token:this.runtime.token,externalId:this.runtime.externalId,query:String(a.query||""),path:a.path,limit:ye(a.limit)});case"configure_file_delete":return this.filesRequester.delete({token:this.runtime.token,externalId:this.runtime.externalId,path:String(a.path||"")});default:throw new m(b.INVALID_INPUT,`Unknown Configure tool: ${o}`)}},this.sessionId=wi(i,"sessionId")||cr("session"),this.runtimeScopeId=wi(i,"runtimeScopeId")||cr("scope")}correlation(){let t=this.pendingReadIds.values().next().value;return{sessionId:this.sessionId,runtimeScopeId:this.runtimeScopeId,...t?{readId:t}:{}}}recordObligations(t){if(!t||typeof t!="object")return;let r=t.readIds;if(Array.isArray(r))for(let e of r)typeof e=="string"&&e&&this.pendingReadIds.add(e)}};function jo(t){let r=t.name||t.function?.name;if(!r)throw new m(b.INVALID_INPUT,"Tool call name is required");let e=t.arguments??t.input??t.function?.arguments??{};if(typeof e=="string")try{return{name:r,args:JSON.parse(e)}}catch{throw new m(b.INVALID_INPUT,"Tool call arguments must be valid JSON")}return{name:r,args:e}}function Uo(t){if(!t||typeof t!="object")throw new m(b.INVALID_INPUT,"commit input is required");let r=t.messages?[...t.messages]:[];if(t.response!==void 0&&r.push({role:"assistant",content:typeof t.response=="string"?t.response:JSON.stringify(t.response)}),r.length>$i)throw new m(b.INVALID_INPUT,`profile.commit accepts at most ${$i} messages`);let e=0,i=r.map(a=>{if(!a.content)throw new m(b.INVALID_INPUT,"commit messag