@pluno/product-agent-web 0.1.236 → 0.1.237

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,7 +93,7 @@ function m(s) {
93
93
  nextCursor: s.nextCursor
94
94
  };
95
95
  }
96
- function $(s, e, t) {
96
+ function z(s, e, t) {
97
97
  if (t === "replace" || s === null) return e;
98
98
  const i = { ...s.entitiesById, ...e.entitiesById }, n = [...s.ids];
99
99
  for (const r of e.ids)
@@ -103,24 +103,24 @@ function $(s, e, t) {
103
103
  function F(s) {
104
104
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
105
105
  }
106
- function ue(s) {
106
+ function pe(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 he(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 ge(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 fe(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 me(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 ye(s) {
124
124
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
125
125
  return s.hasRunningAssistantTurn && !e ? {
126
126
  action: "stop",
@@ -134,20 +134,20 @@ const Q = "Pluno is reconnecting. Try again in a moment.";
134
134
  function B(s) {
135
135
  return (s instanceof Error ? s.message : s) === Q;
136
136
  }
137
- class ye {
137
+ class ve {
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
+ z
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,17 +167,17 @@ 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({
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
+ ), a = Array.from(this.optimisticEntities.values()).filter((d) => !n.has(d.id)).reverse(), o = e.data || t.data || a.length > 0 ? y({
175
175
  entities: [...a, ...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),
180
+ status: G(e, t),
181
181
  data: o,
182
182
  error: e.error ?? t.error,
183
183
  requestId: Math.max(e.requestId, t.requestId),
@@ -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,10 +283,10 @@ 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 G(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
292
  function R(s) {
@@ -305,11 +305,11 @@ 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 H(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 Z(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);
@@ -320,10 +320,10 @@ function H(s, e) {
320
320
  return !0;
321
321
  return !1;
322
322
  }
323
- class ve {
323
+ class be {
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;
@@ -345,7 +345,7 @@ class ve {
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(G({ ...t, lifecycle: r, payload: a }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
348
+ this.sources.set(i, N(H({ ...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 ve {
371
371
  userPrompt: o?.type === "user_message" ? o.data.content : "",
372
372
  assistantAnswer: ""
373
373
  },
374
- terminal: !a.wait_for_terminal || H(i, r.user_message_id)
374
+ terminal: !a.wait_for_terminal || Z(i, r.user_message_id)
375
375
  };
376
376
  } else a.kind === "integration_auth" ? t.integrations.push({
377
377
  revision: r.version,
@@ -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()) {
@@ -463,17 +463,17 @@ class ve {
463
463
  return null;
464
464
  }
465
465
  getDecisionKey(e) {
466
- const t = _(e.scope);
466
+ const t = S(e.scope);
467
467
  return e.action === "dont_show_again" ? `${t}:category:${e.category}` : `${t}:interaction:${e.promptKey}`;
468
468
  }
469
469
  getExactKey(e) {
470
- return `${_(e.scope)}:interaction:${e.key}`;
470
+ return `${S(e.scope)}:interaction:${e.key}`;
471
471
  }
472
472
  getCategoryKey(e) {
473
- return `${_(e.scope)}:category:${e.category}`;
473
+ return `${S(e.scope)}:category:${e.category}`;
474
474
  }
475
475
  }
476
- function be(s, e) {
476
+ function _e(s, e) {
477
477
  return {
478
478
  load: async () => V(s, e),
479
479
  save: async (t) => s.setItem(e, JSON.stringify(t))
@@ -483,28 +483,28 @@ function V(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
- function _(s) {
488
+ function S(s) {
489
489
  return `${s.level}:${s.key}`;
490
490
  }
491
491
  function L(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
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");
498
498
  }
499
- const Z = {
499
+ const J = {
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
+ }, W = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
+ function Y(s, e) {
506
+ if (!e) return _(s);
507
+ const t = _(s), i = `${J[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 = _(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 ? _(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 = Y(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 Ie(s) {
549
549
  return {
550
550
  getTitle: () => s.title,
551
551
  setTitle: (e) => {
@@ -561,10 +561,10 @@ function _e(s) {
561
561
  }
562
562
  };
563
563
  }
564
- function S(s) {
565
- return s.replace(J, "");
564
+ function _(s) {
565
+ return s.replace(W, "");
566
566
  }
567
- function Y(s) {
567
+ function X(s) {
568
568
  if (s.details !== void 0 && !b(s.details))
569
569
  throw new TypeError("Product Agent transported error details must be JSON-safe.");
570
570
  return {
@@ -576,7 +576,7 @@ function Y(s) {
576
576
  }
577
577
  function I(s, e = "runtime_error") {
578
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({
579
+ return X({
580
580
  code: n,
581
581
  message: i.trim() && i.trim() !== "[object Object]" ? i : "The Product Agent operation failed. Try again.",
582
582
  retryable: !!(t && "retryable" in t && t.retryable === !0),
@@ -584,7 +584,34 @@ function I(s, e = "runtime_error") {
584
584
  ...r && typeof r == "object" && "securitySettingsUrl" in r && typeof r.securitySettingsUrl == "string" ? { details: { securitySettingsUrl: r.securitySettingsUrl } } : {}
585
585
  });
586
586
  }
587
- const X = [
587
+ const p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
588
+ function ee(s) {
589
+ if (!s || typeof s != "object") return !1;
590
+ 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");
591
+ 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);
592
+ }
593
+ function U(s) {
594
+ if (!s || typeof s != "object") return !1;
595
+ const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
596
+ return Object.keys(e).every((i) => [
597
+ "requestId",
598
+ "method",
599
+ "route",
600
+ "status",
601
+ "abortTrigger",
602
+ "owner",
603
+ "elapsedMs",
604
+ "attempt",
605
+ "queryRequestId",
606
+ "ownerId",
607
+ "authorityGeneration",
608
+ "sessionId",
609
+ "release",
610
+ "upstreamRequestId",
611
+ "upstreamTraceId"
612
+ ].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) && 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));
613
+ }
614
+ const te = [
588
615
  "submit",
589
616
  "stop",
590
617
  "staging_ipc",
@@ -620,22 +647,22 @@ const X = [
620
647
  "stopping_painted",
621
648
  "progress_painted",
622
649
  "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) {
650
+ ], se = Math.random().toString(36).slice(2);
651
+ let ie = 0;
652
+ const q = () => `timing:${se}:${++ie}`, f = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
653
+ function E(s) {
627
654
  if (!s || typeof s != "object") return !1;
628
655
  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;
656
+ 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) && te.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
657
  }
631
- function k(s, e) {
658
+ function C(s, e) {
632
659
  if (!s) return {
633
660
  mark: (n) => {
634
661
  },
635
662
  measure: (n, r) => r()
636
663
  };
637
664
  const t = performance.now(), i = (n, r, a, o) => {
638
- const c = {
665
+ const d = {
639
666
  ...e,
640
667
  stage: n,
641
668
  status: r,
@@ -643,70 +670,64 @@ function k(s, e) {
643
670
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
644
671
  durationMs: Math.max(0, Math.round(performance.now() - a))
645
672
  };
646
- s && T(c) && Promise.resolve().then(() => s(c)).catch(() => {
673
+ s && E(d) && Promise.resolve().then(() => s(d)).catch(() => {
647
674
  });
648
675
  };
649
676
  return {
650
- mark: (n) => i(n, "observed", t, C()),
677
+ mark: (n) => i(n, "observed", t, q()),
651
678
  measure(n, r) {
652
- const a = performance.now(), o = C();
679
+ const a = performance.now(), o = q();
653
680
  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;
681
+ (d) => (i(n, "completed", a, o), d),
682
+ (d) => {
683
+ throw i(n, "failed", a, o), d;
657
684
  }
658
685
  );
659
686
  }
660
687
  };
661
688
  }
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) {
689
+ const D = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], P = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), v = (s) => s === null || P(s), ne = (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));
690
+ function K(s) {
670
691
  if (!s || typeof s != "object") return !1;
671
692
  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));
693
+ 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 || ne(e.createdAt));
673
694
  }
674
- function ne(s) {
695
+ function re(s) {
675
696
  if (!s || typeof s != "object") return !1;
676
697
  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));
698
+ 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));
678
699
  }
679
- function K(s) {
700
+ function $(s) {
680
701
  if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
681
702
  const e = (i) => {
682
703
  if (!i || typeof i != "object") return !1;
683
704
  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));
705
+ return Object.keys(i).every((r) => [...D, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || re(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" && D.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(P));
685
706
  }, t = s;
686
707
  return (t.before === null || e(t.before)) && e(t.current);
687
708
  }
688
709
  const A = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
689
- function re(s) {
710
+ function oe(s) {
690
711
  if (!s || typeof s != "object") return !1;
691
712
  const e = s;
692
713
  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
714
  }
694
- const D = 500;
695
- function oe(s) {
715
+ const k = 500;
716
+ function ae(s) {
696
717
  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
- return e.length > D ? `${e.slice(0, D - 1)}…` : e;
718
+ return e.length > k ? `${e.slice(0, k - 1)}…` : e;
698
719
  }
699
- function ae(s, e, t = "stopped", i) {
720
+ function de(s, e, t = "stopped", i) {
700
721
  const n = new Set(i ?? [
701
722
  s.assistantDraftRespondsToUserMessageId,
702
723
  s.activeResponseUserMessageId,
703
724
  s.messages.filter((o) => o.role === "user").slice(-1)[0]?.id
704
725
  ].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
726
  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 });
727
+ r.some((d) => d.respondsToUserMessageId === o && (d.dataType === "run_status" || d.dataType === "run_error" || d.role === "assistant" && d.phase !== "commentary")) || r.some((d) => d.role === "user" && d.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
728
  const a = s.segments?.map((o) => ({ ...o, outcomeIds: [
708
729
  ...o.outcomeIds,
709
- ...r.filter((c) => c.id === `local-interrupted:${o.userMessageId}` && !o.outcomeIds.includes(c.id)).map((c) => c.id)
730
+ ...r.filter((d) => d.id === `local-interrupted:${o.userMessageId}` && !o.outcomeIds.includes(d.id)).map((d) => d.id)
710
731
  ] }));
711
732
  return {
712
733
  ...s,
@@ -742,7 +763,7 @@ const ce = {
742
763
  function le(s) {
743
764
  return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ce, s.slice(13));
744
765
  }
745
- function q(s) {
766
+ function x(s) {
746
767
  return {
747
768
  ...s.id === void 0 ? {} : { id: s.id },
748
769
  name: s.name,
@@ -753,7 +774,7 @@ function q(s) {
753
774
  ...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
754
775
  };
755
776
  }
756
- function Ie(s) {
777
+ function Ae(s) {
757
778
  if (!s || typeof s != "object" || !("type" in s)) return !1;
758
779
  const e = s;
759
780
  switch (e.type) {
@@ -764,15 +785,15 @@ function Ie(s) {
764
785
  case "run.stop":
765
786
  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
787
  case "runtime.report_response_visibility":
767
- return re(e.observation);
788
+ return oe(e.observation);
768
789
  case "runtime.warmup":
769
790
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
770
791
  case "runtime.report_operation_timing":
771
- return T(e.timing);
792
+ return E(e.timing);
772
793
  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);
794
+ return (e.httpRequest === void 0 || U(e.httpRequest)) && (e.renderedError === void 0 || K(e.renderedError)) && (e.reason === "conversation_error" || e.reason === "attachment_error" || e.reason === "history_error" || e.reason === "action_error") && typeof e.errorFingerprint == "string" && /^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint) && (e.displayedMessage === void 0 || typeof e.displayedMessage == "string" && e.displayedMessage.length <= 500);
774
795
  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");
796
+ return (e.uiInvariant === void 0 || $(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");
776
797
  case "runtime.widget_lifecycle":
777
798
  return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
778
799
  case "session.load":
@@ -800,7 +821,7 @@ function Ie(s) {
800
821
  return !1;
801
822
  }
802
823
  }
803
- class Ae {
824
+ class we {
804
825
  constructor(e, t, i) {
805
826
  this.adapter = t, this.state = w(e), this.model = i;
806
827
  }
@@ -811,7 +832,7 @@ class Ae {
811
832
  interactionListeners = /* @__PURE__ */ new Set();
812
833
  accountListeners = /* @__PURE__ */ new Set();
813
834
  state;
814
- sessionHistoryState = f("unavailable");
835
+ sessionHistoryState = m("unavailable");
815
836
  model;
816
837
  interactions = [];
817
838
  account = null;
@@ -832,7 +853,7 @@ class Ae {
832
853
  const e = w(this.state);
833
854
  for (const [t, i] of this.submissionPreviews)
834
855
  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;
856
+ return this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed"), this.pendingStop ? de(e, "", "stopping", this.pendingStop.userMessageIds) : e;
836
857
  }
837
858
  updateProjection(e, t, i, n, r) {
838
859
  if (this.destroyed) return;
@@ -843,8 +864,8 @@ class Ae {
843
864
  if (this.state = w(e), a.user?.id === e.user?.id)
844
865
  for (const o of this.state.messages) {
845
866
  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));
867
+ const d = a.messages.find((c) => c.role === "user" && c.id === o.id);
868
+ a.sessionId !== e.sessionId && !(a.sessionId === null && d) || (o.attachments = ue(d?.attachments, o.attachments));
848
869
  }
849
870
  if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
850
871
  this.sessionHistoryState = j(i);
@@ -879,7 +900,7 @@ class Ae {
879
900
  this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
880
901
  }
881
902
  reportOperationTiming(e) {
882
- !this.destroyed && T(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
903
+ !this.destroyed && E(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
883
904
  });
884
905
  }
885
906
  reportResponseVisibility(e) {
@@ -887,7 +908,7 @@ class Ae {
887
908
  });
888
909
  }
889
910
  reportInvalidStateTransition(e, t, i) {
890
- i !== void 0 && !K(i) || this.adapter.dispatch({
911
+ i !== void 0 && !$(i) || this.adapter.dispatch({
891
912
  type: "runtime.report_invalid_state_transition",
892
913
  reason: e,
893
914
  clientMessageId: t,
@@ -896,12 +917,14 @@ class Ae {
896
917
  });
897
918
  }
898
919
  reportDisplayedError(e, t, i, n) {
899
- n !== void 0 && !U(n) || this.adapter.dispatch({
920
+ const r = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
921
+ n !== void 0 && !K(n) || this.adapter.dispatch({
900
922
  type: "runtime.report_displayed_error",
901
923
  reason: e,
902
924
  errorFingerprint: t,
903
925
  ...n ? { renderedError: n } : {},
904
- ...i ? { displayedMessage: oe(i) } : {}
926
+ ...U(r) ? { httpRequest: r } : {},
927
+ ...i ? { displayedMessage: ae(i) } : {}
905
928
  }).catch(() => {
906
929
  });
907
930
  }
@@ -910,21 +933,21 @@ class Ae {
910
933
  if (!i && n.length === 0) return Promise.resolve(null);
911
934
  this.pendingStop = null, this.stopError = null;
912
935
  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: {
936
+ this.pendingTransfers.set(r, n.flatMap((c) => c.id ? [c.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
914
937
  id: r,
915
938
  role: "user",
916
939
  content: i,
917
940
  createdAt: "",
918
- attachments: n.map((l) => ({ ...l }))
941
+ attachments: n.map((c) => ({ ...c }))
919
942
  } });
920
- const c = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt: a }, o);
921
- return this.emit("state", this.getState()), c.finally(() => {
943
+ const d = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt: a }, o);
944
+ return this.emit("state", this.getState()), d.finally(() => {
922
945
  this.pendingTransfers.delete(r);
923
946
  });
924
947
  }
925
948
  async sendMessageNow(e, t, i) {
926
- const n = e, r = t.clientMessageId, a = k((l) => {
927
- i === this.submissionGeneration && this.reportOperationTiming(l);
949
+ const n = e, r = t.clientMessageId, a = C((c) => {
950
+ i === this.submissionGeneration && this.reportOperationTiming(c);
928
951
  }, {
929
952
  operation: "send",
930
953
  layer: "renderer",
@@ -933,11 +956,11 @@ class Ae {
933
956
  sessionId: this.state.sessionId
934
957
  });
935
958
  a.mark("submit");
936
- let o = t.attachments ?? [], c = !1;
959
+ let o = t.attachments ?? [], d = !1;
937
960
  if (i !== this.submissionGeneration) return null;
938
961
  try {
939
962
  if (!await a.measure("staging_ipc", async () => {
940
- const d = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
963
+ const l = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
941
964
  type: "conversation.stage",
942
965
  initiatedBy: t.initiatedBy,
943
966
  invocation: t.invocation,
@@ -946,27 +969,27 @@ class Ae {
946
969
  clientMessageId: r,
947
970
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
948
971
  // 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,
972
+ attachments: o.length > 0 ? o.map(x) : void 0,
950
973
  submittedAt: t.submittedAt
951
974
  }) });
952
- return d ? (await d.result, d) : null;
975
+ return l ? (await l.result, l) : null;
953
976
  }) || i !== this.submissionGeneration) return null;
954
- if (c = !0, o.length > 0) {
977
+ if (d = !0, o.length > 0) {
955
978
  if (!this.adapter.uploadAttachment)
956
979
  throw new Error("The runtime does not support attachments.");
957
- const d = [];
980
+ const l = [];
958
981
  for (const u of o) {
959
982
  if (u.sandboxPath || u.storageKey) {
960
- d.push(u);
983
+ l.push(u);
961
984
  continue;
962
985
  }
963
986
  const M = u.id ? this.attachmentFiles.get(u.id) : void 0;
964
987
  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;
988
+ if (l.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(M, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
966
989
  }
967
- o = d;
990
+ o = l;
968
991
  }
969
- const p = await a.measure("send_ipc", () => this.adapter.dispatch({
992
+ const h = await a.measure("send_ipc", () => this.adapter.dispatch({
970
993
  type: "conversation.send",
971
994
  content: n,
972
995
  clientMessageId: r,
@@ -974,23 +997,23 @@ class Ae {
974
997
  invocation: t.invocation,
975
998
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
976
999
  ...t.automationOnboarding ? { automationOnboarding: !0 } : {},
977
- attachments: o.length > 0 ? o.map(q) : void 0
1000
+ attachments: o.length > 0 ? o.map(x) : void 0
978
1001
  }));
979
1002
  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) {
1003
+ for (const l of t.attachments ?? [])
1004
+ l.id && this.attachmentFiles.delete(l.id);
1005
+ return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), h?.clientMessageId ?? r;
1006
+ } catch (c) {
984
1007
  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({
1008
+ if (B(c))
1009
+ for (const l of t.attachments ?? [])
1010
+ l.id && this.attachmentFiles.delete(l.id);
1011
+ const h = this.submissionPreviews.get(r);
1012
+ throw h && (h.pending = !1, h.error = I(c).message, this.emit("state", this.getState())), d && await this.adapter.dispatch({
990
1013
  type: "conversation.fail_staged",
991
1014
  clientMessageId: r,
992
- message: I(l).message
993
- }), l;
1015
+ message: I(c).message
1016
+ }), c;
994
1017
  }
995
1018
  }
996
1019
  getModel() {
@@ -1018,7 +1041,7 @@ class Ae {
1018
1041
  ...t,
1019
1042
  e.activeResponseUserMessageId,
1020
1043
  e.messages.filter((o) => o.role === "user").slice(-1)[0]?.id
1021
- ].filter((o) => !!o))], n = k((o) => this.reportOperationTiming(o), {
1044
+ ].filter((o) => !!o))], n = C((o) => this.reportOperationTiming(o), {
1022
1045
  operation: "stop",
1023
1046
  layer: "renderer",
1024
1047
  requestId: crypto.randomUUID(),
@@ -1142,7 +1165,7 @@ class Ae {
1142
1165
  for (const n of i ?? []) n(t);
1143
1166
  }
1144
1167
  }
1145
- function de(s, e) {
1168
+ function ue(s, e) {
1146
1169
  if (!e || !s) return e;
1147
1170
  const t = /* @__PURE__ */ new Map();
1148
1171
  for (const i of s) {
@@ -1181,7 +1204,7 @@ function w(s) {
1181
1204
  function j(s) {
1182
1205
  return {
1183
1206
  ...s,
1184
- data: s.data ? m({
1207
+ data: s.data ? y({
1185
1208
  entities: F(s.data).map((e) => ({ ...e })),
1186
1209
  nextCursor: s.data.nextCursor
1187
1210
  }) : null
@@ -1189,25 +1212,25 @@ function j(s) {
1189
1212
  }
1190
1213
  export {
1191
1214
  Q as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1192
- ve as ProductAgentInteractionManager,
1215
+ be as ProductAgentInteractionManager,
1193
1216
  O as ProductAgentQueryController,
1194
- Ae as ProductAgentRemoteRuntimeClient,
1195
- ye as ProductAgentSessionHistoryManager,
1217
+ we as ProductAgentRemoteRuntimeClient,
1218
+ ve as ProductAgentSessionHistoryManager,
1196
1219
  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,
1220
+ me as canSubmitPersonalProductAgentMessage,
1221
+ _e as createLocalStorageInteractionDecisionStorage,
1222
+ m as createProductAgentQueryState,
1223
+ Ie as createProductAgentTaskPageTitleDocument,
1224
+ Y as formatProductAgentTaskPageTitle,
1225
+ ge as hasProductAgentPaidCreditFallback,
1203
1226
  B as isProductAgentAuthReconnectError,
1204
- Ie as isProductAgentRuntimeCommand,
1205
- $ as mergeProductAgentEntityPages,
1206
- m as normalizeProductAgentEntityPage,
1227
+ Ae as isProductAgentRuntimeCommand,
1228
+ z as mergeProductAgentEntityPages,
1229
+ y as normalizeProductAgentEntityPage,
1207
1230
  V as readLocalStorageInteractionDecisions,
1208
- pe as reconcileProductAgentSubmissionGate,
1209
- ge as resolveProductAgentBillingPresentation,
1210
- me as resolveProductAgentComposerAction,
1211
- ue as resolveProductAgentWidgetPresentation,
1231
+ he as reconcileProductAgentSubmissionGate,
1232
+ fe as resolveProductAgentBillingPresentation,
1233
+ ye as resolveProductAgentComposerAction,
1234
+ pe as resolveProductAgentWidgetPresentation,
1212
1235
  F as selectProductAgentQueryEntities
1213
1236
  };