@pluno/product-agent-web 0.1.235 → 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",
@@ -8,9 +8,9 @@ function f(s) {
8
8
  updatedAt: null
9
9
  };
10
10
  }
11
- class M {
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 M {
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 M {
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 U(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)
100
100
  s.entitiesById[r] || n.push(r);
101
101
  return { entitiesById: i, ids: n, nextCursor: e.nextCursor };
102
102
  }
103
- function $(s) {
103
+ function F(s) {
104
104
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
105
105
  }
106
- function de(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 le(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 ue(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 pe(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 he(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 ge(s) {
123
+ function ye(s) {
124
124
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
125
125
  return s.hasRunningAssistantTurn && !e ? {
126
126
  action: "stop",
@@ -130,24 +130,24 @@ function ge(s) {
130
130
  disabled: !e || !s.canSubmitMessage
131
131
  };
132
132
  }
133
- const F = "Pluno is reconnecting. Try again in a moment.";
134
- function Q(s) {
135
- return (s instanceof Error ? s.message : s) === F;
133
+ const Q = "Pluno is reconnecting. Try again in a moment.";
134
+ function B(s) {
135
+ return (s instanceof Error ? s.message : s) === Q;
136
136
  }
137
- class fe {
137
+ class ve {
138
138
  constructor(e, t, i = 20) {
139
- this.loadPage = t, this.limit = i, this.recentQuery = new M(
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
- U
148
- ), this.pinnedQuery = new M(
147
+ z
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 fe {
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: B(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 fe {
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,47 +283,47 @@ class fe {
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 B(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
- function O(s) {
292
+ function R(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")}`;
296
296
  }
297
- function A(s) {
297
+ function b(s) {
298
298
  if (s === null || typeof s == "string" || typeof s == "boolean") return !0;
299
299
  if (typeof s == "number") return Number.isFinite(s);
300
- if (Array.isArray(s)) return s.every(A);
300
+ if (Array.isArray(s)) return s.every(b);
301
301
  if (typeof s != "object") return !1;
302
302
  const e = Object.getPrototypeOf(s);
303
- return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(A);
303
+ return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(b);
304
304
  }
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 z(s) {
309
- if (!A(s)) throw new Error("Conversation inputs must be JSON-safe values.");
308
+ function H(s) {
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 G(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);
316
- const i = Object.values(s.items).sort((r, a) => O(r.created_at).localeCompare(O(a.created_at)) || r.id.localeCompare(a.id));
316
+ const i = Object.values(s.items).sort((r, a) => R(r.created_at).localeCompare(R(a.created_at)) || r.id.localeCompare(a.id));
317
317
  let n = !1;
318
318
  for (const r of i)
319
319
  if (r.type === "user_message" && (n = r.id === e), !!n && (r.type === "stopped" || r.type === "error" || r.type === "final_response" && s.streams[r.id]?.state === "finished" && s.streams[r.id].revision >= r.data.revision))
320
320
  return !0;
321
321
  return !1;
322
322
  }
323
- class me {
323
+ class be {
324
324
  constructor(e, t = null) {
325
325
  this.storage = e, t && (this.decisions = new Map(
326
- t.filter(w).map((i) => [this.getDecisionKey(i), i])
326
+ t.filter(T).map((i) => [this.getDecisionKey(i), i])
327
327
  ), this.initialized = !0);
328
328
  }
329
329
  storage;
@@ -345,7 +345,7 @@ class me {
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(z({ ...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 me {
371
371
  userPrompt: o?.type === "user_message" ? o.data.content : "",
372
372
  assistantAnswer: ""
373
373
  },
374
- terminal: !a.wait_for_terminal || G(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 me {
401
401
  if (this.initialized) return;
402
402
  const e = await this.storage.load();
403
403
  this.decisions = new Map(
404
- e.filter(w).map((t) => [this.getDecisionKey(t), t])
404
+ e.filter(T).map((t) => [this.getDecisionKey(t), t])
405
405
  ), this.initialized = !0;
406
406
  }
407
407
  isEligible(e, t = Date.now()) {
@@ -473,17 +473,17 @@ class me {
473
473
  return `${S(e.scope)}:category:${e.category}`;
474
474
  }
475
475
  }
476
- function ye(s, e) {
476
+ function _e(s, e) {
477
477
  return {
478
- load: async () => H(s, e),
478
+ load: async () => V(s, e),
479
479
  save: async (t) => s.setItem(e, JSON.stringify(t))
480
480
  };
481
481
  }
482
- function H(s, e) {
482
+ 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(w) : [];
486
+ return Array.isArray(i) ? i.filter(T) : [];
487
487
  }
488
488
  function S(s) {
489
489
  return `${s.level}:${s.key}`;
@@ -491,23 +491,23 @@ function S(s) {
491
491
  function L(s) {
492
492
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
493
493
  }
494
- function w(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 V = {
499
+ const J = {
500
500
  working: "⏳",
501
501
  completed: "✅",
502
502
  failed: "❗",
503
503
  stopped: "⏹️"
504
- }, Z = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
- function J(s, e) {
506
- if (!e) return b(s);
507
- const t = b(s), i = `${V[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
- class ve {
510
+ class Se {
511
511
  constructor(e) {
512
512
  this.titleDocument = e;
513
513
  }
@@ -529,10 +529,10 @@ class ve {
529
529
  }
530
530
  applyStatus(e) {
531
531
  const t = this.titleDocument.getTitle();
532
- t !== this.lastAppliedTitle && (this.baseTitle = b(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 ? b(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 ve {
541
541
  applyTitle() {
542
542
  if (!this.status)
543
543
  return;
544
- const e = J(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 be(s) {
548
+ function Ie(s) {
549
549
  return {
550
550
  getTitle: () => s.title,
551
551
  setTitle: (e) => {
@@ -561,10 +561,57 @@ function be(s) {
561
561
  }
562
562
  };
563
563
  }
564
- function b(s) {
565
- return s.replace(Z, "");
564
+ function _(s) {
565
+ return s.replace(W, "");
566
+ }
567
+ function X(s) {
568
+ if (s.details !== void 0 && !b(s.details))
569
+ throw new TypeError("Product Agent transported error details must be JSON-safe.");
570
+ return {
571
+ code: s.code,
572
+ message: s.message,
573
+ retryable: s.retryable,
574
+ ...s.details === void 0 ? {} : { details: s.details }
575
+ };
576
+ }
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 X({
580
+ code: n,
581
+ message: i.trim() && i.trim() !== "[object Object]" ? i : "The Product Agent operation failed. Try again.",
582
+ 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 } } : {}
585
+ });
566
586
  }
567
- const W = [
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 = [
568
615
  "submit",
569
616
  "stop",
570
617
  "staging_ipc",
@@ -600,13 +647,13 @@ const W = [
600
647
  "stopping_painted",
601
648
  "progress_painted",
602
649
  "stopped_painted"
603
- ], Y = Math.random().toString(36).slice(2);
604
- let X = 0;
605
- const R = () => `timing:${Y}:${++X}`, g = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(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);
606
653
  function E(s) {
607
654
  if (!s || typeof s != "object") return !1;
608
655
  const e = s;
609
- 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) && W.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;
610
657
  }
611
658
  function C(s, e) {
612
659
  if (!s) return {
@@ -615,7 +662,7 @@ function C(s, e) {
615
662
  measure: (n, r) => r()
616
663
  };
617
664
  const t = performance.now(), i = (n, r, a, o) => {
618
- const c = {
665
+ const d = {
619
666
  ...e,
620
667
  stage: n,
621
668
  status: r,
@@ -623,70 +670,64 @@ function C(s, e) {
623
670
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
624
671
  durationMs: Math.max(0, Math.round(performance.now() - a))
625
672
  };
626
- s && E(c) && Promise.resolve().then(() => s(c)).catch(() => {
673
+ s && E(d) && Promise.resolve().then(() => s(d)).catch(() => {
627
674
  });
628
675
  };
629
676
  return {
630
- mark: (n) => i(n, "observed", t, R()),
677
+ mark: (n) => i(n, "observed", t, q()),
631
678
  measure(n, r) {
632
- const a = performance.now(), o = R();
679
+ const a = performance.now(), o = q();
633
680
  return i(n, "started", a, o), r().then(
634
- (c) => (i(n, "completed", a, o), c),
635
- (c) => {
636
- 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;
637
684
  }
638
685
  );
639
686
  }
640
687
  };
641
688
  }
642
- const y = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
643
- function ee(s) {
644
- if (!s || typeof s != "object") return !1;
645
- 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");
646
- 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);
647
- }
648
- const k = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], T = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), v = (s) => s === null || T(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));
649
- function j(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) {
650
691
  if (!s || typeof s != "object") return !1;
651
692
  const e = s;
652
- return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && v(e.sessionId) && T(e.itemId) && v(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && v(e.runId) && (e.createdAt === null || te(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));
653
694
  }
654
- function se(s) {
695
+ function re(s) {
655
696
  if (!s || typeof s != "object") return !1;
656
697
  const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
657
- 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 || ee(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));
658
699
  }
659
- function K(s) {
700
+ function $(s) {
660
701
  if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
661
702
  const e = (i) => {
662
703
  if (!i || typeof i != "object") return !1;
663
704
  const n = i;
664
- return Object.keys(i).every((r) => [...k, "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" && k.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(T));
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));
665
706
  }, t = s;
666
707
  return (t.before === null || e(t.before)) && e(t.current);
667
708
  }
668
- const _ = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
669
- function ie(s) {
709
+ const A = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
710
+ function oe(s) {
670
711
  if (!s || typeof s != "object") return !1;
671
712
  const e = s;
672
- return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && _(e.sessionId) && _(e.responseItemId) && _(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
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";
673
714
  }
674
- const x = 500;
675
- function ne(s) {
715
+ const k = 500;
716
+ function ae(s) {
676
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();
677
- return e.length > x ? `${e.slice(0, x - 1)}…` : e;
718
+ return e.length > k ? `${e.slice(0, k - 1)}…` : e;
678
719
  }
679
- function re(s, e, t = "stopped", i) {
720
+ function de(s, e, t = "stopped", i) {
680
721
  const n = new Set(i ?? [
681
722
  s.assistantDraftRespondsToUserMessageId,
682
723
  s.activeResponseUserMessageId,
683
724
  s.messages.filter((o) => o.role === "user").slice(-1)[0]?.id
684
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);
685
726
  for (const o of n)
686
- 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 });
687
728
  const a = s.segments?.map((o) => ({ ...o, outcomeIds: [
688
729
  ...o.outcomeIds,
689
- ...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)
690
731
  ] }));
691
732
  return {
692
733
  ...s,
@@ -703,7 +744,7 @@ function re(s, e, t = "stopped", i) {
703
744
  lastErrorCode: null
704
745
  };
705
746
  }
706
- const oe = {
747
+ const ce = {
707
748
  "stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
708
749
  "in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
709
750
  "stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
@@ -719,10 +760,10 @@ const oe = {
719
760
  "thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
720
761
  "thinking-without-progress": "Thinking remained visible without progress for five minutes."
721
762
  };
722
- function ae(s) {
723
- return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(oe, s.slice(13));
763
+ function le(s) {
764
+ return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ce, s.slice(13));
724
765
  }
725
- function D(s) {
766
+ function x(s) {
726
767
  return {
727
768
  ...s.id === void 0 ? {} : { id: s.id },
728
769
  name: s.name,
@@ -733,7 +774,7 @@ function D(s) {
733
774
  ...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
734
775
  };
735
776
  }
736
- function Se(s) {
777
+ function Ae(s) {
737
778
  if (!s || typeof s != "object" || !("type" in s)) return !1;
738
779
  const e = s;
739
780
  switch (e.type) {
@@ -744,15 +785,15 @@ function Se(s) {
744
785
  case "run.stop":
745
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);
746
787
  case "runtime.report_response_visibility":
747
- return ie(e.observation);
788
+ return oe(e.observation);
748
789
  case "runtime.warmup":
749
790
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
750
791
  case "runtime.report_operation_timing":
751
792
  return E(e.timing);
752
793
  case "runtime.report_displayed_error":
753
- return (e.renderedError === void 0 || j(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);
754
795
  case "runtime.report_invalid_state_transition":
755
- 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" || ae(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");
756
797
  case "runtime.widget_lifecycle":
757
798
  return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
758
799
  case "session.load":
@@ -780,9 +821,9 @@ function Se(s) {
780
821
  return !1;
781
822
  }
782
823
  }
783
- class _e {
824
+ class we {
784
825
  constructor(e, t, i) {
785
- this.adapter = t, this.state = I(e), this.model = i;
826
+ this.adapter = t, this.state = w(e), this.model = i;
786
827
  }
787
828
  adapter;
788
829
  listeners = {};
@@ -791,7 +832,7 @@ class _e {
791
832
  interactionListeners = /* @__PURE__ */ new Set();
792
833
  accountListeners = /* @__PURE__ */ new Set();
793
834
  state;
794
- sessionHistoryState = f("unavailable");
835
+ sessionHistoryState = m("unavailable");
795
836
  model;
796
837
  interactions = [];
797
838
  account = null;
@@ -809,10 +850,10 @@ class _e {
809
850
  return i.add(t), this.listeners[e] = i, () => i.delete(t);
810
851
  }
811
852
  getState() {
812
- const e = I(this.state);
853
+ const e = w(this.state);
813
854
  for (const [t, i] of this.submissionPreviews)
814
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"));
815
- return this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed"), this.pendingStop ? re(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;
816
857
  }
817
858
  updateProjection(e, t, i, n, r) {
818
859
  if (this.destroyed) return;
@@ -820,14 +861,14 @@ class _e {
820
861
  (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());
821
862
  for (const o of e.messages)
822
863
  o.role === "user" && this.submissionPreviews.delete(o.id);
823
- if (this.state = I(e), a.user?.id === e.user?.id)
864
+ if (this.state = w(e), a.user?.id === e.user?.id)
824
865
  for (const o of this.state.messages) {
825
866
  if (o.role !== "user" || !o.attachments?.length) continue;
826
- const c = a.messages.find((d) => d.role === "user" && d.id === o.id);
827
- a.sessionId !== e.sessionId && !(a.sessionId === null && c) || (o.attachments = ce(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));
828
869
  }
829
870
  if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
830
- this.sessionHistoryState = q(i);
871
+ this.sessionHistoryState = j(i);
831
872
  for (const o of this.sessionHistoryListeners)
832
873
  o(this.getSessionHistoryState());
833
874
  }
@@ -867,7 +908,7 @@ class _e {
867
908
  });
868
909
  }
869
910
  reportInvalidStateTransition(e, t, i) {
870
- i !== void 0 && !K(i) || this.adapter.dispatch({
911
+ i !== void 0 && !$(i) || this.adapter.dispatch({
871
912
  type: "runtime.report_invalid_state_transition",
872
913
  reason: e,
873
914
  clientMessageId: t,
@@ -876,12 +917,14 @@ class _e {
876
917
  });
877
918
  }
878
919
  reportDisplayedError(e, t, i, n) {
879
- n !== void 0 && !j(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({
880
922
  type: "runtime.report_displayed_error",
881
923
  reason: e,
882
924
  errorFingerprint: t,
883
925
  ...n ? { renderedError: n } : {},
884
- ...i ? { displayedMessage: ne(i) } : {}
926
+ ...U(r) ? { httpRequest: r } : {},
927
+ ...i ? { displayedMessage: ae(i) } : {}
885
928
  }).catch(() => {
886
929
  });
887
930
  }
@@ -890,21 +933,21 @@ class _e {
890
933
  if (!i && n.length === 0) return Promise.resolve(null);
891
934
  this.pendingStop = null, this.stopError = null;
892
935
  const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), a = t.submittedAt ?? Date.now(), o = this.submissionGeneration;
893
- this.pendingTransfers.set(r, n.flatMap((d) => d.id ? [d.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: {
894
937
  id: r,
895
938
  role: "user",
896
939
  content: i,
897
940
  createdAt: "",
898
- attachments: n.map((d) => ({ ...d }))
941
+ attachments: n.map((c) => ({ ...c }))
899
942
  } });
900
- const c = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt: a }, o);
901
- 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(() => {
902
945
  this.pendingTransfers.delete(r);
903
946
  });
904
947
  }
905
948
  async sendMessageNow(e, t, i) {
906
- const n = e, r = t.clientMessageId, a = C((d) => {
907
- i === this.submissionGeneration && this.reportOperationTiming(d);
949
+ const n = e, r = t.clientMessageId, a = C((c) => {
950
+ i === this.submissionGeneration && this.reportOperationTiming(c);
908
951
  }, {
909
952
  operation: "send",
910
953
  layer: "renderer",
@@ -913,7 +956,7 @@ class _e {
913
956
  sessionId: this.state.sessionId
914
957
  });
915
958
  a.mark("submit");
916
- let o = t.attachments ?? [], c = !1;
959
+ let o = t.attachments ?? [], d = !1;
917
960
  if (i !== this.submissionGeneration) return null;
918
961
  try {
919
962
  if (!await a.measure("staging_ipc", async () => {
@@ -926,12 +969,12 @@ class _e {
926
969
  clientMessageId: r,
927
970
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
928
971
  // Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
929
- attachments: o.length > 0 ? o.map(D) : void 0,
972
+ attachments: o.length > 0 ? o.map(x) : void 0,
930
973
  submittedAt: t.submittedAt
931
974
  }) });
932
975
  return l ? (await l.result, l) : null;
933
976
  }) || i !== this.submissionGeneration) return null;
934
- if (c = !0, o.length > 0) {
977
+ if (d = !0, o.length > 0) {
935
978
  if (!this.adapter.uploadAttachment)
936
979
  throw new Error("The runtime does not support attachments.");
937
980
  const l = [];
@@ -940,13 +983,13 @@ class _e {
940
983
  l.push(u);
941
984
  continue;
942
985
  }
943
- const P = u.id ? this.attachmentFiles.get(u.id) : void 0;
944
- if (!P) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
945
- if (l.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(P, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
986
+ const M = u.id ? this.attachmentFiles.get(u.id) : void 0;
987
+ if (!M) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
988
+ if (l.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(M, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
946
989
  }
947
990
  o = l;
948
991
  }
949
- const p = await a.measure("send_ipc", () => this.adapter.dispatch({
992
+ const h = await a.measure("send_ipc", () => this.adapter.dispatch({
950
993
  type: "conversation.send",
951
994
  content: n,
952
995
  clientMessageId: r,
@@ -954,23 +997,23 @@ class _e {
954
997
  invocation: t.invocation,
955
998
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
956
999
  ...t.automationOnboarding ? { automationOnboarding: !0 } : {},
957
- attachments: o.length > 0 ? o.map(D) : void 0
1000
+ attachments: o.length > 0 ? o.map(x) : void 0
958
1001
  }));
959
1002
  if (i !== this.submissionGeneration) return null;
960
1003
  for (const l of t.attachments ?? [])
961
1004
  l.id && this.attachmentFiles.delete(l.id);
962
- return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), p?.clientMessageId ?? r;
963
- } catch (d) {
1005
+ return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), h?.clientMessageId ?? r;
1006
+ } catch (c) {
964
1007
  if (i !== this.submissionGeneration) return null;
965
- if (Q(d))
1008
+ if (B(c))
966
1009
  for (const l of t.attachments ?? [])
967
1010
  l.id && this.attachmentFiles.delete(l.id);
968
- const p = this.submissionPreviews.get(r);
969
- throw p && (p.pending = !1, p.error = d instanceof Error ? d.message : String(d), this.emit("state", this.getState())), c && await this.adapter.dispatch({
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({
970
1013
  type: "conversation.fail_staged",
971
1014
  clientMessageId: r,
972
- message: d instanceof Error ? d.message : String(d)
973
- }), d;
1015
+ message: I(c).message
1016
+ }), c;
974
1017
  }
975
1018
  }
976
1019
  getModel() {
@@ -1009,7 +1052,7 @@ class _e {
1009
1052
  const r = { userMessageIds: i, promise: Promise.resolve() };
1010
1053
  this.pendingStop = r, r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
1011
1054
  }, (o) => {
1012
- this.pendingStop === r && (this.stopError = o instanceof Error ? o.message : String(o));
1055
+ this.pendingStop === r && (this.stopError = I(o).message);
1013
1056
  }).finally(() => {
1014
1057
  this.pendingStop === r && (this.pendingStop = null, this.emit("state", this.getState()));
1015
1058
  }), this.emit("state", this.getState());
@@ -1043,7 +1086,7 @@ class _e {
1043
1086
  return t.sessionHistoryPage;
1044
1087
  }
1045
1088
  getSessionHistoryState() {
1046
- return q(this.sessionHistoryState);
1089
+ return j(this.sessionHistoryState);
1047
1090
  }
1048
1091
  subscribeSessionHistory(e) {
1049
1092
  return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
@@ -1122,7 +1165,7 @@ class _e {
1122
1165
  for (const n of i ?? []) n(t);
1123
1166
  }
1124
1167
  }
1125
- function ce(s, e) {
1168
+ function ue(s, e) {
1126
1169
  if (!e || !s) return e;
1127
1170
  const t = /* @__PURE__ */ new Map();
1128
1171
  for (const i of s) {
@@ -1134,7 +1177,7 @@ function ce(s, e) {
1134
1177
  return n ? { ...i, previewUrl: n } : i;
1135
1178
  });
1136
1179
  }
1137
- function I(s) {
1180
+ function w(s) {
1138
1181
  return {
1139
1182
  ...s,
1140
1183
  starterPrompts: [...s.starterPrompts],
@@ -1158,36 +1201,36 @@ function I(s) {
1158
1201
  activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
1159
1202
  };
1160
1203
  }
1161
- function q(s) {
1204
+ function j(s) {
1162
1205
  return {
1163
1206
  ...s,
1164
- data: s.data ? m({
1165
- entities: $(s.data).map((e) => ({ ...e })),
1207
+ data: s.data ? y({
1208
+ entities: F(s.data).map((e) => ({ ...e })),
1166
1209
  nextCursor: s.data.nextCursor
1167
1210
  }) : null
1168
1211
  };
1169
1212
  }
1170
1213
  export {
1171
- F as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1172
- me as ProductAgentInteractionManager,
1173
- M as ProductAgentQueryController,
1174
- _e as ProductAgentRemoteRuntimeClient,
1175
- fe as ProductAgentSessionHistoryManager,
1176
- ve as ProductAgentTaskPageTitleController,
1177
- he as canSubmitPersonalProductAgentMessage,
1178
- ye as createLocalStorageInteractionDecisionStorage,
1179
- f as createProductAgentQueryState,
1180
- be as createProductAgentTaskPageTitleDocument,
1181
- J as formatProductAgentTaskPageTitle,
1182
- ue as hasProductAgentPaidCreditFallback,
1183
- Q as isProductAgentAuthReconnectError,
1184
- Se as isProductAgentRuntimeCommand,
1185
- U as mergeProductAgentEntityPages,
1186
- m as normalizeProductAgentEntityPage,
1187
- H as readLocalStorageInteractionDecisions,
1188
- le as reconcileProductAgentSubmissionGate,
1189
- pe as resolveProductAgentBillingPresentation,
1190
- ge as resolveProductAgentComposerAction,
1191
- de as resolveProductAgentWidgetPresentation,
1192
- $ as selectProductAgentQueryEntities
1214
+ Q as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1215
+ be as ProductAgentInteractionManager,
1216
+ O as ProductAgentQueryController,
1217
+ we as ProductAgentRemoteRuntimeClient,
1218
+ ve as ProductAgentSessionHistoryManager,
1219
+ Se as ProductAgentTaskPageTitleController,
1220
+ me as canSubmitPersonalProductAgentMessage,
1221
+ _e as createLocalStorageInteractionDecisionStorage,
1222
+ m as createProductAgentQueryState,
1223
+ Ie as createProductAgentTaskPageTitleDocument,
1224
+ Y as formatProductAgentTaskPageTitle,
1225
+ ge as hasProductAgentPaidCreditFallback,
1226
+ B as isProductAgentAuthReconnectError,
1227
+ Ae as isProductAgentRuntimeCommand,
1228
+ z as mergeProductAgentEntityPages,
1229
+ y as normalizeProductAgentEntityPage,
1230
+ V as readLocalStorageInteractionDecisions,
1231
+ he as reconcileProductAgentSubmissionGate,
1232
+ fe as resolveProductAgentBillingPresentation,
1233
+ ye as resolveProductAgentComposerAction,
1234
+ pe as resolveProductAgentWidgetPresentation,
1235
+ F as selectProductAgentQueryEntities
1193
1236
  };