@pluno/product-agent-web 0.1.268 → 0.1.270

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.
@@ -1,7 +1,7 @@
1
1
  function _e(s, e) {
2
2
  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: [] };
3
3
  }
4
- function m(s) {
4
+ function y(s) {
5
5
  return {
6
6
  key: s,
7
7
  status: "not_requested",
@@ -11,9 +11,9 @@ function m(s) {
11
11
  updatedAt: null
12
12
  };
13
13
  }
14
- class O {
14
+ class q {
15
15
  constructor(e, t, i = (n, r) => r) {
16
- this.loader = t, this.merge = i, this.state = m(e);
16
+ this.loader = t, this.merge = i, this.state = y(e);
17
17
  }
18
18
  loader;
19
19
  merge;
@@ -28,10 +28,10 @@ class O {
28
28
  return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
29
29
  }
30
30
  setKey(e) {
31
- e !== this.state.key && (this.state = m(e), this.trailingLoad = null, this.publish());
31
+ e !== this.state.key && (this.state = y(e), this.trailingLoad = null, this.publish());
32
32
  }
33
33
  reset() {
34
- this.state = m(this.state.key), this.trailingLoad = null, this.publish();
34
+ this.state = y(this.state.key), this.trailingLoad = null, this.publish();
35
35
  }
36
36
  invalidate() {
37
37
  this.state = {
@@ -96,14 +96,14 @@ function v(s) {
96
96
  nextCursor: s.nextCursor
97
97
  };
98
98
  }
99
- function B(s, e, t) {
99
+ function Q(s, e, t) {
100
100
  if (t === "replace" || s === null) return e;
101
101
  const i = { ...s.entitiesById, ...e.entitiesById }, n = [...s.ids];
102
102
  for (const r of e.ids)
103
103
  s.entitiesById[r] || n.push(r);
104
104
  return { entitiesById: i, ids: n, nextCursor: e.nextCursor };
105
105
  }
106
- function Q(s) {
106
+ function H(s) {
107
107
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
108
108
  }
109
109
  function Ie(s) {
@@ -114,10 +114,10 @@ function Se(s) {
114
114
  const e = s.paidCreditFallbackModel;
115
115
  return typeof e == "string" && e.length > 0;
116
116
  }
117
- function Ae(s) {
117
+ function we(s) {
118
118
  return s ? s.submissionGate?.allowed === !1 ? ["credits_exhausted", "payment_issue", "onboarding_required"].includes(s.submissionGate.reason) ? { state: "action_required", reason: s.submissionGate.reason } : { state: "hidden" } : 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 we(s) {
120
+ function Ae(s) {
121
121
  return s.submissionAllowed && s.isAuthenticated && s.hasWorkspace && !s.isWebsiteBlocked && s.isCurrentPageResolved && !s.isSubmitting && !s.hasPendingMessage;
122
122
  }
123
123
  function Me(s) {
@@ -130,13 +130,13 @@ function Me(s) {
130
130
  disabled: !e || !s.canSubmitMessage
131
131
  };
132
132
  }
133
- const H = "Pluno is reconnecting. Try again in a moment.";
134
- function V(s) {
135
- return (s instanceof Error ? s.message : s) === H;
133
+ const V = "Pluno is reconnecting. Try again in a moment.";
134
+ function Z(s) {
135
+ return (s instanceof Error ? s.message : s) === V;
136
136
  }
137
137
  class Te {
138
138
  constructor(e, t, i = 20) {
139
- this.loadPage = t, this.limit = i, this.recentQuery = new O(
139
+ this.loadPage = t, this.limit = i, this.recentQuery = new q(
140
140
  `${e}:recent`,
141
141
  async ({ cursor: n }) => v(
142
142
  await this.loadPage({ cursor: n, limit: this.limit, pinned: !1 }).then((r) => ({
@@ -144,8 +144,8 @@ class Te {
144
144
  nextCursor: r.nextCursor
145
145
  }))
146
146
  ),
147
- B
148
- ), this.pinnedQuery = new O(
147
+ Q
148
+ ), this.pinnedQuery = new q(
149
149
  `${e}:pinned`,
150
150
  async () => v({
151
151
  entities: await this.loadAllPinned(),
@@ -167,8 +167,8 @@ class Te {
167
167
  activityReconciliationScheduled = !1;
168
168
  getState() {
169
169
  const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), i = [
170
- ...f(t.data),
171
- ...f(e.data)
170
+ ...m(t.data),
171
+ ...m(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
174
  ), o = Array.from(this.optimisticEntities.values()).filter((d) => !n.has(d.id)).reverse(), a = e.data || t.data || o.length > 0 ? v({
@@ -177,7 +177,7 @@ class Te {
177
177
  }) : null;
178
178
  return {
179
179
  key: e.key.slice(0, -7),
180
- status: Z(e, t),
180
+ status: J(e, t),
181
181
  data: a,
182
182
  error: e.error ?? t.error,
183
183
  requestId: Math.max(e.requestId, t.requestId),
@@ -243,8 +243,8 @@ class Te {
243
243
  }
244
244
  reconcileDurableEntities() {
245
245
  const e = [
246
- ...f(this.pinnedQuery.getState().data),
247
- ...f(this.recentQuery.getState().data)
246
+ ...m(this.pinnedQuery.getState().data),
247
+ ...m(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 Te {
283
283
  for (const e of this.listeners) e(this.getState());
284
284
  }
285
285
  }
286
- function f(s) {
286
+ function m(s) {
287
287
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
288
288
  }
289
- function Z(s, e) {
289
+ function J(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 q(s) {
292
+ function k(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")}`;
@@ -305,15 +305,15 @@ function b(s) {
305
305
  function N(s) {
306
306
  return s !== null && typeof s == "object" && !Object.isFrozen(s) && (Object.values(s).forEach(N), Object.freeze(s)), s;
307
307
  }
308
- function J(s) {
308
+ function W(s) {
309
309
  if (!b(s)) throw new Error("Conversation inputs must be JSON-safe values.");
310
310
  return JSON.parse(JSON.stringify(s));
311
311
  }
312
- function W(s, e) {
312
+ function Y(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) => q(r.created_at).localeCompare(q(o.created_at)) || r.id.localeCompare(o.id));
316
+ const i = Object.values(s.items).sort((r, o) => k(r.created_at).localeCompare(k(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))
@@ -323,7 +323,7 @@ function W(s, e) {
323
323
  class Ee {
324
324
  constructor(e, t = null) {
325
325
  this.storage = e, t && (this.decisions = new Map(
326
- t.filter(w).map((i) => [this.getDecisionKey(i), i])
326
+ t.filter(A).map((i) => [this.getDecisionKey(i), i])
327
327
  ), this.initialized = !0);
328
328
  }
329
329
  storage;
@@ -345,7 +345,7 @@ class Ee {
345
345
  if (n && n.version >= t.version) continue;
346
346
  if (n && n.payload.kind !== t.payload.kind) throw new Error("Interaction kind changed.");
347
347
  const r = n?.payload.kind === "personal_channel" && n.lifecycle === "completed" ? "completed" : t.lifecycle, o = n?.payload.kind === "sharing" && t.payload.kind === "sharing" ? { ...t.payload, variant: n.payload.variant } : t.payload;
348
- this.sources.set(i, N(J({ ...t, lifecycle: r, payload: o }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
348
+ this.sources.set(i, N(W({ ...t, lifecycle: r, payload: o }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
349
349
  }
350
350
  }
351
351
  /** @internal */
@@ -371,7 +371,7 @@ class Ee {
371
371
  userPrompt: a?.type === "user_message" ? a.data.content : "",
372
372
  assistantAnswer: ""
373
373
  },
374
- terminal: !o.wait_for_terminal || W(i, r.user_message_id)
374
+ terminal: !o.wait_for_terminal || Y(i, r.user_message_id)
375
375
  };
376
376
  } else o.kind === "integration_auth" ? t.integrations.push({
377
377
  revision: r.version,
@@ -401,7 +401,7 @@ class Ee {
401
401
  if (this.initialized) return;
402
402
  const e = await this.storage.load();
403
403
  this.decisions = new Map(
404
- e.filter(w).map((t) => [this.getDecisionKey(t), t])
404
+ e.filter(A).map((t) => [this.getDecisionKey(t), t])
405
405
  ), this.initialized = !0;
406
406
  }
407
407
  isEligible(e, t = Date.now()) {
@@ -475,15 +475,15 @@ class Ee {
475
475
  }
476
476
  function Pe(s, e) {
477
477
  return {
478
- load: async () => Y(s, e),
478
+ load: async () => X(s, e),
479
479
  save: async (t) => s.setItem(e, JSON.stringify(t))
480
480
  };
481
481
  }
482
- function Y(s, e) {
482
+ function X(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(w) : [];
486
+ return Array.isArray(i) ? i.filter(A) : [];
487
487
  }
488
488
  function I(s) {
489
489
  return `${s.level}:${s.key}`;
@@ -491,23 +491,23 @@ function I(s) {
491
491
  function z(s) {
492
492
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
493
493
  }
494
- function w(s) {
494
+ function A(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");
498
498
  }
499
- const X = {
499
+ const ee = {
500
500
  working: "⏳",
501
501
  completed: "✅",
502
502
  failed: "❗",
503
503
  stopped: "⏹️"
504
- }, ee = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
- function te(s, e) {
504
+ }, te = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
+ function se(s, e) {
506
506
  if (!e) return _(s);
507
- const t = _(s), i = `${X[e]} Pluno`;
507
+ const t = _(s), i = `${ee[e]} Pluno`;
508
508
  return t ? `${i}: ${t}` : i;
509
509
  }
510
- class Oe {
510
+ class qe {
511
511
  constructor(e) {
512
512
  this.titleDocument = e;
513
513
  }
@@ -541,11 +541,11 @@ class Oe {
541
541
  applyTitle() {
542
542
  if (!this.status)
543
543
  return;
544
- const e = te(this.baseTitle, this.status);
544
+ const e = se(this.baseTitle, this.status);
545
545
  this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
546
546
  }
547
547
  }
548
- function qe(s) {
548
+ function ke(s) {
549
549
  return {
550
550
  getTitle: () => s.title,
551
551
  setTitle: (e) => {
@@ -562,12 +562,12 @@ function qe(s) {
562
562
  };
563
563
  }
564
564
  function _(s) {
565
- return s.replace(ee, "");
565
+ return s.replace(te, "");
566
566
  }
567
- const se = "0.1.268", ie = {
568
- version: se
567
+ const ie = "0.1.270", ne = {
568
+ version: ie
569
569
  }, p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
570
- function ne(s) {
570
+ function re(s) {
571
571
  if (!s || typeof s != "object") return !1;
572
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");
573
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);
@@ -577,23 +577,23 @@ function $(s) {
577
577
  const e = s;
578
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;
579
579
  }
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));
580
+ const O = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], M = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), h = (s) => s === null || M(s), oe = (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
581
  function K(s) {
582
582
  if (!s || typeof s != "object") return !1;
583
583
  const e = s;
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));
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 || oe(e.createdAt));
585
585
  }
586
- function oe(s) {
586
+ function ae(s) {
587
587
  if (!s || typeof s != "object") return !1;
588
588
  const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
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));
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 || re(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));
590
590
  }
591
591
  function U(s) {
592
592
  if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
593
593
  const e = (i) => {
594
594
  if (!i || typeof i != "object") return !1;
595
595
  const n = i;
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));
596
+ return Object.keys(i).every((r) => [...O, "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 || ae(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" && O.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(M));
597
597
  }, t = s;
598
598
  return (t.before === null || e(t.before)) && e(t.current);
599
599
  }
@@ -602,7 +602,7 @@ function L(s) {
602
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();
603
603
  return e.length > R ? `${e.slice(0, R - 1)}…` : e;
604
604
  }
605
- function ae(s) {
605
+ function de(s) {
606
606
  let e = 2166136261;
607
607
  for (let t = 0; t < s.length; t += 1)
608
608
  e ^= s.charCodeAt(t), e = Math.imul(e, 16777619);
@@ -613,23 +613,23 @@ function T(s) {
613
613
  const e = s;
614
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);
615
615
  }
616
- function de(s) {
616
+ function ce(s) {
617
617
  if (!s || typeof s != "object") return !1;
618
618
  const e = s;
619
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));
620
620
  }
621
- function ce(s, e, t, i, n = {}) {
622
- const r = !i && e === "conversation_error" && t !== void 0 && s.conversationDiagnostics?.errorMessageFingerprint === ae(L(t)) ? s.conversationDiagnostics : void 0;
621
+ function le(s, e, t, i, n = {}) {
622
+ const r = !i && e === "conversation_error" && t !== void 0 && s.conversationDiagnostics?.errorMessageFingerprint === de(L(t)) ? s.conversationDiagnostics : void 0;
623
623
  return {
624
624
  sessionId: p(s.sessionId),
625
625
  requestId: p(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
626
626
  ...p(r?.failedClientMessageId) ? { clientMessageId: r.failedClientMessageId } : {},
627
627
  code: r ? p(s.lastErrorCode) : null,
628
628
  ...T(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
629
- builds: { sdk: ie.version, ...n }
629
+ builds: { sdk: ne.version, ...n }
630
630
  };
631
631
  }
632
- function le(s) {
632
+ function ue(s) {
633
633
  if (s.details !== void 0 && !b(s.details))
634
634
  throw new TypeError("Product Agent transported error details must be JSON-safe.");
635
635
  return {
@@ -656,7 +656,7 @@ function g(s, e = "runtime_error", t = "runtime") {
656
656
  ...typeof a.durationMs == "number" && Number.isFinite(a.durationMs) && a.durationMs >= 0 ? { durationMs: a.durationMs } : {},
657
657
  ...typeof a.successfulRequests == "number" && Number.isSafeInteger(a.successfulRequests) && a.successfulRequests >= 0 ? { successfulRequests: a.successfulRequests } : {}
658
658
  };
659
- return le({
659
+ return ue({
660
660
  code: r,
661
661
  message: n.trim() && n.trim() !== "[object Object]" ? n : "The Product Agent operation failed. Try again.",
662
662
  retryable: !!(i && "retryable" in i && i.retryable === !0),
@@ -687,7 +687,7 @@ function G(s) {
687
687
  "upstreamTraceId"
688
688
  ].includes(i)) && p(e.requestId) !== null && ["GET", "POST", "PUT", "PATCH", "DELETE"].includes(e.method) && ["/api/product-agent/conversations/:sessionId/snapshot", "/api/product-agent/:namespace/commands", "/api/product-agent/:namespace/:operation"].includes(e.route) && (e.status === null || t(e.status) && e.status >= 100 && e.status <= 599) && (e.abortTrigger === null || ["deadline", "transport_disposed", "owner_disposed", "authority_retired", "observation_released", "request_replaced", "caller_cancelled", "unexpected_abort"].includes(e.abortTrigger)) && ["http_deadline", "http_transport", "conversation_query", "browser", "http_response"].includes(e.owner) && (e.category === void 0 || /^[a-z0-9_]{1,80}$/.test(e.category)) && [e.responseHeadersMs, e.responseBodyMs].every((i) => i == null || t(i)) && t(e.elapsedMs) && t(e.attempt) && e.attempt >= 1 && e.attempt <= 10 && [e.queryRequestId, e.ownerId, e.sessionId].every((i) => i === null || p(i) !== null) && (e.authorityGeneration === null || t(e.authorityGeneration)) && typeof e.release == "string" && /^[a-zA-Z0-9._-]{1,80}$/.test(e.release) && [e.upstreamRequestId, e.upstreamTraceId].every((i) => i === null || typeof i == "string" && /^[a-zA-Z0-9_:;=./-]{1,160}$/.test(i));
689
689
  }
690
- const ue = [
690
+ const pe = [
691
691
  "submit",
692
692
  "stop",
693
693
  "staging_ipc",
@@ -726,6 +726,15 @@ const ue = [
726
726
  "warmup_checkpoint",
727
727
  "warmup_http",
728
728
  "warmup_wait",
729
+ "session_tabs_snapshot",
730
+ "tab_window",
731
+ "tab_summary",
732
+ "preparation_deadline",
733
+ "preparation_retired",
734
+ "context_discarded",
735
+ "checkpoint_queue",
736
+ "checkpoint_prepared",
737
+ "checkpoint_restore",
729
738
  "acceptance_received",
730
739
  "acceptance_applied",
731
740
  "cancellation_queue",
@@ -746,20 +755,21 @@ const ue = [
746
755
  "backend_refusal",
747
756
  "unknown"
748
757
  ];
749
- function pe(s) {
758
+ function he(s) {
750
759
  const e = s, t = e?.code;
751
760
  return e?.backendRefusal === !0 ? "backend_refusal" : typeof t == "string" && t !== "backend_refusal" && F.includes(t) ? t : e?.name === "AbortError" ? "aborted" : e?.name === "TypeError" ? "type_error" : "unknown";
752
761
  }
753
- const he = Math.random().toString(36).slice(2);
762
+ const B = Math.random().toString(36).slice(2);
754
763
  let ge = 0;
755
- const C = () => `timing:${he}:${++ge}`, y = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
764
+ const C = () => `timing:${B}:${++ge}`, f = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
756
765
  function E(s) {
757
766
  if (!s || typeof s != "object") return !1;
758
767
  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" && F.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;
768
+ return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory", "tabId", "queueDepth", "workerId"].includes(t)) && (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 || f(e.workerId)) && (e.failureCategory === void 0 || e.status === "failed" && F.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) && pe.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;
760
769
  }
761
770
  function x(s, e) {
762
- if (!s) return {
771
+ if (e = { workerId: B, ...e }, !s) return {
772
+ identity: e,
763
773
  mark: (n) => {
764
774
  },
765
775
  measure: (n, r) => r()
@@ -772,12 +782,13 @@ function x(s, e) {
772
782
  spanId: a,
773
783
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
774
784
  durationMs: Math.max(0, Math.round(performance.now() - o)),
775
- ...r === "failed" ? { failureCategory: pe(d) } : {}
785
+ ...r === "failed" ? { failureCategory: he(d) } : {}
776
786
  };
777
787
  s && E(c) && Promise.resolve().then(() => s(c)).catch(() => {
778
788
  });
779
789
  };
780
790
  return {
791
+ identity: e,
781
792
  mark: (n) => i(n, "observed", t, C()),
782
793
  measure(n, r) {
783
794
  const o = performance.now(), a = C();
@@ -796,7 +807,7 @@ function fe(s) {
796
807
  const e = s;
797
808
  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
809
  }
799
- function ye(s, e, t = "stopped", i, n = "Run stopped by user.") {
810
+ function me(s, e, t = "stopped", i, n = "Run stopped by user.") {
800
811
  const r = new Set(i ?? [
801
812
  s.assistantDraftRespondsToUserMessageId,
802
813
  s.activeResponseUserMessageId,
@@ -823,7 +834,7 @@ function ye(s, e, t = "stopped", i, n = "Run stopped by user.") {
823
834
  lastErrorCode: null
824
835
  };
825
836
  }
826
- const me = {
837
+ const ye = {
827
838
  "stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
828
839
  "in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
829
840
  "stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
@@ -840,7 +851,7 @@ const me = {
840
851
  "thinking-without-progress": "Thinking remained visible without progress for five minutes."
841
852
  };
842
853
  function ve(s) {
843
- return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(me, s.slice(13));
854
+ return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ye, s.slice(13));
844
855
  }
845
856
  function D(s) {
846
857
  return {
@@ -853,7 +864,7 @@ function D(s) {
853
864
  ...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
854
865
  };
855
866
  }
856
- function ke(s) {
867
+ function Oe(s) {
857
868
  if (!s || typeof s != "object" || !("type" in s)) return !1;
858
869
  const e = s;
859
870
  switch (e.type) {
@@ -871,7 +882,7 @@ function ke(s) {
871
882
  case "runtime.report_operation_timing":
872
883
  return E(e.timing);
873
884
  case "runtime.report_displayed_error":
874
- return (e.errorDiagnostic === void 0 || de(e.errorDiagnostic)) && (e.httpRequest === void 0 || G(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);
885
+ return (e.errorDiagnostic === void 0 || ce(e.errorDiagnostic)) && (e.httpRequest === void 0 || G(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
886
  case "runtime.report_invalid_state_transition":
876
887
  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
888
  case "runtime.prompt_presented":
@@ -905,7 +916,7 @@ function ke(s) {
905
916
  }
906
917
  class Re {
907
918
  constructor(e, t, i) {
908
- this.adapter = t, this.state = A(e), this.model = i;
919
+ this.adapter = t, this.state = w(e), this.model = i;
909
920
  }
910
921
  adapter;
911
922
  listeners = {};
@@ -914,7 +925,7 @@ class Re {
914
925
  interactionListeners = /* @__PURE__ */ new Set();
915
926
  accountListeners = /* @__PURE__ */ new Set();
916
927
  state;
917
- sessionHistoryState = m("unavailable");
928
+ sessionHistoryState = y("unavailable");
918
929
  model;
919
930
  interactions = [];
920
931
  account = null;
@@ -933,13 +944,13 @@ class Re {
933
944
  return i.add(t), this.listeners[e] = i, () => i.delete(t);
934
945
  }
935
946
  getState() {
936
- const e = A(this.state);
947
+ const e = w(this.state);
937
948
  for (const [n, r] of this.submissionPreviews)
938
949
  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.message, e.lastErrorCode = ["unauthorized", "401", "auth_reconnecting", "submission_not_available"].includes(r.error.code) ? r.error.code : "message_delivery_failed"));
939
950
  this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
940
951
  const t = [...this.stopPreviews.keys()];
941
952
  if (!t.length) return e;
942
- const i = ye(e, "", "stopping", t);
953
+ const i = me(e, "", "stopping", t);
943
954
  return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
944
955
  }
945
956
  updateProjection(e, t, i, n, r) {
@@ -948,7 +959,7 @@ class Re {
948
959
  (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());
949
960
  for (const a of e.messages)
950
961
  a.role === "user" && this.submissionPreviews.delete(a.id);
951
- this.state = A(e);
962
+ this.state = w(e);
952
963
  for (const [a, d] of this.stopPreviews) {
953
964
  const c = e.activity?.executionKey;
954
965
  (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);
@@ -1014,7 +1025,7 @@ class Re {
1014
1025
  reportDisplayedError(e, t, i, n, r) {
1015
1026
  const o = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
1016
1027
  if (n !== void 0 && !K(n) || r !== void 0 && !$(r)) return;
1017
- const a = ce(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds);
1028
+ const a = le(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds);
1018
1029
  this.adapter.dispatch({
1019
1030
  type: "runtime.report_displayed_error",
1020
1031
  errorDiagnostic: a,
@@ -1106,7 +1117,7 @@ class Re {
1106
1117
  return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
1107
1118
  } catch (c) {
1108
1119
  if (i !== this.submissionGeneration) return null;
1109
- if (V(c))
1120
+ if (Z(c))
1110
1121
  for (const u of t.attachments ?? [])
1111
1122
  u.id && this.attachmentFiles.delete(u.id);
1112
1123
  const l = this.submissionPreviews.get(r);
@@ -1305,7 +1316,7 @@ function be(s, e) {
1305
1316
  return n ? { ...i, previewUrl: n } : i;
1306
1317
  });
1307
1318
  }
1308
- function A(s) {
1319
+ function w(s) {
1309
1320
  return {
1310
1321
  ...s,
1311
1322
  starterPrompts: [...s.starterPrompts],
@@ -1333,32 +1344,32 @@ function j(s) {
1333
1344
  return {
1334
1345
  ...s,
1335
1346
  data: s.data ? v({
1336
- entities: Q(s.data).map((e) => ({ ...e })),
1347
+ entities: H(s.data).map((e) => ({ ...e })),
1337
1348
  nextCursor: s.data.nextCursor
1338
1349
  }) : null
1339
1350
  };
1340
1351
  }
1341
1352
  export {
1342
- H as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1353
+ V as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1343
1354
  Ee as ProductAgentInteractionManager,
1344
- O as ProductAgentQueryController,
1355
+ q as ProductAgentQueryController,
1345
1356
  Re as ProductAgentRemoteRuntimeClient,
1346
1357
  Te as ProductAgentSessionHistoryManager,
1347
- Oe as ProductAgentTaskPageTitleController,
1348
- we as canSubmitPersonalProductAgentMessage,
1358
+ qe as ProductAgentTaskPageTitleController,
1359
+ Ae as canSubmitPersonalProductAgentMessage,
1349
1360
  Pe as createLocalStorageInteractionDecisionStorage,
1350
- m as createProductAgentQueryState,
1351
- qe as createProductAgentTaskPageTitleDocument,
1352
- te as formatProductAgentTaskPageTitle,
1361
+ y as createProductAgentQueryState,
1362
+ ke as createProductAgentTaskPageTitleDocument,
1363
+ se as formatProductAgentTaskPageTitle,
1353
1364
  Se as hasProductAgentPaidCreditFallback,
1354
- V as isProductAgentAuthReconnectError,
1355
- ke as isProductAgentRuntimeCommand,
1356
- B as mergeProductAgentEntityPages,
1365
+ Z as isProductAgentAuthReconnectError,
1366
+ Oe as isProductAgentRuntimeCommand,
1367
+ Q as mergeProductAgentEntityPages,
1357
1368
  v as normalizeProductAgentEntityPage,
1358
- Y as readLocalStorageInteractionDecisions,
1369
+ X as readLocalStorageInteractionDecisions,
1359
1370
  _e as reconcileProductAgentSubmissionGate,
1360
- Ae as resolveProductAgentBillingPresentation,
1371
+ we as resolveProductAgentBillingPresentation,
1361
1372
  Me as resolveProductAgentComposerAction,
1362
1373
  Ie as resolveProductAgentWidgetPresentation,
1363
- Q as selectProductAgentQueryEntities
1374
+ H as selectProductAgentQueryEntities
1364
1375
  };