@pluno/product-agent-web 0.1.236 → 0.1.238

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,4 +1,4 @@
1
- function f(s) {
1
+ function m(s) {
2
2
  return {
3
3
  key: s,
4
4
  status: "not_requested",
@@ -10,7 +10,7 @@ function f(s) {
10
10
  }
11
11
  class O {
12
12
  constructor(e, t, i = (n, r) => r) {
13
- this.loader = t, this.merge = i, this.state = f(e);
13
+ this.loader = t, this.merge = i, this.state = m(e);
14
14
  }
15
15
  loader;
16
16
  merge;
@@ -25,10 +25,10 @@ class O {
25
25
  return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
26
26
  }
27
27
  setKey(e) {
28
- e !== this.state.key && (this.state = f(e), this.trailingLoad = null, this.publish());
28
+ e !== this.state.key && (this.state = m(e), this.trailingLoad = null, this.publish());
29
29
  }
30
30
  reset() {
31
- this.state = f(this.state.key), this.trailingLoad = null, this.publish();
31
+ this.state = m(this.state.key), this.trailingLoad = null, this.publish();
32
32
  }
33
33
  invalidate() {
34
34
  this.state = {
@@ -83,7 +83,7 @@ class O {
83
83
  for (const e of this.listeners) e(this.state);
84
84
  }
85
85
  }
86
- function m(s) {
86
+ function y(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,34 +93,34 @@ function m(s) {
93
93
  nextCursor: s.nextCursor
94
94
  };
95
95
  }
96
- function $(s, e, t) {
96
+ function F(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 F(s) {
103
+ function B(s) {
104
104
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
105
105
  }
106
- function ue(s) {
106
+ function he(s) {
107
107
  return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
108
108
  }
109
- function pe(s, e) {
109
+ function ge(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 he(s) {
112
+ function fe(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 ge(s) {
117
+ function me(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 fe(s) {
120
+ function ye(s) {
121
121
  return s.submissionAllowed && s.isAuthenticated && s.hasWorkspace && !s.isWebsiteBlocked && s.isCurrentPageResolved && !s.isSubmitting && !s.hasPendingMessage;
122
122
  }
123
- function me(s) {
123
+ function ve(s) {
124
124
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
125
125
  return s.hasRunningAssistantTurn && !e ? {
126
126
  action: "stop",
@@ -131,23 +131,23 @@ function me(s) {
131
131
  };
132
132
  }
133
133
  const Q = "Pluno is reconnecting. Try again in a moment.";
134
- function B(s) {
134
+ function G(s) {
135
135
  return (s instanceof Error ? s.message : s) === Q;
136
136
  }
137
- class ye {
137
+ class be {
138
138
  constructor(e, t, i = 20) {
139
139
  this.loadPage = t, this.limit = i, this.recentQuery = new O(
140
140
  `${e}:recent`,
141
- async ({ cursor: n }) => m(
141
+ async ({ cursor: n }) => y(
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
- $
147
+ F
148
148
  ), this.pinnedQuery = new O(
149
149
  `${e}:pinned`,
150
- async () => m({
150
+ async () => y({
151
151
  entities: await this.loadAllPinned(),
152
152
  nextCursor: null
153
153
  })
@@ -167,18 +167,18 @@ class ye {
167
167
  activityReconciliationScheduled = !1;
168
168
  getState() {
169
169
  const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), i = [
170
- ...h(t.data),
171
- ...h(e.data)
172
- ], n = new Map(i.map((c) => [c.id, c])), r = Array.from(n.values()).map(
173
- (c) => this.applyOverrides(c, this.completedRefreshSequence)
174
- ), a = Array.from(this.optimisticEntities.values()).filter((c) => !n.has(c.id)).reverse(), o = e.data || t.data || a.length > 0 ? m({
175
- entities: [...a, ...r],
170
+ ...g(t.data),
171
+ ...g(e.data)
172
+ ], n = new Map(i.map((d) => [d.id, d])), r = Array.from(n.values()).map(
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({
175
+ entities: [...o, ...r],
176
176
  nextCursor: e.data?.nextCursor ?? null
177
177
  }) : null;
178
178
  return {
179
179
  key: e.key.slice(0, -7),
180
- status: z(e, t),
181
- data: o,
180
+ status: H(e, t),
181
+ data: a,
182
182
  error: e.error ?? t.error,
183
183
  requestId: Math.max(e.requestId, t.requestId),
184
184
  updatedAt: Math.max(e.updatedAt ?? 0, t.updatedAt ?? 0) || null
@@ -243,8 +243,8 @@ class ye {
243
243
  }
244
244
  reconcileDurableEntities() {
245
245
  const e = [
246
- ...h(this.pinnedQuery.getState().data),
247
- ...h(this.recentQuery.getState().data)
246
+ ...g(this.pinnedQuery.getState().data),
247
+ ...g(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 ye {
283
283
  for (const e of this.listeners) e(this.getState());
284
284
  }
285
285
  }
286
- function h(s) {
286
+ function g(s) {
287
287
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
288
288
  }
289
- function z(s, e) {
289
+ function H(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 R(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,25 +305,25 @@ 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 G(s) {
308
+ function Z(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 H(s, e) {
312
+ function V(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) => R(r.created_at).localeCompare(R(a.created_at)) || r.id.localeCompare(a.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 ve {
323
+ class Ie {
324
324
  constructor(e, t = null) {
325
325
  this.storage = e, t && (this.decisions = new Map(
326
- t.filter(E).map((i) => [this.getDecisionKey(i), i])
326
+ t.filter(T).map((i) => [this.getDecisionKey(i), i])
327
327
  ), this.initialized = !0);
328
328
  }
329
329
  storage;
@@ -344,8 +344,8 @@ class ve {
344
344
  const i = JSON.stringify([t.conversation_id, t.id]), n = this.sources.get(i);
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
- 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(G({ ...t, lifecycle: r, payload: a }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
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(Z({ ...t, lifecycle: r, payload: o }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
349
349
  }
350
350
  }
351
351
  /** @internal */
@@ -357,38 +357,38 @@ class ve {
357
357
  if (!this.conversationReader) return;
358
358
  const t = { share: null, integrations: [], channel: null }, i = e ? this.conversationReader(e) : null;
359
359
  if (!i) return t;
360
- const n = [...this.sources.values()].filter((r) => r.conversation_id === e).sort((r, a) => r.version - a.version || r.id.localeCompare(a.id));
360
+ const n = [...this.sources.values()].filter((r) => r.conversation_id === e).sort((r, o) => r.version - o.version || r.id.localeCompare(o.id));
361
361
  for (const r of n) {
362
- const a = r.payload;
363
- if (a.kind === "sharing") {
364
- if (t.share = null, !a.eligible || r.lifecycle !== "pending" || r.invocation !== "user" || !["main_web_chat", "automation", "extension_sidepanel", "extension_widget"].includes(r.entry_surface ?? "")) continue;
365
- const o = r.user_message_id ? i.items[r.user_message_id] : null;
362
+ const o = r.payload;
363
+ if (o.kind === "sharing") {
364
+ if (t.share = null, !o.eligible || r.lifecycle !== "pending" || r.invocation !== "user" || !["main_web_chat", "automation", "extension_sidepanel", "extension_widget"].includes(r.entry_surface ?? "")) continue;
365
+ const a = r.user_message_id ? i.items[r.user_message_id] : null;
366
366
  t.share = {
367
367
  revision: r.version,
368
368
  candidate: {
369
369
  id: r.id,
370
- variant: a.variant,
371
- userPrompt: o?.type === "user_message" ? o.data.content : "",
370
+ variant: o.variant,
371
+ userPrompt: a?.type === "user_message" ? a.data.content : "",
372
372
  assistantAnswer: ""
373
373
  },
374
- terminal: !a.wait_for_terminal || H(i, r.user_message_id)
374
+ terminal: !o.wait_for_terminal || V(i, r.user_message_id)
375
375
  };
376
- } else a.kind === "integration_auth" ? t.integrations.push({
376
+ } else o.kind === "integration_auth" ? t.integrations.push({
377
377
  revision: r.version,
378
378
  request: {
379
379
  type: "pipedream_auth_required",
380
- authRequestId: a.request_id,
381
- appSlug: a.app_slug,
382
- appName: a.app_name,
383
- appLogo: a.app_logo ?? void 0,
384
- expiresAt: a.expires_at
380
+ authRequestId: o.request_id,
381
+ appSlug: o.app_slug,
382
+ appName: o.app_name,
383
+ appLogo: o.app_logo ?? void 0,
384
+ expiresAt: o.expires_at
385
385
  },
386
- lifecycle: r.lifecycle === "pending" && Date.parse(a.expires_at) <= Date.now() ? "expired" : r.lifecycle
386
+ lifecycle: r.lifecycle === "pending" && Date.parse(o.expires_at) <= Date.now() ? "expired" : r.lifecycle
387
387
  }) : t.channel = { revision: r.version, request: {
388
388
  type: "personal_channel_connection_required",
389
- requestId: a.request_id,
390
- channel: a.channel,
391
- managementUrl: a.management_url
389
+ requestId: o.request_id,
390
+ channel: o.channel,
391
+ managementUrl: o.management_url
392
392
  }, lifecycle: r.lifecycle };
393
393
  }
394
394
  return t;
@@ -401,7 +401,7 @@ class ve {
401
401
  if (this.initialized) return;
402
402
  const e = await this.storage.load();
403
403
  this.decisions = new Map(
404
- e.filter(E).map((t) => [this.getDecisionKey(t), t])
404
+ e.filter(T).map((t) => [this.getDecisionKey(t), t])
405
405
  ), this.initialized = !0;
406
406
  }
407
407
  isEligible(e, t = Date.now()) {
@@ -437,7 +437,7 @@ class ve {
437
437
  async applyAction(e, t, i) {
438
438
  if (!e.allowedActions.includes(t))
439
439
  throw new Error(`Interaction ${e.key} does not allow ${t}.`);
440
- if (!L(t))
440
+ if (!$(t))
441
441
  throw new Error(`Interaction action ${t} is not a persistence decision.`);
442
442
  const n = i.now ?? /* @__PURE__ */ new Date(), r = {
443
443
  promptKey: e.key,
@@ -446,8 +446,8 @@ class ve {
446
446
  scope: e.scope,
447
447
  decidedAt: n.toISOString(),
448
448
  nextEligibleAt: this.getNextEligibleAt(e, t, n, i.snoozeUntil)
449
- }, a = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), o = new Map(this.decisions);
450
- return o.set(a, r), await this.storage.save([...o.values()]), this.decisions = o, r;
449
+ }, o = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), a = new Map(this.decisions);
450
+ return a.set(o, r), await this.storage.save([...a.values()]), this.decisions = a, r;
451
451
  }
452
452
  isDecisionEligible(e, t) {
453
453
  return e ? e.action === "dismiss" || e.action === "never" || e.action === "dont_show_again" ? !1 : !e.nextEligibleAt || Date.parse(e.nextEligibleAt) <= t : !0;
@@ -473,38 +473,38 @@ class ve {
473
473
  return `${_(e.scope)}:category:${e.category}`;
474
474
  }
475
475
  }
476
- function be(s, e) {
476
+ function _e(s, e) {
477
477
  return {
478
- load: async () => V(s, e),
478
+ load: async () => J(s, e),
479
479
  save: async (t) => s.setItem(e, JSON.stringify(t))
480
480
  };
481
481
  }
482
- function V(s, e) {
482
+ function J(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(E) : [];
486
+ return Array.isArray(i) ? i.filter(T) : [];
487
487
  }
488
488
  function _(s) {
489
489
  return `${s.level}:${s.key}`;
490
490
  }
491
- function L(s) {
491
+ function $(s) {
492
492
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
493
493
  }
494
- function E(s) {
494
+ function T(s) {
495
495
  if (!s || typeof s != "object") return !1;
496
496
  const e = s;
497
- return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && L(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
497
+ return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && $(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
498
498
  }
499
- const Z = {
499
+ const W = {
500
500
  working: "⏳",
501
501
  completed: "✅",
502
502
  failed: "❗",
503
503
  stopped: "⏹️"
504
- }, J = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
- function W(s, e) {
506
- if (!e) return S(s);
507
- const t = S(s), i = `${Z[e]} Pluno`;
504
+ }, Y = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
+ function X(s, e) {
506
+ if (!e) return I(s);
507
+ const t = I(s), i = `${W[e]} Pluno`;
508
508
  return t ? `${i}: ${t}` : i;
509
509
  }
510
510
  class Se {
@@ -529,10 +529,10 @@ class Se {
529
529
  }
530
530
  applyStatus(e) {
531
531
  const t = this.titleDocument.getTitle();
532
- t !== this.lastAppliedTitle && (this.baseTitle = S(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 ? S(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() {
@@ -541,11 +541,11 @@ class Se {
541
541
  applyTitle() {
542
542
  if (!this.status)
543
543
  return;
544
- const e = W(this.baseTitle, this.status);
544
+ const e = X(this.baseTitle, this.status);
545
545
  this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
546
546
  }
547
547
  }
548
- function _e(s) {
548
+ function Ae(s) {
549
549
  return {
550
550
  getTitle: () => s.title,
551
551
  setTitle: (e) => {
@@ -561,10 +561,41 @@ function _e(s) {
561
561
  }
562
562
  };
563
563
  }
564
- function S(s) {
565
- return s.replace(J, "");
564
+ function I(s) {
565
+ return s.replace(Y, "");
566
+ }
567
+ const p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
568
+ function ee(s) {
569
+ if (!s || typeof s != "object") return !1;
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
+ 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
+ }
573
+ function L(s) {
574
+ if (!s || typeof s != "object") return !1;
575
+ const e = s;
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
+ }
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), te = (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 U(s) {
580
+ if (!s || typeof s != "object") return !1;
581
+ 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 || te(e.createdAt));
583
+ }
584
+ function se(s) {
585
+ if (!s || typeof s != "object") return !1;
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 || ee(e.owner));
566
588
  }
567
- function Y(s) {
589
+ function K(s) {
590
+ if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
591
+ const e = (i) => {
592
+ if (!i || typeof i != "object") return !1;
593
+ const n = i;
594
+ return Object.keys(i).every((r) => [...R, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || se(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));
595
+ }, t = s;
596
+ return (t.before === null || e(t.before)) && e(t.current);
597
+ }
598
+ function ie(s) {
568
599
  if (s.details !== void 0 && !b(s.details))
569
600
  throw new TypeError("Product Agent transported error details must be JSON-safe.");
570
601
  return {
@@ -574,17 +605,46 @@ function Y(s) {
574
605
  ...s.details === void 0 ? {} : { details: s.details }
575
606
  };
576
607
  }
577
- function I(s, e = "runtime_error") {
578
- const t = s !== null && typeof s == "object" ? s : null, i = typeof s == "string" ? s : t && "message" in t && typeof t.message == "string" ? t.message : "", n = t && "code" in t && typeof t.code == "string" && t.code.trim() ? t.code : e, r = t && "details" in t ? t.details : null;
579
- return Y({
608
+ function S(s, e = "runtime_error") {
609
+ const t = s !== null && typeof s == "object" ? s : null, i = typeof s == "string" ? s : t && "message" in t && typeof t.message == "string" ? t.message : "", n = t && "code" in t && typeof t.code == "string" && t.code.trim() ? t.code : e, r = t && "details" in t ? t.details : null, o = r && typeof r == "object" ? r : {}, a = {
610
+ ...typeof o.securitySettingsUrl == "string" ? { securitySettingsUrl: o.securitySettingsUrl } : {},
611
+ ...typeof o.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(o.transportCode) ? { transportCode: o.transportCode } : {},
612
+ ...typeof o.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(o.requestId) ? { requestId: o.requestId } : {},
613
+ ...typeof o.durationMs == "number" && Number.isFinite(o.durationMs) && o.durationMs >= 0 ? { durationMs: o.durationMs } : {},
614
+ ...typeof o.successfulRequests == "number" && Number.isSafeInteger(o.successfulRequests) && o.successfulRequests >= 0 ? { successfulRequests: o.successfulRequests } : {}
615
+ };
616
+ return ie({
580
617
  code: n,
581
618
  message: i.trim() && i.trim() !== "[object Object]" ? i : "The Product Agent operation failed. Try again.",
582
619
  retryable: !!(t && "retryable" in t && t.retryable === !0),
583
- // Only this public recovery action is consumed from error details. Do not copy arbitrary thrown metadata.
584
- ...r && typeof r == "object" && "securitySettingsUrl" in r && typeof r.securitySettingsUrl == "string" ? { details: { securitySettingsUrl: r.securitySettingsUrl } } : {}
620
+ ...Object.keys(a).length ? { details: a } : {}
585
621
  });
586
622
  }
587
- const X = [
623
+ function z(s) {
624
+ if (!s || typeof s != "object") return !1;
625
+ const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
626
+ return Object.keys(e).every((i) => [
627
+ "requestId",
628
+ "method",
629
+ "route",
630
+ "status",
631
+ "abortTrigger",
632
+ "owner",
633
+ "elapsedMs",
634
+ "attempt",
635
+ "category",
636
+ "responseHeadersMs",
637
+ "responseBodyMs",
638
+ "queryRequestId",
639
+ "ownerId",
640
+ "authorityGeneration",
641
+ "sessionId",
642
+ "release",
643
+ "upstreamRequestId",
644
+ "upstreamTraceId"
645
+ ].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));
646
+ }
647
+ const ne = [
588
648
  "submit",
589
649
  "stop",
590
650
  "staging_ipc",
@@ -620,13 +680,13 @@ const X = [
620
680
  "stopping_painted",
621
681
  "progress_painted",
622
682
  "stopped_painted"
623
- ], ee = Math.random().toString(36).slice(2);
624
- let te = 0;
625
- const C = () => `timing:${ee}:${++te}`, g = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
626
- function T(s) {
683
+ ], re = Math.random().toString(36).slice(2);
684
+ let oe = 0;
685
+ const C = () => `timing:${re}:${++oe}`, f = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
686
+ function M(s) {
627
687
  if (!s || typeof s != "object") return !1;
628
688
  const e = s;
629
- 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"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && X.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;
689
+ 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"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && ne.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;
630
690
  }
631
691
  function k(s, e) {
632
692
  if (!s) return {
@@ -634,79 +694,53 @@ function k(s, e) {
634
694
  },
635
695
  measure: (n, r) => r()
636
696
  };
637
- const t = performance.now(), i = (n, r, a, o) => {
638
- const c = {
697
+ const t = performance.now(), i = (n, r, o, a) => {
698
+ const d = {
639
699
  ...e,
640
700
  stage: n,
641
701
  status: r,
642
- spanId: o,
702
+ spanId: a,
643
703
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
644
- durationMs: Math.max(0, Math.round(performance.now() - a))
704
+ durationMs: Math.max(0, Math.round(performance.now() - o))
645
705
  };
646
- s && T(c) && Promise.resolve().then(() => s(c)).catch(() => {
706
+ s && M(d) && Promise.resolve().then(() => s(d)).catch(() => {
647
707
  });
648
708
  };
649
709
  return {
650
710
  mark: (n) => i(n, "observed", t, C()),
651
711
  measure(n, r) {
652
- const a = performance.now(), o = C();
653
- return i(n, "started", a, o), r().then(
654
- (c) => (i(n, "completed", a, o), c),
655
- (c) => {
656
- throw i(n, "failed", a, o), c;
712
+ const o = performance.now(), a = C();
713
+ return i(n, "started", o, a), r().then(
714
+ (d) => (i(n, "completed", o, a), d),
715
+ (d) => {
716
+ throw i(n, "failed", o, a), d;
657
717
  }
658
718
  );
659
719
  }
660
720
  };
661
721
  }
662
- const y = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
663
- function se(s) {
664
- if (!s || typeof s != "object") return !1;
665
- 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) && y(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 || y(r) !== null) && (n.projectionReady === null || typeof n.projectionReady == "boolean");
666
- return Object.keys(e).every((n) => ["ownerId", "revision", "dropped", "lastIntent", "lastSelection", "transitions"].includes(n)) && y(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);
667
- }
668
- const x = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], P = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), v = (s) => s === null || P(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));
669
- function U(s) {
670
- if (!s || typeof s != "object") return !1;
671
- const e = s;
672
- return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && v(e.sessionId) && P(e.itemId) && v(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && v(e.runId) && (e.createdAt === null || ie(e.createdAt));
673
- }
674
- function ne(s) {
675
- if (!s || typeof s != "object") return !1;
676
- const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
677
- 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 || y(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));
678
- }
679
- function K(s) {
680
- if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
681
- const e = (i) => {
682
- if (!i || typeof i != "object") return !1;
683
- const n = i;
684
- return Object.keys(i).every((r) => [...x, "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" && x.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(P));
685
- }, t = s;
686
- return (t.before === null || e(t.before)) && e(t.current);
687
- }
688
722
  const A = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
689
- function re(s) {
723
+ function ae(s) {
690
724
  if (!s || typeof s != "object") return !1;
691
725
  const e = s;
692
726
  return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && A(e.sessionId) && A(e.responseItemId) && A(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
693
727
  }
694
728
  const D = 500;
695
- function oe(s) {
729
+ function de(s) {
696
730
  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();
697
731
  return e.length > D ? `${e.slice(0, D - 1)}…` : e;
698
732
  }
699
- function ae(s, e, t = "stopped", i) {
733
+ function ce(s, e, t = "stopped", i) {
700
734
  const n = new Set(i ?? [
701
735
  s.assistantDraftRespondsToUserMessageId,
702
736
  s.activeResponseUserMessageId,
703
- s.messages.filter((o) => o.role === "user").slice(-1)[0]?.id
704
- ].filter((o) => !!o)), r = s.messages.filter((o) => !(o.dataType === "run_status" && o.loading && n.has(o.respondsToUserMessageId ?? ""))).map((o) => n.has(o.respondsToUserMessageId ?? "") ? { ...o, loading: !1 } : o);
705
- for (const o of n)
706
- r.some((c) => c.respondsToUserMessageId === o && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary")) || r.some((c) => c.role === "user" && c.id === o) && r.push({ id: `local-interrupted:${o}`, role: "system", dataType: "run_status", content: t === "stopping" ? "Stopping…" : "Run stopped by user.", createdAt: e, respondsToUserMessageId: o });
707
- const a = s.segments?.map((o) => ({ ...o, outcomeIds: [
708
- ...o.outcomeIds,
709
- ...r.filter((c) => c.id === `local-interrupted:${o.userMessageId}` && !o.outcomeIds.includes(c.id)).map((c) => c.id)
737
+ s.messages.filter((a) => a.role === "user").slice(-1)[0]?.id
738
+ ].filter((a) => !!a)), r = s.messages.filter((a) => !(a.dataType === "run_status" && a.loading && n.has(a.respondsToUserMessageId ?? ""))).map((a) => n.has(a.respondsToUserMessageId ?? "") ? { ...a, loading: !1 } : a);
739
+ for (const a of n)
740
+ r.some((d) => d.respondsToUserMessageId === a && (d.dataType === "run_status" || d.dataType === "run_error" || d.role === "assistant" && d.phase !== "commentary")) || r.some((d) => d.role === "user" && d.id === a) && r.push({ id: `local-interrupted:${a}`, role: "system", dataType: "run_status", content: t === "stopping" ? "Stopping…" : "Run stopped by user.", createdAt: e, respondsToUserMessageId: a });
741
+ const o = s.segments?.map((a) => ({ ...a, outcomeIds: [
742
+ ...a.outcomeIds,
743
+ ...r.filter((d) => d.id === `local-interrupted:${a.userMessageId}` && !a.outcomeIds.includes(d.id)).map((d) => d.id)
710
744
  ] }));
711
745
  return {
712
746
  ...s,
@@ -715,7 +749,7 @@ function ae(s, e, t = "stopped", i) {
715
749
  isRetrying: !1,
716
750
  pendingMessageStatus: null,
717
751
  turnPhase: null,
718
- segments: a,
752
+ segments: o,
719
753
  activity: { phase: t, activeItemId: null },
720
754
  isLoadingSession: s.isLoadingSession && r.length === 0,
721
755
  taskStatus: t === "stopped" ? "stopped" : null,
@@ -723,7 +757,7 @@ function ae(s, e, t = "stopped", i) {
723
757
  lastErrorCode: null
724
758
  };
725
759
  }
726
- const ce = {
760
+ const le = {
727
761
  "stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
728
762
  "in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
729
763
  "stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
@@ -739,10 +773,10 @@ const ce = {
739
773
  "thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
740
774
  "thinking-without-progress": "Thinking remained visible without progress for five minutes."
741
775
  };
742
- function le(s) {
743
- return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ce, s.slice(13));
776
+ function ue(s) {
777
+ return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(le, s.slice(13));
744
778
  }
745
- function q(s) {
779
+ function x(s) {
746
780
  return {
747
781
  ...s.id === void 0 ? {} : { id: s.id },
748
782
  name: s.name,
@@ -753,7 +787,7 @@ function q(s) {
753
787
  ...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
754
788
  };
755
789
  }
756
- function Ie(s) {
790
+ function we(s) {
757
791
  if (!s || typeof s != "object" || !("type" in s)) return !1;
758
792
  const e = s;
759
793
  switch (e.type) {
@@ -764,15 +798,15 @@ function Ie(s) {
764
798
  case "run.stop":
765
799
  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);
766
800
  case "runtime.report_response_visibility":
767
- return re(e.observation);
801
+ return ae(e.observation);
768
802
  case "runtime.warmup":
769
803
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
770
804
  case "runtime.report_operation_timing":
771
- return T(e.timing);
805
+ return M(e.timing);
772
806
  case "runtime.report_displayed_error":
773
- return (e.renderedError === void 0 || U(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);
807
+ return (e.httpRequest === void 0 || z(e.httpRequest)) && (e.historyRefreshFailure === void 0 || L(e.historyRefreshFailure)) && (e.renderedError === void 0 || U(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);
774
808
  case "runtime.report_invalid_state_transition":
775
- return (e.uiInvariant === void 0 || K(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || le(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
809
+ return (e.uiInvariant === void 0 || K(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || ue(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
776
810
  case "runtime.widget_lifecycle":
777
811
  return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
778
812
  case "session.load":
@@ -800,7 +834,7 @@ function Ie(s) {
800
834
  return !1;
801
835
  }
802
836
  }
803
- class Ae {
837
+ class Te {
804
838
  constructor(e, t, i) {
805
839
  this.adapter = t, this.state = w(e), this.model = i;
806
840
  }
@@ -811,7 +845,7 @@ class Ae {
811
845
  interactionListeners = /* @__PURE__ */ new Set();
812
846
  accountListeners = /* @__PURE__ */ new Set();
813
847
  state;
814
- sessionHistoryState = f("unavailable");
848
+ sessionHistoryState = m("unavailable");
815
849
  model;
816
850
  interactions = [];
817
851
  account = null;
@@ -832,32 +866,32 @@ class Ae {
832
866
  const e = w(this.state);
833
867
  for (const [t, i] of this.submissionPreviews)
834
868
  e.messages.some((n) => n.id === t) || (e.messages.push({ ...i.message, attachments: i.message.attachments?.map((n) => ({ ...n })) }), e.segments && (e.segments = [...e.segments, { id: t, userMessageId: t, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, i.pending && (e.activeResponseUserMessageId = t, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), i.error && (e.lastError = i.error, e.lastErrorCode = "message_delivery_failed"));
835
- return this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed"), this.pendingStop ? ae(e, "", "stopping", this.pendingStop.userMessageIds) : e;
869
+ return this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed"), this.pendingStop ? ce(e, "", "stopping", this.pendingStop.userMessageIds) : e;
836
870
  }
837
871
  updateProjection(e, t, i, n, r) {
838
872
  if (this.destroyed) return;
839
- const a = this.getState();
840
- (a.user?.id !== e.user?.id || a.selectionKey !== void 0 && a.selectionKey !== e.selectionKey || a.selectionKey === void 0 && a.sessionId !== null && a.sessionId !== e.sessionId) && (this.cancelPendingSubmissions(), this.submissionPreviews.clear());
841
- for (const o of e.messages)
842
- o.role === "user" && this.submissionPreviews.delete(o.id);
843
- if (this.state = w(e), a.user?.id === e.user?.id)
844
- for (const o of this.state.messages) {
845
- if (o.role !== "user" || !o.attachments?.length) continue;
846
- const c = a.messages.find((l) => l.role === "user" && l.id === o.id);
847
- a.sessionId !== e.sessionId && !(a.sessionId === null && c) || (o.attachments = de(c?.attachments, o.attachments));
873
+ const o = this.getState();
874
+ (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());
875
+ for (const a of e.messages)
876
+ a.role === "user" && this.submissionPreviews.delete(a.id);
877
+ if (this.state = w(e), o.user?.id === e.user?.id)
878
+ for (const a of this.state.messages) {
879
+ if (a.role !== "user" || !a.attachments?.length) continue;
880
+ const d = o.messages.find((c) => c.role === "user" && c.id === a.id);
881
+ o.sessionId !== e.sessionId && !(o.sessionId === null && d) || (a.attachments = pe(d?.attachments, a.attachments));
848
882
  }
849
883
  if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
850
884
  this.sessionHistoryState = j(i);
851
- for (const o of this.sessionHistoryListeners)
852
- o(this.getSessionHistoryState());
885
+ for (const a of this.sessionHistoryListeners)
886
+ a(this.getSessionHistoryState());
853
887
  }
854
888
  if (n && JSON.stringify(n) !== JSON.stringify(this.interactions)) {
855
- this.interactions = n.map((o) => ({ ...o }));
856
- for (const o of this.interactionListeners) o(this.getInteractions());
889
+ this.interactions = n.map((a) => ({ ...a }));
890
+ for (const a of this.interactionListeners) a(this.getInteractions());
857
891
  }
858
892
  if (r !== void 0 && JSON.stringify(r) !== JSON.stringify(this.account)) {
859
893
  this.account = r ? { ...r } : null;
860
- for (const o of this.accountListeners) o(this.getAccount());
894
+ for (const a of this.accountListeners) a(this.getAccount());
861
895
  }
862
896
  this.emit("state", this.getState());
863
897
  }
@@ -879,7 +913,7 @@ class Ae {
879
913
  this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
880
914
  }
881
915
  reportOperationTiming(e) {
882
- !this.destroyed && T(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
916
+ !this.destroyed && M(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
883
917
  });
884
918
  }
885
919
  reportResponseVisibility(e) {
@@ -895,13 +929,16 @@ class Ae {
895
929
  }).catch(() => {
896
930
  });
897
931
  }
898
- reportDisplayedError(e, t, i, n) {
899
- n !== void 0 && !U(n) || this.adapter.dispatch({
932
+ reportDisplayedError(e, t, i, n, r) {
933
+ const o = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
934
+ n !== void 0 && !U(n) || r !== void 0 && !L(r) || this.adapter.dispatch({
900
935
  type: "runtime.report_displayed_error",
901
936
  reason: e,
902
937
  errorFingerprint: t,
903
938
  ...n ? { renderedError: n } : {},
904
- ...i ? { displayedMessage: oe(i) } : {}
939
+ ...r ? { historyRefreshFailure: r } : {},
940
+ ...z(o) ? { httpRequest: o } : {},
941
+ ...i ? { displayedMessage: de(i) } : {}
905
942
  }).catch(() => {
906
943
  });
907
944
  }
@@ -909,22 +946,22 @@ class Ae {
909
946
  const i = e.trim(), n = t.attachments ?? [];
910
947
  if (!i && n.length === 0) return Promise.resolve(null);
911
948
  this.pendingStop = null, this.stopError = null;
912
- const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), a = t.submittedAt ?? Date.now(), o = this.submissionGeneration;
913
- this.pendingTransfers.set(r, n.flatMap((l) => l.id ? [l.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
949
+ const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), o = t.submittedAt ?? Date.now(), a = this.submissionGeneration;
950
+ this.pendingTransfers.set(r, n.flatMap((c) => c.id ? [c.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
914
951
  id: r,
915
952
  role: "user",
916
953
  content: i,
917
954
  createdAt: "",
918
- attachments: n.map((l) => ({ ...l }))
955
+ attachments: n.map((c) => ({ ...c }))
919
956
  } });
920
- const c = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt: a }, o);
921
- return this.emit("state", this.getState()), c.finally(() => {
957
+ const d = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt: o }, a);
958
+ return this.emit("state", this.getState()), d.finally(() => {
922
959
  this.pendingTransfers.delete(r);
923
960
  });
924
961
  }
925
962
  async sendMessageNow(e, t, i) {
926
- const n = e, r = t.clientMessageId, a = k((l) => {
927
- i === this.submissionGeneration && this.reportOperationTiming(l);
963
+ const n = e, r = t.clientMessageId, o = k((c) => {
964
+ i === this.submissionGeneration && this.reportOperationTiming(c);
928
965
  }, {
929
966
  operation: "send",
930
967
  layer: "renderer",
@@ -932,12 +969,12 @@ class Ae {
932
969
  clientMessageId: r,
933
970
  sessionId: this.state.sessionId
934
971
  });
935
- a.mark("submit");
936
- let o = t.attachments ?? [], c = !1;
972
+ o.mark("submit");
973
+ let a = t.attachments ?? [], d = !1;
937
974
  if (i !== this.submissionGeneration) return null;
938
975
  try {
939
- if (!await a.measure("staging_ipc", async () => {
940
- const d = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
976
+ if (!await o.measure("staging_ipc", async () => {
977
+ const l = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
941
978
  type: "conversation.stage",
942
979
  initiatedBy: t.initiatedBy,
943
980
  invocation: t.invocation,
@@ -946,27 +983,27 @@ class Ae {
946
983
  clientMessageId: r,
947
984
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
948
985
  // Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
949
- attachments: o.length > 0 ? o.map(q) : void 0,
986
+ attachments: a.length > 0 ? a.map(x) : void 0,
950
987
  submittedAt: t.submittedAt
951
988
  }) });
952
- return d ? (await d.result, d) : null;
989
+ return l ? (await l.result, l) : null;
953
990
  }) || i !== this.submissionGeneration) return null;
954
- if (c = !0, o.length > 0) {
991
+ if (d = !0, a.length > 0) {
955
992
  if (!this.adapter.uploadAttachment)
956
993
  throw new Error("The runtime does not support attachments.");
957
- const d = [];
958
- for (const u of o) {
994
+ const l = [];
995
+ for (const u of a) {
959
996
  if (u.sandboxPath || u.storageKey) {
960
- d.push(u);
997
+ l.push(u);
961
998
  continue;
962
999
  }
963
- const M = u.id ? this.attachmentFiles.get(u.id) : void 0;
964
- if (!M) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
965
- if (d.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(M, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
1000
+ const P = u.id ? this.attachmentFiles.get(u.id) : void 0;
1001
+ if (!P) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
1002
+ if (l.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(P, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
966
1003
  }
967
- o = d;
1004
+ a = l;
968
1005
  }
969
- const p = await a.measure("send_ipc", () => this.adapter.dispatch({
1006
+ const h = await o.measure("send_ipc", () => this.adapter.dispatch({
970
1007
  type: "conversation.send",
971
1008
  content: n,
972
1009
  clientMessageId: r,
@@ -974,23 +1011,23 @@ class Ae {
974
1011
  invocation: t.invocation,
975
1012
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
976
1013
  ...t.automationOnboarding ? { automationOnboarding: !0 } : {},
977
- attachments: o.length > 0 ? o.map(q) : void 0
1014
+ attachments: a.length > 0 ? a.map(x) : void 0
978
1015
  }));
979
1016
  if (i !== this.submissionGeneration) return null;
980
- for (const d of t.attachments ?? [])
981
- d.id && this.attachmentFiles.delete(d.id);
982
- return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), p?.clientMessageId ?? r;
983
- } catch (l) {
1017
+ for (const l of t.attachments ?? [])
1018
+ l.id && this.attachmentFiles.delete(l.id);
1019
+ return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), h?.clientMessageId ?? r;
1020
+ } catch (c) {
984
1021
  if (i !== this.submissionGeneration) return null;
985
- if (B(l))
986
- for (const d of t.attachments ?? [])
987
- d.id && this.attachmentFiles.delete(d.id);
988
- const p = this.submissionPreviews.get(r);
989
- throw p && (p.pending = !1, p.error = I(l).message, this.emit("state", this.getState())), c && await this.adapter.dispatch({
1022
+ if (G(c))
1023
+ for (const l of t.attachments ?? [])
1024
+ l.id && this.attachmentFiles.delete(l.id);
1025
+ const h = this.submissionPreviews.get(r);
1026
+ throw h && (h.pending = !1, h.error = S(c).message, this.emit("state", this.getState())), d && await this.adapter.dispatch({
990
1027
  type: "conversation.fail_staged",
991
1028
  clientMessageId: r,
992
- message: I(l).message
993
- }), l;
1029
+ message: S(c).message
1030
+ }), c;
994
1031
  }
995
1032
  }
996
1033
  getModel() {
@@ -1017,8 +1054,8 @@ class Ae {
1017
1054
  const e = this.getState(), t = this.cancelPendingSubmissions(), i = [...new Set([
1018
1055
  ...t,
1019
1056
  e.activeResponseUserMessageId,
1020
- e.messages.filter((o) => o.role === "user").slice(-1)[0]?.id
1021
- ].filter((o) => !!o))], n = k((o) => this.reportOperationTiming(o), {
1057
+ e.messages.filter((a) => a.role === "user").slice(-1)[0]?.id
1058
+ ].filter((a) => !!a))], n = k((a) => this.reportOperationTiming(a), {
1022
1059
  operation: "stop",
1023
1060
  layer: "renderer",
1024
1061
  requestId: crypto.randomUUID(),
@@ -1028,15 +1065,15 @@ class Ae {
1028
1065
  n.mark("stop");
1029
1066
  const r = { userMessageIds: i, promise: Promise.resolve() };
1030
1067
  this.pendingStop = r, r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
1031
- }, (o) => {
1032
- this.pendingStop === r && (this.stopError = I(o).message);
1068
+ }, (a) => {
1069
+ this.pendingStop === r && (this.stopError = S(a).message);
1033
1070
  }).finally(() => {
1034
1071
  this.pendingStop === r && (this.pendingStop = null, this.emit("state", this.getState()));
1035
1072
  }), this.emit("state", this.getState());
1036
- const a = r.promise;
1037
- return this.operationQueue = a.then(() => {
1073
+ const o = r.promise;
1074
+ return this.operationQueue = o.then(() => {
1038
1075
  }, () => {
1039
- }), a.then(() => {
1076
+ }), o.then(() => {
1040
1077
  });
1041
1078
  }
1042
1079
  cancelPendingSubmissions() {
@@ -1142,7 +1179,7 @@ class Ae {
1142
1179
  for (const n of i ?? []) n(t);
1143
1180
  }
1144
1181
  }
1145
- function de(s, e) {
1182
+ function pe(s, e) {
1146
1183
  if (!e || !s) return e;
1147
1184
  const t = /* @__PURE__ */ new Map();
1148
1185
  for (const i of s) {
@@ -1162,7 +1199,7 @@ function w(s) {
1162
1199
  messages: s.messages.map((e) => {
1163
1200
  const t = {
1164
1201
  ...e,
1165
- attachments: e.attachments?.map((a) => ({ ...a }))
1202
+ attachments: e.attachments?.map((o) => ({ ...o }))
1166
1203
  }, i = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
1167
1204
  return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
1168
1205
  value: r,
@@ -1181,33 +1218,33 @@ function w(s) {
1181
1218
  function j(s) {
1182
1219
  return {
1183
1220
  ...s,
1184
- data: s.data ? m({
1185
- entities: F(s.data).map((e) => ({ ...e })),
1221
+ data: s.data ? y({
1222
+ entities: B(s.data).map((e) => ({ ...e })),
1186
1223
  nextCursor: s.data.nextCursor
1187
1224
  }) : null
1188
1225
  };
1189
1226
  }
1190
1227
  export {
1191
1228
  Q as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1192
- ve as ProductAgentInteractionManager,
1229
+ Ie as ProductAgentInteractionManager,
1193
1230
  O as ProductAgentQueryController,
1194
- Ae as ProductAgentRemoteRuntimeClient,
1195
- ye as ProductAgentSessionHistoryManager,
1231
+ Te as ProductAgentRemoteRuntimeClient,
1232
+ be as ProductAgentSessionHistoryManager,
1196
1233
  Se as ProductAgentTaskPageTitleController,
1197
- fe as canSubmitPersonalProductAgentMessage,
1198
- be as createLocalStorageInteractionDecisionStorage,
1199
- f as createProductAgentQueryState,
1200
- _e as createProductAgentTaskPageTitleDocument,
1201
- W as formatProductAgentTaskPageTitle,
1202
- he as hasProductAgentPaidCreditFallback,
1203
- B as isProductAgentAuthReconnectError,
1204
- Ie as isProductAgentRuntimeCommand,
1205
- $ as mergeProductAgentEntityPages,
1206
- m as normalizeProductAgentEntityPage,
1207
- V as readLocalStorageInteractionDecisions,
1208
- pe as reconcileProductAgentSubmissionGate,
1209
- ge as resolveProductAgentBillingPresentation,
1210
- me as resolveProductAgentComposerAction,
1211
- ue as resolveProductAgentWidgetPresentation,
1212
- F as selectProductAgentQueryEntities
1234
+ ye as canSubmitPersonalProductAgentMessage,
1235
+ _e as createLocalStorageInteractionDecisionStorage,
1236
+ m as createProductAgentQueryState,
1237
+ Ae as createProductAgentTaskPageTitleDocument,
1238
+ X as formatProductAgentTaskPageTitle,
1239
+ fe as hasProductAgentPaidCreditFallback,
1240
+ G as isProductAgentAuthReconnectError,
1241
+ we as isProductAgentRuntimeCommand,
1242
+ F as mergeProductAgentEntityPages,
1243
+ y as normalizeProductAgentEntityPage,
1244
+ J as readLocalStorageInteractionDecisions,
1245
+ ge as reconcileProductAgentSubmissionGate,
1246
+ me as resolveProductAgentBillingPresentation,
1247
+ ve as resolveProductAgentComposerAction,
1248
+ he as resolveProductAgentWidgetPresentation,
1249
+ B as selectProductAgentQueryEntities
1213
1250
  };