@pluno/product-agent-web 0.1.238 → 0.1.240
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/adapters/web/socketIOTransport.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +51 -37
- package/dist/product-agent-sdk.js +61 -43
- package/dist/product-agent-widget.js +26 -22
- package/dist/runtimeClient.d.ts +1 -0
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@ type Options = {
|
|
|
28
28
|
backendUrl: string;
|
|
29
29
|
auth: ProductAgentSocketAuth;
|
|
30
30
|
onReady: (ready: Ready) => void;
|
|
31
|
-
onDisconnect: (intentional: boolean) => void;
|
|
31
|
+
onDisconnect: (intentional: boolean, reason: string) => void;
|
|
32
32
|
onEvent: (name: string, event: unknown) => void;
|
|
33
33
|
onToolCall: (event: unknown) => boolean | Promise<boolean>;
|
|
34
34
|
onError: (error: ProductAgentSocketError) => void;
|
|
@@ -78,7 +78,7 @@ export declare class ProductAgentSocketIOTransport {
|
|
|
78
78
|
get connectionAttempt(): ProductAgentConnectionAttempt | null;
|
|
79
79
|
markReady(): void;
|
|
80
80
|
private restoreBackoff;
|
|
81
|
-
recover(): void;
|
|
81
|
+
recover(reason?: string): void;
|
|
82
82
|
private beginAttempt;
|
|
83
83
|
private clearReadinessTimers;
|
|
84
84
|
retain(sessionId: string, owner: string): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export declare const PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR = ".pluno-pa-widge
|
|
|
38
38
|
export declare const PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR = ".pluno-pa-widget__panel";
|
|
39
39
|
export declare const PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR = ".pluno-pa-widget__timeline";
|
|
40
40
|
export type ProductAgentMessage = {
|
|
41
|
+
provisional?: boolean;
|
|
41
42
|
id: string;
|
|
42
43
|
role: "user" | "assistant" | "tool" | "system";
|
|
43
44
|
phase?: "commentary" | "final_answer";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return{key:s,status:"not_requested",data:null,error:null,requestId:0,updatedAt:null}}class P{constructor(e,t,i=(n,r)=>r){this.loader=t,this.merge=i,this.state=g(e)}loader;merge;state;listeners=new Set;inFlight=null;trailingLoad=null;getState(){return this.state}subscribe(e){return this.listeners.add(e),e(this.state),()=>this.listeners.delete(e)}setKey(e){e!==this.state.key&&(this.state=g(e),this.trailingLoad=null,this.publish())}reset(){this.state=g(this.state.key),this.trailingLoad=null,this.publish()}invalidate(){this.state={...this.state,status:this.state.data===null?"not_requested":"ready",updatedAt:null},this.publish()}load(e="replace",t=null){return this.trailingLoad={mode:e,cursor:t},this.inFlight?this.inFlight:(this.inFlight=this.runLoads().finally(()=>{this.inFlight=null}),this.inFlight)}update(e){this.state={...this.state,data:e(this.state.data)},this.publish()}async runLoads(){for(;this.trailingLoad;){const e=this.trailingLoad;this.trailingLoad=null;const t=this.state.key,i=this.state.requestId+1;this.state={...this.state,status:e.mode==="append"?"loading_more":this.state.data===null?"loading":"refreshing",error:null,requestId:i},this.publish();try{const n=await this.loader({key:t,cursor:e.cursor});if(t!==this.state.key||i!==this.state.requestId)continue;this.state={...this.state,status:"ready",data:this.merge(this.state.data,n,e.mode),error:null,updatedAt:Date.now()},this.publish()}catch(n){if(t!==this.state.key||i!==this.state.requestId)continue;this.state={...this.state,status:"error",error:n instanceof Error?n.message:"The query failed."},this.publish()}}}publish(){for(const e of this.listeners)e(this.state)}}function f(s){const e={},t=[];for(const i of s.entities)e[i.id]||t.push(i.id),e[i.id]=i;return{entitiesById:e,ids:t,nextCursor:s.nextCursor}}function j(s,e,t){if(t==="replace"||s===null)return e;const i={...s.entitiesById,...e.entitiesById},n=[...s.ids];for(const r of e.ids)s.entitiesById[r]||n.push(r);return{entitiesById:i,ids:n,nextCursor:e.nextCursor}}function L(s){return s?s.ids.map(e=>s.entitiesById[e]).filter(e=>!!e):[]}function V(s){return s.visible?s.minimized?{state:"minimized"}:{state:s.open?"visible_open":"visible_closed"}:{state:"hidden"}}function J(s,e){return e==="limit_exceeded"?{allowed:!1,reason:"credits_exhausted",actions:["upgrade","earn_credits"]}:e==="subscription_required"||e==="subscription_inactive"||e==="payment_issue"||e==="subscription_invalid"||e==="payment_required"?{allowed:!1,reason:"payment_issue",actions:["upgrade"]}:s??{allowed:!0,reason:"allowed",actions:[]}}function W(s){if(!s||typeof s!="object")return!1;const e=s.paidCreditFallbackModel;return typeof e=="string"&&e.length>0}function Y(s){return s?s.submissionGate?.allowed===!1?{state:"action_required",reason:s.submissionGate.reason}:s.usingPaidCreditFallback===!0?{state:"paid_credit_fallback"}:s.creditLimit!==null&&s.creditLimit>0&&s.creditsRemaining!==null&&s.creditsRemaining>0&&s.creditsRemaining/s.creditLimit<=.2?{state:"low_credits"}:s.creditsUsed!==null?{state:"usage"}:{state:"hidden"}:{state:"hidden"}}function X(s){return s.submissionAllowed&&s.isAuthenticated&&s.hasWorkspace&&!s.isWebsiteBlocked&&s.isCurrentPageResolved&&!s.isSubmitting&&!s.hasPendingMessage}function ee(s){const e=s.hasDraftMessage||s.hasPreSubmittedAttachment;return s.hasRunningAssistantTurn&&!e?{action:"stop",disabled:!s.canStopRunningTurn}:{action:"send",disabled:!e||!s.canSubmitMessage}}const $="Pluno is reconnecting. Try again in a moment.";function U(s){return(s instanceof Error?s.message:s)===$}class te{constructor(e,t,i=20){this.loadPage=t,this.limit=i,this.recentQuery=new P(`${e}:recent`,async({cursor:n})=>f(await this.loadPage({cursor:n,limit:this.limit,pinned:!1}).then(r=>({entities:r.sessions,nextCursor:r.nextCursor}))),j),this.pinnedQuery=new P(`${e}:pinned`,async()=>f({entities:await this.loadAllPinned(),nextCursor:null})),this.recentQuery.subscribe(()=>this.publish()),this.pinnedQuery.subscribe(()=>this.publish())}loadPage;limit;recentQuery;pinnedQuery;listeners=new Set;optimisticEntities=new Map;activityOverrides=new Map;pinnedOverrides=new Map;titleOverrides=new Map;refreshSequence=0;completedRefreshSequence=0;activityReconciliationScheduled=!1;getState(){const e=this.recentQuery.getState(),t=this.pinnedQuery.getState(),i=[...m(t.data),...m(e.data)],n=new Map(i.map(d=>[d.id,d])),r=Array.from(n.values()).map(d=>this.applyOverrides(d,this.completedRefreshSequence)),o=Array.from(this.optimisticEntities.values()).filter(d=>!n.has(d.id)).reverse(),a=e.data||t.data||o.length>0?f({entities:[...o,...r],nextCursor:e.data?.nextCursor??null}):null;return{key:e.key.slice(0,-7),status:se(e,t),data:a,error:e.error??t.error,requestId:Math.max(e.requestId,t.requestId),updatedAt:Math.max(e.updatedAt??0,t.updatedAt??0)||null}}subscribe(e){return this.listeners.add(e),e(this.getState()),()=>this.listeners.delete(e)}getEntity(e){return this.getState().data?.entitiesById[e]??null}setKey(e){this.optimisticEntities.clear(),this.activityOverrides.clear(),this.pinnedOverrides.clear(),this.titleOverrides.clear(),this.refreshSequence=0,this.completedRefreshSequence=0,this.activityReconciliationScheduled=!1,this.recentQuery.setKey(`${e}:recent`),this.pinnedQuery.setKey(`${e}:pinned`)}refresh(){const e=++this.refreshSequence,t=Promise.all([this.recentQuery.load("replace"),this.pinnedQuery.load("replace")]).then(()=>{this.completedRefreshSequence=Math.max(this.completedRefreshSequence,e),this.reconcileDurableEntities()});return t.then(()=>{!this.hasUnconfirmedActivityOverride()||this.activityReconciliationScheduled||(this.activityReconciliationScheduled=!0,this.refresh().finally(()=>{this.activityReconciliationScheduled=!1}))}),t}loadMore(e){return this.recentQuery.load("append",e)}addOptimistic(e){this.optimisticEntities.set(e.id,e),this.updateProjection()}removeOptimistic(e){this.optimisticEntities.delete(e)&&this.updateProjection()}acknowledgeOptimistic(e,t){this.optimisticEntities.delete(e),this.optimisticEntities.set(t.id,t),this.updateProjection()}setActivity(e,t){this.activityOverrides.set(e,{isActive:t,confirmAfterRefresh:this.completedRefreshSequence+1,releaseAfterRefresh:this.completedRefreshSequence+2}),this.updateEntity(e,i=>({...i,isActive:t}))}setPinned(e,t){const i={pinned:t,confirmAfterRefresh:Number.POSITIVE_INFINITY};return this.pinnedOverrides.set(e,i),this.updateEntity(e,n=>({...n,isPinned:t})),i}confirmPinned(e,t){this.pinnedOverrides.get(e)===t&&(t.confirmAfterRefresh=this.completedRefreshSequence+1)}rollbackPinned(e,t,i){this.pinnedOverrides.get(e)===t&&(this.pinnedOverrides.delete(e),this.updateEntity(e,n=>({...n,isPinned:i})))}setTitle(e,t){this.titleOverrides.set(e,t),this.updateEntity(e,i=>({...i,customTitle:t}))}confirmTitle(e){this.titleOverrides.delete(e)}reconcileDurableEntities(){const e=[...m(this.pinnedQuery.getState().data),...m(this.recentQuery.getState().data)],t=new Set(e.map(i=>i.id));for(const i of this.optimisticEntities.keys())t.has(i)&&this.optimisticEntities.delete(i);for(const i of e)this.applyOverrides(i,this.completedRefreshSequence);this.publish()}async loadAllPinned(){const e=[];let t=null;do{const i=await this.loadPage({cursor:t,limit:this.limit,pinned:!0});e.push(...i.sessions),t=i.nextCursor}while(t);return e}applyOverrides(e,t){let i=e;const n=this.activityOverrides.get(e.id);n&&(t>=n.confirmAfterRefresh&&e.isActive===n.isActive?this.activityOverrides.delete(e.id):t>=n.releaseAfterRefresh?this.activityOverrides.delete(e.id):i={...i,isActive:n.isActive});const r=this.pinnedOverrides.get(e.id);return r&&(t>=r.confirmAfterRefresh&&e.isPinned===!0===r.pinned?this.pinnedOverrides.delete(e.id):i={...i,isPinned:r.pinned}),this.titleOverrides.has(e.id)&&(i={...i,customTitle:this.titleOverrides.get(e.id)??null}),i}updateProjection(){this.publish()}updateEntity(e,t){const i=this.optimisticEntities.get(e);i&&this.optimisticEntities.set(e,t(i)),this.publish()}hasUnconfirmedActivityOverride(){return Array.from(this.activityOverrides.values()).some(e=>this.completedRefreshSequence<e.releaseAfterRefresh)}publish(){for(const e of this.listeners)e(this.getState())}}function m(s){return s?s.ids.map(e=>s.entitiesById[e]).filter(e=>!!e):[]}function se(s,e){return s.status==="error"||e.status==="error"?"error":s.status==="loading"||e.status==="loading"?"loading":s.status==="refreshing"||e.status==="refreshing"?"refreshing":s.status==="loading_more"?"loading_more":s.status==="ready"||e.status==="ready"?"ready":"not_requested"}function R(s){const e=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?(?:Z|\+00:00)$/.exec(s);if(!e)throw new Error("Display timestamps must retain the backend UTC precision.");return`${e[1]}.${(e[2]??"").padEnd(6,"0")}`}function b(s){if(s===null||typeof s=="string"||typeof s=="boolean")return!0;if(typeof s=="number")return Number.isFinite(s);if(Array.isArray(s))return s.every(b);if(typeof s!="object")return!1;const e=Object.getPrototypeOf(s);return e!==Object.prototype&&e!==null?!1:Object.values(s).every(b)}function K(s){return s!==null&&typeof s=="object"&&!Object.isFrozen(s)&&(Object.values(s).forEach(K),Object.freeze(s)),s}function ie(s){if(!b(s))throw new Error("Conversation inputs must be JSON-safe values.");return JSON.parse(JSON.stringify(s))}function ne(s,e){if(!e)return!1;const t=s.executionByUserMessage[e];if(t)return["completed","stopped","failed"].includes(t.phase);const i=Object.values(s.items).sort((r,o)=>R(r.created_at).localeCompare(R(o.created_at))||r.id.localeCompare(o.id));let n=!1;for(const r of i)if(r.type==="user_message"&&(n=r.id===e),!!n&&(r.type==="stopped"||r.type==="error"||r.type==="final_response"&&s.streams[r.id]?.state==="finished"&&s.streams[r.id].revision>=r.data.revision))return!0;return!1}class re{constructor(e,t=null){this.storage=e,t&&(this.decisions=new Map(t.filter(T).map(i=>[this.getDecisionKey(i),i])),this.initialized=!0)}storage;conversationReader=null;sources=new Map;invalidateAuth=()=>{};installConversationSources(e,t=()=>{}){this.sources.clear(),this.conversationReader=e,this.invalidateAuth=t}receiveConversationSources(e){for(const t of e){if(!Number.isSafeInteger(t.version)||t.version<0)throw new Error("Invalid interaction source version.");const i=JSON.stringify([t.conversation_id,t.id]),n=this.sources.get(i);if(n&&n.version>=t.version)continue;if(n&&n.payload.kind!==t.payload.kind)throw new Error("Interaction kind changed.");const r=n?.payload.kind==="personal_channel"&&n.lifecycle==="completed"?"completed":t.lifecycle,o=n?.payload.kind==="sharing"&&t.payload.kind==="sharing"?{...t.payload,variant:n.payload.variant}:t.payload;this.sources.set(i,K(ie({...t,lifecycle:r,payload:o}))),t.payload.kind==="integration_auth"&&this.invalidateAuth(t.payload.request_id)}}getIntegrationSource(e){return[...this.sources.values()].find(t=>t.payload.kind==="integration_auth"&&t.payload.request_id===e&&this.conversationReader?.(t.conversation_id))??null}getConversationInputs(e){if(!this.conversationReader)return;const t={share:null,integrations:[],channel:null},i=e?this.conversationReader(e):null;if(!i)return t;const n=[...this.sources.values()].filter(r=>r.conversation_id===e).sort((r,o)=>r.version-o.version||r.id.localeCompare(o.id));for(const r of n){const o=r.payload;if(o.kind==="sharing"){if(t.share=null,!o.eligible||r.lifecycle!=="pending"||r.invocation!=="user"||!["main_web_chat","automation","extension_sidepanel","extension_widget"].includes(r.entry_surface??""))continue;const a=r.user_message_id?i.items[r.user_message_id]:null;t.share={revision:r.version,candidate:{id:r.id,variant:o.variant,userPrompt:a?.type==="user_message"?a.data.content:"",assistantAnswer:""},terminal:!o.wait_for_terminal||ne(i,r.user_message_id)}}else o.kind==="integration_auth"?t.integrations.push({revision:r.version,request:{type:"pipedream_auth_required",authRequestId:o.request_id,appSlug:o.app_slug,appName:o.app_name,appLogo:o.app_logo??void 0,expiresAt:o.expires_at},lifecycle:r.lifecycle==="pending"&&Date.parse(o.expires_at)<=Date.now()?"expired":r.lifecycle}):t.channel={revision:r.version,request:{type:"personal_channel_connection_required",requestId:o.request_id,channel:o.channel,managementUrl:o.management_url},lifecycle:r.lifecycle}}return t}decisions=new Map;scheduledEligibility=new Map;initialized=!1;actionQueue=Promise.resolve();async initialize(){if(this.initialized)return;const e=await this.storage.load();this.decisions=new Map(e.filter(T).map(t=>[this.getDecisionKey(t),t])),this.initialized=!0}isEligible(e,t=Date.now()){const i=this.scheduledEligibility.get(this.getExactKey(e));return i!==void 0&&i>t?!1:this.isDecisionEligible(this.decisions.get(this.getExactKey(e)),t)&&this.isDecisionEligible(this.decisions.get(this.getCategoryKey(e)),t)}getDecision(e){return this.decisions.get(this.getExactKey(e))??this.decisions.get(this.getCategoryKey(e))??null}getStatus(e,t=Date.now()){const i=this.scheduledEligibility.get(this.getExactKey(e));if(i!==void 0&&i>t)return"scheduled";const n=this.getDecision(e);return n?n.action==="never"||n.action==="dont_show_again"?"suppressed":n.action==="dismiss"?"resolved":n.nextEligibleAt&&Date.parse(n.nextEligibleAt)>t?"snoozed":"presentable":"presentable"}scheduleEligibility(e,t){const i=this.getExactKey(e),n=this.scheduledEligibility.get(i);return n!==void 0?n:(this.scheduledEligibility.set(i,t),t)}getNextEligibilityAt(e=Date.now()){const t=[...Array.from(this.scheduledEligibility.values()).filter(i=>i>e),...Array.from(this.decisions.values()).map(i=>i.nextEligibleAt?Date.parse(i.nextEligibleAt):Number.NaN).filter(i=>Number.isFinite(i)&&i>e)];return t.length>0?Math.min(...t):null}act(e,t,i={}){const n=this.actionQueue.then(()=>this.applyAction(e,t,i));return this.actionQueue=n.then(()=>{},()=>{}),n}async applyAction(e,t,i){if(!e.allowedActions.includes(t))throw new Error(`Interaction ${e.key} does not allow ${t}.`);if(!F(t))throw new Error(`Interaction action ${t} is not a persistence decision.`);const n=i.now??new Date,r={promptKey:e.key,category:e.category,action:t,scope:e.scope,decidedAt:n.toISOString(),nextEligibleAt:this.getNextEligibleAt(e,t,n,i.snoozeUntil)},o=t==="dont_show_again"?this.getCategoryKey(e):this.getExactKey(e),a=new Map(this.decisions);return a.set(o,r),await this.storage.save([...a.values()]),this.decisions=a,r}isDecisionEligible(e,t){return e?e.action==="dismiss"||e.action==="never"||e.action==="dont_show_again"?!1:!e.nextEligibleAt||Date.parse(e.nextEligibleAt)<=t:!0}getNextEligibleAt(e,t,i,n){if(t==="later")return new Date(i.getTime()+(e.laterDelayMs??3600*1e3)).toISOString();if(t==="snooze"){if(!n||n.getTime()<=i.getTime())throw new Error("Snooze requires a future next-eligible time.");return n.toISOString()}return null}getDecisionKey(e){const t=_(e.scope);return e.action==="dont_show_again"?`${t}:category:${e.category}`:`${t}:interaction:${e.promptKey}`}getExactKey(e){return`${_(e.scope)}:interaction:${e.key}`}getCategoryKey(e){return`${_(e.scope)}:category:${e.category}`}}function oe(s,e){return{load:async()=>z(s,e),save:async t=>s.setItem(e,JSON.stringify(t))}}function z(s,e){const t=s.getItem(e);if(!t)return[];const i=JSON.parse(t);return Array.isArray(i)?i.filter(T):[]}function _(s){return`${s.level}:${s.key}`}function F(s){return s==="dismiss"||s==="later"||s==="snooze"||s==="never"||s==="dont_show_again"}function T(s){if(!s||typeof s!="object")return!1;const e=s;return typeof e.promptKey=="string"&&typeof e.category=="string"&&typeof e.decidedAt=="string"&&(e.nextEligibleAt===null||typeof e.nextEligibleAt=="string")&&F(e.action)&&!!(e.scope&&typeof e.scope=="object"&&typeof e.scope.level=="string"&&typeof e.scope.key=="string")}const ae={working:"⏳",completed:"✅",failed:"❗",stopped:"⏹️"},de=/^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;function Q(s,e){if(!e)return I(s);const t=I(s),i=`${ae[e]} Pluno`;return t?`${i}: ${t}`:i}class ce{constructor(e){this.titleDocument=e}titleDocument;status=null;baseTitle="";lastAppliedTitle=null;stopObserving=null;liveStatusVersion=0;setStatus(e){this.liveStatusVersion+=1,this.applyStatus(e)}clear(){this.liveStatusVersion+=1,this.applyClear()}async syncStatus(e){const t=this.liveStatusVersion,i=await e();i===void 0||t!==this.liveStatusVersion||(i?this.applyStatus(i):this.applyClear())}applyStatus(e){const t=this.titleDocument.getTitle();t!==this.lastAppliedTitle&&(this.baseTitle=I(t)),this.status=e,this.stopObserving||(this.stopObserving=this.titleDocument.observeTitle(()=>this.handleTitleChanged())),this.applyTitle()}applyClear(){const e=this.titleDocument.getTitle(),t=this.lastAppliedTitle!==null&&e===this.lastAppliedTitle,i=this.lastAppliedTitle===null?I(e):e;this.status=null,this.lastAppliedTitle=null,this.stopObserving?.(),this.stopObserving=null,t?this.titleDocument.setTitle(this.baseTitle):i!==e&&this.titleDocument.setTitle(i)}handleTitleChanged(){!this.status||this.titleDocument.getTitle()===this.lastAppliedTitle||this.applyTitle()}applyTitle(){if(!this.status)return;const e=Q(this.baseTitle,this.status);this.lastAppliedTitle=e,this.titleDocument.getTitle()!==e&&this.titleDocument.setTitle(e)}}function le(s){return{getTitle:()=>s.title,setTitle:e=>{s.title=e},observeTitle:e=>{const t=new MutationObserver(e);return t.observe(s.head,{childList:!0,subtree:!0,characterData:!0}),()=>t.disconnect()}}}function I(s){return s.replace(de,"")}const p=s=>typeof s=="string"&&/^[a-zA-Z0-9:_.-]{1,160}$/.test(s)?s:null;function ue(s){if(!s||typeof s!="object")return!1;const e=s,t=n=>Number.isSafeInteger(n)&&n>=0,i=n=>n&&typeof n=="object"&&Object.keys(n).every(r=>["sequence","at","type","changed","generation","sessionId","scopeId","requestId","effectId","clientScopeId","reason","effectKind","eventType","itemCount","removedCount","projectionReady"].includes(r))&&t(n.sequence)&&t(n.at)&&p(n.type)!==null&&typeof n.changed=="boolean"&&[n.generation,n.itemCount,n.removedCount].every(r=>r===null||t(r))&&[n.sessionId,n.scopeId,n.requestId,n.effectId,n.clientScopeId,n.reason,n.effectKind,n.eventType].every(r=>r===null||p(r)!==null)&&(n.projectionReady===null||typeof n.projectionReady=="boolean");return Object.keys(e).every(n=>["ownerId","revision","dropped","lastIntent","lastSelection","transitions"].includes(n))&&p(e.ownerId)!==null&&t(e.revision)&&t(e.dropped)&&(e.lastIntent==null||i(e.lastIntent))&&(e.lastSelection===null||i(e.lastSelection))&&Array.isArray(e.transitions)&&e.transitions.length<=16&&e.transitions.every(i)}function B(s){if(!s||typeof s!="object")return!1;const e=s;return Object.keys(e).every(t=>["sessionId","episodeId","consecutiveFailures","transportCode","requestId","durationMs"].includes(t))&&typeof e.sessionId=="string"&&/^[a-zA-Z0-9:_-]{1,160}$/.test(e.sessionId)&&typeof e.episodeId=="string"&&/^[a-zA-Z0-9:_-]{1,500}$/.test(e.episodeId)&&(e.transportCode===void 0||typeof e.transportCode=="string"&&/^[a-z0-9_]{1,80}$/.test(e.transportCode))&&(e.requestId===void 0||typeof e.requestId=="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test(e.requestId))&&(e.durationMs===void 0||typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>=0)&&Number.isSafeInteger(e.consecutiveFailures)&&e.consecutiveFailures>=1}const q=["messageKeys","canonicalItemKeys","terminalResponseKeys","toolCallKeys","activeResponseKeys"],E=s=>typeof s=="string"&&/^[a-zA-Z0-9:_-]{1,160}$/.test(s),v=s=>s===null||E(s),pe=s=>typeof s=="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(s)&&Number.isFinite(Date.parse(s));function G(s){if(!s||typeof s!="object")return!1;const e=s;return Object.keys(s).every(t=>["sessionId","itemId","userMessageId","createdAt","runId","retryable"].includes(t))&&v(e.sessionId)&&E(e.itemId)&&v(e.userMessageId)&&(e.retryable===void 0||typeof e.retryable=="boolean")&&v(e.runId)&&(e.createdAt===null||pe(e.createdAt))}function he(s){if(!s||typeof s!="object")return!1;const e=s,t=i=>Number.isSafeInteger(i)&&i>=0;return Object.keys(e).every(i=>["capturedAt","selectionKey","userId","loading","draft","thinking","connected","hasError","phase","queryStatus","queryRequestId","queryUpdatedAt","renderSource","selectionFencePending","guardCreatedAt","owner"].includes(i))&&t(e.capturedAt)&&[e.queryUpdatedAt,e.guardCreatedAt].every(i=>i===null||t(i))&&[e.selectionKey,e.userId,e.phase,e.queryStatus,e.queryRequestId].every(i=>i===null||p(i)!==null)&&[e.loading,e.draft,e.thinking,e.connected,e.hasError,e.selectionFencePending].every(i=>typeof i=="boolean")&&["state","account","interactions","local","sidepanel_layout"].includes(e.renderSource)&&(e.owner===void 0||ue(e.owner))}function H(s){if(!s||typeof s!="object"||Object.keys(s).some(i=>i!=="before"&&i!=="current"))return!1;const e=i=>{if(!i||typeof i!="object")return!1;const n=i;return Object.keys(i).every(r=>[...q,"sessionId","runtimeItemCount","welcome","truncated","thinkingSequence","context"].includes(r))&&(n.context===void 0||he(n.context))&&(n.thinkingSequence===void 0||Array.isArray(n.thinkingSequence)&&n.thinkingSequence.length<=20&&n.thinkingSequence.every(r=>r==="user"||r==="thinking"))&&v(n.sessionId)&&Number.isSafeInteger(n.runtimeItemCount)&&n.runtimeItemCount>=0&&typeof n.welcome=="boolean"&&typeof n.truncated=="boolean"&&q.every(r=>Array.isArray(n[r])&&n[r].length<=20&&n[r].every(E))},t=s;return(t.before===null||e(t.before))&&e(t.current)}function ge(s){if(s.details!==void 0&&!b(s.details))throw new TypeError("Product Agent transported error details must be JSON-safe.");return{code:s.code,message:s.message,retryable:s.retryable,...s.details===void 0?{}:{details:s.details}}}function S(s,e="runtime_error"){const t=s!==null&&typeof s=="object"?s:null,i=typeof s=="string"?s:t&&"message"in t&&typeof t.message=="string"?t.message:"",n=t&&"code"in t&&typeof t.code=="string"&&t.code.trim()?t.code:e,r=t&&"details"in t?t.details:null,o=r&&typeof r=="object"?r:{},a={...typeof o.securitySettingsUrl=="string"?{securitySettingsUrl:o.securitySettingsUrl}:{},...typeof o.transportCode=="string"&&/^[a-z0-9_]{1,80}$/.test(o.transportCode)?{transportCode:o.transportCode}:{},...typeof o.requestId=="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test(o.requestId)?{requestId:o.requestId}:{},...typeof o.durationMs=="number"&&Number.isFinite(o.durationMs)&&o.durationMs>=0?{durationMs:o.durationMs}:{},...typeof o.successfulRequests=="number"&&Number.isSafeInteger(o.successfulRequests)&&o.successfulRequests>=0?{successfulRequests:o.successfulRequests}:{}};return ge({code:n,message:i.trim()&&i.trim()!=="[object Object]"?i:"The Product Agent operation failed. Try again.",retryable:!!(t&&"retryable"in t&&t.retryable===!0),...Object.keys(a).length?{details:a}:{}})}function Z(s){if(!s||typeof s!="object")return!1;const e=s,t=i=>Number.isSafeInteger(i)&&i>=0;return Object.keys(e).every(i=>["requestId","method","route","status","abortTrigger","owner","elapsedMs","attempt","category","responseHeadersMs","responseBodyMs","queryRequestId","ownerId","authorityGeneration","sessionId","release","upstreamRequestId","upstreamTraceId"].includes(i))&&p(e.requestId)!==null&&["GET","POST","PUT","PATCH","DELETE"].includes(e.method)&&["/api/product-agent/conversations/:sessionId/snapshot","/api/product-agent/:namespace/commands","/api/product-agent/:namespace/:operation"].includes(e.route)&&(e.status===null||t(e.status)&&e.status>=100&&e.status<=599)&&(e.abortTrigger===null||["deadline","transport_disposed","owner_disposed","authority_retired","observation_released","request_replaced","caller_cancelled","unexpected_abort"].includes(e.abortTrigger))&&["http_deadline","http_transport","conversation_query","browser","http_response"].includes(e.owner)&&(e.category===void 0||/^[a-z0-9_]{1,80}$/.test(e.category))&&[e.responseHeadersMs,e.responseBodyMs].every(i=>i==null||t(i))&&t(e.elapsedMs)&&t(e.attempt)&&e.attempt>=1&&e.attempt<=10&&[e.queryRequestId,e.ownerId,e.sessionId].every(i=>i===null||p(i)!==null)&&(e.authorityGeneration===null||t(e.authorityGeneration))&&typeof e.release=="string"&&/^[a-zA-Z0-9._-]{1,80}$/.test(e.release)&&[e.upstreamRequestId,e.upstreamTraceId].every(i=>i===null||typeof i=="string"&&/^[a-zA-Z0-9_:;=./-]{1,160}$/.test(i))}const fe=["submit","stop","staging_ipc","send_ipc","stop_ipc","attachment_transfer","tab_lookup","tab_recovery","session_recovery","conversation_scope","local_stage","view_publication","page_access","authentication","community","preferences","page_capture","session_tabs","context_ready","first_frame","checkpoint","command_http","http_authentication","http_request","receipt_http","attachment_upload","runtime_reading","runtime_stopping","runtime_progress","runtime_stopped","message_painted","reading_painted","stopping_painted","progress_painted","stopped_painted"],me=Math.random().toString(36).slice(2);let ye=0;const C=()=>`timing:${me}:${++ye}`,y=s=>typeof s=="string"&&/^[a-zA-Z0-9:_-]{1,160}$/.test(s);function M(s){if(!s||typeof s!="object")return!1;const e=s;return Object.keys(e).every(t=>["entrySurface","operation","layer","stage","status","spanId","requestId","clientMessageId","sessionId","occurredAt","durationMs"].includes(t))&&(e.entrySurface===void 0||["extension_sidepanel","extension_widget","main_web_chat","embedded_widget","embedded_custom_ui","automation","mcp","whatsapp"].includes(e.entrySurface))&&["send","stop"].includes(e.operation)&&["renderer","sdk","extension","http"].includes(e.layer)&&fe.includes(e.stage)&&["started","completed","failed","observed"].includes(e.status)&&y(e.spanId)&&y(e.requestId)&&(e.clientMessageId===null||y(e.clientMessageId))&&(e.sessionId===null||y(e.sessionId))&&typeof e.occurredAt=="string"&&e.occurredAt.length<=40&&Number.isFinite(Date.parse(e.occurredAt))&&Number.isSafeInteger(e.durationMs)&&e.durationMs>=0}function k(s,e){if(!s)return{mark:n=>{},measure:(n,r)=>r()};const t=performance.now(),i=(n,r,o,a)=>{const d={...e,stage:n,status:r,spanId:a,occurredAt:new Date().toISOString(),durationMs:Math.max(0,Math.round(performance.now()-o))};s&&M(d)&&Promise.resolve().then(()=>s(d)).catch(()=>{})};return{mark:n=>i(n,"observed",t,C()),measure(n,r){const o=performance.now(),a=C();return i(n,"started",o,a),r().then(d=>(i(n,"completed",o,a),d),d=>{throw i(n,"failed",o,a),d})}}}const A=s=>s===null||typeof s=="string"&&/^[a-zA-Z0-9:_-]{1,160}$/.test(s);function ve(s){if(!s||typeof s!="object")return!1;const e=s;return typeof e.observedAt=="string"&&e.observedAt.length<=40&&Number.isFinite(Date.parse(e.observedAt))&&A(e.sessionId)&&A(e.responseItemId)&&A(e.respondsToUserMessageId)&&typeof e.panelVisible=="boolean"&&typeof e.documentVisible=="boolean"&&typeof e.loading=="boolean"}const D=500;function be(s){const e=s.replace(/\n\s*at\s[\s\S]*$/,"").replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g,"[REDACTED]").replace(/\b(?:set-cookie|cookie)\s*[:=]\s*[^\n]+/gi,"cookie=[REDACTED]").replace(/\bdata:[^\s<>"']+/gi,"[DATA]").replace(/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi,"[URL]").replace(/\b(?:Bearer|Basic)\s+[^\s,;"']+/gi,"[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?/g,"[REDACTED]").replace(/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp)[-_][A-Za-z0-9_-]{8,}/g,"[REDACTED]").replace(/\b((?:access|refresh|id|auth)[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|pwd|secret|token|jwt|authorization|cookie|set-cookie)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;}&]+)/gi,"$1=[REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,"[EMAIL]").replace(/(?:[A-Z]:[\\/]|\\\\|(?:~|\.\.?)?\/|[\w.-]+[\\/])[^\s<>"']+/gi,"[FILE]").replace(new RegExp("(?<![\\w.])(?:[\\w.-]+\\.[A-Z][A-Z0-9]{0,15}|\\.[A-Z][\\w.-]*)\\b","gi"),"[FILE]").replace(/\s+/g," ").trim();return e.length>D?`${e.slice(0,D-1)}…`:e}function Ie(s,e,t="stopped",i){const n=new Set(i??[s.assistantDraftRespondsToUserMessageId,s.activeResponseUserMessageId,s.messages.filter(a=>a.role==="user").slice(-1)[0]?.id].filter(a=>!!a)),r=s.messages.filter(a=>!(a.dataType==="run_status"&&a.loading&&n.has(a.respondsToUserMessageId??""))).map(a=>n.has(a.respondsToUserMessageId??"")?{...a,loading:!1}:a);for(const a of n)r.some(d=>d.respondsToUserMessageId===a&&(d.dataType==="run_status"||d.dataType==="run_error"||d.role==="assistant"&&d.phase!=="commentary"))||r.some(d=>d.role==="user"&&d.id===a)&&r.push({id:`local-interrupted:${a}`,role:"system",dataType:"run_status",content:t==="stopping"?"Stopping…":"Run stopped by user.",createdAt:e,respondsToUserMessageId:a});const o=s.segments?.map(a=>({...a,outcomeIds:[...a.outcomeIds,...r.filter(d=>d.id===`local-interrupted:${a.userMessageId}`&&!a.outcomeIds.includes(d.id)).map(d=>d.id)]}));return{...s,messages:r,isThinking:!1,isRetrying:!1,pendingMessageStatus:null,turnPhase:null,segments:o,activity:{phase:t,activeItemId:null},isLoadingSession:s.isLoadingSession&&r.length===0,taskStatus:t==="stopped"?"stopped":null,lastError:null,lastErrorCode:null}}const _e={"stop-without-rendered-message":"Stop is enabled while no message is rendered or the welcome screen is still visible.","in-progress-stop-unavailable":"An in-progress response has no visible enabled interrupt control.","stop-did-not-interrupt":"The stopped response remained in progress after an interrupt click.","duplicate-message-item":"A canonical message rendered more than once.","duplicate-canonical-item":"A canonical session item rendered more than once.","duplicate-tool-call":"A tool call rendered more than once.","duplicate-attachment":"An attachment rendered more than once.","duplicate-terminal-outcome":"A response rendered more than one terminal outcome.","foreign-session-item-visible":"The visible transcript contains state owned by another session.","terminal-response-reactivated":"A terminal response became active again.","terminal-history-not-append-only":"An established terminal outcome disappeared or changed order.","runtime-transcript-not-rendered":"A nonempty runtime transcript is displaying starter prompts.","thinking-groups-without-user-message":"Multiple thinking groups appeared without a user message between them.","thinking-without-progress":"Thinking remained visible without progress for five minutes."};function Se(s){return typeof s=="string"&&s.startsWith("ui_invariant:")&&Object.prototype.hasOwnProperty.call(_e,s.slice(13))}function x(s){return{...s.id===void 0?{}:{id:s.id},name:s.name,mimeType:s.mimeType,sizeBytes:s.sizeBytes,...s.sandboxPath===void 0?{}:{sandboxPath:s.sandboxPath},...s.storageKey===void 0?{}:{storageKey:s.storageKey},...s.fileUrl===void 0?{}:{fileUrl:s.fileUrl}}}function Ae(s){if(!s||typeof s!="object"||!("type"in s))return!1;const e=s;switch(e.type){case"runtime.connect":case"session.new":case"run.retry":return!0;case"run.stop":return e.clientMessageIds===void 0||Array.isArray(e.clientMessageIds)&&e.clientMessageIds.length<=100&&e.clientMessageIds.every(t=>typeof t=="string"&&t.length>0&&t.length<=160);case"runtime.report_response_visibility":return ve(e.observation);case"runtime.warmup":return e.reason==="panel_open"||e.reason==="extension_install"||e.reason==="composer_input";case"runtime.report_operation_timing":return M(e.timing);case"runtime.report_displayed_error":return(e.httpRequest===void 0||Z(e.httpRequest))&&(e.historyRefreshFailure===void 0||B(e.historyRefreshFailure))&&(e.renderedError===void 0||G(e.renderedError))&&(e.reason==="conversation_error"||e.reason==="attachment_error"||e.reason==="history_error"||e.reason==="action_error")&&typeof e.errorFingerprint=="string"&&/^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint)&&(e.displayedMessage===void 0||typeof e.displayedMessage=="string"&&e.displayedMessage.length<=500);case"runtime.report_invalid_state_transition":return(e.uiInvariant===void 0||H(e.uiInvariant))&&(e.reason==="submitted_turn_returned_to_welcome_without_new_chat"||e.reason==="new_messages_button_without_user_scroll"||Se(e.reason))&&(e.clientMessageId===void 0||typeof e.clientMessageId=="string");case"runtime.widget_lifecycle":return(e.action==="opened"||e.action==="closed"||e.action==="minimized")&&typeof e.trigger=="string";case"session.load":return typeof e.sessionId=="string"&&e.sessionId.length>0;case"session.list":return(e.cursor===void 0||e.cursor===null||typeof e.cursor=="string")&&(e.limit===void 0||typeof e.limit=="number")&&(e.pinned===void 0||typeof e.pinned=="boolean");case"composer.select_model":case"session.set_model":return typeof e.model=="string";case"session.pin":return typeof e.sessionId=="string"&&typeof e.pinned=="boolean";case"session.rename":return typeof e.sessionId=="string"&&typeof e.title=="string";case"interaction.act":return typeof e.interactionId=="string"&&typeof e.action=="string"&&typeof e.expectedRevision=="number";case"conversation.stage_proactive_suggestion":return typeof e.question=="string"&&typeof e.clientMessageId=="string";case"conversation.stage":return typeof e.content=="string"&&typeof e.clientMessageId=="string"&&(e.submittedAt===void 0||typeof e.submittedAt=="number")&&(e.requestedModel===void 0||typeof e.requestedModel=="string")&&(e.attachments===void 0||Array.isArray(e.attachments));case"conversation.fail_staged":return typeof e.clientMessageId=="string"&&typeof e.message=="string";case"conversation.send":return typeof e.content=="string"&&typeof e.clientMessageId=="string"&&(e.requestedModel===void 0||typeof e.requestedModel=="string")&&(e.automationOnboarding===void 0||typeof e.automationOnboarding=="boolean")&&(e.attachments===void 0||Array.isArray(e.attachments));default:return!1}}class we{constructor(e,t,i){this.adapter=t,this.state=w(e),this.model=i}adapter;listeners={};attachmentFiles=new Map;sessionHistoryListeners=new Set;interactionListeners=new Set;accountListeners=new Set;state;sessionHistoryState=g("unavailable");model;interactions=[];account=null;stagedProactiveSuggestionClientMessageId=null;pendingTransfers=new Map;submissionPreviews=new Map;submissionGeneration=0;pendingStop=null;stopError=null;operationQueue=Promise.resolve();destroyed=!1;on(e,t){const i=this.listeners[e]??new Set;return i.add(t),this.listeners[e]=i,()=>i.delete(t)}getState(){const e=w(this.state);for(const[t,i]of this.submissionPreviews)e.messages.some(n=>n.id===t)||(e.messages.push({...i.message,attachments:i.message.attachments?.map(n=>({...n}))}),e.segments&&(e.segments=[...e.segments,{id:t,userMessageId:t,activityIds:[],outcomeIds:[],collapsed:!1}]),e.isLoadingSession=!1,i.pending&&(e.activeResponseUserMessageId=t,e.pendingMessageStatus="sending",e.turnPhase="sending",e.activity={phase:"submitting",activeItemId:null}),i.error&&(e.lastError=i.error,e.lastErrorCode="message_delivery_failed"));return this.stopError&&(e.lastError=this.stopError,e.lastErrorCode="stop_failed"),this.pendingStop?Ie(e,"","stopping",this.pendingStop.userMessageIds):e}updateProjection(e,t,i,n,r){if(this.destroyed)return;const o=this.getState();(o.user?.id!==e.user?.id||o.selectionKey!==void 0&&o.selectionKey!==e.selectionKey||o.selectionKey===void 0&&o.sessionId!==null&&o.sessionId!==e.sessionId)&&(this.cancelPendingSubmissions(),this.submissionPreviews.clear());for(const a of e.messages)a.role==="user"&&this.submissionPreviews.delete(a.id);if(this.state=w(e),o.user?.id===e.user?.id)for(const a of this.state.messages){if(a.role!=="user"||!a.attachments?.length)continue;const d=o.messages.find(c=>c.role==="user"&&c.id===a.id);o.sessionId!==e.sessionId&&!(o.sessionId===null&&d)||(a.attachments=Pe(d?.attachments,a.attachments))}if(t!==void 0&&(this.model=t),i&&JSON.stringify(i)!==JSON.stringify(this.sessionHistoryState)){this.sessionHistoryState=N(i);for(const a of this.sessionHistoryListeners)a(this.getSessionHistoryState())}if(n&&JSON.stringify(n)!==JSON.stringify(this.interactions)){this.interactions=n.map(a=>({...a}));for(const a of this.interactionListeners)a(this.getInteractions())}if(r!==void 0&&JSON.stringify(r)!==JSON.stringify(this.account)){this.account=r?{...r}:null;for(const a of this.accountListeners)a(this.getAccount())}this.emit("state",this.getState())}async connect(){await this.dispatch({type:"runtime.connect"})}destroy(){if(!this.destroyed){this.destroyed=!0,this.pendingStop=null,this.pendingTransfers.clear(),this.submissionPreviews.clear(),this.attachmentFiles.clear(),this.sessionHistoryListeners.clear(),this.interactionListeners.clear(),this.accountListeners.clear();for(const e of Object.values(this.listeners))e?.clear();this.adapter.onDisconnect?.()}}warmup(e="panel_open"){return this.adapter.dispatch({type:"runtime.warmup",reason:e}).then(()=>{})}recordWidgetLifecycle(e,t){this.dispatch({type:"runtime.widget_lifecycle",action:e,trigger:t})}reportOperationTiming(e){!this.destroyed&&M(e)&&this.adapter.dispatch({type:"runtime.report_operation_timing",timing:e}).catch(()=>{})}reportResponseVisibility(e){this.adapter.dispatch({type:"runtime.report_response_visibility",observation:e}).catch(()=>{})}reportInvalidStateTransition(e,t,i){i!==void 0&&!H(i)||this.adapter.dispatch({type:"runtime.report_invalid_state_transition",reason:e,clientMessageId:t,...i?{uiInvariant:i}:{}}).catch(()=>{})}reportDisplayedError(e,t,i,n,r){const o=e==="conversation_error"&&!n?this.getState().conversationDiagnostics?.httpRequest:void 0;n!==void 0&&!G(n)||r!==void 0&&!B(r)||this.adapter.dispatch({type:"runtime.report_displayed_error",reason:e,errorFingerprint:t,...n?{renderedError:n}:{},...r?{historyRefreshFailure:r}:{},...Z(o)?{httpRequest:o}:{},...i?{displayedMessage:be(i)}:{}}).catch(()=>{})}sendMessage(e,t={}){const i=e.trim(),n=t.attachments??[];if(!i&&n.length===0)return Promise.resolve(null);this.pendingStop=null,this.stopError=null;const r=t.clientMessageId??(t.proactiveSuggestionQuestion&&this.stagedProactiveSuggestionClientMessageId?this.stagedProactiveSuggestionClientMessageId:crypto.randomUUID()),o=t.submittedAt??Date.now(),a=this.submissionGeneration;this.pendingTransfers.set(r,n.flatMap(c=>c.id?[c.id]:[])),this.submissionPreviews.set(r,{pending:!0,message:{id:r,role:"user",content:i,createdAt:"",attachments:n.map(c=>({...c}))}});const d=this.sendMessageNow(i,{...t,clientMessageId:r,submittedAt:o},a);return this.emit("state",this.getState()),d.finally(()=>{this.pendingTransfers.delete(r)})}async sendMessageNow(e,t,i){const n=e,r=t.clientMessageId,o=k(c=>{i===this.submissionGeneration&&this.reportOperationTiming(c)},{operation:"send",layer:"renderer",requestId:r,clientMessageId:r,sessionId:this.state.sessionId});o.mark("submit");let a=t.attachments??[],d=!1;if(i!==this.submissionGeneration)return null;try{if(!await o.measure("staging_ipc",async()=>{const l=await this.enqueueOperation(async()=>this.destroyed||i!==this.submissionGeneration?null:{result:this.adapter.dispatch({type:"conversation.stage",initiatedBy:t.initiatedBy,invocation:t.invocation,automationOnboarding:t.automationOnboarding,content:n,clientMessageId:r,proactiveSuggestionQuestion:t.proactiveSuggestionQuestion,attachments:a.length>0?a.map(x):void 0,submittedAt:t.submittedAt})});return l?(await l.result,l):null})||i!==this.submissionGeneration)return null;if(d=!0,a.length>0){if(!this.adapter.uploadAttachment)throw new Error("The runtime does not support attachments.");const l=[];for(const u of a){if(u.sandboxPath||u.storageKey){l.push(u);continue}const O=u.id?this.attachmentFiles.get(u.id):void 0;if(!O)throw new Error(`Attachment bytes are unavailable for ${u.name}`);if(l.push(await o.measure("attachment_transfer",()=>this.adapter.uploadAttachment(O,u,{clientMessageId:r}))),i!==this.submissionGeneration)return null}a=l}const h=await o.measure("send_ipc",()=>this.adapter.dispatch({type:"conversation.send",content:n,clientMessageId:r,initiatedBy:t.initiatedBy,invocation:t.invocation,proactiveSuggestionQuestion:t.proactiveSuggestionQuestion,...t.automationOnboarding?{automationOnboarding:!0}:{},attachments:a.length>0?a.map(x):void 0}));if(i!==this.submissionGeneration)return null;for(const l of t.attachments??[])l.id&&this.attachmentFiles.delete(l.id);return r===this.stagedProactiveSuggestionClientMessageId&&(this.stagedProactiveSuggestionClientMessageId=null),h?.clientMessageId??r}catch(c){if(i!==this.submissionGeneration)return null;if(U(c))for(const l of t.attachments??[])l.id&&this.attachmentFiles.delete(l.id);const h=this.submissionPreviews.get(r);throw h&&(h.pending=!1,h.error=S(c).message,this.emit("state",this.getState())),d&&await this.adapter.dispatch({type:"conversation.fail_staged",clientMessageId:r,message:S(c).message}),c}}getModel(){return this.model}setModel(e){return this.dispatch({type:"session.set_model",model:e}).then(()=>{})}retryLastMessage(){return this.dispatch({type:"run.retry"}),!0}createLocalAttachment(e){const t=crypto.randomUUID();return this.attachmentFiles.set(t,e),{id:t,name:e.name||"attachment",mimeType:e.type||"application/octet-stream",sizeBytes:e.size}}stop(){if(this.pendingStop)return this.pendingStop.promise;const e=this.getState(),t=this.cancelPendingSubmissions(),i=[...new Set([...t,e.activeResponseUserMessageId,e.messages.filter(a=>a.role==="user").slice(-1)[0]?.id].filter(a=>!!a))],n=k(a=>this.reportOperationTiming(a),{operation:"stop",layer:"renderer",requestId:crypto.randomUUID(),clientMessageId:i[0]??null,sessionId:e.sessionId});n.mark("stop");const r={userMessageIds:i,promise:Promise.resolve()};this.pendingStop=r,r.promise=n.measure("stop_ipc",()=>this.adapter.dispatch({type:"run.stop",...t.length?{clientMessageIds:t}:{}})).then(()=>{},a=>{this.pendingStop===r&&(this.stopError=S(a).message)}).finally(()=>{this.pendingStop===r&&(this.pendingStop=null,this.emit("state",this.getState()))}),this.emit("state",this.getState());const o=r.promise;return this.operationQueue=o.then(()=>{},()=>{}),o.then(()=>{})}cancelPendingSubmissions(){this.pendingStop=null,this.stopError=null;const e=[...this.pendingTransfers.keys()];this.submissionGeneration++;for(const t of this.pendingTransfers.values())for(const i of t)this.attachmentFiles.delete(i);this.pendingTransfers.clear();for(const t of this.submissionPreviews.values())t.pending=!1;return this.operationQueue=Promise.resolve(),e}startNewSession(e={}){return this.cancelPendingSubmissions(),this.submissionPreviews.clear(),this.emit("state",this.getState()),e.notifyTransport===!1?Promise.resolve():this.dispatch({type:"session.new"}).then(()=>{})}async listSessions(e={}){const t=await this.dispatch({type:"session.list",...e});if(t===void 0){const i=this.getSessionHistoryState().data;return{sessions:i?i.ids.map(n=>i.entitiesById[n]):[],nextCursor:i?.nextCursor??null}}if(!t?.sessionHistoryPage)throw new Error("Session list command did not return a page.");return t.sessionHistoryPage}getSessionHistoryState(){return N(this.sessionHistoryState)}subscribeSessionHistory(e){return this.sessionHistoryListeners.add(e),e(this.getSessionHistoryState()),()=>this.sessionHistoryListeners.delete(e)}refreshSessionHistory(){return this.dispatch({type:"session.list",limit:20}).then(()=>{})}loadMoreSessionHistory(){const e=this.sessionHistoryState.data?.nextCursor??null;return e?this.dispatch({type:"session.list",cursor:e}).then(()=>{}):Promise.resolve()}setSessionPinned(e,t){return this.dispatch({type:"session.pin",sessionId:e,pinned:t}).then(()=>{})}renameSession(e,t){return this.dispatch({type:"session.rename",sessionId:e,title:t}).then(()=>{})}getInteractions(){return this.interactions.map(e=>({...e}))}subscribeInteractions(e){return this.interactionListeners.add(e),e(this.getInteractions()),()=>this.interactionListeners.delete(e)}actOnInteraction(e,t,i,n={}){return this.dispatch({type:"interaction.act",interactionId:e,action:t,expectedRevision:i,...n}).then(()=>{})}getAccount(){return this.account?{...this.account}:null}subscribeAccount(e){return this.accountListeners.add(e),e(this.getAccount()),()=>this.accountListeners.delete(e)}refreshAccount(){return Promise.resolve()}loadSession(e){return this.cancelPendingSubmissions(),this.submissionPreviews.clear(),this.emit("state",this.getState()),this.dispatch({type:"session.load",sessionId:e}).then(()=>{})}stageProactiveSuggestionQuestion(e){const t=e.trim();if(!t)return Promise.resolve();const i=this.stagedProactiveSuggestionClientMessageId??crypto.randomUUID();return this.stagedProactiveSuggestionClientMessageId=i,this.dispatch({type:"conversation.stage_proactive_suggestion",question:t,clientMessageId:i}).then(()=>{})}dispatch(e){return e.type==="session.list"?this.adapter.dispatch(e):this.enqueueOperation(()=>this.adapter.dispatch(e))}enqueueOperation(e){const t=this.operationQueue.then(e);return this.operationQueue=t.then(()=>{},()=>{}),t}emit(e,t){const i=this.listeners[e];for(const n of i??[])n(t)}}function Pe(s,e){if(!e||!s)return e;const t=new Map;for(const i of s){const n=i.previewUrl;i.id&&n&&t.set(i.id,n)}return e.map(i=>{const n=i.id?t.get(i.id):void 0;return n?{...i,previewUrl:n}:i})}function w(s){return{...s,starterPrompts:[...s.starterPrompts],appearance:s.appearance?{...s.appearance}:null,messages:s.messages.map(e=>{const t={...e,attachments:e.attachments?.map(o=>({...o}))},i=e.assistantDraftItemId,n=e.clientMessageId,r=e.proactiveSuggestionClientMessageId;return r&&Object.defineProperty(t,"proactiveSuggestionClientMessageId",{value:r,enumerable:!1}),i&&Object.defineProperty(t,"assistantDraftItemId",{value:i,enumerable:!1}),n&&Object.defineProperty(t,"clientMessageId",{value:n,enumerable:!1}),t}),activeScheduledFollowUps:s.activeScheduledFollowUps?.map(e=>({...e}))??null}}function N(s){return{...s,data:s.data?f({entities:L(s.data).map(e=>({...e})),nextCursor:s.data.nextCursor}):null}}exports.PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE=$;exports.ProductAgentInteractionManager=re;exports.ProductAgentQueryController=P;exports.ProductAgentRemoteRuntimeClient=we;exports.ProductAgentSessionHistoryManager=te;exports.ProductAgentTaskPageTitleController=ce;exports.canSubmitPersonalProductAgentMessage=X;exports.createLocalStorageInteractionDecisionStorage=oe;exports.createProductAgentQueryState=g;exports.createProductAgentTaskPageTitleDocument=le;exports.formatProductAgentTaskPageTitle=Q;exports.hasProductAgentPaidCreditFallback=W;exports.isProductAgentAuthReconnectError=U;exports.isProductAgentRuntimeCommand=Ae;exports.mergeProductAgentEntityPages=j;exports.normalizeProductAgentEntityPage=f;exports.readLocalStorageInteractionDecisions=z;exports.reconcileProductAgentSubmissionGate=J;exports.resolveProductAgentBillingPresentation=Y;exports.resolveProductAgentComposerAction=ee;exports.resolveProductAgentWidgetPresentation=V;exports.selectProductAgentQueryEntities=L;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function g(s){return{key:s,status:"not_requested",data:null,error:null,requestId:0,updatedAt:null}}class P{constructor(e,t,i=(n,r)=>r){this.loader=t,this.merge=i,this.state=g(e)}loader;merge;state;listeners=new Set;inFlight=null;trailingLoad=null;getState(){return this.state}subscribe(e){return this.listeners.add(e),e(this.state),()=>this.listeners.delete(e)}setKey(e){e!==this.state.key&&(this.state=g(e),this.trailingLoad=null,this.publish())}reset(){this.state=g(this.state.key),this.trailingLoad=null,this.publish()}invalidate(){this.state={...this.state,status:this.state.data===null?"not_requested":"ready",updatedAt:null},this.publish()}load(e="replace",t=null){return this.trailingLoad={mode:e,cursor:t},this.inFlight?this.inFlight:(this.inFlight=this.runLoads().finally(()=>{this.inFlight=null}),this.inFlight)}update(e){this.state={...this.state,data:e(this.state.data)},this.publish()}async runLoads(){for(;this.trailingLoad;){const e=this.trailingLoad;this.trailingLoad=null;const t=this.state.key,i=this.state.requestId+1;this.state={...this.state,status:e.mode==="append"?"loading_more":this.state.data===null?"loading":"refreshing",error:null,requestId:i},this.publish();try{const n=await this.loader({key:t,cursor:e.cursor});if(t!==this.state.key||i!==this.state.requestId)continue;this.state={...this.state,status:"ready",data:this.merge(this.state.data,n,e.mode),error:null,updatedAt:Date.now()},this.publish()}catch(n){if(t!==this.state.key||i!==this.state.requestId)continue;this.state={...this.state,status:"error",error:n instanceof Error?n.message:"The query failed."},this.publish()}}}publish(){for(const e of this.listeners)e(this.state)}}function f(s){const e={},t=[];for(const i of s.entities)e[i.id]||t.push(i.id),e[i.id]=i;return{entitiesById:e,ids:t,nextCursor:s.nextCursor}}function j(s,e,t){if(t==="replace"||s===null)return e;const i={...s.entitiesById,...e.entitiesById},n=[...s.ids];for(const r of e.ids)s.entitiesById[r]||n.push(r);return{entitiesById:i,ids:n,nextCursor:e.nextCursor}}function U(s){return s?s.ids.map(e=>s.entitiesById[e]).filter(e=>!!e):[]}function V(s){return s.visible?s.minimized?{state:"minimized"}:{state:s.open?"visible_open":"visible_closed"}:{state:"hidden"}}function J(s,e){return e==="limit_exceeded"?{allowed:!1,reason:"credits_exhausted",actions:["upgrade","earn_credits"]}:e==="subscription_required"||e==="subscription_inactive"||e==="payment_issue"||e==="subscription_invalid"||e==="payment_required"?{allowed:!1,reason:"payment_issue",actions:["upgrade"]}:s??{allowed:!0,reason:"allowed",actions:[]}}function W(s){if(!s||typeof s!="object")return!1;const e=s.paidCreditFallbackModel;return typeof e=="string"&&e.length>0}function Y(s){return s?s.submissionGate?.allowed===!1?{state:"action_required",reason:s.submissionGate.reason}:s.usingPaidCreditFallback===!0?{state:"paid_credit_fallback"}:s.creditLimit!==null&&s.creditLimit>0&&s.creditsRemaining!==null&&s.creditsRemaining>0&&s.creditsRemaining/s.creditLimit<=.2?{state:"low_credits"}:s.creditsUsed!==null?{state:"usage"}:{state:"hidden"}:{state:"hidden"}}function X(s){return s.submissionAllowed&&s.isAuthenticated&&s.hasWorkspace&&!s.isWebsiteBlocked&&s.isCurrentPageResolved&&!s.isSubmitting&&!s.hasPendingMessage}function ee(s){const e=s.hasDraftMessage||s.hasPreSubmittedAttachment;return s.hasRunningAssistantTurn&&!e?{action:"stop",disabled:!s.canStopRunningTurn}:{action:"send",disabled:!e||!s.canSubmitMessage}}const L="Pluno is reconnecting. Try again in a moment.";function $(s){return(s instanceof Error?s.message:s)===L}class te{constructor(e,t,i=20){this.loadPage=t,this.limit=i,this.recentQuery=new P(`${e}:recent`,async({cursor:n})=>f(await this.loadPage({cursor:n,limit:this.limit,pinned:!1}).then(r=>({entities:r.sessions,nextCursor:r.nextCursor}))),j),this.pinnedQuery=new P(`${e}:pinned`,async()=>f({entities:await this.loadAllPinned(),nextCursor:null})),this.recentQuery.subscribe(()=>this.publish()),this.pinnedQuery.subscribe(()=>this.publish())}loadPage;limit;recentQuery;pinnedQuery;listeners=new Set;optimisticEntities=new Map;activityOverrides=new Map;pinnedOverrides=new Map;titleOverrides=new Map;refreshSequence=0;completedRefreshSequence=0;activityReconciliationScheduled=!1;getState(){const e=this.recentQuery.getState(),t=this.pinnedQuery.getState(),i=[...m(t.data),...m(e.data)],n=new Map(i.map(d=>[d.id,d])),r=Array.from(n.values()).map(d=>this.applyOverrides(d,this.completedRefreshSequence)),o=Array.from(this.optimisticEntities.values()).filter(d=>!n.has(d.id)).reverse(),a=e.data||t.data||o.length>0?f({entities:[...o,...r],nextCursor:e.data?.nextCursor??null}):null;return{key:e.key.slice(0,-7),status:se(e,t),data:a,error:e.error??t.error,requestId:Math.max(e.requestId,t.requestId),updatedAt:Math.max(e.updatedAt??0,t.updatedAt??0)||null}}subscribe(e){return this.listeners.add(e),e(this.getState()),()=>this.listeners.delete(e)}getEntity(e){return this.getState().data?.entitiesById[e]??null}setKey(e){this.optimisticEntities.clear(),this.activityOverrides.clear(),this.pinnedOverrides.clear(),this.titleOverrides.clear(),this.refreshSequence=0,this.completedRefreshSequence=0,this.activityReconciliationScheduled=!1,this.recentQuery.setKey(`${e}:recent`),this.pinnedQuery.setKey(`${e}:pinned`)}refresh(){const e=++this.refreshSequence,t=Promise.all([this.recentQuery.load("replace"),this.pinnedQuery.load("replace")]).then(()=>{this.completedRefreshSequence=Math.max(this.completedRefreshSequence,e),this.reconcileDurableEntities()});return t.then(()=>{!this.hasUnconfirmedActivityOverride()||this.activityReconciliationScheduled||(this.activityReconciliationScheduled=!0,this.refresh().finally(()=>{this.activityReconciliationScheduled=!1}))}),t}loadMore(e){return this.recentQuery.load("append",e)}addOptimistic(e){this.optimisticEntities.set(e.id,e),this.updateProjection()}removeOptimistic(e){this.optimisticEntities.delete(e)&&this.updateProjection()}acknowledgeOptimistic(e,t){this.optimisticEntities.delete(e),this.optimisticEntities.set(t.id,t),this.updateProjection()}setActivity(e,t){this.activityOverrides.set(e,{isActive:t,confirmAfterRefresh:this.completedRefreshSequence+1,releaseAfterRefresh:this.completedRefreshSequence+2}),this.updateEntity(e,i=>({...i,isActive:t}))}setPinned(e,t){const i={pinned:t,confirmAfterRefresh:Number.POSITIVE_INFINITY};return this.pinnedOverrides.set(e,i),this.updateEntity(e,n=>({...n,isPinned:t})),i}confirmPinned(e,t){this.pinnedOverrides.get(e)===t&&(t.confirmAfterRefresh=this.completedRefreshSequence+1)}rollbackPinned(e,t,i){this.pinnedOverrides.get(e)===t&&(this.pinnedOverrides.delete(e),this.updateEntity(e,n=>({...n,isPinned:i})))}setTitle(e,t){this.titleOverrides.set(e,t),this.updateEntity(e,i=>({...i,customTitle:t}))}confirmTitle(e){this.titleOverrides.delete(e)}reconcileDurableEntities(){const e=[...m(this.pinnedQuery.getState().data),...m(this.recentQuery.getState().data)],t=new Set(e.map(i=>i.id));for(const i of this.optimisticEntities.keys())t.has(i)&&this.optimisticEntities.delete(i);for(const i of e)this.applyOverrides(i,this.completedRefreshSequence);this.publish()}async loadAllPinned(){const e=[];let t=null;do{const i=await this.loadPage({cursor:t,limit:this.limit,pinned:!0});e.push(...i.sessions),t=i.nextCursor}while(t);return e}applyOverrides(e,t){let i=e;const n=this.activityOverrides.get(e.id);n&&(t>=n.confirmAfterRefresh&&e.isActive===n.isActive?this.activityOverrides.delete(e.id):t>=n.releaseAfterRefresh?this.activityOverrides.delete(e.id):i={...i,isActive:n.isActive});const r=this.pinnedOverrides.get(e.id);return r&&(t>=r.confirmAfterRefresh&&e.isPinned===!0===r.pinned?this.pinnedOverrides.delete(e.id):i={...i,isPinned:r.pinned}),this.titleOverrides.has(e.id)&&(i={...i,customTitle:this.titleOverrides.get(e.id)??null}),i}updateProjection(){this.publish()}updateEntity(e,t){const i=this.optimisticEntities.get(e);i&&this.optimisticEntities.set(e,t(i)),this.publish()}hasUnconfirmedActivityOverride(){return Array.from(this.activityOverrides.values()).some(e=>this.completedRefreshSequence<e.releaseAfterRefresh)}publish(){for(const e of this.listeners)e(this.getState())}}function m(s){return s?s.ids.map(e=>s.entitiesById[e]).filter(e=>!!e):[]}function se(s,e){return s.status==="error"||e.status==="error"?"error":s.status==="loading"||e.status==="loading"?"loading":s.status==="refreshing"||e.status==="refreshing"?"refreshing":s.status==="loading_more"?"loading_more":s.status==="ready"||e.status==="ready"?"ready":"not_requested"}function R(s){const e=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?(?:Z|\+00:00)$/.exec(s);if(!e)throw new Error("Display timestamps must retain the backend UTC precision.");return`${e[1]}.${(e[2]??"").padEnd(6,"0")}`}function b(s){if(s===null||typeof s=="string"||typeof s=="boolean")return!0;if(typeof s=="number")return Number.isFinite(s);if(Array.isArray(s))return s.every(b);if(typeof s!="object")return!1;const e=Object.getPrototypeOf(s);return e!==Object.prototype&&e!==null?!1:Object.values(s).every(b)}function K(s){return s!==null&&typeof s=="object"&&!Object.isFrozen(s)&&(Object.values(s).forEach(K),Object.freeze(s)),s}function ie(s){if(!b(s))throw new Error("Conversation inputs must be JSON-safe values.");return JSON.parse(JSON.stringify(s))}function ne(s,e){if(!e)return!1;const t=s.executionByUserMessage[e];if(t)return["completed","stopped","failed"].includes(t.phase);const i=Object.values(s.items).sort((r,o)=>R(r.created_at).localeCompare(R(o.created_at))||r.id.localeCompare(o.id));let n=!1;for(const r of i)if(r.type==="user_message"&&(n=r.id===e),!!n&&(r.type==="stopped"||r.type==="error"||r.type==="final_response"&&s.streams[r.id]?.state==="finished"&&s.streams[r.id].revision>=r.data.revision))return!0;return!1}class re{constructor(e,t=null){this.storage=e,t&&(this.decisions=new Map(t.filter(T).map(i=>[this.getDecisionKey(i),i])),this.initialized=!0)}storage;conversationReader=null;sources=new Map;invalidateAuth=()=>{};installConversationSources(e,t=()=>{}){this.sources.clear(),this.conversationReader=e,this.invalidateAuth=t}receiveConversationSources(e){for(const t of e){if(!Number.isSafeInteger(t.version)||t.version<0)throw new Error("Invalid interaction source version.");const i=JSON.stringify([t.conversation_id,t.id]),n=this.sources.get(i);if(n&&n.version>=t.version)continue;if(n&&n.payload.kind!==t.payload.kind)throw new Error("Interaction kind changed.");const r=n?.payload.kind==="personal_channel"&&n.lifecycle==="completed"?"completed":t.lifecycle,o=n?.payload.kind==="sharing"&&t.payload.kind==="sharing"?{...t.payload,variant:n.payload.variant}:t.payload;this.sources.set(i,K(ie({...t,lifecycle:r,payload:o}))),t.payload.kind==="integration_auth"&&this.invalidateAuth(t.payload.request_id)}}getIntegrationSource(e){return[...this.sources.values()].find(t=>t.payload.kind==="integration_auth"&&t.payload.request_id===e&&this.conversationReader?.(t.conversation_id))??null}getConversationInputs(e){if(!this.conversationReader)return;const t={share:null,integrations:[],channel:null},i=e?this.conversationReader(e):null;if(!i)return t;const n=[...this.sources.values()].filter(r=>r.conversation_id===e).sort((r,o)=>r.version-o.version||r.id.localeCompare(o.id));for(const r of n){const o=r.payload;if(o.kind==="sharing"){if(t.share=null,!o.eligible||r.lifecycle!=="pending"||r.invocation!=="user"||!["main_web_chat","automation","extension_sidepanel","extension_widget"].includes(r.entry_surface??""))continue;const a=r.user_message_id?i.items[r.user_message_id]:null;t.share={revision:r.version,candidate:{id:r.id,variant:o.variant,userPrompt:a?.type==="user_message"?a.data.content:"",assistantAnswer:""},terminal:!o.wait_for_terminal||ne(i,r.user_message_id)}}else o.kind==="integration_auth"?t.integrations.push({revision:r.version,request:{type:"pipedream_auth_required",authRequestId:o.request_id,appSlug:o.app_slug,appName:o.app_name,appLogo:o.app_logo??void 0,expiresAt:o.expires_at},lifecycle:r.lifecycle==="pending"&&Date.parse(o.expires_at)<=Date.now()?"expired":r.lifecycle}):t.channel={revision:r.version,request:{type:"personal_channel_connection_required",requestId:o.request_id,channel:o.channel,managementUrl:o.management_url},lifecycle:r.lifecycle}}return t}decisions=new Map;scheduledEligibility=new Map;initialized=!1;actionQueue=Promise.resolve();async initialize(){if(this.initialized)return;const e=await this.storage.load();this.decisions=new Map(e.filter(T).map(t=>[this.getDecisionKey(t),t])),this.initialized=!0}isEligible(e,t=Date.now()){const i=this.scheduledEligibility.get(this.getExactKey(e));return i!==void 0&&i>t?!1:this.isDecisionEligible(this.decisions.get(this.getExactKey(e)),t)&&this.isDecisionEligible(this.decisions.get(this.getCategoryKey(e)),t)}getDecision(e){return this.decisions.get(this.getExactKey(e))??this.decisions.get(this.getCategoryKey(e))??null}getStatus(e,t=Date.now()){const i=this.scheduledEligibility.get(this.getExactKey(e));if(i!==void 0&&i>t)return"scheduled";const n=this.getDecision(e);return n?n.action==="never"||n.action==="dont_show_again"?"suppressed":n.action==="dismiss"?"resolved":n.nextEligibleAt&&Date.parse(n.nextEligibleAt)>t?"snoozed":"presentable":"presentable"}scheduleEligibility(e,t){const i=this.getExactKey(e),n=this.scheduledEligibility.get(i);return n!==void 0?n:(this.scheduledEligibility.set(i,t),t)}getNextEligibilityAt(e=Date.now()){const t=[...Array.from(this.scheduledEligibility.values()).filter(i=>i>e),...Array.from(this.decisions.values()).map(i=>i.nextEligibleAt?Date.parse(i.nextEligibleAt):Number.NaN).filter(i=>Number.isFinite(i)&&i>e)];return t.length>0?Math.min(...t):null}act(e,t,i={}){const n=this.actionQueue.then(()=>this.applyAction(e,t,i));return this.actionQueue=n.then(()=>{},()=>{}),n}async applyAction(e,t,i){if(!e.allowedActions.includes(t))throw new Error(`Interaction ${e.key} does not allow ${t}.`);if(!F(t))throw new Error(`Interaction action ${t} is not a persistence decision.`);const n=i.now??new Date,r={promptKey:e.key,category:e.category,action:t,scope:e.scope,decidedAt:n.toISOString(),nextEligibleAt:this.getNextEligibleAt(e,t,n,i.snoozeUntil)},o=t==="dont_show_again"?this.getCategoryKey(e):this.getExactKey(e),a=new Map(this.decisions);return a.set(o,r),await this.storage.save([...a.values()]),this.decisions=a,r}isDecisionEligible(e,t){return e?e.action==="dismiss"||e.action==="never"||e.action==="dont_show_again"?!1:!e.nextEligibleAt||Date.parse(e.nextEligibleAt)<=t:!0}getNextEligibleAt(e,t,i,n){if(t==="later")return new Date(i.getTime()+(e.laterDelayMs??3600*1e3)).toISOString();if(t==="snooze"){if(!n||n.getTime()<=i.getTime())throw new Error("Snooze requires a future next-eligible time.");return n.toISOString()}return null}getDecisionKey(e){const t=_(e.scope);return e.action==="dont_show_again"?`${t}:category:${e.category}`:`${t}:interaction:${e.promptKey}`}getExactKey(e){return`${_(e.scope)}:interaction:${e.key}`}getCategoryKey(e){return`${_(e.scope)}:category:${e.category}`}}function oe(s,e){return{load:async()=>z(s,e),save:async t=>s.setItem(e,JSON.stringify(t))}}function z(s,e){const t=s.getItem(e);if(!t)return[];const i=JSON.parse(t);return Array.isArray(i)?i.filter(T):[]}function _(s){return`${s.level}:${s.key}`}function F(s){return s==="dismiss"||s==="later"||s==="snooze"||s==="never"||s==="dont_show_again"}function T(s){if(!s||typeof s!="object")return!1;const e=s;return typeof e.promptKey=="string"&&typeof e.category=="string"&&typeof e.decidedAt=="string"&&(e.nextEligibleAt===null||typeof e.nextEligibleAt=="string")&&F(e.action)&&!!(e.scope&&typeof e.scope=="object"&&typeof e.scope.level=="string"&&typeof e.scope.key=="string")}const ae={working:"⏳",completed:"✅",failed:"❗",stopped:"⏹️"},de=/^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;function Q(s,e){if(!e)return I(s);const t=I(s),i=`${ae[e]} Pluno`;return t?`${i}: ${t}`:i}class ce{constructor(e){this.titleDocument=e}titleDocument;status=null;baseTitle="";lastAppliedTitle=null;stopObserving=null;liveStatusVersion=0;setStatus(e){this.liveStatusVersion+=1,this.applyStatus(e)}clear(){this.liveStatusVersion+=1,this.applyClear()}async syncStatus(e){const t=this.liveStatusVersion,i=await e();i===void 0||t!==this.liveStatusVersion||(i?this.applyStatus(i):this.applyClear())}applyStatus(e){const t=this.titleDocument.getTitle();t!==this.lastAppliedTitle&&(this.baseTitle=I(t)),this.status=e,this.stopObserving||(this.stopObserving=this.titleDocument.observeTitle(()=>this.handleTitleChanged())),this.applyTitle()}applyClear(){const e=this.titleDocument.getTitle(),t=this.lastAppliedTitle!==null&&e===this.lastAppliedTitle,i=this.lastAppliedTitle===null?I(e):e;this.status=null,this.lastAppliedTitle=null,this.stopObserving?.(),this.stopObserving=null,t?this.titleDocument.setTitle(this.baseTitle):i!==e&&this.titleDocument.setTitle(i)}handleTitleChanged(){!this.status||this.titleDocument.getTitle()===this.lastAppliedTitle||this.applyTitle()}applyTitle(){if(!this.status)return;const e=Q(this.baseTitle,this.status);this.lastAppliedTitle=e,this.titleDocument.getTitle()!==e&&this.titleDocument.setTitle(e)}}function le(s){return{getTitle:()=>s.title,setTitle:e=>{s.title=e},observeTitle:e=>{const t=new MutationObserver(e);return t.observe(s.head,{childList:!0,subtree:!0,characterData:!0}),()=>t.disconnect()}}}function I(s){return s.replace(de,"")}const p=s=>typeof s=="string"&&/^[a-zA-Z0-9:_.-]{1,160}$/.test(s)?s:null;function ue(s){if(!s||typeof s!="object")return!1;const e=s,t=n=>Number.isSafeInteger(n)&&n>=0,i=n=>n&&typeof n=="object"&&Object.keys(n).every(r=>["sequence","at","type","changed","generation","sessionId","scopeId","requestId","effectId","clientScopeId","reason","effectKind","eventType","itemCount","removedCount","projectionReady"].includes(r))&&t(n.sequence)&&t(n.at)&&p(n.type)!==null&&typeof n.changed=="boolean"&&[n.generation,n.itemCount,n.removedCount].every(r=>r===null||t(r))&&[n.sessionId,n.scopeId,n.requestId,n.effectId,n.clientScopeId,n.reason,n.effectKind,n.eventType].every(r=>r===null||p(r)!==null)&&(n.projectionReady===null||typeof n.projectionReady=="boolean");return Object.keys(e).every(n=>["ownerId","revision","dropped","lastIntent","lastSelection","transitions"].includes(n))&&p(e.ownerId)!==null&&t(e.revision)&&t(e.dropped)&&(e.lastIntent==null||i(e.lastIntent))&&(e.lastSelection===null||i(e.lastSelection))&&Array.isArray(e.transitions)&&e.transitions.length<=16&&e.transitions.every(i)}function B(s){if(!s||typeof s!="object")return!1;const e=s;return Object.keys(e).every(t=>["sessionId","episodeId","consecutiveFailures","transportCode","requestId","durationMs"].includes(t))&&typeof e.sessionId=="string"&&/^[a-zA-Z0-9:_-]{1,160}$/.test(e.sessionId)&&typeof e.episodeId=="string"&&/^[a-zA-Z0-9:_-]{1,500}$/.test(e.episodeId)&&(e.transportCode===void 0||typeof e.transportCode=="string"&&/^[a-z0-9_]{1,80}$/.test(e.transportCode))&&(e.requestId===void 0||typeof e.requestId=="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test(e.requestId))&&(e.durationMs===void 0||typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>=0)&&Number.isSafeInteger(e.consecutiveFailures)&&e.consecutiveFailures>=1}const q=["messageKeys","canonicalItemKeys","terminalResponseKeys","toolCallKeys","activeResponseKeys"],E=s=>typeof s=="string"&&/^[a-zA-Z0-9:_-]{1,160}$/.test(s),v=s=>s===null||E(s),pe=s=>typeof s=="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(s)&&Number.isFinite(Date.parse(s));function G(s){if(!s||typeof s!="object")return!1;const e=s;return Object.keys(s).every(t=>["sessionId","itemId","userMessageId","createdAt","runId","retryable"].includes(t))&&v(e.sessionId)&&E(e.itemId)&&v(e.userMessageId)&&(e.retryable===void 0||typeof e.retryable=="boolean")&&v(e.runId)&&(e.createdAt===null||pe(e.createdAt))}function he(s){if(!s||typeof s!="object")return!1;const e=s,t=i=>Number.isSafeInteger(i)&&i>=0;return Object.keys(e).every(i=>["capturedAt","selectionKey","userId","loading","draft","thinking","connected","hasError","phase","queryStatus","queryRequestId","queryUpdatedAt","renderSource","selectionFencePending","guardCreatedAt","owner"].includes(i))&&t(e.capturedAt)&&[e.queryUpdatedAt,e.guardCreatedAt].every(i=>i===null||t(i))&&[e.selectionKey,e.userId,e.phase,e.queryStatus,e.queryRequestId].every(i=>i===null||p(i)!==null)&&[e.loading,e.draft,e.thinking,e.connected,e.hasError,e.selectionFencePending].every(i=>typeof i=="boolean")&&["state","account","interactions","local","sidepanel_layout"].includes(e.renderSource)&&(e.owner===void 0||ue(e.owner))}function H(s){if(!s||typeof s!="object"||Object.keys(s).some(i=>i!=="before"&&i!=="current"))return!1;const e=i=>{if(!i||typeof i!="object")return!1;const n=i;return Object.keys(i).every(r=>[...q,"sessionId","runtimeItemCount","welcome","truncated","thinkingSequence","context"].includes(r))&&(n.context===void 0||he(n.context))&&(n.thinkingSequence===void 0||Array.isArray(n.thinkingSequence)&&n.thinkingSequence.length<=20&&n.thinkingSequence.every(r=>r==="user"||r==="thinking"))&&v(n.sessionId)&&Number.isSafeInteger(n.runtimeItemCount)&&n.runtimeItemCount>=0&&typeof n.welcome=="boolean"&&typeof n.truncated=="boolean"&&q.every(r=>Array.isArray(n[r])&&n[r].length<=20&&n[r].every(E))},t=s;return(t.before===null||e(t.before))&&e(t.current)}function ge(s){if(s.details!==void 0&&!b(s.details))throw new TypeError("Product Agent transported error details must be JSON-safe.");return{code:s.code,message:s.message,retryable:s.retryable,...s.details===void 0?{}:{details:s.details}}}function S(s,e="runtime_error"){const t=s!==null&&typeof s=="object"?s:null,i=typeof s=="string"?s:t&&"message"in t&&typeof t.message=="string"?t.message:"",n=t&&"code"in t&&typeof t.code=="string"&&t.code.trim()?t.code:e,r=t&&"details"in t?t.details:null,o=r&&typeof r=="object"?r:{},a={...typeof o.securitySettingsUrl=="string"?{securitySettingsUrl:o.securitySettingsUrl}:{},...typeof o.transportCode=="string"&&/^[a-z0-9_]{1,80}$/.test(o.transportCode)?{transportCode:o.transportCode}:{},...typeof o.requestId=="string"&&/^[a-zA-Z0-9_-]{1,160}$/.test(o.requestId)?{requestId:o.requestId}:{},...typeof o.durationMs=="number"&&Number.isFinite(o.durationMs)&&o.durationMs>=0?{durationMs:o.durationMs}:{},...typeof o.successfulRequests=="number"&&Number.isSafeInteger(o.successfulRequests)&&o.successfulRequests>=0?{successfulRequests:o.successfulRequests}:{}};return ge({code:n,message:i.trim()&&i.trim()!=="[object Object]"?i:"The Product Agent operation failed. Try again.",retryable:!!(t&&"retryable"in t&&t.retryable===!0),...Object.keys(a).length?{details:a}:{}})}function Z(s){if(!s||typeof s!="object")return!1;const e=s,t=i=>Number.isSafeInteger(i)&&i>=0;return Object.keys(e).every(i=>["requestId","method","route","status","abortTrigger","owner","elapsedMs","attempt","category","responseHeadersMs","responseBodyMs","queryRequestId","ownerId","authorityGeneration","sessionId","release","upstreamRequestId","upstreamTraceId"].includes(i))&&p(e.requestId)!==null&&["GET","POST","PUT","PATCH","DELETE"].includes(e.method)&&["/api/product-agent/conversations/:sessionId/snapshot","/api/product-agent/:namespace/commands","/api/product-agent/:namespace/:operation"].includes(e.route)&&(e.status===null||t(e.status)&&e.status>=100&&e.status<=599)&&(e.abortTrigger===null||["deadline","transport_disposed","owner_disposed","authority_retired","observation_released","request_replaced","caller_cancelled","unexpected_abort"].includes(e.abortTrigger))&&["http_deadline","http_transport","conversation_query","browser","http_response"].includes(e.owner)&&(e.category===void 0||/^[a-z0-9_]{1,80}$/.test(e.category))&&[e.responseHeadersMs,e.responseBodyMs].every(i=>i==null||t(i))&&t(e.elapsedMs)&&t(e.attempt)&&e.attempt>=1&&e.attempt<=10&&[e.queryRequestId,e.ownerId,e.sessionId].every(i=>i===null||p(i)!==null)&&(e.authorityGeneration===null||t(e.authorityGeneration))&&typeof e.release=="string"&&/^[a-zA-Z0-9._-]{1,80}$/.test(e.release)&&[e.upstreamRequestId,e.upstreamTraceId].every(i=>i===null||typeof i=="string"&&/^[a-zA-Z0-9_:;=./-]{1,160}$/.test(i))}const fe=["submit","stop","staging_ipc","send_ipc","stop_ipc","attachment_transfer","tab_lookup","tab_recovery","session_recovery","conversation_scope","local_stage","view_publication","page_access","authentication","community","preferences","page_capture","session_tabs","context_ready","first_frame","checkpoint","command_http","http_authentication","http_request","receipt_http","attachment_upload","runtime_reading","runtime_stopping","runtime_progress","runtime_stopped","message_painted","reading_painted","stopping_painted","progress_painted","stopped_painted"],me=Math.random().toString(36).slice(2);let ye=0;const C=()=>`timing:${me}:${++ye}`,y=s=>typeof s=="string"&&/^[a-zA-Z0-9:_-]{1,160}$/.test(s);function M(s){if(!s||typeof s!="object")return!1;const e=s;return Object.keys(e).every(t=>["entrySurface","operation","layer","stage","status","spanId","requestId","clientMessageId","sessionId","occurredAt","durationMs"].includes(t))&&(e.entrySurface===void 0||["extension_sidepanel","extension_widget","main_web_chat","embedded_widget","embedded_custom_ui","automation","mcp","whatsapp"].includes(e.entrySurface))&&["send","stop"].includes(e.operation)&&["renderer","sdk","extension","http"].includes(e.layer)&&fe.includes(e.stage)&&["started","completed","failed","observed"].includes(e.status)&&y(e.spanId)&&y(e.requestId)&&(e.clientMessageId===null||y(e.clientMessageId))&&(e.sessionId===null||y(e.sessionId))&&typeof e.occurredAt=="string"&&e.occurredAt.length<=40&&Number.isFinite(Date.parse(e.occurredAt))&&Number.isSafeInteger(e.durationMs)&&e.durationMs>=0}function k(s,e){if(!s)return{mark:n=>{},measure:(n,r)=>r()};const t=performance.now(),i=(n,r,o,a)=>{const d={...e,stage:n,status:r,spanId:a,occurredAt:new Date().toISOString(),durationMs:Math.max(0,Math.round(performance.now()-o))};s&&M(d)&&Promise.resolve().then(()=>s(d)).catch(()=>{})};return{mark:n=>i(n,"observed",t,C()),measure(n,r){const o=performance.now(),a=C();return i(n,"started",o,a),r().then(d=>(i(n,"completed",o,a),d),d=>{throw i(n,"failed",o,a),d})}}}const A=s=>s===null||typeof s=="string"&&/^[a-zA-Z0-9:_-]{1,160}$/.test(s);function ve(s){if(!s||typeof s!="object")return!1;const e=s;return typeof e.observedAt=="string"&&e.observedAt.length<=40&&Number.isFinite(Date.parse(e.observedAt))&&A(e.sessionId)&&A(e.responseItemId)&&A(e.respondsToUserMessageId)&&typeof e.panelVisible=="boolean"&&typeof e.documentVisible=="boolean"&&typeof e.loading=="boolean"}const D=500;function be(s){const e=s.replace(/\n\s*at\s[\s\S]*$/,"").replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g,"[REDACTED]").replace(/\b(?:set-cookie|cookie)\s*[:=]\s*[^\n]+/gi,"cookie=[REDACTED]").replace(/\bdata:[^\s<>"']+/gi,"[DATA]").replace(/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi,"[URL]").replace(/\b(?:Bearer|Basic)\s+[^\s,;"']+/gi,"[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?/g,"[REDACTED]").replace(/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp)[-_][A-Za-z0-9_-]{8,}/g,"[REDACTED]").replace(/\b((?:access|refresh|id|auth)[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|pwd|secret|token|jwt|authorization|cookie|set-cookie)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;}&]+)/gi,"$1=[REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,"[EMAIL]").replace(/(?:[A-Z]:[\\/]|\\\\|(?:~|\.\.?)?\/|[\w.-]+[\\/])[^\s<>"']+/gi,"[FILE]").replace(new RegExp("(?<![\\w.])(?:[\\w.-]+\\.[A-Z][A-Z0-9]{0,15}|\\.[A-Z][\\w.-]*)\\b","gi"),"[FILE]").replace(/\s+/g," ").trim();return e.length>D?`${e.slice(0,D-1)}…`:e}function Ie(s,e,t="stopped",i){const n=new Set(i??[s.assistantDraftRespondsToUserMessageId,s.activeResponseUserMessageId,s.messages.filter(a=>a.role==="user").slice(-1)[0]?.id].filter(a=>!!a)),r=s.messages.filter(a=>!(a.dataType==="run_status"&&a.loading&&n.has(a.respondsToUserMessageId??""))).map(a=>n.has(a.respondsToUserMessageId??"")?{...a,loading:!1}:a);for(const a of n)r.some(d=>d.respondsToUserMessageId===a&&(d.dataType==="run_status"||d.dataType==="run_error"||d.role==="assistant"&&d.phase!=="commentary"))||r.some(d=>d.role==="user"&&d.id===a)&&r.push({id:`local-interrupted:${a}`,role:"system",dataType:"run_status",provisional:t==="stopping",content:t==="stopping"?"Stopping…":"Run stopped by user.",createdAt:e,respondsToUserMessageId:a});const o=s.segments?.map(a=>({...a,outcomeIds:[...a.outcomeIds,...r.filter(d=>d.id===`local-interrupted:${a.userMessageId}`&&!a.outcomeIds.includes(d.id)).map(d=>d.id)]}));return{...s,messages:r,isThinking:!1,isRetrying:!1,pendingMessageStatus:null,turnPhase:null,segments:o,activity:{phase:t,activeItemId:null},isLoadingSession:s.isLoadingSession&&r.length===0,taskStatus:t==="stopped"?"stopped":null,lastError:null,lastErrorCode:null}}const _e={"stop-without-rendered-message":"Stop is enabled while no message is rendered or the welcome screen is still visible.","in-progress-stop-unavailable":"An in-progress response has no visible enabled interrupt control.","stop-did-not-interrupt":"The stopped response remained in progress after an interrupt click.","duplicate-message-item":"A canonical message rendered more than once.","duplicate-canonical-item":"A canonical session item rendered more than once.","duplicate-tool-call":"A tool call rendered more than once.","duplicate-attachment":"An attachment rendered more than once.","duplicate-terminal-outcome":"A response rendered more than one terminal outcome.","foreign-session-item-visible":"The visible transcript contains state owned by another session.","terminal-response-reactivated":"A terminal response became active again.","terminal-history-not-append-only":"An established terminal outcome disappeared or changed order.","runtime-transcript-not-rendered":"A nonempty runtime transcript is displaying starter prompts.","thinking-groups-without-user-message":"Multiple thinking groups appeared without a user message between them.","thinking-without-progress":"Thinking remained visible without progress for five minutes."};function Se(s){return typeof s=="string"&&s.startsWith("ui_invariant:")&&Object.prototype.hasOwnProperty.call(_e,s.slice(13))}function x(s){return{...s.id===void 0?{}:{id:s.id},name:s.name,mimeType:s.mimeType,sizeBytes:s.sizeBytes,...s.sandboxPath===void 0?{}:{sandboxPath:s.sandboxPath},...s.storageKey===void 0?{}:{storageKey:s.storageKey},...s.fileUrl===void 0?{}:{fileUrl:s.fileUrl}}}function Ae(s){if(!s||typeof s!="object"||!("type"in s))return!1;const e=s;switch(e.type){case"runtime.connect":case"session.new":case"run.retry":return!0;case"run.stop":return e.clientMessageIds===void 0||Array.isArray(e.clientMessageIds)&&e.clientMessageIds.length<=100&&e.clientMessageIds.every(t=>typeof t=="string"&&t.length>0&&t.length<=160);case"runtime.report_response_visibility":return ve(e.observation);case"runtime.warmup":return e.reason==="panel_open"||e.reason==="extension_install"||e.reason==="composer_input";case"runtime.report_operation_timing":return M(e.timing);case"runtime.report_displayed_error":return(e.httpRequest===void 0||Z(e.httpRequest))&&(e.historyRefreshFailure===void 0||B(e.historyRefreshFailure))&&(e.renderedError===void 0||G(e.renderedError))&&(e.reason==="conversation_error"||e.reason==="attachment_error"||e.reason==="history_error"||e.reason==="action_error")&&typeof e.errorFingerprint=="string"&&/^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint)&&(e.displayedMessage===void 0||typeof e.displayedMessage=="string"&&e.displayedMessage.length<=500);case"runtime.report_invalid_state_transition":return(e.uiInvariant===void 0||H(e.uiInvariant))&&(e.reason==="submitted_turn_returned_to_welcome_without_new_chat"||e.reason==="new_messages_button_without_user_scroll"||Se(e.reason))&&(e.clientMessageId===void 0||typeof e.clientMessageId=="string");case"runtime.widget_lifecycle":return(e.action==="opened"||e.action==="closed"||e.action==="minimized")&&typeof e.trigger=="string";case"session.load":return typeof e.sessionId=="string"&&e.sessionId.length>0;case"session.list":return(e.cursor===void 0||e.cursor===null||typeof e.cursor=="string")&&(e.limit===void 0||typeof e.limit=="number")&&(e.pinned===void 0||typeof e.pinned=="boolean");case"composer.select_model":case"session.set_model":return typeof e.model=="string";case"session.pin":return typeof e.sessionId=="string"&&typeof e.pinned=="boolean";case"session.rename":return typeof e.sessionId=="string"&&typeof e.title=="string";case"interaction.act":return typeof e.interactionId=="string"&&typeof e.action=="string"&&typeof e.expectedRevision=="number";case"conversation.stage_proactive_suggestion":return typeof e.question=="string"&&typeof e.clientMessageId=="string";case"conversation.stage":return typeof e.content=="string"&&typeof e.clientMessageId=="string"&&(e.submittedAt===void 0||typeof e.submittedAt=="number")&&(e.requestedModel===void 0||typeof e.requestedModel=="string")&&(e.attachments===void 0||Array.isArray(e.attachments));case"conversation.fail_staged":return typeof e.clientMessageId=="string"&&typeof e.message=="string";case"conversation.send":return typeof e.content=="string"&&typeof e.clientMessageId=="string"&&(e.requestedModel===void 0||typeof e.requestedModel=="string")&&(e.automationOnboarding===void 0||typeof e.automationOnboarding=="boolean")&&(e.attachments===void 0||Array.isArray(e.attachments));default:return!1}}class we{constructor(e,t,i){this.adapter=t,this.state=w(e),this.model=i}adapter;listeners={};attachmentFiles=new Map;sessionHistoryListeners=new Set;interactionListeners=new Set;accountListeners=new Set;state;sessionHistoryState=g("unavailable");model;interactions=[];account=null;stagedProactiveSuggestionClientMessageId=null;pendingTransfers=new Map;submissionPreviews=new Map;submissionGeneration=0;pendingStop=null;stopError=null;stopPreviews=new Set;operationQueue=Promise.resolve();destroyed=!1;on(e,t){const i=this.listeners[e]??new Set;return i.add(t),this.listeners[e]=i,()=>i.delete(t)}getState(){const e=w(this.state);for(const[n,r]of this.submissionPreviews)e.messages.some(o=>o.id===n)||(e.messages.push({...r.message,attachments:r.message.attachments?.map(o=>({...o}))}),e.segments&&(e.segments=[...e.segments,{id:n,userMessageId:n,activityIds:[],outcomeIds:[],collapsed:!1}]),e.isLoadingSession=!1,r.pending&&(e.activeResponseUserMessageId=n,e.pendingMessageStatus="sending",e.turnPhase="sending",e.activity={phase:"submitting",activeItemId:null}),r.error&&(e.lastError=r.error,e.lastErrorCode="message_delivery_failed"));this.stopError&&(e.lastError=this.stopError,e.lastErrorCode="stop_failed");const t=[...this.stopPreviews];if(!t.length)return e;const i=Ie(e,"","stopping",t);return e.activeResponseUserMessageId&&!this.stopPreviews.has(e.activeResponseUserMessageId)?{...e,messages:i.messages,segments:i.segments}:i}updateProjection(e,t,i,n,r){if(this.destroyed)return;const o=this.getState();(o.user?.id!==e.user?.id||o.selectionKey!==void 0&&o.selectionKey!==e.selectionKey||o.selectionKey===void 0&&o.sessionId!==null&&o.sessionId!==e.sessionId)&&(this.cancelPendingSubmissions(),this.submissionPreviews.clear());for(const a of e.messages)a.role==="user"&&this.submissionPreviews.delete(a.id);this.state=w(e);for(const a of this.stopPreviews)e.messages.some(d=>d.respondsToUserMessageId===a&&!d.provisional&&d.loading!==!0&&(d.dataType==="run_status"||d.dataType==="run_error"||d.role==="assistant"&&d.phase!=="commentary"&&(d.streamState===void 0||["finished","stopped","failed"].includes(d.streamState))))&&this.stopPreviews.delete(a);if(o.user?.id===e.user?.id)for(const a of this.state.messages){if(a.role!=="user"||!a.attachments?.length)continue;const d=o.messages.find(c=>c.role==="user"&&c.id===a.id);o.sessionId!==e.sessionId&&!(o.sessionId===null&&d)||(a.attachments=Pe(d?.attachments,a.attachments))}if(t!==void 0&&(this.model=t),i&&JSON.stringify(i)!==JSON.stringify(this.sessionHistoryState)){this.sessionHistoryState=N(i);for(const a of this.sessionHistoryListeners)a(this.getSessionHistoryState())}if(n&&JSON.stringify(n)!==JSON.stringify(this.interactions)){this.interactions=n.map(a=>({...a}));for(const a of this.interactionListeners)a(this.getInteractions())}if(r!==void 0&&JSON.stringify(r)!==JSON.stringify(this.account)){this.account=r?{...r}:null;for(const a of this.accountListeners)a(this.getAccount())}this.emit("state",this.getState())}async connect(){await this.dispatch({type:"runtime.connect"})}destroy(){if(!this.destroyed){this.destroyed=!0,this.pendingStop=null,this.stopPreviews.clear(),this.pendingTransfers.clear(),this.submissionPreviews.clear(),this.attachmentFiles.clear(),this.sessionHistoryListeners.clear(),this.interactionListeners.clear(),this.accountListeners.clear();for(const e of Object.values(this.listeners))e?.clear();this.adapter.onDisconnect?.()}}warmup(e="panel_open"){return this.adapter.dispatch({type:"runtime.warmup",reason:e}).then(()=>{})}recordWidgetLifecycle(e,t){this.dispatch({type:"runtime.widget_lifecycle",action:e,trigger:t})}reportOperationTiming(e){!this.destroyed&&M(e)&&this.adapter.dispatch({type:"runtime.report_operation_timing",timing:e}).catch(()=>{})}reportResponseVisibility(e){this.adapter.dispatch({type:"runtime.report_response_visibility",observation:e}).catch(()=>{})}reportInvalidStateTransition(e,t,i){i!==void 0&&!H(i)||this.adapter.dispatch({type:"runtime.report_invalid_state_transition",reason:e,clientMessageId:t,...i?{uiInvariant:i}:{}}).catch(()=>{})}reportDisplayedError(e,t,i,n,r){const o=e==="conversation_error"&&!n?this.getState().conversationDiagnostics?.httpRequest:void 0;n!==void 0&&!G(n)||r!==void 0&&!B(r)||this.adapter.dispatch({type:"runtime.report_displayed_error",reason:e,errorFingerprint:t,...n?{renderedError:n}:{},...r?{historyRefreshFailure:r}:{},...Z(o)?{httpRequest:o}:{},...i?{displayedMessage:be(i)}:{}}).catch(()=>{})}sendMessage(e,t={}){const i=e.trim(),n=t.attachments??[];if(!i&&n.length===0)return Promise.resolve(null);this.pendingStop=null,this.stopError=null;const r=t.clientMessageId??(t.proactiveSuggestionQuestion&&this.stagedProactiveSuggestionClientMessageId?this.stagedProactiveSuggestionClientMessageId:crypto.randomUUID()),o=t.submittedAt??Date.now(),a=this.submissionGeneration;this.pendingTransfers.set(r,n.flatMap(c=>c.id?[c.id]:[])),this.submissionPreviews.set(r,{pending:!0,message:{id:r,role:"user",content:i,createdAt:"",attachments:n.map(c=>({...c}))}});const d=this.sendMessageNow(i,{...t,clientMessageId:r,submittedAt:o},a);return this.emit("state",this.getState()),d.finally(()=>{this.pendingTransfers.delete(r)})}async sendMessageNow(e,t,i){const n=e,r=t.clientMessageId,o=k(c=>{i===this.submissionGeneration&&this.reportOperationTiming(c)},{operation:"send",layer:"renderer",requestId:r,clientMessageId:r,sessionId:this.state.sessionId});o.mark("submit");let a=t.attachments??[],d=!1;if(i!==this.submissionGeneration)return null;try{if(!await o.measure("staging_ipc",async()=>{const l=await this.enqueueOperation(async()=>this.destroyed||i!==this.submissionGeneration?null:{result:this.adapter.dispatch({type:"conversation.stage",initiatedBy:t.initiatedBy,invocation:t.invocation,automationOnboarding:t.automationOnboarding,content:n,clientMessageId:r,proactiveSuggestionQuestion:t.proactiveSuggestionQuestion,attachments:a.length>0?a.map(x):void 0,submittedAt:t.submittedAt})});return l?(await l.result,l):null})||i!==this.submissionGeneration)return null;if(d=!0,a.length>0){if(!this.adapter.uploadAttachment)throw new Error("The runtime does not support attachments.");const l=[];for(const u of a){if(u.sandboxPath||u.storageKey){l.push(u);continue}const O=u.id?this.attachmentFiles.get(u.id):void 0;if(!O)throw new Error(`Attachment bytes are unavailable for ${u.name}`);if(l.push(await o.measure("attachment_transfer",()=>this.adapter.uploadAttachment(O,u,{clientMessageId:r}))),i!==this.submissionGeneration)return null}a=l}const h=await o.measure("send_ipc",()=>this.adapter.dispatch({type:"conversation.send",content:n,clientMessageId:r,initiatedBy:t.initiatedBy,invocation:t.invocation,proactiveSuggestionQuestion:t.proactiveSuggestionQuestion,...t.automationOnboarding?{automationOnboarding:!0}:{},attachments:a.length>0?a.map(x):void 0}));if(i!==this.submissionGeneration)return null;for(const l of t.attachments??[])l.id&&this.attachmentFiles.delete(l.id);return r===this.stagedProactiveSuggestionClientMessageId&&(this.stagedProactiveSuggestionClientMessageId=null),h?.clientMessageId??r}catch(c){if(i!==this.submissionGeneration)return null;if($(c))for(const l of t.attachments??[])l.id&&this.attachmentFiles.delete(l.id);const h=this.submissionPreviews.get(r);throw h&&(h.pending=!1,h.error=S(c).message,this.emit("state",this.getState())),d&&await this.adapter.dispatch({type:"conversation.fail_staged",clientMessageId:r,message:S(c).message}),c}}getModel(){return this.model}setModel(e){return this.dispatch({type:"session.set_model",model:e}).then(()=>{})}retryLastMessage(){return this.dispatch({type:"run.retry"}),!0}createLocalAttachment(e){const t=crypto.randomUUID();return this.attachmentFiles.set(t,e),{id:t,name:e.name||"attachment",mimeType:e.type||"application/octet-stream",sizeBytes:e.size}}stop(){if(this.pendingStop)return this.pendingStop.promise;const e=this.getState(),t=this.cancelPendingSubmissions(!1),i=[...new Set([...t,e.activeResponseUserMessageId,e.messages.filter(d=>d.role==="user").slice(-1)[0]?.id].filter(d=>!!d))],n=k(d=>this.reportOperationTiming(d),{operation:"stop",layer:"renderer",requestId:crypto.randomUUID(),clientMessageId:i[0]??null,sessionId:e.sessionId});n.mark("stop");const r={userMessageIds:i,promise:Promise.resolve()};this.pendingStop=r;for(const d of i)this.stopPreviews.add(d);const o=this.submissionGeneration;r.promise=n.measure("stop_ipc",()=>this.adapter.dispatch({type:"run.stop",...t.length?{clientMessageIds:t}:{}})).then(()=>{},d=>{if(o===this.submissionGeneration){for(const c of i)this.stopPreviews.delete(c);this.stopError=S(d).message}}).finally(()=>{this.destroyed||o!==this.submissionGeneration||(this.pendingStop===r&&(this.pendingStop=null),this.emit("state",this.getState()))}),this.emit("state",this.getState());const a=r.promise;return this.operationQueue=a.then(()=>{},()=>{}),a.then(()=>{})}cancelPendingSubmissions(e=!0){this.pendingStop=null,e&&this.stopPreviews.clear(),this.stopError=null;const t=[...this.pendingTransfers.keys()];this.submissionGeneration++;for(const i of this.pendingTransfers.values())for(const n of i)this.attachmentFiles.delete(n);this.pendingTransfers.clear();for(const i of this.submissionPreviews.values())i.pending=!1;return this.operationQueue=Promise.resolve(),t}startNewSession(e={}){return this.cancelPendingSubmissions(),this.submissionPreviews.clear(),this.emit("state",this.getState()),e.notifyTransport===!1?Promise.resolve():this.dispatch({type:"session.new"}).then(()=>{})}async listSessions(e={}){const t=await this.dispatch({type:"session.list",...e});if(t===void 0){const i=this.getSessionHistoryState().data;return{sessions:i?i.ids.map(n=>i.entitiesById[n]):[],nextCursor:i?.nextCursor??null}}if(!t?.sessionHistoryPage)throw new Error("Session list command did not return a page.");return t.sessionHistoryPage}getSessionHistoryState(){return N(this.sessionHistoryState)}subscribeSessionHistory(e){return this.sessionHistoryListeners.add(e),e(this.getSessionHistoryState()),()=>this.sessionHistoryListeners.delete(e)}refreshSessionHistory(){return this.dispatch({type:"session.list",limit:20}).then(()=>{})}loadMoreSessionHistory(){const e=this.sessionHistoryState.data?.nextCursor??null;return e?this.dispatch({type:"session.list",cursor:e}).then(()=>{}):Promise.resolve()}setSessionPinned(e,t){return this.dispatch({type:"session.pin",sessionId:e,pinned:t}).then(()=>{})}renameSession(e,t){return this.dispatch({type:"session.rename",sessionId:e,title:t}).then(()=>{})}getInteractions(){return this.interactions.map(e=>({...e}))}subscribeInteractions(e){return this.interactionListeners.add(e),e(this.getInteractions()),()=>this.interactionListeners.delete(e)}actOnInteraction(e,t,i,n={}){return this.dispatch({type:"interaction.act",interactionId:e,action:t,expectedRevision:i,...n}).then(()=>{})}getAccount(){return this.account?{...this.account}:null}subscribeAccount(e){return this.accountListeners.add(e),e(this.getAccount()),()=>this.accountListeners.delete(e)}refreshAccount(){return Promise.resolve()}loadSession(e){return this.cancelPendingSubmissions(),this.submissionPreviews.clear(),this.emit("state",this.getState()),this.dispatch({type:"session.load",sessionId:e}).then(()=>{})}stageProactiveSuggestionQuestion(e){const t=e.trim();if(!t)return Promise.resolve();const i=this.stagedProactiveSuggestionClientMessageId??crypto.randomUUID();return this.stagedProactiveSuggestionClientMessageId=i,this.dispatch({type:"conversation.stage_proactive_suggestion",question:t,clientMessageId:i}).then(()=>{})}dispatch(e){return e.type==="session.list"?this.adapter.dispatch(e):this.enqueueOperation(()=>this.adapter.dispatch(e))}enqueueOperation(e){const t=this.operationQueue.then(e);return this.operationQueue=t.then(()=>{},()=>{}),t}emit(e,t){const i=this.listeners[e];for(const n of i??[])n(t)}}function Pe(s,e){if(!e||!s)return e;const t=new Map;for(const i of s){const n=i.previewUrl;i.id&&n&&t.set(i.id,n)}return e.map(i=>{const n=i.id?t.get(i.id):void 0;return n?{...i,previewUrl:n}:i})}function w(s){return{...s,starterPrompts:[...s.starterPrompts],appearance:s.appearance?{...s.appearance}:null,messages:s.messages.map(e=>{const t={...e,attachments:e.attachments?.map(o=>({...o}))},i=e.assistantDraftItemId,n=e.clientMessageId,r=e.proactiveSuggestionClientMessageId;return r&&Object.defineProperty(t,"proactiveSuggestionClientMessageId",{value:r,enumerable:!1}),i&&Object.defineProperty(t,"assistantDraftItemId",{value:i,enumerable:!1}),n&&Object.defineProperty(t,"clientMessageId",{value:n,enumerable:!1}),t}),activeScheduledFollowUps:s.activeScheduledFollowUps?.map(e=>({...e}))??null}}function N(s){return{...s,data:s.data?f({entities:U(s.data).map(e=>({...e})),nextCursor:s.data.nextCursor}):null}}exports.PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE=L;exports.ProductAgentInteractionManager=re;exports.ProductAgentQueryController=P;exports.ProductAgentRemoteRuntimeClient=we;exports.ProductAgentSessionHistoryManager=te;exports.ProductAgentTaskPageTitleController=ce;exports.canSubmitPersonalProductAgentMessage=X;exports.createLocalStorageInteractionDecisionStorage=oe;exports.createProductAgentQueryState=g;exports.createProductAgentTaskPageTitleDocument=le;exports.formatProductAgentTaskPageTitle=Q;exports.hasProductAgentPaidCreditFallback=W;exports.isProductAgentAuthReconnectError=$;exports.isProductAgentRuntimeCommand=Ae;exports.mergeProductAgentEntityPages=j;exports.normalizeProductAgentEntityPage=f;exports.readLocalStorageInteractionDecisions=z;exports.reconcileProductAgentSubmissionGate=J;exports.resolveProductAgentBillingPresentation=Y;exports.resolveProductAgentComposerAction=ee;exports.resolveProductAgentWidgetPresentation=V;exports.selectProductAgentQueryEntities=U;
|
|
@@ -570,16 +570,16 @@ function ee(s) {
|
|
|
570
570
|
const e = s, t = (n) => Number.isSafeInteger(n) && n >= 0, i = (n) => n && typeof n == "object" && Object.keys(n).every((r) => ["sequence", "at", "type", "changed", "generation", "sessionId", "scopeId", "requestId", "effectId", "clientScopeId", "reason", "effectKind", "eventType", "itemCount", "removedCount", "projectionReady"].includes(r)) && t(n.sequence) && t(n.at) && p(n.type) !== null && typeof n.changed == "boolean" && [n.generation, n.itemCount, n.removedCount].every((r) => r === null || t(r)) && [n.sessionId, n.scopeId, n.requestId, n.effectId, n.clientScopeId, n.reason, n.effectKind, n.eventType].every((r) => r === null || p(r) !== null) && (n.projectionReady === null || typeof n.projectionReady == "boolean");
|
|
571
571
|
return Object.keys(e).every((n) => ["ownerId", "revision", "dropped", "lastIntent", "lastSelection", "transitions"].includes(n)) && p(e.ownerId) !== null && t(e.revision) && t(e.dropped) && (e.lastIntent == null || i(e.lastIntent)) && (e.lastSelection === null || i(e.lastSelection)) && Array.isArray(e.transitions) && e.transitions.length <= 16 && e.transitions.every(i);
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function U(s) {
|
|
574
574
|
if (!s || typeof s != "object") return !1;
|
|
575
575
|
const e = s;
|
|
576
576
|
return Object.keys(e).every((t) => ["sessionId", "episodeId", "consecutiveFailures", "transportCode", "requestId", "durationMs"].includes(t)) && typeof e.sessionId == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(e.sessionId) && typeof e.episodeId == "string" && /^[a-zA-Z0-9:_-]{1,500}$/.test(e.episodeId) && (e.transportCode === void 0 || typeof e.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(e.transportCode)) && (e.requestId === void 0 || typeof e.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(e.requestId)) && (e.durationMs === void 0 || typeof e.durationMs == "number" && Number.isFinite(e.durationMs) && e.durationMs >= 0) && Number.isSafeInteger(e.consecutiveFailures) && e.consecutiveFailures >= 1;
|
|
577
577
|
}
|
|
578
|
-
const R = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"],
|
|
579
|
-
function
|
|
578
|
+
const R = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], P = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), v = (s) => s === null || P(s), te = (s) => typeof s == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(s) && Number.isFinite(Date.parse(s));
|
|
579
|
+
function L(s) {
|
|
580
580
|
if (!s || typeof s != "object") return !1;
|
|
581
581
|
const e = s;
|
|
582
|
-
return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && v(e.sessionId) &&
|
|
582
|
+
return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && v(e.sessionId) && P(e.itemId) && v(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && v(e.runId) && (e.createdAt === null || te(e.createdAt));
|
|
583
583
|
}
|
|
584
584
|
function se(s) {
|
|
585
585
|
if (!s || typeof s != "object") return !1;
|
|
@@ -591,7 +591,7 @@ function K(s) {
|
|
|
591
591
|
const e = (i) => {
|
|
592
592
|
if (!i || typeof i != "object") return !1;
|
|
593
593
|
const n = i;
|
|
594
|
-
return Object.keys(i).every((r) => [...R, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || se(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) && v(n.sessionId) && Number.isSafeInteger(n.runtimeItemCount) && n.runtimeItemCount >= 0 && typeof n.welcome == "boolean" && typeof n.truncated == "boolean" && R.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(
|
|
594
|
+
return Object.keys(i).every((r) => [...R, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || se(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) && v(n.sessionId) && Number.isSafeInteger(n.runtimeItemCount) && n.runtimeItemCount >= 0 && typeof n.welcome == "boolean" && typeof n.truncated == "boolean" && R.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(P));
|
|
595
595
|
}, t = s;
|
|
596
596
|
return (t.before === null || e(t.before)) && e(t.current);
|
|
597
597
|
}
|
|
@@ -683,7 +683,7 @@ const ne = [
|
|
|
683
683
|
], re = Math.random().toString(36).slice(2);
|
|
684
684
|
let oe = 0;
|
|
685
685
|
const C = () => `timing:${re}:${++oe}`, f = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
|
|
686
|
-
function
|
|
686
|
+
function E(s) {
|
|
687
687
|
if (!s || typeof s != "object") return !1;
|
|
688
688
|
const e = s;
|
|
689
689
|
return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs"].includes(t)) && (e.entrySurface === void 0 || ["extension_sidepanel", "extension_widget", "main_web_chat", "embedded_widget", "embedded_custom_ui", "automation", "mcp", "whatsapp"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && ne.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && f(e.spanId) && f(e.requestId) && (e.clientMessageId === null || f(e.clientMessageId)) && (e.sessionId === null || f(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
|
|
@@ -703,7 +703,7 @@ function k(s, e) {
|
|
|
703
703
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
704
704
|
durationMs: Math.max(0, Math.round(performance.now() - o))
|
|
705
705
|
};
|
|
706
|
-
s &&
|
|
706
|
+
s && E(d) && Promise.resolve().then(() => s(d)).catch(() => {
|
|
707
707
|
});
|
|
708
708
|
};
|
|
709
709
|
return {
|
|
@@ -737,7 +737,7 @@ function ce(s, e, t = "stopped", i) {
|
|
|
737
737
|
s.messages.filter((a) => a.role === "user").slice(-1)[0]?.id
|
|
738
738
|
].filter((a) => !!a)), r = s.messages.filter((a) => !(a.dataType === "run_status" && a.loading && n.has(a.respondsToUserMessageId ?? ""))).map((a) => n.has(a.respondsToUserMessageId ?? "") ? { ...a, loading: !1 } : a);
|
|
739
739
|
for (const a of n)
|
|
740
|
-
r.some((d) => d.respondsToUserMessageId === a && (d.dataType === "run_status" || d.dataType === "run_error" || d.role === "assistant" && d.phase !== "commentary")) || r.some((d) => d.role === "user" && d.id === a) && r.push({ id: `local-interrupted:${a}`, role: "system", dataType: "run_status", content: t === "stopping" ? "Stopping…" : "Run stopped by user.", createdAt: e, respondsToUserMessageId: a });
|
|
740
|
+
r.some((d) => d.respondsToUserMessageId === a && (d.dataType === "run_status" || d.dataType === "run_error" || d.role === "assistant" && d.phase !== "commentary")) || r.some((d) => d.role === "user" && d.id === a) && r.push({ id: `local-interrupted:${a}`, role: "system", dataType: "run_status", provisional: t === "stopping", content: t === "stopping" ? "Stopping…" : "Run stopped by user.", createdAt: e, respondsToUserMessageId: a });
|
|
741
741
|
const o = s.segments?.map((a) => ({ ...a, outcomeIds: [
|
|
742
742
|
...a.outcomeIds,
|
|
743
743
|
...r.filter((d) => d.id === `local-interrupted:${a.userMessageId}` && !a.outcomeIds.includes(d.id)).map((d) => d.id)
|
|
@@ -802,9 +802,9 @@ function we(s) {
|
|
|
802
802
|
case "runtime.warmup":
|
|
803
803
|
return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
|
|
804
804
|
case "runtime.report_operation_timing":
|
|
805
|
-
return
|
|
805
|
+
return E(e.timing);
|
|
806
806
|
case "runtime.report_displayed_error":
|
|
807
|
-
return (e.httpRequest === void 0 || z(e.httpRequest)) && (e.historyRefreshFailure === void 0 ||
|
|
807
|
+
return (e.httpRequest === void 0 || z(e.httpRequest)) && (e.historyRefreshFailure === void 0 || U(e.historyRefreshFailure)) && (e.renderedError === void 0 || L(e.renderedError)) && (e.reason === "conversation_error" || e.reason === "attachment_error" || e.reason === "history_error" || e.reason === "action_error") && typeof e.errorFingerprint == "string" && /^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint) && (e.displayedMessage === void 0 || typeof e.displayedMessage == "string" && e.displayedMessage.length <= 500);
|
|
808
808
|
case "runtime.report_invalid_state_transition":
|
|
809
809
|
return (e.uiInvariant === void 0 || K(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || ue(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
|
|
810
810
|
case "runtime.widget_lifecycle":
|
|
@@ -856,6 +856,7 @@ class Te {
|
|
|
856
856
|
submissionGeneration = 0;
|
|
857
857
|
pendingStop = null;
|
|
858
858
|
stopError = null;
|
|
859
|
+
stopPreviews = /* @__PURE__ */ new Set();
|
|
859
860
|
operationQueue = Promise.resolve();
|
|
860
861
|
destroyed = !1;
|
|
861
862
|
on(e, t) {
|
|
@@ -864,9 +865,13 @@ class Te {
|
|
|
864
865
|
}
|
|
865
866
|
getState() {
|
|
866
867
|
const e = w(this.state);
|
|
867
|
-
for (const [
|
|
868
|
-
e.messages.some((
|
|
869
|
-
|
|
868
|
+
for (const [n, r] of this.submissionPreviews)
|
|
869
|
+
e.messages.some((o) => o.id === n) || (e.messages.push({ ...r.message, attachments: r.message.attachments?.map((o) => ({ ...o })) }), e.segments && (e.segments = [...e.segments, { id: n, userMessageId: n, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, r.pending && (e.activeResponseUserMessageId = n, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), r.error && (e.lastError = r.error, e.lastErrorCode = "message_delivery_failed"));
|
|
870
|
+
this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
|
|
871
|
+
const t = [...this.stopPreviews];
|
|
872
|
+
if (!t.length) return e;
|
|
873
|
+
const i = ce(e, "", "stopping", t);
|
|
874
|
+
return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
|
|
870
875
|
}
|
|
871
876
|
updateProjection(e, t, i, n, r) {
|
|
872
877
|
if (this.destroyed) return;
|
|
@@ -874,7 +879,10 @@ class Te {
|
|
|
874
879
|
(o.user?.id !== e.user?.id || o.selectionKey !== void 0 && o.selectionKey !== e.selectionKey || o.selectionKey === void 0 && o.sessionId !== null && o.sessionId !== e.sessionId) && (this.cancelPendingSubmissions(), this.submissionPreviews.clear());
|
|
875
880
|
for (const a of e.messages)
|
|
876
881
|
a.role === "user" && this.submissionPreviews.delete(a.id);
|
|
877
|
-
|
|
882
|
+
this.state = w(e);
|
|
883
|
+
for (const a of this.stopPreviews)
|
|
884
|
+
e.messages.some((d) => d.respondsToUserMessageId === a && !d.provisional && d.loading !== !0 && (d.dataType === "run_status" || d.dataType === "run_error" || d.role === "assistant" && d.phase !== "commentary" && (d.streamState === void 0 || ["finished", "stopped", "failed"].includes(d.streamState)))) && this.stopPreviews.delete(a);
|
|
885
|
+
if (o.user?.id === e.user?.id)
|
|
878
886
|
for (const a of this.state.messages) {
|
|
879
887
|
if (a.role !== "user" || !a.attachments?.length) continue;
|
|
880
888
|
const d = o.messages.find((c) => c.role === "user" && c.id === a.id);
|
|
@@ -900,7 +908,7 @@ class Te {
|
|
|
900
908
|
}
|
|
901
909
|
destroy() {
|
|
902
910
|
if (!this.destroyed) {
|
|
903
|
-
this.destroyed = !0, this.pendingStop = null, this.pendingTransfers.clear(), this.submissionPreviews.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
|
|
911
|
+
this.destroyed = !0, this.pendingStop = null, this.stopPreviews.clear(), this.pendingTransfers.clear(), this.submissionPreviews.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
|
|
904
912
|
for (const e of Object.values(this.listeners)) e?.clear();
|
|
905
913
|
this.adapter.onDisconnect?.();
|
|
906
914
|
}
|
|
@@ -913,7 +921,7 @@ class Te {
|
|
|
913
921
|
this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
|
|
914
922
|
}
|
|
915
923
|
reportOperationTiming(e) {
|
|
916
|
-
!this.destroyed &&
|
|
924
|
+
!this.destroyed && E(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
|
|
917
925
|
});
|
|
918
926
|
}
|
|
919
927
|
reportResponseVisibility(e) {
|
|
@@ -931,7 +939,7 @@ class Te {
|
|
|
931
939
|
}
|
|
932
940
|
reportDisplayedError(e, t, i, n, r) {
|
|
933
941
|
const o = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
|
|
934
|
-
n !== void 0 && !
|
|
942
|
+
n !== void 0 && !L(n) || r !== void 0 && !U(r) || this.adapter.dispatch({
|
|
935
943
|
type: "runtime.report_displayed_error",
|
|
936
944
|
reason: e,
|
|
937
945
|
errorFingerprint: t,
|
|
@@ -997,9 +1005,9 @@ class Te {
|
|
|
997
1005
|
l.push(u);
|
|
998
1006
|
continue;
|
|
999
1007
|
}
|
|
1000
|
-
const
|
|
1001
|
-
if (!
|
|
1002
|
-
if (l.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(
|
|
1008
|
+
const M = u.id ? this.attachmentFiles.get(u.id) : void 0;
|
|
1009
|
+
if (!M) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
|
|
1010
|
+
if (l.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(M, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
|
|
1003
1011
|
}
|
|
1004
1012
|
a = l;
|
|
1005
1013
|
}
|
|
@@ -1051,11 +1059,11 @@ class Te {
|
|
|
1051
1059
|
}
|
|
1052
1060
|
stop() {
|
|
1053
1061
|
if (this.pendingStop) return this.pendingStop.promise;
|
|
1054
|
-
const e = this.getState(), t = this.cancelPendingSubmissions(), i = [...new Set([
|
|
1062
|
+
const e = this.getState(), t = this.cancelPendingSubmissions(!1), i = [...new Set([
|
|
1055
1063
|
...t,
|
|
1056
1064
|
e.activeResponseUserMessageId,
|
|
1057
|
-
e.messages.filter((
|
|
1058
|
-
].filter((
|
|
1065
|
+
e.messages.filter((d) => d.role === "user").slice(-1)[0]?.id
|
|
1066
|
+
].filter((d) => !!d))], n = k((d) => this.reportOperationTiming(d), {
|
|
1059
1067
|
operation: "stop",
|
|
1060
1068
|
layer: "renderer",
|
|
1061
1069
|
requestId: crypto.randomUUID(),
|
|
@@ -1064,27 +1072,33 @@ class Te {
|
|
|
1064
1072
|
});
|
|
1065
1073
|
n.mark("stop");
|
|
1066
1074
|
const r = { userMessageIds: i, promise: Promise.resolve() };
|
|
1067
|
-
this.pendingStop = r
|
|
1068
|
-
|
|
1069
|
-
|
|
1075
|
+
this.pendingStop = r;
|
|
1076
|
+
for (const d of i) this.stopPreviews.add(d);
|
|
1077
|
+
const o = this.submissionGeneration;
|
|
1078
|
+
r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
|
|
1079
|
+
}, (d) => {
|
|
1080
|
+
if (o === this.submissionGeneration) {
|
|
1081
|
+
for (const c of i) this.stopPreviews.delete(c);
|
|
1082
|
+
this.stopError = S(d).message;
|
|
1083
|
+
}
|
|
1070
1084
|
}).finally(() => {
|
|
1071
|
-
this.pendingStop === r && (this.pendingStop = null, this.emit("state", this.getState()));
|
|
1085
|
+
this.destroyed || o !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
|
|
1072
1086
|
}), this.emit("state", this.getState());
|
|
1073
|
-
const
|
|
1074
|
-
return this.operationQueue =
|
|
1087
|
+
const a = r.promise;
|
|
1088
|
+
return this.operationQueue = a.then(() => {
|
|
1075
1089
|
}, () => {
|
|
1076
|
-
}),
|
|
1090
|
+
}), a.then(() => {
|
|
1077
1091
|
});
|
|
1078
1092
|
}
|
|
1079
|
-
cancelPendingSubmissions() {
|
|
1080
|
-
this.pendingStop = null, this.stopError = null;
|
|
1081
|
-
const
|
|
1093
|
+
cancelPendingSubmissions(e = !0) {
|
|
1094
|
+
this.pendingStop = null, e && this.stopPreviews.clear(), this.stopError = null;
|
|
1095
|
+
const t = [...this.pendingTransfers.keys()];
|
|
1082
1096
|
this.submissionGeneration++;
|
|
1083
|
-
for (const
|
|
1084
|
-
for (const
|
|
1097
|
+
for (const i of this.pendingTransfers.values())
|
|
1098
|
+
for (const n of i) this.attachmentFiles.delete(n);
|
|
1085
1099
|
this.pendingTransfers.clear();
|
|
1086
|
-
for (const
|
|
1087
|
-
return this.operationQueue = Promise.resolve(),
|
|
1100
|
+
for (const i of this.submissionPreviews.values()) i.pending = !1;
|
|
1101
|
+
return this.operationQueue = Promise.resolve(), t;
|
|
1088
1102
|
}
|
|
1089
1103
|
startNewSession(e = {}) {
|
|
1090
1104
|
return this.cancelPendingSubmissions(), this.submissionPreviews.clear(), this.emit("state", this.getState()), e.notifyTransport === !1 ? Promise.resolve() : this.dispatch({ type: "session.new" }).then(() => {
|
|
@@ -1386,7 +1386,7 @@ function ts(s, e, t = "stopped", i) {
|
|
|
1386
1386
|
s.messages.filter((a) => a.role === "user").slice(-1)[0]?.id
|
|
1387
1387
|
].filter((a) => !!a)), r = s.messages.filter((a) => !(a.dataType === "run_status" && a.loading && n.has(a.respondsToUserMessageId ?? ""))).map((a) => n.has(a.respondsToUserMessageId ?? "") ? { ...a, loading: !1 } : a);
|
|
1388
1388
|
for (const a of n)
|
|
1389
|
-
r.some((c) => c.respondsToUserMessageId === a && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary")) || r.some((c) => c.role === "user" && c.id === a) && r.push({ id: `local-interrupted:${a}`, role: "system", dataType: "run_status", content: t === "stopping" ? "Stopping…" : "Run stopped by user.", createdAt: e, respondsToUserMessageId: a });
|
|
1389
|
+
r.some((c) => c.respondsToUserMessageId === a && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary")) || r.some((c) => c.role === "user" && c.id === a) && r.push({ id: `local-interrupted:${a}`, role: "system", dataType: "run_status", provisional: t === "stopping", content: t === "stopping" ? "Stopping…" : "Run stopped by user.", createdAt: e, respondsToUserMessageId: a });
|
|
1390
1390
|
const o = s.segments?.map((a) => ({ ...a, outcomeIds: [
|
|
1391
1391
|
...a.outcomeIds,
|
|
1392
1392
|
...r.filter((c) => c.id === `local-interrupted:${a.userMessageId}` && !a.outcomeIds.includes(c.id)).map((c) => c.id)
|
|
@@ -1632,7 +1632,7 @@ function ar(s) {
|
|
|
1632
1632
|
return e() && i.directory.memberships[t]?.members.length ? i.conversation.sessions[t] ?? null : null;
|
|
1633
1633
|
}, s.invalidateAuth), async (t) => (!e() || t.authorityId !== s.authority.authorityId || t.generation !== s.authority.generation || !s.runtime().engine.getState().slices.directory.memberships[t.sessionId]?.members.length || (s.manager.receiveConversationSources(t.sources), s.notify()), null);
|
|
1634
1634
|
}
|
|
1635
|
-
const cr = "0.1.
|
|
1635
|
+
const cr = "0.1.240", dr = {
|
|
1636
1636
|
version: cr
|
|
1637
1637
|
};
|
|
1638
1638
|
function et(s) {
|
|
@@ -4104,8 +4104,11 @@ class uo {
|
|
|
4104
4104
|
forceNew: !0,
|
|
4105
4105
|
auth: { ...e.auth },
|
|
4106
4106
|
reconnection: e.reconnect ?? !0
|
|
4107
|
-
}), this.socket.io.on("reconnect_attempt", () => this.beginAttempt()), this.socket.io.on("close", () => {
|
|
4108
|
-
this.
|
|
4107
|
+
}), this.socket.io.on("reconnect_attempt", () => this.beginAttempt()), this.socket.io.on("close", (t) => {
|
|
4108
|
+
const i = this.generation, n = this.attempt;
|
|
4109
|
+
t === "forced close" ? queueMicrotask(() => {
|
|
4110
|
+
i === this.generation && n === this.attempt && this.invalidate(!1, t);
|
|
4111
|
+
}) : this.invalidate(!1, t), this.restoreBackoff();
|
|
4109
4112
|
}), this.socket.io.on("reconnect", () => this.restoreBackoff()), this.socket.on("connection.ready", (t) => {
|
|
4110
4113
|
if (t.protocol !== 1 || t.role !== this.options.auth.role || t.display_projection_ready !== !1) {
|
|
4111
4114
|
this.options.onError(new w("Unsupported Product Agent transport negotiation", "protocol_error")), this.disconnect();
|
|
@@ -4115,7 +4118,8 @@ class uo {
|
|
|
4115
4118
|
}), this.socket.on("connect", () => {
|
|
4116
4119
|
this.active = !0, this.activate();
|
|
4117
4120
|
}), this.socket.on("disconnect", (t) => this.invalidate(
|
|
4118
|
-
t === "io client disconnect" && !this.replacingCredentials
|
|
4121
|
+
t === "io client disconnect" && !this.replacingCredentials,
|
|
4122
|
+
t
|
|
4119
4123
|
)), this.socket.on("connect_error", (t) => {
|
|
4120
4124
|
const i = t.data?.code;
|
|
4121
4125
|
if (i === "unauthorized" && t.data?.reason === "token_expired" && t.data.retryable === !0) {
|
|
@@ -4123,7 +4127,7 @@ class uo {
|
|
|
4123
4127
|
return;
|
|
4124
4128
|
}
|
|
4125
4129
|
if (!i || t.data?.retryable === !0) {
|
|
4126
|
-
if (this.invalidate(!1), this.options.reconnect === !1)
|
|
4130
|
+
if (this.invalidate(!1, "connect_error"), this.options.reconnect === !1)
|
|
4127
4131
|
this.socket.disconnect();
|
|
4128
4132
|
else {
|
|
4129
4133
|
const n = this.socket.io;
|
|
@@ -4206,10 +4210,10 @@ class uo {
|
|
|
4206
4210
|
}
|
|
4207
4211
|
}
|
|
4208
4212
|
replaceCredentials(e, t) {
|
|
4209
|
-
this.replacingCredentials = !0, this.invalidate(!1), this.socket.disconnect(), this.replacingCredentials = !1, this.invalidate(!1), t && this.bindings.clear(), this.options.auth = { ...e }, this.socket.auth = { ...e }, this.connect();
|
|
4213
|
+
this.replacingCredentials = !0, this.invalidate(!1, "credential_replacement"), this.socket.disconnect(), this.replacingCredentials = !1, this.invalidate(!1, "credential_replacement"), t && this.bindings.clear(), this.options.auth = { ...e }, this.socket.auth = { ...e }, this.connect();
|
|
4210
4214
|
}
|
|
4211
4215
|
suspend() {
|
|
4212
|
-
this.replacingCredentials = !0, this.invalidate(!1), this.socket.disconnect(), this.replacingCredentials = !1, this.invalidate(!1);
|
|
4216
|
+
this.replacingCredentials = !0, this.invalidate(!1, "local_suspend"), this.socket.disconnect(), this.replacingCredentials = !1, this.invalidate(!1, "local_suspend");
|
|
4213
4217
|
}
|
|
4214
4218
|
disconnect() {
|
|
4215
4219
|
this.invalidate(!0), this.socket.disconnect();
|
|
@@ -4227,8 +4231,8 @@ class uo {
|
|
|
4227
4231
|
const e = this.socket.io;
|
|
4228
4232
|
e.backoff.attempts = Math.min(20, Math.max(0, this.attemptCount - 1));
|
|
4229
4233
|
}
|
|
4230
|
-
recover() {
|
|
4231
|
-
!this.active || this.retired || (this.invalidate(!1), this.socket.io.engine.close());
|
|
4234
|
+
recover(e = "local_recovery") {
|
|
4235
|
+
!this.active || this.retired || (this.invalidate(!1, e), this.socket.io.engine.close());
|
|
4232
4236
|
}
|
|
4233
4237
|
beginAttempt() {
|
|
4234
4238
|
this.clearReadinessTimers(), this.active = !0, this.attempt = { connectionAttemptId: crypto.randomUUID(), reconnectAttempt: this.attemptCount++, startedAt: Date.now() }, this.socket.auth = { ...this.options.auth, connection_attempt_id: this.attempt.connectionAttemptId }, this.options.onAttempt?.(this.attempt);
|
|
@@ -4237,7 +4241,7 @@ class uo {
|
|
|
4237
4241
|
retryable: !0,
|
|
4238
4242
|
...this.attempt,
|
|
4239
4243
|
readinessPhase: this.ready ? "bootstrap" : this.admitted ? "activation" : "namespace_ready"
|
|
4240
|
-
})), e === this.generation && this.recover());
|
|
4244
|
+
})), e === this.generation && this.recover(i));
|
|
4241
4245
|
};
|
|
4242
4246
|
this.admissionTimer = setTimeout(() => t("connect_timeout"), 15e3), this.readinessTimer = setTimeout(() => t("auth_timeout"), co);
|
|
4243
4247
|
}
|
|
@@ -4285,7 +4289,7 @@ class uo {
|
|
|
4285
4289
|
}
|
|
4286
4290
|
activationFailed(e) {
|
|
4287
4291
|
const t = this.generation;
|
|
4288
|
-
this.options.onError(e), t === this.generation && ((e.outcomeUnknown || e.detail?.retryable === !0) && this.options.reconnect !== !1 ? this.
|
|
4292
|
+
this.options.onError(e), t === this.generation && ((e.outcomeUnknown || e.detail?.retryable === !0) && this.options.reconnect !== !1 ? this.recover("local_activation_failure") : this.disconnect());
|
|
4289
4293
|
}
|
|
4290
4294
|
synchronize(e = !1) {
|
|
4291
4295
|
const t = this.generation;
|
|
@@ -4377,13 +4381,13 @@ class uo {
|
|
|
4377
4381
|
});
|
|
4378
4382
|
}
|
|
4379
4383
|
recoverUncertainDelivery(e, t) {
|
|
4380
|
-
e instanceof w && (e.outcomeUnknown || e.code === "backpressure" && !e.backendRefusal) && t === this.generation && this.active && this.
|
|
4384
|
+
e instanceof w && (e.outcomeUnknown || e.code === "backpressure" && !e.backendRefusal) && t === this.generation && this.active && this.recover(e.code === "backpressure" ? "local_backpressure" : "local_delivery_uncertain");
|
|
4381
4385
|
}
|
|
4382
|
-
invalidate(e = !1) {
|
|
4386
|
+
invalidate(e = !1, t = "local_invalidation") {
|
|
4383
4387
|
if (this.clearReadinessTimers(), !!this.active) {
|
|
4384
4388
|
this.active = !1, this.generation++, this.ready = null, this.admitted = null, this.activating = !1;
|
|
4385
|
-
for (const
|
|
4386
|
-
this.options.onDisconnect(e);
|
|
4389
|
+
for (const i of [...this.pending]) i(new w("Connection lost before acknowledgement", "delivery_unknown", !0));
|
|
4390
|
+
this.options.onDisconnect(e, t);
|
|
4387
4391
|
}
|
|
4388
4392
|
}
|
|
4389
4393
|
}
|
|
@@ -4926,12 +4930,12 @@ class D extends EventTarget {
|
|
|
4926
4930
|
onReady: () => {
|
|
4927
4931
|
this.readyState !== 3 && (this.readyState = 1, this.dispatchEvent(new Event("open")));
|
|
4928
4932
|
},
|
|
4929
|
-
onDisconnect: (t) => {
|
|
4933
|
+
onDisconnect: (t, i) => {
|
|
4930
4934
|
if (t) {
|
|
4931
4935
|
this.finishClose(!0);
|
|
4932
4936
|
return;
|
|
4933
4937
|
}
|
|
4934
|
-
this.readyState !== 3 && (this.resetBootstrap(), this.readyState = 0, this.initialized = !1, this.bootstrapped = !1, this.beforeBootstrap.length = 0, this.rejectToolReceipts(), this.dispatchEvent(new
|
|
4938
|
+
this.readyState !== 3 && (this.resetBootstrap(), this.readyState = 0, this.initialized = !1, this.bootstrapped = !1, this.beforeBootstrap.length = 0, this.rejectToolReceipts(), this.dispatchEvent(new CustomEvent("reconnecting", { detail: { reason: i } })));
|
|
4935
4939
|
},
|
|
4936
4940
|
onEvent: (t, i) => {
|
|
4937
4941
|
const n = i, r = n.sessionId ?? n.session?.id ?? n.item?.sessionId, o = this.hydration;
|
|
@@ -6918,6 +6922,7 @@ class Ud {
|
|
|
6918
6922
|
submissionGeneration = 0;
|
|
6919
6923
|
pendingStop = null;
|
|
6920
6924
|
stopError = null;
|
|
6925
|
+
stopPreviews = /* @__PURE__ */ new Set();
|
|
6921
6926
|
operationQueue = Promise.resolve();
|
|
6922
6927
|
destroyed = !1;
|
|
6923
6928
|
on(e, t) {
|
|
@@ -6926,9 +6931,13 @@ class Ud {
|
|
|
6926
6931
|
}
|
|
6927
6932
|
getState() {
|
|
6928
6933
|
const e = Lt(this.state);
|
|
6929
|
-
for (const [
|
|
6930
|
-
e.messages.some((
|
|
6931
|
-
|
|
6934
|
+
for (const [n, r] of this.submissionPreviews)
|
|
6935
|
+
e.messages.some((o) => o.id === n) || (e.messages.push({ ...r.message, attachments: r.message.attachments?.map((o) => ({ ...o })) }), e.segments && (e.segments = [...e.segments, { id: n, userMessageId: n, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, r.pending && (e.activeResponseUserMessageId = n, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), r.error && (e.lastError = r.error, e.lastErrorCode = "message_delivery_failed"));
|
|
6936
|
+
this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
|
|
6937
|
+
const t = [...this.stopPreviews];
|
|
6938
|
+
if (!t.length) return e;
|
|
6939
|
+
const i = ts(e, "", "stopping", t);
|
|
6940
|
+
return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
|
|
6932
6941
|
}
|
|
6933
6942
|
updateProjection(e, t, i, n, r) {
|
|
6934
6943
|
if (this.destroyed) return;
|
|
@@ -6936,7 +6945,10 @@ class Ud {
|
|
|
6936
6945
|
(o.user?.id !== e.user?.id || o.selectionKey !== void 0 && o.selectionKey !== e.selectionKey || o.selectionKey === void 0 && o.sessionId !== null && o.sessionId !== e.sessionId) && (this.cancelPendingSubmissions(), this.submissionPreviews.clear());
|
|
6937
6946
|
for (const a of e.messages)
|
|
6938
6947
|
a.role === "user" && this.submissionPreviews.delete(a.id);
|
|
6939
|
-
|
|
6948
|
+
this.state = Lt(e);
|
|
6949
|
+
for (const a of this.stopPreviews)
|
|
6950
|
+
e.messages.some((c) => c.respondsToUserMessageId === a && !c.provisional && c.loading !== !0 && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary" && (c.streamState === void 0 || ["finished", "stopped", "failed"].includes(c.streamState)))) && this.stopPreviews.delete(a);
|
|
6951
|
+
if (o.user?.id === e.user?.id)
|
|
6940
6952
|
for (const a of this.state.messages) {
|
|
6941
6953
|
if (a.role !== "user" || !a.attachments?.length) continue;
|
|
6942
6954
|
const c = o.messages.find((u) => u.role === "user" && u.id === a.id);
|
|
@@ -6962,7 +6974,7 @@ class Ud {
|
|
|
6962
6974
|
}
|
|
6963
6975
|
destroy() {
|
|
6964
6976
|
if (!this.destroyed) {
|
|
6965
|
-
this.destroyed = !0, this.pendingStop = null, this.pendingTransfers.clear(), this.submissionPreviews.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
|
|
6977
|
+
this.destroyed = !0, this.pendingStop = null, this.stopPreviews.clear(), this.pendingTransfers.clear(), this.submissionPreviews.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
|
|
6966
6978
|
for (const e of Object.values(this.listeners)) e?.clear();
|
|
6967
6979
|
this.adapter.onDisconnect?.();
|
|
6968
6980
|
}
|
|
@@ -7113,11 +7125,11 @@ class Ud {
|
|
|
7113
7125
|
}
|
|
7114
7126
|
stop() {
|
|
7115
7127
|
if (this.pendingStop) return this.pendingStop.promise;
|
|
7116
|
-
const e = this.getState(), t = this.cancelPendingSubmissions(), i = [...new Set([
|
|
7128
|
+
const e = this.getState(), t = this.cancelPendingSubmissions(!1), i = [...new Set([
|
|
7117
7129
|
...t,
|
|
7118
7130
|
e.activeResponseUserMessageId,
|
|
7119
|
-
e.messages.filter((
|
|
7120
|
-
].filter((
|
|
7131
|
+
e.messages.filter((c) => c.role === "user").slice(-1)[0]?.id
|
|
7132
|
+
].filter((c) => !!c))], n = me((c) => this.reportOperationTiming(c), {
|
|
7121
7133
|
operation: "stop",
|
|
7122
7134
|
layer: "renderer",
|
|
7123
7135
|
requestId: crypto.randomUUID(),
|
|
@@ -7126,27 +7138,33 @@ class Ud {
|
|
|
7126
7138
|
});
|
|
7127
7139
|
n.mark("stop");
|
|
7128
7140
|
const r = { userMessageIds: i, promise: Promise.resolve() };
|
|
7129
|
-
this.pendingStop = r
|
|
7130
|
-
|
|
7131
|
-
|
|
7141
|
+
this.pendingStop = r;
|
|
7142
|
+
for (const c of i) this.stopPreviews.add(c);
|
|
7143
|
+
const o = this.submissionGeneration;
|
|
7144
|
+
r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
|
|
7145
|
+
}, (c) => {
|
|
7146
|
+
if (o === this.submissionGeneration) {
|
|
7147
|
+
for (const u of i) this.stopPreviews.delete(u);
|
|
7148
|
+
this.stopError = we(c).message;
|
|
7149
|
+
}
|
|
7132
7150
|
}).finally(() => {
|
|
7133
|
-
this.pendingStop === r && (this.pendingStop = null, this.emit("state", this.getState()));
|
|
7151
|
+
this.destroyed || o !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
|
|
7134
7152
|
}), this.emit("state", this.getState());
|
|
7135
|
-
const
|
|
7136
|
-
return this.operationQueue =
|
|
7153
|
+
const a = r.promise;
|
|
7154
|
+
return this.operationQueue = a.then(() => {
|
|
7137
7155
|
}, () => {
|
|
7138
|
-
}),
|
|
7156
|
+
}), a.then(() => {
|
|
7139
7157
|
});
|
|
7140
7158
|
}
|
|
7141
|
-
cancelPendingSubmissions() {
|
|
7142
|
-
this.pendingStop = null, this.stopError = null;
|
|
7143
|
-
const
|
|
7159
|
+
cancelPendingSubmissions(e = !0) {
|
|
7160
|
+
this.pendingStop = null, e && this.stopPreviews.clear(), this.stopError = null;
|
|
7161
|
+
const t = [...this.pendingTransfers.keys()];
|
|
7144
7162
|
this.submissionGeneration++;
|
|
7145
|
-
for (const
|
|
7146
|
-
for (const
|
|
7163
|
+
for (const i of this.pendingTransfers.values())
|
|
7164
|
+
for (const n of i) this.attachmentFiles.delete(n);
|
|
7147
7165
|
this.pendingTransfers.clear();
|
|
7148
|
-
for (const
|
|
7149
|
-
return this.operationQueue = Promise.resolve(),
|
|
7166
|
+
for (const i of this.submissionPreviews.values()) i.pending = !1;
|
|
7167
|
+
return this.operationQueue = Promise.resolve(), t;
|
|
7150
7168
|
}
|
|
7151
7169
|
startNewSession(e = {}) {
|
|
7152
7170
|
return this.cancelPendingSubmissions(), this.submissionPreviews.clear(), this.emit("state", this.getState()), e.notifyTransport === !1 ? Promise.resolve() : this.dispatch({ type: "session.new" }).then(() => {
|
|
@@ -7973,8 +7991,8 @@ class bt {
|
|
|
7973
7991
|
});
|
|
7974
7992
|
this.socket = r, this.options.webSocketFactory && (this.socketConnectTimer = window.setTimeout(() => {
|
|
7975
7993
|
this.socket === r && r.readyState === WebSocket.CONNECTING && (N("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(r));
|
|
7976
|
-
}, Ua)), r.addEventListener("reconnecting", () => {
|
|
7977
|
-
this.socket === r && this.state.status !== "closed" && (this.refreshingDefaultCredentials || this.reportTransportDiagnostic("socket_closed", {
|
|
7994
|
+
}, Ua)), r.addEventListener("reconnecting", (o) => {
|
|
7995
|
+
this.socket === r && this.state.status !== "closed" && (this.refreshingDefaultCredentials || this.reportTransportDiagnostic("socket_closed", { disconnectReason: o.detail.reason }), this.setReconnectingState());
|
|
7978
7996
|
}), r.addEventListener("open", () => {
|
|
7979
7997
|
this.socket !== r || (this.clearSocketConnectTimer(), this.directoryObservation.reconnect().catch(() => {
|
|
7980
7998
|
}), this.conversationObservation?.wake(), N("web-sdk.agent", "Pluno socket opened", {
|
|
@@ -8876,7 +8894,7 @@ class bt {
|
|
|
8876
8894
|
}
|
|
8877
8895
|
/** @internal */
|
|
8878
8896
|
reportTransportDiagnostic(e, t = {}) {
|
|
8879
|
-
const i = typeof navigator > "u" ? "unknown" : navigator.onLine === !1 ? "offline" : "online", n = `${e}:${t.requestId ?? t.connectionAttemptId ?? "none"}:${t.closeCode ?? "none"}:${i}`, r = (/* @__PURE__ */ new Date()).toISOString(), o = this.transportDiagnosticEpisodes.get(n), a = {
|
|
8897
|
+
const i = typeof navigator > "u" ? "unknown" : navigator.onLine === !1 ? "offline" : "online", n = `${e}:${t.requestId ?? t.connectionAttemptId ?? "none"}:${t.closeCode ?? "none"}:${t.disconnectReason ?? "none"}:${i}`, r = (/* @__PURE__ */ new Date()).toISOString(), o = this.transportDiagnosticEpisodes.get(n), a = {
|
|
8880
8898
|
id: o?.id ?? crypto.randomUUID(),
|
|
8881
8899
|
phase: e,
|
|
8882
8900
|
entrySurface: this.options.entrySurface,
|
|
@@ -1574,7 +1574,7 @@ function wc(t, e, n = "stopped", i) {
|
|
|
1574
1574
|
t.messages.filter((r) => r.role === "user").slice(-1)[0]?.id
|
|
1575
1575
|
].filter((r) => !!r)), o = t.messages.filter((r) => !(r.dataType === "run_status" && r.loading && s.has(r.respondsToUserMessageId ?? ""))).map((r) => s.has(r.respondsToUserMessageId ?? "") ? { ...r, loading: !1 } : r);
|
|
1576
1576
|
for (const r of s)
|
|
1577
|
-
o.some((c) => c.respondsToUserMessageId === r && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary")) || o.some((c) => c.role === "user" && c.id === r) && o.push({ id: `local-interrupted:${r}`, role: "system", dataType: "run_status", content: n === "stopping" ? "Stopping…" : "Run stopped by user.", createdAt: e, respondsToUserMessageId: r });
|
|
1577
|
+
o.some((c) => c.respondsToUserMessageId === r && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary")) || o.some((c) => c.role === "user" && c.id === r) && o.push({ id: `local-interrupted:${r}`, role: "system", dataType: "run_status", provisional: n === "stopping", content: n === "stopping" ? "Stopping…" : "Run stopped by user.", createdAt: e, respondsToUserMessageId: r });
|
|
1578
1578
|
const a = t.segments?.map((r) => ({ ...r, outcomeIds: [
|
|
1579
1579
|
...r.outcomeIds,
|
|
1580
1580
|
...o.filter((c) => c.id === `local-interrupted:${r.userMessageId}` && !r.outcomeIds.includes(c.id)).map((c) => c.id)
|
|
@@ -1820,7 +1820,7 @@ function Op(t) {
|
|
|
1820
1820
|
return e() && i.directory.memberships[n]?.members.length ? i.conversation.sessions[n] ?? null : null;
|
|
1821
1821
|
}, t.invalidateAuth), async (n) => (!e() || n.authorityId !== t.authority.authorityId || n.generation !== t.authority.generation || !t.runtime().engine.getState().slices.directory.memberships[n.sessionId]?.members.length || (t.manager.receiveConversationSources(n.sources), t.notify()), null);
|
|
1822
1822
|
}
|
|
1823
|
-
const Ql = "0.1.
|
|
1823
|
+
const Ql = "0.1.240", Np = {
|
|
1824
1824
|
version: Ql
|
|
1825
1825
|
}, Tt = /* @__PURE__ */ Object.create(null);
|
|
1826
1826
|
Tt.open = "0";
|
|
@@ -4158,8 +4158,11 @@ class qh {
|
|
|
4158
4158
|
forceNew: !0,
|
|
4159
4159
|
auth: { ...e.auth },
|
|
4160
4160
|
reconnection: e.reconnect ?? !0
|
|
4161
|
-
}), this.socket.io.on("reconnect_attempt", () => this.beginAttempt()), this.socket.io.on("close", () => {
|
|
4162
|
-
this.
|
|
4161
|
+
}), this.socket.io.on("reconnect_attempt", () => this.beginAttempt()), this.socket.io.on("close", (n) => {
|
|
4162
|
+
const i = this.generation, s = this.attempt;
|
|
4163
|
+
n === "forced close" ? queueMicrotask(() => {
|
|
4164
|
+
i === this.generation && s === this.attempt && this.invalidate(!1, n);
|
|
4165
|
+
}) : this.invalidate(!1, n), this.restoreBackoff();
|
|
4163
4166
|
}), this.socket.io.on("reconnect", () => this.restoreBackoff()), this.socket.on("connection.ready", (n) => {
|
|
4164
4167
|
if (n.protocol !== 1 || n.role !== this.options.auth.role || n.display_projection_ready !== !1) {
|
|
4165
4168
|
this.options.onError(new O("Unsupported Product Agent transport negotiation", "protocol_error")), this.disconnect();
|
|
@@ -4169,7 +4172,8 @@ class qh {
|
|
|
4169
4172
|
}), this.socket.on("connect", () => {
|
|
4170
4173
|
this.active = !0, this.activate();
|
|
4171
4174
|
}), this.socket.on("disconnect", (n) => this.invalidate(
|
|
4172
|
-
n === "io client disconnect" && !this.replacingCredentials
|
|
4175
|
+
n === "io client disconnect" && !this.replacingCredentials,
|
|
4176
|
+
n
|
|
4173
4177
|
)), this.socket.on("connect_error", (n) => {
|
|
4174
4178
|
const i = n.data?.code;
|
|
4175
4179
|
if (i === "unauthorized" && n.data?.reason === "token_expired" && n.data.retryable === !0) {
|
|
@@ -4177,7 +4181,7 @@ class qh {
|
|
|
4177
4181
|
return;
|
|
4178
4182
|
}
|
|
4179
4183
|
if (!i || n.data?.retryable === !0) {
|
|
4180
|
-
if (this.invalidate(!1), this.options.reconnect === !1)
|
|
4184
|
+
if (this.invalidate(!1, "connect_error"), this.options.reconnect === !1)
|
|
4181
4185
|
this.socket.disconnect();
|
|
4182
4186
|
else {
|
|
4183
4187
|
const s = this.socket.io;
|
|
@@ -4260,10 +4264,10 @@ class qh {
|
|
|
4260
4264
|
}
|
|
4261
4265
|
}
|
|
4262
4266
|
replaceCredentials(e, n) {
|
|
4263
|
-
this.replacingCredentials = !0, this.invalidate(!1), this.socket.disconnect(), this.replacingCredentials = !1, this.invalidate(!1), n && this.bindings.clear(), this.options.auth = { ...e }, this.socket.auth = { ...e }, this.connect();
|
|
4267
|
+
this.replacingCredentials = !0, this.invalidate(!1, "credential_replacement"), this.socket.disconnect(), this.replacingCredentials = !1, this.invalidate(!1, "credential_replacement"), n && this.bindings.clear(), this.options.auth = { ...e }, this.socket.auth = { ...e }, this.connect();
|
|
4264
4268
|
}
|
|
4265
4269
|
suspend() {
|
|
4266
|
-
this.replacingCredentials = !0, this.invalidate(!1), this.socket.disconnect(), this.replacingCredentials = !1, this.invalidate(!1);
|
|
4270
|
+
this.replacingCredentials = !0, this.invalidate(!1, "local_suspend"), this.socket.disconnect(), this.replacingCredentials = !1, this.invalidate(!1, "local_suspend");
|
|
4267
4271
|
}
|
|
4268
4272
|
disconnect() {
|
|
4269
4273
|
this.invalidate(!0), this.socket.disconnect();
|
|
@@ -4281,8 +4285,8 @@ class qh {
|
|
|
4281
4285
|
const e = this.socket.io;
|
|
4282
4286
|
e.backoff.attempts = Math.min(20, Math.max(0, this.attemptCount - 1));
|
|
4283
4287
|
}
|
|
4284
|
-
recover() {
|
|
4285
|
-
!this.active || this.retired || (this.invalidate(!1), this.socket.io.engine.close());
|
|
4288
|
+
recover(e = "local_recovery") {
|
|
4289
|
+
!this.active || this.retired || (this.invalidate(!1, e), this.socket.io.engine.close());
|
|
4286
4290
|
}
|
|
4287
4291
|
beginAttempt() {
|
|
4288
4292
|
this.clearReadinessTimers(), this.active = !0, this.attempt = { connectionAttemptId: crypto.randomUUID(), reconnectAttempt: this.attemptCount++, startedAt: Date.now() }, this.socket.auth = { ...this.options.auth, connection_attempt_id: this.attempt.connectionAttemptId }, this.options.onAttempt?.(this.attempt);
|
|
@@ -4291,7 +4295,7 @@ class qh {
|
|
|
4291
4295
|
retryable: !0,
|
|
4292
4296
|
...this.attempt,
|
|
4293
4297
|
readinessPhase: this.ready ? "bootstrap" : this.admitted ? "activation" : "namespace_ready"
|
|
4294
|
-
})), e === this.generation && this.recover());
|
|
4298
|
+
})), e === this.generation && this.recover(i));
|
|
4295
4299
|
};
|
|
4296
4300
|
this.admissionTimer = setTimeout(() => n("connect_timeout"), 15e3), this.readinessTimer = setTimeout(() => n("auth_timeout"), Ph);
|
|
4297
4301
|
}
|
|
@@ -4339,7 +4343,7 @@ class qh {
|
|
|
4339
4343
|
}
|
|
4340
4344
|
activationFailed(e) {
|
|
4341
4345
|
const n = this.generation;
|
|
4342
|
-
this.options.onError(e), n === this.generation && ((e.outcomeUnknown || e.detail?.retryable === !0) && this.options.reconnect !== !1 ? this.
|
|
4346
|
+
this.options.onError(e), n === this.generation && ((e.outcomeUnknown || e.detail?.retryable === !0) && this.options.reconnect !== !1 ? this.recover("local_activation_failure") : this.disconnect());
|
|
4343
4347
|
}
|
|
4344
4348
|
synchronize(e = !1) {
|
|
4345
4349
|
const n = this.generation;
|
|
@@ -4431,13 +4435,13 @@ class qh {
|
|
|
4431
4435
|
});
|
|
4432
4436
|
}
|
|
4433
4437
|
recoverUncertainDelivery(e, n) {
|
|
4434
|
-
e instanceof O && (e.outcomeUnknown || e.code === "backpressure" && !e.backendRefusal) && n === this.generation && this.active && this.
|
|
4438
|
+
e instanceof O && (e.outcomeUnknown || e.code === "backpressure" && !e.backendRefusal) && n === this.generation && this.active && this.recover(e.code === "backpressure" ? "local_backpressure" : "local_delivery_uncertain");
|
|
4435
4439
|
}
|
|
4436
|
-
invalidate(e = !1) {
|
|
4440
|
+
invalidate(e = !1, n = "local_invalidation") {
|
|
4437
4441
|
if (this.clearReadinessTimers(), !!this.active) {
|
|
4438
4442
|
this.active = !1, this.generation++, this.ready = null, this.admitted = null, this.activating = !1;
|
|
4439
|
-
for (const
|
|
4440
|
-
this.options.onDisconnect(e);
|
|
4443
|
+
for (const i of [...this.pending]) i(new O("Connection lost before acknowledgement", "delivery_unknown", !0));
|
|
4444
|
+
this.options.onDisconnect(e, n);
|
|
4441
4445
|
}
|
|
4442
4446
|
}
|
|
4443
4447
|
}
|
|
@@ -4980,12 +4984,12 @@ class Te extends EventTarget {
|
|
|
4980
4984
|
onReady: () => {
|
|
4981
4985
|
this.readyState !== 3 && (this.readyState = 1, this.dispatchEvent(new Event("open")));
|
|
4982
4986
|
},
|
|
4983
|
-
onDisconnect: (n) => {
|
|
4987
|
+
onDisconnect: (n, i) => {
|
|
4984
4988
|
if (n) {
|
|
4985
4989
|
this.finishClose(!0);
|
|
4986
4990
|
return;
|
|
4987
4991
|
}
|
|
4988
|
-
this.readyState !== 3 && (this.resetBootstrap(), this.readyState = 0, this.initialized = !1, this.bootstrapped = !1, this.beforeBootstrap.length = 0, this.rejectToolReceipts(), this.dispatchEvent(new
|
|
4992
|
+
this.readyState !== 3 && (this.resetBootstrap(), this.readyState = 0, this.initialized = !1, this.bootstrapped = !1, this.beforeBootstrap.length = 0, this.rejectToolReceipts(), this.dispatchEvent(new CustomEvent("reconnecting", { detail: { reason: i } })));
|
|
4989
4993
|
},
|
|
4990
4994
|
onEvent: (n, i) => {
|
|
4991
4995
|
const s = i, o = s.sessionId ?? s.session?.id ?? s.item?.sessionId, a = this.hydration;
|
|
@@ -7508,8 +7512,8 @@ class Qr {
|
|
|
7508
7512
|
});
|
|
7509
7513
|
this.socket = o, this.options.webSocketFactory && (this.socketConnectTimer = window.setTimeout(() => {
|
|
7510
7514
|
this.socket === o && o.readyState === WebSocket.CONNECTING && (Me("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(o));
|
|
7511
|
-
}, lf)), o.addEventListener("reconnecting", () => {
|
|
7512
|
-
this.socket === o && this.state.status !== "closed" && (this.refreshingDefaultCredentials || this.reportTransportDiagnostic("socket_closed", {
|
|
7515
|
+
}, lf)), o.addEventListener("reconnecting", (a) => {
|
|
7516
|
+
this.socket === o && this.state.status !== "closed" && (this.refreshingDefaultCredentials || this.reportTransportDiagnostic("socket_closed", { disconnectReason: a.detail.reason }), this.setReconnectingState());
|
|
7513
7517
|
}), o.addEventListener("open", () => {
|
|
7514
7518
|
this.socket !== o || (this.clearSocketConnectTimer(), this.directoryObservation.reconnect().catch(() => {
|
|
7515
7519
|
}), this.conversationObservation?.wake(), Me("web-sdk.agent", "Pluno socket opened", {
|
|
@@ -8411,7 +8415,7 @@ class Qr {
|
|
|
8411
8415
|
}
|
|
8412
8416
|
/** @internal */
|
|
8413
8417
|
reportTransportDiagnostic(e, n = {}) {
|
|
8414
|
-
const i = typeof navigator > "u" ? "unknown" : navigator.onLine === !1 ? "offline" : "online", s = `${e}:${n.requestId ?? n.connectionAttemptId ?? "none"}:${n.closeCode ?? "none"}:${i}`, o = (/* @__PURE__ */ new Date()).toISOString(), a = this.transportDiagnosticEpisodes.get(s), r = {
|
|
8418
|
+
const i = typeof navigator > "u" ? "unknown" : navigator.onLine === !1 ? "offline" : "online", s = `${e}:${n.requestId ?? n.connectionAttemptId ?? "none"}:${n.closeCode ?? "none"}:${n.disconnectReason ?? "none"}:${i}`, o = (/* @__PURE__ */ new Date()).toISOString(), a = this.transportDiagnosticEpisodes.get(s), r = {
|
|
8415
8419
|
id: a?.id ?? crypto.randomUUID(),
|
|
8416
8420
|
phase: e,
|
|
8417
8421
|
entrySurface: this.options.entrySurface,
|
|
@@ -14928,7 +14932,7 @@ function Xw(t, e, n, i, s, o, a, r, c, u, p, l, h, g, y, f, w, b, _, T, x, A, q,
|
|
|
14928
14932
|
Ae.classList.add("pluno-pa-widget__terminal-marker"), G(Ae);
|
|
14929
14933
|
}
|
|
14930
14934
|
const V = document.createElement("div"), Se = k.dataType === "run_error";
|
|
14931
|
-
if (V.className = Se ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", V.dataset.messageKey = ca(k), V.dataset.canonicalItemKey = k.id, V.dataset.messageRole = "system", V.dataset.terminalResponseKey = hu(k), k.runId && (V.dataset.runId = k.runId), V.textContent = Ls(
|
|
14935
|
+
if (V.className = Se ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", V.dataset.messageKey = ca(k), V.dataset.canonicalItemKey = k.id, V.dataset.messageRole = "system", k.provisional || (V.dataset.terminalResponseKey = hu(k)), k.runId && (V.dataset.runId = k.runId), V.textContent = Ls(
|
|
14932
14936
|
k.content
|
|
14933
14937
|
), Se && k.securitySettingsUrl) {
|
|
14934
14938
|
const Ae = document.createElement("a");
|
package/dist/runtimeClient.d.ts
CHANGED
|
@@ -182,6 +182,7 @@ export declare class ProductAgentRemoteRuntimeClient implements ProductAgentRunt
|
|
|
182
182
|
private submissionGeneration;
|
|
183
183
|
private pendingStop;
|
|
184
184
|
private stopError;
|
|
185
|
+
private readonly stopPreviews;
|
|
185
186
|
private operationQueue;
|
|
186
187
|
private destroyed;
|
|
187
188
|
constructor(initialState: ProductAgentState, adapter: ProductAgentRuntimeClientAdapter, model?: ProductAgentModel);
|
package/package.json
CHANGED