@pluno/product-agent-web 0.1.256 → 0.1.258

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.
@@ -8,7 +8,7 @@ function m(s) {
8
8
  updatedAt: null
9
9
  };
10
10
  }
11
- class q {
11
+ class O {
12
12
  constructor(e, t, i = (n, r) => r) {
13
13
  this.loader = t, this.merge = i, this.state = m(e);
14
14
  }
@@ -83,7 +83,7 @@ class q {
83
83
  for (const e of this.listeners) e(this.state);
84
84
  }
85
85
  }
86
- function y(s) {
86
+ function v(s) {
87
87
  const e = {}, t = [];
88
88
  for (const i of s.entities)
89
89
  e[i.id] || t.push(i.id), e[i.id] = i;
@@ -93,7 +93,7 @@ function y(s) {
93
93
  nextCursor: s.nextCursor
94
94
  };
95
95
  }
96
- function G(s, e, t) {
96
+ function B(s, e, t) {
97
97
  if (t === "replace" || s === null) return e;
98
98
  const i = { ...s.entitiesById, ...e.entitiesById }, n = [...s.ids];
99
99
  for (const r of e.ids)
@@ -103,10 +103,10 @@ function G(s, e, t) {
103
103
  function Q(s) {
104
104
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
105
105
  }
106
- function _e(s) {
106
+ function Ie(s) {
107
107
  return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
108
108
  }
109
- function Ie(s, e) {
109
+ function _e(s, e) {
110
110
  return e === "limit_exceeded" ? { allowed: !1, reason: "credits_exhausted", actions: ["upgrade", "earn_credits"] } : e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required" ? { allowed: !1, reason: "payment_issue", actions: ["upgrade"] } : s ?? { allowed: !0, reason: "allowed", actions: [] };
111
111
  }
112
112
  function Se(s) {
@@ -114,13 +114,13 @@ function Se(s) {
114
114
  const e = s.paidCreditFallbackModel;
115
115
  return typeof e == "string" && e.length > 0;
116
116
  }
117
- function we(s) {
117
+ function Ae(s) {
118
118
  return s ? s.submissionGate?.allowed === !1 ? { state: "action_required", reason: s.submissionGate.reason } : s.usingPaidCreditFallback === !0 ? { state: "paid_credit_fallback" } : s.creditLimit !== null && s.creditLimit > 0 && s.creditsRemaining !== null && s.creditsRemaining > 0 && s.creditsRemaining / s.creditLimit <= 0.2 ? { state: "low_credits" } : s.creditsUsed !== null ? { state: "usage" } : { state: "hidden" } : { state: "hidden" };
119
119
  }
120
- function Ae(s) {
120
+ function we(s) {
121
121
  return s.submissionAllowed && s.isAuthenticated && s.hasWorkspace && !s.isWebsiteBlocked && s.isCurrentPageResolved && !s.isSubmitting && !s.hasPendingMessage;
122
122
  }
123
- function Ee(s) {
123
+ function Me(s) {
124
124
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
125
125
  return s.hasRunningAssistantTurn && !e ? {
126
126
  action: "stop",
@@ -134,20 +134,20 @@ const H = "Pluno is reconnecting. Try again in a moment.";
134
134
  function Z(s) {
135
135
  return (s instanceof Error ? s.message : s) === H;
136
136
  }
137
- class Me {
137
+ class Te {
138
138
  constructor(e, t, i = 20) {
139
- this.loadPage = t, this.limit = i, this.recentQuery = new q(
139
+ this.loadPage = t, this.limit = i, this.recentQuery = new O(
140
140
  `${e}:recent`,
141
- async ({ cursor: n }) => y(
141
+ async ({ cursor: n }) => v(
142
142
  await this.loadPage({ cursor: n, limit: this.limit, pinned: !1 }).then((r) => ({
143
143
  entities: r.sessions,
144
144
  nextCursor: r.nextCursor
145
145
  }))
146
146
  ),
147
- G
148
- ), this.pinnedQuery = new q(
147
+ B
148
+ ), this.pinnedQuery = new O(
149
149
  `${e}:pinned`,
150
- async () => y({
150
+ async () => v({
151
151
  entities: await this.loadAllPinned(),
152
152
  nextCursor: null
153
153
  })
@@ -167,11 +167,11 @@ class Me {
167
167
  activityReconciliationScheduled = !1;
168
168
  getState() {
169
169
  const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), i = [
170
- ...g(t.data),
171
- ...g(e.data)
170
+ ...f(t.data),
171
+ ...f(e.data)
172
172
  ], n = new Map(i.map((d) => [d.id, d])), r = Array.from(n.values()).map(
173
173
  (d) => this.applyOverrides(d, this.completedRefreshSequence)
174
- ), o = Array.from(this.optimisticEntities.values()).filter((d) => !n.has(d.id)).reverse(), a = e.data || t.data || o.length > 0 ? y({
174
+ ), o = Array.from(this.optimisticEntities.values()).filter((d) => !n.has(d.id)).reverse(), a = e.data || t.data || o.length > 0 ? v({
175
175
  entities: [...o, ...r],
176
176
  nextCursor: e.data?.nextCursor ?? null
177
177
  }) : null;
@@ -243,8 +243,8 @@ class Me {
243
243
  }
244
244
  reconcileDurableEntities() {
245
245
  const e = [
246
- ...g(this.pinnedQuery.getState().data),
247
- ...g(this.recentQuery.getState().data)
246
+ ...f(this.pinnedQuery.getState().data),
247
+ ...f(this.recentQuery.getState().data)
248
248
  ], t = new Set(e.map((i) => i.id));
249
249
  for (const i of this.optimisticEntities.keys())
250
250
  t.has(i) && this.optimisticEntities.delete(i);
@@ -283,13 +283,13 @@ class Me {
283
283
  for (const e of this.listeners) e(this.getState());
284
284
  }
285
285
  }
286
- function g(s) {
286
+ function f(s) {
287
287
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
288
288
  }
289
289
  function V(s, e) {
290
290
  return s.status === "error" || e.status === "error" ? "error" : s.status === "loading" || e.status === "loading" ? "loading" : s.status === "refreshing" || e.status === "refreshing" ? "refreshing" : s.status === "loading_more" ? "loading_more" : s.status === "ready" || e.status === "ready" ? "ready" : "not_requested";
291
291
  }
292
- function O(s) {
292
+ function q(s) {
293
293
  const e = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?(?:Z|\+00:00)$/.exec(s);
294
294
  if (!e) throw new Error("Display timestamps must retain the backend UTC precision.");
295
295
  return `${e[1]}.${(e[2] ?? "").padEnd(6, "0")}`;
@@ -313,17 +313,17 @@ function W(s, e) {
313
313
  if (!e) return !1;
314
314
  const t = s.executionByUserMessage[e];
315
315
  if (t) return ["completed", "stopped", "failed"].includes(t.phase);
316
- const i = Object.values(s.items).sort((r, o) => O(r.created_at).localeCompare(O(o.created_at)) || r.id.localeCompare(o.id));
316
+ const i = Object.values(s.items).sort((r, o) => q(r.created_at).localeCompare(q(o.created_at)) || r.id.localeCompare(o.id));
317
317
  let n = !1;
318
318
  for (const r of i)
319
319
  if (r.type === "user_message" && (n = r.id === e), !!n && (r.type === "stopped" || r.type === "error" || r.type === "final_response" && s.streams[r.id]?.state === "finished" && s.streams[r.id].revision >= r.data.revision))
320
320
  return !0;
321
321
  return !1;
322
322
  }
323
- class Pe {
323
+ class Ee {
324
324
  constructor(e, t = null) {
325
325
  this.storage = e, t && (this.decisions = new Map(
326
- t.filter(A).map((i) => [this.getDecisionKey(i), i])
326
+ t.filter(w).map((i) => [this.getDecisionKey(i), i])
327
327
  ), this.initialized = !0);
328
328
  }
329
329
  storage;
@@ -401,7 +401,7 @@ class Pe {
401
401
  if (this.initialized) return;
402
402
  const e = await this.storage.load();
403
403
  this.decisions = new Map(
404
- e.filter(A).map((t) => [this.getDecisionKey(t), t])
404
+ e.filter(w).map((t) => [this.getDecisionKey(t), t])
405
405
  ), this.initialized = !0;
406
406
  }
407
407
  isEligible(e, t = Date.now()) {
@@ -463,17 +463,17 @@ class Pe {
463
463
  return null;
464
464
  }
465
465
  getDecisionKey(e) {
466
- const t = I(e.scope);
466
+ const t = _(e.scope);
467
467
  return e.action === "dont_show_again" ? `${t}:category:${e.category}` : `${t}:interaction:${e.promptKey}`;
468
468
  }
469
469
  getExactKey(e) {
470
- return `${I(e.scope)}:interaction:${e.key}`;
470
+ return `${_(e.scope)}:interaction:${e.key}`;
471
471
  }
472
472
  getCategoryKey(e) {
473
- return `${I(e.scope)}:category:${e.category}`;
473
+ return `${_(e.scope)}:category:${e.category}`;
474
474
  }
475
475
  }
476
- function Te(s, e) {
476
+ function Pe(s, e) {
477
477
  return {
478
478
  load: async () => Y(s, e),
479
479
  save: async (t) => s.setItem(e, JSON.stringify(t))
@@ -483,15 +483,15 @@ function Y(s, e) {
483
483
  const t = s.getItem(e);
484
484
  if (!t) return [];
485
485
  const i = JSON.parse(t);
486
- return Array.isArray(i) ? i.filter(A) : [];
486
+ return Array.isArray(i) ? i.filter(w) : [];
487
487
  }
488
- function I(s) {
488
+ function _(s) {
489
489
  return `${s.level}:${s.key}`;
490
490
  }
491
491
  function z(s) {
492
492
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
493
493
  }
494
- function A(s) {
494
+ function w(s) {
495
495
  if (!s || typeof s != "object") return !1;
496
496
  const e = s;
497
497
  return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && z(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
@@ -503,11 +503,11 @@ const X = {
503
503
  stopped: "⏹️"
504
504
  }, ee = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
505
  function te(s, e) {
506
- if (!e) return _(s);
507
- const t = _(s), i = `${X[e]} Pluno`;
506
+ if (!e) return I(s);
507
+ const t = I(s), i = `${X[e]} Pluno`;
508
508
  return t ? `${i}: ${t}` : i;
509
509
  }
510
- class qe {
510
+ class Oe {
511
511
  constructor(e) {
512
512
  this.titleDocument = e;
513
513
  }
@@ -529,10 +529,10 @@ class qe {
529
529
  }
530
530
  applyStatus(e) {
531
531
  const t = this.titleDocument.getTitle();
532
- t !== this.lastAppliedTitle && (this.baseTitle = _(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
532
+ t !== this.lastAppliedTitle && (this.baseTitle = I(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
533
533
  }
534
534
  applyClear() {
535
- const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, i = this.lastAppliedTitle === null ? _(e) : e;
535
+ const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, i = this.lastAppliedTitle === null ? I(e) : e;
536
536
  this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : i !== e && this.titleDocument.setTitle(i);
537
537
  }
538
538
  handleTitleChanged() {
@@ -545,7 +545,7 @@ class qe {
545
545
  this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
546
546
  }
547
547
  }
548
- function Oe(s) {
548
+ function qe(s) {
549
549
  return {
550
550
  getTitle: () => s.title,
551
551
  setTitle: (e) => {
@@ -561,55 +561,54 @@ function Oe(s) {
561
561
  }
562
562
  };
563
563
  }
564
- function _(s) {
564
+ function I(s) {
565
565
  return s.replace(ee, "");
566
566
  }
567
- const p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
568
- function se(s) {
567
+ const se = "0.1.258", ie = {
568
+ version: se
569
+ }, p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
570
+ function ne(s) {
569
571
  if (!s || typeof s != "object") return !1;
570
572
  const e = s, t = (n) => Number.isSafeInteger(n) && n >= 0, i = (n) => n && typeof n == "object" && Object.keys(n).every((r) => ["sequence", "at", "type", "changed", "generation", "sessionId", "scopeId", "requestId", "effectId", "clientScopeId", "reason", "effectKind", "eventType", "itemCount", "removedCount", "projectionReady"].includes(r)) && t(n.sequence) && t(n.at) && p(n.type) !== null && typeof n.changed == "boolean" && [n.generation, n.itemCount, n.removedCount].every((r) => r === null || t(r)) && [n.sessionId, n.scopeId, n.requestId, n.effectId, n.clientScopeId, n.reason, n.effectKind, n.eventType].every((r) => r === null || p(r) !== null) && (n.projectionReady === null || typeof n.projectionReady == "boolean");
571
573
  return Object.keys(e).every((n) => ["ownerId", "revision", "dropped", "lastIntent", "lastSelection", "transitions"].includes(n)) && p(e.ownerId) !== null && t(e.revision) && t(e.dropped) && (e.lastIntent == null || i(e.lastIntent)) && (e.lastSelection === null || i(e.lastSelection)) && Array.isArray(e.transitions) && e.transitions.length <= 16 && e.transitions.every(i);
572
574
  }
573
- function K(s) {
575
+ function $(s) {
574
576
  if (!s || typeof s != "object") return !1;
575
577
  const e = s;
576
578
  return Object.keys(e).every((t) => ["sessionId", "episodeId", "consecutiveFailures", "transportCode", "requestId", "durationMs"].includes(t)) && typeof e.sessionId == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(e.sessionId) && typeof e.episodeId == "string" && /^[a-zA-Z0-9:_-]{1,500}$/.test(e.episodeId) && (e.transportCode === void 0 || typeof e.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(e.transportCode)) && (e.requestId === void 0 || typeof e.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(e.requestId)) && (e.durationMs === void 0 || typeof e.durationMs == "number" && Number.isFinite(e.durationMs) && e.durationMs >= 0) && Number.isSafeInteger(e.consecutiveFailures) && e.consecutiveFailures >= 1;
577
579
  }
578
- const R = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], E = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), v = (s) => s === null || E(s), ie = (s) => typeof s == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(s) && Number.isFinite(Date.parse(s));
579
- function $(s) {
580
+ const k = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], M = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), h = (s) => s === null || M(s), re = (s) => typeof s == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(s) && Number.isFinite(Date.parse(s));
581
+ function K(s) {
580
582
  if (!s || typeof s != "object") return !1;
581
583
  const e = s;
582
- return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && v(e.sessionId) && E(e.itemId) && v(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && v(e.runId) && (e.createdAt === null || ie(e.createdAt));
584
+ return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && h(e.sessionId) && M(e.itemId) && h(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && h(e.runId) && (e.createdAt === null || re(e.createdAt));
583
585
  }
584
- function ne(s) {
586
+ function oe(s) {
585
587
  if (!s || typeof s != "object") return !1;
586
588
  const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
587
- return Object.keys(e).every((i) => ["capturedAt", "selectionKey", "userId", "loading", "draft", "thinking", "connected", "hasError", "phase", "queryStatus", "queryRequestId", "queryUpdatedAt", "renderSource", "selectionFencePending", "guardCreatedAt", "owner"].includes(i)) && t(e.capturedAt) && [e.queryUpdatedAt, e.guardCreatedAt].every((i) => i === null || t(i)) && [e.selectionKey, e.userId, e.phase, e.queryStatus, e.queryRequestId].every((i) => i === null || p(i) !== null) && [e.loading, e.draft, e.thinking, e.connected, e.hasError, e.selectionFencePending].every((i) => typeof i == "boolean") && ["state", "account", "interactions", "local", "sidepanel_layout"].includes(e.renderSource) && (e.owner === void 0 || se(e.owner));
589
+ return Object.keys(e).every((i) => ["capturedAt", "selectionKey", "userId", "loading", "draft", "thinking", "connected", "hasError", "phase", "queryStatus", "queryRequestId", "queryUpdatedAt", "renderSource", "selectionFencePending", "guardCreatedAt", "owner", "sdkVersion", "presentationGate", "firstObservedAt", "confirmationMs"].includes(i)) && t(e.capturedAt) && [e.queryUpdatedAt, e.guardCreatedAt].every((i) => i === null || t(i)) && [e.selectionKey, e.userId, e.phase, e.queryStatus, e.queryRequestId].every((i) => i === null || p(i) !== null) && [e.loading, e.draft, e.thinking, e.connected, e.hasError, e.selectionFencePending].every((i) => typeof i == "boolean") && ["state", "account", "interactions", "local", "sidepanel_layout", "observer"].includes(e.renderSource) && (e.owner === void 0 || ne(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((i) => i === void 0 || t(i));
588
590
  }
589
591
  function U(s) {
590
592
  if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
591
593
  const e = (i) => {
592
594
  if (!i || typeof i != "object") return !1;
593
595
  const n = i;
594
- return Object.keys(i).every((r) => [...R, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || ne(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) && v(n.sessionId) && Number.isSafeInteger(n.runtimeItemCount) && n.runtimeItemCount >= 0 && typeof n.welcome == "boolean" && typeof n.truncated == "boolean" && R.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(E));
596
+ return Object.keys(i).every((r) => [...k, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context", "duplicateToolCalls"].includes(r)) && (n.duplicateToolCalls === void 0 || Array.isArray(n.duplicateToolCalls) && n.duplicateToolCalls.length <= 5 && n.duplicateToolCalls.every((r) => r && Object.keys(r).every((o) => ["key", "count", "rows", "truncated"].includes(o)) && h(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((o) => o && Object.keys(o).every((a) => ["itemId", "groupId"].includes(a)) && h(o.itemId) && h(o.groupId)))) && (n.context === void 0 || oe(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) && h(n.sessionId) && Number.isSafeInteger(n.runtimeItemCount) && n.runtimeItemCount >= 0 && typeof n.welcome == "boolean" && typeof n.truncated == "boolean" && k.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(M));
595
597
  }, t = s;
596
598
  return (t.before === null || e(t.before)) && e(t.current);
597
599
  }
598
- const k = 500;
600
+ const R = 500;
599
601
  function L(s) {
600
602
  const e = s.replace(/\n\s*at\s[\s\S]*$/, "").replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g, "[REDACTED]").replace(/\b(?:set-cookie|cookie)\s*[:=]\s*[^\n]+/gi, "cookie=[REDACTED]").replace(/\bdata:[^\s<>"']+/gi, "[DATA]").replace(/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi, "[URL]").replace(/\b(?:Bearer|Basic)\s+[^\s,;"']+/gi, "[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp)[-_][A-Za-z0-9_-]{8,}/g, "[REDACTED]").replace(/\b((?:access|refresh|id|auth)[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|pwd|secret|token|jwt|authorization|cookie|set-cookie)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;}&]+)/gi, "$1=[REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[EMAIL]").replace(/(?:[A-Z]:[\\/]|\\\\|(?:~|\.\.?)?\/|[\w.-]+[\\/])[^\s<>"']+/gi, "[FILE]").replace(new RegExp("(?<![\\w.])(?:[\\w.-]+\\.[A-Z][A-Z0-9]{0,15}|\\.[A-Z][\\w.-]*)\\b", "gi"), "[FILE]").replace(/\s+/g, " ").trim();
601
- return e.length > k ? `${e.slice(0, k - 1)}…` : e;
603
+ return e.length > R ? `${e.slice(0, R - 1)}…` : e;
602
604
  }
603
- function re(s) {
605
+ function ae(s) {
604
606
  let e = 2166136261;
605
607
  for (let t = 0; t < s.length; t += 1)
606
608
  e ^= s.charCodeAt(t), e = Math.imul(e, 16777619);
607
609
  return `fnv1a-${(e >>> 0).toString(16).padStart(8, "0")}`;
608
610
  }
609
- const oe = "0.1.256", ae = {
610
- version: oe
611
- };
612
- function M(s) {
611
+ function T(s) {
613
612
  if (!s || typeof s != "object") return !1;
614
613
  const e = s;
615
614
  return Object.keys(s).every((t) => ["boundary", "category", "messageKind"].includes(t)) && ["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);
@@ -617,17 +616,17 @@ function M(s) {
617
616
  function de(s) {
618
617
  if (!s || typeof s != "object") return !1;
619
618
  const e = s;
620
- return Object.keys(e).every((t) => ["sessionId", "requestId", "code", "normalization", "builds", "clientMessageId"].includes(t)) && (e.clientMessageId === void 0 || p(e.clientMessageId) !== null) && [e.sessionId, e.requestId, e.code].every((t) => t === null || p(t) !== null) && (e.normalization === void 0 || M(e.normalization)) && !!e.builds && typeof e.builds == "object" && typeof e.builds.sdk == "string" && Object.entries(e.builds).every(([t, i]) => ["sdk", "rendererExtension", "contentExtension", "backgroundExtension"].includes(t) && typeof i == "string" && /^\d{1,5}\.\d{1,5}\.\d{1,5}$/.test(i));
619
+ return Object.keys(e).every((t) => ["sessionId", "requestId", "code", "normalization", "builds", "clientMessageId"].includes(t)) && (e.clientMessageId === void 0 || p(e.clientMessageId) !== null) && [e.sessionId, e.requestId, e.code].every((t) => t === null || p(t) !== null) && (e.normalization === void 0 || T(e.normalization)) && !!e.builds && typeof e.builds == "object" && typeof e.builds.sdk == "string" && Object.entries(e.builds).every(([t, i]) => ["sdk", "rendererExtension", "contentExtension", "backgroundExtension"].includes(t) && typeof i == "string" && /^\d{1,5}\.\d{1,5}\.\d{1,5}$/.test(i));
621
620
  }
622
621
  function ce(s, e, t, i, n = {}) {
623
- const r = !i && e === "conversation_error" && t !== void 0 && s.conversationDiagnostics?.errorMessageFingerprint === re(L(t)) ? s.conversationDiagnostics : void 0;
622
+ const r = !i && e === "conversation_error" && t !== void 0 && s.conversationDiagnostics?.errorMessageFingerprint === ae(L(t)) ? s.conversationDiagnostics : void 0;
624
623
  return {
625
624
  sessionId: p(s.sessionId),
626
625
  requestId: p(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
627
626
  ...p(r?.failedClientMessageId) ? { clientMessageId: r.failedClientMessageId } : {},
628
627
  code: r ? p(s.lastErrorCode) : null,
629
- ...M(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
630
- builds: { sdk: ae.version, ...n }
628
+ ...T(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
629
+ builds: { sdk: ie.version, ...n }
631
630
  };
632
631
  }
633
632
  function le(s) {
@@ -640,10 +639,10 @@ function le(s) {
640
639
  ...s.details === void 0 ? {} : { details: s.details }
641
640
  };
642
641
  }
643
- function h(s, e = "runtime_error", t = "runtime") {
642
+ function g(s, e = "runtime_error", t = "runtime") {
644
643
  const i = s !== null && typeof s == "object" ? s : null, n = typeof s == "string" ? s : i && "message" in i && typeof i.message == "string" ? i.message : "", r = i && "code" in i && typeof i.code == "string" && i.code.trim() ? i.code : e, o = i && "details" in i ? i.details : null, a = o && typeof o == "object" ? o : {}, d = {
645
644
  // Preserve the first boundary's shape after normalization replaces the original message/prototype.
646
- errorNormalization: M(a.errorNormalization) ? a.errorNormalization : {
645
+ errorNormalization: T(a.errorNormalization) ? a.errorNormalization : {
647
646
  boundary: t,
648
647
  category: s instanceof Error ? "error" : s === null ? "null" : Array.isArray(s) ? "array" : typeof s,
649
648
  messageKind: n.trim() === "[object Object]" ? "object_coercion" : n.trim() ? "text" : typeof s == "string" || i && "message" in i && typeof i.message == "string" ? "blank" : "non_text"
@@ -730,7 +729,7 @@ const ue = [
730
729
  "acceptance_applied",
731
730
  "cancellation_queue",
732
731
  "cancellation_write"
733
- ], B = [
732
+ ], G = [
734
733
  "request_timed_out",
735
734
  "delivery_unknown",
736
735
  "invalid_ack",
@@ -748,15 +747,15 @@ const ue = [
748
747
  ];
749
748
  function pe(s) {
750
749
  const e = s, t = e?.code;
751
- return e?.backendRefusal === !0 ? "backend_refusal" : typeof t == "string" && t !== "backend_refusal" && B.includes(t) ? t : e?.name === "AbortError" ? "aborted" : e?.name === "TypeError" ? "type_error" : "unknown";
750
+ return e?.backendRefusal === !0 ? "backend_refusal" : typeof t == "string" && t !== "backend_refusal" && G.includes(t) ? t : e?.name === "AbortError" ? "aborted" : e?.name === "TypeError" ? "type_error" : "unknown";
752
751
  }
753
752
  const he = Math.random().toString(36).slice(2);
754
753
  let ge = 0;
755
- const C = () => `timing:${he}:${++ge}`, f = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
756
- function P(s) {
754
+ const C = () => `timing:${he}:${++ge}`, y = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
755
+ function E(s) {
757
756
  if (!s || typeof s != "object") return !1;
758
757
  const e = s;
759
- return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory"].includes(t)) && (e.failureCategory === void 0 || e.status === "failed" && B.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) && ue.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && f(e.spanId) && f(e.requestId) && (e.clientMessageId === null || f(e.clientMessageId)) && (e.sessionId === null || f(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
758
+ return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory"].includes(t)) && (e.failureCategory === void 0 || e.status === "failed" && G.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) && ue.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && y(e.spanId) && y(e.requestId) && (e.clientMessageId === null || y(e.clientMessageId)) && (e.sessionId === null || y(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
760
759
  }
761
760
  function x(s, e) {
762
761
  if (!s) return {
@@ -774,7 +773,7 @@ function x(s, e) {
774
773
  durationMs: Math.max(0, Math.round(performance.now() - o)),
775
774
  ...r === "failed" ? { failureCategory: pe(d) } : {}
776
775
  };
777
- s && P(c) && Promise.resolve().then(() => s(c)).catch(() => {
776
+ s && E(c) && Promise.resolve().then(() => s(c)).catch(() => {
778
777
  });
779
778
  };
780
779
  return {
@@ -796,7 +795,7 @@ function fe(s) {
796
795
  const e = s;
797
796
  return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && S(e.sessionId) && S(e.responseItemId) && S(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
798
797
  }
799
- function me(s, e, t = "stopped", i, n = "Run stopped by user.") {
798
+ function ye(s, e, t = "stopped", i, n = "Run stopped by user.") {
800
799
  const r = new Set(i ?? [
801
800
  s.assistantDraftRespondsToUserMessageId,
802
801
  s.activeResponseUserMessageId,
@@ -823,7 +822,7 @@ function me(s, e, t = "stopped", i, n = "Run stopped by user.") {
823
822
  lastErrorCode: null
824
823
  };
825
824
  }
826
- const ye = {
825
+ const me = {
827
826
  "stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
828
827
  "in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
829
828
  "stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
@@ -840,7 +839,7 @@ const ye = {
840
839
  "thinking-without-progress": "Thinking remained visible without progress for five minutes."
841
840
  };
842
841
  function ve(s) {
843
- return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ye, s.slice(13));
842
+ return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(me, s.slice(13));
844
843
  }
845
844
  function D(s) {
846
845
  return {
@@ -853,7 +852,7 @@ function D(s) {
853
852
  ...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
854
853
  };
855
854
  }
856
- function Re(s) {
855
+ function ke(s) {
857
856
  if (!s || typeof s != "object" || !("type" in s)) return !1;
858
857
  const e = s;
859
858
  switch (e.type) {
@@ -869,9 +868,9 @@ function Re(s) {
869
868
  case "runtime.warmup":
870
869
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
871
870
  case "runtime.report_operation_timing":
872
- return P(e.timing);
871
+ return E(e.timing);
873
872
  case "runtime.report_displayed_error":
874
- return (e.errorDiagnostic === void 0 || de(e.errorDiagnostic)) && (e.httpRequest === void 0 || F(e.httpRequest)) && (e.historyRefreshFailure === void 0 || K(e.historyRefreshFailure)) && (e.renderedError === void 0 || $(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);
873
+ return (e.errorDiagnostic === void 0 || de(e.errorDiagnostic)) && (e.httpRequest === void 0 || F(e.httpRequest)) && (e.historyRefreshFailure === void 0 || $(e.historyRefreshFailure)) && (e.renderedError === void 0 || K(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);
875
874
  case "runtime.report_invalid_state_transition":
876
875
  return (e.uiInvariant === void 0 || U(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || ve(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
877
876
  case "runtime.widget_lifecycle":
@@ -901,9 +900,9 @@ function Re(s) {
901
900
  return !1;
902
901
  }
903
902
  }
904
- class ke {
903
+ class Re {
905
904
  constructor(e, t, i) {
906
- this.adapter = t, this.state = w(e), this.model = i;
905
+ this.adapter = t, this.state = A(e), this.model = i;
907
906
  }
908
907
  adapter;
909
908
  listeners = {};
@@ -931,13 +930,13 @@ class ke {
931
930
  return i.add(t), this.listeners[e] = i, () => i.delete(t);
932
931
  }
933
932
  getState() {
934
- const e = w(this.state);
933
+ const e = A(this.state);
935
934
  for (const [n, r] of this.submissionPreviews)
936
935
  e.messages.some((o) => o.id === n) || (e.messages.push({ ...r.message, attachments: r.message.attachments?.map((o) => ({ ...o })) }), e.segments && (e.segments = [...e.segments, { id: n, userMessageId: n, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, r.pending && (e.activeResponseUserMessageId = n, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), r.error && (e.lastError = r.error, e.lastErrorCode = "message_delivery_failed"));
937
936
  this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
938
937
  const t = [...this.stopPreviews.keys()];
939
938
  if (!t.length) return e;
940
- const i = me(e, "", "stopping", t);
939
+ const i = ye(e, "", "stopping", t);
941
940
  return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
942
941
  }
943
942
  updateProjection(e, t, i, n, r) {
@@ -946,7 +945,7 @@ class ke {
946
945
  (o.user?.id !== e.user?.id || o.selectionKey !== void 0 && o.selectionKey !== e.selectionKey || o.selectionKey === void 0 && o.sessionId !== null && o.sessionId !== e.sessionId) && (this.cancelPendingSubmissions(), this.submissionPreviews.clear());
947
946
  for (const a of e.messages)
948
947
  a.role === "user" && this.submissionPreviews.delete(a.id);
949
- this.state = w(e);
948
+ this.state = A(e);
950
949
  for (const [a, d] of this.stopPreviews) {
951
950
  const c = e.activity?.executionKey;
952
951
  (d !== void 0 && d !== "[]" && c !== void 0 && c !== "[]" && (c !== d || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (d === void 0 || d === "[]") && e.messages.some((u) => u.respondsToUserMessageId === a && !u.provisional && u.loading !== !0 && (u.dataType === "run_status" || u.dataType === "run_error" || u.role === "assistant" && u.phase !== "commentary" && (u.streamState === void 0 || ["finished", "stopped", "failed"].includes(u.streamState))))) && this.stopPreviews.delete(a);
@@ -990,7 +989,7 @@ class ke {
990
989
  this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
991
990
  }
992
991
  reportOperationTiming(e) {
993
- !this.destroyed && P(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
992
+ !this.destroyed && E(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
994
993
  });
995
994
  }
996
995
  reportResponseVisibility(e) {
@@ -1008,7 +1007,7 @@ class ke {
1008
1007
  }
1009
1008
  reportDisplayedError(e, t, i, n, r) {
1010
1009
  const o = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
1011
- if (n !== void 0 && !$(n) || r !== void 0 && !K(r)) return;
1010
+ if (n !== void 0 && !K(n) || r !== void 0 && !$(r)) return;
1012
1011
  const a = ce(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds);
1013
1012
  this.adapter.dispatch({
1014
1013
  type: "runtime.report_displayed_error",
@@ -1080,9 +1079,9 @@ class ke {
1080
1079
  l.push(u);
1081
1080
  continue;
1082
1081
  }
1083
- const T = u.id ? this.attachmentFiles.get(u.id) : void 0;
1084
- if (!T) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
1085
- if (l.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(T, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
1082
+ const P = u.id ? this.attachmentFiles.get(u.id) : void 0;
1083
+ if (!P) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
1084
+ if (l.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(P, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
1086
1085
  }
1087
1086
  a = l;
1088
1087
  }
@@ -1105,10 +1104,10 @@ class ke {
1105
1104
  for (const u of t.attachments ?? [])
1106
1105
  u.id && this.attachmentFiles.delete(u.id);
1107
1106
  const l = this.submissionPreviews.get(r);
1108
- throw l && (l.pending = !1, l.error = h(c).message, l.retry = !d && h(c).code === "command_not_received" ? () => this.sendMessageNow(e, t, i) : void 0, this.emit("state", this.getState())), d && await this.adapter.dispatch({
1107
+ throw l && (l.pending = !1, l.error = g(c).message, l.retry = !d && g(c).code === "command_not_received" ? () => this.sendMessageNow(e, t, i) : void 0, this.emit("state", this.getState())), d && await this.adapter.dispatch({
1109
1108
  type: "conversation.fail_staged",
1110
1109
  clientMessageId: r,
1111
- message: h(c).message
1110
+ message: g(c).message
1112
1111
  }), c;
1113
1112
  }
1114
1113
  }
@@ -1129,7 +1128,7 @@ class ke {
1129
1128
  return i && n ? (i.pending = !0, i.error = void 0, i.retry = void 0, this.pendingTransfers.set(t, (i.message.attachments ?? []).flatMap((o) => o.id ? [o.id] : [])), this.emit("state", this.getState()), await n()) : await this.dispatch({ type: "run.retry", clientMessageId: t }), !0;
1130
1129
  } catch (o) {
1131
1130
  if (!i) throw o;
1132
- return r === this.submissionGeneration && this.submissionPreviews.get(t) === i && (i.error = h(o).message, this.emit("state", this.getState())), !1;
1131
+ return r === this.submissionGeneration && this.submissionPreviews.get(t) === i && (i.error = g(o).message, this.emit("state", this.getState())), !1;
1133
1132
  } finally {
1134
1133
  n && this.pendingTransfers.delete(t), i && r === this.submissionGeneration && this.submissionPreviews.get(t) === i && (i.pending = !1, this.emit("state", this.getState()));
1135
1134
  }
@@ -1167,7 +1166,7 @@ class ke {
1167
1166
  }, (c) => {
1168
1167
  if (!(a !== this.submissionGeneration || i.every((l) => !this.stopPreviews.has(l)))) {
1169
1168
  for (const l of i) this.stopPreviews.delete(l);
1170
- this.stopError = h(c).message;
1169
+ this.stopError = g(c).message;
1171
1170
  }
1172
1171
  }).finally(() => {
1173
1172
  this.destroyed || a !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
@@ -1298,7 +1297,7 @@ function be(s, e) {
1298
1297
  return n ? { ...i, previewUrl: n } : i;
1299
1298
  });
1300
1299
  }
1301
- function w(s) {
1300
+ function A(s) {
1302
1301
  return {
1303
1302
  ...s,
1304
1303
  starterPrompts: [...s.starterPrompts],
@@ -1325,7 +1324,7 @@ function w(s) {
1325
1324
  function j(s) {
1326
1325
  return {
1327
1326
  ...s,
1328
- data: s.data ? y({
1327
+ data: s.data ? v({
1329
1328
  entities: Q(s.data).map((e) => ({ ...e })),
1330
1329
  nextCursor: s.data.nextCursor
1331
1330
  }) : null
@@ -1333,25 +1332,25 @@ function j(s) {
1333
1332
  }
1334
1333
  export {
1335
1334
  H as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1336
- Pe as ProductAgentInteractionManager,
1337
- q as ProductAgentQueryController,
1338
- ke as ProductAgentRemoteRuntimeClient,
1339
- Me as ProductAgentSessionHistoryManager,
1340
- qe as ProductAgentTaskPageTitleController,
1341
- Ae as canSubmitPersonalProductAgentMessage,
1342
- Te as createLocalStorageInteractionDecisionStorage,
1335
+ Ee as ProductAgentInteractionManager,
1336
+ O as ProductAgentQueryController,
1337
+ Re as ProductAgentRemoteRuntimeClient,
1338
+ Te as ProductAgentSessionHistoryManager,
1339
+ Oe as ProductAgentTaskPageTitleController,
1340
+ we as canSubmitPersonalProductAgentMessage,
1341
+ Pe as createLocalStorageInteractionDecisionStorage,
1343
1342
  m as createProductAgentQueryState,
1344
- Oe as createProductAgentTaskPageTitleDocument,
1343
+ qe as createProductAgentTaskPageTitleDocument,
1345
1344
  te as formatProductAgentTaskPageTitle,
1346
1345
  Se as hasProductAgentPaidCreditFallback,
1347
1346
  Z as isProductAgentAuthReconnectError,
1348
- Re as isProductAgentRuntimeCommand,
1349
- G as mergeProductAgentEntityPages,
1350
- y as normalizeProductAgentEntityPage,
1347
+ ke as isProductAgentRuntimeCommand,
1348
+ B as mergeProductAgentEntityPages,
1349
+ v as normalizeProductAgentEntityPage,
1351
1350
  Y as readLocalStorageInteractionDecisions,
1352
- Ie as reconcileProductAgentSubmissionGate,
1353
- we as resolveProductAgentBillingPresentation,
1354
- Ee as resolveProductAgentComposerAction,
1355
- _e as resolveProductAgentWidgetPresentation,
1351
+ _e as reconcileProductAgentSubmissionGate,
1352
+ Ae as resolveProductAgentBillingPresentation,
1353
+ Me as resolveProductAgentComposerAction,
1354
+ Ie as resolveProductAgentWidgetPresentation,
1356
1355
  Q as selectProductAgentQueryEntities
1357
1356
  };