@pluno/product-agent-web 0.1.250 → 0.1.251

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 f(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 = f(e);
14
14
  }
@@ -93,34 +93,34 @@ function y(s) {
93
93
  nextCursor: s.nextCursor
94
94
  };
95
95
  }
96
- function B(s, e, t) {
96
+ function Q(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)
100
100
  s.entitiesById[r] || n.push(r);
101
101
  return { entitiesById: i, ids: n, nextCursor: e.nextCursor };
102
102
  }
103
- function Q(s) {
103
+ function G(s) {
104
104
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
105
105
  }
106
- function ve(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 be(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
- function Ie(s) {
112
+ function Se(s) {
113
113
  if (!s || typeof s != "object") return !1;
114
114
  const e = s.paidCreditFallbackModel;
115
115
  return typeof e == "string" && e.length > 0;
116
116
  }
117
- function _e(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 Se(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 Ae(s) {
123
+ function Ee(s) {
124
124
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
125
125
  return s.hasRunningAssistantTurn && !e ? {
126
126
  action: "stop",
@@ -130,13 +130,13 @@ function Ae(s) {
130
130
  disabled: !e || !s.canSubmitMessage
131
131
  };
132
132
  }
133
- const G = "Pluno is reconnecting. Try again in a moment.";
134
- function H(s) {
135
- return (s instanceof Error ? s.message : s) === G;
133
+ const H = "Pluno is reconnecting. Try again in a moment.";
134
+ function Z(s) {
135
+ return (s instanceof Error ? s.message : s) === H;
136
136
  }
137
- class we {
137
+ class Me {
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
141
  async ({ cursor: n }) => y(
142
142
  await this.loadPage({ cursor: n, limit: this.limit, pinned: !1 }).then((r) => ({
@@ -144,8 +144,8 @@ class we {
144
144
  nextCursor: r.nextCursor
145
145
  }))
146
146
  ),
147
- B
148
- ), this.pinnedQuery = new q(
147
+ Q
148
+ ), this.pinnedQuery = new O(
149
149
  `${e}:pinned`,
150
150
  async () => y({
151
151
  entities: await this.loadAllPinned(),
@@ -177,7 +177,7 @@ class we {
177
177
  }) : null;
178
178
  return {
179
179
  key: e.key.slice(0, -7),
180
- status: Z(e, t),
180
+ status: V(e, t),
181
181
  data: o,
182
182
  error: e.error ?? t.error,
183
183
  requestId: Math.max(e.requestId, t.requestId),
@@ -286,10 +286,10 @@ class we {
286
286
  function h(s) {
287
287
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
288
288
  }
289
- function Z(s, e) {
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")}`;
@@ -305,22 +305,22 @@ function v(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 V(s) {
308
+ function J(s) {
309
309
  if (!v(s)) throw new Error("Conversation inputs must be JSON-safe values.");
310
310
  return JSON.parse(JSON.stringify(s));
311
311
  }
312
- function J(s, e) {
312
+ 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, a) => O(r.created_at).localeCompare(O(a.created_at)) || r.id.localeCompare(a.id));
316
+ const i = Object.values(s.items).sort((r, a) => q(r.created_at).localeCompare(q(a.created_at)) || r.id.localeCompare(a.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 Ee {
323
+ class Te {
324
324
  constructor(e, t = null) {
325
325
  this.storage = e, t && (this.decisions = new Map(
326
326
  t.filter(w).map((i) => [this.getDecisionKey(i), i])
@@ -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, a = n?.payload.kind === "sharing" && t.payload.kind === "sharing" ? { ...t.payload, variant: n.payload.variant } : t.payload;
348
- this.sources.set(i, N(V({ ...t, lifecycle: r, payload: a }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
348
+ this.sources.set(i, N(J({ ...t, lifecycle: r, payload: a }))), 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: o?.type === "user_message" ? o.data.content : "",
372
372
  assistantAnswer: ""
373
373
  },
374
- terminal: !a.wait_for_terminal || J(i, r.user_message_id)
374
+ terminal: !a.wait_for_terminal || W(i, r.user_message_id)
375
375
  };
376
376
  } else a.kind === "integration_auth" ? t.integrations.push({
377
377
  revision: r.version,
@@ -475,11 +475,11 @@ class Ee {
475
475
  }
476
476
  function Pe(s, e) {
477
477
  return {
478
- load: async () => W(s, e),
478
+ load: async () => Y(s, e),
479
479
  save: async (t) => s.setItem(e, JSON.stringify(t))
480
480
  };
481
481
  }
482
- function W(s, e) {
482
+ function Y(s, e) {
483
483
  const t = s.getItem(e);
484
484
  if (!t) return [];
485
485
  const i = JSON.parse(t);
@@ -496,18 +496,18 @@ function w(s) {
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 Y = {
499
+ const X = {
500
500
  working: "⏳",
501
501
  completed: "✅",
502
502
  failed: "❗",
503
503
  stopped: "⏹️"
504
- }, X = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
- function ee(s, e) {
504
+ }, ee = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
+ function te(s, e) {
506
506
  if (!e) return b(s);
507
- const t = b(s), i = `${Y[e]} Pluno`;
507
+ const t = b(s), i = `${X[e]} Pluno`;
508
508
  return t ? `${i}: ${t}` : i;
509
509
  }
510
- class Te {
510
+ class Oe {
511
511
  constructor(e) {
512
512
  this.titleDocument = e;
513
513
  }
@@ -541,11 +541,11 @@ class Te {
541
541
  applyTitle() {
542
542
  if (!this.status)
543
543
  return;
544
- const e = ee(this.baseTitle, this.status);
544
+ const e = te(this.baseTitle, this.status);
545
545
  this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
546
546
  }
547
547
  }
548
- function Me(s) {
548
+ function qe(s) {
549
549
  return {
550
550
  getTitle: () => s.title,
551
551
  setTitle: (e) => {
@@ -562,10 +562,10 @@ function Me(s) {
562
562
  };
563
563
  }
564
564
  function b(s) {
565
- return s.replace(X, "");
565
+ return s.replace(ee, "");
566
566
  }
567
567
  const p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
568
- function te(s) {
568
+ function se(s) {
569
569
  if (!s || typeof s != "object") return !1;
570
570
  const e = s, t = (n) => Number.isSafeInteger(n) && n >= 0, i = (n) => n && typeof n == "object" && Object.keys(n).every((r) => ["sequence", "at", "type", "changed", "generation", "sessionId", "scopeId", "requestId", "effectId", "clientScopeId", "reason", "effectKind", "eventType", "itemCount", "removedCount", "projectionReady"].includes(r)) && t(n.sequence) && t(n.at) && p(n.type) !== null && typeof n.changed == "boolean" && [n.generation, n.itemCount, n.removedCount].every((r) => r === null || t(r)) && [n.sessionId, n.scopeId, n.requestId, n.effectId, n.clientScopeId, n.reason, n.effectKind, n.eventType].every((r) => r === null || p(r) !== null) && (n.projectionReady === null || typeof n.projectionReady == "boolean");
571
571
  return Object.keys(e).every((n) => ["ownerId", "revision", "dropped", "lastIntent", "lastSelection", "transitions"].includes(n)) && p(e.ownerId) !== null && t(e.revision) && t(e.dropped) && (e.lastIntent == null || i(e.lastIntent)) && (e.lastSelection === null || i(e.lastSelection)) && Array.isArray(e.transitions) && e.transitions.length <= 16 && e.transitions.every(i);
@@ -575,23 +575,23 @@ function K(s) {
575
575
  const e = s;
576
576
  return Object.keys(e).every((t) => ["sessionId", "episodeId", "consecutiveFailures", "transportCode", "requestId", "durationMs"].includes(t)) && typeof e.sessionId == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(e.sessionId) && typeof e.episodeId == "string" && /^[a-zA-Z0-9:_-]{1,500}$/.test(e.episodeId) && (e.transportCode === void 0 || typeof e.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(e.transportCode)) && (e.requestId === void 0 || typeof e.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(e.requestId)) && (e.durationMs === void 0 || typeof e.durationMs == "number" && Number.isFinite(e.durationMs) && e.durationMs >= 0) && Number.isSafeInteger(e.consecutiveFailures) && e.consecutiveFailures >= 1;
577
577
  }
578
- const R = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], E = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), m = (s) => s === null || E(s), se = (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));
578
+ const R = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], E = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), m = (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
579
  function $(s) {
580
580
  if (!s || typeof s != "object") return !1;
581
581
  const e = s;
582
- return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && m(e.sessionId) && E(e.itemId) && m(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && m(e.runId) && (e.createdAt === null || se(e.createdAt));
582
+ return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && m(e.sessionId) && E(e.itemId) && m(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && m(e.runId) && (e.createdAt === null || ie(e.createdAt));
583
583
  }
584
- function ie(s) {
584
+ function ne(s) {
585
585
  if (!s || typeof s != "object") return !1;
586
586
  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 || te(e.owner));
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));
588
588
  }
589
589
  function U(s) {
590
590
  if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
591
591
  const e = (i) => {
592
592
  if (!i || typeof i != "object") return !1;
593
593
  const n = i;
594
- return Object.keys(i).every((r) => [...R, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || ie(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) && m(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));
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")) && m(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));
595
595
  }, t = s;
596
596
  return (t.before === null || e(t.before)) && e(t.current);
597
597
  }
@@ -600,36 +600,37 @@ function L(s) {
600
600
  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
601
  return e.length > k ? `${e.slice(0, k - 1)}…` : e;
602
602
  }
603
- function ne(s) {
603
+ function re(s) {
604
604
  let e = 2166136261;
605
605
  for (let t = 0; t < s.length; t += 1)
606
606
  e ^= s.charCodeAt(t), e = Math.imul(e, 16777619);
607
607
  return `fnv1a-${(e >>> 0).toString(16).padStart(8, "0")}`;
608
608
  }
609
- const re = "0.1.250", oe = {
610
- version: re
609
+ const oe = "0.1.251", ae = {
610
+ version: oe
611
611
  };
612
- function P(s) {
612
+ function M(s) {
613
613
  if (!s || typeof s != "object") return !1;
614
614
  const e = s;
615
615
  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);
616
616
  }
617
- function ae(s) {
617
+ function de(s) {
618
618
  if (!s || typeof s != "object") return !1;
619
619
  const e = s;
620
- return Object.keys(e).every((t) => ["sessionId", "requestId", "code", "normalization", "builds"].includes(t)) && [e.sessionId, e.requestId, e.code].every((t) => t === null || p(t) !== null) && (e.normalization === void 0 || P(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
+ 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));
621
621
  }
622
- function de(s, e, t, i, n = {}) {
623
- const r = !i && e === "conversation_error" && t !== void 0 && s.conversationDiagnostics?.errorMessageFingerprint === ne(L(t)) ? s.conversationDiagnostics : void 0;
622
+ 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;
624
624
  return {
625
625
  sessionId: p(s.sessionId),
626
626
  requestId: p(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
627
+ ...p(r?.failedClientMessageId) ? { clientMessageId: r.failedClientMessageId } : {},
627
628
  code: r ? p(s.lastErrorCode) : null,
628
- ...P(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
629
- builds: { sdk: oe.version, ...n }
629
+ ...M(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
630
+ builds: { sdk: ae.version, ...n }
630
631
  };
631
632
  }
632
- function ce(s) {
633
+ function le(s) {
633
634
  if (s.details !== void 0 && !v(s.details))
634
635
  throw new TypeError("Product Agent transported error details must be JSON-safe.");
635
636
  return {
@@ -642,7 +643,7 @@ function ce(s) {
642
643
  function _(s, e = "runtime_error", t = "runtime") {
643
644
  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, a = i && "details" in i ? i.details : null, o = a && typeof a == "object" ? a : {}, d = {
644
645
  // Preserve the first boundary's shape after normalization replaces the original message/prototype.
645
- errorNormalization: P(o.errorNormalization) ? o.errorNormalization : {
646
+ errorNormalization: M(o.errorNormalization) ? o.errorNormalization : {
646
647
  boundary: t,
647
648
  category: s instanceof Error ? "error" : s === null ? "null" : Array.isArray(s) ? "array" : typeof s,
648
649
  messageKind: n.trim() === "[object Object]" ? "object_coercion" : n.trim() ? "text" : typeof s == "string" || i && "message" in i && typeof i.message == "string" ? "blank" : "non_text"
@@ -655,7 +656,7 @@ function _(s, e = "runtime_error", t = "runtime") {
655
656
  ...typeof o.durationMs == "number" && Number.isFinite(o.durationMs) && o.durationMs >= 0 ? { durationMs: o.durationMs } : {},
656
657
  ...typeof o.successfulRequests == "number" && Number.isSafeInteger(o.successfulRequests) && o.successfulRequests >= 0 ? { successfulRequests: o.successfulRequests } : {}
657
658
  };
658
- return ce({
659
+ return le({
659
660
  code: r,
660
661
  message: n.trim() && n.trim() !== "[object Object]" ? n : "The Product Agent operation failed. Try again.",
661
662
  retryable: !!(i && "retryable" in i && i.retryable === !0),
@@ -686,7 +687,7 @@ function F(s) {
686
687
  "upstreamTraceId"
687
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));
688
689
  }
689
- const le = [
690
+ const ue = [
690
691
  "submit",
691
692
  "stop",
692
693
  "staging_ipc",
@@ -721,53 +722,76 @@ const le = [
721
722
  "reading_painted",
722
723
  "stopping_painted",
723
724
  "progress_painted",
724
- "stopped_painted"
725
- ], ue = Math.random().toString(36).slice(2);
726
- let pe = 0;
727
- const x = () => `timing:${ue}:${++pe}`, g = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
725
+ "stopped_painted",
726
+ "acceptance_received",
727
+ "acceptance_applied"
728
+ ], B = [
729
+ "request_timed_out",
730
+ "delivery_unknown",
731
+ "invalid_ack",
732
+ "acceptance_identity_mismatch",
733
+ "disconnected",
734
+ "executor_not_ready",
735
+ "unauthorized",
736
+ "connection_failed",
737
+ "invalid_response",
738
+ "network_error",
739
+ "type_error",
740
+ "aborted",
741
+ "backend_refusal",
742
+ "unknown"
743
+ ];
744
+ function pe(s) {
745
+ const e = s, t = e?.code;
746
+ 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";
747
+ }
748
+ const he = Math.random().toString(36).slice(2);
749
+ let ge = 0;
750
+ const C = () => `timing:${he}:${++ge}`, g = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
728
751
  function T(s) {
729
752
  if (!s || typeof s != "object") return !1;
730
753
  const e = s;
731
- return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs"].includes(t)) && (e.entrySurface === void 0 || ["extension_sidepanel", "extension_widget", "main_web_chat", "embedded_widget", "embedded_custom_ui", "automation", "mcp", "whatsapp", "email"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && le.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && g(e.spanId) && g(e.requestId) && (e.clientMessageId === null || g(e.clientMessageId)) && (e.sessionId === null || g(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
754
+ 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) && g(e.spanId) && g(e.requestId) && (e.clientMessageId === null || g(e.clientMessageId)) && (e.sessionId === null || g(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
732
755
  }
733
- function C(s, e) {
756
+ function x(s, e) {
734
757
  if (!s) return {
735
758
  mark: (n) => {
736
759
  },
737
760
  measure: (n, r) => r()
738
761
  };
739
- const t = performance.now(), i = (n, r, a, o) => {
740
- const d = {
762
+ const t = performance.now(), i = (n, r, a, o, d) => {
763
+ const c = {
741
764
  ...e,
742
765
  stage: n,
743
766
  status: r,
744
767
  spanId: o,
745
768
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
746
- durationMs: Math.max(0, Math.round(performance.now() - a))
769
+ durationMs: Math.max(0, Math.round(performance.now() - a)),
770
+ ...r === "failed" ? { failureCategory: pe(d) } : {}
747
771
  };
748
- s && T(d) && Promise.resolve().then(() => s(d)).catch(() => {
772
+ s && T(c) && Promise.resolve().then(() => s(c)).catch(() => {
749
773
  });
750
774
  };
751
775
  return {
752
- mark: (n) => i(n, "observed", t, x()),
776
+ mark: (n) => i(n, "observed", t, C()),
753
777
  measure(n, r) {
754
- const a = performance.now(), o = x();
778
+ const a = performance.now(), o = C();
755
779
  return i(n, "started", a, o), r().then(
756
780
  (d) => (i(n, "completed", a, o), d),
757
781
  (d) => {
758
- throw i(n, "failed", a, o), d;
782
+ throw i(n, "failed", a, o, d), d;
759
783
  }
760
784
  );
761
785
  }
762
786
  };
763
787
  }
764
788
  const S = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
765
- function he(s) {
789
+ function fe(s) {
766
790
  if (!s || typeof s != "object") return !1;
767
791
  const e = s;
768
792
  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";
769
793
  }
770
- function ge(s, e, t = "stopped", i, n = "Run stopped by user.") {
794
+ function ye(s, e, t = "stopped", i, n = "Run stopped by user.") {
771
795
  const r = new Set(i ?? [
772
796
  s.assistantDraftRespondsToUserMessageId,
773
797
  s.activeResponseUserMessageId,
@@ -794,7 +818,7 @@ function ge(s, e, t = "stopped", i, n = "Run stopped by user.") {
794
818
  lastErrorCode: null
795
819
  };
796
820
  }
797
- const fe = {
821
+ const me = {
798
822
  "stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
799
823
  "in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
800
824
  "stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
@@ -810,8 +834,8 @@ const fe = {
810
834
  "thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
811
835
  "thinking-without-progress": "Thinking remained visible without progress for five minutes."
812
836
  };
813
- function ye(s) {
814
- return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(fe, s.slice(13));
837
+ function ve(s) {
838
+ return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(me, s.slice(13));
815
839
  }
816
840
  function D(s) {
817
841
  return {
@@ -824,7 +848,7 @@ function D(s) {
824
848
  ...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
825
849
  };
826
850
  }
827
- function qe(s) {
851
+ function Re(s) {
828
852
  if (!s || typeof s != "object" || !("type" in s)) return !1;
829
853
  const e = s;
830
854
  switch (e.type) {
@@ -836,15 +860,15 @@ function qe(s) {
836
860
  case "run.stop":
837
861
  return e.clientMessageIds === void 0 || Array.isArray(e.clientMessageIds) && e.clientMessageIds.length <= 100 && e.clientMessageIds.every((t) => typeof t == "string" && t.length > 0 && t.length <= 160);
838
862
  case "runtime.report_response_visibility":
839
- return he(e.observation);
863
+ return fe(e.observation);
840
864
  case "runtime.warmup":
841
865
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
842
866
  case "runtime.report_operation_timing":
843
867
  return T(e.timing);
844
868
  case "runtime.report_displayed_error":
845
- return (e.errorDiagnostic === void 0 || ae(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);
869
+ 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);
846
870
  case "runtime.report_invalid_state_transition":
847
- 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" || ye(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
871
+ 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");
848
872
  case "runtime.widget_lifecycle":
849
873
  return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
850
874
  case "session.load":
@@ -872,7 +896,7 @@ function qe(s) {
872
896
  return !1;
873
897
  }
874
898
  }
875
- class Oe {
899
+ class ke {
876
900
  constructor(e, t, i) {
877
901
  this.adapter = t, this.state = A(e), this.model = i;
878
902
  }
@@ -908,7 +932,7 @@ class Oe {
908
932
  this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
909
933
  const t = [...this.stopPreviews.keys()];
910
934
  if (!t.length) return e;
911
- const i = ge(e, "", "stopping", t);
935
+ const i = ye(e, "", "stopping", t);
912
936
  return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
913
937
  }
914
938
  updateProjection(e, t, i, n, r) {
@@ -926,7 +950,7 @@ class Oe {
926
950
  for (const o of this.state.messages) {
927
951
  if (o.role !== "user" || !o.attachments?.length) continue;
928
952
  const d = a.messages.find((c) => c.role === "user" && c.id === o.id);
929
- a.sessionId !== e.sessionId && !(a.sessionId === null && d) || (o.attachments = me(d?.attachments, o.attachments));
953
+ a.sessionId !== e.sessionId && !(a.sessionId === null && d) || (o.attachments = be(d?.attachments, o.attachments));
930
954
  }
931
955
  if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
932
956
  this.sessionHistoryState = j(i);
@@ -979,9 +1003,12 @@ class Oe {
979
1003
  }
980
1004
  reportDisplayedError(e, t, i, n, r) {
981
1005
  const a = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
982
- n !== void 0 && !$(n) || r !== void 0 && !K(r) || this.adapter.dispatch({
1006
+ if (n !== void 0 && !$(n) || r !== void 0 && !K(r)) return;
1007
+ const o = ce(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds);
1008
+ this.adapter.dispatch({
983
1009
  type: "runtime.report_displayed_error",
984
- errorDiagnostic: de(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds),
1010
+ errorDiagnostic: o,
1011
+ ...o.clientMessageId ? { clientMessageId: o.clientMessageId } : {},
985
1012
  reason: e,
986
1013
  errorFingerprint: t,
987
1014
  ...n ? { renderedError: n } : {},
@@ -1009,7 +1036,7 @@ class Oe {
1009
1036
  });
1010
1037
  }
1011
1038
  async sendMessageNow(e, t, i) {
1012
- const n = e, r = t.clientMessageId, a = C((c) => {
1039
+ const n = e, r = t.clientMessageId, a = x((c) => {
1013
1040
  i === this.submissionGeneration && this.reportOperationTiming(c);
1014
1041
  }, {
1015
1042
  operation: "send",
@@ -1046,9 +1073,9 @@ class Oe {
1046
1073
  u.push(l);
1047
1074
  continue;
1048
1075
  }
1049
- const M = l.id ? this.attachmentFiles.get(l.id) : void 0;
1050
- if (!M) throw new Error(`Attachment bytes are unavailable for ${l.name}`);
1051
- if (u.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(M, l, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
1076
+ const P = l.id ? this.attachmentFiles.get(l.id) : void 0;
1077
+ if (!P) throw new Error(`Attachment bytes are unavailable for ${l.name}`);
1078
+ if (u.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(P, l, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
1052
1079
  }
1053
1080
  o = u;
1054
1081
  }
@@ -1067,7 +1094,7 @@ class Oe {
1067
1094
  return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
1068
1095
  } catch (c) {
1069
1096
  if (i !== this.submissionGeneration) return null;
1070
- if (H(c))
1097
+ if (Z(c))
1071
1098
  for (const l of t.attachments ?? [])
1072
1099
  l.id && this.attachmentFiles.delete(l.id);
1073
1100
  const u = this.submissionPreviews.get(r);
@@ -1103,7 +1130,7 @@ class Oe {
1103
1130
  ...t,
1104
1131
  e.activeResponseUserMessageId,
1105
1132
  e.messages.filter((c) => c.role === "user").slice(-1)[0]?.id
1106
- ].filter((c) => !!c))], n = C((c) => this.reportOperationTiming(c), {
1133
+ ].filter((c) => !!c))], n = x((c) => this.reportOperationTiming(c), {
1107
1134
  operation: "stop",
1108
1135
  layer: "renderer",
1109
1136
  requestId: crypto.randomUUID(),
@@ -1236,7 +1263,7 @@ class Oe {
1236
1263
  for (const n of i ?? []) n(t);
1237
1264
  }
1238
1265
  }
1239
- function me(s, e) {
1266
+ function be(s, e) {
1240
1267
  if (!e || !s) return e;
1241
1268
  const t = /* @__PURE__ */ new Map();
1242
1269
  for (const i of s) {
@@ -1276,32 +1303,32 @@ function j(s) {
1276
1303
  return {
1277
1304
  ...s,
1278
1305
  data: s.data ? y({
1279
- entities: Q(s.data).map((e) => ({ ...e })),
1306
+ entities: G(s.data).map((e) => ({ ...e })),
1280
1307
  nextCursor: s.data.nextCursor
1281
1308
  }) : null
1282
1309
  };
1283
1310
  }
1284
1311
  export {
1285
- G as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1286
- Ee as ProductAgentInteractionManager,
1287
- q as ProductAgentQueryController,
1288
- Oe as ProductAgentRemoteRuntimeClient,
1289
- we as ProductAgentSessionHistoryManager,
1290
- Te as ProductAgentTaskPageTitleController,
1291
- Se as canSubmitPersonalProductAgentMessage,
1312
+ H as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1313
+ Te as ProductAgentInteractionManager,
1314
+ O as ProductAgentQueryController,
1315
+ ke as ProductAgentRemoteRuntimeClient,
1316
+ Me as ProductAgentSessionHistoryManager,
1317
+ Oe as ProductAgentTaskPageTitleController,
1318
+ we as canSubmitPersonalProductAgentMessage,
1292
1319
  Pe as createLocalStorageInteractionDecisionStorage,
1293
1320
  f as createProductAgentQueryState,
1294
- Me as createProductAgentTaskPageTitleDocument,
1295
- ee as formatProductAgentTaskPageTitle,
1296
- Ie as hasProductAgentPaidCreditFallback,
1297
- H as isProductAgentAuthReconnectError,
1298
- qe as isProductAgentRuntimeCommand,
1299
- B as mergeProductAgentEntityPages,
1321
+ qe as createProductAgentTaskPageTitleDocument,
1322
+ te as formatProductAgentTaskPageTitle,
1323
+ Se as hasProductAgentPaidCreditFallback,
1324
+ Z as isProductAgentAuthReconnectError,
1325
+ Re as isProductAgentRuntimeCommand,
1326
+ Q as mergeProductAgentEntityPages,
1300
1327
  y as normalizeProductAgentEntityPage,
1301
- W as readLocalStorageInteractionDecisions,
1302
- be as reconcileProductAgentSubmissionGate,
1303
- _e as resolveProductAgentBillingPresentation,
1304
- Ae as resolveProductAgentComposerAction,
1305
- ve as resolveProductAgentWidgetPresentation,
1306
- Q as selectProductAgentQueryEntities
1328
+ Y as readLocalStorageInteractionDecisions,
1329
+ _e as reconcileProductAgentSubmissionGate,
1330
+ Ae as resolveProductAgentBillingPresentation,
1331
+ Ee as resolveProductAgentComposerAction,
1332
+ Ie as resolveProductAgentWidgetPresentation,
1333
+ G as selectProductAgentQueryEntities
1307
1334
  };