@pluno/product-agent-web 0.1.213 → 0.1.214

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.
@@ -344,7 +344,7 @@ function mn(s, e, t) {
344
344
  for (const h of s) {
345
345
  const p = t(h);
346
346
  let y = o.get(p.id);
347
- if (p.isOptimistic && p.optimisticKey ? y = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? y = l.get(p.assistantDraftKey) : p.isActivity && (y = p.activityKeys?.map((M) => c.get(M)).find((M) => M !== void 0) ?? y), y && !g.has(y)) {
347
+ if (p.isOptimistic && p.optimisticKey ? y = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? y = l.get(p.assistantDraftKey) : p.isActivity && (y = p.activityKeys?.map((b) => c.get(b)).find((b) => b !== void 0) ?? y), y && !g.has(y)) {
348
348
  f.push(y), g.add(y);
349
349
  continue;
350
350
  }
@@ -431,13 +431,13 @@ function An() {
431
431
  }
432
432
  function ys() {
433
433
  return {
434
- storage: Mn(),
435
- channel: bn(),
434
+ storage: bn(),
435
+ channel: Mn(),
436
436
  randomUUID: () => crypto.randomUUID(),
437
437
  settle: () => new Promise((s) => Sn(s, In))
438
438
  };
439
439
  }
440
- function Mn() {
440
+ function bn() {
441
441
  return {
442
442
  getItem: (s) => {
443
443
  try {
@@ -455,7 +455,7 @@ function Mn() {
455
455
  }
456
456
  };
457
457
  }
458
- function bn() {
458
+ function Mn() {
459
459
  if (typeof BroadcastChannel < "u") {
460
460
  const s = new BroadcastChannel(yn);
461
461
  return {
@@ -973,7 +973,7 @@ class Ln {
973
973
  async applyAction(e, t, n) {
974
974
  if (!e.allowedActions.includes(t))
975
975
  throw new Error(`Interaction ${e.key} does not allow ${t}.`);
976
- if (!Ms(t))
976
+ if (!bs(t))
977
977
  throw new Error(`Interaction action ${t} is not a persistence decision.`);
978
978
  const i = n.now ?? /* @__PURE__ */ new Date(), r = {
979
979
  promptKey: e.key,
@@ -1024,13 +1024,13 @@ function Nn(s, e) {
1024
1024
  function Je(s) {
1025
1025
  return `${s.level}:${s.key}`;
1026
1026
  }
1027
- function Ms(s) {
1027
+ function bs(s) {
1028
1028
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
1029
1029
  }
1030
1030
  function ot(s) {
1031
1031
  if (!s || typeof s != "object") return !1;
1032
1032
  const e = s;
1033
- return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && Ms(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
1033
+ return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && bs(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
1034
1034
  }
1035
1035
  const Hn = {
1036
1036
  working: "⏳",
@@ -1152,7 +1152,7 @@ function Bo(s) {
1152
1152
  case "conversation.fail_staged":
1153
1153
  return typeof e.clientMessageId == "string" && typeof e.message == "string";
1154
1154
  case "conversation.send":
1155
- return typeof e.content == "string" && typeof e.clientMessageId == "string" && (e.attachments === void 0 || Array.isArray(e.attachments));
1155
+ return typeof e.content == "string" && typeof e.clientMessageId == "string" && (e.automationOnboarding === void 0 || typeof e.automationOnboarding == "boolean") && (e.attachments === void 0 || Array.isArray(e.attachments));
1156
1156
  default:
1157
1157
  return !1;
1158
1158
  }
@@ -1307,6 +1307,7 @@ class Fo {
1307
1307
  initiatedBy: t.initiatedBy,
1308
1308
  invocation: t.invocation,
1309
1309
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1310
+ ...t.automationOnboarding ? { automationOnboarding: !0 } : {},
1310
1311
  attachments: o.length > 0 ? o : void 0
1311
1312
  });
1312
1313
  for (const c of t.attachments ?? [])
@@ -1580,14 +1581,14 @@ class Te extends Error {
1580
1581
  function Xn(s) {
1581
1582
  return s === 408 || s === 425 || s === 429 || s >= 500;
1582
1583
  }
1583
- const Yn = "https://app.pluno.ai", Zn = 2e4, ei = 1e4, ti = 6e4, si = 6e4, ni = 1e4, ii = 1e4, ri = 3e3, oi = 3e4, ai = 1e3, at = 3e4, jt = 0.2, li = 6e4, zt = 15e3, ci = 6e4, ui = 8, di = "Browser connection was interrupted.", Kt = 15e3, hi = "Pluno could not send this message. Try it again.", pi = "Still connecting to Pluno. Retrying automatically.", gi = 2e3, fi = 1e3, mi = 100, Gt = 8e3, Vt = 3, yi = [300, 1e3], bs = 50 * 1024 * 1024, Ii = /* @__PURE__ */ new Set([
1584
+ const Yn = "https://app.pluno.ai", Zn = 2e4, ei = 1e4, ti = 6e4, si = 6e4, ni = 1e4, ii = 1e4, ri = 3e3, oi = 3e4, ai = 1e3, at = 3e4, jt = 0.2, li = 6e4, zt = 15e3, ci = 6e4, ui = 8, di = "Browser connection was interrupted.", Kt = 15e3, hi = "Pluno could not send this message. Try it again.", pi = "Still connecting to Pluno. Retrying automatically.", gi = 2e3, fi = 1e3, mi = 100, Gt = 8e3, Vt = 3, yi = [300, 1e3], Ms = 50 * 1024 * 1024, Ii = /* @__PURE__ */ new Set([
1584
1585
  ".jpeg:image/jpeg",
1585
1586
  ".jpg:image/jpeg",
1586
1587
  ".pdf:application/pdf",
1587
1588
  ".png:image/png",
1588
1589
  ".webp:image/webp"
1589
- ]), Wo = ".pdf,.png,.jpg,.jpeg,.webp", wt = 64e3, Ye = 4e3, At = 30, Si = 2e3, Ti = 1e3, Rs = "Image is too large for model vision input.", wi = 100, Ai = 20, ks = "pluno.productAgent.state.", lt = "pluno.productAgent.pendingEvents.", Le = "pluno.productAgent.activeToolCalls.", Mi = 100;
1590
- function bi(s, e = 0) {
1590
+ ]), Wo = ".pdf,.png,.jpg,.jpeg,.webp", wt = 64e3, Ye = 4e3, At = 30, Si = 2e3, Ti = 1e3, Rs = "Image is too large for model vision input.", wi = 100, Ai = 20, ks = "pluno.productAgent.state.", lt = "pluno.productAgent.pendingEvents.", Le = "pluno.productAgent.activeToolCalls.", bi = 100;
1591
+ function Mi(s, e = 0) {
1591
1592
  const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
1592
1593
  return Math.max(e, t);
1593
1594
  }
@@ -1858,7 +1859,7 @@ class Ne {
1858
1859
  }, n);
1859
1860
  try {
1860
1861
  on().catch((r) => {
1861
- b("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
1862
+ M("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
1862
1863
  message: r instanceof Error ? r.message : String(r)
1863
1864
  });
1864
1865
  }), t.disableNetworkCapture || i.enableNetworkCapture(), i.startPageLifecycleRecovery(), i.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await i.connect();
@@ -1957,9 +1958,9 @@ class Ne {
1957
1958
  throw new J("Pluno requires a token or tokenProvider", !1);
1958
1959
  const t = Yi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1959
1960
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
1960
- this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(n));
1961
+ this.socket === n && n.readyState === WebSocket.CONNECTING && (M("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(n));
1961
1962
  }, ni), n.addEventListener("open", () => {
1962
- this.socket !== n || (this.clearSocketConnectTimer(), b("web-sdk.agent", "Pluno socket opened", {
1963
+ this.socket !== n || (this.clearSocketConnectTimer(), M("web-sdk.agent", "Pluno socket opened", {
1963
1964
  queuedClientEventCount: this.queuedClientEvents.length,
1964
1965
  isThinking: this.state.isThinking
1965
1966
  }), !(this.token ? this.sendNow({
@@ -1969,7 +1970,7 @@ class Ne {
1969
1970
  transportId: this.transportIdentity.transportId,
1970
1971
  pageUrl: location.href
1971
1972
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
1972
- this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.reportTransportDiagnostic("auth_timeout"), this.replaceTimedOutSocket(n));
1973
+ this.socket === n && (M("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.reportTransportDiagnostic("auth_timeout"), this.replaceTimedOutSocket(n));
1973
1974
  }, ii));
1974
1975
  }), n.addEventListener("message", (i) => {
1975
1976
  this.socket === n && this.handleServerEvent(ar(i.data));
@@ -1981,7 +1982,7 @@ class Ne {
1981
1982
  (o) => o.type === "chat.user_message" && o.clientMessageId === r.clientMessageId
1982
1983
  ) && (this.queuedClientEvents.push(r), Q(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
1983
1984
  }), n.addEventListener("close", (i) => {
1984
- this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (b("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
1985
+ this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (M("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
1985
1986
  code: typeof i?.code == "number" ? i.code : null,
1986
1987
  reason: typeof i?.reason == "string" ? i.reason : "",
1987
1988
  wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : null,
@@ -1992,7 +1993,7 @@ class Ne {
1992
1993
  wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : void 0
1993
1994
  }), this.setReconnectingState(), this.scheduleReconnect()));
1994
1995
  }), n.addEventListener("error", () => {
1995
- this.socket !== n || this.state.status === "closed" || (b("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
1996
+ this.socket !== n || this.state.status === "closed" || (M("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
1996
1997
  queuedClientEventCount: this.queuedClientEvents.length,
1997
1998
  isThinking: this.state.isThinking
1998
1999
  }), this.reportTransportDiagnostic("socket_error"), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
@@ -2002,7 +2003,7 @@ class Ne {
2002
2003
  return;
2003
2004
  const n = Ci(t);
2004
2005
  if (Ei(t)) {
2005
- b("web-sdk.agent", "Pluno connection attempt failed; retrying", {
2006
+ M("web-sdk.agent", "Pluno connection attempt failed; retrying", {
2006
2007
  message: n.message,
2007
2008
  reconnectAttempt: this.reconnectAttempts
2008
2009
  }), t instanceof J && this.reportTransportDiagnostic("auth_timeout"), this.setState({
@@ -2078,7 +2079,7 @@ class Ne {
2078
2079
  if (this.options.productVariant === "customer_embedded" && (i.forEach(Hs), i.reduce(
2079
2080
  (T, N) => T + N.sizeBytes,
2080
2081
  0
2081
- ) > bs))
2082
+ ) > Ms))
2082
2083
  throw new Error("Embedded attachments must total at most 50 MB per message");
2083
2084
  let r = i.map(qe);
2084
2085
  if (!n && r.length === 0)
@@ -2099,7 +2100,7 @@ class Ne {
2099
2100
  content: n,
2100
2101
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2101
2102
  ...i.length > 0 ? { attachments: i } : {}
2102
- }, g = this.state.messages.some((S) => S.id === d.id || S.clientMessageId === a), f = this.state.isThinking, h = this.state.taskStatus, p = this.state.pendingMessageStatus, y = this.state.turnPhase, m = this.state.messages, M = g ? this.state.messages : [
2103
+ }, g = this.state.messages.some((S) => S.id === d.id || S.clientMessageId === a), f = this.state.isThinking, h = this.state.taskStatus, p = this.state.pendingMessageStatus, y = this.state.turnPhase, m = this.state.messages, b = g ? this.state.messages : [
2103
2104
  ...this.state.messages.map(
2104
2105
  (S) => c && S.id === c.id ? {
2105
2106
  ...S,
@@ -2117,7 +2118,7 @@ class Ne {
2117
2118
  lastError: this.state.lastError
2118
2119
  };
2119
2120
  this.setState({
2120
- messages: M,
2121
+ messages: b,
2121
2122
  ...f ? {} : {
2122
2123
  assistantDraft: "",
2123
2124
  assistantDraftItemId: null,
@@ -2175,11 +2176,14 @@ class Ne {
2175
2176
  entrySurface: this.options.entrySurface,
2176
2177
  content: n,
2177
2178
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
2178
- pageContent: D && Mt() || void 0,
2179
+ pageContent: D && bt() || void 0,
2179
2180
  attachments: r.length > 0 ? r.map(qe) : void 0,
2180
2181
  page: o,
2181
2182
  model: this.options.model,
2182
- metadata: Qt(this.options.metadata)
2183
+ metadata: {
2184
+ ...Qt(this.options.metadata),
2185
+ ...t.automationOnboarding ? { automationOnboarding: !0 } : {}
2186
+ }
2183
2187
  };
2184
2188
  return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
2185
2189
  } });
@@ -2243,7 +2247,7 @@ class Ne {
2243
2247
  createdAt: i,
2244
2248
  lastUsedAt: i
2245
2249
  }).catch((r) => {
2246
- b("web-sdk.attachments", "Failed to store Product Agent attachment", {
2250
+ M("web-sdk.attachments", "Failed to store Product Agent attachment", {
2247
2251
  attachmentId: t,
2248
2252
  name: n.name,
2249
2253
  message: r instanceof Error ? r.message : String(r)
@@ -2276,16 +2280,16 @@ class Ne {
2276
2280
  };
2277
2281
  let o;
2278
2282
  if (this.options.persistAttachmentUpload)
2279
- o = await be(
2283
+ o = await Me(
2280
2284
  () => this.options.persistAttachmentUpload(r, e),
2281
2285
  "Failed to upload attachment"
2282
2286
  );
2283
2287
  else {
2284
- const l = this.options.prepareAttachmentUpload ? await be(
2288
+ const l = this.options.prepareAttachmentUpload ? await Me(
2285
2289
  () => this.options.prepareAttachmentUpload(r),
2286
2290
  "Failed to prepare attachment upload"
2287
2291
  ) : await this.prepareEmbedAttachmentUpload(r);
2288
- await be(async () => {
2292
+ await Me(async () => {
2289
2293
  const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
2290
2294
  method: l.uploadMethod,
2291
2295
  headers: l.uploadHeaders,
@@ -2305,7 +2309,7 @@ class Ne {
2305
2309
  storageKey: a.storageKey,
2306
2310
  lastUsedAt: Date.now()
2307
2311
  }).catch((l) => {
2308
- b("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
2312
+ M("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
2309
2313
  attachmentId: t.id,
2310
2314
  name: a.name,
2311
2315
  message: l instanceof Error ? l.message : String(l)
@@ -2325,7 +2329,7 @@ class Ne {
2325
2329
  }
2326
2330
  async prepareEmbedAttachmentUpload(e) {
2327
2331
  let t = !1;
2328
- return await be(async () => {
2332
+ return await Me(async () => {
2329
2333
  const n = await this.fetchEmbedAttachmentUpload(e, !1);
2330
2334
  if (n.ok)
2331
2335
  return await n.json();
@@ -2370,7 +2374,7 @@ class Ne {
2370
2374
  stoppedCausalSequence: null,
2371
2375
  toolCallIds: new Set(
2372
2376
  this.state.messages.filter(
2373
- (t) => Me(
2377
+ (t) => be(
2374
2378
  t,
2375
2379
  e.respondsToUserMessageId,
2376
2380
  e.runId
@@ -2790,7 +2794,7 @@ class Ne {
2790
2794
  } catch (o) {
2791
2795
  if (o instanceof Te)
2792
2796
  throw o;
2793
- b("web-sdk.history", "HTTP session history page failed; retrying", {
2797
+ M("web-sdk.history", "HTTP session history page failed; retrying", {
2794
2798
  sessionId: e,
2795
2799
  hasCursor: !!n,
2796
2800
  retryDelayMs: r,
@@ -2833,7 +2837,7 @@ class Ne {
2833
2837
  return;
2834
2838
  const r = n instanceof Error ? n.message : String(n);
2835
2839
  if (i) {
2836
- this.sessionActivityRequestId = null, b("web-sdk.history", "Background session activity hydration stopped", {
2840
+ this.sessionActivityRequestId = null, M("web-sdk.history", "Background session activity hydration stopped", {
2837
2841
  sessionId: t,
2838
2842
  message: r
2839
2843
  });
@@ -2845,7 +2849,7 @@ class Ne {
2845
2849
  message: r,
2846
2850
  requestId: e,
2847
2851
  sessionId: t
2848
- }), b("web-sdk.history", "HTTP session history page failed permanently", {
2852
+ }), M("web-sdk.history", "HTTP session history page failed permanently", {
2849
2853
  sessionId: t,
2850
2854
  message: r
2851
2855
  });
@@ -2873,7 +2877,7 @@ class Ne {
2873
2877
  try {
2874
2878
  return t.send(JSON.stringify(e)), Se("client_event", e.type, $t(e)), !0;
2875
2879
  } catch (n) {
2876
- return b("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2880
+ return M("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2877
2881
  message: n instanceof Error ? n.message : String(n),
2878
2882
  queuedClientEventCount: this.queuedClientEvents.length,
2879
2883
  isThinking: this.state.isThinking
@@ -2908,7 +2912,7 @@ class Ne {
2908
2912
  signal: i
2909
2913
  }));
2910
2914
  } catch (r) {
2911
- b("web-sdk.agent", "Pluno health signal send failed", {
2915
+ M("web-sdk.agent", "Pluno health signal send failed", {
2912
2916
  name: e,
2913
2917
  message: r instanceof Error ? r.message : String(r)
2914
2918
  }), this.queueHealthDiagnostic(i);
@@ -3048,7 +3052,7 @@ class Ne {
3048
3052
  const e = location.href;
3049
3053
  e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
3050
3054
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
3051
- }, Mi));
3055
+ }, bi));
3052
3056
  }
3053
3057
  refreshStarterPromptsForCurrentUrl() {
3054
3058
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -3144,7 +3148,7 @@ class Ne {
3144
3148
  stoppedCausalSequence: P(n),
3145
3149
  toolCallIds: new Set(
3146
3150
  this.state.messages.filter(
3147
- (a) => Me(a, i, r)
3151
+ (a) => be(a, i, r)
3148
3152
  ).map((a) => a.callId).filter((a) => typeof a == "string")
3149
3153
  )
3150
3154
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
@@ -3252,7 +3256,7 @@ class Ne {
3252
3256
  const t = fr(e.user);
3253
3257
  this.authenticatedSocket !== this.socket && this.authenticatedUserId && t && t.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = t?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingWidgetLifecycleEvents(), this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
3254
3258
  const n = ur(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
3255
- b("web-sdk.agent", "Received auth.ok appearance", {
3259
+ M("web-sdk.agent", "Received auth.ok appearance", {
3256
3260
  hasAppearance: i,
3257
3261
  rawAppearance: e.appearance,
3258
3262
  normalizedAppearance: n
@@ -3307,14 +3311,14 @@ class Ne {
3307
3311
  runId: u?.runId
3308
3312
  }), g = this.filterStoppedSnapshotItems(n, r), f = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, h = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, y = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
3309
3313
  f && h && (this.pendingClientMessageId = h);
3310
- let m = Mr(
3314
+ let m = br(
3311
3315
  e.assistantDraft
3312
3316
  );
3313
3317
  m && this.findStoppedTurn(r, {
3314
3318
  respondsToUserMessageId: m.respondsToUserMessageId,
3315
3319
  runId: m.runId
3316
3320
  }) && (m = void 0);
3317
- const M = m !== void 0;
3321
+ const b = m !== void 0;
3318
3322
  this.rememberUserMessageClientMessageIds(g);
3319
3323
  const w = xr(g), D = g.filter((U) => {
3320
3324
  const q = C(U);
@@ -3322,7 +3326,7 @@ class Ne {
3322
3326
  }), S = ct(
3323
3327
  this.state.messages,
3324
3328
  st(D, this.options.backendUrl)
3325
- ), T = rs(S), N = M ? m?.content ?? "" : this.state.assistantDraft, v = M ? m?.itemId ?? null : this.state.assistantDraftItemId, re = M ? m?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, Y = M ? m?.runId ?? null : this.state.assistantDraftRunId, Z = g.some(
3329
+ ), T = rs(S), N = b ? m?.content ?? "" : this.state.assistantDraft, v = b ? m?.itemId ?? null : this.state.assistantDraftItemId, re = b ? m?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, Y = b ? m?.runId ?? null : this.state.assistantDraftRunId, Z = g.some(
3326
3330
  (U, q) => os(
3327
3331
  C(U),
3328
3332
  N,
@@ -3331,7 +3335,7 @@ class Ne {
3331
3335
  Y,
3332
3336
  Lr(g, q)
3333
3337
  )
3334
- ), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), V = Ur(S), oe = B && V ? "completed" : d ? "stopped" : B ? "failed" : null;
3338
+ ), ee = b ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), V = Ur(S), oe = B && V ? "completed" : d ? "stopped" : B ? "failed" : null;
3335
3339
  if (!T && Or(this.state.messages, g))
3336
3340
  return;
3337
3341
  this.lastUserMessagePageUrl = Dr(g);
@@ -3356,7 +3360,7 @@ class Ne {
3356
3360
  assistantDraftPhase: null,
3357
3361
  assistantDraftRespondsToUserMessageId: null,
3358
3362
  assistantDraftRunId: null
3359
- } : M ? {
3363
+ } : b ? {
3360
3364
  assistantDraft: m?.content ?? "",
3361
3365
  assistantDraftItemId: m?.itemId ?? null,
3362
3366
  assistantDraftPhase: m?.phase ?? null,
@@ -3521,7 +3525,7 @@ class Ne {
3521
3525
  return;
3522
3526
  const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !i || i === this.activeResponseRunId), l = xt(
3523
3527
  this.state.messages.filter(
3524
- (c) => c.dataType !== "assistant_draft" || !Me(
3528
+ (c) => c.dataType !== "assistant_draft" || !be(
3525
3529
  c,
3526
3530
  n,
3527
3531
  i
@@ -3765,7 +3769,7 @@ class Ne {
3765
3769
  if (e.type === "chat.assistant_done") {
3766
3770
  const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = xt(
3767
3771
  n.filter(
3768
- (a) => a.dataType !== "assistant_draft" || !Me(a, i, r)
3772
+ (a) => a.dataType !== "assistant_draft" || !be(a, i, r)
3769
3773
  ),
3770
3774
  i,
3771
3775
  r,
@@ -3967,7 +3971,7 @@ class Ne {
3967
3971
  }
3968
3972
  t === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = t + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
3969
3973
  this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
3970
- }, bi(t, gi));
3974
+ }, Mi(t, gi));
3971
3975
  }
3972
3976
  failPendingDelivery(e) {
3973
3977
  if (this.pendingClientMessageId !== e)
@@ -4021,7 +4025,7 @@ class Ne {
4021
4025
  }, Kt);
4022
4026
  }
4023
4027
  recoverMissedRunAck(e) {
4024
- !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (b("web-sdk.agent", "Pluno run ack missed; resyncing session", {
4028
+ !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (M("web-sdk.agent", "Pluno run ack missed; resyncing session", {
4025
4029
  sessionId: this.state.sessionId,
4026
4030
  clientMessageId: e
4027
4031
  }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(zt));
@@ -4037,7 +4041,7 @@ class Ne {
4037
4041
  return;
4038
4042
  const e = this.activeClientMessageId;
4039
4043
  if (!e) {
4040
- b("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
4044
+ M("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
4041
4045
  sessionId: this.state.sessionId
4042
4046
  }), this.reportHealthSignal("run_recovery_exhausted", {
4043
4047
  reason: "missing_client_message_id"
@@ -4053,7 +4057,7 @@ class Ne {
4053
4057
  return;
4054
4058
  }
4055
4059
  const t = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0;
4056
- this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = t + 1, b("web-sdk.agent", "Pluno thinking watchdog resyncing authoritative session state", {
4060
+ this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = t + 1, M("web-sdk.agent", "Pluno thinking watchdog resyncing authoritative session state", {
4057
4061
  sessionId: this.state.sessionId,
4058
4062
  clientMessageId: e,
4059
4063
  resyncAttempts: t + 1
@@ -4197,7 +4201,7 @@ class Ne {
4197
4201
  );
4198
4202
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
4199
4203
  this.reconnectTimer = null, this.connect().catch((n) => {
4200
- b("web-sdk.agent", "Pluno reconnect failed; retrying", {
4204
+ M("web-sdk.agent", "Pluno reconnect failed; retrying", {
4201
4205
  message: n instanceof Error ? n.message : String(n),
4202
4206
  queuedClientEventCount: this.queuedClientEvents.length,
4203
4207
  isThinking: this.state.isThinking
@@ -4209,7 +4213,7 @@ class Ne {
4209
4213
  this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
4210
4214
  const e = this.socket;
4211
4215
  !e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
4212
- this.socket === e && (b("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
4216
+ this.socket === e && (M("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
4213
4217
  }, ei));
4214
4218
  }, Zn);
4215
4219
  }
@@ -4336,11 +4340,11 @@ function Pi() {
4336
4340
  throw m;
4337
4341
  }
4338
4342
  try {
4339
- const m = f instanceof Request ? f : null, M = go(f, m), w = Bs(h?.headers ?? m?.headers);
4340
- if (!te(M, w, h?.body)) {
4343
+ const m = f instanceof Request ? f : null, b = go(f, m), w = Bs(h?.headers ?? m?.headers);
4344
+ if (!te(b, w, h?.body)) {
4341
4345
  const H = {
4342
4346
  requestId: nt("fetch"),
4343
- url: F(M, Ye),
4347
+ url: F(b, Ye),
4344
4348
  method: (h?.method ?? m?.method ?? "GET").toUpperCase(),
4345
4349
  requestHeaders: w,
4346
4350
  requestBody: ps(h?.body),
@@ -4370,7 +4374,7 @@ function Pi() {
4370
4374
  }
4371
4375
  return y;
4372
4376
  }, a = function(f, h, p, y, m) {
4373
- const M = n.call(this, f, h, p ?? !0, y ?? void 0, m ?? void 0), w = typeof h == "string" ? h : h.toString();
4377
+ const b = n.call(this, f, h, p ?? !0, y ?? void 0, m ?? void 0), w = typeof h == "string" ? h : h.toString();
4374
4378
  return Ze.set(this, {
4375
4379
  requestId: nt("xhr"),
4376
4380
  method: String(f ?? "GET").toUpperCase(),
@@ -4379,7 +4383,7 @@ function Pi() {
4379
4383
  startedAtMs: Date.now(),
4380
4384
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
4381
4385
  excluded: te(w)
4382
- }), M;
4386
+ }), b;
4383
4387
  }, l = function(f, h) {
4384
4388
  const p = i.call(this, f, h), y = Ze.get(this);
4385
4389
  return y && Object.keys(y.requestHeaders).length < At && (y.requestHeaders[f] = kt(f, h), y.excluded = y.excluded || te(y.url, y.requestHeaders)), p;
@@ -4482,7 +4486,7 @@ function Pi() {
4482
4486
  };
4483
4487
  return window.__plunoProductAgentNetworkCapture = d, d;
4484
4488
  }
4485
- function b(s, e, t) {
4489
+ function M(s, e, t) {
4486
4490
  if (typeof window > "u")
4487
4491
  return;
4488
4492
  const n = window, i = {
@@ -4550,7 +4554,7 @@ function xi() {
4550
4554
  };
4551
4555
  }
4552
4556
  function Li() {
4553
- return ms(globalThis, "getPageSnapshot", async () => Mt());
4557
+ return ms(globalThis, "getPageSnapshot", async () => bt());
4554
4558
  }
4555
4559
  function Ni() {
4556
4560
  return ms(globalThis, "pageImages", {
@@ -4775,7 +4779,7 @@ function Zi() {
4775
4779
  return {
4776
4780
  pageUrl: location.href,
4777
4781
  pageTitle: document.title,
4778
- htmlContent: Mt()
4782
+ htmlContent: bt()
4779
4783
  };
4780
4784
  }
4781
4785
  function er(s) {
@@ -4801,7 +4805,7 @@ function tr() {
4801
4805
  function et() {
4802
4806
  return Ps()?.surface === "browser_extension_sdk_preview";
4803
4807
  }
4804
- function Mt() {
4808
+ function bt() {
4805
4809
  if (!document.body)
4806
4810
  return "";
4807
4811
  const s = [], e = [], t = (p, y) => {
@@ -4998,9 +5002,9 @@ function nr(s, e) {
4998
5002
  };
4999
5003
  return [`--- ${D} ---`, ...S(w, 0).lines].join(`
5000
5004
  `);
5001
- }, m = [], M = ne(window.getSelection()?.toString() ?? "");
5002
- M && m.push(`--- selected text ---
5003
- ${JSON.stringify(M)}`), d.length > 0 && m.push(rr(d, t, l, o));
5005
+ }, m = [], b = ne(window.getSelection()?.toString() ?? "");
5006
+ b && m.push(`--- selected text ---
5007
+ ${JSON.stringify(b)}`), d.length > 0 && m.push(rr(d, t, l, o));
5004
5008
  for (const w of s.slice(0, 3))
5005
5009
  m.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
5006
5010
  if (e && m.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
@@ -5474,7 +5478,7 @@ function se(s) {
5474
5478
  const e = s.trim() || "Run tool", t = e.codePointAt(0) ?? 0;
5475
5479
  return t >= 126976 && t <= 129791 || t >= 9728 && t <= 10175 || t >= 127462 && t <= 127487 ? e : `🛠️ ${e}`;
5476
5480
  }
5477
- function Mr(s) {
5481
+ function br(s) {
5478
5482
  if (s == null)
5479
5483
  return s;
5480
5484
  if (typeof s != "object")
@@ -5510,11 +5514,11 @@ function es(s) {
5510
5514
  function de(s, e) {
5511
5515
  const t = vs(
5512
5516
  s,
5513
- bt(s, e)
5517
+ Mt(s, e)
5514
5518
  ), n = kr(
5515
5519
  Rr(
5516
5520
  Pr(
5517
- br(s, e),
5521
+ Mr(s, e),
5518
5522
  e
5519
5523
  ),
5520
5524
  t
@@ -5528,7 +5532,7 @@ function de(s, e) {
5528
5532
  const r = [...n];
5529
5533
  return r[i] = t, pt(r);
5530
5534
  }
5531
- function bt(s, e, t = !0) {
5535
+ function Mt(s, e, t = !0) {
5532
5536
  const n = s.find(
5533
5537
  (r) => r.id === e.id || e.callId !== void 0 && r.callId === e.callId || e.assistantDraftItemId !== void 0 && (r.id === e.assistantDraftItemId || r.assistantDraftItemId === e.assistantDraftItemId)
5534
5538
  );
@@ -5539,7 +5543,7 @@ function bt(s, e, t = !0) {
5539
5543
  const i = s.flatMap((r) => (e.respondsToUserMessageId !== void 0 ? r.respondsToUserMessageId === e.respondsToUserMessageId : e.runId !== void 0 && r.respondsToUserMessageId === void 0 && r.runId === e.runId) && r.displaySequence !== void 0 ? [r.displaySequence] : []);
5540
5544
  return e.displaySequence = (i.length > 0 ? Math.max(...i) : 0) + 1, e;
5541
5545
  }
5542
- function br(s, e) {
5546
+ function Mr(s, e) {
5543
5547
  const t = e.proactiveSuggestionClientMessageId;
5544
5548
  if (!t)
5545
5549
  return s;
@@ -5555,7 +5559,7 @@ function Rr(s, e) {
5555
5559
  (n) => n.dataType === "assistant_draft" && n.id === t ? e : n
5556
5560
  ) : s;
5557
5561
  }
5558
- function Me(s, e, t) {
5562
+ function be(s, e, t) {
5559
5563
  return e !== null ? s.respondsToUserMessageId === e : t !== null && s.runId === t;
5560
5564
  }
5561
5565
  function ts(s, e, t, n) {
@@ -5633,7 +5637,7 @@ function ct(s, e) {
5633
5637
  t.push(
5634
5638
  vs(
5635
5639
  i,
5636
- bt(i, n, !1)
5640
+ Mt(i, n, !1)
5637
5641
  )
5638
5642
  );
5639
5643
  }
@@ -5645,7 +5649,7 @@ function ct(s, e) {
5645
5649
  }
5646
5650
  function Er(s, e) {
5647
5651
  const t = new Map(s.map((r) => [r.id, r])), n = e.map(
5648
- (r) => bt(s, r, !1)
5652
+ (r) => Mt(s, r, !1)
5649
5653
  );
5650
5654
  for (const r of n)
5651
5655
  t.set(r.id, r);
@@ -6281,7 +6285,7 @@ function Hs(s) {
6281
6285
  const e = lo(s.name), t = s.mimeType.trim().toLowerCase();
6282
6286
  if (!Ii.has(`${e}:${t}`))
6283
6287
  throw new Error("This attachment type is not supported by the embedded model provider");
6284
- if (s.sizeBytes <= 0 || s.sizeBytes >= bs)
6288
+ if (s.sizeBytes <= 0 || s.sizeBytes >= Ms)
6285
6289
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
6286
6290
  }
6287
6291
  function lo(s) {
@@ -6492,13 +6496,13 @@ class Pe extends Error {
6492
6496
  }
6493
6497
  status;
6494
6498
  }
6495
- async function be(s, e) {
6499
+ async function Me(s, e) {
6496
6500
  let t = null;
6497
6501
  for (let n = 0; n < Vt; n += 1)
6498
6502
  try {
6499
6503
  return await s();
6500
6504
  } catch (i) {
6501
- if (t = i, n >= Vt - 1 || !Mo(i))
6505
+ if (t = i, n >= Vt - 1 || !bo(i))
6502
6506
  throw i;
6503
6507
  await Ao(n);
6504
6508
  }
@@ -6509,10 +6513,10 @@ function Ao(s) {
6509
6513
  window.setTimeout(e, yi[s] ?? 0);
6510
6514
  });
6511
6515
  }
6512
- function Mo(s) {
6513
- return s instanceof Pe ? bo(s.status) : s instanceof TypeError;
6514
- }
6515
6516
  function bo(s) {
6517
+ return s instanceof Pe ? Mo(s.status) : s instanceof TypeError;
6518
+ }
6519
+ function Mo(s) {
6516
6520
  return s === 408 || s === 409 || s === 429 || s >= 500;
6517
6521
  }
6518
6522
  function Ro(s) {