@pluno/product-agent-web 0.1.276 → 0.1.278

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.
@@ -16,7 +16,7 @@ function Ps(t) {
16
16
  for (const i of Un) t.removeItem(i);
17
17
  return t.setItem(Nn, JSON.stringify(s.filter((i) => !xs.includes(i.promptKey)))), n;
18
18
  }
19
- function Fr(t, e) {
19
+ function $r(t, e) {
20
20
  if (!xs.includes(e)) throw new Error("Unknown device hint.");
21
21
  t.setItem(Ms, JSON.stringify({ ...Ps(t), [e]: !0 }));
22
22
  }
@@ -47,14 +47,14 @@ function es(t, e, s, n) {
47
47
  }
48
48
  return { ...t, interactions: { ...t.interactions, openings: i, openingGeneration: r } };
49
49
  }
50
- function Oi(t, e, s) {
50
+ function xi(t, e, s) {
51
51
  const n = t.interactions.openings[e];
52
52
  return n?.sessionId ? n.shown[s] ?? Object.entries(n.turns).find(([, i]) => i.active && i[s])?.[0] ?? null : null;
53
53
  }
54
54
  function xt(t, e) {
55
55
  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"] } : t ?? { allowed: !0, reason: "allowed", actions: [] };
56
56
  }
57
- const xi = {
57
+ const Mi = {
58
58
  connect: "canConnect",
59
59
  read_account: "canReadAccount",
60
60
  read_appearance: "canReadAppearance",
@@ -144,7 +144,7 @@ const xi = {
144
144
  canReadHostedBrowserEligibility: !1,
145
145
  canManageInteractions: !0,
146
146
  canInvokeConversationActions: !0
147
- }, $r = {
147
+ }, zr = {
148
148
  ...Ds,
149
149
  canExecuteCurrentPageTools: !1,
150
150
  canManageTabs: !1,
@@ -200,20 +200,20 @@ const xi = {
200
200
  canReadHostedBrowserEligibility: !1,
201
201
  canManageInteractions: !0,
202
202
  canInvokeConversationActions: !0
203
- }, zr = {
203
+ }, Hr = {
204
204
  extension_sidepanel: Ds,
205
205
  extension_widget: Ds,
206
- main_web_chat: $r,
206
+ main_web_chat: zr,
207
207
  embedded_widget: jn,
208
208
  embedded_custom_ui: jn
209
209
  };
210
210
  function X(t, e) {
211
- return zr[t][e] === !0;
211
+ return Hr[t][e] === !0;
212
212
  }
213
- function Mi(t, e, s = null, n = !0) {
213
+ function Pi(t, e, s = null, n = !0) {
214
214
  const i = (a, o) => ({ operation: e, allowed: a === "allowed", reason: a, recovery: o }), r = t.authority;
215
215
  if (!r) return i("authentication", "login");
216
- if (!X(r.profile, xi[e])) return i("capability", "none");
216
+ if (!X(r.profile, Mi[e])) return i("capability", "none");
217
217
  if (s && t.preferences?.blockedOrigins.includes(s)) return i("blocked_origin", "settings");
218
218
  if (!n) return i("device", "settings");
219
219
  if (["send_message", "retry_message", "start_deep_flow"].includes(e) && !r.profile.startsWith("embedded_")) {
@@ -290,7 +290,7 @@ function Z(t) {
290
290
  if (!je(t)) throw new Error("Conversation inputs must be JSON-safe values.");
291
291
  return JSON.parse(JSON.stringify(t));
292
292
  }
293
- function Pi(t = "", e = 0) {
293
+ function Di(t = "", e = 0) {
294
294
  return G({ authorityId: t, generation: e, pendingRestoration: {}, proactiveQuestions: {}, sessions: {}, submissions: {}, submissionOrder: [], stops: {}, requests: {}, requestSequence: 0, deliveries: {}, operations: {}, effectsEnabled: !1, durableSubmissionIds: [], pendingDurabilityIds: [], checkpointEffectId: null, checkpointError: null });
295
295
  }
296
296
  function Us(t) {
@@ -306,11 +306,11 @@ function Us(t) {
306
306
  queries: { current: ye(`${t}:current`), history: ye(`${t}:history`) }
307
307
  };
308
308
  }
309
- function Di(t) {
309
+ function Ui(t) {
310
310
  return ["history_load_failed", "request_timed_out", "connection_interrupted", "408", "425", "429"].includes(t) || /^5\d\d$/.test(t);
311
311
  }
312
- const Hr = "Message storage has not confirmed this submission. Reconnect to check its status.";
313
- function Vr(t, e) {
312
+ const Vr = "Message storage has not confirmed this submission. Reconnect to check its status.";
313
+ function Kr(t, e) {
314
314
  const s = t?.executionByUserMessage[e]?.responseMessageIds, n = s?.indexOf(e) ?? -1;
315
315
  return s && n >= 0 ? s.slice(0, n + 1) : [e];
316
316
  }
@@ -354,7 +354,7 @@ function Ie(t, e, s) {
354
354
  const v = ["thinking", "steering", "queued"].includes(k), I = t.stops[s] ?? R, w = I?.userMessageIds.filter((S) => !["completed", "failed"].includes(r?.executionByUserMessage[S]?.phase ?? "")) ?? [], _ = w.some((S) => {
355
355
  const x = a.find((H) => H.userMessageId === S);
356
356
  return !Object.values(t.operations).some((H) => H.command.type === "run.stop" && H.command.payload.expectedUserMessageId === S && H.phase === "done") && (x?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(x.delivery) || !!(u && le(u).includes(S) && ["thinking", "steering", "queued", "stopping"].includes(u.phase)));
357
- }), A = u?.user_message_ids ?? [], T = y || b ? f?.userMessageId ?? null : A[A.length - 1] ?? null, q = l.find((S) => S.userMessageId === T), C = v ? [...q?.activityIds ?? []].reverse().find((S) => d[S] === "open") ?? null : null, O = i !== null && !!e.selections[s]?.provisionalId && o.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
357
+ }), A = u?.user_message_ids ?? [], C = y || b ? f?.userMessageId ?? null : A[A.length - 1] ?? null, q = l.find((S) => S.userMessageId === C), T = v ? [...q?.activityIds ?? []].reverse().find((S) => d[S] === "open") ?? null : null, O = i !== null && !!e.selections[s]?.provisionalId && o.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
358
358
  (!r?.execution || r.execution.phase === "idle" && r.execution.user_message_ids.length === 0) && Object.values(t.operations).some((S) => S.conversationScopeId === s && S.phase === "done" && ["runtime.warmup", "attachment.prepare"].includes(S.command.type) && !S.command.payload.sessionId && S.result?.sessionId === i);
359
359
  return G({
360
360
  historyRefreshFailure: r?.historyRefreshFailure ?? null,
@@ -373,14 +373,14 @@ function Ie(t, e, s) {
373
373
  streamStates: d,
374
374
  preparation: r?.preparation ?? null,
375
375
  stop: I ? { ...I, userMessageIds: w, pending: _ } : null,
376
- segments: l.map((S, x) => ({ ...S, collapsed: v ? S.userMessageId !== T : x < l.length - 1 || S.activityIds.length > 0 })),
377
- activity: { phase: k, activeItemId: C, userMessageId: T, executionKey: JSON.stringify([...le(u)].sort()) },
376
+ segments: l.map((S, x) => ({ ...S, collapsed: v ? S.userMessageId !== C : x < l.length - 1 || S.activityIds.length > 0 })),
377
+ activity: { phase: k, activeItemId: T, userMessageId: C, executionKey: JSON.stringify([...le(u)].sort()) },
378
378
  // Staging transfers the immutable input to the core. Waiting for backend acceptance leaves
379
379
  // the same submitted text in the optimistic transcript and composer during delivery.
380
380
  receipts: n.filter((S) => !S.cancelled && e.clients[S.clientScopeId] === s).map((S) => ({ viewId: S.viewId, userMessageId: S.userMessageId, acceptedRendererRevision: S.rendererRevision, durable: t.durableSubmissionIds.includes(S.userMessageId) || S.delivery === "accepted" }))
381
381
  });
382
382
  }
383
- function Ui(t, e) {
383
+ function Ni(t, e) {
384
384
  const s = /* @__PURE__ */ new Set([
385
385
  ...t.items.filter((o) => o.type === "user_message").map((o) => o.id),
386
386
  ...t.submissions.filter((o) => o.delivery === "accepted").map((o) => o.userMessageId)
@@ -389,14 +389,14 @@ function Ui(t, e) {
389
389
  return { type: "preparation", submission: r };
390
390
  if (r && !r.cancelled && (r.delivery === "uncertain" || r.delivery === "failed" && !["attachment_source_unavailable", "context_preparation_interrupted"].includes(r.error?.code ?? "") || t.deliveries[r.userMessageId]?.phase === "paused"))
391
391
  return { type: "delivery", userMessageId: r.userMessageId };
392
- if (e && r?.delivery !== "accepted") return null;
392
+ if (e && (r ? r.delivery !== "accepted" : !s.has(e))) return null;
393
393
  const a = e ?? [...t.items].reverse().find((o) => o.type === "user_message")?.id ?? [...t.submissions].reverse().find((o) => !o.cancelled && o.delivery === "accepted")?.userMessageId;
394
394
  return t.sessionId && a ? { type: "execution", userMessageId: a, sessionId: t.sessionId } : null;
395
395
  }
396
- function Kr(t, e) {
396
+ function Wr(t, e) {
397
397
  return G({ scopes: Object.fromEntries([...new Set(Object.values(e.clients))].map((s) => [s, Ie(t, e, s)])) });
398
398
  }
399
- function Ni(t, e) {
399
+ function ji(t, e) {
400
400
  if (!e) return !1;
401
401
  const s = t.executionByUserMessage[e];
402
402
  if (s) return ["completed", "stopped", "failed"].includes(s.phase);
@@ -407,7 +407,7 @@ function Ni(t, e) {
407
407
  return !0;
408
408
  return !1;
409
409
  }
410
- function ji(t) {
410
+ function Bi(t) {
411
411
  return t.category === "morning_report" ? "category:morning_report" : `prompt:${t.category}:${t.promptKey}`;
412
412
  }
413
413
  function dn(t) {
@@ -416,7 +416,7 @@ function dn(t) {
416
416
  function ss(t, e) {
417
417
  const s = { ...t.decisions };
418
418
  for (const n of e) {
419
- if (dn(n.request), n.decisionKey !== ji(n.request)) throw new Error("Decision scope does not match its category.");
419
+ if (dn(n.request), n.decisionKey !== Bi(n.request)) throw new Error("Decision scope does not match its category.");
420
420
  (!s[n.decisionKey] || n.revision > s[n.decisionKey].revision) && (s[n.decisionKey] = n);
421
421
  }
422
422
  return { ...t, decisions: s };
@@ -432,11 +432,11 @@ function Bn(t, e) {
432
432
  function Ln(t, e) {
433
433
  return !!t && (t.outcome !== "snoozed" || t.nextEligibleAt !== null && Date.parse(t.nextEligibleAt) > e);
434
434
  }
435
- function Bi(t, e, s) {
435
+ function Li(t, e, s) {
436
436
  const n = Object.values(t.interactions.actions).filter((i) => i.interactionId === e && (!s.conversationScopeId || i.conversationScopeId === s.conversationScopeId) && (i.operation.kind !== "edit" || !s.clientScopeId || i.clientScopeId === s.clientScopeId));
437
437
  return n.find((i) => i.status === "pending") ?? n[n.length - 1];
438
438
  }
439
- function Wr(t, e, s) {
439
+ function Gr(t, e, s) {
440
440
  const n = t.account.authority;
441
441
  if (!n) return [];
442
442
  const i = X(n.profile, "canShowPersonalFeatures"), r = [], a = t.features.now, o = (c) => {
@@ -467,7 +467,7 @@ function Wr(t, e, s) {
467
467
  const d = c === "notifications" ? "canRequestNotificationPermission" : "canGroupSessionTabs";
468
468
  if (!X(n.profile, d)) continue;
469
469
  const l = s.conversationScopeId ? t.interactions.openings[s.conversationScopeId] : void 0;
470
- if (!s.sessionId || !l || l.sessionId !== s.sessionId || !Oi(t, s.conversationScopeId, c) || t.features.refreshRequired && !l.shown[c] || n.profile === "main_web_chat" && !t.interactions.bridgeReady && !l.shown[c]) continue;
470
+ if (!s.sessionId || !l || l.sessionId !== s.sessionId || !xi(t, s.conversationScopeId, c) || t.features.refreshRequired && !l.shown[c] || n.profile === "main_web_chat" && !t.interactions.bridgeReady && !l.shown[c]) continue;
471
471
  const u = Ye(t, c), h = t.interactions.preferencePrompts[c], p = t.interactions.deviceFacts[c], m = `preference:${c}`, f = u === null;
472
472
  if (u === !1 || t.features.desiredPreferences[c] === !1 || f && h.snoozedUntil && Date.parse(h.snoozedUntil) > a || !f && (p.permission !== "missing" || p.snoozedUntil && Date.parse(p.snoozedUntil) > a)) continue;
473
473
  const y = Object.values(t.interactions.devicePending).some((R) => R.feature === c), b = o([m, `preferenceSnooze:${c}`, `preferenceAcknowledge:${c}`]), k = b.error ?? t.interactions.deviceErrors[c] ?? (l.shown[c] && t.interactions.bridgeError ? { code: "connection_interrupted", message: t.interactions.bridgeError, retryable: !0 } : null);
@@ -494,7 +494,7 @@ function Wr(t, e, s) {
494
494
  if (d.kind === "sharing") {
495
495
  if (!i || !X(n.profile, "canShare") || !d.eligible || c.invocation !== "user" || (n.profile.startsWith("extension_") ? !t.interactions.localSharingReady : t.features.refreshRequired)) continue;
496
496
  const m = e.sessions[c.conversation_id];
497
- if (d.wait_for_terminal && (!m || !Ni(m, c.user_message_id)) || (n.profile.startsWith("extension_") ? t.interactions.localSharing[c.id]?.resolved : Ln(t.interactions.decisions[`prompt:social_share:${c.id}`], a))) continue;
497
+ if (d.wait_for_terminal && (!m || !ji(m, c.user_message_id)) || (n.profile.startsWith("extension_") ? t.interactions.localSharing[c.id]?.resolved : Ln(t.interactions.decisions[`prompt:social_share:${c.id}`], a))) continue;
498
498
  }
499
499
  if (d.kind === "integration_auth" && !X(n.profile, "canManageIntegrationAuth") || d.kind === "personal_channel" && !i) continue;
500
500
  const l = d.kind === "integration_auth" && c.lifecycle === "pending" && Date.parse(d.expires_at) <= a ? "expired" : c.lifecycle, u = t.interactions.decisions[`prompt:social_share:${c.id}`], h = t.interactions.localSharing[c.id], p = Object.values(t.interactions.actions).filter((m) => m.interactionId === c.id && m.sourceVersion === c.version && (m.operation.kind !== "connect" || m.operation.source.conversation_id === c.conversation_id)).slice(-1)[0];
@@ -519,7 +519,7 @@ function Wr(t, e, s) {
519
519
  for (const c of Object.values(t.interactions.welcome)) {
520
520
  const d = c.category === "morning_report" ? "canManageMorningReport" : "canManageProactiveSuggestions", l = c.category === "morning_report" ? "category:morning_report" : `prompt:proactive_suggestion:${c.sourceSuggestionId ?? c.id}`;
521
521
  if (c.clientScopeId && c.clientScopeId !== s.clientScopeId || !c.eligible || c.expiresAt !== void 0 && c.expiresAt <= a || !X(n.profile, d) || Ln(t.interactions.decisions[l], a)) continue;
522
- const u = o([l]), h = Bi(t, c.id, s), p = u.status === "pending" || h?.status === "pending" ? "pending" : u.error || h?.status === "error" ? "error" : "presentable";
522
+ const u = o([l]), h = Li(t, c.id, s), p = u.status === "pending" || h?.status === "pending" ? "pending" : u.error || h?.status === "error" ? "error" : "presentable";
523
523
  r.push({
524
524
  id: c.id,
525
525
  category: c.category,
@@ -538,13 +538,13 @@ function Wr(t, e, s) {
538
538
  }
539
539
  return r;
540
540
  }
541
- function Li(t, e, s, n) {
541
+ function Fi(t, e, s, n) {
542
542
  const i = s.clients[n], r = s.selections[i];
543
543
  if (!r || s.authorityId !== t.account.authority?.authorityId || s.generation !== t.account.authority.generation) return [];
544
544
  const a = Object.values(e.submissions).some((o) => o.conversationScopeId === i && !o.cancelled && o.delivery !== "failed");
545
- return Wr(t, e, { sessionId: r.sessionId, newChat: r.sessionId === null && r.provisionalId !== null, submissionStarted: a, clientScopeId: n, conversationScopeId: i });
545
+ return Gr(t, e, { sessionId: r.sessionId, newChat: r.sessionId === null && r.provisionalId !== null, submissionStarted: a, clientScopeId: n, conversationScopeId: i });
546
546
  }
547
- function Gr(t, e, s, n) {
547
+ function Jr(t, e, s, n) {
548
548
  let i = t;
549
549
  const r = [], a = i.account.authority, o = (l, u) => JSON.stringify(["stage7.platform", a.authorityId, a.generation, l, u]), c = (l, u) => {
550
550
  i = { ...i, interactions: { ...i.interactions, actions: { ...i.interactions.actions, [l]: u } } };
@@ -575,7 +575,7 @@ function Gr(t, e, s, n) {
575
575
  }
576
576
  } };
577
577
  }
578
- const u = Li(i, s, n, e.clientScopeId).find((f) => f.id === e.interactionId);
578
+ const u = Fi(i, s, n, e.clientScopeId).find((f) => f.id === e.interactionId);
579
579
  if (!u || !u.actions.includes(e.action) || u.decisionRevision !== e.expectedRevision || u.sourceVersion !== e.sourceVersion || u.status === "pending") throw new Error("Interaction changed or action is unavailable.");
580
580
  if (u.category === "preference" || u.category === "permission") {
581
581
  const f = u.payload.feature;
@@ -613,11 +613,11 @@ function Gr(t, e, s, n) {
613
613
  if (h?.payload.kind !== "personal_channel") throw new Error("Missing channel request.");
614
614
  p = { kind: "pair", interactionId: u.id, requestId: h.payload.request_id, managementUrl: h.payload.management_url };
615
615
  } else {
616
- const f = Bi(i, u.id, { clientScopeId: e.clientScopeId, conversationScopeId: n.clients[e.clientScopeId] });
616
+ const f = Li(i, u.id, { clientScopeId: e.clientScopeId, conversationScopeId: n.clients[e.clientScopeId] });
617
617
  if (f?.status === "error" && f.error?.code !== "interaction_not_started") throw new Error("Reconcile the previous action before trying again.");
618
618
  if (e.action !== "edit") {
619
619
  if (a.profile.startsWith("extension_") && !e.origin) throw new Error("Task submission requires the current page origin.");
620
- const k = Mi(i.account, "send_message", e.origin ?? null);
620
+ const k = Pi(i.account, "send_message", e.origin ?? null);
621
621
  if (!k.allowed) throw new Error(`Task submission unavailable: ${k.reason}.`);
622
622
  }
623
623
  const y = i.interactions.welcome[u.id], b = y.category === "morning_report" ? y.tasks[e.taskIndex ?? 0] : y.text;
@@ -676,14 +676,14 @@ function Gr(t, e, s, n) {
676
676
  return { state: i, effects: r, command: null };
677
677
  }
678
678
  const oe = (t) => t;
679
- function Fi(t) {
679
+ function $i(t) {
680
680
  return ["appearance", "sampleStyle", "saveStyle", "scribble", "deleteStyle"].includes(t.kind);
681
681
  }
682
- function Jr(t, e, s, n) {
682
+ function Qr(t, e, s, n) {
683
683
  let i = t;
684
684
  const r = [], a = (u) => {
685
685
  i = { ...i, ...u };
686
- }, o = (u, h, p) => JSON.stringify(["stage7", e.authorityId, e.generation, u, h, ...p === void 0 ? [] : [p]]), c = (u, h) => Fi(u) && "origin" in u && u.origin === h, d = (u) => Object.values(i.pending).some((h) => h.mode === "mutation" && ["pending", "queued"].includes(h.status) && c(h.operation, u)), l = (u) => {
686
+ }, o = (u, h, p) => JSON.stringify(["stage7", e.authorityId, e.generation, u, h, ...p === void 0 ? [] : [p]]), c = (u, h) => $i(u) && "origin" in u && u.origin === h, d = (u) => Object.values(i.pending).some((h) => h.mode === "mutation" && ["pending", "queued"].includes(h.status) && c(h.operation, u)), l = (u) => {
687
687
  const h = i.pending[u];
688
688
  a({ pending: { ...i.pending, [u]: { ...h, status: "pending" } } }), r.push({ kind: "stage7.query", id: u, input: { authority: e, requestId: h.requestId, query: h.operation } });
689
689
  };
@@ -764,7 +764,7 @@ function Jr(t, e, s, n) {
764
764
  function Ns(t = null) {
765
765
  return { authority: t, refusal: null, paidFallbackBySession: {}, query: ye("account"), preferences: null };
766
766
  }
767
- function Qr(t, e) {
767
+ function Xr(t, e) {
768
768
  return t.preferences && e.preferencesVersion <= t.preferences.preferencesVersion ? t : { ...t, preferences: e };
769
769
  }
770
770
  function js() {
@@ -813,7 +813,7 @@ function ie(t, e) {
813
813
  function Ye(t, e) {
814
814
  return t.account.preferences?.[e === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled"] ?? null;
815
815
  }
816
- const Xr = {
816
+ const Yr = {
817
817
  account: "read_account",
818
818
  preferences: "manage_preferences",
819
819
  preferencePrompts: "manage_preferences",
@@ -846,7 +846,7 @@ const Xr = {
846
846
  blockedOrigins: "manage_origin_access"
847
847
  };
848
848
  function Ce(t, e) {
849
- if (!X(t.profile, xi[Xr[e.kind]])) throw new Error("Feature capability unavailable.");
849
+ if (!X(t.profile, Mi[Yr[e.kind]])) throw new Error("Feature capability unavailable.");
850
850
  if (["decisions", "decision", "preferencePrompts"].includes(e.kind) && !X(t.profile, "canShowPersonalFeatures")) throw new Error("Personal feature unavailable.");
851
851
  if (t.profile.startsWith("embedded_") && e.kind === "targetFeedback") throw new Error("Embedded target feedback has no supported contract.");
852
852
  if (e.kind === "proactiveFeedback" && !X(t.profile, "canManageProactiveSuggestions")) throw new Error("Proactive feedback unavailable.");
@@ -857,7 +857,7 @@ function Ce(t, e) {
857
857
  }
858
858
  }
859
859
  function Fn(t) {
860
- return t.kind === "decision" ? ji(t) : t.kind === "proactiveFeedback" ? `prompt:proactive_suggestion:${t.suggestionId}` : "feature" in t ? `${t.kind}:${t.feature}` : t.kind;
860
+ return t.kind === "decision" ? Bi(t) : t.kind === "proactiveFeedback" ? `prompt:proactive_suggestion:${t.suggestionId}` : "feature" in t ? `${t.kind}:${t.feature}` : t.kind;
861
861
  }
862
862
  function Se(t, e, s) {
863
863
  return JSON.stringify(["stage7", t.authorityId, t.generation, e, s]);
@@ -881,42 +881,42 @@ function Ls(t, e, s) {
881
881
  const c = (g, v) => {
882
882
  const I = { ...n.features.contextObservers }, w = I[g];
883
883
  if (v === null ? delete I[g] : I[g] = ie(o, { kind: "originContext", clientScopeId: g, origin: v, pageUrl: "" }), r({ contextObservers: I }), !w || Object.values(I).includes(w)) return;
884
- const _ = { ...n.features.queries }, A = { ...n.features.polls }, T = { ...n.features.contextReads }, q = { ...n.features.originContextQueries }, C = { ...n.features.pending }, O = q[w]?.origin, S = { ...n.features.contextRunOrigins };
884
+ const _ = { ...n.features.queries }, A = { ...n.features.polls }, C = { ...n.features.contextReads }, q = { ...n.features.originContextQueries }, T = { ...n.features.pending }, O = q[w]?.origin, S = { ...n.features.contextRunOrigins };
885
885
  for (const [x, U] of Object.entries(S)) U === O && delete S[x];
886
- delete _[w], delete A[w], delete T[w], delete q[w];
887
- for (const [x, U] of Object.entries(C)) U.mode === "query" && U.key === w && delete C[x];
888
- r({ queries: _, polls: A, contextReads: T, originContextQueries: q, contextRunOrigins: S, pending: C });
886
+ delete _[w], delete A[w], delete C[w], delete q[w];
887
+ for (const [x, U] of Object.entries(T)) U.mode === "query" && U.key === w && delete T[x];
888
+ r({ queries: _, polls: A, contextReads: C, originContextQueries: q, contextRunOrigins: S, pending: T });
889
889
  };
890
890
  if (e.type === "stage7.account_fallback") return { state: { ...n, account: {
891
891
  ...n.account,
892
892
  paidFallbackBySession: { ...n.account.paidFallbackBySession, [e.sessionId]: e.enabled }
893
893
  } }, effects: i };
894
894
  const d = e.type === "stage7.query" ? e.query : e.type === "stage7.mutate" ? e.mutation : e.type === "effect.completed" || e.type === "effect.failed" ? n.features.pending[e.effectId]?.operation : null;
895
- if (d && Fi(d)) {
895
+ if (d && $i(d)) {
896
896
  Ce(o, d);
897
- const g = Jr(n.features, o, e, (v) => ie(o, v));
897
+ const g = Qr(n.features, o, e, (v) => ie(o, v));
898
898
  return { state: { ...n, features: g.state }, effects: g.effects };
899
899
  }
900
900
  if (e.type === "stage7.act" || e.type === "stage7.retry_action" || (e.type === "effect.completed" || e.type === "effect.failed") && e.effectKind === "stage7.platform") {
901
- const g = Gr(n, e, s.conversation, s.directory);
901
+ const g = Jr(n, e, s.conversation, s.directory);
902
902
  if (!g.command) return { state: g.state, effects: g.effects };
903
903
  const v = Ls(g.state, g.command, s);
904
904
  return { state: v.state, effects: [...g.effects, ...v.effects] };
905
905
  }
906
906
  const l = (g, v, I) => {
907
907
  const w = g === "notifications" ? "canRequestNotificationPermission" : "canGroupSessionTabs";
908
- if (!X(o.profile, w) || Ye(n, g) !== !0 || n.features.desiredPreferences[g] === !1 || Object.values(n.interactions.devicePending).some((T) => T.feature === g && (v === "check" || T.action !== "check"))) return;
908
+ if (!X(o.profile, w) || Ye(n, g) !== !0 || n.features.desiredPreferences[g] === !1 || Object.values(n.interactions.devicePending).some((C) => C.feature === g && (v === "check" || C.action !== "check"))) return;
909
909
  const _ = Se(o, "device", I), A = { ...n.interactions.deviceErrors };
910
910
  delete A[g], a({ deviceErrors: A, devicePending: { ...n.interactions.devicePending, [_]: { feature: g, requestId: I, generation: o.generation, desired: !0, action: v } } }), i.push({ kind: "stage7.device", id: _, input: { authority: o, requestId: I, feature: g, action: v, now: n.features.now } });
911
911
  }, u = (g, v) => {
912
912
  const I = v ? n.interactions.promptActions[v.replace(/:ack$/, "")] : void 0, w = { ...n.interactions.openings };
913
913
  for (const [_, A] of Object.entries(w)) {
914
914
  if (I?.scope === _ && I.openingGeneration === A.generation && ["enable", "allow"].includes(I.action)) continue;
915
- const T = { ...A.shown };
916
- delete T[g], w[_] = {
915
+ const C = { ...A.shown };
916
+ delete C[g], w[_] = {
917
917
  ...A,
918
- shown: T,
919
- turns: Object.fromEntries(Object.entries(A.turns).map(([q, C]) => [q, { ...C, [g]: !1, [`${g}Suppressed`]: !0 }]))
918
+ shown: C,
919
+ turns: Object.fromEntries(Object.entries(A.turns).map(([q, T]) => [q, { ...T, [g]: !1, [`${g}Suppressed`]: !0 }]))
920
920
  };
921
921
  }
922
922
  a({ openings: w });
@@ -931,7 +931,7 @@ function Ls(t, e, s) {
931
931
  const w = g.kind === "preferencePrompts" ? g.value[I] : g.feature === I ? g.value : null;
932
932
  w && w.revision > n.interactions.preferencePrompts[I].revision && u(I, w.requestId);
933
933
  }
934
- g.kind === "preferences" && (n = { ...n, account: Qr(n.account, g.value) }), g.kind === "preferencePrompts" && (n = { ...n, interactions: Bn(n.interactions, g.value) }), g.kind === "preferencePrompt" && (n = { ...n, interactions: Bn(n.interactions, { ...n.interactions.preferencePrompts, [g.feature]: g.value }) }), g.kind === "decisions" && (n = { ...n, interactions: ss(n.interactions, g.decisions) }), g.kind === "decision" && (n = { ...n, interactions: ss(n.interactions, [g.value]) });
934
+ g.kind === "preferences" && (n = { ...n, account: Xr(n.account, g.value) }), g.kind === "preferencePrompts" && (n = { ...n, interactions: Bn(n.interactions, g.value) }), g.kind === "preferencePrompt" && (n = { ...n, interactions: Bn(n.interactions, { ...n.interactions.preferencePrompts, [g.feature]: g.value }) }), g.kind === "decisions" && (n = { ...n, interactions: ss(n.interactions, g.decisions) }), g.kind === "decision" && (n = { ...n, interactions: ss(n.interactions, [g.value]) });
935
935
  }, p = (g, v) => {
936
936
  const I = n.interactions.deviceFacts[g];
937
937
  v.revision <= I.revision || (Ye(n, g) === !0 && (v.permission === "granted" && I.permission !== "granted" || v.snoozedUntil && v.snoozedUntil !== I.snoozedUntil) && u(g, null), a({ deviceFacts: { ...n.interactions.deviceFacts, [g]: v } }));
@@ -939,13 +939,13 @@ function Ls(t, e, s) {
939
939
  Ce(o, g);
940
940
  const w = ie(o, g), _ = Se(o, "query", v);
941
941
  if (g.kind === "originContext") {
942
- const C = n.features.queries[w], O = n.features.contextReads[w];
943
- if (r({ originContextQueries: { ...n.features.originContextQueries, [w]: g } }), !I && (C?.status === "ready" || C?.status === "error") && O && (n.features.now - O.settledAt < 3e4 || C.error && !C.error.retryable && C.error.code !== "runtime_error")) return;
942
+ const T = n.features.queries[w], O = n.features.contextReads[w];
943
+ if (r({ originContextQueries: { ...n.features.originContextQueries, [w]: g } }), !I && (T?.status === "ready" || T?.status === "error") && O && (n.features.now - O.settledAt < 3e4 || T.error && !T.error.retryable && T.error.code !== "runtime_error")) return;
944
944
  }
945
945
  const A = n.features.pending[_];
946
946
  if (A && A.fingerprint !== JSON.stringify(g)) throw new Error("Query request ID changed payload.");
947
- if (A?.status === "pending" || Object.values(n.features.pending).some((C) => C.mode === "query" && C.key === w && C.status === "pending")) return;
948
- const T = n.features.queries[w] ?? ye(w), q = Ue(T, { key: w, requestId: oe(v), mode: "replace" });
947
+ if (A?.status === "pending" || Object.values(n.features.pending).some((T) => T.mode === "query" && T.key === w && T.status === "pending")) return;
948
+ const C = n.features.queries[w] ?? ye(w), q = Ue(C, { key: w, requestId: oe(v), mode: "replace" });
949
949
  r({ queries: { ...n.features.queries, [w]: q }, pending: { ...n.features.pending, [_]: {
950
950
  requestId: v,
951
951
  effectId: _,
@@ -967,17 +967,17 @@ function Ls(t, e, s) {
967
967
  if (!["decision", "preferenceSnooze", "preferenceAcknowledge"].includes(g.kind)) throw new Error("This operation cannot be replayed automatically.");
968
968
  if (["conflict", "409"].includes(A.error?.code ?? "")) throw new Error("Refresh the conflicting decision before making another choice.");
969
969
  }
970
- if (g.kind === "preference" && (r({ desiredPreferences: { ...n.features.desiredPreferences, [g.feature]: g.enabled } }), Object.values(n.features.pending).some((T) => T.status === "pending" && T.operation.kind === "preference" && T.operation.feature === g.feature))) {
971
- const T = n.features.queuedPreferences[g.feature];
972
- if (T && T.requestId !== v) {
973
- const q = Se(o, "mutate", T.requestId), C = { kind: "preference", feature: g.feature, enabled: T.enabled };
970
+ if (g.kind === "preference" && (r({ desiredPreferences: { ...n.features.desiredPreferences, [g.feature]: g.enabled } }), Object.values(n.features.pending).some((C) => C.status === "pending" && C.operation.kind === "preference" && C.operation.feature === g.feature))) {
971
+ const C = n.features.queuedPreferences[g.feature];
972
+ if (C && C.requestId !== v) {
973
+ const q = Se(o, "mutate", C.requestId), T = { kind: "preference", feature: g.feature, enabled: C.enabled };
974
974
  r({ pending: { ...n.features.pending, [q]: {
975
- requestId: T.requestId,
975
+ requestId: C.requestId,
976
976
  effectId: q,
977
- fingerprint: JSON.stringify(C),
978
- key: Fn(C),
977
+ fingerprint: JSON.stringify(T),
978
+ key: Fn(T),
979
979
  generation: o.generation,
980
- operation: C,
980
+ operation: T,
981
981
  mode: "mutation",
982
982
  status: "error",
983
983
  result: null,
@@ -988,8 +988,8 @@ function Ls(t, e, s) {
988
988
  return;
989
989
  }
990
990
  if (g.kind === "generatePrompts") {
991
- const T = { kind: "starterPrompts", ...g.page, includeUserSuggestions: g.includeUserSuggestions ?? !1 }, q = ie(o, T), C = n.features.queries[q] ?? ye(q);
992
- r({ queries: { ...n.features.queries, [q]: Ue(C, { key: q, requestId: oe(v), mode: "replace" }) } });
991
+ const C = { kind: "starterPrompts", ...g.page, includeUserSuggestions: g.includeUserSuggestions ?? !1 }, q = ie(o, C), T = n.features.queries[q] ?? ye(q);
992
+ r({ queries: { ...n.features.queries, [q]: Ue(T, { key: q, requestId: oe(v), mode: "replace" }) } });
993
993
  }
994
994
  r({ pending: { ...n.features.pending, [w]: { requestId: v, effectId: w, fingerprint: _, key: Fn(g), generation: o.generation, operation: g, mode: "mutation", status: "pending", error: null, result: null } } }), i.push({ kind: "stage7.mutate", id: w, input: { authority: o, requestId: v, mutation: g } });
995
995
  }, y = (g) => {
@@ -1008,8 +1008,8 @@ function Ls(t, e, s) {
1008
1008
  else {
1009
1009
  const A = _ ? n.features.failures + 1 : 0;
1010
1010
  r({ refreshBatch: null, failures: A, refreshAt: n.features.now + Math.min(6e4 * 2 ** A, 9e5) });
1011
- const T = n.features.refreshQueuedRequestId;
1012
- T && (r({ refreshQueuedRequestId: null }), y(T));
1011
+ const C = n.features.refreshQueuedRequestId;
1012
+ C && (r({ refreshQueuedRequestId: null }), y(C));
1013
1013
  }
1014
1014
  }
1015
1015
  };
@@ -1020,10 +1020,10 @@ function Ls(t, e, s) {
1020
1020
  const v = { ...n.features.queries }, I = { ...n.features.pending }, w = [];
1021
1021
  for (const [_, A] of Object.entries(I)) {
1022
1022
  if (A.operation.kind !== "account" || A.status === "done" || A.status === "error") continue;
1023
- const T = { code: e.code, message: "The backend refused account access. Refresh account status before retrying.", retryable: !0 };
1024
- I[_] = { ...A, status: "error", error: T }, w.push(_);
1023
+ const C = { code: e.code, message: "The backend refused account access. Refresh account status before retrying.", retryable: !0 };
1024
+ I[_] = { ...A, status: "error", error: C }, w.push(_);
1025
1025
  const q = v[A.key];
1026
- q && (v[A.key] = dt(q, { key: A.key, requestId: oe(A.requestId), error: T }));
1026
+ q && (v[A.key] = dt(q, { key: A.key, requestId: oe(A.requestId), error: C }));
1027
1027
  }
1028
1028
  n = { ...n, features: { ...n.features, pending: I, queries: v }, account: {
1029
1029
  ...n.account,
@@ -1088,7 +1088,7 @@ function Ls(t, e, s) {
1088
1088
  case "stage7.prompt_shown": {
1089
1089
  const g = s.directory.clients[e.clientScopeId], v = n.interactions.openings[g];
1090
1090
  if (!v || v.generation !== e.openingGeneration) break;
1091
- const I = Oi(n, g, e.feature);
1091
+ const I = xi(n, g, e.feature);
1092
1092
  I && a({ openings: { ...n.interactions.openings, [g]: { ...v, shown: { ...v.shown, [e.feature]: I } } } });
1093
1093
  break;
1094
1094
  }
@@ -1259,18 +1259,18 @@ function Ls(t, e, s) {
1259
1259
  r({ contextRunOrigins: { ...n.features.contextRunOrigins, [I.value.runId]: w } });
1260
1260
  else {
1261
1261
  const _ = { ...n.features.contextRunOrigins };
1262
- for (const [A, T] of Object.entries(_)) T === w && delete _[A];
1262
+ for (const [A, C] of Object.entries(_)) C === w && delete _[A];
1263
1263
  r({ contextRunOrigins: _ });
1264
1264
  }
1265
1265
  if (g.mode === "mutation") {
1266
- const _ = { ...n.features.queries }, A = { ...n.features.pending }, T = { ...n.features.contextReads }, q = { ...n.features.polls };
1267
- for (const [C, O] of Object.entries(n.features.originContextQueries))
1266
+ const _ = { ...n.features.queries }, A = { ...n.features.pending }, C = { ...n.features.contextReads }, q = { ...n.features.polls };
1267
+ for (const [T, O] of Object.entries(n.features.originContextQueries))
1268
1268
  if (O.origin === w) {
1269
- _[C] = { ..._[C], data: I, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, T[C] = { settledAt: e.output.completedAt, failures: 0 }, delete q[C];
1270
- for (const [S, x] of Object.entries(A)) x.mode === "query" && x.key === C && delete A[S];
1271
- ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status) && (q[C] = { query: { ...O, kind: "originContext", trigger: "poll" }, deadline: n.features.now + 5e3 });
1269
+ _[T] = { ..._[T], data: I, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, C[T] = { settledAt: e.output.completedAt, failures: 0 }, delete q[T];
1270
+ for (const [S, x] of Object.entries(A)) x.mode === "query" && x.key === T && delete A[S];
1271
+ ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status) && (q[T] = { query: { ...O, kind: "originContext", trigger: "poll" }, deadline: n.features.now + 5e3 });
1272
1272
  }
1273
- r({ queries: _, pending: A, contextReads: T, polls: q });
1273
+ r({ queries: _, pending: A, contextReads: C, polls: q });
1274
1274
  }
1275
1275
  }
1276
1276
  }
@@ -1279,11 +1279,11 @@ function Ls(t, e, s) {
1279
1279
  if (w && I) {
1280
1280
  const _ = { ...n.features.contextRunOrigins };
1281
1281
  delete _[I], r({ contextRunOrigins: _ });
1282
- for (const [A, T] of Object.entries(n.features.originContextQueries)) {
1283
- if (T.origin !== w) continue;
1282
+ for (const [A, C] of Object.entries(n.features.originContextQueries)) {
1283
+ if (C.origin !== w) continue;
1284
1284
  const q = { ...n.features.pending };
1285
- for (const [C, O] of Object.entries(q)) O.mode === "query" && O.key === A && delete q[C];
1286
- r({ pending: q }), m({ ...T, kind: "originContext" }, `context-final:${g.requestId}:${A}`, !0);
1285
+ for (const [T, O] of Object.entries(q)) O.mode === "query" && O.key === A && delete q[T];
1286
+ r({ pending: q }), m({ ...C, kind: "originContext" }, `context-final:${g.requestId}:${A}`, !0);
1287
1287
  }
1288
1288
  }
1289
1289
  }
@@ -1302,7 +1302,7 @@ function Ls(t, e, s) {
1302
1302
  const _ = n.features.queries[I]?.data;
1303
1303
  if (_?.kind === "originContext" && _.value.runId === g.operation.runId) {
1304
1304
  const A = { ...n.features.pending };
1305
- for (const [T, q] of Object.entries(A)) q.mode === "query" && q.key === I && delete A[T];
1305
+ for (const [C, q] of Object.entries(A)) q.mode === "query" && q.key === I && delete A[C];
1306
1306
  r({ pending: A }), m({ ...w, kind: "originContext" }, `context-stop:${g.requestId}:${I}`, !0);
1307
1307
  }
1308
1308
  }
@@ -1350,11 +1350,11 @@ function Ls(t, e, s) {
1350
1350
  function Pt(t, e) {
1351
1351
  return t.account.authority ? t.features.queries[ie(t.account.authority, e)] ?? null : null;
1352
1352
  }
1353
- function Yr(t, e) {
1353
+ function Zr(t, e) {
1354
1354
  const s = Pt(t, e);
1355
1355
  return s?.status === "loading" || s?.status === "refreshing" || !!(t.account.authority && t.features.polls[ie(t.account.authority, e)]);
1356
1356
  }
1357
- const Zr = {
1357
+ const eo = {
1358
1358
  taskNotificationsEnabled: null,
1359
1359
  tabGroupingEnabled: null,
1360
1360
  scribbleStyleEnabled: null,
@@ -1363,7 +1363,7 @@ const Zr = {
1363
1363
  preferencesVersion: 0,
1364
1364
  securityPolicyVersion: 1
1365
1365
  };
1366
- function eo(t, e, s, n) {
1366
+ function to(t, e, s, n) {
1367
1367
  let i = Promise.resolve(), r = !1;
1368
1368
  const a = (d) => {
1369
1369
  if (JSON.stringify(s()) !== JSON.stringify(d)) throw new Error("Feature authority retired.");
@@ -1445,7 +1445,7 @@ function eo(t, e, s, n) {
1445
1445
  if (l.kind !== "preference" && l.kind !== "scribblePreference") return t["stage7.mutate"](d);
1446
1446
  const u = await o(async () => {
1447
1447
  a(d.authority);
1448
- const h = await e.load(d.authority.userId), p = h?.value ?? Zr, m = l.kind === "preference" ? { [l.feature === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled"]: l.enabled } : { scribbleStyleEnabled: l.enabled }, f = { ...p, ...m, preferencesVersion: p.preferencesVersion + 1 };
1448
+ const h = await e.load(d.authority.userId), p = h?.value ?? eo, m = l.kind === "preference" ? { [l.feature === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled"]: l.enabled } : { scribbleStyleEnabled: l.enabled }, f = { ...p, ...m, preferencesVersion: p.preferencesVersion + 1 };
1449
1449
  return await e.save(d.authority.userId, { value: f, pending: [...h?.pending ?? [], l] }), f;
1450
1450
  });
1451
1451
  return a(d.authority), c(d.authority), { data: { kind: "preferences", value: u }, completedAt: n() };
@@ -1457,7 +1457,7 @@ function it(t) {
1457
1457
  const e = t;
1458
1458
  return Object.keys(t).every((s) => ["boundary", "category", "messageKind"].includes(s)) && ["runtime", "web_transport", "extension_ipc"].includes(e.boundary) && ["error", "object", "null", "array", "string", "undefined", "number", "boolean", "bigint", "symbol", "function"].includes(e.category) && ["object_coercion", "text", "blank", "non_text"].includes(e.messageKind);
1459
1459
  }
1460
- function to(t) {
1460
+ function so(t) {
1461
1461
  if (t.details !== void 0 && !je(t.details))
1462
1462
  throw new TypeError("Product Agent transported error details must be JSON-safe.");
1463
1463
  return {
@@ -1484,7 +1484,7 @@ function Y(t, e = "runtime_error", s = "runtime") {
1484
1484
  ...typeof o.durationMs == "number" && Number.isFinite(o.durationMs) && o.durationMs >= 0 ? { durationMs: o.durationMs } : {},
1485
1485
  ...typeof o.successfulRequests == "number" && Number.isSafeInteger(o.successfulRequests) && o.successfulRequests >= 0 ? { successfulRequests: o.successfulRequests } : {}
1486
1486
  };
1487
- return to({
1487
+ return so({
1488
1488
  code: r,
1489
1489
  message: i.trim() && i.trim() !== "[object Object]" ? i : "The Product Agent operation failed. Try again.",
1490
1490
  retryable: !!(n && "retryable" in n && n.retryable === !0),
@@ -1538,7 +1538,7 @@ function Ut(t) {
1538
1538
  const e = N(t);
1539
1539
  return { eligibleSince: Dt(e.eligibleSince), revision: xe(e.revision), requestId: de(e.requestId), snoozedUntil: Dt(e.snoozedUntil) };
1540
1540
  }
1541
- function so(t) {
1541
+ function no(t) {
1542
1542
  const e = N(t);
1543
1543
  return { notifications: Ut(e.notifications), tab_grouping: Ut(e.tabGrouping) };
1544
1544
  }
@@ -1570,7 +1570,7 @@ function is(t) {
1570
1570
  ...e.targetAncestorRegex == null ? {} : { targetAncestorRegex: P(e.targetAncestorRegex) }
1571
1571
  };
1572
1572
  }
1573
- function no(t) {
1573
+ function io(t) {
1574
1574
  const e = N(t), s = N(e.condition), n = { id: P(e.id), suggestedQuery: P(e.suggestedQuery) };
1575
1575
  if (s.template === "page_visit") return { ...n, condition: { template: s.template, urlRegex: P(s.urlRegex) } };
1576
1576
  if (s.template === "semantic_interaction") return { ...n, condition: { template: s.template, event: is(s.event) } };
@@ -1640,7 +1640,7 @@ function rs(t) {
1640
1640
  sdk_preview_open: t.sdkPreviewOpen
1641
1641
  };
1642
1642
  }
1643
- function io(t) {
1643
+ function ro(t) {
1644
1644
  const e = (n) => {
1645
1645
  if (JSON.stringify(n) !== JSON.stringify(t.authority())) throw new Error("Feature authority retired.");
1646
1646
  }, s = {
@@ -1656,7 +1656,7 @@ function io(t) {
1656
1656
  c = { kind: "preferences", value: He(await o("/preferences")) };
1657
1657
  break;
1658
1658
  case "preferencePrompts":
1659
- c = { kind: "preferencePrompts", value: so(await o("/preference-prompts")) };
1659
+ c = { kind: "preferencePrompts", value: no(await o("/preference-prompts")) };
1660
1660
  break;
1661
1661
  case "decisions": {
1662
1662
  const d = N(await o("/interaction-decisions"));
@@ -1677,7 +1677,7 @@ function io(t) {
1677
1677
  prompts: It(d.starterPrompts),
1678
1678
  morningReportOpening: de(d.morningReportOpening),
1679
1679
  signupAt: P(d.signupAt),
1680
- proactiveSuggestions: d.proactiveSuggestions.map(no)
1680
+ proactiveSuggestions: d.proactiveSuggestions.map(io)
1681
1681
  };
1682
1682
  break;
1683
1683
  }
@@ -1786,9 +1786,9 @@ function io(t) {
1786
1786
  return e(n), { data: c, completedAt: t.now() };
1787
1787
  }
1788
1788
  };
1789
- return t.preferenceStorage ? eo(s, t.preferenceStorage, t.authority, t.now) : s;
1789
+ return t.preferenceStorage ? to(s, t.preferenceStorage, t.authority, t.now) : s;
1790
1790
  }
1791
- function ro(t) {
1791
+ function oo(t) {
1792
1792
  let e = null, s = null, n = !1;
1793
1793
  const i = () => {
1794
1794
  e !== null && clearTimeout(e), e = null, s?.({ now: t() }), s = null;
@@ -1806,7 +1806,7 @@ function ro(t) {
1806
1806
  }
1807
1807
  };
1808
1808
  }
1809
- function oo(t, e) {
1809
+ function ao(t, e) {
1810
1810
  let s = "";
1811
1811
  const n = () => {
1812
1812
  const r = t.engine.getState().slices, a = r.account.authority;
@@ -1821,16 +1821,16 @@ function oo(t, e) {
1821
1821
  }, i = t.engine.subscribe(n);
1822
1822
  return t.onDispose(i), n(), i;
1823
1823
  }
1824
- async function ao(t, e, s) {
1824
+ async function co(t, e, s) {
1825
1825
  await t.engine.dispatch({ type: "stage7.initialize", authority: e, now: s }), await t.engine.dispatch({ type: "stage7.reconcile", authority: e, now: s, requestId: crypto.randomUUID(), reason: "startup" });
1826
1826
  }
1827
1827
  function os(t, e, s = {}) {
1828
- return $i(t, { type: "stage7.query", query: e, force: s.force });
1828
+ return zi(t, { type: "stage7.query", query: e, force: s.force });
1829
1829
  }
1830
- function co(t, e, s) {
1831
- return $i(t, { type: "stage7.mutate", mutation: e });
1830
+ function lo(t, e, s) {
1831
+ return zi(t, { type: "stage7.mutate", mutation: e });
1832
1832
  }
1833
- function $i(t, e, s) {
1833
+ function zi(t, e, s) {
1834
1834
  const n = t.engine.getState().slices.account.authority;
1835
1835
  if (!n || t.isDisposed) return Promise.reject(new Error("Product Agent is not authenticated."));
1836
1836
  const r = (e.type === "stage7.mutate" && ["generatePrompts", "sampleStyle"].includes(e.mutation.kind) ? Object.values(t.engine.getState().slices.features.pending).find((a) => a.status === "pending" && a.mode === "mutation" && a.fingerprint === JSON.stringify(e.mutation)) : null)?.requestId ?? crypto.randomUUID();
@@ -1863,7 +1863,7 @@ function $i(t, e, s) {
1863
1863
  }, (m) => h(m));
1864
1864
  });
1865
1865
  }
1866
- async function lo(t, e, s = crypto.randomUUID()) {
1866
+ async function uo(t, e, s = crypto.randomUUID()) {
1867
1867
  const n = t.engine.getState().slices.account.authority;
1868
1868
  if (!n || t.isDisposed) throw new Error("Product Agent is not authenticated.");
1869
1869
  const i = Object.entries(t.engine.getState().slices.interactions.actions).find(([, a]) => a.clientScopeId === e.clientScopeId && a.sourceVersion === (e.expectedSourceVersion ?? null) && a.interactionId === e.interactionId && a.action === e.action && a.expectedRevision === e.expectedRevision && a.status === "error" && a.step === "persist"), r = i?.[0] ?? s;
@@ -1898,8 +1898,8 @@ async function lo(t, e, s = crypto.randomUUID()) {
1898
1898
  }, h);
1899
1899
  });
1900
1900
  }
1901
- function uo(t, e, s, n) {
1902
- return Li(t, e, s, n).map((i) => {
1901
+ function ho(t, e, s, n) {
1902
+ return Fi(t, e, s, n).map((i) => {
1903
1903
  const r = i.sourceId ? Object.values(t.interactions.sources).find((m) => m.id === i.sourceId && m.conversation_id === i.conversationId) : null, a = r?.payload, o = i.payload.feature, c = i.category === "permission", d = i.category === "sharing" ? "social_share" : i.category === "integration_auth" ? "integration_connection" : i.category === "personal_channel" ? "personal_channel_connection" : o === "notifications" ? "task_notifications" : o === "tab_grouping" ? "tab_group_permission" : i.category, l = d === "integration_connection" && a?.kind === "integration_auth" ? `Connect ${a.app_name}` : d === "personal_channel_connection" ? "Connect WhatsApp" : null, u = o === "notifications" ? c ? "Allow notifications in this browser?" : "Get notified when Pluno finishes a task?" : o === "tab_grouping" ? c ? "Allow Pluno to group tabs in this browser?" : "Group tabs used by Pluno?" : i.category === "sharing" ? "Share what Pluno helped you accomplish." : String(i.payload.text ?? l ?? ""), h = Object.fromEntries(i.actions.map((m) => [m, i.actionLabels?.[m] ?? { enable: "Enable", not_now: "Not now", dont_enable: "Don't ask again", allow: "Allow", run: i.category === "proactive_suggestion" ? "Yes" : "Start", edit: "Edit", never: "Never", snooze: "Snooze morning report", pair: "Pair WhatsApp", dismiss: "Dismiss", copy: "Copy", share: "Share", feedback: "Send feedback" }[m] ?? m])), p = a?.kind === "integration_auth" ? { type: "pipedream_auth_required", authRequestId: a.request_id, appSlug: a.app_slug, appName: a.app_name, appLogo: a.app_logo, expiresAt: a.expires_at } : a?.kind === "personal_channel" ? { type: "personal_channel_connection_required", requestId: a.request_id, channel: a.channel, managementUrl: a.management_url } : null;
1904
1904
  return {
1905
1905
  id: i.id,
@@ -1928,7 +1928,7 @@ function uo(t, e, s, n) {
1928
1928
  };
1929
1929
  });
1930
1930
  }
1931
- function ho(t, e, s) {
1931
+ function po(t, e, s) {
1932
1932
  return {
1933
1933
  user: e,
1934
1934
  communityId: s,
@@ -1941,7 +1941,7 @@ function ho(t, e, s) {
1941
1941
  presentation: t
1942
1942
  };
1943
1943
  }
1944
- function po(t, e = null) {
1944
+ function fo(t, e = null) {
1945
1945
  if (!t.authority) return null;
1946
1946
  const s = t.query.data, n = s?.presentation ?? {
1947
1947
  creditsUsed: null,
@@ -1951,7 +1951,7 @@ function po(t, e = null) {
1951
1951
  paymentIssue: null,
1952
1952
  pricingUrl: "",
1953
1953
  earnCreditsUrl: ""
1954
- }, i = Mi(t, "send_message"), r = i.reason === "unavailable" && n.submissionGate?.allowed === !1, a = t.refusal ?? (i.allowed ? n.submissionGate ?? { allowed: !0, reason: "allowed", actions: [] } : r ? n.submissionGate : {
1954
+ }, i = Pi(t, "send_message"), r = i.reason === "unavailable" && n.submissionGate?.allowed === !1, a = t.refusal ?? (i.allowed ? n.submissionGate ?? { allowed: !0, reason: "allowed", actions: [] } : r ? n.submissionGate : {
1955
1955
  allowed: !1,
1956
1956
  reason: i.reason === "workspace" ? "workspace_required" : i.reason === "authentication" ? "authentication_required" : i.reason === "unavailable" ? "connection_required" : n.submissionGate?.reason ?? "credits_exhausted",
1957
1957
  actions: n.submissionGate?.actions ?? []
@@ -1962,9 +1962,9 @@ function po(t, e = null) {
1962
1962
  } : void 0);
1963
1963
  return { ...n, ...o ? { auth: o } : {}, submissionGate: a, usingPaidCreditFallback: e ? t.paidFallbackBySession[e] ?? !1 : !1 };
1964
1964
  }
1965
- const fo = "0.1.276", Lt = {
1966
- version: fo
1967
- }, ln = (t) => t.selectedModel ?? t.historyModel ?? t.defaultModel, go = (t, e) => t.scopes[e];
1965
+ const go = "0.1.278", Lt = {
1966
+ version: go
1967
+ }, ln = (t) => t.selectedModel ?? t.historyModel ?? t.defaultModel, mo = (t, e) => t.scopes[e];
1968
1968
  function Ft(t) {
1969
1969
  if (!Number.isSafeInteger(t) || t < 0) throw new Error("Invalid conversation revision.");
1970
1970
  }
@@ -1987,7 +1987,7 @@ function Fs(t, e) {
1987
1987
  }
1988
1988
  return { ...t, items: { ...t.items, [e.id]: { ...e, created_at: r?.created_at ?? e.created_at } } };
1989
1989
  }
1990
- function zi(t, e) {
1990
+ function Hi(t, e) {
1991
1991
  if (Ft(e.revision), t.removedItems[e.item_id]) return t;
1992
1992
  const s = t.streams[e.item_id];
1993
1993
  return s && (s.state === "stopped" || e.revision < s.revision || s.state !== "open" && (e.state === "open" || e.revision === s.revision) || s.state === e.state && s.revision === e.revision) ? t : { ...t, streams: { ...t.streams, [e.item_id]: e } };
@@ -2003,7 +2003,7 @@ function $s(t, e) {
2003
2003
  };
2004
2004
  return { ...t, execution: e, executionByUserMessage: s };
2005
2005
  }
2006
- function mo(t) {
2006
+ function yo(t) {
2007
2007
  const e = /* @__PURE__ */ new Set();
2008
2008
  for (const s of Object.values(t.items)) {
2009
2009
  const n = Mt(s), i = t.streams[s.id];
@@ -2025,7 +2025,7 @@ function as(t, e) {
2025
2025
  return $s(t, e.execution);
2026
2026
  case "conversation.item.stream_finished":
2027
2027
  if (e.conversation_id !== t.sessionId) throw new Error("Stream belongs to another conversation.");
2028
- return zi(t, { item_id: e.item_id, revision: e.revision, state: e.state });
2028
+ return Hi(t, { item_id: e.item_id, revision: e.revision, state: e.state });
2029
2029
  case "conversation.item.removed": {
2030
2030
  if (e.conversation_id !== t.sessionId) throw new Error("Removal belongs to another conversation.");
2031
2031
  if (t.removedItems[e.item_id]) return t;
@@ -2051,7 +2051,7 @@ function Hs(t, e) {
2051
2051
  }
2052
2052
  function Vs(t, e, s = !1) {
2053
2053
  if (t.authorityId !== (e.authorityId ?? "") || t.generation !== e.generation) {
2054
- const r = Pi(e.authorityId ?? void 0, e.generation);
2054
+ const r = Di(e.authorityId ?? void 0, e.generation);
2055
2055
  if (!s || t.authorityId) return r;
2056
2056
  const a = Object.fromEntries(Object.entries(t.submissions).filter(([o, c]) => c.sessionId === null && !c.cancelled && t.deliveries[o]?.acceptance === "unissued" && e.clients[c.clientScopeId] === c.conversationScopeId));
2057
2057
  return {
@@ -2085,7 +2085,7 @@ function Vs(t, e, s = !1) {
2085
2085
  function ht(t) {
2086
2086
  return JSON.stringify(t, (e, s) => s && typeof s == "object" && !Array.isArray(s) ? Object.fromEntries(Object.entries(s).sort(([n], [i]) => n.localeCompare(i))) : s);
2087
2087
  }
2088
- function yo(t, e, s, n) {
2088
+ function vo(t, e, s, n) {
2089
2089
  let i = t;
2090
2090
  const r = [];
2091
2091
  let a = null;
@@ -2095,7 +2095,7 @@ function yo(t, e, s, n) {
2095
2095
  let c = t.sessions[o.sessionId];
2096
2096
  const d = c.queries[o.lane];
2097
2097
  if (d.requestId !== o.requestId) return { state: t, effects: r };
2098
- const l = e.type === "effect.failed" && Di(e.error.code), u = e.type === "effect.failed" && Number(e.error.details?.successfulRequests ?? 0) > 0 ? null : c.historyRefreshFailure;
2098
+ const l = e.type === "effect.failed" && Ui(e.error.code), u = e.type === "effect.failed" && Number(e.error.details?.successfulRequests ?? 0) > 0 ? null : c.historyRefreshFailure;
2099
2099
  o.lane === "current" && (c = { ...c, historyRefreshFailure: l ? {
2100
2100
  sessionId: o.sessionId,
2101
2101
  episodeId: u?.episodeId ?? `${t.generation}:${o.sessionId}:${o.requestId}`,
@@ -2129,7 +2129,7 @@ function yo(t, e, s, n) {
2129
2129
  if (m.conversation_id !== o.sessionId) throw new Error("Snapshot belongs to another conversation.");
2130
2130
  for (const b of m.removed_items) c = as(c, b);
2131
2131
  for (const b of m.items) c = Fs(c, b);
2132
- for (const b of m.streams) c = zi(c, b);
2132
+ for (const b of m.streams) c = Hi(c, b);
2133
2133
  if (c = $s(c, m.execution), c = as(c, {
2134
2134
  type: "conversation.follow_ups.updated",
2135
2135
  conversation_id: m.conversation_id,
@@ -2189,24 +2189,24 @@ function yo(t, e, s, n) {
2189
2189
  }
2190
2190
  case "conversation.submission_stage": {
2191
2191
  if (s.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
2192
- const { type: o, authorityId: c, generation: d, prepareContext: l, waitForAuthentication: u, ...h } = e, p = t.submissions[e.userMessageId];
2193
- if (p) {
2194
- const { contextPreparation: R, requestedModel: g, sessionId: v, delivery: I, cancelled: w, cancellationReason: _, error: A, executionVersion: T, ...q } = p;
2195
- if (ht(q) !== ht(h)) throw new Error("User-message identity cannot be reused with different input.");
2192
+ const { type: o, authorityId: c, generation: d, prepareContext: l, reconcileAcceptance: u, waitForAuthentication: h, ...p } = e, m = t.submissions[e.userMessageId];
2193
+ if (m) {
2194
+ const { contextPreparation: g, requestedModel: v, sessionId: I, delivery: w, cancelled: _, cancellationReason: A, error: C, executionVersion: q, ...T } = m;
2195
+ if (ht(T) !== ht(p)) throw new Error("User-message identity cannot be reused with different input.");
2196
2196
  return { state: t, effects: r };
2197
2197
  }
2198
- const m = s.selections[e.conversationScopeId], f = Object.values(t.submissions).find((R) => R.conversationScopeId === e.conversationScopeId && !R.cancelled && R.sessionId !== null), y = n.scopes[e.clientScopeId], b = {
2199
- ...Z(h),
2198
+ const f = s.selections[e.conversationScopeId], y = Object.values(t.submissions).find((g) => g.conversationScopeId === e.conversationScopeId && !g.cancelled && g.sessionId !== null), b = n.scopes[e.clientScopeId], k = {
2199
+ ...Z(p),
2200
2200
  ...l ? { contextPreparation: null } : {},
2201
2201
  // Extension staging can await page context after the picker has already changed.
2202
- requestedModel: y?.submissions[e.userMessageId] ? y.submissions[e.userMessageId].requestedModel ?? null : y ? ln(y) ?? null : null,
2203
- sessionId: m.sessionId ?? f?.sessionId ?? null,
2204
- delivery: u ? "failed" : "staged",
2202
+ requestedModel: b?.submissions[e.userMessageId] ? b.submissions[e.userMessageId].requestedModel ?? null : b ? ln(b) ?? null : null,
2203
+ sessionId: f.sessionId ?? y?.sessionId ?? null,
2204
+ delivery: h ? "failed" : "staged",
2205
2205
  cancelled: !1,
2206
- error: u ? { code: u, message: u === "unauthorized" ? "Open the Pluno login link, then return to Pluno." : "Pluno is reconnecting. Try again in a moment.", retryable: !1 } : null,
2206
+ error: h ? { code: h, message: h === "unauthorized" ? "Open the Pluno login link, then return to Pluno." : "Pluno is reconnecting. Try again in a moment.", retryable: !1 } : null,
2207
2207
  executionVersion: null
2208
- }, k = { ...t.proactiveQuestions };
2209
- delete k[e.conversationScopeId], i = { ...t, proactiveQuestions: k, submissions: { ...t.submissions, [e.userMessageId]: b }, submissionOrder: [...t.submissionOrder, e.userMessageId] };
2208
+ }, R = { ...t.proactiveQuestions };
2209
+ delete R[e.conversationScopeId], i = { ...t, proactiveQuestions: R, submissions: { ...t.submissions, [e.userMessageId]: k }, submissionOrder: [...t.submissionOrder, e.userMessageId] };
2210
2210
  break;
2211
2211
  }
2212
2212
  case "conversation.submission_accepted": {
@@ -2273,7 +2273,7 @@ function yo(t, e, s, n) {
2273
2273
  requestId: e.requestId,
2274
2274
  lane: e.lane,
2275
2275
  before: e.lane === "history" ? c.cursor : null,
2276
- refreshItemIds: mo(o),
2276
+ refreshItemIds: yo(o),
2277
2277
  retryPreparation: c.error?.code === "history_preparation_failed"
2278
2278
  }, l = Object.values(t.submissions).filter((p) => p.sessionId === e.sessionId && p.delivery === "accepted" && p.executionVersion === null).map((p) => p.userMessageId), u = t.requestSequence + 1, h = `conversation:${t.generation}:${u}`;
2279
2279
  i = {
@@ -2343,7 +2343,7 @@ function un(t, e) {
2343
2343
  requestSequence: t.requestSequence
2344
2344
  });
2345
2345
  }
2346
- function Hi(t) {
2346
+ function Vi(t) {
2347
2347
  return t.command.type !== "chat.retry_last_user_message";
2348
2348
  }
2349
2349
  function we(t, e) {
@@ -2362,7 +2362,7 @@ function Ks(t, e, s, n = !1) {
2362
2362
  function Ws(t, e = null) {
2363
2363
  return { command: Z(t), conversationScopeId: e, phase: "waiting", effectId: null, result: null, error: null };
2364
2364
  }
2365
- function vo(t) {
2365
+ function bo(t) {
2366
2366
  const e = { ...t.context, ...t.contextPreparation };
2367
2367
  return Object.fromEntries(["page", "pageContent", "agentMode", "metadata", "sessionTabs", "proactiveSuggestionQuestion"].filter((s) => s in e).map((s) => [s, e[s]]));
2368
2368
  }
@@ -2380,6 +2380,11 @@ function Gs(t) {
2380
2380
  const c = e.submissions[o];
2381
2381
  let d = e.deliveries[o];
2382
2382
  if (t.pendingRestoration[c.clientScopeId] === c.conversationScopeId || !d || d.phase !== "waiting" || !we(e, o) || c.delivery === "accepted") continue;
2383
+ if (d.handoffRecovery && d.step === "receipt") {
2384
+ const p = i();
2385
+ e = { ...e, deliveries: { ...e.deliveries, [o]: { ...d, phase: "running", effectId: p, prepared: c.cancelled } } }, s.push({ id: p, kind: "conversation.receipt", input: { ...n, userMessageId: o, sessionId: c.sessionId } });
2386
+ continue;
2387
+ }
2383
2388
  if (!d.prepared && !c.cancelled) {
2384
2389
  const p = i();
2385
2390
  e = { ...e, deliveries: { ...e.deliveries, [o]: { ...d, phase: "running", effectId: p } } }, s.push({ id: p, kind: "conversation.prepare", input: { ...n, submission: c, sources: c.attachments.slice(d.uploads.length) } });
@@ -2412,7 +2417,7 @@ function Gs(t) {
2412
2417
  request_id: c.requestId,
2413
2418
  type: "chat.user_message",
2414
2419
  payload: {
2415
- ...vo(c),
2420
+ ...bo(c),
2416
2421
  sessionId: c.sessionId,
2417
2422
  clientMessageId: o,
2418
2423
  content: c.content,
@@ -2473,7 +2478,7 @@ function Gs(t) {
2473
2478
  }
2474
2479
  return { state: G(e), effects: s };
2475
2480
  }
2476
- function bo(t, e, s, n) {
2481
+ function Io(t, e, s, n) {
2477
2482
  let i = t, r = e;
2478
2483
  if (e.type === "effect.completed" || e.type === "effect.failed") {
2479
2484
  e.effectKind === "conversation.checkpoint" && e.effectId === t.checkpointEffectId && (i = { ...i, checkpointEffectId: null, checkpointError: e.type === "effect.failed" ? e.error : null }), e.type === "effect.completed" && e.effectKind === "conversation.checkpoint" && e.output && e.output.authorityId === t.authorityId && e.output.generation === t.generation && (i = { ...i, durableSubmissionIds: [.../* @__PURE__ */ new Set([...t.durableSubmissionIds, ...e.output.submissionIds])].filter((p) => !!t.submissions[p]) });
@@ -2483,7 +2488,13 @@ function bo(t, e, s, n) {
2483
2488
  let f = { ...p, phase: "waiting", effectId: null };
2484
2489
  if (e.type === "effect.failed") {
2485
2490
  const y = e.error.details?.acceptance === "unissued" && p.acceptance !== "accepted" ? "unissued" : e.error.details?.acceptance === "rejected" ? "rejected" : p.acceptance, b = e.error.details?.allocation === "unissued" ? "unissued" : p.allocation, k = e.effectKind === "conversation.command" && p.step === "send" && y === "unissued" || e.effectKind === "conversation.upload" && e.error.details?.allocation === "unissued", R = e.effectKind === "conversation.prepare" || k ? "failed" : y === "uncertain" || b === "uncertain" || e.error.retryable ? "uncertain" : "failed";
2486
- f = { ...f, phase: R, acceptance: y, allocation: b }, !m.cancelled && m.delivery !== "accepted" && (i = { ...i, submissions: {
2491
+ f = {
2492
+ ...f,
2493
+ phase: R,
2494
+ acceptance: y,
2495
+ allocation: b,
2496
+ ...p.handoffRecovery && p.step === "send" ? { step: "receipt" } : {}
2497
+ }, !m.cancelled && m.delivery !== "accepted" && (i = { ...i, submissions: {
2487
2498
  ...i.submissions,
2488
2499
  [u]: { ...m, delivery: R, error: e.error }
2489
2500
  } });
@@ -2507,7 +2518,9 @@ function bo(t, e, s, n) {
2507
2518
  ]));
2508
2519
  i = { ...i, submissions: k };
2509
2520
  } else if (e.effectKind === "conversation.receipt")
2510
- if (e.output === null)
2521
+ if (e.output === null && p.handoffRecovery && !m.cancelled)
2522
+ f = { ...f, phase: "waiting", step: null };
2523
+ else if (e.output === null)
2511
2524
  f = { ...f, phase: m.cancelled ? "uncertain" : "paused" }, m.cancelled || (i = { ...i, submissions: { ...i.submissions, [u]: {
2512
2525
  ...m,
2513
2526
  delivery: "failed",
@@ -2590,11 +2603,11 @@ function bo(t, e, s, n) {
2590
2603
  executionVersion: null,
2591
2604
  cancelled: v.cancelled || !R(v) && !Hs(v, s),
2592
2605
  ...!v.cancelled && !R(v) && !Hs(v, s) ? { cancellationReason: "owner_lost" } : {},
2593
- delivery: (v.contextPreparation === null || !m.deliveries[g]) && !v.cancelled && v.delivery !== "accepted" ? "failed" : v.delivery === "sending" ? "uncertain" : v.delivery,
2594
- error: v.contextPreparation === null && !v.cancelled && !["unauthorized", "auth_reconnecting"].includes(v.error?.code ?? "") ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !m.deliveries[g] && v.delivery !== "accepted" && !v.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : v.error
2606
+ delivery: (v.contextPreparation === null && !m.deliveries[g]?.handoffRecovery || !m.deliveries[g]) && !v.cancelled && v.delivery !== "accepted" ? "failed" : v.delivery === "sending" ? "uncertain" : v.delivery,
2607
+ error: v.contextPreparation === null && !m.deliveries[g]?.handoffRecovery && !v.cancelled && !["unauthorized", "auth_reconnecting"].includes(v.error?.code ?? "") ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !m.deliveries[g] && v.delivery !== "accepted" && !v.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : v.error
2595
2608
  }])),
2596
2609
  deliveries: Object.fromEntries(Object.entries(m.submissions).map(([g, v], I) => {
2597
- const w = m.deliveries[g], _ = v.contextPreparation === null, A = v.delivery === "accepted" ? "accepted" : w?.acceptance ?? (w && (w.step === "send" || w.step === "receipt") ? "uncertain" : "unissued");
2610
+ const w = m.deliveries[g], _ = v.contextPreparation === null && !w?.handoffRecovery, A = v.delivery === "accepted" ? "accepted" : w?.acceptance ?? (w && (w.step === "send" || w.step === "receipt") ? "uncertain" : "unissued");
2598
2611
  return [g, {
2599
2612
  ...zn(v, I),
2600
2613
  ...w,
@@ -2602,7 +2615,7 @@ function bo(t, e, s, n) {
2602
2615
  allocation: v.sessionId !== null ? "resolved" : w?.allocation ?? (w?.step === "upload" ? "uncertain" : "unissued"),
2603
2616
  effectId: null,
2604
2617
  // Readiness is authority-local and must be re-established after restart. Captured input stays immutable.
2605
- step: A === "uncertain" && w?.step === "send" && w.phase !== "done" ? "receipt" : w?.step ?? null,
2618
+ step: A === "uncertain" && (w?.step === "send" || w?.handoffRecovery) && w.phase !== "done" ? "receipt" : w?.step ?? null,
2606
2619
  prepared: A === "accepted",
2607
2620
  queuePosition: w?.queuePosition ?? I,
2608
2621
  phase: A === "accepted" ? "done" : _ || !w ? "failed" : ["running", "waiting"].includes(w.phase) ? "uncertain" : w.phase
@@ -2627,7 +2640,7 @@ function bo(t, e, s, n) {
2627
2640
  ])),
2628
2641
  operations: Object.fromEntries(Object.entries(t.operations).map(([u, h]) => [
2629
2642
  u,
2630
- h.phase === "uncertain" && Hi(h) ? { ...h, phase: "waiting" } : h
2643
+ h.phase === "uncertain" && Vi(h) ? { ...h, phase: "waiting" } : h
2631
2644
  ]))
2632
2645
  }), e.type === "conversation.submit") {
2633
2646
  const u = t.submissions[e.userMessageId];
@@ -2690,13 +2703,17 @@ function bo(t, e, s, n) {
2690
2703
  u?.phase === "uncertain" && (i = { ...t, operations: { ...t.operations, [e.requestId]: { ...u, phase: "waiting" } } });
2691
2704
  }
2692
2705
  }
2693
- const a = yo(i, r, s, n);
2706
+ const a = vo(i, r, s, n);
2694
2707
  let o = a.state;
2695
2708
  e.type === "conversation.submission_stage" && o !== i && !o.deliveries[e.userMessageId] && (o = {
2696
2709
  ...o,
2697
2710
  effectsEnabled: !0,
2698
2711
  requestSequence: o.requestSequence + 1,
2699
- deliveries: { ...o.deliveries, [e.userMessageId]: { ...zn(o.submissions[e.userMessageId], o.requestSequence + 1), ...e.waitForAuthentication ? { phase: "failed" } : {} } }
2712
+ deliveries: { ...o.deliveries, [e.userMessageId]: {
2713
+ ...zn(o.submissions[e.userMessageId], o.requestSequence + 1),
2714
+ ...e.reconcileAcceptance !== void 0 ? { handoffRecovery: !0, recoveryDeadline: e.reconcileAcceptance + 18e4, acceptance: "uncertain", step: "receipt" } : {},
2715
+ ...e.waitForAuthentication ? { phase: "failed" } : {}
2716
+ } }
2700
2717
  });
2701
2718
  for (const [u, h] of Object.entries(o.submissions)) {
2702
2719
  const p = o.deliveries[u];
@@ -2724,7 +2741,7 @@ function bo(t, e, s, n) {
2724
2741
  const d = Gs(o), l = Ks(t, d.state, s, e.type === "conversation.recover" && t.checkpointError !== null);
2725
2742
  return { state: l.state, effects: [...l.effects, ...a.effects, ...d.effects], interactionSources: a.interactionSources };
2726
2743
  }
2727
- const Io = [
2744
+ const wo = [
2728
2745
  "submit",
2729
2746
  "stop",
2730
2747
  "staging_ipc",
@@ -2787,7 +2804,7 @@ const Io = [
2787
2804
  "acceptance_applied",
2788
2805
  "cancellation_queue",
2789
2806
  "cancellation_write"
2790
- ], Vi = [
2807
+ ], Ki = [
2791
2808
  "request_timed_out",
2792
2809
  "delivery_unknown",
2793
2810
  "invalid_ack",
@@ -2803,20 +2820,20 @@ const Io = [
2803
2820
  "backend_refusal",
2804
2821
  "unknown"
2805
2822
  ];
2806
- function wo(t) {
2823
+ function _o(t) {
2807
2824
  const e = t, s = e?.code;
2808
- return e?.backendRefusal === !0 ? "backend_refusal" : typeof s == "string" && s !== "backend_refusal" && Vi.includes(s) ? s : e?.name === "AbortError" ? "aborted" : e?.name === "TypeError" ? "type_error" : "unknown";
2825
+ return e?.backendRefusal === !0 ? "backend_refusal" : typeof s == "string" && s !== "backend_refusal" && Ki.includes(s) ? s : e?.name === "AbortError" ? "aborted" : e?.name === "TypeError" ? "type_error" : "unknown";
2809
2826
  }
2810
- const Ki = Math.random().toString(36).slice(2);
2811
- let _o = 0;
2812
- const Vn = () => `timing:${Ki}:${++_o}`, Ke = (t) => typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t);
2827
+ const Wi = Math.random().toString(36).slice(2);
2828
+ let So = 0;
2829
+ const Vn = () => `timing:${Wi}:${++So}`, Ke = (t) => typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t);
2813
2830
  function rt(t) {
2814
2831
  if (!t || typeof t != "object") return !1;
2815
2832
  const e = t;
2816
- return Object.keys(e).every((s) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory", "tabId", "queueDepth", "workerId"].includes(s)) && (e.tabId === void 0 || Number.isSafeInteger(e.tabId) && e.tabId >= 0) && (e.queueDepth === void 0 || Number.isSafeInteger(e.queueDepth) && e.queueDepth >= 0) && (e.workerId === void 0 || Ke(e.workerId)) && (e.failureCategory === void 0 || e.status === "failed" && Vi.includes(e.failureCategory)) && (e.entrySurface === void 0 || ["extension_sidepanel", "extension_widget", "main_web_chat", "embedded_widget", "embedded_custom_ui", "automation", "mcp", "whatsapp", "email"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && Io.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && Ke(e.spanId) && Ke(e.requestId) && (e.clientMessageId === null || Ke(e.clientMessageId)) && (e.sessionId === null || Ke(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
2833
+ return Object.keys(e).every((s) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory", "tabId", "queueDepth", "workerId"].includes(s)) && (e.tabId === void 0 || Number.isSafeInteger(e.tabId) && e.tabId >= 0) && (e.queueDepth === void 0 || Number.isSafeInteger(e.queueDepth) && e.queueDepth >= 0) && (e.workerId === void 0 || Ke(e.workerId)) && (e.failureCategory === void 0 || e.status === "failed" && Ki.includes(e.failureCategory)) && (e.entrySurface === void 0 || ["extension_sidepanel", "extension_widget", "main_web_chat", "embedded_widget", "embedded_custom_ui", "automation", "mcp", "whatsapp", "email"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && wo.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && Ke(e.spanId) && Ke(e.requestId) && (e.clientMessageId === null || Ke(e.clientMessageId)) && (e.sessionId === null || Ke(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
2817
2834
  }
2818
2835
  function Q(t, e) {
2819
- if (e = { workerId: Ki, ...e }, !t) return {
2836
+ if (e = { workerId: Wi, ...e }, !t) return {
2820
2837
  identity: e,
2821
2838
  mark: (i) => {
2822
2839
  },
@@ -2830,7 +2847,7 @@ function Q(t, e) {
2830
2847
  spanId: o,
2831
2848
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
2832
2849
  durationMs: Math.max(0, Math.round(performance.now() - a)),
2833
- ...r === "failed" ? { failureCategory: wo(c) } : {}
2850
+ ...r === "failed" ? { failureCategory: _o(c) } : {}
2834
2851
  };
2835
2852
  t && rt(d) && Promise.resolve().then(() => t(d)).catch(() => {
2836
2853
  });
@@ -2849,7 +2866,7 @@ function Q(t, e) {
2849
2866
  }
2850
2867
  };
2851
2868
  }
2852
- function So(t) {
2869
+ function ko(t) {
2853
2870
  let e = [], s;
2854
2871
  const n = () => {
2855
2872
  clearTimeout(s), s = void 0;
@@ -2861,7 +2878,7 @@ function So(t) {
2861
2878
  rt(i) && (JSON.stringify([...e, i]).length > 2800 && n(), e.push(i), e.length === 8 ? n() : s ??= setTimeout(n, 250));
2862
2879
  };
2863
2880
  }
2864
- function ko(t) {
2881
+ function Ro(t) {
2865
2882
  let e = Promise.resolve(), s = null, n = null;
2866
2883
  const i = () => n ??= t.read().catch((a) => {
2867
2884
  throw n = null, a;
@@ -2926,7 +2943,7 @@ function ko(t) {
2926
2943
  }
2927
2944
  };
2928
2945
  }
2929
- function Ro(t, e, s, n) {
2946
+ function Ao(t, e, s, n) {
2930
2947
  if (t !== e)
2931
2948
  for (const i of Object.values(e.submissions))
2932
2949
  i.delivery !== "accepted" || t.submissions[i.userMessageId]?.delivery === "accepted" || Q(s, {
@@ -2939,12 +2956,12 @@ function Ro(t, e, s, n) {
2939
2956
  }).mark("acceptance_applied");
2940
2957
  }
2941
2958
  const j = (t) => typeof t == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(t) ? t : null;
2942
- function Ao(t) {
2959
+ function Eo(t) {
2943
2960
  if (!t || typeof t != "object") return !1;
2944
2961
  const e = t, s = (i) => Number.isSafeInteger(i) && i >= 0, n = (i) => i && typeof i == "object" && Object.keys(i).every((r) => ["sequence", "at", "type", "changed", "generation", "sessionId", "scopeId", "requestId", "effectId", "clientScopeId", "reason", "effectKind", "eventType", "itemCount", "removedCount", "projectionReady"].includes(r)) && s(i.sequence) && s(i.at) && j(i.type) !== null && typeof i.changed == "boolean" && [i.generation, i.itemCount, i.removedCount].every((r) => r === null || s(r)) && [i.sessionId, i.scopeId, i.requestId, i.effectId, i.clientScopeId, i.reason, i.effectKind, i.eventType].every((r) => r === null || j(r) !== null) && (i.projectionReady === null || typeof i.projectionReady == "boolean");
2945
2962
  return Object.keys(e).every((i) => ["ownerId", "revision", "dropped", "lastIntent", "lastSelection", "transitions"].includes(i)) && j(e.ownerId) !== null && s(e.revision) && s(e.dropped) && (e.lastIntent == null || n(e.lastIntent)) && (e.lastSelection === null || n(e.lastSelection)) && Array.isArray(e.transitions) && e.transitions.length <= 16 && e.transitions.every(n);
2946
2963
  }
2947
- function Eo(t, e, s) {
2964
+ function qo(t, e, s) {
2948
2965
  const n = t;
2949
2966
  if (!/^(directory\.|conversation\.|session\.)/.test(n.type ?? "") && !/^(directory\.|conversation\.|session\.)/.test(n.effectKind ?? "") || n.type === "conversation.display_received" && !["conversation.execution.updated", "conversation.item.removed"].includes(n.event?.type ?? "")) return null;
2950
2967
  const i = n.output?.snapshot;
@@ -2972,23 +2989,23 @@ function hn(t) {
2972
2989
  const e = t;
2973
2990
  return Object.keys(e).every((s) => ["sessionId", "episodeId", "consecutiveFailures", "transportCode", "requestId", "durationMs"].includes(s)) && 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;
2974
2991
  }
2975
- const Kn = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], pn = (t) => typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t), Ee = (t) => t === null || pn(t), qo = (t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(t) && Number.isFinite(Date.parse(t));
2992
+ const Kn = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], pn = (t) => typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t), Ee = (t) => t === null || pn(t), To = (t) => typeof t == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(t) && Number.isFinite(Date.parse(t));
2976
2993
  function fn(t) {
2977
2994
  if (!t || typeof t != "object") return !1;
2978
2995
  const e = t;
2979
- return Object.keys(t).every((s) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(s)) && Ee(e.sessionId) && pn(e.itemId) && Ee(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && Ee(e.runId) && (e.createdAt === null || qo(e.createdAt));
2996
+ return Object.keys(t).every((s) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(s)) && Ee(e.sessionId) && pn(e.itemId) && Ee(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && Ee(e.runId) && (e.createdAt === null || To(e.createdAt));
2980
2997
  }
2981
- function To(t) {
2998
+ function Co(t) {
2982
2999
  if (!t || typeof t != "object") return !1;
2983
3000
  const e = t, s = (n) => Number.isSafeInteger(n) && n >= 0;
2984
- return Object.keys(e).every((n) => ["capturedAt", "selectionKey", "userId", "loading", "draft", "thinking", "connected", "hasError", "phase", "queryStatus", "queryRequestId", "queryUpdatedAt", "renderSource", "selectionFencePending", "guardCreatedAt", "owner", "sdkVersion", "presentationGate", "firstObservedAt", "confirmationMs"].includes(n)) && s(e.capturedAt) && [e.queryUpdatedAt, e.guardCreatedAt].every((n) => n === null || s(n)) && [e.selectionKey, e.userId, e.phase, e.queryStatus, e.queryRequestId].every((n) => n === null || j(n) !== null) && [e.loading, e.draft, e.thinking, e.connected, e.hasError, e.selectionFencePending].every((n) => typeof n == "boolean") && ["state", "account", "interactions", "local", "sidepanel_layout", "observer"].includes(e.renderSource) && (e.owner === void 0 || Ao(e.owner)) && (e.sdkVersion === void 0 || typeof e.sdkVersion == "string" && e.sdkVersion.length <= 32 && /^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/.test(e.sdkVersion)) && (e.presentationGate === void 0 || ["none", "authentication", "signup"].includes(e.presentationGate)) && [e.firstObservedAt, e.confirmationMs].every((n) => n === void 0 || s(n));
3001
+ return Object.keys(e).every((n) => ["capturedAt", "selectionKey", "userId", "loading", "draft", "thinking", "connected", "hasError", "phase", "queryStatus", "queryRequestId", "queryUpdatedAt", "renderSource", "selectionFencePending", "guardCreatedAt", "owner", "sdkVersion", "presentationGate", "firstObservedAt", "confirmationMs"].includes(n)) && s(e.capturedAt) && [e.queryUpdatedAt, e.guardCreatedAt].every((n) => n === null || s(n)) && [e.selectionKey, e.userId, e.phase, e.queryStatus, e.queryRequestId].every((n) => n === null || j(n) !== null) && [e.loading, e.draft, e.thinking, e.connected, e.hasError, e.selectionFencePending].every((n) => typeof n == "boolean") && ["state", "account", "interactions", "local", "sidepanel_layout", "observer"].includes(e.renderSource) && (e.owner === void 0 || Eo(e.owner)) && (e.sdkVersion === void 0 || typeof e.sdkVersion == "string" && e.sdkVersion.length <= 32 && /^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/.test(e.sdkVersion)) && (e.presentationGate === void 0 || ["none", "authentication", "signup"].includes(e.presentationGate)) && [e.firstObservedAt, e.confirmationMs].every((n) => n === void 0 || s(n));
2985
3002
  }
2986
3003
  function gn(t) {
2987
3004
  if (!t || typeof t != "object" || Object.keys(t).some((n) => n !== "before" && n !== "current")) return !1;
2988
3005
  const e = (n) => {
2989
3006
  if (!n || typeof n != "object") return !1;
2990
3007
  const i = n;
2991
- return Object.keys(n).every((r) => [...Kn, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context", "duplicateToolCalls"].includes(r)) && (i.duplicateToolCalls === void 0 || Array.isArray(i.duplicateToolCalls) && i.duplicateToolCalls.length <= 5 && i.duplicateToolCalls.every((r) => r && Object.keys(r).every((a) => ["key", "count", "rows", "truncated"].includes(a)) && Ee(r.key) && Number.isSafeInteger(r.count) && r.count >= 2 && typeof r.truncated == "boolean" && Array.isArray(r.rows) && r.rows.length >= 1 && r.rows.length <= 5 && r.rows.length <= r.count && r.rows.every((a) => a && Object.keys(a).every((o) => ["itemId", "groupId"].includes(o)) && Ee(a.itemId) && Ee(a.groupId)))) && (i.context === void 0 || To(i.context)) && (i.thinkingSequence === void 0 || Array.isArray(i.thinkingSequence) && i.thinkingSequence.length <= 20 && i.thinkingSequence.every((r) => r === "user" || r === "thinking")) && Ee(i.sessionId) && Number.isSafeInteger(i.runtimeItemCount) && i.runtimeItemCount >= 0 && typeof i.welcome == "boolean" && typeof i.truncated == "boolean" && Kn.every((r) => Array.isArray(i[r]) && i[r].length <= 20 && i[r].every(pn));
3008
+ return Object.keys(n).every((r) => [...Kn, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context", "duplicateToolCalls"].includes(r)) && (i.duplicateToolCalls === void 0 || Array.isArray(i.duplicateToolCalls) && i.duplicateToolCalls.length <= 5 && i.duplicateToolCalls.every((r) => r && Object.keys(r).every((a) => ["key", "count", "rows", "truncated"].includes(a)) && Ee(r.key) && Number.isSafeInteger(r.count) && r.count >= 2 && typeof r.truncated == "boolean" && Array.isArray(r.rows) && r.rows.length >= 1 && r.rows.length <= 5 && r.rows.length <= r.count && r.rows.every((a) => a && Object.keys(a).every((o) => ["itemId", "groupId"].includes(o)) && Ee(a.itemId) && Ee(a.groupId)))) && (i.context === void 0 || Co(i.context)) && (i.thinkingSequence === void 0 || Array.isArray(i.thinkingSequence) && i.thinkingSequence.length <= 20 && i.thinkingSequence.every((r) => r === "user" || r === "thinking")) && Ee(i.sessionId) && Number.isSafeInteger(i.runtimeItemCount) && i.runtimeItemCount >= 0 && typeof i.welcome == "boolean" && typeof i.truncated == "boolean" && Kn.every((r) => Array.isArray(i[r]) && i[r].length <= 20 && i[r].every(pn));
2992
3009
  }, s = t;
2993
3010
  return (s.before === null || e(s.before)) && e(s.current);
2994
3011
  }
@@ -2997,19 +3014,19 @@ function Oe(t) {
2997
3014
  const e = t.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();
2998
3015
  return e.length > Wn ? `${e.slice(0, Wn - 1)}…` : e;
2999
3016
  }
3000
- function Wi(t) {
3017
+ function Gi(t) {
3001
3018
  let e = 2166136261;
3002
3019
  for (let s = 0; s < t.length; s += 1)
3003
3020
  e ^= t.charCodeAt(s), e = Math.imul(e, 16777619);
3004
3021
  return `fnv1a-${(e >>> 0).toString(16).padStart(8, "0")}`;
3005
3022
  }
3006
- function Co(t) {
3023
+ function Oo(t) {
3007
3024
  if (!t || typeof t != "object") return !1;
3008
3025
  const e = t;
3009
3026
  return Object.keys(e).every((s) => ["sessionId", "requestId", "code", "normalization", "builds", "clientMessageId"].includes(s)) && (e.clientMessageId === void 0 || j(e.clientMessageId) !== null) && [e.sessionId, e.requestId, e.code].every((s) => s === null || j(s) !== null) && (e.normalization === void 0 || it(e.normalization)) && !!e.builds && typeof e.builds == "object" && typeof e.builds.sdk == "string" && Object.entries(e.builds).every(([s, n]) => ["sdk", "rendererExtension", "contentExtension", "backgroundExtension"].includes(s) && typeof n == "string" && /^\d{1,5}\.\d{1,5}\.\d{1,5}$/.test(n));
3010
3027
  }
3011
- function Gi(t, e, s, n, i = {}) {
3012
- const r = !n && e === "conversation_error" && s !== void 0 && t.conversationDiagnostics?.errorMessageFingerprint === Wi(Oe(s)) ? t.conversationDiagnostics : void 0;
3028
+ function Ji(t, e, s, n, i = {}) {
3029
+ const r = !n && e === "conversation_error" && s !== void 0 && t.conversationDiagnostics?.errorMessageFingerprint === Gi(Oe(s)) ? t.conversationDiagnostics : void 0;
3013
3030
  return {
3014
3031
  sessionId: j(t.sessionId),
3015
3032
  requestId: j(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
@@ -3019,7 +3036,7 @@ function Gi(t, e, s, n, i = {}) {
3019
3036
  builds: { sdk: Lt.version, ...i }
3020
3037
  };
3021
3038
  }
3022
- function Oo(t, e = "runtime") {
3039
+ function xo(t, e = "runtime") {
3023
3040
  const s = Y(t, "runtime_error", e), n = t !== null && typeof t == "object" && "stack" in t && typeof t.stack == "string" ? Oe(t.stack.slice(0, 4e3).split(`
3024
3041
  `).slice(0, 6).join(`
3025
3042
  `).replace(/\n\s*at\s/g, `
@@ -3056,7 +3073,7 @@ function he(t) {
3056
3073
  "upstreamTraceId"
3057
3074
  ].includes(n)) && j(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 || s(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((n) => n == null || s(n)) && s(e.elapsedMs) && s(e.attempt) && e.attempt >= 1 && e.attempt <= 10 && [e.queryRequestId, e.ownerId, e.sessionId].every((n) => n === null || j(n) !== null) && (e.authorityGeneration === null || s(e.authorityGeneration)) && typeof e.release == "string" && /^[a-zA-Z0-9._-]{1,80}$/.test(e.release) && [e.upstreamRequestId, e.upstreamTraceId].every((n) => n === null || typeof n == "string" && /^[a-zA-Z0-9_:;=./-]{1,160}$/.test(n));
3058
3075
  }
3059
- function xo(t) {
3076
+ function Mo(t) {
3060
3077
  const e = {}, s = (n, i) => {
3061
3078
  if (!n || typeof n != "object") return;
3062
3079
  const r = n;
@@ -3077,7 +3094,7 @@ function xo(t) {
3077
3094
  }
3078
3095
  return e;
3079
3096
  }
3080
- function Mo(t, e = Math.random, s = Math.random) {
3097
+ function Po(t, e = Math.random, s = Math.random) {
3081
3098
  const n = () => Math.floor(s() * 21) - 10;
3082
3099
  return {
3083
3100
  "activeUsers.load": async () => ({ count: await t(), updatedAt: Date.now(), offset: n() }),
@@ -3085,14 +3102,14 @@ function Mo(t, e = Math.random, s = Math.random) {
3085
3102
  "activeUsers.wait": ({ milliseconds: i }) => new Promise((r) => setTimeout(() => r(null), i + Math.round((e() - 0.5) * 1e3)))
3086
3103
  };
3087
3104
  }
3088
- async function Po(t, e = fetch) {
3105
+ async function Do(t, e = fetch) {
3089
3106
  const s = await e(new URL("/api/product-agent/embed/active-users", t), { cache: "no-store", credentials: "omit" });
3090
3107
  if (!s.ok) throw new Error(`Active users request failed (${s.status})`);
3091
3108
  const n = await s.json();
3092
3109
  if (typeof n.count != "number" || !Number.isFinite(n.count) || n.count < 0) throw new Error("Invalid active users count");
3093
3110
  return Math.round(n.count);
3094
3111
  }
3095
- function Do(t) {
3112
+ function Uo(t) {
3096
3113
  const e = {
3097
3114
  sidepanel: "extension_sidepanel",
3098
3115
  browser_extension_page_ui: "extension_widget",
@@ -3104,7 +3121,7 @@ function Do(t) {
3104
3121
  };
3105
3122
  return t && t in e ? e[t] : t ?? "embedded_custom_ui";
3106
3123
  }
3107
- function Uo(t, e) {
3124
+ function No(t, e) {
3108
3125
  const s = {}, n = {};
3109
3126
  for (const i of e) {
3110
3127
  const r = i.command.payload, a = String(r.clientMessageId);
@@ -3141,7 +3158,7 @@ function cs(t) {
3141
3158
  return null;
3142
3159
  }
3143
3160
  }
3144
- function No(t, e) {
3161
+ function jo(t, e) {
3145
3162
  try {
3146
3163
  window.sessionStorage.setItem(`pa.authority:${t}`, e);
3147
3164
  } catch (s) {
@@ -3234,7 +3251,7 @@ function ke(t, e) {
3234
3251
  retryable: t !== null && typeof t == "object" && "retryable" in t && typeof t.retryable == "boolean" ? t.retryable : ["authority_retired", "executor_not_ready", "connection_interrupted", "request_timed_out", "408", "425", "429"].includes(n) || /^5\d\d$/.test(n)
3235
3252
  });
3236
3253
  }
3237
- function jo(t) {
3254
+ function Bo(t) {
3238
3255
  let e = Promise.resolve();
3239
3256
  const s = (o = un(t.runtime().engine.getState().slices.conversation, t.runtime().engine.getState().slices.directory), c = Promise.resolve()) => {
3240
3257
  const d = c.then(() => ({ ok: !0 }), (m) => ({ ok: !1, error: m })), l = o ? Object.values(o.submissions).filter((m) => m.delivery !== "accepted").slice(-8).map((m) => ({ submission: m, timer: Q(t.onTiming, {
@@ -3500,12 +3517,12 @@ function jo(t) {
3500
3517
  const d = ke(c, { requestId: o.requestId, sessionId: o.sessionId });
3501
3518
  if (["display_projection_disabled", "409", "connection_interrupted", "request_timed_out", "request_cancelled", "408", "425", "429", "500", "502", "503", "504"].includes(d.code))
3502
3519
  throw Object.assign(d, { code: "history_load_failed", message: "We couldn’t refresh this conversation. Try again.", retryable: !0 });
3503
- if (Di(d.code)) throw Object.assign(d, { retryable: !0 });
3520
+ if (Ui(d.code)) throw Object.assign(d, { retryable: !0 });
3504
3521
  return n(c, { operation: "conversation.snapshot", requestId: o.requestId, sessionId: o.sessionId });
3505
3522
  })
3506
3523
  };
3507
3524
  }
3508
- class Bo {
3525
+ class Lo {
3509
3526
  constructor(e) {
3510
3527
  this.options = e, this.owner = `conversation:${e.authority.authorityId}:${e.authority.generation}`, this.deliveryRecovery = new wt({
3511
3528
  activeIntervalMs: 3e3,
@@ -3602,7 +3619,7 @@ class Bo {
3602
3619
  }
3603
3620
  hasUncertainDelivery() {
3604
3621
  const e = this.options.runtime().engine.getState().slices.conversation;
3605
- return e.checkpointError !== null || Object.entries(e.deliveries).some(([s, n]) => n.phase === "uncertain" && we(e, s)) || Object.values(e.operations).some((s) => s.phase === "uncertain" && Hi(s));
3622
+ return e.checkpointError !== null || Object.entries(e.deliveries).some(([s, n]) => n.phase === "uncertain" && we(e, s)) || Object.values(e.operations).some((s) => s.phase === "uncertain" && Vi(s));
3606
3623
  }
3607
3624
  hasRunningDelivery() {
3608
3625
  const e = this.options.runtime().engine.getState().slices.conversation;
@@ -3622,10 +3639,10 @@ class Bo {
3622
3639
  }
3623
3640
  }
3624
3641
  }
3625
- const Lo = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
3642
+ const Fo = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
3626
3643
  function De(t, e) {
3627
3644
  return e ? t.replace(
3628
- Lo,
3645
+ Fo,
3629
3646
  (s, n, i, r) => `${n}${new URL(i, e).toString()}${r}`
3630
3647
  ) : t;
3631
3648
  }
@@ -3666,7 +3683,7 @@ function Gn(t, e) {
3666
3683
  ...t.file_url === null ? {} : { fileUrl: new URL(t.file_url, e).toString() }
3667
3684
  };
3668
3685
  }
3669
- function Fo(t, e, s, n) {
3686
+ function $o(t, e, s, n) {
3670
3687
  const i = s === "open" || s === "awaiting_content", r = {
3671
3688
  id: t.id,
3672
3689
  createdAt: t.created_at,
@@ -3707,7 +3724,7 @@ function ds(t, e, s, n) {
3707
3724
  const i = /* @__PURE__ */ new Map();
3708
3725
  for (const _ of t.segments)
3709
3726
  for (const A of [..._.activityIds, ..._.outcomeIds]) i.set(A, _.userMessageId);
3710
- const r = t.items.map((_) => Fo(
3727
+ const r = t.items.map((_) => $o(
3711
3728
  _,
3712
3729
  i.get(_.id) ?? null,
3713
3730
  t.streamStates[_.id],
@@ -3719,7 +3736,7 @@ function ds(t, e, s, n) {
3719
3736
  content: _.content,
3720
3737
  // There is no canonical timestamp before acceptance. Keep identity stable without fabricating one.
3721
3738
  createdAt: "",
3722
- retryable: _.delivery === "failed" && !["unauthorized", "401", "auth_reconnecting"].includes(_.error?.code ?? "") && ["delivery", "preparation"].includes(Ui(t, _.userMessageId)?.type ?? ""),
3739
+ retryable: _.delivery === "failed" && !["unauthorized", "401", "auth_reconnecting"].includes(_.error?.code ?? "") && ["delivery", "preparation"].includes(Ni(t, _.userMessageId)?.type ?? ""),
3723
3740
  attachments: _.attachments.map((A) => ({
3724
3741
  id: A.sourceId,
3725
3742
  name: A.name,
@@ -3730,7 +3747,7 @@ function ds(t, e, s, n) {
3730
3747
  const a = t.segments.flatMap((_) => r.filter((A) => A.id === _.userMessageId || _.activityIds.includes(A.id) || _.outcomeIds.includes(A.id))), o = { ...t.removedItems };
3731
3748
  for (const _ of t.segments) {
3732
3749
  if (!_.userMessageId) continue;
3733
- const A = r.find((T) => _.outcomeIds.includes(T.id) && !T.loading && (T.dataType === "run_status" || T.dataType === "run_error" || T.role === "assistant" && T.phase === "final_answer" && T.streamState === "finished"));
3750
+ const A = r.find((C) => _.outcomeIds.includes(C.id) && !C.loading && (C.dataType === "run_status" || C.dataType === "run_error" || C.role === "assistant" && C.phase === "final_answer" && C.streamState === "finished"));
3734
3751
  A && (o[`local-interrupted:${_.userMessageId}`] = A.id);
3735
3752
  }
3736
3753
  t.proactiveQuestion && a.push({
@@ -3755,13 +3772,13 @@ function ds(t, e, s, n) {
3755
3772
  }] : [_];
3756
3773
  }), y = e?.error != null && t.historyRefreshFailure != null && t.historyRefreshFailure.consecutiveFailures < 4, b = y ? null : e?.error ?? null, k = [...t.submissions].reverse().find((_) => t.pendingDurabilityIds?.includes(_.userMessageId)), R = k ? {
3757
3774
  code: "submission_checkpoint_pending",
3758
- message: Hr,
3775
+ message: Vr,
3759
3776
  details: { requestId: k.requestId }
3760
3777
  } : null, g = l?.delivery === "failed" && !l.cancelled && !p ? l.error : b ?? R, v = {
3761
3778
  isRetrying: t.isRetrying ?? !1,
3762
3779
  historyRefreshFailure: g === e?.error ? t.historyRefreshFailure ?? null : null,
3763
3780
  conversationDiagnostics: {
3764
- ...g ? { errorMessageFingerprint: Wi(Oe(g.message)) } : {},
3781
+ ...g ? { errorMessageFingerprint: Gi(Oe(g.message)) } : {},
3765
3782
  ...l && g && g === l.error && !p ? { failedClientMessageId: l.userMessageId } : {},
3766
3783
  ...typeof g?.details?.requestId == "string" ? { errorRequestId: g.details.requestId } : {},
3767
3784
  ...it(g?.details?.errorNormalization) ? { errorNormalization: g.details.errorNormalization } : {},
@@ -3835,7 +3852,7 @@ function Jn(t) {
3835
3852
  return "This request was interrupted before acceptance could be confirmed.";
3836
3853
  }
3837
3854
  }
3838
- function $o(t) {
3855
+ function zo(t) {
3839
3856
  return {
3840
3857
  content: t.content,
3841
3858
  ...typeof t.context.proactiveSuggestionQuestion == "string" ? { proactiveSuggestionQuestion: t.context.proactiveSuggestionQuestion } : {},
@@ -3947,20 +3964,20 @@ function St(t) {
3947
3964
  nextCursor: t.nextCursor
3948
3965
  };
3949
3966
  }
3950
- function zo(t, e, s) {
3967
+ function Ho(t, e, s) {
3951
3968
  if (s === "replace" || t === null) return e;
3952
3969
  const n = { ...t.entitiesById, ...e.entitiesById }, i = [...t.ids];
3953
3970
  for (const r of e.ids)
3954
3971
  t.entitiesById[r] || i.push(r);
3955
3972
  return { entitiesById: n, ids: i, nextCursor: e.nextCursor };
3956
3973
  }
3957
- function Ho(t) {
3974
+ function Vo(t) {
3958
3975
  return t ? t.ids.map((e) => t.entitiesById[e]).filter((e) => !!e) : [];
3959
3976
  }
3960
3977
  function Zl(t) {
3961
3978
  return t.visible ? t.minimized ? { state: "minimized" } : { state: t.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
3962
3979
  }
3963
- function Vo(t) {
3980
+ function Ko(t) {
3964
3981
  if (!t || typeof t != "object") return !1;
3965
3982
  const e = t.paidCreditFallbackModel;
3966
3983
  return typeof e == "string" && e.length > 0;
@@ -3978,9 +3995,9 @@ function tu(t) {
3978
3995
  disabled: !e || !t.canSubmitMessage
3979
3996
  };
3980
3997
  }
3981
- const Ko = "Pluno is reconnecting. Try again in a moment.";
3982
- function Wo(t) {
3983
- return (t instanceof Error ? t.message : t) === Ko;
3998
+ const Wo = "Pluno is reconnecting. Try again in a moment.";
3999
+ function Xn(t) {
4000
+ return (t instanceof Error ? t.message : t) === Wo;
3984
4001
  }
3985
4002
  const pe = /* @__PURE__ */ Object.create(null);
3986
4003
  pe.open = "0";
@@ -3994,29 +4011,29 @@ const kt = /* @__PURE__ */ Object.create(null);
3994
4011
  Object.keys(pe).forEach((t) => {
3995
4012
  kt[pe[t]] = t;
3996
4013
  });
3997
- const Qs = { type: "error", data: "parser error" }, Ji = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Qi = typeof ArrayBuffer == "function", Xi = (t) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(t) : t && t.buffer instanceof ArrayBuffer, mn = ({ type: t, data: e }, s, n) => Ji && e instanceof Blob ? s ? n(e) : Xn(e, n) : Qi && (e instanceof ArrayBuffer || Xi(e)) ? s ? n(e) : Xn(new Blob([e]), n) : n(pe[t] + (e || "")), Xn = (t, e) => {
4014
+ const Qs = { type: "error", data: "parser error" }, Qi = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Xi = typeof ArrayBuffer == "function", Yi = (t) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(t) : t && t.buffer instanceof ArrayBuffer, mn = ({ type: t, data: e }, s, n) => Qi && e instanceof Blob ? s ? n(e) : Yn(e, n) : Xi && (e instanceof ArrayBuffer || Yi(e)) ? s ? n(e) : Yn(new Blob([e]), n) : n(pe[t] + (e || "")), Yn = (t, e) => {
3998
4015
  const s = new FileReader();
3999
4016
  return s.onload = function() {
4000
4017
  const n = s.result.split(",")[1];
4001
4018
  e("b" + (n || ""));
4002
4019
  }, s.readAsDataURL(t);
4003
4020
  };
4004
- function Yn(t) {
4021
+ function Zn(t) {
4005
4022
  return t instanceof Uint8Array ? t : t instanceof ArrayBuffer ? new Uint8Array(t) : new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
4006
4023
  }
4007
4024
  let ls;
4008
4025
  function Go(t, e) {
4009
- if (Ji && t.data instanceof Blob)
4010
- return t.data.arrayBuffer().then(Yn).then(e);
4011
- if (Qi && (t.data instanceof ArrayBuffer || Xi(t.data)))
4012
- return e(Yn(t.data));
4026
+ if (Qi && t.data instanceof Blob)
4027
+ return t.data.arrayBuffer().then(Zn).then(e);
4028
+ if (Xi && (t.data instanceof ArrayBuffer || Yi(t.data)))
4029
+ return e(Zn(t.data));
4013
4030
  mn(t, !1, (s) => {
4014
4031
  ls || (ls = new TextEncoder()), e(ls.encode(s));
4015
4032
  });
4016
4033
  }
4017
- const Zn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ze = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
4018
- for (let t = 0; t < Zn.length; t++)
4019
- Ze[Zn.charCodeAt(t)] = t;
4034
+ const ei = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ze = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
4035
+ for (let t = 0; t < ei.length; t++)
4036
+ Ze[ei.charCodeAt(t)] = t;
4020
4037
  const Jo = (t) => {
4021
4038
  let e = t.length * 0.75, s = t.length, n, i = 0, r, a, o, c;
4022
4039
  t[t.length - 1] === "=" && (e--, t[t.length - 2] === "=" && e--);
@@ -4028,7 +4045,7 @@ const Jo = (t) => {
4028
4045
  if (typeof t != "string")
4029
4046
  return {
4030
4047
  type: "message",
4031
- data: Yi(t, e)
4048
+ data: Zi(t, e)
4032
4049
  };
4033
4050
  const s = t.charAt(0);
4034
4051
  return s === "b" ? {
@@ -4043,19 +4060,19 @@ const Jo = (t) => {
4043
4060
  }, Xo = (t, e) => {
4044
4061
  if (Qo) {
4045
4062
  const s = Jo(t);
4046
- return Yi(s, e);
4063
+ return Zi(s, e);
4047
4064
  } else
4048
4065
  return { base64: !0, data: t };
4049
- }, Yi = (t, e) => e === "blob" ? t instanceof Blob ? t : new Blob([t]) : t instanceof ArrayBuffer ? t : t.buffer, Zi = "", Yo = (t, e) => {
4066
+ }, Zi = (t, e) => e === "blob" ? t instanceof Blob ? t : new Blob([t]) : t instanceof ArrayBuffer ? t : t.buffer, er = "", Yo = (t, e) => {
4050
4067
  const s = t.length, n = new Array(s);
4051
4068
  let i = 0;
4052
4069
  t.forEach((r, a) => {
4053
4070
  mn(r, !1, (o) => {
4054
- n[a] = o, ++i === s && e(n.join(Zi));
4071
+ n[a] = o, ++i === s && e(n.join(er));
4055
4072
  });
4056
4073
  });
4057
4074
  }, Zo = (t, e) => {
4058
- const s = t.split(Zi), n = [];
4075
+ const s = t.split(er), n = [];
4059
4076
  for (let i = 0; i < s.length; i++) {
4060
4077
  const r = yn(s[i], e);
4061
4078
  if (n.push(r), r.type === "error")
@@ -4138,7 +4155,7 @@ function ta(t, e) {
4138
4155
  }
4139
4156
  });
4140
4157
  }
4141
- const er = 4;
4158
+ const tr = 4;
4142
4159
  function F(t) {
4143
4160
  if (t) return sa(t);
4144
4161
  }
@@ -4189,7 +4206,7 @@ F.prototype.hasListeners = function(t) {
4189
4206
  return !!this.listeners(t).length;
4190
4207
  };
4191
4208
  const $t = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, s) => s(e, 0), re = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), na = "arraybuffer";
4192
- function tr(t, ...e) {
4209
+ function sr(t, ...e) {
4193
4210
  return e.reduce((s, n) => (t.hasOwnProperty(n) && (s[n] = t[n]), s), {});
4194
4211
  }
4195
4212
  const ia = re.setTimeout, ra = re.clearTimeout;
@@ -4206,7 +4223,7 @@ function ca(t) {
4206
4223
  e = t.charCodeAt(n), e < 128 ? s += 1 : e < 2048 ? s += 2 : e < 55296 || e >= 57344 ? s += 3 : (n++, s += 4);
4207
4224
  return s;
4208
4225
  }
4209
- function sr() {
4226
+ function nr() {
4210
4227
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
4211
4228
  }
4212
4229
  function da(t) {
@@ -4415,15 +4432,15 @@ class ha extends vn {
4415
4432
  */
4416
4433
  uri() {
4417
4434
  const e = this.opts.secure ? "https" : "http", s = this.query || {};
4418
- return this.opts.timestampRequests !== !1 && (s[this.opts.timestampParam] = sr()), !this.supportsBinary && !s.sid && (s.b64 = 1), this.createUri(e, s);
4435
+ return this.opts.timestampRequests !== !1 && (s[this.opts.timestampParam] = nr()), !this.supportsBinary && !s.sid && (s.b64 = 1), this.createUri(e, s);
4419
4436
  }
4420
4437
  }
4421
- let nr = !1;
4438
+ let ir = !1;
4422
4439
  try {
4423
- nr = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
4440
+ ir = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
4424
4441
  } catch {
4425
4442
  }
4426
- const pa = nr;
4443
+ const pa = ir;
4427
4444
  function fa() {
4428
4445
  }
4429
4446
  class ga extends ha {
@@ -4485,7 +4502,7 @@ let Ne = class Rt extends F {
4485
4502
  */
4486
4503
  _create() {
4487
4504
  var e;
4488
- const s = tr(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
4505
+ const s = sr(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
4489
4506
  s.xdomain = !!this._opts.xd;
4490
4507
  const n = this._xhr = this.createRequest(s);
4491
4508
  try {
@@ -4569,18 +4586,18 @@ Ne.requestsCount = 0;
4569
4586
  Ne.requests = {};
4570
4587
  if (typeof document < "u") {
4571
4588
  if (typeof attachEvent == "function")
4572
- attachEvent("onunload", ei);
4589
+ attachEvent("onunload", ti);
4573
4590
  else if (typeof addEventListener == "function") {
4574
4591
  const t = "onpagehide" in re ? "pagehide" : "unload";
4575
- addEventListener(t, ei, !1);
4592
+ addEventListener(t, ti, !1);
4576
4593
  }
4577
4594
  }
4578
- function ei() {
4595
+ function ti() {
4579
4596
  for (let t in Ne.requests)
4580
4597
  Ne.requests.hasOwnProperty(t) && Ne.requests[t].abort();
4581
4598
  }
4582
4599
  const ma = (function() {
4583
- const t = ir({
4600
+ const t = rr({
4584
4601
  xdomain: !1
4585
4602
  });
4586
4603
  return t && t.responseType !== null;
@@ -4592,10 +4609,10 @@ class ya extends ga {
4592
4609
  this.supportsBinary = ma && !s;
4593
4610
  }
4594
4611
  request(e = {}) {
4595
- return Object.assign(e, { xd: this.xd }, this.opts), new Ne(ir, this.uri(), e);
4612
+ return Object.assign(e, { xd: this.xd }, this.opts), new Ne(rr, this.uri(), e);
4596
4613
  }
4597
4614
  }
4598
- function ir(t) {
4615
+ function rr(t) {
4599
4616
  const e = t.xdomain;
4600
4617
  try {
4601
4618
  if (typeof XMLHttpRequest < "u" && (!e || pa))
@@ -4608,13 +4625,13 @@ function ir(t) {
4608
4625
  } catch {
4609
4626
  }
4610
4627
  }
4611
- const rr = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
4628
+ const or = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
4612
4629
  class va extends vn {
4613
4630
  get name() {
4614
4631
  return "websocket";
4615
4632
  }
4616
4633
  doOpen() {
4617
- const e = this.uri(), s = this.opts.protocols, n = rr ? {} : tr(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
4634
+ const e = this.uri(), s = this.opts.protocols, n = or ? {} : sr(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
4618
4635
  this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
4619
4636
  try {
4620
4637
  this.ws = this.createSocket(e, s, n);
@@ -4662,13 +4679,13 @@ class va extends vn {
4662
4679
  */
4663
4680
  uri() {
4664
4681
  const e = this.opts.secure ? "wss" : "ws", s = this.query || {};
4665
- return this.opts.timestampRequests && (s[this.opts.timestampParam] = sr()), this.supportsBinary || (s.b64 = 1), this.createUri(e, s);
4682
+ return this.opts.timestampRequests && (s[this.opts.timestampParam] = nr()), this.supportsBinary || (s.b64 = 1), this.createUri(e, s);
4666
4683
  }
4667
4684
  }
4668
4685
  const hs = re.WebSocket || re.MozWebSocket;
4669
4686
  class ba extends va {
4670
4687
  createSocket(e, s, n) {
4671
- return rr ? new hs(e, s, n) : s ? new hs(e, s) : new hs(e);
4688
+ return or ? new hs(e, s, n) : s ? new hs(e, s) : new hs(e);
4672
4689
  }
4673
4690
  doWrite(e, s) {
4674
4691
  this.ws.send(s);
@@ -4810,7 +4827,7 @@ class _e extends F {
4810
4827
  */
4811
4828
  createTransport(e) {
4812
4829
  const s = Object.assign({}, this.opts.query);
4813
- s.EIO = er, s.transport = e, this.id && (s.sid = this.id);
4830
+ s.EIO = tr, s.transport = e, this.id && (s.sid = this.id);
4814
4831
  const n = Object.assign({}, this.opts, {
4815
4832
  query: s,
4816
4833
  socket: this,
@@ -5034,7 +5051,7 @@ class _e extends F {
5034
5051
  }
5035
5052
  }
5036
5053
  }
5037
- _e.protocol = er;
5054
+ _e.protocol = tr;
5038
5055
  class Aa extends _e {
5039
5056
  constructor() {
5040
5057
  super(...arguments), this._upgrades = [];
@@ -5119,7 +5136,7 @@ function qa(t, e = "", s) {
5119
5136
  const r = n.host.indexOf(":") !== -1 ? "[" + n.host + "]" : n.host;
5120
5137
  return n.id = n.protocol + "://" + r + ":" + n.port + e, n.href = n.protocol + "://" + r + (s && s.port === n.port ? "" : ":" + n.port), n;
5121
5138
  }
5122
- const Ta = typeof ArrayBuffer == "function", Ca = (t) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(t) : t.buffer instanceof ArrayBuffer, or = Object.prototype.toString, Oa = typeof Blob == "function" || typeof Blob < "u" && or.call(Blob) === "[object BlobConstructor]", xa = typeof File == "function" || typeof File < "u" && or.call(File) === "[object FileConstructor]";
5139
+ const Ta = typeof ArrayBuffer == "function", Ca = (t) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(t) : t.buffer instanceof ArrayBuffer, ar = Object.prototype.toString, Oa = typeof Blob == "function" || typeof Blob < "u" && ar.call(Blob) === "[object BlobConstructor]", xa = typeof File == "function" || typeof File < "u" && ar.call(File) === "[object FileConstructor]";
5123
5140
  function bn(t) {
5124
5141
  return Ta && (t instanceof ArrayBuffer || Ca(t)) || Oa && t instanceof Blob || xa && t instanceof File;
5125
5142
  }
@@ -5340,11 +5357,11 @@ class In extends F {
5340
5357
  static isPayloadValid(e, s) {
5341
5358
  switch (e) {
5342
5359
  case M.CONNECT:
5343
- return ti(s);
5360
+ return si(s);
5344
5361
  case M.DISCONNECT:
5345
5362
  return s === void 0;
5346
5363
  case M.CONNECT_ERROR:
5347
- return typeof s == "string" || ti(s);
5364
+ return typeof s == "string" || si(s);
5348
5365
  case M.EVENT:
5349
5366
  case M.BINARY_EVENT:
5350
5367
  return Array.isArray(s) && (typeof s[0] == "number" || typeof s[0] == "string" && Da.indexOf(s[0]) === -1);
@@ -5389,7 +5406,7 @@ class Na {
5389
5406
  const ja = Number.isInteger || function(t) {
5390
5407
  return typeof t == "number" && isFinite(t) && Math.floor(t) === t;
5391
5408
  };
5392
- function ti(t) {
5409
+ function si(t) {
5393
5410
  return Object.prototype.toString.call(t) === "[object Object]";
5394
5411
  }
5395
5412
  const Ba = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -5414,7 +5431,7 @@ const La = Object.freeze({
5414
5431
  newListener: 1,
5415
5432
  removeListener: 1
5416
5433
  });
5417
- class ar extends F {
5434
+ class cr extends F {
5418
5435
  /**
5419
5436
  * `Socket` constructor.
5420
5437
  */
@@ -6170,7 +6187,7 @@ class en extends F {
6170
6187
  */
6171
6188
  socket(e, s) {
6172
6189
  let n = this.nsps[e];
6173
- return n ? this._autoConnect && !n.active && n.connect() : (n = new ar(this, e, s), this.nsps[e] = n), n;
6190
+ return n ? this._autoConnect && !n.active && n.connect() : (n = new cr(this, e, s), this.nsps[e] = n), n;
6174
6191
  }
6175
6192
  /**
6176
6193
  * Called upon a socket close.
@@ -6276,7 +6293,7 @@ function Tt(t, e) {
6276
6293
  }
6277
6294
  Object.assign(Tt, {
6278
6295
  Manager: en,
6279
- Socket: ar,
6296
+ Socket: cr,
6280
6297
  io: Tt,
6281
6298
  connect: Tt
6282
6299
  });
@@ -6301,7 +6318,7 @@ class E extends Error {
6301
6318
  detail;
6302
6319
  backendRefusal;
6303
6320
  }
6304
- function si(t, e) {
6321
+ function ni(t, e) {
6305
6322
  const s = t.result && typeof t.result == "object" ? t.result : void 0, n = typeof s?.message == "string" && s.message.trim() ? s.message : `${e} (${t.code ?? "request_rejected"})`;
6306
6323
  return new E(n, t.code ?? "request_rejected", !1, t.result, !0);
6307
6324
  }
@@ -6602,7 +6619,7 @@ class za {
6602
6619
  throw new E("Result upload outcome is unknown", "delivery_unknown", !0);
6603
6620
  if (h?.request_id !== i || typeof h.ok != "boolean")
6604
6621
  throw new E("Invalid result acknowledgement identity", "invalid_ack", !0);
6605
- if (!h.ok) throw si(h, "Product Agent result rejected");
6622
+ if (!h.ok) throw ni(h, "Product Agent result rejected");
6606
6623
  return h.result;
6607
6624
  } catch (d) {
6608
6625
  const l = d instanceof E ? d : new E("Result upload outcome is unknown", "delivery_unknown", !0);
@@ -6619,7 +6636,7 @@ class za {
6619
6636
  this.pending.delete(o), a(c);
6620
6637
  };
6621
6638
  this.pending.add(o), this.socket.timeout(this.options.requestTimeoutMs ?? 15e3).emit(e, { ...s, request_id: i }, (c, d) => {
6622
- this.pending.delete(o) && (c || n !== this.generation ? a(new E("Delivery outcome is unknown; reconcile without repeating execution", "delivery_unknown", !0)) : d?.request_id !== i || typeof d.ok != "boolean" ? a(new E("Invalid acknowledgement identity", "invalid_ack", !0)) : d.ok ? r(d.result) : a(si(d, "Product Agent request rejected")));
6639
+ this.pending.delete(o) && (c || n !== this.generation ? a(new E("Delivery outcome is unknown; reconcile without repeating execution", "delivery_unknown", !0)) : d?.request_id !== i || typeof d.ok != "boolean" ? a(new E("Invalid acknowledgement identity", "invalid_ack", !0)) : d.ok ? r(d.result) : a(ni(d, "Product Agent request rejected")));
6623
6640
  });
6624
6641
  }).catch((r) => {
6625
6642
  throw this.recoverUncertainDelivery(r, n), r;
@@ -6649,8 +6666,8 @@ function Ha() {
6649
6666
  const e = Array.from(t, (s) => s.toString(16).padStart(2, "0")).join("");
6650
6667
  return `${e.slice(0, 8)}-${e.slice(8, 12)}-${e.slice(12, 16)}-${e.slice(16, 20)}-${e.slice(20)}`;
6651
6668
  }
6652
- const ni = (t) => t && /^[a-zA-Z0-9_:;=./-]{1,160}$/.test(t) ? t : null;
6653
- class cr {
6669
+ const ii = (t) => t && /^[a-zA-Z0-9_:;=./-]{1,160}$/.test(t) ? t : null;
6670
+ class dr {
6654
6671
  constructor(e) {
6655
6672
  this.options = e, this.auth = e.auth;
6656
6673
  }
@@ -6700,15 +6717,15 @@ class cr {
6700
6717
  }
6701
6718
  async requestOnce(e, s, n, i, r, a, o, c = 1) {
6702
6719
  const d = this.auth.client_kind === "embed", l = new URL(`/api/product-agent/${r ?? (d ? "embed" : "runtime")}${e}`, this.options.backendUrl), u = r === "conversations" ? {} : d ? { client_id: this.auth.client_id, transport_id: this.auth.transport_id } : { community_id: this.auth.community_id, automation_run_id: this.auth.automation_run_id };
6703
- for (const [q, C] of Object.entries({ ...u, ...s }))
6704
- C != null && l.searchParams.set(q, String(C));
6720
+ for (const [q, T] of Object.entries({ ...u, ...s }))
6721
+ T != null && l.searchParams.set(q, String(T));
6705
6722
  this.requests.signal.throwIfAborted(), a?.throwIfAborted();
6706
6723
  const h = new AbortController(), p = { trigger: null }, m = (q) => {
6707
6724
  h.signal.aborted || (p.trigger = q, h.abort());
6708
6725
  }, f = () => m("transport_disposed"), y = () => m(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
6709
6726
  this.requests.signal.addEventListener("abort", f, { once: !0 }), a?.addEventListener("abort", y, { once: !0 });
6710
6727
  const b = r === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && i === "POST", k = /^\/conversations(?:\/[^/]+)?$/.test(e) && (i ?? (n === void 0 ? "GET" : "POST")) === "GET", R = setTimeout(() => m("deadline"), k ? 6e4 : b ? 3e4 : 15e3), g = Ha(), v = Date.now();
6711
- let I = null, w = !1, _ = null, A = null, T = null;
6728
+ let I = null, w = !1, _ = null, A = null, C = null;
6712
6729
  try {
6713
6730
  const q = await Promise.resolve(fetch(l, {
6714
6731
  method: i ?? (n === void 0 ? "GET" : "POST"),
@@ -6716,11 +6733,11 @@ class cr {
6716
6733
  signal: h.signal,
6717
6734
  headers: { "x-product-agent-auth-request-id": g, authorization: d || r === "conversations" ? `Bearer ${this.auth.token}` : this.auth.token, "content-type": "application/json", ...b ? { "x-request-id": g } : {} },
6718
6735
  ...n === void 0 ? {} : { body: JSON.stringify(n) }
6719
- })).catch((C) => {
6720
- throw w = !0, C;
6736
+ })).catch((T) => {
6737
+ throw w = !0, T;
6721
6738
  });
6722
- if (I = Date.now(), _ = q.status, A = ni(q.headers.get("x-request-id")), T = ni(q.headers.get("x-cloud-trace-context")), !q.ok) {
6723
- const C = q.status === 401 ? "unauthorized" : q.status === 426 ? "update_required" : String(q.status), O = (await q.json().catch(() => null))?.detail;
6739
+ if (I = Date.now(), _ = q.status, A = ii(q.headers.get("x-request-id")), C = ii(q.headers.get("x-cloud-trace-context")), !q.ok) {
6740
+ const T = q.status === 401 ? "unauthorized" : q.status === 426 ? "update_required" : String(q.status), O = (await q.json().catch(() => null))?.detail;
6724
6741
  if (d && q.status === 403 && (r === "conversations" && /^\/[^/]+\/snapshot$/.test(e) || (!r || r === "embed") && /^\/conversations\/[^/]+$/.test(e)) && ["Conversation unavailable", "Integration mismatch", "Embedded origin mismatch"].includes(O))
6725
6742
  throw new E("Conversation unavailable", "conversation_access_denied");
6726
6743
  if (r === "conversations" && e.endsWith("/snapshot") && q.status === 409 && O === "Display projection is not enabled")
@@ -6735,20 +6752,20 @@ class cr {
6735
6752
  ...typeof O.securitySettingsUrl == "string" ? { securitySettingsUrl: O.securitySettingsUrl } : {}
6736
6753
  }, r === "conversations" && e === "/commands");
6737
6754
  const S = O === "Token expired" ? "token_expired" : O === "Invalid token" ? "invalid_token" : O?.reason, x = q.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(S) ? { requestId: g, authTransport: "http", authEndpoint: `${r ?? (d ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: S, retryable: S === "token_expired" && (O === "Token expired" || O.retryable === !0) } : void 0;
6738
- throw new E(q.status === 401 ? "Your session expired or is invalid. Reconnect to continue." : q.status === 403 ? "You don't have access to this conversation. Check your access and reconnect." : `Product Agent request failed (${q.status})`, C, !1, x);
6755
+ throw new E(q.status === 401 ? "Your session expired or is invalid. Reconnect to continue." : q.status === 403 ? "You don't have access to this conversation. Check your access and reconnect." : `Product Agent request failed (${q.status})`, T, !1, x);
6739
6756
  }
6740
6757
  return await q.json();
6741
6758
  } catch (q) {
6742
- const C = p.trigger ?? ((q instanceof Error || q instanceof DOMException) && q.name === "AbortError" ? "unexpected_abort" : null), O = {
6759
+ const T = p.trigger ?? ((q instanceof Error || q instanceof DOMException) && q.name === "AbortError" ? "unexpected_abort" : null), O = {
6743
6760
  requestId: g,
6744
6761
  method: i ?? (n === void 0 ? "GET" : "POST"),
6745
6762
  route: b ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
6746
6763
  status: _,
6747
- abortTrigger: C,
6748
- category: C === "deadline" ? "request_timed_out" : C === "unexpected_abort" ? "connection_interrupted" : C ? "request_cancelled" : q instanceof E ? q.code : w ? "connection_interrupted" : "invalid_response",
6764
+ abortTrigger: T,
6765
+ category: T === "deadline" ? "request_timed_out" : T === "unexpected_abort" ? "connection_interrupted" : T ? "request_cancelled" : q instanceof E ? q.code : w ? "connection_interrupted" : "invalid_response",
6749
6766
  responseHeadersMs: I === null ? null : Math.max(0, I - v),
6750
6767
  responseBodyMs: I === null ? null : Math.max(0, Date.now() - I),
6751
- owner: C === "deadline" ? "http_deadline" : C === "transport_disposed" ? "http_transport" : C && C !== "unexpected_abort" ? "conversation_query" : _ === null ? "browser" : "http_response",
6768
+ owner: T === "deadline" ? "http_deadline" : T === "transport_disposed" ? "http_transport" : T && T !== "unexpected_abort" ? "conversation_query" : _ === null ? "browser" : "http_response",
6752
6769
  elapsedMs: Math.max(0, Date.now() - v),
6753
6770
  attempt: c,
6754
6771
  queryRequestId: j(o?.queryRequestId),
@@ -6757,16 +6774,16 @@ class cr {
6757
6774
  sessionId: j(o?.sessionId),
6758
6775
  release: this.auth.extension_version ? `extension-${this.auth.extension_version}` : `sdk-${Lt.version}`,
6759
6776
  upstreamRequestId: A,
6760
- upstreamTraceId: T
6777
+ upstreamTraceId: C
6761
6778
  };
6762
6779
  he(O) && Promise.resolve().then(() => this.options.onRequestFailure ? this.options.onRequestFailure(O) : console.warn("Product Agent HTTP request failed", O)).catch(() => {
6763
6780
  });
6764
6781
  const S = he(O) ? { httpRequest: O } : void 0;
6765
- if (C !== null) {
6766
- const x = C !== "deadline" && C !== "unexpected_abort";
6782
+ if (T !== null) {
6783
+ const x = T !== "deadline" && T !== "unexpected_abort";
6767
6784
  throw new E(
6768
- x ? "The request was cancelled." : C === "deadline" ? "The request timed out. Please try again." : "The connection was interrupted. Please try again.",
6769
- x ? "request_cancelled" : C === "deadline" ? "request_timed_out" : "connection_interrupted",
6785
+ x ? "The request was cancelled." : T === "deadline" ? "The request timed out. Please try again." : "The connection was interrupted. Please try again.",
6786
+ x ? "request_cancelled" : T === "deadline" ? "request_timed_out" : "connection_interrupted",
6770
6787
  !0,
6771
6788
  S
6772
6789
  );
@@ -6789,7 +6806,7 @@ function nt(t) {
6789
6806
  }
6790
6807
  return t;
6791
6808
  }
6792
- function dr() {
6809
+ function lr() {
6793
6810
  return nt({
6794
6811
  authorityId: null,
6795
6812
  generation: 0,
@@ -6839,10 +6856,10 @@ function Ae(t) {
6839
6856
  const e = t.origin.trim();
6840
6857
  return { ...t, origin: e.includes("://") ? new URL(e).origin : e.toLowerCase() };
6841
6858
  }
6842
- function lr(t, e) {
6859
+ function ur(t, e) {
6843
6860
  return t.request(`/conversations/${encodeURIComponent(e)}`, {}, void 0, "GET", t.auth.client_kind === "extension" ? "extension" : void 0);
6844
6861
  }
6845
- function ii(t) {
6862
+ function ri(t) {
6846
6863
  return new Promise((e, s) => {
6847
6864
  let n = null, i = null, r = !1;
6848
6865
  const a = () => {
@@ -6871,7 +6888,7 @@ function Wa(t) {
6871
6888
  if (t.http.auth.client_kind === "embed") {
6872
6889
  const o = await t.http.request("/conversations", { ...r, page_url: i.origin ?? t.pageUrl() });
6873
6890
  Ge(t, n), a = { entries: await Promise.all(o.sessions.map(async (d) => ({
6874
- ...await lr(t.http, d.id),
6891
+ ...await ur(t.http, d.id),
6875
6892
  ...typeof d.isActive == "boolean" ? { is_active: d.isActive } : {}
6876
6893
  }))), next_cursor: o.nextCursor };
6877
6894
  } else
@@ -6925,7 +6942,7 @@ class Ga {
6925
6942
  isActiveTurn: () => this.options.isActiveTurn(i),
6926
6943
  poll: async () => {
6927
6944
  try {
6928
- return await lr(this.options.http, i);
6945
+ return await ur(this.options.http, i);
6929
6946
  } catch (c) {
6930
6947
  throw this.options.onError(c), c;
6931
6948
  }
@@ -7089,7 +7106,7 @@ function Ja(t) {
7089
7106
  if (!e.bindings.some((a) => a.sessionId === i && a.clientScopeId === r)) return !1;
7090
7107
  return !0;
7091
7108
  }
7092
- const ri = /* @__PURE__ */ new WeakMap();
7109
+ const oi = /* @__PURE__ */ new WeakMap();
7093
7110
  class Qa {
7094
7111
  constructor(e) {
7095
7112
  this.options = e;
@@ -7150,10 +7167,10 @@ class Qa {
7150
7167
  browserSessionId: this.options.persistence.sessionId(),
7151
7168
  bindings: Object.entries(e.clients).map(([i, r]) => ({ clientScopeId: i, conversationScopeId: r, ...e.selections[r] })),
7152
7169
  mains: Object.fromEntries(Object.entries(e.memberships).flatMap(([i, r]) => r.mainClientScopeId ? [[i, r.mainClientScopeId]] : []))
7153
- }, n = (ri.get(this.options.runtime) ?? Promise.resolve()).then(async () => {
7170
+ }, n = (oi.get(this.options.runtime) ?? Promise.resolve()).then(async () => {
7154
7171
  this.current() && await this.options.persistence.write(s);
7155
7172
  });
7156
- return ri.set(this.options.runtime, n.catch(() => {
7173
+ return oi.set(this.options.runtime, n.catch(() => {
7157
7174
  })), n;
7158
7175
  }
7159
7176
  async restore(e) {
@@ -7197,18 +7214,18 @@ function Xa(t, e, s, n = () => crypto.randomUUID()) {
7197
7214
  liveClients: async () => [e]
7198
7215
  };
7199
7216
  }
7200
- const oi = /* @__PURE__ */ new Map(), ai = /* @__PURE__ */ new Map();
7217
+ const ai = /* @__PURE__ */ new Map(), ci = /* @__PURE__ */ new Map();
7201
7218
  function Ya(t, e, s = () => crypto.randomUUID()) {
7202
7219
  try {
7203
7220
  return Xa(window.sessionStorage, t, e, s);
7204
7221
  } catch (n) {
7205
7222
  if (!(n instanceof DOMException) || n.name !== "SecurityError" && n.name !== "QuotaExceededError") throw n;
7206
- const i = `${e}:${t}`, r = ai.get(i) ?? s();
7207
- return ai.set(i, r), {
7223
+ const i = `${e}:${t}`, r = ci.get(i) ?? s();
7224
+ return ci.set(i, r), {
7208
7225
  sessionId: () => r,
7209
- read: async () => oi.get(i),
7226
+ read: async () => ai.get(i),
7210
7227
  write: async (a) => {
7211
- oi.set(i, a);
7228
+ ai.set(i, a);
7212
7229
  },
7213
7230
  liveClients: async () => [t]
7214
7231
  };
@@ -7216,7 +7233,7 @@ function Ya(t, e, s = () => crypto.randomUUID()) {
7216
7233
  }
7217
7234
  class L extends EventTarget {
7218
7235
  constructor(e) {
7219
- super(), this.options = e, this.httpTransport = new cr({
7236
+ super(), this.options = e, this.httpTransport = new dr({
7220
7237
  ...e,
7221
7238
  executorConnection: () => this.connectionId,
7222
7239
  restoreExecutor: (s) => this.restoreExecutor(s)
@@ -7586,13 +7603,13 @@ class L extends EventTarget {
7586
7603
  }
7587
7604
  }
7588
7605
  const tn = /* @__PURE__ */ new WeakMap(), qe = (t) => t === null || typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t);
7589
- function ur(t) {
7606
+ function hr(t) {
7590
7607
  if (!t || typeof t != "object") return !1;
7591
7608
  const e = t;
7592
7609
  return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && qe(e.sessionId) && qe(e.responseItemId) && qe(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
7593
7610
  }
7594
7611
  function Za(t, e, s) {
7595
- if (!ur(s)) return;
7612
+ if (!hr(s)) return;
7596
7613
  const n = tn.get(t) ?? /* @__PURE__ */ new Map();
7597
7614
  n.set(e, {
7598
7615
  observedAt: s.observedAt,
@@ -7622,19 +7639,19 @@ function tc(t, e, s, n, i, r, a, o, c = null, d = !1) {
7622
7639
  };
7623
7640
  }
7624
7641
  const sc = 1e4, nc = 3e3;
7625
- function hr() {
7642
+ function pr() {
7626
7643
  return { authenticated: !1, generation: 0, sequence: 0, displaySequence: 0, backendCount: null, query: ye("activeUsers") };
7627
7644
  }
7628
7645
  function ic(t, e) {
7629
7646
  if (e.type === "activeUsers.authenticate") {
7630
7647
  if (t.authenticated === e.authenticated) return { state: t, effects: [] };
7631
- const n = { ...hr(), authenticated: e.authenticated, generation: t.generation + 1 };
7632
- return e.authenticated ? ci(n) : { state: n, effects: [] };
7648
+ const n = { ...pr(), authenticated: e.authenticated, generation: t.generation + 1 };
7649
+ return e.authenticated ? di(n) : { state: n, effects: [] };
7633
7650
  }
7634
7651
  if (!t.authenticated || !e.effectId.startsWith(`activeUsers:${t.generation}:`)) return { state: t, effects: [] };
7635
- if (e.effectKind === "activeUsers.wait") return e.type === "effect.completed" ? ci(t) : { state: t, effects: [] };
7652
+ if (e.effectKind === "activeUsers.wait") return e.type === "effect.completed" ? di(t) : { state: t, effects: [] };
7636
7653
  if (e.effectKind === "activeUsers.displayWait")
7637
- return e.type !== "effect.completed" || t.backendCount === null || String(e.effectId) !== `activeUsers:${t.generation}:display:${t.displaySequence}` ? { state: t, effects: [] } : di({ ...t, query: { ...t.query, data: Math.max(0, t.backendCount + e.output.offset) } });
7654
+ return e.type !== "effect.completed" || t.backendCount === null || String(e.effectId) !== `activeUsers:${t.generation}:display:${t.displaySequence}` ? { state: t, effects: [] } : li({ ...t, query: { ...t.query, data: Math.max(0, t.backendCount + e.output.offset) } });
7638
7655
  if (String(e.effectId) !== t.query.requestId) return { state: t, effects: [] };
7639
7656
  if (e.type === "effect.failed") return { state: { ...t, query: { ...t.query, status: "error", error: e.error } }, effects: [] };
7640
7657
  const s = { ...t, backendCount: e.output.count, query: {
@@ -7644,13 +7661,13 @@ function ic(t, e) {
7644
7661
  updatedAt: e.output.updatedAt,
7645
7662
  error: null
7646
7663
  } };
7647
- return t.backendCount === null ? di(s) : { state: s, effects: [] };
7664
+ return t.backendCount === null ? li(s) : { state: s, effects: [] };
7648
7665
  }
7649
- function ci(t) {
7666
+ function di(t) {
7650
7667
  const e = t.sequence + 1, s = `activeUsers:${t.generation}:${e}`, n = [{ id: `${s}:wait`, kind: "activeUsers.wait", input: { milliseconds: sc } }];
7651
7668
  return t.query.status === "loading" || t.query.status === "refreshing" ? { state: { ...t, sequence: e }, effects: n } : (n.push({ id: `${s}:load`, kind: "activeUsers.load", input: { generation: t.generation } }), { state: { ...t, sequence: e, query: { ...t.query, requestId: `${s}:load`, status: t.query.data === null ? "loading" : "refreshing", error: null } }, effects: n });
7652
7669
  }
7653
- function di(t) {
7670
+ function li(t) {
7654
7671
  const e = t.displaySequence + 1;
7655
7672
  return { state: { ...t, displaySequence: e }, effects: [{
7656
7673
  id: `activeUsers:${t.generation}:display:${e}`,
@@ -7737,7 +7754,7 @@ function oc(t, e) {
7737
7754
  })
7738
7755
  });
7739
7756
  }
7740
- function li(t, e, s) {
7757
+ function ui(t, e, s) {
7741
7758
  const n = t.clients[e];
7742
7759
  if (!n) return t;
7743
7760
  const i = t.selections[n].sessionId, r = { ...t.clients };
@@ -7755,7 +7772,7 @@ function li(t, e, s) {
7755
7772
  }
7756
7773
  return { ...t, clients: r, memberships: a, membershipRevision: t.membershipRevision + 1 };
7757
7774
  }
7758
- function ui(t, e, s, n) {
7775
+ function hi(t, e, s, n) {
7759
7776
  let i = t.memberships;
7760
7777
  if (n.sessionId !== null) {
7761
7778
  const r = i[n.sessionId], a = r?.members ?? [];
@@ -7790,10 +7807,10 @@ function ac(t, e, s) {
7790
7807
  ...t,
7791
7808
  clients: { ...t.clients, [e.clientScopeId]: e.conversationScopeId },
7792
7809
  selections: { ...t.selections, [e.conversationScopeId]: n }
7793
- } : ui(li(t, e.clientScopeId, e.replacement), e.clientScopeId, e.conversationScopeId, n);
7810
+ } : hi(ui(t, e.clientScopeId, e.replacement), e.clientScopeId, e.conversationScopeId, n);
7794
7811
  }
7795
7812
  case "directory.detach":
7796
- return li(t, e.clientScopeId, e.replacement);
7813
+ return ui(t, e.clientScopeId, e.replacement);
7797
7814
  case "directory.accepted": {
7798
7815
  const n = t.selections[e.conversationScopeId];
7799
7816
  if (!n || n.provisionalId !== e.provisionalId) return t;
@@ -7805,7 +7822,7 @@ function ac(t, e, s) {
7805
7822
  if (i.length === 0) return t;
7806
7823
  let r = t;
7807
7824
  for (const [a] of i)
7808
- r = ui(r, a, e.conversationScopeId, { ...n, sessionId: e.sessionId });
7825
+ r = hi(r, a, e.conversationScopeId, { ...n, sessionId: e.sessionId });
7809
7826
  return r;
7810
7827
  }
7811
7828
  case "directory.view_attach":
@@ -7845,7 +7862,7 @@ function Te(t, e, s) {
7845
7862
  if (e.expectedGeneration !== t.generation || e.generation <= t.generation) return { state: t, effects: i };
7846
7863
  const r = e.adoptLocalSubmissions && !t.authorityId ? Object.fromEntries(Object.entries(t.clients).filter(([, a]) => t.selections[a]?.sessionId === null)) : {};
7847
7864
  n = {
7848
- ...dr(),
7865
+ ...lr(),
7849
7866
  authorityId: e.authorityId,
7850
7867
  generation: e.generation,
7851
7868
  clients: r,
@@ -8079,7 +8096,7 @@ class uc {
8079
8096
  return this.state;
8080
8097
  }
8081
8098
  recordDiagnosticTransition(e, s = !1) {
8082
- let n = Eo(e, this.diagnostics.revision + 1, s);
8099
+ let n = qo(e, this.diagnostics.revision + 1, s);
8083
8100
  if (n?.effectId) {
8084
8101
  if (n.type === "effect.started")
8085
8102
  this.diagnosticEffects.set(n.effectId, n), this.diagnosticEffects.size > 128 && this.diagnosticEffects.delete(this.diagnosticEffects.keys().next().value);
@@ -8204,7 +8221,7 @@ const hc = Object.freeze({
8204
8221
  interactions: "core",
8205
8222
  browserExecution: "legacy"
8206
8223
  });
8207
- function hi(t, e) {
8224
+ function pi(t, e) {
8208
8225
  const s = hc[t], n = e[s];
8209
8226
  if (!n) throw new Error(`No ${s} implementation for ${t}.`);
8210
8227
  return n();
@@ -8242,7 +8259,7 @@ const gc = {
8242
8259
  throw new Error("Conversation command adapter is not installed.");
8243
8260
  }
8244
8261
  };
8245
- function pi(t, e, s) {
8262
+ function fi(t, e, s) {
8246
8263
  if (t === e) return s;
8247
8264
  let n = s;
8248
8265
  const i = { authorityId: e.authorityId, generation: e.generation };
@@ -8288,9 +8305,9 @@ class yc {
8288
8305
  features: G(Bs()),
8289
8306
  interactions: G(js()),
8290
8307
  modelSelection: rc(),
8291
- directory: dr(),
8292
- conversation: Pi(),
8293
- activeUsers: hr()
8308
+ directory: lr(),
8309
+ conversation: Di(),
8310
+ activeUsers: pr()
8294
8311
  }) }),
8295
8312
  reducer: (r, a) => {
8296
8313
  const o = a.value;
@@ -8305,14 +8322,14 @@ class yc {
8305
8322
  return { state: d.state === r.slices.activeUsers ? r : Object.freeze({ revision: r.revision + 1, slices: Object.freeze({ ...r.slices, activeUsers: d.state }) }), effects: d.effects };
8306
8323
  }
8307
8324
  if (pc(o)) {
8308
- const d = Te(r.slices.directory, o, r.slices.conversation), l = Gs(Vs(r.slices.conversation, d.state, o.type === "directory.authority_replace" && o.adoptLocalSubmissions === !0)), u = Ks(r.slices.conversation, l.state, d.state, d.state.clients !== r.slices.directory.clients), h = u.state, p = pi(r.slices.conversation, h, d.state);
8325
+ const d = Te(r.slices.directory, o, r.slices.conversation), l = Gs(Vs(r.slices.conversation, d.state, o.type === "directory.authority_replace" && o.adoptLocalSubmissions === !0)), u = Ks(r.slices.conversation, l.state, d.state, d.state.clients !== r.slices.directory.clients), h = u.state, p = fi(r.slices.conversation, h, d.state);
8309
8326
  return { state: p === r.slices.directory && h === r.slices.conversation ? r : Object.freeze({
8310
8327
  revision: r.revision + 1,
8311
8328
  slices: Object.freeze({ ...r.slices, directory: p, conversation: h })
8312
8329
  }), effects: [...u.effects, ...d.effects, ...l.effects] };
8313
8330
  }
8314
8331
  if (fc(o)) {
8315
- const d = bo(r.slices.conversation, o, r.slices.directory, r.slices.modelSelection);
8332
+ const d = Io(r.slices.conversation, o, r.slices.directory, r.slices.modelSelection);
8316
8333
  let l = r.slices.directory;
8317
8334
  for (const [k, R] of Object.entries(d.state.operations)) {
8318
8335
  if (!["runtime.warmup", "attachment.prepare"].includes(R.command.type) || !R.conversationScopeId || R.phase !== "done" || r.slices.conversation.operations[k]?.phase === "done") continue;
@@ -8338,7 +8355,7 @@ class yc {
8338
8355
  sessionId: u.sessionId
8339
8356
  }).state);
8340
8357
  }
8341
- l = pi(r.slices.conversation, d.state, l);
8358
+ l = fi(r.slices.conversation, d.state, l);
8342
8359
  const h = Gs(Vs(d.state, l)), p = Ks(d.state, h.state, l);
8343
8360
  let m = r.slices;
8344
8361
  const f = [], y = d.interactionSources, b = m.account.authority;
@@ -8357,7 +8374,7 @@ class yc {
8357
8374
  slices: Object.freeze({ ...r.slices, modelSelection: c })
8358
8375
  }), effects: [] };
8359
8376
  },
8360
- selector: (r) => Object.freeze({ ...r.slices, directory: dc(r.slices.directory), conversation: Kr(r.slices.conversation, r.slices.directory) }),
8377
+ selector: (r) => Object.freeze({ ...r.slices, directory: dc(r.slices.directory), conversation: Wr(r.slices.conversation, r.slices.directory) }),
8361
8378
  effectHandlers: {
8362
8379
  ...e,
8363
8380
  "stage7.platform": (r) => {
@@ -8422,10 +8439,10 @@ class yc {
8422
8439
  }
8423
8440
  route(e, s) {
8424
8441
  if (this.disposed) throw new Error("Product Agent runtime is disposed.");
8425
- return hi(e, s);
8442
+ return pi(e, s);
8426
8443
  }
8427
8444
  project(e, s) {
8428
- return hi(e, s);
8445
+ return pi(e, s);
8429
8446
  }
8430
8447
  onDispose(e) {
8431
8448
  return this.disposed ? (e(), () => {
@@ -8442,10 +8459,10 @@ class yc {
8442
8459
  const vc = "pluno-product-agent-attachments", bc = 1, nn = "files", Ic = 1440 * 60 * 1e3;
8443
8460
  async function wc(t) {
8444
8461
  const e = await Ht();
8445
- await fr(e, "readwrite", (s) => s.put(t));
8462
+ await gr(e, "readwrite", (s) => s.put(t));
8446
8463
  }
8447
- async function fi(t) {
8448
- const e = await Ht(), s = await fr(
8464
+ async function gi(t) {
8465
+ const e = await Ht(), s = await gr(
8449
8466
  e,
8450
8467
  "readonly",
8451
8468
  (i) => i.get(t)
@@ -8453,9 +8470,9 @@ async function fi(t) {
8453
8470
  if (!s)
8454
8471
  return null;
8455
8472
  const n = Date.now();
8456
- return await pr(t, { lastUsedAt: n }), { ...s, lastUsedAt: n };
8473
+ return await fr(t, { lastUsedAt: n }), { ...s, lastUsedAt: n };
8457
8474
  }
8458
- async function pr(t, e) {
8475
+ async function fr(t, e) {
8459
8476
  const s = await Ht();
8460
8477
  await wn(s, "readwrite", async (n) => {
8461
8478
  const i = await _n(
@@ -8483,7 +8500,7 @@ function Ht() {
8483
8500
  }, s.onsuccess = () => t(s.result), s.onerror = () => e(s.error ?? new Error("Failed to open Product Agent attachment storage"));
8484
8501
  });
8485
8502
  }
8486
- async function fr(t, e, s) {
8503
+ async function gr(t, e, s) {
8487
8504
  return await wn(t, e, async (n) => await _n(s(n)));
8488
8505
  }
8489
8506
  function wn(t, e, s) {
@@ -8516,7 +8533,7 @@ function _n(t) {
8516
8533
  function Sc(t) {
8517
8534
  return t !== null && (typeof t == "object" || typeof t == "function");
8518
8535
  }
8519
- function gr(t, e, s) {
8536
+ function mr(t, e, s) {
8520
8537
  const n = Reflect.get(t, "pluno"), i = Sc(n) ? n : {};
8521
8538
  if (i !== n && !Reflect.set(t, "pluno", i))
8522
8539
  return null;
@@ -8531,7 +8548,7 @@ function gr(t, e, s) {
8531
8548
  }
8532
8549
  };
8533
8550
  }
8534
- const mr = "suggest_share_on_socials";
8551
+ const yr = "suggest_share_on_socials";
8535
8552
  function kc(t) {
8536
8553
  let e = t;
8537
8554
  if (typeof t == "string")
@@ -8553,7 +8570,7 @@ function Ec(t) {
8553
8570
  const gs = "pluno.productAgent.transportId", qc = "pluno.productAgent.transportIdentity", ms = "pluno.productAgent.transportIdentity.event", Tc = 50, Cc = globalThis.setTimeout.bind(globalThis);
8554
8571
  let Je = null;
8555
8572
  const Ct = /* @__PURE__ */ new Set(), ys = /* @__PURE__ */ new Map();
8556
- async function Oc(t = yr()) {
8573
+ async function Oc(t = vr()) {
8557
8574
  const e = t.randomUUID(), s = t.storage.getItem(gs);
8558
8575
  let n = s ?? t.randomUUID(), i = !1, r = !1;
8559
8576
  const a = t.channel.subscribe((c) => {
@@ -8593,7 +8610,7 @@ async function Oc(t = yr()) {
8593
8610
  }
8594
8611
  async function xc(t = !1) {
8595
8612
  Je || (Je = Oc({
8596
- ...yr(),
8613
+ ...vr(),
8597
8614
  skipStoredIdentityCollisionCheck: t
8598
8615
  }), Je.then((i) => {
8599
8616
  const r = (a) => {
@@ -8618,7 +8635,7 @@ function Mc() {
8618
8635
  t += 1;
8619
8636
  return t;
8620
8637
  }
8621
- function yr() {
8638
+ function vr() {
8622
8639
  return {
8623
8640
  storage: Pc(),
8624
8641
  channel: Dc(),
@@ -8679,7 +8696,7 @@ function Uc() {
8679
8696
  }
8680
8697
  };
8681
8698
  }
8682
- const vr = "schedule_follow_up";
8699
+ const br = "schedule_follow_up";
8683
8700
  function Nc(t) {
8684
8701
  let e = t;
8685
8702
  if (typeof e == "string")
@@ -8691,7 +8708,7 @@ function Nc(t) {
8691
8708
  if (!e || typeof e != "object")
8692
8709
  return null;
8693
8710
  const s = e;
8694
- return s.ok !== !0 || s.toolName !== vr || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : {
8711
+ return s.ok !== !0 || s.toolName !== br || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : {
8695
8712
  id: typeof s.taskId == "string" && s.taskId ? s.taskId : null,
8696
8713
  dueAt: s.dueAt
8697
8714
  };
@@ -8730,7 +8747,7 @@ function Fc(t) {
8730
8747
  if (!(!rn(s) || !rn(n) || i !== "openrouter" && i !== "azure" && i !== "openai"))
8731
8748
  return Object.freeze({ requestedModel: s, effectiveModel: n, provider: i });
8732
8749
  }
8733
- const Sn = (t, e) => go(
8750
+ const Sn = (t, e) => mo(
8734
8751
  t.engine.getState().slices.modelSelection,
8735
8752
  e
8736
8753
  ), $c = (t, e) => ln(Sn(t, e));
@@ -8778,7 +8795,7 @@ class nu {
8778
8795
  nextCursor: r.nextCursor
8779
8796
  }))
8780
8797
  ),
8781
- zo
8798
+ Ho
8782
8799
  ), this.pinnedQuery = new Qn(
8783
8800
  `${e}:pinned`,
8784
8801
  async () => St({
@@ -8974,7 +8991,7 @@ class iu {
8974
8991
  userPrompt: o?.type === "user_message" ? o.data.content : "",
8975
8992
  assistantAnswer: ""
8976
8993
  },
8977
- terminal: !a.wait_for_terminal || Ni(n, r.user_message_id)
8994
+ terminal: !a.wait_for_terminal || ji(n, r.user_message_id)
8978
8995
  };
8979
8996
  } else a.kind === "integration_auth" ? s.integrations.push({
8980
8997
  revision: r.version,
@@ -9040,7 +9057,7 @@ class iu {
9040
9057
  async applyAction(e, s, n) {
9041
9058
  if (!e.allowedActions.includes(s))
9042
9059
  throw new Error(`Interaction ${e.key} does not allow ${s}.`);
9043
- if (!br(s))
9060
+ if (!Ir(s))
9044
9061
  throw new Error(`Interaction action ${s} is not a persistence decision.`);
9045
9062
  const i = n.now ?? /* @__PURE__ */ new Date(), r = {
9046
9063
  promptKey: e.key,
@@ -9091,13 +9108,13 @@ function Vc(t, e) {
9091
9108
  function ws(t) {
9092
9109
  return `${t.level}:${t.key}`;
9093
9110
  }
9094
- function br(t) {
9111
+ function Ir(t) {
9095
9112
  return t === "dismiss" || t === "later" || t === "snooze" || t === "never" || t === "dont_show_again";
9096
9113
  }
9097
9114
  function on(t) {
9098
9115
  if (!t || typeof t != "object") return !1;
9099
9116
  const e = t;
9100
- return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && br(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
9117
+ return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && Ir(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
9101
9118
  }
9102
9119
  const Kc = {
9103
9120
  working: "⏳",
@@ -9186,7 +9203,7 @@ const Jc = {
9186
9203
  function Qc(t) {
9187
9204
  return typeof t == "string" && t.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(Jc, t.slice(13));
9188
9205
  }
9189
- function gi(t) {
9206
+ function mi(t) {
9190
9207
  return {
9191
9208
  ...t.id === void 0 ? {} : { id: t.id },
9192
9209
  name: t.name,
@@ -9209,13 +9226,13 @@ function cu(t) {
9209
9226
  case "run.stop":
9210
9227
  return e.clientMessageIds === void 0 || Array.isArray(e.clientMessageIds) && e.clientMessageIds.length <= 100 && e.clientMessageIds.every((s) => typeof s == "string" && s.length > 0 && s.length <= 160);
9211
9228
  case "runtime.report_response_visibility":
9212
- return ur(e.observation);
9229
+ return hr(e.observation);
9213
9230
  case "runtime.warmup":
9214
9231
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
9215
9232
  case "runtime.report_operation_timing":
9216
9233
  return rt(e.timing);
9217
9234
  case "runtime.report_displayed_error":
9218
- return (e.errorDiagnostic === void 0 || Co(e.errorDiagnostic)) && (e.httpRequest === void 0 || he(e.httpRequest)) && (e.historyRefreshFailure === void 0 || hn(e.historyRefreshFailure)) && (e.renderedError === void 0 || fn(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);
9235
+ return (e.errorDiagnostic === void 0 || Oo(e.errorDiagnostic)) && (e.httpRequest === void 0 || he(e.httpRequest)) && (e.historyRefreshFailure === void 0 || hn(e.historyRefreshFailure)) && (e.renderedError === void 0 || fn(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);
9219
9236
  case "runtime.report_invalid_state_transition":
9220
9237
  return (e.uiInvariant === void 0 || gn(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || Qc(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
9221
9238
  case "runtime.prompt_presented":
@@ -9238,7 +9255,7 @@ function cu(t) {
9238
9255
  case "conversation.stage_proactive_suggestion":
9239
9256
  return typeof e.question == "string" && typeof e.clientMessageId == "string";
9240
9257
  case "conversation.stage":
9241
- 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));
9258
+ return (e.reconcileAcceptance === void 0 || typeof e.reconcileAcceptance == "boolean") && (e.selectionKey === void 0 || typeof e.selectionKey == "string") && (e.reconcileAcceptance !== !0 || typeof e.selectionKey == "string" && e.selectionKey.length > 0) && 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));
9242
9259
  case "conversation.fail_staged":
9243
9260
  return typeof e.clientMessageId == "string" && typeof e.message == "string";
9244
9261
  case "conversation.send":
@@ -9266,6 +9283,8 @@ class du {
9266
9283
  pendingTransfers = /* @__PURE__ */ new Map();
9267
9284
  // Presentation of commands in transit only; the background remains the submission/delivery owner.
9268
9285
  submissionPreviews = /* @__PURE__ */ new Map();
9286
+ // Durable metadata can retire the preview before receipt reconciliation permits byte transfer.
9287
+ submissionRetries = /* @__PURE__ */ new Map();
9269
9288
  submissionGeneration = 0;
9270
9289
  pendingStop = null;
9271
9290
  stopError = null;
@@ -9305,7 +9324,7 @@ class du {
9305
9324
  a.sessionId !== e.sessionId && !(a.sessionId === null && c) || (o.attachments = Xc(c?.attachments, o.attachments));
9306
9325
  }
9307
9326
  if (s !== void 0 && (this.model = s), n && JSON.stringify(n) !== JSON.stringify(this.sessionHistoryState)) {
9308
- this.sessionHistoryState = mi(n);
9327
+ this.sessionHistoryState = yi(n);
9309
9328
  for (const o of this.sessionHistoryListeners)
9310
9329
  o(this.getSessionHistoryState());
9311
9330
  }
@@ -9326,7 +9345,7 @@ class du {
9326
9345
  if (!this.destroyed) {
9327
9346
  this.destroyed = !0;
9328
9347
  for (const e of this.durabilityWaiters) e();
9329
- this.pendingStop = null, this.stopPreviews.clear(), this.pendingTransfers.clear(), this.submissionPreviews.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
9348
+ this.pendingStop = null, this.stopPreviews.clear(), this.pendingTransfers.clear(), this.submissionRetries.clear(), this.submissionPreviews.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
9330
9349
  for (const e of Object.values(this.listeners)) e?.clear();
9331
9350
  this.adapter.onDisconnect?.();
9332
9351
  }
@@ -9361,7 +9380,7 @@ class du {
9361
9380
  reportDisplayedError(e, s, n, i, r) {
9362
9381
  const a = e === "conversation_error" && !i ? this.getState().conversationDiagnostics?.httpRequest : void 0;
9363
9382
  if (i !== void 0 && !fn(i) || r !== void 0 && !hn(r)) return;
9364
- const o = Gi(this.getState(), e, n, !!i, this.adapter.diagnosticBuilds);
9383
+ const o = Ji(this.getState(), e, n, !!i, this.adapter.diagnosticBuilds);
9365
9384
  this.adapter.dispatch({
9366
9385
  type: "runtime.report_displayed_error",
9367
9386
  errorDiagnostic: o,
@@ -9389,7 +9408,7 @@ class du {
9389
9408
  createdAt: "",
9390
9409
  attachments: i.map((d) => ({ ...d }))
9391
9410
  } });
9392
- const c = this.sendMessageNow(n, { ...s, clientMessageId: r, submittedAt: a }, o);
9411
+ const c = this.sendMessageNow(n, { ...s, clientMessageId: r, submittedAt: a, selectionKey: this.state.selectionKey }, o);
9393
9412
  return this.emit("state", this.getState()), c.finally(() => {
9394
9413
  this.pendingTransfers.delete(r);
9395
9414
  });
@@ -9408,9 +9427,10 @@ class du {
9408
9427
  let o = s.attachments ?? [], c = !1;
9409
9428
  if (n !== this.submissionGeneration) return null;
9410
9429
  try {
9411
- if (!await a.measure("staging_ipc", async () => {
9430
+ const d = await a.measure("staging_ipc", async () => {
9412
9431
  const l = await this.enqueueOperation(async () => this.destroyed || n !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
9413
9432
  type: "conversation.stage",
9433
+ ...s.reconcileAcceptance ? { reconcileAcceptance: !0, selectionKey: s.selectionKey } : {},
9414
9434
  initiatedBy: s.initiatedBy,
9415
9435
  invocation: s.invocation,
9416
9436
  automationOnboarding: s.automationOnboarding,
@@ -9418,17 +9438,24 @@ class du {
9418
9438
  clientMessageId: r,
9419
9439
  proactiveSuggestionQuestion: s.proactiveSuggestionQuestion,
9420
9440
  // Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
9421
- attachments: o.length > 0 ? o.map(gi) : void 0,
9441
+ attachments: o.length > 0 ? o.map(mi) : void 0,
9422
9442
  submittedAt: s.submittedAt
9423
9443
  }) });
9424
- return l && await l.result.then(() => !0, (h) => {
9425
- const p = Y(h);
9426
- if (p.code !== "submission_checkpoint_pending") throw h;
9427
- const m = this.submissionPreviews.get(r);
9428
- return m && (m.error = p), this.emit("state", this.getState()), this.waitForSubmissionDurability(r, n);
9429
- }) ? l : null;
9430
- }) || n !== this.submissionGeneration) return null;
9431
- if (c = !0, o.length > 0) {
9444
+ return l ? l.result.then((u) => ({ result: u }), async (u) => {
9445
+ const h = Y(u);
9446
+ if (h.code !== "submission_checkpoint_pending") throw u;
9447
+ const p = this.submissionPreviews.get(r);
9448
+ return p && (p.error = h), this.emit("state", this.getState()), await this.waitForSubmissionDurability(r, n) ? { result: void 0 } : null;
9449
+ }) : null;
9450
+ });
9451
+ if (!d || n !== this.submissionGeneration) return null;
9452
+ if (c = !0, this.submissionRetries.delete(r), d.result?.submissionAccepted) {
9453
+ r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null);
9454
+ for (const l of s.attachments ?? [])
9455
+ l.id && this.attachmentFiles.delete(l.id);
9456
+ return r;
9457
+ }
9458
+ if (o.length > 0) {
9432
9459
  if (!this.adapter.uploadAttachment)
9433
9460
  throw new Error("The runtime does not support attachments.");
9434
9461
  const l = [];
@@ -9451,18 +9478,23 @@ class du {
9451
9478
  invocation: s.invocation,
9452
9479
  automationOnboarding: s.automationOnboarding,
9453
9480
  proactiveSuggestionQuestion: s.proactiveSuggestionQuestion,
9454
- attachments: o.length > 0 ? o.map(gi) : void 0
9481
+ attachments: o.length > 0 ? o.map(mi) : void 0
9455
9482
  }), n !== this.submissionGeneration)) return null;
9456
9483
  for (const l of s.attachments ?? [])
9457
9484
  l.id && this.attachmentFiles.delete(l.id);
9458
9485
  return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
9459
9486
  } catch (d) {
9460
9487
  if (n !== this.submissionGeneration) return null;
9461
- if (Wo(d))
9462
- for (const u of s.attachments ?? [])
9463
- u.id && this.attachmentFiles.delete(u.id);
9464
- const l = this.submissionPreviews.get(r);
9465
- throw l && (l.pending = !1, l.error = Y(d), l.retry = !c && Y(d).code === "command_not_received" ? () => this.sendMessageNow(e, s, n) : void 0, this.emit("state", this.getState())), c && await this.adapter.dispatch({
9488
+ if (Xn(d))
9489
+ for (const p of s.attachments ?? [])
9490
+ p.id && this.attachmentFiles.delete(p.id);
9491
+ const u = Y(d).code === "command_not_received";
9492
+ !c && !Xn(d) && (u || s.selectionKey !== void 0) && this.submissionRetries.set(r, {
9493
+ retry: () => this.sendMessageNow(e, { ...s, reconcileAcceptance: !u }, n),
9494
+ attachmentIds: (s.attachments ?? []).flatMap((p) => p.id ? [p.id] : [])
9495
+ });
9496
+ const h = this.submissionPreviews.get(r);
9497
+ throw h && (h.pending = !1, h.error = Y(d), this.emit("state", this.getState())), c && await this.adapter.dispatch({
9466
9498
  type: "conversation.fail_staged",
9467
9499
  clientMessageId: r,
9468
9500
  message: Y(d).message
@@ -9477,18 +9509,18 @@ class du {
9477
9509
  });
9478
9510
  }
9479
9511
  async retryLastMessage(e) {
9480
- const s = e ?? [...this.submissionPreviews].reverse().find(([, a]) => a.error)?.[0] ?? this.state.messages.filter((a) => a.role === "user").slice(-1)[0]?.id;
9512
+ const s = e ?? [...this.submissionPreviews].reverse().find(([, o]) => o.error)?.[0] ?? this.state.messages.filter((o) => o.role === "user").slice(-1)[0]?.id;
9481
9513
  if (!s || this.destroyed) return !1;
9482
9514
  const n = this.submissionPreviews.get(s);
9483
- if (n?.pending) return !1;
9484
- const i = n?.retry, r = this.submissionGeneration;
9515
+ if (n?.pending || this.pendingTransfers.has(s)) return !1;
9516
+ const i = this.submissionRetries.get(s), r = i?.retry, a = this.submissionGeneration;
9485
9517
  try {
9486
- return n && i ? (n.pending = !0, n.error = void 0, n.retry = void 0, this.pendingTransfers.set(s, (n.message.attachments ?? []).flatMap((a) => a.id ? [a.id] : [])), this.emit("state", this.getState()), await i()) : await this.dispatch({ type: "run.retry", clientMessageId: s }), !0;
9487
- } catch (a) {
9488
- if (!n) throw a;
9489
- return r === this.submissionGeneration && this.submissionPreviews.get(s) === n && (n.error = Y(a), this.emit("state", this.getState())), !1;
9518
+ return i && r ? (n && (n.pending = !0, n.error = void 0), this.submissionRetries.delete(s), this.pendingTransfers.set(s, i.attachmentIds), this.emit("state", this.getState()), await r()) : await this.dispatch({ type: "run.retry", clientMessageId: s }), !0;
9519
+ } catch (o) {
9520
+ if (!n && !r) throw o;
9521
+ return n && a === this.submissionGeneration && this.submissionPreviews.get(s) === n && (n.error = Y(o), this.emit("state", this.getState())), !1;
9490
9522
  } finally {
9491
- i && this.pendingTransfers.delete(s), n && r === this.submissionGeneration && this.submissionPreviews.get(s) === n && (n.pending = !1, this.emit("state", this.getState()));
9523
+ r && this.pendingTransfers.delete(s), n && a === this.submissionGeneration && this.submissionPreviews.get(s) === n && (n.pending = !1, this.emit("state", this.getState()));
9492
9524
  }
9493
9525
  }
9494
9526
  createLocalAttachment(e) {
@@ -9567,14 +9599,17 @@ class du {
9567
9599
  }
9568
9600
  cancelPendingSubmissions(e = !0) {
9569
9601
  this.pendingStop = null, e && this.stopPreviews.clear(), this.stopError = null;
9570
- const s = [...this.pendingTransfers.keys()];
9602
+ const s = [.../* @__PURE__ */ new Set([...this.pendingTransfers.keys(), ...this.submissionRetries.keys()])];
9571
9603
  this.submissionGeneration++;
9572
9604
  for (const n of this.durabilityWaiters) n();
9573
9605
  for (const n of this.pendingTransfers.values())
9574
9606
  for (const i of n) this.attachmentFiles.delete(i);
9575
9607
  this.pendingTransfers.clear();
9608
+ for (const n of this.submissionRetries.values())
9609
+ for (const i of n.attachmentIds) this.attachmentFiles.delete(i);
9610
+ this.submissionRetries.clear();
9576
9611
  for (const n of this.submissionPreviews.values()) {
9577
- n.pending = !1, n.retry = void 0, n.error?.code === "submission_checkpoint_pending" && (n.error = void 0);
9612
+ n.pending = !1, n.error?.code === "submission_checkpoint_pending" && (n.error = void 0);
9578
9613
  for (const i of n.message.attachments ?? [])
9579
9614
  i.id && this.attachmentFiles.delete(i.id);
9580
9615
  }
@@ -9594,7 +9629,7 @@ class du {
9594
9629
  return s.sessionHistoryPage;
9595
9630
  }
9596
9631
  getSessionHistoryState() {
9597
- return mi(this.sessionHistoryState);
9632
+ return yi(this.sessionHistoryState);
9598
9633
  }
9599
9634
  subscribeSessionHistory(e) {
9600
9635
  return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
@@ -9712,16 +9747,16 @@ function _s(t) {
9712
9747
  activeScheduledFollowUps: t.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
9713
9748
  };
9714
9749
  }
9715
- function mi(t) {
9750
+ function yi(t) {
9716
9751
  return {
9717
9752
  ...t,
9718
9753
  data: t.data ? St({
9719
- entities: Ho(t.data).map((e) => ({ ...e })),
9754
+ entities: Vo(t.data).map((e) => ({ ...e })),
9720
9755
  nextCursor: t.data.nextCursor
9721
9756
  }) : null
9722
9757
  };
9723
9758
  }
9724
- const Yc = globalThis.fetch.bind(globalThis), yi = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Zc = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ed = ".pluno-pa-widget__panel", td = ".pluno-pa-widget__timeline", sd = "__plunoExtensionWidgetOwner";
9759
+ const Yc = globalThis.fetch.bind(globalThis), vi = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Zc = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ed = ".pluno-pa-widget__panel", td = ".pluno-pa-widget__timeline", sd = "__plunoExtensionWidgetOwner";
9725
9760
  class ue extends Error {
9726
9761
  constructor(e, s, n, i) {
9727
9762
  super(e), this.retryable = s, this.status = n, this.retryAfterMs = i, this.name = "ProductAgentTokenProviderError";
@@ -9762,7 +9797,7 @@ function Ss(t) {
9762
9797
  const r = (c) => {
9763
9798
  if (!c || typeof c != "object")
9764
9799
  return null;
9765
- const d = c, l = d.data, u = l && typeof l == "object" ? l : {}, h = Rr(c);
9800
+ const d = c, l = d.data, u = l && typeof l == "object" ? l : {}, h = Ar(c);
9766
9801
  return {
9767
9802
  id: typeof d.id == "string" ? d.id : null,
9768
9803
  streamId: u.type === "message" && u.role === "assistant" && typeof u.id == "string" ? u.id : null,
@@ -9775,7 +9810,7 @@ function Ss(t) {
9775
9810
  stage: typeof u.stage == "string" ? u.stage : null,
9776
9811
  retryable: u.retryable === !0,
9777
9812
  visible: !!(h && // Recovery-only failures are intentionally hidden, not missing transcript items.
9778
- !(u.type === "run_error" && u.retryable === !0) && !h.scheduledCheckInAt && h.toolName !== mr && (u.type !== "run_status" || ["failed", "interrupted", "stopped"].includes(String(u.status))))
9813
+ !(u.type === "run_error" && u.retryable === !0) && !h.scheduledCheckInAt && h.toolName !== yr && (u.type !== "run_status" || ["failed", "interrupted", "stopped"].includes(String(u.status))))
9779
9814
  };
9780
9815
  }, a = r(t.item);
9781
9816
  if (a?.id && (e.itemId = a.id, a.type && (e.itemType = a.type), a.role && (e.itemRole = a.role), a.sessionId && typeof e.sessionId != "string" && (e.sessionId = a.sessionId), a.runId && typeof e.runId != "string" && (e.runId = a.runId), a.respondsToUserMessageId && typeof e.respondsToUserMessageId != "string" && (e.respondsToUserMessageId = a.respondsToUserMessageId), a.status && (e.itemStatus = a.status), a.stage && (e.itemStage = a.stage), a.retryable && (e.itemRetryable = !0), a.visible && (e.visibleItemId = a.id, a.streamId && (e.visibleItemAliases = JSON.stringify([[a.streamId, a.id]])))), Array.isArray(t.items)) {
@@ -9796,7 +9831,7 @@ function Ss(t) {
9796
9831
  }
9797
9832
  }
9798
9833
  }
9799
- return { ...e, ...xo(t) };
9834
+ return { ...e, ...Mo(t) };
9800
9835
  }
9801
9836
  function Me(t, e, s) {
9802
9837
  if (typeof window > "u")
@@ -9817,16 +9852,16 @@ function Me(t, e, s) {
9817
9852
  };
9818
9853
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: i }));
9819
9854
  }
9820
- const id = "https://app.pluno.ai", rd = 2e4, od = 1e4, ad = 6e4, cd = 6e4, dd = 1e4, ld = 1e4, ud = 1e3, an = 3e4, vi = 0.2, ks = 6e4, Rs = 3, bi = "Still connecting to Pluno. Retrying automatically.", hd = 1e3, pd = 100, Ii = 3, fd = [300, 1e3], Ir = 50 * 1024 * 1024, gd = /* @__PURE__ */ new Set([
9855
+ const id = "https://app.pluno.ai", rd = 2e4, od = 1e4, ad = 6e4, cd = 6e4, dd = 1e4, ld = 1e4, ud = 1e3, an = 3e4, bi = 0.2, ks = 6e4, Rs = 3, Ii = "Still connecting to Pluno. Retrying automatically.", hd = 1e3, pd = 100, wi = 3, fd = [300, 1e3], wr = 50 * 1024 * 1024, gd = /* @__PURE__ */ new Set([
9821
9856
  ".jpeg:image/jpeg",
9822
9857
  ".jpg:image/jpeg",
9823
9858
  ".pdf:application/pdf",
9824
9859
  ".png:image/png",
9825
9860
  ".webp:image/webp"
9826
- ]), lu = ".pdf,.png,.jpg,.jpeg,.webp", kn = 64e3, As = 4e3, Rn = 30, md = 2e3, yd = 1e3, wr = "Image is too large for model vision input.", vd = "pluno.productAgent.state.", cn = "pluno.productAgent.pendingEvents.", Vt = "pluno.productAgent.activeToolCalls.", bd = 100, Ot = /* @__PURE__ */ new Set();
9861
+ ]), lu = ".pdf,.png,.jpg,.jpeg,.webp", kn = 64e3, As = 4e3, Rn = 30, md = 2e3, yd = 1e3, _r = "Image is too large for model vision input.", vd = "pluno.productAgent.state.", cn = "pluno.productAgent.pendingEvents.", Vt = "pluno.productAgent.activeToolCalls.", bd = 100, Ot = /* @__PURE__ */ new Set();
9827
9862
  let mt = null;
9828
9863
  function Id(t, e = Math.random) {
9829
- const s = Math.min(an, ud * 2 ** t), n = 1 - vi + e() * vi * 2;
9864
+ const s = Math.min(an, ud * 2 ** t), n = 1 - bi + e() * bi * 2;
9830
9865
  return Math.min(an, Math.round(s * n));
9831
9866
  }
9832
9867
  function wd(t) {
@@ -9868,7 +9903,7 @@ class Kt {
9868
9903
  this.options = e, this.transportIdentity = s, this.directoryAuthority = {
9869
9904
  authorityId: cs(`pa.authority:${e.clientId}`) ?? `${e.clientId}:${e.runtimeCommunityId ?? e.productVariant}`,
9870
9905
  generation: 1
9871
- }, this.directoryHttp = new cr({
9906
+ }, this.directoryHttp = new dr({
9872
9907
  backendUrl: e.backendUrl,
9873
9908
  authority: () => `${this.directoryAuthority.authorityId}:${this.directoryAuthority.generation}`,
9874
9909
  authenticationFailure: () => this.authenticationFailure,
@@ -9899,9 +9934,9 @@ class Kt {
9899
9934
  pageUrl: () => location.href,
9900
9935
  now: () => Date.now(),
9901
9936
  onError: (i) => this.handleDirectoryTransportError(i)
9902
- }), void 0, Mo(async () => {
9937
+ }), void 0, Po(async () => {
9903
9938
  if (!this.token || !this.state.user || this.state.status === "closed") throw new Error("Product Agent is not authenticated");
9904
- return this.options.activeUsersLoader ? (await this.options.activeUsersLoader()).count : Po(this.options.backendUrl);
9939
+ return this.options.activeUsersLoader ? (await this.options.activeUsersLoader()).count : Do(this.options.backendUrl);
9905
9940
  })), this.modelClientScopeId = Lc(e.clientId, () => crypto.randomUUID()), this.directoryConversationScopeId = `conversation:${this.modelClientScopeId}`, this.createDirectoryAdapters(), this.clientRuntime.engine.dispatch({
9906
9941
  type: "model.scope_open",
9907
9942
  clientScopeId: this.modelClientScopeId,
@@ -10033,7 +10068,7 @@ class Kt {
10033
10068
  backendUrl: jd(e.backendUrl ?? id),
10034
10069
  clientId: e.clientId ?? sl(),
10035
10070
  productVariant: e.productVariant ?? "customer_embedded",
10036
- entrySurface: Do(e.entrySurface)
10071
+ entrySurface: Uo(e.entrySurface)
10037
10072
  }, n);
10038
10073
  try {
10039
10074
  await i.initializeDirectory(), await i.initializeConversation(), _c().catch((r) => {
@@ -10084,12 +10119,12 @@ class Kt {
10084
10119
  const e = ++this.conversationAdapterGeneration;
10085
10120
  this.conversationObservation?.dispose(), this.conversationUnsubscribe?.();
10086
10121
  const s = this.directoryAuthority, n = () => e === this.conversationAdapterGeneration;
10087
- this.operationTimingReporter = So((f) => {
10122
+ this.operationTimingReporter = ko((f) => {
10088
10123
  n() && !this.clientRuntime.isDisposed && this.reportHealthSignal("operation_timing", { timings: f.map((y) => ({ ...y, entrySurface: this.options.entrySurface })) });
10089
10124
  });
10090
10125
  const i = `pa.conversation.delivery:${this.modelClientScopeId}:${s.authorityId}`, r = `${i}:cancellations`;
10091
10126
  this.authenticatedUserId && this.options.restorePersistedState === !1 && sessionStorage.removeItem(r);
10092
- const a = this.authenticatedUserId ? cs(r) : null, o = ko({
10127
+ const a = this.authenticatedUserId ? cs(r) : null, o = Ro({
10093
10128
  authorityId: s.authorityId,
10094
10129
  isCurrent: n,
10095
10130
  read: async () => a ? JSON.parse(a) : null,
@@ -10099,7 +10134,7 @@ class Kt {
10099
10134
  onTiming: (f) => this.reportOperationTiming(f)
10100
10135
  });
10101
10136
  this.clientRuntime.installConversationPorts({
10102
- ...jo({
10137
+ ...Bo({
10103
10138
  authority: s,
10104
10139
  runtime: () => this.clientRuntime,
10105
10140
  isCurrent: n,
@@ -10135,14 +10170,14 @@ class Kt {
10135
10170
  for (const v of y)
10136
10171
  if (!v.uploaded && (await bt(b, () => (this.attachmentPersistence.get(v.sourceId) ?? Promise.resolve()).catch(() => {
10137
10172
  throw Object.assign(new Error("Attachment files could not be stored. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
10138
- })), !await bt(b, () => fi(v.sourceId))))
10173
+ })), !await bt(b, () => gi(v.sourceId))))
10139
10174
  throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
10140
10175
  return b.throwIfAborted(), k.mark("context_ready"), { ...g, now: Date.now() };
10141
10176
  },
10142
10177
  connectionId: () => this.socket instanceof L ? this.socket.connectionId : null,
10143
10178
  prepareUpload: this.options.prepareAttachmentUpload ?? (this.options.productVariant === "customer_embedded" ? (f) => this.prepareEmbedAttachmentUpload(f, n) : void 0),
10144
10179
  onUploaded: async (f, y, b) => {
10145
- await pr(f, {
10180
+ await fr(f, {
10146
10181
  sessionId: y,
10147
10182
  sandboxPath: b.sandbox_path ?? void 0,
10148
10183
  storageKey: b.storage_key ?? void 0,
@@ -10155,7 +10190,7 @@ class Kt {
10155
10190
  },
10156
10191
  persistUpload: this.options.persistAttachmentUpload,
10157
10192
  readAttachment: async (f) => {
10158
- const y = (await fi(f))?.blob;
10193
+ const y = (await gi(f))?.blob;
10159
10194
  if (!y) throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
10160
10195
  return y;
10161
10196
  },
@@ -10173,13 +10208,13 @@ class Kt {
10173
10208
  y.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
10174
10209
  return;
10175
10210
  }
10176
- V("web-sdk.conversation", "Conversation operation failed", { ...y, ...Oo(f) }), f instanceof E && f.backendRefusal && y.operation.startsWith("chat.") ? this.applyAccountSubmissionError(f.code) : this.handleDirectoryTransportError(f);
10211
+ V("web-sdk.conversation", "Conversation operation failed", { ...y, ...xo(f) }), f instanceof E && f.backendRefusal && y.operation.startsWith("chat.") ? this.applyAccountSubmissionError(f.code) : this.handleDirectoryTransportError(f);
10177
10212
  }
10178
10213
  })
10179
10214
  });
10180
10215
  const c = this.clientRuntime.engine.getState().slices.conversation, d = this.options.restorePersistedState === !1 || !this.authenticatedUserId ? null : cs(i);
10181
10216
  if (this.authenticatedUserId && !c.submissionOrder.length && !Object.keys(c.operations).length) {
10182
- const f = this.queuedClientEvents.filter((k) => k.type === "chat.user_message"), y = d ? JSON.parse(d) : f.length ? Uo(c, f.map((k) => {
10217
+ const f = this.queuedClientEvents.filter((k) => k.type === "chat.user_message"), y = d ? JSON.parse(d) : f.length ? No(c, f.map((k) => {
10183
10218
  const { type: R, ...g } = k, v = this.clientRuntime.engine.getState().slices.directory, I = v.clients[this.modelClientScopeId];
10184
10219
  return {
10185
10220
  command: { type: R, request_id: k.clientMessageId, payload: JSON.parse(JSON.stringify(g)) },
@@ -10198,7 +10233,7 @@ class Kt {
10198
10233
  b && (y || Object.keys(b.operations).length || Object.keys(b.stops).length) && await this.clientRuntime.engine.dispatch({ ...s, type: "conversation.restore_delivery", checkpoint: b });
10199
10234
  }
10200
10235
  if (this.authenticatedUserId && (this.queuedClientEvents = this.queuedClientEvents.filter((f) => !["chat.user_message", "chat.retry_last_user_message", "run.stop", "runtime.warmup", "session.reset", "attachment.upload_completed"].includes(f.type))), Re(this.options.clientId, this.queuedClientEvents), !n()) return;
10201
- this.conversationObservation = new Bo({
10236
+ this.conversationObservation = new Lo({
10202
10237
  authority: s,
10203
10238
  now: () => Date.now(),
10204
10239
  runtime: () => this.clientRuntime,
@@ -10231,7 +10266,7 @@ class Kt {
10231
10266
  for (const b of f)
10232
10267
  if (b.content.trim() && (b.role === "assistant" || b.dataType === "commentary_history" || b.dataType === "tool_summary")) {
10233
10268
  const k = y ? this.clientRuntime.engine.getState().slices.conversation.sessions[y] : void 0;
10234
- for (const R of b.respondsToUserMessageId ? Vr(k, b.respondsToUserMessageId) : [])
10269
+ for (const R of b.respondsToUserMessageId ? Kr(k, b.respondsToUserMessageId) : [])
10235
10270
  this.clearFirstResponseTimer(R, !0, y);
10236
10271
  }
10237
10272
  }
@@ -10239,7 +10274,7 @@ class Kt {
10239
10274
  let u = new Map(this.getState().messages.map((f) => [f.id, f])), h = this.clientRuntime.engine.getState().slices.conversation, p = this.clientRuntime.engine.getState().slices.directory.selections, m = this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId];
10240
10275
  this.conversationUnsubscribe = this.clientRuntime.engine.subscribe(() => {
10241
10276
  const f = this.clientRuntime.engine.getState().slices, y = h;
10242
- h = f.conversation, Ro(y, f.conversation, this.operationTimingReporter, "sdk");
10277
+ h = f.conversation, Ao(y, f.conversation, this.operationTimingReporter, "sdk");
10243
10278
  const b = m !== f.directory.clients[this.modelClientScopeId];
10244
10279
  m = f.directory.clients[this.modelClientScopeId], p !== f.directory.selections && (p = f.directory.selections, this.directoryScope.persist());
10245
10280
  for (const R of Object.values(f.conversation.submissions)) {
@@ -10342,7 +10377,7 @@ class Kt {
10342
10377
  lastErrorCode: i.lastErrorCode ?? this.platformState.lastErrorCode,
10343
10378
  lastErrorSecuritySettingsUrl: !i.lastErrorCode || i.lastErrorCode === this.platformState.lastErrorCode ? this.platformState.lastErrorSecuritySettingsUrl : null,
10344
10379
  starterPrompts: o?.data && (o.data.kind === "starterPrompts" || o.data.kind === "userSuggestedTasks") ? [...o.data.prompts] : Xd(this.options.initialStarterPrompts),
10345
- starterPromptsLoading: Yr(e, a),
10380
+ starterPromptsLoading: Zr(e, a),
10346
10381
  appearance: d ? { accentColor: d.accent, colorScheme: d.colorScheme, fontFamily: d.fontFamily, scribbleStyle: d.scribbleStyle } : null
10347
10382
  };
10348
10383
  }
@@ -10404,7 +10439,7 @@ class Kt {
10404
10439
  const n = () => {
10405
10440
  e.removeEventListener("message", i), e.removeEventListener("close", n), s();
10406
10441
  }, i = (r) => {
10407
- const a = ki(r.data);
10442
+ const a = Ri(r.data);
10408
10443
  (a.type === "auth.ok" || a.type === "error") && n();
10409
10444
  };
10410
10445
  e.addEventListener("message", i), e.addEventListener("close", n);
@@ -10481,7 +10516,7 @@ class Kt {
10481
10516
  }), a.addEventListener("message", (o) => {
10482
10517
  if (this.socket !== a)
10483
10518
  return;
10484
- const c = ki(o.data);
10519
+ const c = Ri(o.data);
10485
10520
  if (a instanceof L && c.type === "tool.call" && !Qd(c)) {
10486
10521
  this.setState({ status: "error", lastError: "Invalid tool-call envelope", lastErrorCode: "invalid_tool_call" });
10487
10522
  return;
@@ -10525,7 +10560,7 @@ class Kt {
10525
10560
  reconnectAttempt: this.reconnectAttempts
10526
10561
  }), this.reportTransportDiagnostic("auth_timeout", this.connectionFailureDiagnostic(r, "token_provider")), this.setState({
10527
10562
  status: "reconnecting",
10528
- lastError: bi,
10563
+ lastError: Ii,
10529
10564
  lastErrorCode: "connection_failed"
10530
10565
  }), this.emit("error", a), this.scheduleReconnect(
10531
10566
  r instanceof ue ? r.retryAfterMs : void 0
@@ -10629,7 +10664,7 @@ class Kt {
10629
10664
  if (this.clientRuntime.isDisposed) return null;
10630
10665
  const n = e.trim(), i = s.attachments ?? [];
10631
10666
  if (!n && !i.length) return null;
10632
- if (this.options.productVariant === "customer_embedded" && (i.forEach(Cr), i.reduce((y, b) => y + b.sizeBytes, 0) > Ir))
10667
+ if (this.options.productVariant === "customer_embedded" && (i.forEach(Or), i.reduce((y, b) => y + b.sizeBytes, 0) > wr))
10633
10668
  throw new Error("Embedded attachments must total at most 50 MB per message");
10634
10669
  const r = s.clientMessageId ?? z(), a = Q(this.operationTimingReporter, {
10635
10670
  operation: "send",
@@ -10675,7 +10710,7 @@ class Kt {
10675
10710
  context: JSON.parse(JSON.stringify({
10676
10711
  page: u,
10677
10712
  ...s.proactiveSuggestionQuestion ? { proactiveSuggestionQuestion: s.proactiveSuggestionQuestion } : {},
10678
- metadata: { ...wi(this.options.metadata), ...s.automationOnboarding ? { automationOnboarding: !0 } : {} }
10713
+ metadata: { ..._i(this.options.metadata), ...s.automationOnboarding ? { automationOnboarding: !0 } : {} }
10679
10714
  })),
10680
10715
  invocation: Bd(s.invocation ?? s.initiatedBy),
10681
10716
  entrySurface: this.options.entrySurface,
@@ -10711,7 +10746,7 @@ class Kt {
10711
10746
  reportDisplayedError(e, s, n, i, r) {
10712
10747
  const a = e === "conversation_error" && !i ? this.getState().conversationDiagnostics?.httpRequest : void 0;
10713
10748
  if (i !== void 0 && !fn(i) || r !== void 0 && !hn(r)) return;
10714
- const o = Gi(this.getState(), e, n, !!i);
10749
+ const o = Ji(this.getState(), e, n, !!i);
10715
10750
  this.reportHealthSignal("user_visible_error", {
10716
10751
  errorDiagnostic: o,
10717
10752
  ...o.clientMessageId ? { clientMessageId: o.clientMessageId } : {},
@@ -10734,10 +10769,10 @@ class Kt {
10734
10769
  } });
10735
10770
  }
10736
10771
  retryLastMessage(e) {
10737
- const s = this.clientRuntime.engine.getState().slices, n = s.directory.clients[this.modelClientScopeId], i = Ie(s.conversation, s.directory, n), r = Ui(i, e);
10772
+ const s = this.clientRuntime.engine.getState().slices, n = s.directory.clients[this.modelClientScopeId], i = Ie(s.conversation, s.directory, n), r = Ni(i, e);
10738
10773
  if (!r) return !1;
10739
10774
  if (r.type === "preparation") {
10740
- const a = z(), o = $o(r.submission);
10775
+ const a = z(), o = zo(r.submission);
10741
10776
  return bs(this.clientRuntime, this.modelClientScopeId, a, r.submission.requestedModel), this.sendMessage(o.content, { clientMessageId: a, attachments: o.attachments, proactiveSuggestionQuestion: o.proactiveSuggestionQuestion }).catch((c) => this.emit("error", Qe(c))), !0;
10742
10777
  }
10743
10778
  return r.type === "delivery" ? (this.clientRuntime.engine.dispatch({ ...this.directoryAuthority, type: "conversation.submit", userMessageId: r.userMessageId, now: Date.now(), manualRetry: !0 }), !0) : (this.clientRuntime.engine.dispatch({ ...this.directoryAuthority, type: "conversation.operation", command: {
@@ -10755,7 +10790,7 @@ class Kt {
10755
10790
  const s = z(), n = {
10756
10791
  id: s,
10757
10792
  name: e.name || "attachment",
10758
- mimeType: Tr(e),
10793
+ mimeType: Cr(e),
10759
10794
  sizeBytes: e.size
10760
10795
  }, i = Date.now(), r = wc({
10761
10796
  attachmentId: s,
@@ -10786,7 +10821,7 @@ class Kt {
10786
10821
  conversationScopeId: o,
10787
10822
  command: { request_id: c, type: "attachment.prepare", payload: {
10788
10823
  source: { sourceId: r.id, name: r.name, mimeType: r.mimeType, sizeBytes: r.sizeBytes },
10789
- context: JSON.parse(JSON.stringify({ page: ae(), metadata: wi(this.options.metadata) })),
10824
+ context: JSON.parse(JSON.stringify({ page: ae(), metadata: _i(this.options.metadata) })),
10790
10825
  requestedModel: n ?? null,
10791
10826
  entrySurface: this.options.entrySurface,
10792
10827
  sessionId: this.getState().sessionId
@@ -10801,7 +10836,7 @@ class Kt {
10801
10836
  return;
10802
10837
  }
10803
10838
  const k = f.result.attachment;
10804
- d(qr({
10839
+ d(Tr({
10805
10840
  id: k.id,
10806
10841
  name: k.name,
10807
10842
  mimeType: k.mime_type,
@@ -10833,7 +10868,7 @@ class Kt {
10833
10868
  let a = !1;
10834
10869
  return Bl(async () => {
10835
10870
  let o = await r(!1);
10836
- if (i(), !o.ok && zl(o.status) && this.options.tokenProvider && !a && (a = !0, o = await r(!0), i()), !o.ok) throw new Mr("Failed to prepare attachment upload", o.status);
10871
+ if (i(), !o.ok && zl(o.status) && this.options.tokenProvider && !a && (a = !0, o = await r(!0), i()), !o.ok) throw new Pr("Failed to prepare attachment upload", o.status);
10837
10872
  return await o.json();
10838
10873
  }, "Failed to prepare attachment upload");
10839
10874
  }
@@ -10854,7 +10889,7 @@ class Kt {
10854
10889
  const i = s.selections[n]?.sessionId;
10855
10890
  for (const [r, a] of this.activeBrowserToolCalls)
10856
10891
  a.event.sessionId === i && this.activeBrowserToolCalls.delete(r);
10857
- Ei(this.options.clientId, this.activeBrowserToolCalls.values()), this.clientRuntime.engine.dispatch({
10892
+ qi(this.options.clientId, this.activeBrowserToolCalls.values()), this.clientRuntime.engine.dispatch({
10858
10893
  ...this.directoryAuthority,
10859
10894
  type: "conversation.stop",
10860
10895
  clientScopeId: this.modelClientScopeId,
@@ -10942,7 +10977,7 @@ class Kt {
10942
10977
  sessionId: e,
10943
10978
  requestId: n,
10944
10979
  patch: { pinned: s }
10945
- }), await ii({
10980
+ }), await ri({
10946
10981
  runtime: this.clientRuntime,
10947
10982
  authority: this.directoryAuthority,
10948
10983
  sessionId: e,
@@ -10962,7 +10997,7 @@ class Kt {
10962
10997
  sessionId: e,
10963
10998
  requestId: n,
10964
10999
  patch: { title: s }
10965
- }), await ii({
11000
+ }), await ri({
10966
11001
  runtime: this.clientRuntime,
10967
11002
  authority: this.directoryAuthority,
10968
11003
  sessionId: e,
@@ -10999,7 +11034,7 @@ class Kt {
10999
11034
  }
11000
11035
  getInteractions() {
11001
11036
  const e = this.clientRuntime.engine.getState().slices;
11002
- return uo(e, e.conversation, e.directory, this.modelClientScopeId);
11037
+ return ho(e, e.conversation, e.directory, this.modelClientScopeId);
11003
11038
  }
11004
11039
  subscribeInteractions(e) {
11005
11040
  return this.interactionListeners.add(e), e(this.getInteractions()), () => this.interactionListeners.delete(e);
@@ -11008,7 +11043,7 @@ class Kt {
11008
11043
  const r = this.clientRuntime.engine.getState().slices.account.authority;
11009
11044
  if (!r) throw new Error("Product Agent is not authenticated.");
11010
11045
  const a = this.getInteractions().find((d) => d.id === e), o = i.expectedSourceVersion === void 0 ? a?.sourceVersion ?? null : i.expectedSourceVersion, c = crypto.randomUUID();
11011
- await lo(this.clientRuntime, {
11046
+ await uo(this.clientRuntime, {
11012
11047
  clientScopeId: this.modelClientScopeId,
11013
11048
  interactionId: e,
11014
11049
  action: s,
@@ -11042,7 +11077,7 @@ class Kt {
11042
11077
  for (const e of this.accountListeners) e(this.getAccount());
11043
11078
  }
11044
11079
  getAccount() {
11045
- return po(this.clientRuntime.engine.getState().slices.account, this.state.sessionId);
11080
+ return fo(this.clientRuntime.engine.getState().slices.account, this.state.sessionId);
11046
11081
  }
11047
11082
  subscribeAccount(e) {
11048
11083
  return this.accountListeners.add(e), e(this.getAccount()), () => this.accountListeners.delete(e);
@@ -11072,7 +11107,7 @@ class Kt {
11072
11107
  }
11073
11108
  }
11074
11109
  installFeaturePorts() {
11075
- const e = ro(() => Date.now());
11110
+ const e = oo(() => Date.now());
11076
11111
  let s = !1, n = !1;
11077
11112
  const i = () => {
11078
11113
  const l = this.options.runtimeAdapters?.featurePermissions, u = this.clientRuntime.engine.getState().slices.account.authority;
@@ -11110,7 +11145,7 @@ class Kt {
11110
11145
  }).finally(() => {
11111
11146
  s = !1, n && (n = !1, i());
11112
11147
  });
11113
- }, r = io({
11148
+ }, r = ro({
11114
11149
  http: this.directoryHttp,
11115
11150
  now: () => Date.now(),
11116
11151
  preferenceStorage: {
@@ -11125,7 +11160,7 @@ class Kt {
11125
11160
  readAccount: async (l) => {
11126
11161
  const u = this.clientRuntime.engine.getState().slices.account, h = this.options.accountLoader ? await this.options.accountLoader() : u.refusal ? null : this.options.initialAccount;
11127
11162
  if (!h) throw new Error("Account information is unavailable.");
11128
- return i(), ho(h, {
11163
+ return i(), po(h, {
11129
11164
  id: l.userId,
11130
11165
  email: this.state.user?.email ?? null,
11131
11166
  name: this.state.user?.name ?? null,
@@ -11159,7 +11194,7 @@ class Kt {
11159
11194
  "stage7.platform": async (l) => {
11160
11195
  const u = l.operation, h = u.kind === "connect" ? u.source : null;
11161
11196
  if (u.kind === "saveHint")
11162
- Fr(localStorage, u.interactionId);
11197
+ $r(localStorage, u.interactionId);
11163
11198
  else if (u.kind === "connect" && h?.payload.kind === "integration_auth") {
11164
11199
  const p = h.payload;
11165
11200
  if (!this.options.runtimeAdapters?.integrationAuthHandler) throw new Error("Connection handler unavailable.");
@@ -11190,7 +11225,7 @@ class Kt {
11190
11225
  const l = this.clientRuntime.engine.getState().slices, h = l.directory.selections[l.directory.clients[this.modelClientScopeId]]?.sessionId, p = JSON.stringify([h, h ? l.conversation.sessions[h]?.execution : null]);
11191
11226
  p !== a && (a = p, i());
11192
11227
  }), c = this.options.runtimeAdapters?.featurePermissions?.subscribe?.(i);
11193
- this.clientRuntime.onDispose(() => c?.()), oo(this.clientRuntime, () => Date.now());
11228
+ this.clientRuntime.onDispose(() => c?.()), ao(this.clientRuntime, () => Date.now());
11194
11229
  const d = () => {
11195
11230
  const l = this.clientRuntime.engine.getState().slices.account.authority;
11196
11231
  l?.profile === "main_web_chat" && this.options.entrySurface === "main_web_chat" && this.clientRuntime.engine.dispatch({ type: "stage7.device_hints", authority: l, now: Date.now(), hints: Ps(localStorage) });
@@ -11454,7 +11489,7 @@ class Kt {
11454
11489
  }
11455
11490
  requestTransientStarterPrompts() {
11456
11491
  const e = ne(Fd());
11457
- return co(this.clientRuntime, {
11492
+ return lo(this.clientRuntime, {
11458
11493
  kind: "generatePrompts",
11459
11494
  page: { clientScopeId: this.modelClientScopeId, origin: location.origin, pageUrl: e.pageUrl },
11460
11495
  htmlContent: e.htmlContent,
@@ -11500,10 +11535,10 @@ class Kt {
11500
11535
  this.resetConversationSelection({ notifyTransport: !1 }), this.queuedClientEvents = [], Re(this.options.clientId, this.queuedClientEvents);
11501
11536
  }
11502
11537
  applyAuthenticatedDirectoryIdentity(e) {
11503
- const s = Ri(e);
11538
+ const s = Ai(e);
11504
11539
  if (!s) return !1;
11505
11540
  const n = vt(e, "runtimeCommunityId") ?? this.directoryHttp.auth.community_id, i = `${this.options.clientId}:${s.id}:${n ?? this.options.productVariant}`, r = this.directoryAuthority.authorityId !== i, a = this.authenticatedUserId === null, o = a ? Object.values(this.clientRuntime.engine.getState().slices.conversation.operations).filter((l) => ["waiting", "running", "uncertain"].includes(l.phase) && (l.command.type === "run.stop" || l.command.type === "session.reset")).map((l) => l.command) : [], c = a && this.directoryAuthority.authorityId === `${this.options.clientId}:${this.options.runtimeCommunityId ?? this.options.productVariant}` ? this.state.sessionId : null;
11506
- if (this.authenticatedUserId = s.id, this.directoryHttp.auth.community_id = n, No(this.options.clientId, i), r) {
11541
+ if (this.authenticatedUserId = s.id, this.directoryHttp.auth.community_id = n, jo(this.options.clientId, i), r) {
11507
11542
  const l = this.directoryAuthority;
11508
11543
  this.directoryObservation.dispose(), this.conversationAdapterGeneration++, this.conversationObservation?.dispose(), this.directoryAuthority = { authorityId: i, generation: l.generation + 1 }, this.clientRuntime.engine.dispatch({ ...this.directoryAuthority, type: "directory.authority_replace", expectedGeneration: l.generation }), this.createDirectoryAdapters();
11509
11544
  const u = this.getModel();
@@ -11520,7 +11555,7 @@ class Kt {
11520
11555
  personalChannel: !!this.options.runtimeAdapters?.personalChannelConnectionHandler
11521
11556
  }
11522
11557
  };
11523
- if (ao(this.clientRuntime, d, Date.now()).then(async () => {
11558
+ if (co(this.clientRuntime, d, Date.now()).then(async () => {
11524
11559
  this.options.entrySurface === "main_web_chat" && d.profile === "main_web_chat" && await this.clientRuntime.engine.dispatch({ type: "stage7.device_hints", authority: d, now: Date.now(), hints: Ps(localStorage) }), await this.refreshStarterPromptsForCurrentUrl();
11525
11560
  }).catch(() => {
11526
11561
  }), r || a) {
@@ -11583,7 +11618,7 @@ class Kt {
11583
11618
  }
11584
11619
  if (e.type === "auth.ok") {
11585
11620
  this.clearSocketAuthTimer(), this.clearEmbeddedRecoveryBudget(), this.rejectedDiagnosticsToken = null, this.clientDiagnosticsRetryTimer !== null && window.clearTimeout(this.clientDiagnosticsRetryTimer), this.clientDiagnosticsRetryTimer = null, this.options.productVariant === "customer_embedded" && (this.pendingTransportDiagnostics.length > 0 || this.state.lastErrorCode === "connection_failed") && this.reportTransportDiagnostic("ready_applied", { recoveryOutcome: "recovered", stage: "bootstrap" }), this.reconnectAttempts = 0, this.transportDiagnosticEpisodes.clear(), this.flushClientDiagnostics();
11586
- const s = Ri(e.user);
11621
+ const s = Ai(e.user);
11587
11622
  this.applyAuthenticatedDirectoryIdentity(e.user), this.authenticatedSocket = this.socket, this.directoryObservation.reconnect().catch(() => {
11588
11623
  }), this.conversationObservation?.wake(), this.flushPendingWidgetLifecycleEvents(), this.flushQueuedClientEvents(), this.startHeartbeat(), this.runtimeHelperJavascript = Zd(e.runtimeHelpers)?.javascript ?? null;
11589
11624
  const n = {
@@ -11698,7 +11733,7 @@ class Kt {
11698
11733
  authority: n,
11699
11734
  now: Date.now(),
11700
11735
  sessionId: s,
11701
- enabled: Vo(e.metadata)
11736
+ enabled: Ko(e.metadata)
11702
11737
  });
11703
11738
  }
11704
11739
  async executeToolCall(e) {
@@ -11761,7 +11796,7 @@ class Kt {
11761
11796
  startedAtOrigin: location.origin
11762
11797
  }), this.installSessionBrowserApis();
11763
11798
  let l = null, u;
11764
- l = await this.executeRuntimeHelper(), u = await _i(
11799
+ l = await this.executeRuntimeHelper(), u = await Si(
11765
11800
  a,
11766
11801
  Ud(e.runtimeContext, this.options.backendUrl)
11767
11802
  ).catch((h) => ({
@@ -11777,13 +11812,13 @@ class Kt {
11777
11812
  summary: a.summary,
11778
11813
  rawInput: ne(a),
11779
11814
  rawOutput: ne(el(u, l))
11780
- }), Ei(this.options.clientId, this.activeBrowserToolCalls.values()));
11815
+ }), qi(this.options.clientId, this.activeBrowserToolCalls.values()));
11781
11816
  }
11782
11817
  startPageLifecycleRecovery() {
11783
11818
  if (this.pageLifecycleCleanup)
11784
11819
  return;
11785
11820
  const e = () => {
11786
- Ar(this.options.clientId, this.activeBrowserToolCalls.values());
11821
+ Er(this.options.clientId, this.activeBrowserToolCalls.values());
11787
11822
  };
11788
11823
  window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
11789
11824
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
@@ -11798,7 +11833,7 @@ class Kt {
11798
11833
  async executeRuntimeHelper() {
11799
11834
  if (!this.runtimeHelperJavascript?.trim())
11800
11835
  return null;
11801
- const e = await _i({
11836
+ const e = await Si({
11802
11837
  javascript: this.runtimeHelperJavascript
11803
11838
  });
11804
11839
  return e.ok === !1 ? tl(e) : null;
@@ -11957,7 +11992,7 @@ class Kt {
11957
11992
  const d = c instanceof E ? c : new E(c instanceof ue ? c.message : "Your session could not be refreshed. Try again.", this.options.productVariant === "customer_embedded" ? "connection_failed" : "unauthorized", !1);
11958
11993
  throw this.stopAuthentication(d), d;
11959
11994
  }
11960
- throw this.options.productVariant === "customer_embedded" && this.setState({ status: "reconnecting", lastError: bi, lastErrorCode: "connection_failed" }), this.scheduleReconnect(), c;
11995
+ throw this.options.productVariant === "customer_embedded" && this.setState({ status: "reconnecting", lastError: Ii, lastErrorCode: "connection_failed" }), this.scheduleReconnect(), c;
11961
11996
  }).finally(() => {
11962
11997
  this.credentialRecovery === o && (this.credentialRecovery = null), this.flushClientDiagnostics();
11963
11998
  });
@@ -12035,14 +12070,14 @@ function Sd() {
12035
12070
  throw b;
12036
12071
  }
12037
12072
  try {
12038
- const b = p instanceof Request ? p : null, k = Ol(p, b), R = Or(m?.headers ?? b?.headers);
12073
+ const b = p instanceof Request ? p : null, k = Ol(p, b), R = xr(m?.headers ?? b?.headers);
12039
12074
  if (!Pe(k, R, m?.body)) {
12040
12075
  const v = {
12041
12076
  requestId: Os("fetch"),
12042
12077
  url: ge(k, As),
12043
12078
  method: (m?.method ?? b?.method ?? "GET").toUpperCase(),
12044
12079
  requestHeaders: R,
12045
- requestBody: Ti(m?.body),
12080
+ requestBody: Ci(m?.body),
12046
12081
  resourceType: "fetch",
12047
12082
  startedAt: new Date(f).toISOString()
12048
12083
  };
@@ -12085,7 +12120,7 @@ function Sd() {
12085
12120
  }, d = function(p) {
12086
12121
  try {
12087
12122
  const m = Ts.get(this);
12088
- m && (m.excluded = m.excluded || Pe(m.url, m.requestHeaders, p), m.requestBody = Ti(p), m.excluded || this.addEventListener(
12123
+ m && (m.excluded = m.excluded || Pe(m.url, m.requestHeaders, p), m.requestBody = Ci(p), m.excluded || this.addEventListener(
12089
12124
  "loadend",
12090
12125
  () => {
12091
12126
  queueMicrotask(() => {
@@ -12192,7 +12227,7 @@ function V(t, e, s) {
12192
12227
  }, r = n.__plunoProductAgentDiagnostics__ ?? [];
12193
12228
  r.push(i), r.length > 120 && r.splice(0, r.length - 120), n.__plunoProductAgentDiagnostics__ = r, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...r], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: i }));
12194
12229
  }
12195
- function wi(t) {
12230
+ function _i(t) {
12196
12231
  const e = typeof t == "function" ? t() : t;
12197
12232
  return e && Object.keys(e).length > 0 ? e : void 0;
12198
12233
  }
@@ -12208,10 +12243,10 @@ function Ad() {
12208
12243
  };
12209
12244
  }
12210
12245
  function Ed() {
12211
- return gr(globalThis, "getPageSnapshot", async () => An());
12246
+ return mr(globalThis, "getPageSnapshot", async () => An());
12212
12247
  }
12213
12248
  function qd() {
12214
- return gr(globalThis, "pageImages", {
12249
+ return mr(globalThis, "pageImages", {
12215
12250
  inspectImage: async (e, s) => await Td(e, s)
12216
12251
  });
12217
12252
  }
@@ -12220,7 +12255,7 @@ async function Td(t, e = {}) {
12220
12255
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
12221
12256
  type: "pluno.pageImages.inspectImage",
12222
12257
  imageAttached: !1,
12223
- imageAttachmentError: wr
12258
+ imageAttachmentError: _r
12224
12259
  } : {
12225
12260
  type: "pluno.pageImages.inspectImage",
12226
12261
  imageAttached: !0,
@@ -12235,7 +12270,7 @@ async function Td(t, e = {}) {
12235
12270
  };
12236
12271
  }
12237
12272
  async function Cd(t) {
12238
- return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error: wr } : {
12273
+ return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error: _r } : {
12239
12274
  ok: !0,
12240
12275
  mimeType: t.type,
12241
12276
  sizeBytes: t.size,
@@ -12288,7 +12323,7 @@ function Dd(t) {
12288
12323
  }, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(t);
12289
12324
  });
12290
12325
  }
12291
- async function _i(t, e) {
12326
+ async function Si(t, e) {
12292
12327
  const s = Object.getPrototypeOf(async function() {
12293
12328
  }).constructor, n = t.timeoutMs ?? kd, i = Date.now(), r = [];
12294
12329
  let a;
@@ -12453,7 +12488,7 @@ function An() {
12453
12488
  };
12454
12489
  s("Selected text", window.getSelection()?.toString() ?? "");
12455
12490
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", i = Array.from(document.querySelectorAll(n)).filter(
12456
- (f) => _r(f) && !f.parentElement?.closest(n)
12491
+ (f) => Sr(f) && !f.parentElement?.closest(n)
12457
12492
  );
12458
12493
  for (const f of i.slice(0, 3))
12459
12494
  s("Active overlay", Cs(st(f), e));
@@ -12486,12 +12521,12 @@ function Cs(t, e) {
12486
12521
  s = s.replace(n, "");
12487
12522
  return Le(s);
12488
12523
  }
12489
- function _r(t) {
12524
+ function Sr(t) {
12490
12525
  const e = window.getComputedStyle(t);
12491
12526
  return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
12492
12527
  }
12493
12528
  function Hd() {
12494
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(_r).sort((t, e) => st(e).length - st(t).length)[0] ?? null;
12529
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Sr).sort((t, e) => st(e).length - st(t).length)[0] ?? null;
12495
12530
  }
12496
12531
  function Vd(t, e) {
12497
12532
  const s = /* @__PURE__ */ new Set([
@@ -12584,11 +12619,11 @@ function Vd(t, e) {
12584
12619
  return `${R.tagName.toLowerCase()}|${m(R)}|${g}`;
12585
12620
  }, y = (R, g, v) => {
12586
12621
  const I = (w, _) => {
12587
- const A = w.tagName.toLowerCase(), T = window.getComputedStyle(w), q = l.has(w);
12588
- if (p >= 1e3 && !q || v.has(w) || r.has(A) || w.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || T.display === "none" || T.visibility === "hidden")
12622
+ const A = w.tagName.toLowerCase(), C = window.getComputedStyle(w), q = l.has(w);
12623
+ if (p >= 1e3 && !q || v.has(w) || r.has(A) || w.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || C.display === "none" || C.visibility === "hidden")
12589
12624
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
12590
12625
  p += 1;
12591
- const C = m(w), O = kr(w), S = o.has(C) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(A) || A === "a" && w.hasAttribute("href"), x = Array.from(w.children).filter((D) => D instanceof HTMLElement), U = /* @__PURE__ */ new Map();
12626
+ const T = m(w), O = Rr(w), S = o.has(T) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(A) || A === "a" && w.hasAttribute("href"), x = Array.from(w.children).filter((D) => D instanceof HTMLElement), U = /* @__PURE__ */ new Map();
12592
12627
  for (const D of x) {
12593
12628
  const $ = f(D);
12594
12629
  U.set($, (U.get($) ?? 0) + 1);
@@ -12614,10 +12649,10 @@ function Vd(t, e) {
12614
12649
  D instanceof HTMLElement && Jt.push(I(D, _ + 1));
12615
12650
  const ct = [...On, ...Jt], Qt = O.length > 0 || S || ct.some((D) => D.hasUsefulContent), xn = Le(
12616
12651
  [O, ...ct.map((D) => D.textPreview)].filter(Boolean).join(" ")
12617
- ).slice(0, 180), Lr = w.hasAttribute("contenteditable") && (O.length > 0 || !w.querySelector("[contenteditable]")), Mn = d.some((D) => w.hasAttribute(D)) || !!C || Lr, Xt = (w.getClientRects().length > 0 || T.display === "contents") && (s.has(A) || Mn || q) && (Qt || q) && (!i.has(A) || Qt || Mn || q), Yt = Xt ? 1 : 0, ze = [];
12652
+ ).slice(0, 180), Fr = w.hasAttribute("contenteditable") && (O.length > 0 || !w.querySelector("[contenteditable]")), Mn = d.some((D) => w.hasAttribute(D)) || !!T || Fr, Xt = (w.getClientRects().length > 0 || C.display === "contents") && (s.has(A) || Mn || q) && (Qt || q) && (!i.has(A) || Qt || Mn || q), Yt = Xt ? 1 : 0, ze = [];
12618
12653
  if (Xt) {
12619
12654
  const D = ct.some((ve) => ve.containsTextElement), $ = n.has(A) && !D ? xn : O;
12620
- ze.push(Sr(w, c, a, $.slice(0, 180)));
12655
+ ze.push(kr(w, c, a, $.slice(0, 180)));
12621
12656
  }
12622
12657
  for (const D of Gt)
12623
12658
  ze.push(...yt(D, Yt));
@@ -12654,7 +12689,7 @@ ${JSON.stringify(k)}`), u.length > 0 && b.push(Wd(u, s, c, a));
12654
12689
 
12655
12690
  `);
12656
12691
  }
12657
- function Sr(t, e, s, n) {
12692
+ function kr(t, e, s, n) {
12658
12693
  const i = t.tagName.toLowerCase();
12659
12694
  let r = i;
12660
12695
  const a = t.getAttribute("id");
@@ -12692,7 +12727,7 @@ function Kd() {
12692
12727
  n = n.shadowRoot.activeElement;
12693
12728
  n !== document.body && n !== document.documentElement && s(n, "focused");
12694
12729
  const i = window.getSelection();
12695
- i && !i.isCollapsed && (s(Si(i.anchorNode), "selected text"), s(Si(i.focusNode), "selected text"));
12730
+ i && !i.isCollapsed && (s(ki(i.anchorNode), "selected text"), s(ki(i.focusNode), "selected text"));
12696
12731
  const r = [
12697
12732
  ["[aria-selected='true']", "selected"],
12698
12733
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -12725,18 +12760,18 @@ function Wd(t, e, s, n) {
12725
12760
  const u = o.getRootNode();
12726
12761
  o = o.parentElement ?? (u instanceof ShadowRoot && u.host instanceof HTMLElement ? u.host : null);
12727
12762
  }
12728
- const c = a.length > 6 ? [a[0], ...a.slice(-5)] : a, d = c.map((l, u) => Sr(
12763
+ const c = a.length > 6 ? [a[0], ...a.slice(-5)] : a, d = c.map((l, u) => kr(
12729
12764
  l,
12730
12765
  s,
12731
12766
  n,
12732
- u === c.length - 1 ? kr(l).slice(0, 180) : ""
12767
+ u === c.length - 1 ? Rr(l).slice(0, 180) : ""
12733
12768
  ));
12734
12769
  a.length > c.length && d.splice(1, 0, "…"), i.push(`${r.labels.join(", ")}: ${d.join(" > ")}`);
12735
12770
  }
12736
12771
  return i.join(`
12737
12772
  `);
12738
12773
  }
12739
- function Si(t) {
12774
+ function ki(t) {
12740
12775
  return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
12741
12776
  }
12742
12777
  function yt(t, e) {
@@ -12745,7 +12780,7 @@ function yt(t, e) {
12745
12780
  const s = " ".repeat(e);
12746
12781
  return t.map((n) => `${s}${n}`);
12747
12782
  }
12748
- function kr(t) {
12783
+ function Rr(t) {
12749
12784
  return Le(
12750
12785
  Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
12751
12786
  );
@@ -12754,7 +12789,7 @@ function Gd(t) {
12754
12789
  return t.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(t) && !/[a-f0-9]{12,}/i.test(t) && !/:r[0-9a-z]+:/i.test(t);
12755
12790
  }
12756
12791
  function Jd() {
12757
- const t = Array.from(document.querySelectorAll(yi)), e = t.find(
12792
+ const t = Array.from(document.querySelectorAll(vi)), e = t.find(
12758
12793
  (r) => typeof r[sd] == "string"
12759
12794
  );
12760
12795
  if (!(e ?? t[0]))
@@ -12766,7 +12801,7 @@ function Jd() {
12766
12801
  selectors: [
12767
12802
  {
12768
12803
  name: "widget_host",
12769
- selector: yi,
12804
+ selector: vi,
12770
12805
  description: "Finds Pluno's shadow-host element in the host page DOM."
12771
12806
  },
12772
12807
  {
@@ -12801,7 +12836,7 @@ function Qd(t) {
12801
12836
  return s === void 0 || typeof s == "number" && Number.isInteger(s) && s >= 0;
12802
12837
  });
12803
12838
  }
12804
- function ki(t) {
12839
+ function Ri(t) {
12805
12840
  try {
12806
12841
  const e = JSON.parse(t);
12807
12842
  return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
@@ -12855,7 +12890,7 @@ function sl() {
12855
12890
  function z() {
12856
12891
  return crypto.randomUUID();
12857
12892
  }
12858
- function Ri(t) {
12893
+ function Ai(t) {
12859
12894
  if (!t || typeof t != "object")
12860
12895
  return null;
12861
12896
  const e = t, s = typeof e.id == "string" ? e.id : null;
@@ -12868,10 +12903,10 @@ function Ri(t) {
12868
12903
  }
12869
12904
  function hu(t, e) {
12870
12905
  return Array.isArray(t) ? dl(
12871
- t.map((s) => Rr(s, e)).filter((s) => s !== null)
12906
+ t.map((s) => Ar(s, e)).filter((s) => s !== null)
12872
12907
  ) : [];
12873
12908
  }
12874
- function Rr(t, e) {
12909
+ function Ar(t, e) {
12875
12910
  if (!t || typeof t != "object")
12876
12911
  return null;
12877
12912
  const s = t, n = s.data;
@@ -12886,7 +12921,7 @@ function Rr(t, e) {
12886
12921
  role: "assistant",
12887
12922
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
12888
12923
  content: De(
12889
- Ai(i.content),
12924
+ Ei(i.content),
12890
12925
  e
12891
12926
  ),
12892
12927
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
@@ -12903,7 +12938,7 @@ function Rr(t, e) {
12903
12938
  role: r,
12904
12939
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
12905
12940
  content: De(
12906
- Ai(i.content),
12941
+ Ei(i.content),
12907
12942
  e
12908
12943
  ),
12909
12944
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
@@ -12911,7 +12946,7 @@ function Rr(t, e) {
12911
12946
  ...se(i) !== null ? { causalSequence: se(i) } : {},
12912
12947
  respondsToUserMessageId: be(i) ?? void 0,
12913
12948
  ...W(i) ? { runId: W(i) } : {},
12914
- attachments: Er(i.attachments, e),
12949
+ attachments: qr(i.attachments, e),
12915
12950
  ...i.steered === !0 ? { steered: !0 } : {}
12916
12951
  };
12917
12952
  return r === "assistant" && typeof i.id == "string" && Object.defineProperty(a, "assistantDraftItemId", {
@@ -12937,7 +12972,7 @@ function Rr(t, e) {
12937
12972
  respondsToUserMessageId: be(i) ?? void 0,
12938
12973
  ...W(i) ? { runId: W(i) } : {},
12939
12974
  dataType: "function_call_output",
12940
- toolName: mr,
12975
+ toolName: yr,
12941
12976
  callId: Xe(i) ?? void 0,
12942
12977
  sharePromptAllowed: r
12943
12978
  };
@@ -12952,7 +12987,7 @@ function Rr(t, e) {
12952
12987
  respondsToUserMessageId: be(i) ?? void 0,
12953
12988
  ...W(i) ? { runId: W(i) } : {},
12954
12989
  dataType: "scheduled_check_in",
12955
- toolName: vr,
12990
+ toolName: br,
12956
12991
  callId: Xe(i) ?? void 0,
12957
12992
  scheduledCheckInId: a.id ?? void 0,
12958
12993
  scheduledCheckInAt: a.dueAt
@@ -13096,7 +13131,7 @@ function se(t) {
13096
13131
  function K(t) {
13097
13132
  return typeof t.displaySequence == "number" && Number.isSafeInteger(t.displaySequence) ? t.displaySequence : null;
13098
13133
  }
13099
- function Ai(t) {
13134
+ function Ei(t) {
13100
13135
  return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
13101
13136
  if (!e || typeof e != "object")
13102
13137
  return "";
@@ -13223,7 +13258,7 @@ function Re(t, e) {
13223
13258
  return;
13224
13259
  }
13225
13260
  }
13226
- function Ar(t, e) {
13261
+ function Er(t, e) {
13227
13262
  try {
13228
13263
  const s = `${Vt}${t}`, n = location.href, i = location.origin, r = Array.from(e, (a) => ({
13229
13264
  ...a,
@@ -13239,14 +13274,14 @@ function Ar(t, e) {
13239
13274
  } catch {
13240
13275
  }
13241
13276
  }
13242
- function Ei(t, e) {
13277
+ function qi(t, e) {
13243
13278
  try {
13244
13279
  if (window.sessionStorage.getItem(`${Vt}${t}`) === null)
13245
13280
  return;
13246
13281
  } catch {
13247
13282
  return;
13248
13283
  }
13249
- Ar(t, e);
13284
+ Er(t, e);
13250
13285
  }
13251
13286
  function Il(t) {
13252
13287
  try {
@@ -13307,15 +13342,15 @@ function qn(t) {
13307
13342
  if (!t || typeof t != "object")
13308
13343
  return !1;
13309
13344
  const e = t;
13310
- return e.type === "chat.user_message" ? typeof e.content == "string" && qi(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? qi(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
13345
+ return e.type === "chat.user_message" ? typeof e.content == "string" && Ti(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Ti(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
13311
13346
  }
13312
- function qi(t) {
13347
+ function Ti(t) {
13313
13348
  if (!t || typeof t != "object")
13314
13349
  return !1;
13315
13350
  const e = t;
13316
13351
  return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
13317
13352
  }
13318
- function Er(t, e) {
13353
+ function qr(t, e) {
13319
13354
  if (!Array.isArray(t))
13320
13355
  return;
13321
13356
  const s = t.filter((i) => {
@@ -13323,30 +13358,30 @@ function Er(t, e) {
13323
13358
  return !1;
13324
13359
  const r = i;
13325
13360
  return typeof r.name == "string" && typeof r.mimeType == "string" && typeof r.sizeBytes == "number";
13326
- }), n = e ? s.map((i) => qr(i, e)) : s;
13361
+ }), n = e ? s.map((i) => Tr(i, e)) : s;
13327
13362
  return n.length > 0 ? n : void 0;
13328
13363
  }
13329
- function qr(t, e) {
13364
+ function Tr(t, e) {
13330
13365
  return t.fileUrl?.startsWith("/") ? {
13331
13366
  ...t,
13332
13367
  fileUrl: new URL(t.fileUrl, e).toString()
13333
13368
  } : t;
13334
13369
  }
13335
- function Tr(t) {
13370
+ function Cr(t) {
13336
13371
  return t.type || El(t.name) || "application/octet-stream";
13337
13372
  }
13338
13373
  function Rl(t) {
13339
- Cr({
13374
+ Or({
13340
13375
  name: t.name,
13341
- mimeType: Tr(t),
13376
+ mimeType: Cr(t),
13342
13377
  sizeBytes: t.size
13343
13378
  });
13344
13379
  }
13345
- function Cr(t) {
13380
+ function Or(t) {
13346
13381
  const e = Al(t.name), s = t.mimeType.trim().toLowerCase();
13347
13382
  if (!gd.has(`${e}:${s}`))
13348
13383
  throw new Error("This attachment type is not supported by the embedded model provider");
13349
- if (t.sizeBytes <= 0 || t.sizeBytes >= Ir)
13384
+ if (t.sizeBytes <= 0 || t.sizeBytes >= wr)
13350
13385
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
13351
13386
  }
13352
13387
  function Al(t) {
@@ -13375,7 +13410,7 @@ function ql(t) {
13375
13410
  scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
13376
13411
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
13377
13412
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
13378
- attachments: Er(e.attachments)?.map(Tl),
13413
+ attachments: qr(e.attachments)?.map(Tl),
13379
13414
  loading: typeof e.loading == "boolean" ? e.loading : void 0
13380
13415
  };
13381
13416
  }
@@ -13401,7 +13436,7 @@ function Cl(t) {
13401
13436
  const e = t?.timeoutMs;
13402
13437
  return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= Rd);
13403
13438
  }
13404
- function Or(t) {
13439
+ function xr(t) {
13405
13440
  const e = {};
13406
13441
  try {
13407
13442
  new Headers(t).forEach((s, n) => {
@@ -13413,13 +13448,13 @@ function Or(t) {
13413
13448
  return e;
13414
13449
  }
13415
13450
  function Tn(t, e) {
13416
- return jr(t) ? Wt : ge(Bt(e), md);
13451
+ return Br(t) ? Wt : ge(Bt(e), md);
13417
13452
  }
13418
13453
  function Ol(t, e) {
13419
13454
  return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
13420
13455
  }
13421
13456
  async function xl(t, e, s, n) {
13422
- const i = Or(t.headers);
13457
+ const i = xr(t.headers);
13423
13458
  n({
13424
13459
  ...e,
13425
13460
  responseStatus: t.status,
@@ -13429,7 +13464,7 @@ async function xl(t, e, s, n) {
13429
13464
  });
13430
13465
  }
13431
13466
  async function Ml(t) {
13432
- if (!xr(t.headers))
13467
+ if (!Mr(t.headers))
13433
13468
  return;
13434
13469
  let e = null, s = null;
13435
13470
  try {
@@ -13461,25 +13496,25 @@ async function Ml(t) {
13461
13496
  }
13462
13497
  }
13463
13498
  function Pl(t, e) {
13464
- if (xr(new Headers(e)))
13499
+ if (Mr(new Headers(e)))
13465
13500
  try {
13466
13501
  return t.responseType === "" || t.responseType === "text" ? ge(t.responseText ?? "") : void 0;
13467
13502
  } catch {
13468
13503
  return;
13469
13504
  }
13470
13505
  }
13471
- function Ti(t) {
13506
+ function Ci(t) {
13472
13507
  if (typeof t == "string")
13473
13508
  return ge(t);
13474
13509
  }
13475
13510
  function Dl(t) {
13476
13511
  return ne({
13477
13512
  ...t,
13478
- requestBody: Ci(t.requestBody),
13479
- responseBody: Ci(t.responseBody)
13513
+ requestBody: Oi(t.requestBody),
13514
+ responseBody: Oi(t.responseBody)
13480
13515
  });
13481
13516
  }
13482
- function Ci(t) {
13517
+ function Oi(t) {
13483
13518
  if (typeof t != "string")
13484
13519
  return t;
13485
13520
  const e = t.trim();
@@ -13491,7 +13526,7 @@ function Ci(t) {
13491
13526
  return Bt(t);
13492
13527
  }
13493
13528
  }
13494
- function xr(t) {
13529
+ function Mr(t) {
13495
13530
  if (!t)
13496
13531
  return !1;
13497
13532
  const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
@@ -13545,7 +13580,7 @@ function ge(t, e = kn) {
13545
13580
  function Os(t) {
13546
13581
  return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
13547
13582
  }
13548
- class Mr extends Error {
13583
+ class Pr extends Error {
13549
13584
  constructor(e, s) {
13550
13585
  super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError", this.code = String(s);
13551
13586
  }
@@ -13554,11 +13589,11 @@ class Mr extends Error {
13554
13589
  }
13555
13590
  async function Bl(t, e) {
13556
13591
  let s = null;
13557
- for (let n = 0; n < Ii; n += 1)
13592
+ for (let n = 0; n < wi; n += 1)
13558
13593
  try {
13559
13594
  return await t();
13560
13595
  } catch (i) {
13561
- if (s = i, n >= Ii - 1 || !Fl(i))
13596
+ if (s = i, n >= wi - 1 || !Fl(i))
13562
13597
  throw i;
13563
13598
  await Ll(n);
13564
13599
  }
@@ -13570,7 +13605,7 @@ function Ll(t) {
13570
13605
  });
13571
13606
  }
13572
13607
  function Fl(t) {
13573
- return t instanceof Mr ? $l(t.status) : t instanceof TypeError;
13608
+ return t instanceof Pr ? $l(t.status) : t instanceof TypeError;
13574
13609
  }
13575
13610
  function $l(t) {
13576
13611
  return t === 408 || t === 409 || t === 429 || t >= 500;
@@ -13578,7 +13613,7 @@ function $l(t) {
13578
13613
  function zl(t) {
13579
13614
  return t === 401 || t === 403;
13580
13615
  }
13581
- const Wt = "[REDACTED_SECRET]", me = "[REDACTED_TOKEN]", Hl = "[REDACTED_SIGNED_URL]", Vl = 20, Kl = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Pr = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Dr = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ur = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Nr = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, Wl = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Gl = /\bhttps?:\/\/[^\s"'<>]+/gi, Jl = /[),.;\]]+$/;
13616
+ const Wt = "[REDACTED_SECRET]", me = "[REDACTED_TOKEN]", Hl = "[REDACTED_SIGNED_URL]", Vl = 20, Kl = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Dr = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Ur = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Nr = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, jr = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, Wl = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Gl = /\bhttps?:\/\/[^\s"'<>]+/gi, Jl = /[),.;\]]+$/;
13582
13617
  function ne(t) {
13583
13618
  return jt(t, 0, /* @__PURE__ */ new WeakSet());
13584
13619
  }
@@ -13595,17 +13630,17 @@ function jt(t, e, s) {
13595
13630
  return t.map((i) => jt(i, e + 1, s));
13596
13631
  const n = {};
13597
13632
  for (const [i, r] of Object.entries(t))
13598
- i === "pageContent" ? n[i] = r : jr(i) ? n[i] = Wt : n[i] = i.toLowerCase() === "url" ? Ql(r) : jt(r, e + 1, s);
13633
+ i === "pageContent" ? n[i] = r : Br(i) ? n[i] = Wt : n[i] = i.toLowerCase() === "url" ? Ql(r) : jt(r, e + 1, s);
13599
13634
  return n;
13600
13635
  }
13601
- function jr(t) {
13636
+ function Br(t) {
13602
13637
  const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
13603
13638
  return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
13604
13639
  }
13605
13640
  function Ql(t) {
13606
- return typeof t == "string" ? Br(t) : jt(t, 0, /* @__PURE__ */ new WeakSet());
13641
+ return typeof t == "string" ? Lr(t) : jt(t, 0, /* @__PURE__ */ new WeakSet());
13607
13642
  }
13608
- function Br(t) {
13643
+ function Lr(t) {
13609
13644
  try {
13610
13645
  const e = new URL(t, location.href);
13611
13646
  for (const s of Array.from(e.searchParams.keys()))
@@ -13616,14 +13651,14 @@ function Br(t) {
13616
13651
  }
13617
13652
  }
13618
13653
  function Bt(t) {
13619
- return t.replace(Wl, Hl).replace(Gl, Yl).replace(Pr, `Bearer ${me}`).replace(Dr, `Basic ${me}`).replace(Ur, me).replace(Nr, (e, s) => `${s}: ${Wt}`);
13654
+ return t.replace(Wl, Hl).replace(Gl, Yl).replace(Dr, `Bearer ${me}`).replace(Ur, `Basic ${me}`).replace(Nr, me).replace(jr, (e, s) => `${s}: ${Wt}`);
13620
13655
  }
13621
13656
  function Xl(t) {
13622
- return t.replace(Pr, `Bearer ${me}`).replace(Dr, `Basic ${me}`).replace(Ur, me).replace(Nr, (e, s) => `${s}: ${Wt}`);
13657
+ return t.replace(Dr, `Bearer ${me}`).replace(Ur, `Basic ${me}`).replace(Nr, me).replace(jr, (e, s) => `${s}: ${Wt}`);
13623
13658
  }
13624
13659
  function Yl(t) {
13625
13660
  const e = t.match(Jl)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
13626
- return `${Br(s)}${e}`;
13661
+ return `${Lr(s)}${e}`;
13627
13662
  }
13628
13663
  const pu = Object.freeze({
13629
13664
  init: (t) => Kt.init(t)
@@ -13632,11 +13667,11 @@ function fu(t) {
13632
13667
  return Kt.init(t);
13633
13668
  }
13634
13669
  export {
13635
- yi as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
13670
+ vi as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
13636
13671
  ed as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
13637
13672
  Zc as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
13638
13673
  td as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
13639
- Ko as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
13674
+ Wo as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
13640
13675
  lu as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
13641
13676
  pu as PlunoProductAgent,
13642
13677
  iu as ProductAgentInteractionManager,
@@ -13655,14 +13690,14 @@ export {
13655
13690
  pu as default,
13656
13691
  Gc as formatProductAgentTaskPageTitle,
13657
13692
  uu as getProductAgentOriginAccessErrorMessage,
13658
- Wo as isProductAgentAuthReconnectError,
13693
+ Xn as isProductAgentAuthReconnectError,
13659
13694
  cu as isProductAgentRuntimeCommand,
13660
- zo as mergeProductAgentEntityPages,
13695
+ Ho as mergeProductAgentEntityPages,
13661
13696
  St as normalizeProductAgentEntityPage,
13662
13697
  hu as normalizeProductAgentSessionItems,
13663
13698
  Vc as readLocalStorageInteractionDecisions,
13664
13699
  tu as resolveProductAgentComposerAction,
13665
13700
  Zl as resolveProductAgentWidgetPresentation,
13666
- Ho as selectProductAgentQueryEntities,
13701
+ Vo as selectProductAgentQueryEntities,
13667
13702
  Rl as validateProductAgentProviderInputFile
13668
13703
  };