@pagelines/widget 1.0.835 → 1.0.836
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/dist/widget.js +2 -2
- package/package.json +2 -2
package/dist/widget.js
CHANGED
|
@@ -85,7 +85,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
85
85
|
* vue v3.5.40
|
|
86
86
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
87
87
|
* @license MIT
|
|
88
|
-
**/});function _A(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function $A(e){let t=e?_A(e):0;return P$[t%P$.length]}function Di(e){let t=e?e[0].toUpperCase():"?",[n,i]=$A(e),r=['<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80">','<defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1">',`<stop offset="0%" stop-color="${n}"/>`,`<stop offset="100%" stop-color="${i}"/>`,"</linearGradient></defs>",'<rect width="80" height="80" fill="url(#g)"/>',`<text x="40" y="40" text-anchor="middle" dominant-baseline="central" fill="white" font-family="system-ui,-apple-system,sans-serif" font-size="36" font-weight="600">${t}</text>`,"</svg>"].join("");return`data:image/svg+xml;base64,${btoa(r)}`}var P$,y0=O(()=>{"use strict";P$=[["#6366f1","#8b5cf6"],["#3b82f6","#06b6d4"],["#10b981","#34d399"],["#f59e0b","#f97316"],["#ef4444","#f97316"],["#ec4899","#8b5cf6"],["#14b8a6","#3b82f6"],["#8b5cf6","#ec4899"]]});var ti,Ms=O(()=>{"use strict";Oe();ti=l.enum(["active","stopped"])});var Pi,x0,Ri,R$,M$,w0,U$,j$,Bu=O(()=>{"use strict";Oe();Pi=l.enum(["woman","man"]),x0=[{key:"lauren",gender:"woman",accent:"American",character:"Friendly, comforting and soft",isDefault:!0},{key:"amy",gender:"woman",accent:"American",character:"Natural and sweet"},{key:"eve",gender:"woman",accent:"American",character:"Authentic, energetic and happy"},{key:"korina",gender:"woman",accent:"American",character:"Calm and friendly"},{key:"tamsin",gender:"woman",accent:"British",character:"Engaging and emotionally resonant"},{key:"jessica",gender:"woman",accent:"British",character:"Smooth, articulate and warm"},{key:"jude",gender:"man",accent:"British",character:"Engaging and naturally conversational"},{key:"adam",gender:"man",accent:"American",character:"Engaging, friendly and bright",isDefault:!0},{key:"evan",gender:"man",accent:"American",character:"Calm, grounded and reflective"},{key:"jon",gender:"man",accent:"American",character:"Relaxed, deep and approachable"},{key:"joe",gender:"man",accent:"British",character:"Reflective and thoughtful"},{key:"julius",gender:"man",accent:"German",character:"Deep, articulate and professional"},{key:"chuck",gender:"man",accent:"American",character:"Easygoing and plain-spoken"}],Ri=l.enum(x0.map(e=>e.key)),R$=l.object({conversationId:l.string().min(1)}).strict(),M$=l.object({conversationId:l.string().min(1),agentId:l.string().min(1),personaName:l.string().min(1),personaTitle:l.string().max(255).nullable().optional(),gender:Pi,voiceKey:Ri.nullable(),sessionScope:l.enum(["private","org","public"]),senderName:l.string().optional(),senderRole:l.enum(["owner","member"]).optional(),sessionContext:l.string().max(1e3).optional(),threadSummary:l.string(),capabilities:l.array(l.object({name:l.string().min(1),description:l.string().min(1)})).optional(),surfaceGuidance:l.string().optional(),maxDurationSeconds:l.number().int().positive().max(3600).optional(),expiresAt:l.iso.datetime()}),w0=l.enum(["elevenlabs","livekit"]),U$=l.object({name:l.enum(["voice.ready","voice.first_playback","voice.failed"]),client:l.enum(["web","ios"]),agentId:l.string().min(1).max(64).optional(),conversationId:l.string().min(1).max(64).optional(),provider:w0.optional(),durationMs:l.number().int().min(0).max(36e5),phase:l.enum(["idle","minting","connecting","live","ended"]).optional(),code:l.string().min(1).max(64).optional(),appVersion:l.string().min(1).max(32).optional(),appBuild:l.string().min(1).max(32).optional()}).strict(),j$=l.discriminatedUnion("provider",[l.object({provider:l.literal("elevenlabs"),conversationToken:l.string().min(1),voiceId:l.string().min(1)}).strict(),l.object({provider:l.literal("livekit"),url:l.string().min(1),token:l.string().min(1),room:l.string().min(1)}).strict()])});var SA,EA,Yo,Zu,k0,L$,nn,Us=O(()=>{"use strict";Oe();zn();y0();Ao();Qc();xn();Qg();Ms();Kn();Bu();SA=l.object({platform:l.enum(["linkedin","x","facebook","tiktok","youtube","github","instagram","threads","email","phone","website"]),handle:l.string()}),EA=l.preprocess(e=>Array.isArray(e)?e.filter(t=>t&&typeof t=="object"&&t.platform&&t.handle):e,l.array(SA)),Yo=l.enum(["essential","professional","business"]),Zu=l.object({agentId:l.string().optional(),handle:l.string().optional(),ownerId:l.string().optional(),orgId:l.string().optional(),name:l.string().optional(),emoji:l.string().nullable().optional(),title:l.string().nullable().optional(),summary:l.string().nullable().optional(),entityType:l.string().optional(),avatarId:l.string().nullable().optional(),coverId:l.string().nullable().optional(),avatar:at.optional(),cover:at.optional(),email:l.string().nullable().optional(),website:l.string().url().nullable().optional(),accounts:EA.nullable().optional(),model:l.string().nullable().optional(),gender:Pi.optional(),voiceKey:Ri.nullable().optional(),billingTier:Yo.optional(),lastActiveAt:l.string().nullable().optional(),lastMessageAt:l.string().nullable().optional(),runtime:l.string().default("hermes").optional(),timezone:l.string().optional(),desiredStatus:ti.nullable().optional(),automationPrimaryChannel:l.string().optional(),heartbeatEnabled:l.boolean().optional(),heartbeatBriefingTime:vn.nullable().optional(),heartbeatCheckinTime:vn.nullable().optional(),heartbeatCloseoutTime:vn.nullable().optional(),onboardedAt:l.string().nullable().optional(),org:l.object({orgId:l.string(),handle:l.string(),name:l.string(),headline:l.string().optional(),summary:l.string().optional(),status:l.string()}).optional(),owner:l.object({userId:l.string(),fullName:l.string().optional(),avatar:at.optional()}).optional(),visibility:l.enum(["private","org","public"]).optional(),status:l.string().optional(),createdAt:l.string().optional(),updatedAt:l.string().optional()}),k0=Zu.extend({isPrimary:l.boolean().optional(),lifecycle:kn.optional(),changedAt:l.string().datetime().optional(),detail:l.string().optional(),blocker:wn.optional(),operation:ns.optional()}),L$=Object.keys(k0.shape),nn=class e extends Hr{constructor(t){let n="config"in t?{...t.config instanceof e?t.config.toConfig():t.config,context:t.context}:t;super("Agent",n),this.agentId=G(this.settings.agentId),this.handle=G(this.settings.handle),this.ownerId=G(this.settings.ownerId),this.orgId=G(this.settings.orgId),this.name=G(this.settings.name),this.title=G(this.settings.title),this.summary=G(this.settings.summary),this.entityType=G(this.settings.entityType),this.avatarId=G(this.settings.avatarId),this.coverId=G(this.settings.coverId),this.avatar=G(this.settings.avatar),this.cover=G(this.settings.cover),this.email=G(this.settings.email),this.website=G(this.settings.website),this.accounts=G(this.settings.accounts),this.model=G(this.settings.model),this.billingTier=G(this.settings.billingTier),this.lastActiveAt=G(this.settings.lastActiveAt),this.lastMessageAt=G(this.settings.lastMessageAt),this.timezone=G(this.settings.timezone),this.desiredStatus=G(this.settings.desiredStatus),this.automationPrimaryChannel=G(this.settings.automationPrimaryChannel),this.heartbeatEnabled=G(this.settings.heartbeatEnabled),this.heartbeatBriefingTime=G(this.settings.heartbeatBriefingTime),this.heartbeatCheckinTime=G(this.settings.heartbeatCheckinTime),this.heartbeatCloseoutTime=G(this.settings.heartbeatCloseoutTime),this.onboardedAt=G(this.settings.onboardedAt),this.org=G(this.settings.org),this.owner=G(this.settings.owner),this.visibility=G(this.settings.visibility),this.status=G(this.settings.status),this.createdAt=G(this.settings.createdAt),this.updatedAt=G(this.settings.updatedAt),this.isPrimary=G(this.settings.isPrimary),this.lifecycle=G(this.settings.lifecycle),this.changedAt=G(this.settings.changedAt),this.detail=G(this.settings.detail),this.blocker=G(this.settings.blocker),this.operation=G(this.settings.operation),this.state=N(()=>cu({lifecycle:this.lifecycle.value??"unknown",detail:this.detail.value,changedAt:this.changedAt.value,blocker:this.blocker.value,operation:this.operation.value},this.displayName.value)),this.avatarUrl=N(()=>this.avatar.value?.src||Di(this.name.value)),this.ownerMarkUrl=N(()=>{let i=this.owner.value;if(i)return i.avatar?.src||Di(i.fullName||i.userId)}),this.displayName=N(()=>this.name.value||"Unnamed"),this.hasCustomHandle=N(()=>!!this.handle.value&&!/\d{13,}$/.test(this.handle.value)),this.displayHandle=N(()=>this.hasCustomHandle.value?`@${this.handle.value}`:void 0),this.isContextPrimary=N(()=>!!this.agentId.value&&this.agentId.value===this.settings.context?.primaryAgentId),this.wakeUpLabel=N(()=>`Wake up ${this.displayName.value}`),this.manageLabel=N(()=>`Manage ${this.displayName.value}`),this.hasReceivedMessage=N(()=>!!this.lastMessageAt.value)}merge(t){for(let n of L$){if(!(n in t))continue;let i=this[n];i&&typeof i=="object"&&"value"in i&&(i.value=t[n])}}toConfig(){let t={};for(let n of L$){let i=this[n];i&&typeof i=="object"&&"value"in i&&(t[n]=i.value)}return t}toJSON(){return this.toConfig()}}});var js,_0,V$,IA,TA,zA,NA,AA,CA,Ls,OA,DA,F$,PA,Hu=O(()=>{"use strict";Oe();ov();xn();Us();js=l.string().trim().min(3).max(100).regex(/^[a-zA-Z0-9-]+$/,"Use the username from your LinkedIn profile URL"),_0=l.string().trim().toLowerCase().pipe(l.email()),V$=l.object({userId:l.string(),email:l.string().optional(),handle:l.string().optional(),fullName:l.string().optional(),linkedinUsername:js.optional(),avatarId:l.string().optional(),avatar:at.optional(),isEmailVerified:l.boolean().optional(),primaryAgentId:l.string().optional(),primaryOrgId:l.string().optional(),lastActiveOrgId:l.string().optional(),onboarding:l.any().optional(),recentAgentIds:l.array(l.string()).optional(),location:l.string().optional(),geo:l.any().optional(),systemRole:l.string().optional(),status:l.string().optional(),lastSeenAt:l.string().optional(),createdAt:l.string().optional(),updatedAt:l.string().optional(),onboarded:l.boolean().optional()}),IA=l.object({name:l.string().min(1).max(100).optional(),linkedinUsername:js.nullable().optional(),avatar:l.object({src:l.string(),mediaId:l.string()}).optional(),primaryAgentId:l.string().optional(),primaryOrgId:l.string().optional(),lastActiveOrgId:l.string().optional(),onboarding:l.any().optional()}).partial(),TA=l.object({email:_0}),zA=l.object({email:_0,code:l.string().min(6,"Verification code is required"),timezone:l.string().max(64).optional()}),NA=l.object({newEmail:_0}),AA=l.object({credential:l.string().optional(),code:l.string().optional(),timezone:l.string().max(64).optional(),source:l.enum(["web","ios"]).optional()}).refine(e=>e.credential||e.code,{message:"Either credential or code must be provided"}),CA=l.object({identityToken:l.string().min(1),fullName:l.string().optional(),timezone:l.string().max(64).optional()}),Ls=l.object({orgId:l.string().optional(),handle:l.string().optional(),name:l.string().optional(),email:l.string().nullable().optional(),website:l.string().url().nullable().optional(),summary:l.string().nullable().optional(),avatarId:l.string().nullable().optional(),avatar:at.optional(),coverId:l.string().nullable().optional(),cover:at.optional(),accounts:iv.nullable().optional(),ownerId:l.string().optional(),isPersonal:l.boolean().optional(),stripeCustomerIdTest:l.string().nullable().optional(),stripeCustomerIdLive:l.string().nullable().optional(),maxUsers:l.number().optional(),timezone:l.string().nullable().optional(),apiKey:l.string().nullable().optional(),syncedPlan:l.string().nullable().optional(),syncedBillingStatus:l.string().nullable().optional(),firstPaidAt:l.string().nullable().optional(),entitlementDeleteAt:l.string().nullable().optional(),billingLastSyncedAt:l.string().nullable().optional(),syncedPeriodStart:l.string().nullable().optional(),syncedPeriodEnd:l.string().nullable().optional(),onboarding:l.any().optional(),status:l.string().optional(),createdAt:l.string().optional(),updatedAt:l.string().optional()}),OA=Ls.extend({defaultAgent:l.object({agentId:l.string(),handle:l.string(),name:l.string(),orgId:l.string()}),onboardingCompleted:l.boolean().optional()}),DA=l.object({completedAt:l.string().datetime().optional(),setupBy:l.string().optional(),billingSetup:l.boolean().optional(),teamInvitesSetup:l.boolean().optional(),brandingSetup:l.boolean().optional(),domainsSetup:l.boolean().optional()}),F$=l.object({membershipId:l.string(),orgId:l.string(),name:l.string(),handle:l.string(),avatarId:l.string().optional(),avatar:at.optional(),coverId:l.string().optional(),cover:at.optional(),role:l.enum(["owner","admin","member","observer"]),memberCount:l.number().optional(),agentCount:l.number().optional(),joinedAt:l.string().datetime(),onboarding:DA.optional()}),PA=V$.extend({orgs:l.array(F$).optional(),agents:l.array(Zu).optional()})});var B$=O(()=>{"use strict";ov();cv();w_();av();k_();xn();Hu()});var Z$=O(()=>{"use strict"});var H$=O(()=>{"use strict"});function MA(e){return e.trim().toUpperCase().replace(/\s+/g," ")}function Vs(e){let t=MA(e);return t.length<=64&&RA.has(t)}var K$,RA,W$=O(()=>{"use strict";K$=["[SILENT]","SILENT","NO_REPLY","NO REPLY","NO-OP","NOOP","NO_OP","NO OP","[NO-OP]","[NOOP]","[NO_OP]","[NO OP]","HEARTBEAT_OK"],RA=new Set(K$)});var G$=O(()=>{"use strict"});var J$=O(()=>{"use strict"});var q$=O(()=>{"use strict"});var Y$=O(()=>{"use strict"});var on,Fs=O(()=>{"use strict";Oe();on=l.string().min(1).max(64).refine(e=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(new Date(0)),!0}catch{return!1}},"Invalid IANA timezone")});var $0,X$,Q$,eS,tS=O(()=>{"use strict";Oe();Us();Qc();Fs();Bu();$0=l.string().min(1).max(50).regex(/^(pagelines|channel-[a-z0-9-]+)$/),X$=l.object({orgId:l.string(),name:l.string().min(1).max(100),emoji:l.string().max(8).nullable().optional(),title:l.string().max(120).nullable().optional(),summary:l.string().max(500).nullable().optional(),handle:l.string().min(2).max(50).optional(),timezone:on.optional(),runtime:l.enum(["hermes"]).optional(),visibility:l.enum(["private","org","public"]).optional()}).strict(),Q$=l.object({name:l.string().min(1).max(100).optional(),handle:l.string().min(2).max(50).optional(),emoji:l.string().max(8).nullable().optional(),title:l.string().max(120).nullable().optional(),summary:l.string().max(500).nullable().optional(),email:l.string().email().nullable().optional(),website:l.string().url().nullable().optional(),avatarMediaId:l.string().nullable().optional(),coverMediaId:l.string().nullable().optional(),timezone:on.optional(),model:l.string().nullable().optional(),gender:Pi.optional(),voiceKey:Ri.nullable().optional(),billingTier:Yo.optional(),visibility:l.enum(["private","org","public"]).optional(),automationPrimaryChannel:$0.optional(),heartbeatEnabled:l.boolean().optional(),heartbeatBriefingTime:vn.nullable().optional(),heartbeatCheckinTime:vn.nullable().optional(),heartbeatCloseoutTime:vn.nullable().optional()}).strict(),eS=l.object({id:l.string(),label:l.string(),prompt:l.string()})});var S0,Xo,Ku=O(()=>{"use strict";Oe();S0=["AGENT_BOOT_FAILED","AGENT_CREATE_FAILED","AGENT_DELETED","AGENT_DELETE_FAILED","AGENT_INACTIVE","AGENT_LIMIT","AGENT_NOT_FOUND","AGENT_NOT_DEPLOYED","AGENT_TOKENS_MISSING","AGENT_UNREACHABLE","AGENT_UPDATE_FAILED","AGENT_WAKE_TIMEOUT","ALREADY_MEMBER","ATTACHMENT_TYPE_UNSUPPORTED","AUTH_ACCOUNT_NOT_FOUND","AUTH_BOT_BLOCKED","AUTH_DISPOSABLE_EMAIL","AUTH_EMAIL_IN_USE","AUTH_INVALID","AUTH_INVALID_CODE","AUTH_INVALID_HANDOFF","AUTH_LOCKED_OUT","AUTH_MISSING","AUTH_PROVIDER_FAILED","AUTH_PROVIDER_NOT_CONFIGURED","AUTH_RATE_LIMITED","AUTH_REVOKED","AUTH_TURNSTILE_MISSING","AUTH_UNKNOWN","AUTH_WRONG_TYPE","AUTOMATION_CHANNEL_UNAVAILABLE","AUTOMATION_PURPOSE_REQUIRED","BOT_REPLY_FAILED","BILLING_BUDGET_REACHED","BILLING_DEMO_SPENT","BILLING_NO_PLAN","BILLING_PAST_DUE","BILLING_RUNAWAY_CAP","BILLING_SEAT_LIMIT","CHECKOUT_FAILED","CONFIRMATION_REQUIRED","CREATE_FAILED","CREDIT_LIMIT","DELETE_FAILED","DUPLICATE_INVITE","EMAIL_DELIVERY_FAILED","EMAIL_FAILED","EMAIL_MISMATCH","EMAIL_RATE_LIMITED","EMAIL_REASON_NOT_ELIGIBLE","EMPTY_STREAM","EMPTY_PATCH","ENV_VAR_CONFLICT","ENV_VAR_RESERVED","EXTENSION_INACTIVE","FORBIDDEN","HANDLE_TAKEN","IMAGE_GENERATION_FAILED","IMAGE_GENERATION_UNCONFIGURED","INTERNAL_ERROR","INVALID_FILE","INVALID_PRIMARY_CHANNEL","UNKNOWN_AUTOMATION_CHANNEL","INVITE_CONFLICT","INVITE_EXPIRED","INVITE_INVALID","MCP_NOT_AVAILABLE","MCP_NOT_CONFIGURED","MEDIA_NOT_FOUND","MEDIA_SERVER_UNAVAILABLE","MEDIA_UPLOAD_FAILED","MEMORY_NOT_FOUND","MISSING_IDEMPOTENCY_KEY","NETWORK_ERROR","NO_WORKSPACE","NOT_A_MEMBER","NOT_AUTHORIZED","NOT_FOUND","ORG_NOT_FOUND","OVERAGE_CAP","OWNER_LOCK","PAIRING_VERIFY_FAILED","PAYMENT_FAILED","PLAN_LIMIT","PROVISIONER_UNAVAILABLE","RATE_LIMIT","RATE_LIMITED","REBUILD_FAILED","RESTART_FAILED","SEND_FAILED","STOP_FAILED","STREAM_DISCONNECT","STREAM_TIMEOUT","STRIPE_LOAD","TIMEOUT","TOKEN_ERROR","TOOL_PROTOCOL","TRIAL_ENDED","TURN_ACTIVE","UPLOAD_FAILED","VALIDATION_ERROR","VOICE_UNAVAILABLE","WAKE_FAILED"],Xo=l.enum(S0)});var E0,rS,nS=O(()=>{"use strict";Oe();Ao();Ku();E0=l.enum(["notFound","busy","rateLimited","timeout","invalidConfig","transient","fatal"]),rS=l.object({ok:l.literal(!1),error:l.string(),code:Xo.optional(),issue:wn.optional(),providerErrorKind:E0.optional()})});var I0,Bs,T0,Wu=O(()=>{"use strict";Oe();I0=l.object({kind:l.enum(["icon","favicon","service"]),icon:l.string().min(1).optional(),domain:l.string().min(1).optional(),serviceKey:l.string().min(1).optional()}).strict(),Bs=l.object({activityId:l.string().min(1),turnId:l.string().min(1),status:l.enum(["started","completed","failed"]),label:l.string().trim().min(1),kind:l.enum(["search","file","image","service","automation","handoff","other"]),toolName:l.string().min(1).optional(),serviceKey:l.string().min(1).optional(),startedAt:l.string().datetime().optional(),endedAt:l.string().datetime().optional(),durationMs:l.number().int().nonnegative().optional(),note:l.string().trim().min(1).optional(),visual:I0.optional()}).strict(),T0=Bs.extend({status:l.enum(["completed","failed"])})});function sS(e,t){e.revisitAt&&e.disposition!=="deferred"&&t.addIssue({code:"custom",path:["revisitAt"],message:"revisitAt requires deferred disposition"})}function uS(e,t){let n=new Set;for(let i of e.participants){let r=`${i.type}:${i.id}`;n.has(r)&&t.addIssue({code:"custom",path:["participants"],message:"Duplicate conversation participant."}),n.add(r)}}var iS,z0,Zs,Gu,oS,aS,N0,lS,A0,Ju,C0,cS,qu,dS,pS,mS,Yu=O(()=>{"use strict";Oe();xn();Wu();Fs();iS=wi,z0=l.object({kind:l.literal("inline"),offset:l.number().int().nonnegative()}),Zs=l.object({type:iS,src:l.url(),filename:l.string().min(1),mimeType:l.string().min(1),mediaId:l.string().min(1).optional(),size:l.number().int().nonnegative().optional(),width:l.number().int().positive().optional(),height:l.number().int().positive().optional(),duration:l.number().nonnegative().optional(),text:l.string().optional(),placement:z0.optional()}),Gu=l.object({ref:l.string().min(1).max(256)}).strict(),oS=l.enum(["handled","dismissed","deferred"]),aS=l.iso.datetime();N0=Gu.extend({disposition:oS.optional(),revisitAt:aS.optional()}).superRefine(sS),lS=Gu.extend({disposition:oS,revisitAt:aS.optional()}).superRefine(sS),A0=l.object({turnId:l.string().min(1).optional(),turnOutcome:l.enum(["failed","stopped"]).optional(),attachments:l.array(Zs).optional(),toolActivities:l.array(T0).optional(),issue:l.object({code:l.string(),bucket:l.enum(["account","error"]),actionLabel:l.string(),actionUrl:l.string(),help:l.string().optional()}).optional(),notification:l.object({push:l.boolean().optional(),excludeUserId:l.string().min(1).optional()}).optional(),automation:l.object({run:l.object({automationRunId:l.string(),sourceKind:l.enum(["webhook","schedule","heartbeat"]),sourceLabel:l.string().optional(),deliveryId:l.string().optional(),status:l.enum(["received","forwarded","owner_notified","needs_approval","completed","failed","dropped"])}).catchall(l.unknown())}).catchall(l.unknown()).optional(),ownerHandoff:l.literal(!0).optional(),attention:l.array(N0).max(20).optional()}).catchall(l.unknown()),Ju=l.object({messageId:l.string().min(1),conversationId:l.string().min(1),role:l.enum(["user","assistant","system"]),authorParticipantId:l.string().nullable(),systemKind:l.string().nullable(),content:l.string(),sequence:l.string().min(1),clientNonce:l.string().nullable().optional(),metadata:A0.nullable().optional(),status:l.string().nullable().optional(),createdAt:l.string(),updatedAt:l.string()}),C0=l.object({type:iS,mediaId:l.string().min(1).optional(),url:l.url().optional(),name:l.string().min(1).optional(),mimeType:l.string().min(1).optional(),duration:l.number().nonnegative().optional()}).superRefine((e,t)=>{if(!e.mediaId)for(let n of["url","name","mimeType"])e[n]||t.addIssue({code:"custom",path:[n],message:`${n} is required when mediaId is absent`})}),cS=l.object({conversationId:l.string().min(1),content:l.string().max(1e4).default(""),clientNonce:l.string().max(64).optional(),attachments:l.array(C0).max(10).optional(),channel:l.enum(["ios","dashboard"]).optional(),actionUrls:l.object({billing:l.string().max(500),agent:l.string().max(500)}).optional(),viewerTimezone:on.optional()}).refine(e=>e.content.trim().length>0||(e.attachments?.length??0)>0,{path:["content"],message:"Message or attachment required"}),qu=l.object({type:l.enum(["user","agent"]),id:l.string().min(1)}).strict();dS=l.object({orgId:l.string().min(1),participants:l.array(qu).min(1).max(20)}).strict().superRefine(uS),pS=l.object({orgId:l.string().min(1),participants:l.array(qu).min(1).max(20)}).strict().superRefine((e,t)=>{uS(e,t),e.participants.some(n=>n.type==="agent")||t.addIssue({code:"custom",path:["participants"],message:"New sessions require at least one agent participant."})}),mS=l.object({category:l.string().min(1).max(30).optional(),reason:l.string().max(2e3).optional()}).strict()});var O0,D0,fS,hS,gS=O(()=>{"use strict";Oe();Yu();O0=l.enum(["1:1","4:3","3:4","16:9","9:16"]),D0=l.enum(["1K","2K","4K"]),fS=l.object({prompt:l.string().trim().min(1).max(4e3),aspectRatio:O0.default("1:1"),outputFormat:l.enum(["png","jpeg","webp"]).default("webp"),resolution:D0.default("2K"),style:l.string().trim().max(200).optional(),altText:l.string().trim().max(500).optional(),referenceMediaIds:l.array(l.string().min(1)).max(4).optional()}).strict(),hS=l.object({mediaId:l.string().min(1),src:l.url(),filename:l.string().min(1),mimeType:l.string().min(1),width:l.number().int().positive().optional(),height:l.number().int().positive().optional(),provider:l.string().min(1).optional(),providerRequestId:l.string().min(1).optional(),media:l.string().startsWith("MEDIA:"),attachment:Zs.extend({type:l.literal("image")})})});var vS,P0,bS,yS,R0,xS,wS,M0,kS,_S=O(()=>{"use strict";Oe();nv();vS=l.object({identityToken:l.string().min(1),fullName:l.string().optional()}),P0=l.object({redirect:l.string(),redirectReason:l.string(),isNew:l.boolean(),deviceId:l.string()}),bS=l.object({ok:l.literal(!0),data:P0,token:l.string()}),yS=l.object({path:l.string().startsWith("/","path must be a relative dashboard path").refine(rv,"path must be a relative dashboard path")}),R0=l.object({url:l.string()}),xS=l.object({ok:l.literal(!0),data:R0}),wS=l.object({token:l.string().min(1)}),M0=l.object({redirect:l.string(),redirectReason:l.string(),deviceId:l.string()}),kS=l.object({ok:l.literal(!0),data:M0,token:l.string()})});var U0,j0,L0,V0,UA,$S,F0,SS,ES,IS,TS,zS=O(()=>{"use strict";Oe();Us();U0=l.enum(["none","active_assistant"]),j0=l.enum(["none","active","trial","canceling","past_due","paused"]),L0=l.object({brand:l.string(),last4:l.string(),expMonth:l.number(),expYear:l.number()}),V0=l.object({date:l.string(),amount:l.number(),status:l.string(),invoicePdf:l.string().optional()}),UA=l.object({graceEndsAt:l.string().optional(),suspended:l.boolean(),url:l.string().optional()}),$S=l.object({plan:U0,status:j0,price:l.number(),tierRates:l.record(l.string(),l.number()).optional(),maxAgents:l.number(),activeAgents:l.number(),workspaceTier:Yo.optional(),upcomingAmountDue:l.number().optional(),upcomingDueDate:l.string().optional(),nextBillDate:l.string().optional(),cancelAtPeriodEnd:l.boolean().optional(),cancelAt:l.string().optional(),trialEnd:l.string().optional(),trialDaysRemaining:l.number().optional(),paymentMethod:L0.optional(),paymentRecovery:UA.optional(),invoices:l.array(V0),stripeError:l.string().optional()}),F0=l.enum(["demo_agent_exists","demo_usage_exhausted","subscription_required","plan_limit"]),SS=l.object({canCreate:l.boolean(),activeAgents:l.number().int().nonnegative(),agentLimit:l.number().int().nonnegative(),isDemo:l.boolean(),reason:F0.optional()}),ES=l.object({orgId:l.string(),agentName:l.string().optional(),runtime:l.string().optional()}),IS=l.object({created:l.number(),skipped:l.number(),errors:l.array(l.string())}),TS=l.object({updated:l.number(),errors:l.array(l.string())})});function Hs(e){return{code:e.code,error:e.message,...e.bucket?{bucket:e.bucket}:{},...e.actionLabel?{actionLabel:e.actionLabel}:{},...e.actionUrl?{actionUrl:e.actionUrl}:{},...e.help?{help:e.help}:{}}}function Ks(e){if(e.event==="message"&&e.data.message.role==="user")return e.data.message.messageId}function H0(e){if(e.event==="message_delta"||e.event==="working_state"||e.event==="tool_activity"||e.event==="working_end"||e.event==="stream_end")return e.data.turnId;if(e.event==="message"){let t=e.data.message.metadata?.turnId;return typeof t=="string"?t:void 0}}function Xu(e,t){if(e.event==="status"||e.event==="error"||Ks(e))return!0;let n=H0(e);return t?n?n===t:e.event==="message":!1}var B0,Z0,Qo,K0=O(()=>{"use strict";Oe();Yu();Wu();Ku();Kn();B0=au,Z0=l.object({code:Xo,message:l.string(),bucket:l.enum(["account","error"]).optional(),actionLabel:l.string().optional(),actionUrl:l.string().optional(),help:l.string().optional()});Qo=l.discriminatedUnion("event",[l.object({event:l.literal("status"),data:B0}),l.object({event:l.literal("message"),data:l.object({message:Ju})}),l.object({event:l.literal("message_delta"),data:l.object({delta:l.string(),turnId:l.string(),messageId:l.string().optional(),role:l.enum(["assistant","system"]).optional()})}),l.object({event:l.literal("working_state"),data:l.object({description:l.string(),turnId:l.string().optional()})}),l.object({event:l.literal("tool_activity"),data:Bs}),l.object({event:l.literal("working_end"),data:l.object({turnId:l.string().optional()}).strict()}),l.object({event:l.literal("stream_end"),data:l.object({turnId:l.string().optional()}).strict()}),l.object({event:l.literal("error"),data:Z0})])});async function Qu(e){let t=e.fetchFn??fetch,n=e.headers??{},i=!1,r=!1,o=!1,a=!1,s,c=!1,u=!1,d,p=new AbortController,m=!1,f,$=()=>{},z=new Promise(_=>{$=_}),T=_=>{m||(m=!0,f&&clearTimeout(f),$(_))},V=(_,B)=>{o=!0,e.onTransportError({stage:_,message:B})},U=()=>{d?.cancel().catch(()=>{})};f=setTimeout(()=>{u=!0,V("stream-open","Timed out opening stream"),p.abort(),T("failed")},e.streamOpenTimeoutMs??1e4);let R=(async()=>{try{let _=await t(e.streamUrl,{headers:n,signal:p.signal});if(!_.ok){o=!0,T("failed"),e.onTransportError({stage:"stream-open",message:await jA(_)});return}if(d=_.body?.getReader(),!d){V("stream-open","No response stream"),T("failed");return}T("ready");for await(let B of W0(d))if(s||(s=Ks(B)),!(i&&!Xu(B,s))){if(B.event==="status")e.onLiveStatus?.(B.data);else if(B.event==="working_state")i&&e.onStatus?.(B.data.description);else if(B.event==="tool_activity")i&&e.onToolActivity?.(B.data);else if(B.event==="working_end")i&&e.onWorkingEnd?.();else if(B.event==="message_delta")i&&e.onDelta(B.data.delta,B.data.role);else if(B.event==="error"){o=!0,e.onChatError(B.data);break}else if(B.event==="message"&&(B.data.message.role==="assistant"||B.data.message.role==="system")){if(!i)continue;a||(a=!0,e.onMessage?.(B.data.message))}else if(B.event==="stream_end")break}!o&&a?e.onDone():!o&&i&&!r&&V("no-reply","Stream ended before reply arrived")}catch(_){!r&&!u&&(T("failed"),V("stream-read",_ instanceof Error?_.message:"Stream failed"))}finally{c=!0;try{await d?.cancel()}catch{}}})();if(await z==="failed"){await R;return}if(c){V("stream-open","Stream closed before send"),await R;return}try{i=!0;let _=await t(e.sendUrl,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(e.sendBody)}),B=await _.json();if(!B.ok){r=!0,p.abort(),U(),o=!0,e.onTransportError({stage:"api",message:B.error||`Send failed: HTTP ${_.status}`,...B.code?{code:B.code}:{}}),await R;return}s=B.data.messageId,e.onUserMessage?.(B.data)}catch(_){r=!0,p.abort(),U(),V("api",_ instanceof Error?_.message:"Send failed"),await R;return}await R}async function jA(e){let t="";try{let n=await e.text();n&&(t=` - ${n.slice(0,200)}`)}catch{}return`HTTP ${e.status}${t}`}async function*W0(e){let t=new TextDecoder,n="";for(;;){let{done:i,value:r}=await e.read();if(i)break;n+=t.decode(r,{stream:!0});let o=n.indexOf(`
|
|
88
|
+
**/});function _A(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return Math.abs(t)}function $A(e){let t=e?_A(e):0;return P$[t%P$.length]}function Di(e){let t=e?e[0].toUpperCase():"?",[n,i]=$A(e),r=['<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80">','<defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1">',`<stop offset="0%" stop-color="${n}"/>`,`<stop offset="100%" stop-color="${i}"/>`,"</linearGradient></defs>",'<rect width="80" height="80" fill="url(#g)"/>',`<text x="40" y="40" text-anchor="middle" dominant-baseline="central" fill="white" font-family="system-ui,-apple-system,sans-serif" font-size="36" font-weight="600">${t}</text>`,"</svg>"].join("");return`data:image/svg+xml;base64,${btoa(r)}`}var P$,y0=O(()=>{"use strict";P$=[["#6366f1","#8b5cf6"],["#3b82f6","#06b6d4"],["#10b981","#34d399"],["#f59e0b","#f97316"],["#ef4444","#f97316"],["#ec4899","#8b5cf6"],["#14b8a6","#3b82f6"],["#8b5cf6","#ec4899"]]});var ti,Ms=O(()=>{"use strict";Oe();ti=l.enum(["active","stopped"])});var Pi,x0,Ri,R$,M$,w0,U$,j$,Bu=O(()=>{"use strict";Oe();Pi=l.enum(["woman","man"]),x0=[{key:"lauren",gender:"woman",accent:"American",character:"Friendly, comforting and soft",isDefault:!0},{key:"amy",gender:"woman",accent:"American",character:"Natural and sweet"},{key:"eve",gender:"woman",accent:"American",character:"Authentic, energetic and happy"},{key:"korina",gender:"woman",accent:"American",character:"Calm and friendly"},{key:"tamsin",gender:"woman",accent:"British",character:"Engaging and emotionally resonant"},{key:"jessica",gender:"woman",accent:"British",character:"Smooth, articulate and warm"},{key:"jude",gender:"man",accent:"British",character:"Engaging and naturally conversational"},{key:"adam",gender:"man",accent:"American",character:"Engaging, friendly and bright",isDefault:!0},{key:"evan",gender:"man",accent:"American",character:"Calm, grounded and reflective"},{key:"jon",gender:"man",accent:"American",character:"Relaxed, deep and approachable"},{key:"joe",gender:"man",accent:"British",character:"Reflective and thoughtful"},{key:"julius",gender:"man",accent:"German",character:"Deep, articulate and professional"},{key:"chuck",gender:"man",accent:"American",character:"Easygoing and plain-spoken"}],Ri=l.enum(x0.map(e=>e.key)),R$=l.object({conversationId:l.string().min(1)}).strict(),M$=l.object({conversationId:l.string().min(1),agentId:l.string().min(1),personaName:l.string().min(1),personaTitle:l.string().max(255).nullable().optional(),gender:Pi,voiceKey:Ri.nullable(),sessionScope:l.enum(["private","org","public"]),senderName:l.string().optional(),senderRole:l.enum(["owner","member"]).optional(),sessionContext:l.string().max(1e3).optional(),threadSummary:l.string(),capabilities:l.array(l.object({name:l.string().min(1),description:l.string().min(1)})).optional(),surfaceGuidance:l.string().optional(),maxDurationSeconds:l.number().int().positive().max(3600).optional(),expiresAt:l.iso.datetime()}),w0=l.enum(["elevenlabs","livekit"]),U$=l.object({name:l.enum(["voice.ready","voice.first_playback","voice.failed"]),client:l.enum(["web","ios"]),agentId:l.string().min(1).max(64).optional(),conversationId:l.string().min(1).max(64).optional(),provider:w0.optional(),durationMs:l.number().int().min(0).max(36e5),phase:l.enum(["idle","minting","connecting","live","ended"]).optional(),code:l.string().min(1).max(64).optional(),appVersion:l.string().min(1).max(32).optional(),appBuild:l.string().min(1).max(32).optional()}).strict(),j$=l.discriminatedUnion("provider",[l.object({provider:l.literal("elevenlabs"),conversationToken:l.string().min(1),voiceId:l.string().min(1)}).strict(),l.object({provider:l.literal("livekit"),url:l.string().min(1),token:l.string().min(1),room:l.string().min(1)}).strict()])});var SA,EA,Yo,Zu,k0,L$,nn,Us=O(()=>{"use strict";Oe();zn();y0();Ao();Qc();xn();Qg();Ms();Kn();Bu();SA=l.object({platform:l.enum(["linkedin","x","facebook","tiktok","youtube","github","instagram","threads","email","phone","website"]),handle:l.string()}),EA=l.preprocess(e=>Array.isArray(e)?e.filter(t=>t&&typeof t=="object"&&t.platform&&t.handle):e,l.array(SA)),Yo=l.enum(["essential","professional","business"]),Zu=l.object({agentId:l.string().optional(),handle:l.string().optional(),ownerId:l.string().optional(),orgId:l.string().optional(),name:l.string().optional(),emoji:l.string().nullable().optional(),title:l.string().nullable().optional(),summary:l.string().nullable().optional(),entityType:l.string().optional(),avatarId:l.string().nullable().optional(),coverId:l.string().nullable().optional(),avatar:at.optional(),cover:at.optional(),email:l.string().nullable().optional(),website:l.string().url().nullable().optional(),accounts:EA.nullable().optional(),model:l.string().nullable().optional(),gender:Pi.optional(),voiceKey:Ri.nullable().optional(),billingTier:Yo.optional(),lastActiveAt:l.string().nullable().optional(),lastMessageAt:l.string().nullable().optional(),runtime:l.string().default("hermes").optional(),timezone:l.string().optional(),desiredStatus:ti.nullable().optional(),automationPrimaryChannel:l.string().optional(),heartbeatEnabled:l.boolean().optional(),heartbeatBriefingTime:vn.nullable().optional(),heartbeatCheckinTime:vn.nullable().optional(),heartbeatCloseoutTime:vn.nullable().optional(),onboardedAt:l.string().nullable().optional(),org:l.object({orgId:l.string(),handle:l.string(),name:l.string(),headline:l.string().optional(),summary:l.string().optional(),status:l.string()}).optional(),owner:l.object({userId:l.string(),fullName:l.string().optional(),avatar:at.optional()}).optional(),visibility:l.enum(["private","org","public"]).optional(),status:l.string().optional(),createdAt:l.string().optional(),updatedAt:l.string().optional()}),k0=Zu.extend({isPrimary:l.boolean().optional(),lifecycle:kn.optional(),changedAt:l.string().datetime().optional(),detail:l.string().optional(),blocker:wn.optional(),operation:ns.optional()}),L$=Object.keys(k0.shape),nn=class e extends Hr{constructor(t){let n="config"in t?{...t.config instanceof e?t.config.toConfig():t.config,context:t.context}:t;super("Agent",n),this.agentId=G(this.settings.agentId),this.handle=G(this.settings.handle),this.ownerId=G(this.settings.ownerId),this.orgId=G(this.settings.orgId),this.name=G(this.settings.name),this.title=G(this.settings.title),this.summary=G(this.settings.summary),this.entityType=G(this.settings.entityType),this.avatarId=G(this.settings.avatarId),this.coverId=G(this.settings.coverId),this.avatar=G(this.settings.avatar),this.cover=G(this.settings.cover),this.email=G(this.settings.email),this.website=G(this.settings.website),this.accounts=G(this.settings.accounts),this.model=G(this.settings.model),this.billingTier=G(this.settings.billingTier),this.lastActiveAt=G(this.settings.lastActiveAt),this.lastMessageAt=G(this.settings.lastMessageAt),this.timezone=G(this.settings.timezone),this.desiredStatus=G(this.settings.desiredStatus),this.automationPrimaryChannel=G(this.settings.automationPrimaryChannel),this.heartbeatEnabled=G(this.settings.heartbeatEnabled),this.heartbeatBriefingTime=G(this.settings.heartbeatBriefingTime),this.heartbeatCheckinTime=G(this.settings.heartbeatCheckinTime),this.heartbeatCloseoutTime=G(this.settings.heartbeatCloseoutTime),this.onboardedAt=G(this.settings.onboardedAt),this.org=G(this.settings.org),this.owner=G(this.settings.owner),this.visibility=G(this.settings.visibility),this.status=G(this.settings.status),this.createdAt=G(this.settings.createdAt),this.updatedAt=G(this.settings.updatedAt),this.isPrimary=G(this.settings.isPrimary),this.lifecycle=G(this.settings.lifecycle),this.changedAt=G(this.settings.changedAt),this.detail=G(this.settings.detail),this.blocker=G(this.settings.blocker),this.operation=G(this.settings.operation),this.state=N(()=>cu({lifecycle:this.lifecycle.value??"unknown",detail:this.detail.value,changedAt:this.changedAt.value,blocker:this.blocker.value,operation:this.operation.value},this.displayName.value)),this.avatarUrl=N(()=>this.avatar.value?.src||Di(this.name.value)),this.ownerMarkUrl=N(()=>{let i=this.owner.value;if(i)return i.avatar?.src||Di(i.fullName||i.userId)}),this.displayName=N(()=>this.name.value||"Unnamed"),this.hasCustomHandle=N(()=>!!this.handle.value&&!/\d{13,}$/.test(this.handle.value)),this.displayHandle=N(()=>this.hasCustomHandle.value?`@${this.handle.value}`:void 0),this.isContextPrimary=N(()=>!!this.agentId.value&&this.agentId.value===this.settings.context?.primaryAgentId),this.wakeUpLabel=N(()=>`Wake up ${this.displayName.value}`),this.manageLabel=N(()=>`Manage ${this.displayName.value}`),this.hasReceivedMessage=N(()=>!!this.lastMessageAt.value)}merge(t){for(let n of L$){if(!(n in t))continue;let i=this[n];i&&typeof i=="object"&&"value"in i&&(i.value=t[n])}}toConfig(){let t={};for(let n of L$){let i=this[n];i&&typeof i=="object"&&"value"in i&&(t[n]=i.value)}return t}toJSON(){return this.toConfig()}}});var js,_0,V$,IA,TA,zA,NA,AA,CA,Ls,OA,DA,F$,PA,Hu=O(()=>{"use strict";Oe();ov();xn();Us();js=l.string().trim().min(3).max(100).regex(/^[a-zA-Z0-9-]+$/,"Use the username from your LinkedIn profile URL"),_0=l.string().trim().toLowerCase().pipe(l.email()),V$=l.object({userId:l.string(),email:l.string().optional(),handle:l.string().optional(),fullName:l.string().optional(),linkedinUsername:js.optional(),avatarId:l.string().optional(),avatar:at.optional(),isEmailVerified:l.boolean().optional(),primaryAgentId:l.string().optional(),primaryOrgId:l.string().optional(),lastActiveOrgId:l.string().optional(),onboarding:l.any().optional(),recentAgentIds:l.array(l.string()).optional(),location:l.string().optional(),geo:l.any().optional(),systemRole:l.string().optional(),status:l.string().optional(),lastSeenAt:l.string().optional(),createdAt:l.string().optional(),updatedAt:l.string().optional(),onboarded:l.boolean().optional()}),IA=l.object({name:l.string().min(1).max(100).optional(),linkedinUsername:js.nullable().optional(),avatar:l.object({src:l.string(),mediaId:l.string()}).optional(),primaryAgentId:l.string().optional(),primaryOrgId:l.string().optional(),lastActiveOrgId:l.string().optional(),onboarding:l.any().optional()}).partial(),TA=l.object({email:_0}),zA=l.object({email:_0,code:l.string().min(6,"Verification code is required"),timezone:l.string().max(64).optional()}),NA=l.object({newEmail:_0}),AA=l.object({credential:l.string().optional(),code:l.string().optional(),timezone:l.string().max(64).optional(),source:l.enum(["web","ios"]).optional()}).refine(e=>e.credential||e.code,{message:"Either credential or code must be provided"}),CA=l.object({identityToken:l.string().min(1),fullName:l.string().optional(),timezone:l.string().max(64).optional()}),Ls=l.object({orgId:l.string().optional(),handle:l.string().optional(),name:l.string().optional(),email:l.string().nullable().optional(),website:l.string().url().nullable().optional(),summary:l.string().nullable().optional(),avatarId:l.string().nullable().optional(),avatar:at.optional(),coverId:l.string().nullable().optional(),cover:at.optional(),accounts:iv.nullable().optional(),ownerId:l.string().optional(),isPersonal:l.boolean().optional(),stripeCustomerIdTest:l.string().nullable().optional(),stripeCustomerIdLive:l.string().nullable().optional(),maxUsers:l.number().optional(),timezone:l.string().nullable().optional(),apiKey:l.string().nullable().optional(),syncedPlan:l.string().nullable().optional(),syncedBillingStatus:l.string().nullable().optional(),firstPaidAt:l.string().nullable().optional(),entitlementDeleteAt:l.string().nullable().optional(),billingLastSyncedAt:l.string().nullable().optional(),syncedPeriodStart:l.string().nullable().optional(),syncedPeriodEnd:l.string().nullable().optional(),onboarding:l.any().optional(),status:l.string().optional(),createdAt:l.string().optional(),updatedAt:l.string().optional()}),OA=Ls.extend({defaultAgent:l.object({agentId:l.string(),handle:l.string(),name:l.string(),orgId:l.string()}),onboardingCompleted:l.boolean().optional()}),DA=l.object({completedAt:l.string().datetime().optional(),setupBy:l.string().optional(),billingSetup:l.boolean().optional(),teamInvitesSetup:l.boolean().optional(),brandingSetup:l.boolean().optional(),domainsSetup:l.boolean().optional()}),F$=l.object({membershipId:l.string(),orgId:l.string(),name:l.string(),handle:l.string(),avatarId:l.string().optional(),avatar:at.optional(),coverId:l.string().optional(),cover:at.optional(),role:l.enum(["owner","admin","member","observer"]),memberCount:l.number().optional(),agentCount:l.number().optional(),joinedAt:l.string().datetime(),onboarding:DA.optional()}),PA=V$.extend({orgs:l.array(F$).optional(),agents:l.array(Zu).optional()})});var B$=O(()=>{"use strict";ov();cv();w_();av();k_();xn();Hu()});var Z$=O(()=>{"use strict"});var H$=O(()=>{"use strict"});function MA(e){return e.trim().toUpperCase().replace(/\s+/g," ")}function Vs(e){let t=MA(e);return t.length<=64&&RA.has(t)}var K$,RA,W$=O(()=>{"use strict";K$=["[SILENT]","SILENT","NO_REPLY","NO REPLY","NO-OP","NOOP","NO_OP","NO OP","[NO-OP]","[NOOP]","[NO_OP]","[NO OP]","HEARTBEAT_OK"],RA=new Set(K$)});var G$=O(()=>{"use strict"});var J$=O(()=>{"use strict"});var q$=O(()=>{"use strict"});var Y$=O(()=>{"use strict"});var on,Fs=O(()=>{"use strict";Oe();on=l.string().min(1).max(64).refine(e=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(new Date(0)),!0}catch{return!1}},"Invalid IANA timezone")});var $0,X$,Q$,eS,tS=O(()=>{"use strict";Oe();Us();Qc();Fs();Bu();$0=l.string().min(1).max(50).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),X$=l.object({orgId:l.string(),name:l.string().min(1).max(100),emoji:l.string().max(8).nullable().optional(),title:l.string().max(120).nullable().optional(),summary:l.string().max(500).nullable().optional(),handle:l.string().min(2).max(50).optional(),timezone:on.optional(),runtime:l.enum(["hermes"]).optional(),visibility:l.enum(["private","org","public"]).optional()}).strict(),Q$=l.object({name:l.string().min(1).max(100).optional(),handle:l.string().min(2).max(50).optional(),emoji:l.string().max(8).nullable().optional(),title:l.string().max(120).nullable().optional(),summary:l.string().max(500).nullable().optional(),email:l.string().email().nullable().optional(),website:l.string().url().nullable().optional(),avatarMediaId:l.string().nullable().optional(),coverMediaId:l.string().nullable().optional(),timezone:on.optional(),model:l.string().nullable().optional(),gender:Pi.optional(),voiceKey:Ri.nullable().optional(),billingTier:Yo.optional(),visibility:l.enum(["private","org","public"]).optional(),automationPrimaryChannel:$0.optional(),heartbeatEnabled:l.boolean().optional(),heartbeatBriefingTime:vn.nullable().optional(),heartbeatCheckinTime:vn.nullable().optional(),heartbeatCloseoutTime:vn.nullable().optional()}).strict(),eS=l.object({id:l.string(),label:l.string(),prompt:l.string()})});var S0,Xo,Ku=O(()=>{"use strict";Oe();S0=["AGENT_BOOT_FAILED","AGENT_CREATE_FAILED","AGENT_DELETED","AGENT_DELETE_FAILED","AGENT_INACTIVE","AGENT_LIMIT","AGENT_NOT_FOUND","AGENT_NOT_DEPLOYED","AGENT_TOKENS_MISSING","AGENT_UNREACHABLE","AGENT_UPDATE_FAILED","AGENT_WAKE_TIMEOUT","ALREADY_MEMBER","ATTACHMENT_TYPE_UNSUPPORTED","AUTH_ACCOUNT_NOT_FOUND","AUTH_BOT_BLOCKED","AUTH_DISPOSABLE_EMAIL","AUTH_EMAIL_IN_USE","AUTH_INVALID","AUTH_INVALID_CODE","AUTH_INVALID_HANDOFF","AUTH_LOCKED_OUT","AUTH_MISSING","AUTH_PROVIDER_FAILED","AUTH_PROVIDER_NOT_CONFIGURED","AUTH_RATE_LIMITED","AUTH_REVOKED","AUTH_TURNSTILE_MISSING","AUTH_UNKNOWN","AUTH_WRONG_TYPE","AUTOMATION_CHANNEL_UNAVAILABLE","AUTOMATION_PURPOSE_REQUIRED","BOT_REPLY_FAILED","BILLING_BUDGET_REACHED","BILLING_DEMO_SPENT","BILLING_NO_PLAN","BILLING_PAST_DUE","BILLING_RUNAWAY_CAP","BILLING_SEAT_LIMIT","CHECKOUT_FAILED","CONFIRMATION_REQUIRED","CREATE_FAILED","CREDIT_LIMIT","DELETE_FAILED","DUPLICATE_INVITE","EMAIL_DELIVERY_FAILED","EMAIL_FAILED","EMAIL_MISMATCH","EMAIL_RATE_LIMITED","EMAIL_REASON_NOT_ELIGIBLE","EMPTY_STREAM","EMPTY_PATCH","ENV_VAR_CONFLICT","ENV_VAR_RESERVED","EXTENSION_INACTIVE","FORBIDDEN","HANDLE_TAKEN","IMAGE_GENERATION_FAILED","IMAGE_GENERATION_UNCONFIGURED","INTERNAL_ERROR","INVALID_FILE","INVALID_PRIMARY_CHANNEL","UNKNOWN_AUTOMATION_CHANNEL","INVITE_CONFLICT","INVITE_EXPIRED","INVITE_INVALID","MCP_NOT_AVAILABLE","MCP_NOT_CONFIGURED","MEDIA_NOT_FOUND","MEDIA_SERVER_UNAVAILABLE","MEDIA_UPLOAD_FAILED","MEMORY_NOT_FOUND","MISSING_IDEMPOTENCY_KEY","NETWORK_ERROR","NO_WORKSPACE","NOT_A_MEMBER","NOT_AUTHORIZED","NOT_FOUND","ORG_NOT_FOUND","OVERAGE_CAP","OWNER_LOCK","PAIRING_VERIFY_FAILED","PAYMENT_FAILED","PLAN_LIMIT","PROVISIONER_UNAVAILABLE","RATE_LIMIT","RATE_LIMITED","REBUILD_FAILED","RESTART_FAILED","SEND_FAILED","STOP_FAILED","STREAM_DISCONNECT","STREAM_TIMEOUT","STRIPE_LOAD","TIMEOUT","TOKEN_ERROR","TOOL_PROTOCOL","TRIAL_ENDED","TURN_ACTIVE","UPLOAD_FAILED","VALIDATION_ERROR","VOICE_UNAVAILABLE","WAKE_FAILED"],Xo=l.enum(S0)});var E0,rS,nS=O(()=>{"use strict";Oe();Ao();Ku();E0=l.enum(["notFound","busy","rateLimited","timeout","invalidConfig","transient","fatal"]),rS=l.object({ok:l.literal(!1),error:l.string(),code:Xo.optional(),issue:wn.optional(),providerErrorKind:E0.optional()})});var I0,Bs,T0,Wu=O(()=>{"use strict";Oe();I0=l.object({kind:l.enum(["icon","favicon","service"]),icon:l.string().min(1).optional(),domain:l.string().min(1).optional(),serviceKey:l.string().min(1).optional()}).strict(),Bs=l.object({activityId:l.string().min(1),turnId:l.string().min(1),status:l.enum(["started","completed","failed"]),label:l.string().trim().min(1),kind:l.enum(["search","file","image","service","automation","handoff","other"]),toolName:l.string().min(1).optional(),serviceKey:l.string().min(1).optional(),startedAt:l.string().datetime().optional(),endedAt:l.string().datetime().optional(),durationMs:l.number().int().nonnegative().optional(),note:l.string().trim().min(1).optional(),visual:I0.optional()}).strict(),T0=Bs.extend({status:l.enum(["completed","failed"])})});function sS(e,t){e.revisitAt&&e.disposition!=="deferred"&&t.addIssue({code:"custom",path:["revisitAt"],message:"revisitAt requires deferred disposition"})}function uS(e,t){let n=new Set;for(let i of e.participants){let r=`${i.type}:${i.id}`;n.has(r)&&t.addIssue({code:"custom",path:["participants"],message:"Duplicate conversation participant."}),n.add(r)}}var iS,z0,Zs,Gu,oS,aS,N0,lS,A0,Ju,C0,cS,qu,dS,pS,mS,Yu=O(()=>{"use strict";Oe();xn();Wu();Fs();iS=wi,z0=l.object({kind:l.literal("inline"),offset:l.number().int().nonnegative()}),Zs=l.object({type:iS,src:l.url(),filename:l.string().min(1),mimeType:l.string().min(1),mediaId:l.string().min(1).optional(),size:l.number().int().nonnegative().optional(),width:l.number().int().positive().optional(),height:l.number().int().positive().optional(),duration:l.number().nonnegative().optional(),text:l.string().optional(),placement:z0.optional()}),Gu=l.object({ref:l.string().min(1).max(256)}).strict(),oS=l.enum(["handled","dismissed","deferred"]),aS=l.iso.datetime();N0=Gu.extend({disposition:oS.optional(),revisitAt:aS.optional()}).superRefine(sS),lS=Gu.extend({disposition:oS,revisitAt:aS.optional()}).superRefine(sS),A0=l.object({turnId:l.string().min(1).optional(),turnOutcome:l.enum(["failed","stopped"]).optional(),attachments:l.array(Zs).optional(),toolActivities:l.array(T0).optional(),issue:l.object({code:l.string(),bucket:l.enum(["account","error"]),actionLabel:l.string(),actionUrl:l.string(),help:l.string().optional()}).optional(),notification:l.object({push:l.boolean().optional(),excludeUserId:l.string().min(1).optional()}).optional(),automation:l.object({run:l.object({automationRunId:l.string(),sourceKind:l.enum(["webhook","schedule","heartbeat"]),sourceLabel:l.string().optional(),deliveryId:l.string().optional(),status:l.enum(["received","forwarded","owner_notified","needs_approval","completed","failed","dropped"])}).catchall(l.unknown())}).catchall(l.unknown()).optional(),ownerHandoff:l.literal(!0).optional(),attention:l.array(N0).max(20).optional()}).catchall(l.unknown()),Ju=l.object({messageId:l.string().min(1),conversationId:l.string().min(1),role:l.enum(["user","assistant","system"]),authorParticipantId:l.string().nullable(),systemKind:l.string().nullable(),content:l.string(),sequence:l.string().min(1),clientNonce:l.string().nullable().optional(),metadata:A0.nullable().optional(),status:l.string().nullable().optional(),createdAt:l.string(),updatedAt:l.string()}),C0=l.object({type:iS,mediaId:l.string().min(1).optional(),url:l.url().optional(),name:l.string().min(1).optional(),mimeType:l.string().min(1).optional(),duration:l.number().nonnegative().optional()}).superRefine((e,t)=>{if(!e.mediaId)for(let n of["url","name","mimeType"])e[n]||t.addIssue({code:"custom",path:[n],message:`${n} is required when mediaId is absent`})}),cS=l.object({conversationId:l.string().min(1),content:l.string().max(1e4).default(""),clientNonce:l.string().max(64).optional(),attachments:l.array(C0).max(10).optional(),channel:l.enum(["ios","dashboard"]).optional(),actionUrls:l.object({billing:l.string().max(500),agent:l.string().max(500)}).optional(),viewerTimezone:on.optional()}).refine(e=>e.content.trim().length>0||(e.attachments?.length??0)>0,{path:["content"],message:"Message or attachment required"}),qu=l.object({type:l.enum(["user","agent"]),id:l.string().min(1)}).strict();dS=l.object({orgId:l.string().min(1),participants:l.array(qu).min(1).max(20)}).strict().superRefine(uS),pS=l.object({orgId:l.string().min(1),participants:l.array(qu).min(1).max(20)}).strict().superRefine((e,t)=>{uS(e,t),e.participants.some(n=>n.type==="agent")||t.addIssue({code:"custom",path:["participants"],message:"New sessions require at least one agent participant."})}),mS=l.object({category:l.string().min(1).max(30).optional(),reason:l.string().max(2e3).optional()}).strict()});var O0,D0,fS,hS,gS=O(()=>{"use strict";Oe();Yu();O0=l.enum(["1:1","4:3","3:4","16:9","9:16"]),D0=l.enum(["1K","2K","4K"]),fS=l.object({prompt:l.string().trim().min(1).max(4e3),aspectRatio:O0.default("1:1"),outputFormat:l.enum(["png","jpeg","webp"]).default("webp"),resolution:D0.default("2K"),style:l.string().trim().max(200).optional(),altText:l.string().trim().max(500).optional(),referenceMediaIds:l.array(l.string().min(1)).max(4).optional()}).strict(),hS=l.object({mediaId:l.string().min(1),src:l.url(),filename:l.string().min(1),mimeType:l.string().min(1),width:l.number().int().positive().optional(),height:l.number().int().positive().optional(),provider:l.string().min(1).optional(),providerRequestId:l.string().min(1).optional(),media:l.string().startsWith("MEDIA:"),attachment:Zs.extend({type:l.literal("image")})})});var vS,P0,bS,yS,R0,xS,wS,M0,kS,_S=O(()=>{"use strict";Oe();nv();vS=l.object({identityToken:l.string().min(1),fullName:l.string().optional()}),P0=l.object({redirect:l.string(),redirectReason:l.string(),isNew:l.boolean(),deviceId:l.string()}),bS=l.object({ok:l.literal(!0),data:P0,token:l.string()}),yS=l.object({path:l.string().startsWith("/","path must be a relative dashboard path").refine(rv,"path must be a relative dashboard path")}),R0=l.object({url:l.string()}),xS=l.object({ok:l.literal(!0),data:R0}),wS=l.object({token:l.string().min(1)}),M0=l.object({redirect:l.string(),redirectReason:l.string(),deviceId:l.string()}),kS=l.object({ok:l.literal(!0),data:M0,token:l.string()})});var U0,j0,L0,V0,UA,$S,F0,SS,ES,IS,TS,zS=O(()=>{"use strict";Oe();Us();U0=l.enum(["none","active_assistant"]),j0=l.enum(["none","active","trial","canceling","past_due","paused"]),L0=l.object({brand:l.string(),last4:l.string(),expMonth:l.number(),expYear:l.number()}),V0=l.object({date:l.string(),amount:l.number(),status:l.string(),invoicePdf:l.string().optional()}),UA=l.object({graceEndsAt:l.string().optional(),suspended:l.boolean(),url:l.string().optional()}),$S=l.object({plan:U0,status:j0,price:l.number(),tierRates:l.record(l.string(),l.number()).optional(),maxAgents:l.number(),activeAgents:l.number(),workspaceTier:Yo.optional(),upcomingAmountDue:l.number().optional(),upcomingDueDate:l.string().optional(),nextBillDate:l.string().optional(),cancelAtPeriodEnd:l.boolean().optional(),cancelAt:l.string().optional(),trialEnd:l.string().optional(),trialDaysRemaining:l.number().optional(),paymentMethod:L0.optional(),paymentRecovery:UA.optional(),invoices:l.array(V0),stripeError:l.string().optional()}),F0=l.enum(["demo_agent_exists","demo_usage_exhausted","subscription_required","plan_limit"]),SS=l.object({canCreate:l.boolean(),activeAgents:l.number().int().nonnegative(),agentLimit:l.number().int().nonnegative(),isDemo:l.boolean(),reason:F0.optional()}),ES=l.object({orgId:l.string(),agentName:l.string().optional(),runtime:l.string().optional()}),IS=l.object({created:l.number(),skipped:l.number(),errors:l.array(l.string())}),TS=l.object({updated:l.number(),errors:l.array(l.string())})});function Hs(e){return{code:e.code,error:e.message,...e.bucket?{bucket:e.bucket}:{},...e.actionLabel?{actionLabel:e.actionLabel}:{},...e.actionUrl?{actionUrl:e.actionUrl}:{},...e.help?{help:e.help}:{}}}function Ks(e){if(e.event==="message"&&e.data.message.role==="user")return e.data.message.messageId}function H0(e){if(e.event==="message_delta"||e.event==="working_state"||e.event==="tool_activity"||e.event==="working_end"||e.event==="stream_end")return e.data.turnId;if(e.event==="message"){let t=e.data.message.metadata?.turnId;return typeof t=="string"?t:void 0}}function Xu(e,t){if(e.event==="status"||e.event==="error"||Ks(e))return!0;let n=H0(e);return t?n?n===t:e.event==="message":!1}var B0,Z0,Qo,K0=O(()=>{"use strict";Oe();Yu();Wu();Ku();Kn();B0=au,Z0=l.object({code:Xo,message:l.string(),bucket:l.enum(["account","error"]).optional(),actionLabel:l.string().optional(),actionUrl:l.string().optional(),help:l.string().optional()});Qo=l.discriminatedUnion("event",[l.object({event:l.literal("status"),data:B0}),l.object({event:l.literal("message"),data:l.object({message:Ju})}),l.object({event:l.literal("message_delta"),data:l.object({delta:l.string(),turnId:l.string(),messageId:l.string().optional(),role:l.enum(["assistant","system"]).optional()})}),l.object({event:l.literal("working_state"),data:l.object({description:l.string(),turnId:l.string().optional()})}),l.object({event:l.literal("tool_activity"),data:Bs}),l.object({event:l.literal("working_end"),data:l.object({turnId:l.string().optional()}).strict()}),l.object({event:l.literal("stream_end"),data:l.object({turnId:l.string().optional()}).strict()}),l.object({event:l.literal("error"),data:Z0})])});async function Qu(e){let t=e.fetchFn??fetch,n=e.headers??{},i=!1,r=!1,o=!1,a=!1,s,c=!1,u=!1,d,p=new AbortController,m=!1,f,$=()=>{},z=new Promise(_=>{$=_}),T=_=>{m||(m=!0,f&&clearTimeout(f),$(_))},V=(_,B)=>{o=!0,e.onTransportError({stage:_,message:B})},U=()=>{d?.cancel().catch(()=>{})};f=setTimeout(()=>{u=!0,V("stream-open","Timed out opening stream"),p.abort(),T("failed")},e.streamOpenTimeoutMs??1e4);let R=(async()=>{try{let _=await t(e.streamUrl,{headers:n,signal:p.signal});if(!_.ok){o=!0,T("failed"),e.onTransportError({stage:"stream-open",message:await jA(_)});return}if(d=_.body?.getReader(),!d){V("stream-open","No response stream"),T("failed");return}T("ready");for await(let B of W0(d))if(s||(s=Ks(B)),!(i&&!Xu(B,s))){if(B.event==="status")e.onLiveStatus?.(B.data);else if(B.event==="working_state")i&&e.onStatus?.(B.data.description);else if(B.event==="tool_activity")i&&e.onToolActivity?.(B.data);else if(B.event==="working_end")i&&e.onWorkingEnd?.();else if(B.event==="message_delta")i&&e.onDelta(B.data.delta,B.data.role);else if(B.event==="error"){o=!0,e.onChatError(B.data);break}else if(B.event==="message"&&(B.data.message.role==="assistant"||B.data.message.role==="system")){if(!i)continue;a||(a=!0,e.onMessage?.(B.data.message))}else if(B.event==="stream_end")break}!o&&a?e.onDone():!o&&i&&!r&&V("no-reply","Stream ended before reply arrived")}catch(_){!r&&!u&&(T("failed"),V("stream-read",_ instanceof Error?_.message:"Stream failed"))}finally{c=!0;try{await d?.cancel()}catch{}}})();if(await z==="failed"){await R;return}if(c){V("stream-open","Stream closed before send"),await R;return}try{i=!0;let _=await t(e.sendUrl,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(e.sendBody)}),B=await _.json();if(!B.ok){r=!0,p.abort(),U(),o=!0,e.onTransportError({stage:"api",message:B.error||`Send failed: HTTP ${_.status}`,...B.code?{code:B.code}:{}}),await R;return}s=B.data.messageId,e.onUserMessage?.(B.data)}catch(_){r=!0,p.abort(),U(),V("api",_ instanceof Error?_.message:"Send failed"),await R;return}await R}async function jA(e){let t="";try{let n=await e.text();n&&(t=` - ${n.slice(0,200)}`)}catch{}return`HTTP ${e.status}${t}`}async function*W0(e){let t=new TextDecoder,n="";for(;;){let{done:i,value:r}=await e.read();if(i)break;n+=t.decode(r,{stream:!0});let o=n.indexOf(`
|
|
89
89
|
|
|
90
90
|
`);for(;o!==-1;){let a=n.slice(0,o);n=n.slice(o+2);let s=LA(a);s&&(yield s),o=n.indexOf(`
|
|
91
91
|
|
|
@@ -94,7 +94,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
94
94
|
`)};let c=et(e.xAxis)??et(e.xLabel),u=et(e.yAxis)??et(e.yLabel),d=u??"Value";return{version:1,visualType:"chart",chartType:t,meta:a,xKey:"label",...c?{xAxisLabel:c}:{},series:[{dataKey:"value",label:d,...u?{axisLabel:u}:{}}],data:i,fallbackMarkdown:s??[`| ${an(c??"Label")} | ${an(d)} |`,"|---|---:|",...i.map(p=>`| ${an(p.label)} | ${an(p.value)} |`)].join(`
|
|
95
95
|
`)}}function nC(e){if(!Mi(e)||(et(e.visualType)??et(e.kind))!=="chart")return null;let n=et(e.chartType);if(n!=="bar"&&n!=="line"&&n!=="scatter")return null;let i=Mi(e.xAxis)?e.xAxis:void 0,r=et(e.xKey)??(i?et(i.key)??et(i.dataKey):void 0);if(!r)return null;let o=et(e.xAxisLabel)??(i?et(i.label):void 0);if(!Array.isArray(e.series))return null;let a=[];for(let f of e.series){if(!Mi(f))return null;let $=et(f.dataKey)??et(f.key);if(!$)return null;let z=et(f.label)??et(f.name);a.push({dataKey:$,...z?{label:z}:{}})}if(a.length===0||!Array.isArray(e.data))return null;let s=e.data.filter(Mi),c=Mi(e.meta)?e.meta:e,u=et(c.title);if(!u)return null;let d=et(c.description)??et(c.subtitle),p=et(c.footer)??et(c.source),m=et(e.fallbackMarkdown)??[`| ${an(o??r)} | ${a.map(f=>an(f.label??f.dataKey)).join(" | ")} |`,`|---|${a.map(()=>"---:").join("|")}|`,...s.map(f=>`| ${an(f[r])} | ${a.map($=>an(f[$.dataKey])).join(" | ")} |`)].join(`
|
|
96
96
|
`);return{version:1,visualType:"chart",chartType:n,meta:{title:u,...d?{description:d}:{},...p?{footer:p}:{}},xKey:r,...o?{xAxisLabel:o}:{},series:a,data:s,fallbackMarkdown:m}}function rd(e){let t;try{t=JSON.parse(e)}catch(i){let r=e.match(/"fallbackMarkdown"\s*:\s*"((?:[^"\\]|\\.)*)"/),o;if(r)try{o=JSON.parse(`"${r[1]}"`)}catch{}return{ok:!1,reason:"invalid_json",message:i instanceof Error?i.message:"Invalid JSON",fallbackMarkdown:o}}let n=td.safeParse(t);if(!n.success){let i=rC(t)??nC(t);if(i){let r=td.safeParse(i);if(r.success)return{ok:!0,spec:r.data}}return{ok:!1,reason:"invalid_spec",message:n.error.issues.map(r=>r.message).join("; "),fallbackMarkdown:QA(t)}}return{ok:!0,spec:n.data}}var FA,J0,Nn,ea,BA,CS,ZA,HA,OS,DS,q0,WA,GA,JA,qA,YA,XA,td,MS=O(()=>{"use strict";Oe();FA=l.string().trim().min(1).max(240),J0=l.string().trim().min(1).max(800),Nn=l.string().trim().min(1).max(80).regex(/^[A-Za-z0-9_.:-]+$/),ea=l.string().trim().min(1).max(120),BA=l.union([l.string().max(500),l.number().finite(),l.boolean(),l.null()]),CS=l.record(Nn,BA),ZA=l.enum(["compact","currency","duration","integer","percent","raw"]),HA=l.object({title:FA,description:J0.optional(),footer:J0.optional()}).strip(),OS=l.object({dataKey:Nn,label:ea.optional(),axisLabel:ea.optional(),valueFormat:ZA.optional(),valuePrefix:l.string().trim().max(12).optional(),valueSuffix:l.string().trim().max(12).optional()}).strip(),DS=l.object({kind:l.literal("linear"),dataKey:Nn,label:ea.optional()}).strip(),q0=l.object({version:l.literal(1),meta:HA,fallbackMarkdown:l.string().trim().min(1).max(4e3)}).strip();WA=q0.extend({visualType:l.literal("chart"),chartType:l.enum(["bar","line","scatter"]),xKey:Nn,xAxisLabel:ea.optional(),series:l.array(OS).min(1).max(6),data:l.array(CS).min(1).max(120),layout:l.enum(["horizontal","vertical"]).optional(),stacking:l.enum(["grouped","stacked"]).optional(),trendLine:DS.optional()}).strip().superRefine((e,t)=>{e.stacking&&e.chartType!=="bar"&&t.addIssue({code:"custom",path:["stacking"],message:"Stacking is only supported for bar charts"}),e.trendLine&&e.chartType!=="line"&&e.chartType!=="scatter"&&t.addIssue({code:"custom",path:["trendLine"],message:"Trend lines are only supported for line and scatter charts"}),PS(e.data,[{path:["xKey"],value:e.xKey},...e.series.map((n,i)=>({path:["series",i,"dataKey"],value:n.dataKey})),...e.trendLine?[{path:["trendLine","dataKey"],value:e.trendLine.dataKey}]:[]],t),RS(e.data,[...e.series.map((n,i)=>({path:["series",i,"dataKey"],value:n.dataKey})),...e.trendLine?[{path:["trendLine","dataKey"],value:e.trendLine.dataKey}]:[]],t)}),GA=q0.extend({visualType:l.literal("chart"),chartType:l.literal("pie"),nameKey:Nn,valueKey:Nn,series:l.array(OS).max(1).optional(),data:l.array(CS).min(1).max(16)}).strip().superRefine((e,t)=>{PS(e.data,[{path:["nameKey"],value:e.nameKey},{path:["valueKey"],value:e.valueKey},...(e.series??[]).map((n,i)=>({path:["series",i,"dataKey"],value:n.dataKey}))],t),RS(e.data,[{path:["valueKey"],value:e.valueKey,nonnegative:!0}],t)}),JA=l.discriminatedUnion("chartType",[WA,GA]),qA=l.object({id:Nn,label:ea,detail:J0.optional(),kind:l.enum(["actor","agent","decision","event","input","output","system","task"]).optional()}).strip(),YA=l.object({from:Nn,to:Nn,label:ea.optional()}).strip(),XA=q0.extend({visualType:l.literal("diagram"),diagramType:l.enum(["flow","org","sequence","state"]),layout:l.enum(["auto","left-to-right","radial","top-to-bottom"]).default("auto"),nodes:l.array(qA).min(1).max(24),edges:l.array(YA).max(48)}).strip().superRefine((e,t)=>{let n=new Set(e.nodes.map(i=>i.id));for(let[i,r]of e.edges.entries())n.has(r.from)||t.addIssue({code:"custom",path:["edges",i,"from"],message:`Unknown node id "${r.from}"`}),n.has(r.to)||t.addIssue({code:"custom",path:["edges",i,"to"],message:`Unknown node id "${r.to}"`})}),td=l.union([JA,XA])});var nd,id,US,jS,LS,VS,FS,BS,ZS=O(()=>{"use strict";Oe();nd=l.object({type:l.enum(["user","agent","anonymous"]),id:l.string(),role:l.enum(["owner","requester","member"]),status:l.enum(["active","left","deleted"]),displayName:l.string().optional(),handle:l.string().optional(),avatarUrl:l.string().optional()}).strict(),id=l.object({messageId:l.string(),role:l.enum(["user","assistant","system"]),content:l.string(),sequence:l.string(),createdAt:l.string()}),US=l.object({conversationId:l.string(),orgId:l.string(),kind:l.enum(["direct","group"]),updatedAt:l.string(),viewerRole:l.enum(["owner","requester","member"]),participants:l.array(nd),lastMessage:id.nullable(),unreadCount:l.number().int().nonnegative(),latestSequence:l.string().nullable()}),jS=l.object({sequence:l.string().min(1)}),LS=l.object({turnId:l.string().min(1).optional()}).strict(),VS=l.object({cancelled:l.boolean(),cancelledTurnIds:l.array(l.string())}).strict(),FS=l.object({conversationId:l.string(),messageId:l.string(),sequence:l.string(),snippet:l.string(),createdAt:l.string(),participants:l.array(nd)}),BS=l.object({conversationId:l.string(),lastMessage:id.nullable(),unreadCount:l.number().int().nonnegative(),latestSequence:l.string().nullable()})});var $r,iC,oC,aC,HS,Y0,X0,KS,WS=O(()=>{"use strict";Oe();Ms();Kn();$r=l.preprocess(e=>e===void 0?null:e,l.string().nullable()),iC=l.preprocess(e=>e===void 0?null:e,kn.nullable()),oC=l.preprocess(e=>e===void 0?null:e,ti.nullable()),aC=l.preprocess(e=>e===void 0?null:e,l.enum(["user","assistant","system"]).nullable()),HS=l.preprocess(e=>e===void 0?0:e,l.number()),Y0=l.object({agentId:l.string(),handle:l.string(),name:l.string(),orgId:l.string(),orgName:$r,orgHandle:$r,ownerEmail:$r,ownerName:$r,state:iC,desiredStatus:oC,runtime:l.string(),imageVersion:$r,lastHealthyAt:$r,lastActiveAt:$r,lastUserMessageAt:$r,lastMessageAt:$r,lastMessageRole:aC,lastMessageChannel:$r,primaryChannel:$r,totalMessages:HS,totalSessions:HS,error:$r,appHandle:l.string(),flyAppExists:l.boolean(),plan:l.string(),billingStatus:l.string(),billingActive:l.boolean(),createdAt:l.string(),updatedAt:l.string()}),X0=l.object({running:l.number(),stopped:l.number(),error:l.number(),starting:l.number(),stopping:l.number(),unknown:l.number(),total:l.number()}),KS=l.object({agents:l.array(Y0),summary:X0,orphanedApps:l.array(l.string()),dailyMessages30d:l.array(l.number().int()).optional(),flyAppCount:l.number().optional(),latestVersion:l.string().optional(),latestVersions:l.record(l.string(),l.string()).optional()})});var JS=O(()=>{"use strict";Kn()});var ad,od,Ws,qS,Q0=O(()=>{"use strict";Oe();xn();ad=nu,od=wi,Ws=l.object({mediaId:l.string(),src:l.string(),alt:l.string().nullable().optional(),filename:l.string().optional(),displayName:l.string().nullable().optional(),mimeType:l.string().optional(),mediaType:od.optional(),type:od.optional(),size:l.number().optional(),width:l.number().nullable().optional(),height:l.number().nullable().optional(),duration:l.number().nullable().optional(),context:ad.nullable().optional(),blurhash:l.string().nullable().optional(),quality:l.string().optional(),status:l.string().optional(),userId:l.string().optional(),orgId:l.string().optional(),agentId:l.string().nullable().optional(),createdAt:l.string().optional(),updatedAt:l.string().optional()}),qS=l.object({file:l.string().describe("Binary file. multipart/form-data field \u2014 the actual upload. The server validates type + size and normalizes image uploads before storage. Audio/video/document uploads use the same uploader and are classified by MIME type."),context:ad.optional().default("general"),agentId:l.string().optional(),orgId:l.string().optional(),duration:l.number().optional()})});var sC,YS,XS,QS,eE,tE,rE,nE=O(()=>{"use strict";Oe();sC=l.object({mediaId:l.string().optional(),src:l.string().optional(),alt:l.string().optional(),width:l.number().optional(),height:l.number().optional(),mimeType:l.string().optional(),mediaType:l.string().optional(),blurhash:l.string().optional()}),YS=l.object({membershipId:l.string(),userId:l.string(),orgId:l.string(),email:l.string(),fullName:l.string().optional(),role:l.enum(["owner","admin","member","observer"]),status:l.enum(["active","suspended"]),joinedAt:l.string(),lastSeenAt:l.string().optional(),avatar:sC.optional()}),XS=l.object({invitationId:l.string(),email:l.string(),role:l.enum(["admin","member"]),status:l.string(),expiresAt:l.string(),createdAt:l.string()}),QS=l.object({token:l.string(),email:l.string(),orgId:l.string(),orgName:l.string(),orgInitial:l.string(),inviterName:l.string().optional(),inviterEmail:l.string(),role:l.enum(["owner","admin","member","observer"]),status:l.enum(["pending","accepted","expired","revoked"]),expiresAt:l.string(),memberCount:l.number().optional()}),eE=l.object({email:l.string().email(),role:l.enum(["admin","member"]).optional(),message:l.string().max(500).optional()}).strict(),tE=l.object({role:l.enum(["admin","member"])}).strict(),rE=l.object({token:l.string().min(1)}).strict()});var eb,tb,iE,oE=O(()=>{"use strict";Oe();xn();Ao();Ms();Kn();eb=l.enum(["planLimit","billingOverdue","rebuilding","agentNotFound"]),tb=l.enum(["rebuilding","provisioning","billingOverdue"]),iE=l.object({agentId:l.string(),name:l.string(),avatar:at.optional(),summary:l.string().nullable().optional(),ownerId:l.string(),ownerFirstName:l.string(),ownerAvatar:at.optional(),ownerLabel:l.string(),avatarInitial:l.string(),isYours:l.boolean(),lastMessageAt:l.string().datetime().nullable(),lastMessagePreview:l.string().nullable(),onboardedAt:l.string().datetime().nullable(),desiredStatus:ti.nullable(),lifecycle:kn,changedAt:l.string().datetime().optional(),detail:l.string().optional(),blocker:wn.optional(),canWake:l.boolean(),cantWakeReason:eb.optional(),canRebuild:l.boolean(),cantRebuildReason:tb.optional()})});var o9,a9,s9,l9,sE=O(()=>{"use strict";Oe();o9=l.object({deviceId:l.string().min(1).max(64),pushToken:l.string().min(1).max(200),appVersion:l.string().max(40).optional(),osVersion:l.string().max(40).optional(),model:l.string().max(80).optional()}),a9=l.object({deviceId:l.string().min(1).max(64)}),s9=l.object({deviceId:l.string().min(1).max(64),kind:l.string().min(1).max(30),action:l.enum(["displayed","tapped","dismissed"]),messageId:l.string().max(32).optional()}),l9=l.object({updated:l.boolean()})});var lE,cE,uE,dE=O(()=>{"use strict";Oe();Hu();Q0();Fs();lE=Ls.pick({orgId:!0,handle:!0,name:!0,email:!0,website:!0,avatarId:!0,coverId:!0,summary:!0,timezone:!0,isPersonal:!0,status:!0,updatedAt:!0}).extend({avatar:Ws.nullable().optional(),cover:Ws.nullable().optional()}),cE=l.object({name:l.string().min(1).max(255),handle:l.string().min(2).max(50).optional(),timezone:on.optional()}).strict(),uE=Ls.pick({name:!0,email:!0,website:!0,summary:!0,timezone:!0}).extend({name:l.string().min(1).max(255).optional(),email:l.preprocess(e=>e===""?null:e,l.string().email().nullable()).optional(),timezone:on.optional(),avatarMediaId:l.string().nullable().optional(),coverMediaId:l.string().nullable().optional()}).strict()});var pE,mE=O(()=>{"use strict";Oe();pE=l.object({messagesHandled:l.number().int().nonnegative(),proactiveRuns:l.number().int().nonnegative(),approvalsWaiting:l.number().int().nonnegative(),approvalConversationId:l.string().optional(),approvalAgentId:l.string().optional(),dailyHandled:l.array(l.number().int().nonnegative()).length(30),messagesByAssistant:l.array(l.object({agentId:l.string(),count:l.number().int().nonnegative()})),briefingsDelivered:l.number().int().nonnegative(),scheduledRuns:l.number().int().nonnegative(),prev30MessagesHandled:l.number().int().nonnegative(),prev30BriefingsDelivered:l.number().int().nonnegative(),prev30ScheduledRuns:l.number().int().nonnegative(),since:l.string()})});var rb,lC,cC,uC,fE,hE=O(()=>{"use strict";Oe();rb=l.enum(["success","info","warning"]),lC=l.object({orgId:l.string(),name:l.string(),avatarUrl:l.string().nullable()}),cC=l.object({key:l.string(),label:l.string(),tone:rb,status:l.string(),trialDaysRemaining:l.number().optional()}),uC=l.object({activeAgentLimit:l.number().int().nonnegative(),activeAgentCount:l.number().int().nonnegative(),agentCount:l.number().int().nonnegative()}),fE=l.object({org:lC,plan:cC,quota:uC,memberCount:l.number().int().nonnegative()})});var gE=O(()=>{"use strict"});var dC,pC,mC,fC,hC,vE,bE=O(()=>{"use strict";Oe();dC=l.object({sender:l.enum(["user","agent"]),text:l.string()}),pC=l.enum(["works-now","guided-setup","coming-soon","custom-workflow"]),mC=l.object({docsUrl:l.string(),verifiedAt:l.string(),version:l.string().optional(),versionPolicy:l.enum(["date-versioned","header-versioned","path-versioned","endpoint-versioned","unversioned"]),note:l.string().optional()}),fC=l.object({key:l.string(),label:l.string(),rank:l.number()}),hC=l.object({text:l.string(),tone:l.enum(["info","warning","success","danger"])}),vE=l.object({serviceKey:l.string(),name:l.string(),description:l.string(),shortDescription:l.string(),subtitle:l.string().optional(),icon:l.string().optional(),category:l.string(),categoryLabel:l.string(),categoryRank:l.number(),secondaryCategories:l.array(fC),badges:l.array(hC),tags:l.array(l.string()),searchAliases:l.array(l.string()),jtbd:l.string(),useCase:l.string(),demoScenario:l.string(),sampleConversation:l.array(dC),publicStatus:pC,apiVerification:mC.optional(),setupDifficulty:l.string(),risk:l.string(),price:l.string(),kind:l.string(),tier:l.string(),installLevel:l.enum(["agent","org","both"]),setupSummary:l.string().optional(),pagePath:l.string()})});var yE,xE=O(()=>{"use strict";Oe();Hu();yE=l.object({fullName:l.string().min(1).max(100).optional(),linkedinUsername:js.nullable().optional(),avatarMediaId:l.string().nullable().optional(),primaryAgentId:l.string().nullable().optional(),lastActiveOrgId:l.string().nullable().optional()}).strict()});var wE=O(()=>{"use strict";Ms();tS();nS();gS();_S();zS();K0();Wu();NS();Yu();AS();MS();ZS();Kn();Ku();WS();JS();Q0();nE();oE();sE();dE();mE();hE();gE();bE();Fs();xE();Bu()});var Gs=O(()=>{"use strict";Wb();Qc();r_();B$();Us();y0();Z$();H$();W$();G$();J$();Ao();uv();q$();Y$();wE()});function Sr(e,t){let n=Number(globalThis.process?.env?.PORT)||Ji.port;return e||(t?`http://localhost:${n}`:Ji.urls.app)}function CC(e,t,n){let i=Sr(e.apiBase,e.isDev);return async(r,o)=>{let a=Hn.getAuthToken(),s=new Headers(o?.headers);s.has("Content-Type")||s.set("Content-Type","application/json"),a&&!s.has("Authorization")&&s.set("Authorization",`Bearer ${a}`);let c=typeof r=="string"&&r.startsWith("/")?`${i}${r}`:r,u=await fetch(c,{...o,headers:s,credentials:"include"});if(n&&u.status===401&&(await u.clone().json().catch(()=>{}))?.code==="TOKEN_ERROR"&&n(),t){let d=u.json.bind(u);u.json=async()=>{let p=await d();return typeof p=="object"&&p&&"ok"in p&&("user"in p||"token"in p)&&t(p),p}}return u}}function Js(e){"@babel/helpers - typeof";return Js=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Js(e)}function PC(e,t){if(Js(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||"default");if(Js(i)!="object")return i;throw TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function RC(e){var t=PC(e,"string");return Js(t)=="symbol"?t:t+""}function Z(e,t,n){return(t=RC(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}async function ta(e,t){e.loading.value=!0,e.error.value=null;try{return await t()}finally{e.loading.value=!1}}function VC(e){let t=e.split(`
|
|
97
|
-
`).filter(r=>r.length>0),n,i;for(let r of t)r.startsWith("event:")?n=r.slice(6).trim():r.startsWith("data:")&&(i=r.slice(5).trim());if(!n||i===void 0)return null;try{let r=Qo.safeParse({event:n,data:JSON.parse(i)});return r.success?r.data:null}catch{return null}}function FC(e){return e.stage==="stream-open"&&e.message.startsWith("HTTP ")?`Stream failed: ${e.message}`:e.message}function BC(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function $E(e){if(!(e.role!=="assistant"&&e.role!=="system"))return{id:e.messageId,text:e.content,sender:e.role==="system"?"system":"agent",timestamp:e.createdAt,conversationId:e.conversationId,sequence:e.sequence,systemKind:e.systemKind,...e.metadata?.turnOutcome?{turnOutcome:e.metadata.turnOutcome}:{},...e.metadata?.attachments?.length?{attachments:e.metadata.attachments}:{},...e.metadata?.toolActivities?.length?{toolActivities:e.metadata.toolActivities}:{},...e.metadata?.issue?{issue:e.metadata.issue}:{}}}var kE,Rr,ri,_E,dd,OC,DC,nb,ra,sd,ld,cd,MC,UC,jC,LC,ZC,HC,KC,ud,qs,ib=O(()=>{"use strict";mn();Gs();zn();Rr=[],ri=0,_E=null,dd=4,OC=(kE=globalThis).nanostoresGlobal||(kE.nanostoresGlobal={epoch:0}),DC=()=>{for(ri=0;ri<Rr.length;ri+=dd)Rr[ri](Rr[ri+1].value,Rr[ri+2],Rr[ri+3]);Rr.length=0},nb=e=>{let t=[],n={get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(i){return n.lc=t.push(i),()=>{for(let o=ri+dd;o<Rr.length;)Rr[o]===i?Rr.splice(o,dd):o+=dd;let r=t.indexOf(i);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(i,r){OC.epoch++;let o=!Rr.length&&!0;for(let a of t)_E?.has(a)||(_E?.add(a),Rr.push(a,n,i,r));o&&DC()},off(){},set(i){let r=n.value;r!==i&&(n.value=i,n.notify(r))},subscribe(i){let r=n.listen(i);return i(n.value),r},value:e};return n};ra=globalThis,sd=ra.__PL_AUTH_USER__??(ra.__PL_AUTH_USER__=nb(void 0)),ld=ra.__PL_AUTH_TOKEN__??(ra.__PL_AUTH_TOKEN__=nb(null)),cd=ra.__PL_AUTH_DEVICE_ID__??(ra.__PL_AUTH_DEVICE_ID__=nb(null)),MC=class{constructor(){Z(this,"logger",yn("SDKStorage"))}isLocalStorageFunctional(){return typeof window<"u"&&typeof localStorage?.getItem=="function"&&typeof localStorage?.setItem=="function"&&typeof localStorage?.removeItem=="function"}syncWithGlobalStores(e){let{activeUser:t,token:n,deviceId:i}=e,r=sd.get(),o=ld.get(),a=cd.get();r&&(t.value=r),o&&(n.value=o),a&&(i.value=a),ut(t,s=>sd.set(s),{immediate:!0}),ut(n,s=>ld.set(s),{immediate:!0}),ut(i,s=>cd.set(s),{immediate:!0}),sd.subscribe(s=>{s!==t.value&&(t.value=s)}),ld.subscribe(s=>{s!==n.value&&(n.value=s)}),cd.subscribe(s=>{s!==i.value&&(i.value=s)})}loadFromStorage(e){if(typeof window>"u")return;let t=Hn.getAuthToken();t&&(e.token.value=t);let n=Hn.getDeviceId();if(n&&(e.deviceId.value=n),this.isLocalStorageFunctional())try{let i=localStorage.getItem("pagelines-user");i&&(e.activeUser.value=JSON.parse(i))}catch(i){this.logger.error("Failed to load user from localStorage",{data:i})}}saveToStorage(e){if(!(typeof window>"u")&&(e.token.value?Hn.setAuthToken(e.token.value):Hn.removeAuthToken(),this.isLocalStorageFunctional()))try{e.activeUser.value?localStorage.setItem("pagelines-user",JSON.stringify(e.activeUser.value)):localStorage.removeItem("pagelines-user")}catch(t){this.logger.error("Failed to save user to localStorage",{data:t})}}clearStorage(){if(!(typeof window>"u")){if(Hn.removeAuthToken(),this.isLocalStorageFunctional())try{localStorage.removeItem("pagelines-user")}catch(e){this.logger.error("Failed to clear user from localStorage",{data:e})}sd.set(void 0),ld.set(null),cd.set(null)}}getItem(e){if(!this.isLocalStorageFunctional())return null;try{return localStorage.getItem(e)}catch(t){return this.logger.error("Failed to get item from localStorage",{key:e,error:t}),null}}setItem(e,t){if(this.isLocalStorageFunctional())try{localStorage.setItem(e,t)}catch(n){this.logger.error("Failed to set item in localStorage",{key:e,error:n})}}},UC=class{constructor(e){Z(this,"ctx",void 0),this.ctx=e}async create(e){let t=e.orgId||this.resolveOrgId(),n=Sr(this.ctx.apiBase,this.ctx.isDev),i=await(await fetch(`${n}/api/agents`,{method:"POST",headers:{"Content-Type":"application/json",...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}},body:JSON.stringify({name:e.name,orgId:t})})).json();if(!i.ok||!i.data?.[0]){let r=i.error||"Failed to create agent";throw this.ctx.error.value=r,Error(r)}return this.ctx.processApiResponse(i),i.data[0]}async getLiveStatus(e){let t=Sr(this.ctx.apiBase,this.ctx.isDev);try{let n=await(await fetch(`${t}/api/agents/state?ids=${encodeURIComponent(e.agentId)}`,{headers:{...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}}})).json();return n.ok?n.data?.[e.agentId]??{lifecycle:"unknown"}:{lifecycle:"unknown"}}catch(n){return this.ctx.logger.warn("agent.getLiveStatus failed",{agentId:e.agentId,error:n instanceof Error?n.message:String(n)}),{lifecycle:"unknown"}}}async waitUntilReady(e){let{agentId:t,onStatus:n,timeoutMs:i=3e5,pollIntervalMs:r=3e3}=e,o=Date.now(),a;for(;Date.now()-o<i;){let s=await this.getLiveStatus({agentId:t});if(s.lifecycle==="running"){n?.("running");return}if(s.lifecycle==="error")throw Error(s.detail||"Your assistant hit a problem starting");s.lifecycle!==a&&(n?.(s.lifecycle),a=s.lifecycle),await new Promise(c=>setTimeout(c,r))}throw Error("Your assistant is taking longer than expected \u2014 please try again")}async webhook(e){let t=`${Sr(this.ctx.apiBase,this.ctx.isDev)}/api/bot-api/webhooks/agents/${e.agentId}`,n={type:e.type,data:e.data};e.meta&&(n.meta=e.meta);let i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){let r=await i.text().catch(()=>"Unknown error");throw Error(`Webhook delivery failed (${i.status}): ${r.slice(0,200)}`)}return i.json()}resolveOrgId(){let e=this.ctx.activeUser.value?.orgs?.[0]?.orgId;if(!e)throw Error("No organization found. Please sign in first.");return e}};jC=class{constructor(e){Z(this,"ctx",void 0),this.ctx=e}async sendCode(e){return ta(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/check-email",{method:"POST",body:JSON.stringify({email:e})})).json();if(!t.ok)throw this.ctx.error.value=t.error,Error(t.error)}catch(t){this.ctx.logger.error("Send code error",{data:t});let n=t instanceof Error?t.message:"Failed to send verification code";throw this.ctx.error.value=n,t}})}async verifyCode(e,t){return ta(this.ctx,async()=>{try{let n=await(await this.ctx.apiFetch("/api/auth/verify-code",{method:"POST",body:JSON.stringify({email:e,code:t})})).json();if(!n.ok)throw this.ctx.error.value=n.error,Error(n.error)}catch(n){this.ctx.logger.error("Verify code error",{data:n});let i=n instanceof Error?n.message:"Failed to verify code";throw this.ctx.error.value=i,n}})}async logout(){return ta(this.ctx,async()=>{try{await this.ctx.apiFetch("/api/auth/logout",{method:"POST"})}catch(e){this.ctx.logger.error("Logout error (user still logged out locally)",{data:e})}this.ctx.activeUser.value=void 0,this.ctx.token.value=null,this.ctx.storage.clearStorage()})}async getCurrentUser(){if(this.ctx.token.value)return ta(this.ctx,async()=>{try{let e=await(await this.ctx.apiFetch("/api/users/me",{method:"GET"})).json();if(!e.ok){this.ctx.error.value=e.error,e.error.includes("Authentication")&&(this.ctx.activeUser.value=void 0,this.ctx.token.value=null,this.ctx.storage.clearStorage());return}return this.ctx.token.value&&(this.ctx.activeUser.value=e.data),e.data}catch(e){this.ctx.logger.error("Get current user error",{data:e}),this.ctx.error.value=e instanceof Error?e.message:"Failed to get user info";return}})}async requestAuthCode(e){return ta(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/check-email",{method:"POST",body:JSON.stringify({email:e.email})})).json();return t.ok?(this.ctx.logger.info("Auth code requested successfully",{email:e.email}),!0):(this.ctx.error.value=t.error,this.ctx.logger.error("Failed to request auth code",{email:e.email,error:t.error}),!1)}catch(t){return this.ctx.logger.error("Request auth code error",{email:e.email,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Failed to request auth code",!1}})}async loginWithCode(e){return ta(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/verify-code",{method:"POST",body:JSON.stringify({email:e.email,code:e.code})})).json();return t.ok?(this.ctx.logger.info("Login successful",{email:e.email}),!0):(this.ctx.error.value=t.error,this.ctx.logger.error("Login failed",{email:e.email,error:t.error}),!1)}catch(t){return this.ctx.logger.error("Login with code error",{email:e.email,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Login failed",!1}})}loginWithGoogle(e){if(typeof window>"u"){this.ctx.logger.error("loginWithGoogle: Only available in browser");return}let t=Sr(this.ctx.apiBase,this.ctx.isDev),n=window.location.origin,i=`${t}/auth/google-popup?origin=${encodeURIComponent(n)}`,r=window.screenX+(window.outerWidth-500)/2,o=window.screenY+(window.outerHeight-600)/2,a=window.open(i,"google-auth",`width=500,height=600,left=${r},top=${o},popup=yes`);if(!a){let u="Popup was blocked. Please allow popups for this site.";this.ctx.error.value=u,e?.onError?.(u);return}let s=u=>{let d=new URL(t).origin;if(u.origin===d){if(u.data?.type==="auth-success"){window.removeEventListener("message",s);let{token:p,user:m}=u.data;this.ctx.processApiResponse({ok:!0,data:{},token:p,user:m}),this.ctx.logger.info("Google login successful"),e?.onSuccess?.(m)}else if(u.data?.type==="auth-error"){window.removeEventListener("message",s);let p=u.data.error||"Google authentication failed";this.ctx.error.value=p,this.ctx.logger.error("Google login failed",{error:p}),e?.onError?.(p)}}};window.addEventListener("message",s);let c=setInterval(()=>{a.closed&&(clearInterval(c),window.removeEventListener("message",s))},500)}},LC=class{constructor(e){Z(this,"ctx",void 0),this.ctx=e}async confirmCheckout(e){if(e?.sessionId){let t=Sr(this.ctx.apiBase,this.ctx.isDev),n=await(await fetch(`${t}/api/billing/complete-checkout`,{method:"POST",headers:{"Content-Type":"application/json",...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}},body:JSON.stringify({sessionId:e.sessionId})})).json();if(!n.ok){let i=n.error||"Failed to complete checkout";throw this.ctx.error.value=i,Error(i)}}return this.getStatus()}async getStatus(){let e=this.resolveOrgId(),t=Sr(this.ctx.apiBase,this.ctx.isDev),n=await(await fetch(`${t}/api/billing/details/${e}`,{headers:{...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}}})).json();if(!n.ok||!n.data)return{plan:void 0,status:"none",hasActiveBilling:!1,maxAgents:0};let i=["active","trial","canceling"].includes(n.data.status)||n.data.status==="past_due"&&n.data.paymentRecovery?.suspended!==!0;return{plan:n.data.plan,status:n.data.status,hasActiveBilling:i,maxAgents:n.data.maxAgents,...n.data.trialEnd&&{trialEnd:n.data.trialEnd},...n.data.trialDaysRemaining!==void 0&&{trialDaysRemaining:n.data.trialDaysRemaining},...n.data.paymentRecovery&&{paymentRecovery:n.data.paymentRecovery}}}resolveOrgId(){let e=this.ctx.activeUser.value?.orgs?.[0]?.orgId;if(!e)throw Error("No organization found. Please sign in first.");return e}};ZC=class{constructor(e){Z(this,"ctx",void 0),this.ctx=e}async cancelConversationTurn(e){let t=Sr(this.ctx.apiBase,this.ctx.isDev),n=this.ctx.token.value?{Authorization:`Bearer ${this.ctx.token.value}`}:{},i=await fetch(`${t}/api/conversations/${encodeURIComponent(e.conversationId)}/cancel`,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(e.turnId?{turnId:e.turnId}:{})}),r=await i.json();if(!r.ok)throw Error(r.error||`Cancel failed: HTTP ${i.status}`);return r.data}async chatStreamPublic(e){let t=`${Sr(this.ctx.apiBase,this.ctx.isDev)}/api/agents/public/${encodeURIComponent(e.handle)}/chat/v2/stream`,n="",i=!1,r=!1,o;try{let a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e.message,anonymousId:e.anonymousId,...e.attachments?.length?{attachments:e.attachments}:{},...e.context?{context:e.context}:{}})});if(!a.ok){let u=await a.json().catch(()=>({error:"Request failed"}));e.onError(u.error||`HTTP ${a.status}`);return}if(n=a.headers.get("X-Conversation-Id")||"",o=a.body?.getReader(),!o){e.onError("No response stream");return}let s=new TextDecoder,c="";e:for(;;){let{done:u,value:d}=await o.read();if(u)break;c+=s.decode(d,{stream:!0});let p=c.indexOf(`
|
|
97
|
+
`).filter(r=>r.length>0),n,i;for(let r of t)r.startsWith("event:")?n=r.slice(6).trim():r.startsWith("data:")&&(i=r.slice(5).trim());if(!n||i===void 0)return null;try{let r=Qo.safeParse({event:n,data:JSON.parse(i)});return r.success?r.data:null}catch{return null}}function FC(e){return e.stage==="stream-open"&&e.message.startsWith("HTTP ")?`Stream failed: ${e.message}`:e.message}function BC(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function $E(e){if(!(e.role!=="assistant"&&e.role!=="system"))return{id:e.messageId,text:e.content,sender:e.role==="system"?"system":"agent",timestamp:e.createdAt,conversationId:e.conversationId,sequence:e.sequence,systemKind:e.systemKind,...e.metadata?.turnOutcome?{turnOutcome:e.metadata.turnOutcome}:{},...e.metadata?.attachments?.length?{attachments:e.metadata.attachments}:{},...e.metadata?.toolActivities?.length?{toolActivities:e.metadata.toolActivities}:{},...e.metadata?.issue?{issue:e.metadata.issue}:{}}}var kE,Rr,ri,_E,dd,OC,DC,nb,ra,sd,ld,cd,MC,UC,jC,LC,ZC,HC,KC,ud,qs,ib=O(()=>{"use strict";mn();Gs();zn();Rr=[],ri=0,_E=null,dd=4,OC=(kE=globalThis).nanostoresGlobal||(kE.nanostoresGlobal={epoch:0}),DC=()=>{for(ri=0;ri<Rr.length;ri+=dd)Rr[ri](Rr[ri+1].value,Rr[ri+2],Rr[ri+3]);Rr.length=0},nb=e=>{let t=[],n={get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(i){return n.lc=t.push(i),()=>{for(let o=ri+dd;o<Rr.length;)Rr[o]===i?Rr.splice(o,dd):o+=dd;let r=t.indexOf(i);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(i,r){OC.epoch++;let o=!Rr.length&&!0;for(let a of t)_E?.has(a)||(_E?.add(a),Rr.push(a,n,i,r));o&&DC()},off(){},set(i){let r=n.value;r!==i&&(n.value=i,n.notify(r))},subscribe(i){let r=n.listen(i);return i(n.value),r},value:e};return n};ra=globalThis,sd=ra.__PL_AUTH_USER__??(ra.__PL_AUTH_USER__=nb(void 0)),ld=ra.__PL_AUTH_TOKEN__??(ra.__PL_AUTH_TOKEN__=nb(null)),cd=ra.__PL_AUTH_DEVICE_ID__??(ra.__PL_AUTH_DEVICE_ID__=nb(null)),MC=class{constructor(){Z(this,"logger",yn("SDKStorage"))}isLocalStorageFunctional(){return typeof window<"u"&&typeof localStorage?.getItem=="function"&&typeof localStorage?.setItem=="function"&&typeof localStorage?.removeItem=="function"}syncWithGlobalStores(e){let{activeUser:t,token:n,deviceId:i}=e,r=sd.get(),o=ld.get(),a=cd.get();r&&(t.value=r),o&&(n.value=o),a&&(i.value=a),ut(t,s=>sd.set(s),{immediate:!0}),ut(n,s=>ld.set(s),{immediate:!0}),ut(i,s=>cd.set(s),{immediate:!0}),sd.subscribe(s=>{s!==t.value&&(t.value=s)}),ld.subscribe(s=>{s!==n.value&&(n.value=s)}),cd.subscribe(s=>{s!==i.value&&(i.value=s)})}loadFromStorage(e){if(typeof window>"u")return;let t=Hn.getAuthToken();t&&(e.token.value=t);let n=Hn.getDeviceId();if(n&&(e.deviceId.value=n),this.isLocalStorageFunctional())try{let i=localStorage.getItem("pagelines-user");i&&(e.activeUser.value=JSON.parse(i))}catch(i){this.logger.error("Failed to load user from localStorage",{data:i})}}saveToStorage(e){if(!(typeof window>"u")&&(e.token.value?Hn.setAuthToken(e.token.value):Hn.removeAuthToken(),this.isLocalStorageFunctional()))try{e.activeUser.value?localStorage.setItem("pagelines-user",JSON.stringify(e.activeUser.value)):localStorage.removeItem("pagelines-user")}catch(t){this.logger.error("Failed to save user to localStorage",{data:t})}}clearStorage(){if(!(typeof window>"u")){if(Hn.removeAuthToken(),this.isLocalStorageFunctional())try{localStorage.removeItem("pagelines-user")}catch(e){this.logger.error("Failed to clear user from localStorage",{data:e})}sd.set(void 0),ld.set(null),cd.set(null)}}getItem(e){if(!this.isLocalStorageFunctional())return null;try{return localStorage.getItem(e)}catch(t){return this.logger.error("Failed to get item from localStorage",{key:e,error:t}),null}}setItem(e,t){if(this.isLocalStorageFunctional())try{localStorage.setItem(e,t)}catch(n){this.logger.error("Failed to set item in localStorage",{key:e,error:n})}}},UC=class{constructor(e){Z(this,"ctx",void 0),this.ctx=e}async create(e){let t=e.orgId||this.resolveOrgId(),n=Sr(this.ctx.apiBase,this.ctx.isDev),i=await(await fetch(`${n}/api/agents`,{method:"POST",headers:{"Content-Type":"application/json",...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}},body:JSON.stringify({name:e.name,orgId:t})})).json();if(!i.ok||!i.data?.[0]){let r=i.error||"Failed to create agent";throw this.ctx.error.value=r,Error(r)}return this.ctx.processApiResponse(i),i.data[0]}async getLiveStatus(e){let t=Sr(this.ctx.apiBase,this.ctx.isDev);try{let n=await(await fetch(`${t}/api/agents/state?ids=${encodeURIComponent(e.agentId)}`,{headers:{...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}}})).json();return n.ok?n.data?.[e.agentId]??{lifecycle:"unknown"}:{lifecycle:"unknown"}}catch(n){return this.ctx.logger.warn("agent.getLiveStatus failed",{agentId:e.agentId,error:n instanceof Error?n.message:String(n)}),{lifecycle:"unknown"}}}async waitUntilReady(e){let{agentId:t,onStatus:n,timeoutMs:i=3e5,pollIntervalMs:r=3e3}=e,o=Date.now(),a;for(;Date.now()-o<i;){let s=await this.getLiveStatus({agentId:t});if(s.lifecycle==="running"){n?.("running");return}if(s.lifecycle==="error")throw Error(s.detail||"Your assistant hit a problem starting");s.lifecycle!==a&&(n?.(s.lifecycle),a=s.lifecycle),await new Promise(c=>setTimeout(c,r))}throw Error("Your assistant is taking longer than expected \u2014 please try again")}async webhook(e){let t=`${Sr(this.ctx.apiBase,this.ctx.isDev)}/api/bot-api/webhooks/agents/${e.agentId}`,n={type:e.type,data:e.data};e.meta&&(n.meta=e.meta);let i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){let r=await i.text().catch(()=>"Unknown error");throw Error(`Webhook delivery failed (${i.status}): ${r.slice(0,200)}`)}return i.json()}resolveOrgId(){let e=this.ctx.activeUser.value?.orgs?.[0]?.orgId;if(!e)throw Error("No organization found. Please sign in first.");return e}};jC=class{constructor(e){Z(this,"ctx",void 0),this.ctx=e}async sendCode(e){return ta(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/check-email",{method:"POST",body:JSON.stringify({email:e})})).json();if(!t.ok)throw this.ctx.error.value=t.error,Error(t.error)}catch(t){this.ctx.logger.error("Send code error",{data:t});let n=t instanceof Error?t.message:"Failed to send verification code";throw this.ctx.error.value=n,t}})}async verifyCode(e,t){return ta(this.ctx,async()=>{try{let n=await(await this.ctx.apiFetch("/api/auth/verify-code",{method:"POST",body:JSON.stringify({email:e,code:t})})).json();if(!n.ok)throw this.ctx.error.value=n.error,Error(n.error)}catch(n){this.ctx.logger.error("Verify code error",{data:n});let i=n instanceof Error?n.message:"Failed to verify code";throw this.ctx.error.value=i,n}})}async logout(){return ta(this.ctx,async()=>{try{await this.ctx.apiFetch("/api/auth/logout",{method:"POST"})}catch(e){this.ctx.logger.error("Logout error (user still logged out locally)",{data:e})}this.ctx.activeUser.value=void 0,this.ctx.token.value=null,this.ctx.storage.clearStorage()})}async getCurrentUser(){if(this.ctx.token.value)return ta(this.ctx,async()=>{try{let e=await(await this.ctx.apiFetch("/api/users/me",{method:"GET"})).json();if(!e.ok){this.ctx.error.value=e.error,e.error.includes("Authentication")&&(this.ctx.activeUser.value=void 0,this.ctx.token.value=null,this.ctx.storage.clearStorage());return}return this.ctx.token.value&&(this.ctx.activeUser.value=e.data),e.data}catch(e){this.ctx.logger.error("Get current user error",{data:e}),this.ctx.error.value=e instanceof Error?e.message:"Failed to get user info";return}})}async requestAuthCode(e){return ta(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/check-email",{method:"POST",body:JSON.stringify({email:e.email})})).json();return t.ok?(this.ctx.logger.info("Auth code requested successfully",{email:e.email}),!0):(this.ctx.error.value=t.error,this.ctx.logger.error("Failed to request auth code",{email:e.email,error:t.error}),!1)}catch(t){return this.ctx.logger.error("Request auth code error",{email:e.email,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Failed to request auth code",!1}})}async loginWithCode(e){return ta(this.ctx,async()=>{try{let t=await(await this.ctx.apiFetch("/api/auth/verify-code",{method:"POST",body:JSON.stringify({email:e.email,code:e.code})})).json();return t.ok?(this.ctx.logger.info("Login successful",{email:e.email}),!0):(this.ctx.error.value=t.error,this.ctx.logger.error("Login failed",{email:e.email,error:t.error}),!1)}catch(t){return this.ctx.logger.error("Login with code error",{email:e.email,error:t}),this.ctx.error.value=t instanceof Error?t.message:"Login failed",!1}})}loginWithGoogle(e){if(typeof window>"u"){this.ctx.logger.error("loginWithGoogle: Only available in browser");return}let t=Sr(this.ctx.apiBase,this.ctx.isDev),n=window.location.origin,i=`${t}/auth/google-popup?origin=${encodeURIComponent(n)}`,r=window.screenX+(window.outerWidth-500)/2,o=window.screenY+(window.outerHeight-600)/2,a=window.open(i,"google-auth",`width=500,height=600,left=${r},top=${o},popup=yes`);if(!a){let u="Popup was blocked. Please allow popups for this site.";this.ctx.error.value=u,e?.onError?.(u);return}let s=async u=>{let d=new URL(t).origin;if(u.origin===d){if(u.data?.type==="auth-success"){window.removeEventListener("message",s);let{token:p}=u.data;this.ctx.processApiResponse({ok:!0,data:{},token:p});let m=await this.getCurrentUser();if(!m){let f="Signed in, but your account could not be loaded. Try again.";this.ctx.error.value=f,this.ctx.logger.error("Google login: token accepted but user hydration failed"),e?.onError?.(f);return}this.ctx.logger.info("Google login successful"),e?.onSuccess?.(m)}else if(u.data?.type==="auth-error"){window.removeEventListener("message",s);let p=u.data.error||"Google authentication failed";this.ctx.error.value=p,this.ctx.logger.error("Google login failed",{error:p}),e?.onError?.(p)}}};window.addEventListener("message",s);let c=setInterval(()=>{a.closed&&(clearInterval(c),window.removeEventListener("message",s))},500)}},LC=class{constructor(e){Z(this,"ctx",void 0),this.ctx=e}async confirmCheckout(e){if(e?.sessionId){let t=Sr(this.ctx.apiBase,this.ctx.isDev),n=await(await fetch(`${t}/api/billing/complete-checkout`,{method:"POST",headers:{"Content-Type":"application/json",...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}},body:JSON.stringify({sessionId:e.sessionId})})).json();if(!n.ok){let i=n.error||"Failed to complete checkout";throw this.ctx.error.value=i,Error(i)}}return this.getStatus()}async getStatus(){let e=this.resolveOrgId(),t=Sr(this.ctx.apiBase,this.ctx.isDev),n=await(await fetch(`${t}/api/billing/details/${e}`,{headers:{...this.ctx.token.value&&{Authorization:`Bearer ${this.ctx.token.value}`}}})).json();if(!n.ok||!n.data)return{plan:void 0,status:"none",hasActiveBilling:!1,maxAgents:0};let i=["active","trial","canceling"].includes(n.data.status)||n.data.status==="past_due"&&n.data.paymentRecovery?.suspended!==!0;return{plan:n.data.plan,status:n.data.status,hasActiveBilling:i,maxAgents:n.data.maxAgents,...n.data.trialEnd&&{trialEnd:n.data.trialEnd},...n.data.trialDaysRemaining!==void 0&&{trialDaysRemaining:n.data.trialDaysRemaining},...n.data.paymentRecovery&&{paymentRecovery:n.data.paymentRecovery}}}resolveOrgId(){let e=this.ctx.activeUser.value?.orgs?.[0]?.orgId;if(!e)throw Error("No organization found. Please sign in first.");return e}};ZC=class{constructor(e){Z(this,"ctx",void 0),this.ctx=e}async cancelConversationTurn(e){let t=Sr(this.ctx.apiBase,this.ctx.isDev),n=this.ctx.token.value?{Authorization:`Bearer ${this.ctx.token.value}`}:{},i=await fetch(`${t}/api/conversations/${encodeURIComponent(e.conversationId)}/cancel`,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(e.turnId?{turnId:e.turnId}:{})}),r=await i.json();if(!r.ok)throw Error(r.error||`Cancel failed: HTTP ${i.status}`);return r.data}async chatStreamPublic(e){let t=`${Sr(this.ctx.apiBase,this.ctx.isDev)}/api/agents/public/${encodeURIComponent(e.handle)}/chat/v2/stream`,n="",i=!1,r=!1,o;try{let a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e.message,anonymousId:e.anonymousId,...e.attachments?.length?{attachments:e.attachments}:{},...e.context?{context:e.context}:{}})});if(!a.ok){let u=await a.json().catch(()=>({error:"Request failed"}));e.onError(u.error||`HTTP ${a.status}`);return}if(n=a.headers.get("X-Conversation-Id")||"",o=a.body?.getReader(),!o){e.onError("No response stream");return}let s=new TextDecoder,c="";e:for(;;){let{done:u,value:d}=await o.read();if(u)break;c+=s.decode(d,{stream:!0});let p=c.indexOf(`
|
|
98
98
|
|
|
99
99
|
`);for(;p!==-1;){let m=c.slice(0,p);c=c.slice(p+2);let f=VC(m);if(f){if(f.event==="working_state")e.onStatus?.(f.data.description);else if(f.event==="tool_activity")e.onToolActivity?.(f.data);else if(f.event==="working_end")e.onWorkingEnd?.();else if(f.event==="message_delta")e.onDelta(f.data.delta,f.data.role);else if(f.event==="error"){i=!0,e.onError(Hs(f.data));break e}else if(f.event==="message"&&(f.data.message.role==="assistant"||f.data.message.role==="system")){r=!0;let $=$E(f.data.message);$&&e.onMessage?.($)}else if(f.event==="stream_end")break e}p=c.indexOf(`
|
|
100
100
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagelines/widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.836",
|
|
4
4
|
"description": "Embeddable PageLines agent widget for any website",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/widget.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"vue-tsc": "^3.3.8"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@pagelines/sdk": "1.0.
|
|
48
|
+
"@pagelines/sdk": "1.0.836"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"dev": "vite --config vite.config.widget.ts",
|