@pluno/product-agent-web 0.1.275 → 0.1.276

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- function _e(s, e) {
1
+ function Se(s, e) {
2
2
  return e === "limit_exceeded" ? { allowed: !1, reason: "credits_exhausted", actions: ["upgrade", "earn_credits"] } : e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required" ? { allowed: !1, reason: "payment_issue", actions: ["upgrade"] } : s ?? { allowed: !0, reason: "allowed", actions: [] };
3
3
  }
4
- function y(s) {
4
+ function b(s) {
5
5
  return {
6
6
  key: s,
7
7
  status: "not_requested",
@@ -11,9 +11,9 @@ function y(s) {
11
11
  updatedAt: null
12
12
  };
13
13
  }
14
- class q {
14
+ class O {
15
15
  constructor(e, t, i = (n, r) => r) {
16
- this.loader = t, this.merge = i, this.state = y(e);
16
+ this.loader = t, this.merge = i, this.state = b(e);
17
17
  }
18
18
  loader;
19
19
  merge;
@@ -28,10 +28,10 @@ class q {
28
28
  return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
29
29
  }
30
30
  setKey(e) {
31
- e !== this.state.key && (this.state = y(e), this.trailingLoad = null, this.publish());
31
+ e !== this.state.key && (this.state = b(e), this.trailingLoad = null, this.publish());
32
32
  }
33
33
  reset() {
34
- this.state = y(this.state.key), this.trailingLoad = null, this.publish();
34
+ this.state = b(this.state.key), this.trailingLoad = null, this.publish();
35
35
  }
36
36
  invalidate() {
37
37
  this.state = {
@@ -96,31 +96,31 @@ function v(s) {
96
96
  nextCursor: s.nextCursor
97
97
  };
98
98
  }
99
- function Q(s, e, t) {
99
+ function V(s, e, t) {
100
100
  if (t === "replace" || s === null) return e;
101
101
  const i = { ...s.entitiesById, ...e.entitiesById }, n = [...s.ids];
102
102
  for (const r of e.ids)
103
103
  s.entitiesById[r] || n.push(r);
104
104
  return { entitiesById: i, ids: n, nextCursor: e.nextCursor };
105
105
  }
106
- function H(s) {
106
+ function Z(s) {
107
107
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
108
108
  }
109
- function Ie(s) {
109
+ function we(s) {
110
110
  return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
111
111
  }
112
- function Se(s) {
112
+ function Ae(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 we(s) {
117
+ function Ee(s) {
118
118
  return s ? s.submissionGate?.allowed === !1 ? ["credits_exhausted", "payment_issue", "onboarding_required"].includes(s.submissionGate.reason) ? { state: "action_required", reason: s.submissionGate.reason } : { state: "hidden" } : s.usingPaidCreditFallback === !0 ? { state: "paid_credit_fallback" } : s.creditLimit !== null && s.creditLimit > 0 && s.creditsRemaining !== null && s.creditsRemaining > 0 && s.creditsRemaining / s.creditLimit <= 0.2 ? { state: "low_credits" } : s.creditsUsed !== null ? { state: "usage" } : { state: "hidden" } : { state: "hidden" };
119
119
  }
120
- function Ae(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 Te(s) {
124
124
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
125
125
  return s.hasRunningAssistantTurn && !e ? {
126
126
  action: "stop",
@@ -130,13 +130,13 @@ function Me(s) {
130
130
  disabled: !e || !s.canSubmitMessage
131
131
  };
132
132
  }
133
- const V = "Pluno is reconnecting. Try again in a moment.";
134
- function Z(s) {
135
- return (s instanceof Error ? s.message : s) === V;
133
+ const J = "Pluno is reconnecting. Try again in a moment.";
134
+ function W(s) {
135
+ return (s instanceof Error ? s.message : s) === J;
136
136
  }
137
- class Te {
137
+ class Pe {
138
138
  constructor(e, t, i = 20) {
139
- this.loadPage = t, this.limit = i, this.recentQuery = new q(
139
+ this.loadPage = t, this.limit = i, this.recentQuery = new O(
140
140
  `${e}:recent`,
141
141
  async ({ cursor: n }) => v(
142
142
  await this.loadPage({ cursor: n, limit: this.limit, pinned: !1 }).then((r) => ({
@@ -144,8 +144,8 @@ class Te {
144
144
  nextCursor: r.nextCursor
145
145
  }))
146
146
  ),
147
- Q
148
- ), this.pinnedQuery = new q(
147
+ V
148
+ ), this.pinnedQuery = new O(
149
149
  `${e}:pinned`,
150
150
  async () => v({
151
151
  entities: await this.loadAllPinned(),
@@ -167,8 +167,8 @@ class Te {
167
167
  activityReconciliationScheduled = !1;
168
168
  getState() {
169
169
  const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), i = [
170
- ...m(t.data),
171
- ...m(e.data)
170
+ ...y(t.data),
171
+ ...y(e.data)
172
172
  ], n = new Map(i.map((d) => [d.id, d])), r = Array.from(n.values()).map(
173
173
  (d) => this.applyOverrides(d, this.completedRefreshSequence)
174
174
  ), o = Array.from(this.optimisticEntities.values()).filter((d) => !n.has(d.id)).reverse(), a = e.data || t.data || o.length > 0 ? v({
@@ -177,7 +177,7 @@ class Te {
177
177
  }) : null;
178
178
  return {
179
179
  key: e.key.slice(0, -7),
180
- status: J(e, t),
180
+ status: Y(e, t),
181
181
  data: a,
182
182
  error: e.error ?? t.error,
183
183
  requestId: Math.max(e.requestId, t.requestId),
@@ -243,8 +243,8 @@ class Te {
243
243
  }
244
244
  reconcileDurableEntities() {
245
245
  const e = [
246
- ...m(this.pinnedQuery.getState().data),
247
- ...m(this.recentQuery.getState().data)
246
+ ...y(this.pinnedQuery.getState().data),
247
+ ...y(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 Te {
283
283
  for (const e of this.listeners) e(this.getState());
284
284
  }
285
285
  }
286
- function m(s) {
286
+ function y(s) {
287
287
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
288
288
  }
289
- function J(s, e) {
289
+ function Y(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 k(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 b(s) {
297
+ function _(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(b);
300
+ if (Array.isArray(s)) return s.every(_);
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(b);
303
+ return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(_);
304
304
  }
305
- function N(s) {
306
- return s !== null && typeof s == "object" && !Object.isFrozen(s) && (Object.values(s).forEach(N), Object.freeze(s)), s;
305
+ function $(s) {
306
+ return s !== null && typeof s == "object" && !Object.isFrozen(s) && (Object.values(s).forEach($), Object.freeze(s)), s;
307
307
  }
308
- function W(s) {
309
- if (!b(s)) throw new Error("Conversation inputs must be JSON-safe values.");
308
+ function X(s) {
309
+ if (!_(s)) throw new Error("Conversation inputs must be JSON-safe values.");
310
310
  return JSON.parse(JSON.stringify(s));
311
311
  }
312
- function Y(s, e) {
312
+ function ee(s, e) {
313
313
  if (!e) return !1;
314
314
  const t = s.executionByUserMessage[e];
315
315
  if (t) return ["completed", "stopped", "failed"].includes(t.phase);
316
- const i = Object.values(s.items).sort((r, o) => k(r.created_at).localeCompare(k(o.created_at)) || r.id.localeCompare(o.id));
316
+ const i = Object.values(s.items).sort((r, o) => R(r.created_at).localeCompare(R(o.created_at)) || r.id.localeCompare(o.id));
317
317
  let n = !1;
318
318
  for (const r of i)
319
319
  if (r.type === "user_message" && (n = r.id === e), !!n && (r.type === "stopped" || r.type === "error" || r.type === "final_response" && s.streams[r.id]?.state === "finished" && s.streams[r.id].revision >= r.data.revision))
320
320
  return !0;
321
321
  return !1;
322
322
  }
323
- class Ee {
323
+ class ke {
324
324
  constructor(e, t = null) {
325
325
  this.storage = e, t && (this.decisions = new Map(
326
- t.filter(A).map((i) => [this.getDecisionKey(i), i])
326
+ t.filter(E).map((i) => [this.getDecisionKey(i), i])
327
327
  ), this.initialized = !0);
328
328
  }
329
329
  storage;
@@ -345,7 +345,7 @@ class Ee {
345
345
  if (n && n.version >= t.version) continue;
346
346
  if (n && n.payload.kind !== t.payload.kind) throw new Error("Interaction kind changed.");
347
347
  const r = n?.payload.kind === "personal_channel" && n.lifecycle === "completed" ? "completed" : t.lifecycle, o = n?.payload.kind === "sharing" && t.payload.kind === "sharing" ? { ...t.payload, variant: n.payload.variant } : t.payload;
348
- this.sources.set(i, N(W({ ...t, lifecycle: r, payload: o }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
348
+ this.sources.set(i, $(X({ ...t, lifecycle: r, payload: o }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
349
349
  }
350
350
  }
351
351
  /** @internal */
@@ -371,7 +371,7 @@ class Ee {
371
371
  userPrompt: a?.type === "user_message" ? a.data.content : "",
372
372
  assistantAnswer: ""
373
373
  },
374
- terminal: !o.wait_for_terminal || Y(i, r.user_message_id)
374
+ terminal: !o.wait_for_terminal || ee(i, r.user_message_id)
375
375
  };
376
376
  } else o.kind === "integration_auth" ? t.integrations.push({
377
377
  revision: r.version,
@@ -401,7 +401,7 @@ class Ee {
401
401
  if (this.initialized) return;
402
402
  const e = await this.storage.load();
403
403
  this.decisions = new Map(
404
- e.filter(A).map((t) => [this.getDecisionKey(t), t])
404
+ e.filter(E).map((t) => [this.getDecisionKey(t), t])
405
405
  ), this.initialized = !0;
406
406
  }
407
407
  isEligible(e, t = Date.now()) {
@@ -437,7 +437,7 @@ class Ee {
437
437
  async applyAction(e, t, i) {
438
438
  if (!e.allowedActions.includes(t))
439
439
  throw new Error(`Interaction ${e.key} does not allow ${t}.`);
440
- if (!z(t))
440
+ if (!K(t))
441
441
  throw new Error(`Interaction action ${t} is not a persistence decision.`);
442
442
  const n = i.now ?? /* @__PURE__ */ new Date(), r = {
443
443
  promptKey: e.key,
@@ -463,51 +463,51 @@ class Ee {
463
463
  return null;
464
464
  }
465
465
  getDecisionKey(e) {
466
- const t = I(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 `${I(e.scope)}:interaction:${e.key}`;
470
+ return `${S(e.scope)}:interaction:${e.key}`;
471
471
  }
472
472
  getCategoryKey(e) {
473
- return `${I(e.scope)}:category:${e.category}`;
473
+ return `${S(e.scope)}:category:${e.category}`;
474
474
  }
475
475
  }
476
- function Pe(s, e) {
476
+ function qe(s, e) {
477
477
  return {
478
- load: async () => X(s, e),
478
+ load: async () => te(s, e),
479
479
  save: async (t) => s.setItem(e, JSON.stringify(t))
480
480
  };
481
481
  }
482
- function X(s, e) {
482
+ function te(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(A) : [];
486
+ return Array.isArray(i) ? i.filter(E) : [];
487
487
  }
488
- function I(s) {
488
+ function S(s) {
489
489
  return `${s.level}:${s.key}`;
490
490
  }
491
- function z(s) {
491
+ function K(s) {
492
492
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
493
493
  }
494
- function A(s) {
494
+ function E(s) {
495
495
  if (!s || typeof s != "object") return !1;
496
496
  const e = s;
497
- return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && z(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
497
+ return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && K(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
498
498
  }
499
- const ee = {
499
+ const se = {
500
500
  working: "⏳",
501
501
  completed: "✅",
502
502
  failed: "❗",
503
503
  stopped: "⏹️"
504
- }, te = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
- function se(s, e) {
506
- if (!e) return _(s);
507
- const t = _(s), i = `${ee[e]} Pluno`;
504
+ }, ie = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
+ function ne(s, e) {
506
+ if (!e) return I(s);
507
+ const t = I(s), i = `${se[e]} Pluno`;
508
508
  return t ? `${i}: ${t}` : i;
509
509
  }
510
- class qe {
510
+ class Oe {
511
511
  constructor(e) {
512
512
  this.titleDocument = e;
513
513
  }
@@ -529,10 +529,10 @@ class qe {
529
529
  }
530
530
  applyStatus(e) {
531
531
  const t = this.titleDocument.getTitle();
532
- t !== this.lastAppliedTitle && (this.baseTitle = _(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
532
+ t !== this.lastAppliedTitle && (this.baseTitle = I(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
533
533
  }
534
534
  applyClear() {
535
- const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, i = this.lastAppliedTitle === null ? _(e) : e;
535
+ const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, i = this.lastAppliedTitle === null ? I(e) : e;
536
536
  this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : i !== e && this.titleDocument.setTitle(i);
537
537
  }
538
538
  handleTitleChanged() {
@@ -541,11 +541,11 @@ class qe {
541
541
  applyTitle() {
542
542
  if (!this.status)
543
543
  return;
544
- const e = se(this.baseTitle, this.status);
544
+ const e = ne(this.baseTitle, this.status);
545
545
  this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
546
546
  }
547
547
  }
548
- function ke(s) {
548
+ function Re(s) {
549
549
  return {
550
550
  getTitle: () => s.title,
551
551
  setTitle: (e) => {
@@ -561,48 +561,48 @@ function ke(s) {
561
561
  }
562
562
  };
563
563
  }
564
- function _(s) {
565
- return s.replace(te, "");
564
+ function I(s) {
565
+ return s.replace(ie, "");
566
566
  }
567
- const ie = "0.1.275", ne = {
568
- version: ie
567
+ const re = "0.1.276", oe = {
568
+ version: re
569
569
  }, p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
570
- function re(s) {
570
+ function ae(s) {
571
571
  if (!s || typeof s != "object") return !1;
572
572
  const e = s, t = (n) => Number.isSafeInteger(n) && n >= 0, i = (n) => n && typeof n == "object" && Object.keys(n).every((r) => ["sequence", "at", "type", "changed", "generation", "sessionId", "scopeId", "requestId", "effectId", "clientScopeId", "reason", "effectKind", "eventType", "itemCount", "removedCount", "projectionReady"].includes(r)) && t(n.sequence) && t(n.at) && p(n.type) !== null && typeof n.changed == "boolean" && [n.generation, n.itemCount, n.removedCount].every((r) => r === null || t(r)) && [n.sessionId, n.scopeId, n.requestId, n.effectId, n.clientScopeId, n.reason, n.effectKind, n.eventType].every((r) => r === null || p(r) !== null) && (n.projectionReady === null || typeof n.projectionReady == "boolean");
573
573
  return Object.keys(e).every((n) => ["ownerId", "revision", "dropped", "lastIntent", "lastSelection", "transitions"].includes(n)) && p(e.ownerId) !== null && t(e.revision) && t(e.dropped) && (e.lastIntent == null || i(e.lastIntent)) && (e.lastSelection === null || i(e.lastSelection)) && Array.isArray(e.transitions) && e.transitions.length <= 16 && e.transitions.every(i);
574
574
  }
575
- function $(s) {
575
+ function U(s) {
576
576
  if (!s || typeof s != "object") return !1;
577
577
  const e = s;
578
578
  return Object.keys(e).every((t) => ["sessionId", "episodeId", "consecutiveFailures", "transportCode", "requestId", "durationMs"].includes(t)) && typeof e.sessionId == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(e.sessionId) && typeof e.episodeId == "string" && /^[a-zA-Z0-9:_-]{1,500}$/.test(e.episodeId) && (e.transportCode === void 0 || typeof e.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(e.transportCode)) && (e.requestId === void 0 || typeof e.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(e.requestId)) && (e.durationMs === void 0 || typeof e.durationMs == "number" && Number.isFinite(e.durationMs) && e.durationMs >= 0) && Number.isSafeInteger(e.consecutiveFailures) && e.consecutiveFailures >= 1;
579
579
  }
580
- const O = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], M = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), h = (s) => s === null || M(s), oe = (s) => typeof s == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(s) && Number.isFinite(Date.parse(s));
581
- function K(s) {
580
+ const C = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], M = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), h = (s) => s === null || M(s), de = (s) => typeof s == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(s) && Number.isFinite(Date.parse(s));
581
+ function L(s) {
582
582
  if (!s || typeof s != "object") return !1;
583
583
  const e = s;
584
- return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && h(e.sessionId) && M(e.itemId) && h(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && h(e.runId) && (e.createdAt === null || oe(e.createdAt));
584
+ return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && h(e.sessionId) && M(e.itemId) && h(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && h(e.runId) && (e.createdAt === null || de(e.createdAt));
585
585
  }
586
- function ae(s) {
586
+ function ce(s) {
587
587
  if (!s || typeof s != "object") return !1;
588
588
  const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
589
- return Object.keys(e).every((i) => ["capturedAt", "selectionKey", "userId", "loading", "draft", "thinking", "connected", "hasError", "phase", "queryStatus", "queryRequestId", "queryUpdatedAt", "renderSource", "selectionFencePending", "guardCreatedAt", "owner", "sdkVersion", "presentationGate", "firstObservedAt", "confirmationMs"].includes(i)) && t(e.capturedAt) && [e.queryUpdatedAt, e.guardCreatedAt].every((i) => i === null || t(i)) && [e.selectionKey, e.userId, e.phase, e.queryStatus, e.queryRequestId].every((i) => i === null || p(i) !== null) && [e.loading, e.draft, e.thinking, e.connected, e.hasError, e.selectionFencePending].every((i) => typeof i == "boolean") && ["state", "account", "interactions", "local", "sidepanel_layout", "observer"].includes(e.renderSource) && (e.owner === void 0 || re(e.owner)) && (e.sdkVersion === void 0 || typeof e.sdkVersion == "string" && e.sdkVersion.length <= 32 && /^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/.test(e.sdkVersion)) && (e.presentationGate === void 0 || ["none", "authentication", "signup"].includes(e.presentationGate)) && [e.firstObservedAt, e.confirmationMs].every((i) => i === void 0 || t(i));
589
+ return Object.keys(e).every((i) => ["capturedAt", "selectionKey", "userId", "loading", "draft", "thinking", "connected", "hasError", "phase", "queryStatus", "queryRequestId", "queryUpdatedAt", "renderSource", "selectionFencePending", "guardCreatedAt", "owner", "sdkVersion", "presentationGate", "firstObservedAt", "confirmationMs"].includes(i)) && t(e.capturedAt) && [e.queryUpdatedAt, e.guardCreatedAt].every((i) => i === null || t(i)) && [e.selectionKey, e.userId, e.phase, e.queryStatus, e.queryRequestId].every((i) => i === null || p(i) !== null) && [e.loading, e.draft, e.thinking, e.connected, e.hasError, e.selectionFencePending].every((i) => typeof i == "boolean") && ["state", "account", "interactions", "local", "sidepanel_layout", "observer"].includes(e.renderSource) && (e.owner === void 0 || ae(e.owner)) && (e.sdkVersion === void 0 || typeof e.sdkVersion == "string" && e.sdkVersion.length <= 32 && /^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/.test(e.sdkVersion)) && (e.presentationGate === void 0 || ["none", "authentication", "signup"].includes(e.presentationGate)) && [e.firstObservedAt, e.confirmationMs].every((i) => i === void 0 || t(i));
590
590
  }
591
- function U(s) {
591
+ function F(s) {
592
592
  if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
593
593
  const e = (i) => {
594
594
  if (!i || typeof i != "object") return !1;
595
595
  const n = i;
596
- return Object.keys(i).every((r) => [...O, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context", "duplicateToolCalls"].includes(r)) && (n.duplicateToolCalls === void 0 || Array.isArray(n.duplicateToolCalls) && n.duplicateToolCalls.length <= 5 && n.duplicateToolCalls.every((r) => r && Object.keys(r).every((o) => ["key", "count", "rows", "truncated"].includes(o)) && h(r.key) && Number.isSafeInteger(r.count) && r.count >= 2 && typeof r.truncated == "boolean" && Array.isArray(r.rows) && r.rows.length >= 1 && r.rows.length <= 5 && r.rows.length <= r.count && r.rows.every((o) => o && Object.keys(o).every((a) => ["itemId", "groupId"].includes(a)) && h(o.itemId) && h(o.groupId)))) && (n.context === void 0 || ae(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) && h(n.sessionId) && Number.isSafeInteger(n.runtimeItemCount) && n.runtimeItemCount >= 0 && typeof n.welcome == "boolean" && typeof n.truncated == "boolean" && O.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(M));
596
+ return Object.keys(i).every((r) => [...C, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context", "duplicateToolCalls"].includes(r)) && (n.duplicateToolCalls === void 0 || Array.isArray(n.duplicateToolCalls) && n.duplicateToolCalls.length <= 5 && n.duplicateToolCalls.every((r) => r && Object.keys(r).every((o) => ["key", "count", "rows", "truncated"].includes(o)) && h(r.key) && Number.isSafeInteger(r.count) && r.count >= 2 && typeof r.truncated == "boolean" && Array.isArray(r.rows) && r.rows.length >= 1 && r.rows.length <= 5 && r.rows.length <= r.count && r.rows.every((o) => o && Object.keys(o).every((a) => ["itemId", "groupId"].includes(a)) && h(o.itemId) && h(o.groupId)))) && (n.context === void 0 || ce(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) && h(n.sessionId) && Number.isSafeInteger(n.runtimeItemCount) && n.runtimeItemCount >= 0 && typeof n.welcome == "boolean" && typeof n.truncated == "boolean" && C.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(M));
597
597
  }, t = s;
598
598
  return (t.before === null || e(t.before)) && e(t.current);
599
599
  }
600
- const R = 500;
601
- function L(s) {
600
+ const x = 500;
601
+ function G(s) {
602
602
  const e = s.replace(/\n\s*at\s[\s\S]*$/, "").replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g, "[REDACTED]").replace(/\b(?:set-cookie|cookie)\s*[:=]\s*[^\n]+/gi, "cookie=[REDACTED]").replace(/\bdata:[^\s<>"']+/gi, "[DATA]").replace(/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi, "[URL]").replace(/\b(?:Bearer|Basic)\s+[^\s,;"']+/gi, "[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp)[-_][A-Za-z0-9_-]{8,}/g, "[REDACTED]").replace(/\b((?:access|refresh|id|auth)[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|pwd|secret|token|jwt|authorization|cookie|set-cookie)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;}&]+)/gi, "$1=[REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[EMAIL]").replace(/(?:[A-Z]:[\\/]|\\\\|(?:~|\.\.?)?\/|[\w.-]+[\\/])[^\s<>"']+/gi, "[FILE]").replace(new RegExp("(?<![\\w.])(?:[\\w.-]+\\.[A-Z][A-Z0-9]{0,15}|\\.[A-Z][\\w.-]*)\\b", "gi"), "[FILE]").replace(/\s+/g, " ").trim();
603
- return e.length > R ? `${e.slice(0, R - 1)}…` : e;
603
+ return e.length > x ? `${e.slice(0, x - 1)}…` : e;
604
604
  }
605
- function de(s) {
605
+ function le(s) {
606
606
  let e = 2166136261;
607
607
  for (let t = 0; t < s.length; t += 1)
608
608
  e ^= s.charCodeAt(t), e = Math.imul(e, 16777619);
@@ -613,24 +613,24 @@ function T(s) {
613
613
  const e = s;
614
614
  return Object.keys(s).every((t) => ["boundary", "category", "messageKind"].includes(t)) && ["runtime", "web_transport", "extension_ipc"].includes(e.boundary) && ["error", "object", "null", "array", "string", "undefined", "number", "boolean", "bigint", "symbol", "function"].includes(e.category) && ["object_coercion", "text", "blank", "non_text"].includes(e.messageKind);
615
615
  }
616
- function ce(s) {
616
+ function ue(s) {
617
617
  if (!s || typeof s != "object") return !1;
618
618
  const e = s;
619
619
  return Object.keys(e).every((t) => ["sessionId", "requestId", "code", "normalization", "builds", "clientMessageId"].includes(t)) && (e.clientMessageId === void 0 || p(e.clientMessageId) !== null) && [e.sessionId, e.requestId, e.code].every((t) => t === null || p(t) !== null) && (e.normalization === void 0 || T(e.normalization)) && !!e.builds && typeof e.builds == "object" && typeof e.builds.sdk == "string" && Object.entries(e.builds).every(([t, i]) => ["sdk", "rendererExtension", "contentExtension", "backgroundExtension"].includes(t) && typeof i == "string" && /^\d{1,5}\.\d{1,5}\.\d{1,5}$/.test(i));
620
620
  }
621
- function le(s, e, t, i, n = {}) {
622
- const r = !i && e === "conversation_error" && t !== void 0 && s.conversationDiagnostics?.errorMessageFingerprint === de(L(t)) ? s.conversationDiagnostics : void 0;
621
+ function pe(s, e, t, i, n = {}) {
622
+ const r = !i && e === "conversation_error" && t !== void 0 && s.conversationDiagnostics?.errorMessageFingerprint === le(G(t)) ? s.conversationDiagnostics : void 0;
623
623
  return {
624
624
  sessionId: p(s.sessionId),
625
625
  requestId: p(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
626
626
  ...p(r?.failedClientMessageId) ? { clientMessageId: r.failedClientMessageId } : {},
627
627
  code: r ? p(s.lastErrorCode) : null,
628
628
  ...T(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
629
- builds: { sdk: ne.version, ...n }
629
+ builds: { sdk: oe.version, ...n }
630
630
  };
631
631
  }
632
- function ue(s) {
633
- if (s.details !== void 0 && !b(s.details))
632
+ function he(s) {
633
+ if (s.details !== void 0 && !_(s.details))
634
634
  throw new TypeError("Product Agent transported error details must be JSON-safe.");
635
635
  return {
636
636
  code: s.code,
@@ -656,14 +656,14 @@ function g(s, e = "runtime_error", t = "runtime") {
656
656
  ...typeof a.durationMs == "number" && Number.isFinite(a.durationMs) && a.durationMs >= 0 ? { durationMs: a.durationMs } : {},
657
657
  ...typeof a.successfulRequests == "number" && Number.isSafeInteger(a.successfulRequests) && a.successfulRequests >= 0 ? { successfulRequests: a.successfulRequests } : {}
658
658
  };
659
- return ue({
659
+ return he({
660
660
  code: r,
661
661
  message: n.trim() && n.trim() !== "[object Object]" ? n : "The Product Agent operation failed. Try again.",
662
662
  retryable: !!(i && "retryable" in i && i.retryable === !0),
663
663
  ...Object.keys(d).length ? { details: d } : {}
664
664
  });
665
665
  }
666
- function G(s) {
666
+ function B(s) {
667
667
  if (!s || typeof s != "object") return !1;
668
668
  const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
669
669
  return Object.keys(e).every((i) => [
@@ -687,7 +687,7 @@ function G(s) {
687
687
  "upstreamTraceId"
688
688
  ].includes(i)) && p(e.requestId) !== null && ["GET", "POST", "PUT", "PATCH", "DELETE"].includes(e.method) && ["/api/product-agent/conversations/:sessionId/snapshot", "/api/product-agent/:namespace/commands", "/api/product-agent/:namespace/:operation"].includes(e.route) && (e.status === null || t(e.status) && e.status >= 100 && e.status <= 599) && (e.abortTrigger === null || ["deadline", "transport_disposed", "owner_disposed", "authority_retired", "observation_released", "request_replaced", "caller_cancelled", "unexpected_abort"].includes(e.abortTrigger)) && ["http_deadline", "http_transport", "conversation_query", "browser", "http_response"].includes(e.owner) && (e.category === void 0 || /^[a-z0-9_]{1,80}$/.test(e.category)) && [e.responseHeadersMs, e.responseBodyMs].every((i) => i == null || t(i)) && t(e.elapsedMs) && t(e.attempt) && e.attempt >= 1 && e.attempt <= 10 && [e.queryRequestId, e.ownerId, e.sessionId].every((i) => i === null || p(i) !== null) && (e.authorityGeneration === null || t(e.authorityGeneration)) && typeof e.release == "string" && /^[a-zA-Z0-9._-]{1,80}$/.test(e.release) && [e.upstreamRequestId, e.upstreamTraceId].every((i) => i === null || typeof i == "string" && /^[a-zA-Z0-9_:;=./-]{1,160}$/.test(i));
689
689
  }
690
- const pe = [
690
+ const ge = [
691
691
  "submit",
692
692
  "stop",
693
693
  "staging_ipc",
@@ -735,11 +735,22 @@ const pe = [
735
735
  "checkpoint_queue",
736
736
  "checkpoint_prepared",
737
737
  "checkpoint_restore",
738
+ "checkpoint_prerequisite",
739
+ "checkpoint_bindings",
740
+ "checkpoint_write",
741
+ "checkpoint_cleanup",
742
+ "reload_checkpoint",
743
+ "reload_checkpoint_queue",
744
+ "reload_directory_write",
745
+ "reload_directory_read",
746
+ "reload_storage_read",
747
+ "reload_documents",
748
+ "reload_storage_write",
738
749
  "acceptance_received",
739
750
  "acceptance_applied",
740
751
  "cancellation_queue",
741
752
  "cancellation_write"
742
- ], F = [
753
+ ], Q = [
743
754
  "request_timed_out",
744
755
  "delivery_unknown",
745
756
  "invalid_ack",
@@ -755,20 +766,20 @@ const pe = [
755
766
  "backend_refusal",
756
767
  "unknown"
757
768
  ];
758
- function he(s) {
769
+ function fe(s) {
759
770
  const e = s, t = e?.code;
760
- return e?.backendRefusal === !0 ? "backend_refusal" : typeof t == "string" && t !== "backend_refusal" && F.includes(t) ? t : e?.name === "AbortError" ? "aborted" : e?.name === "TypeError" ? "type_error" : "unknown";
771
+ return e?.backendRefusal === !0 ? "backend_refusal" : typeof t == "string" && t !== "backend_refusal" && Q.includes(t) ? t : e?.name === "AbortError" ? "aborted" : e?.name === "TypeError" ? "type_error" : "unknown";
761
772
  }
762
- const B = Math.random().toString(36).slice(2);
763
- let ge = 0;
764
- const C = () => `timing:${B}:${++ge}`, f = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
765
- function E(s) {
773
+ const H = Math.random().toString(36).slice(2);
774
+ let me = 0;
775
+ const D = () => `timing:${H}:${++me}`, m = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
776
+ function P(s) {
766
777
  if (!s || typeof s != "object") return !1;
767
778
  const e = s;
768
- return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory", "tabId", "queueDepth", "workerId"].includes(t)) && (e.tabId === void 0 || Number.isSafeInteger(e.tabId) && e.tabId >= 0) && (e.queueDepth === void 0 || Number.isSafeInteger(e.queueDepth) && e.queueDepth >= 0) && (e.workerId === void 0 || f(e.workerId)) && (e.failureCategory === void 0 || e.status === "failed" && F.includes(e.failureCategory)) && (e.entrySurface === void 0 || ["extension_sidepanel", "extension_widget", "main_web_chat", "embedded_widget", "embedded_custom_ui", "automation", "mcp", "whatsapp", "email"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && pe.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && f(e.spanId) && f(e.requestId) && (e.clientMessageId === null || f(e.clientMessageId)) && (e.sessionId === null || f(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
779
+ return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory", "tabId", "queueDepth", "workerId"].includes(t)) && (e.tabId === void 0 || Number.isSafeInteger(e.tabId) && e.tabId >= 0) && (e.queueDepth === void 0 || Number.isSafeInteger(e.queueDepth) && e.queueDepth >= 0) && (e.workerId === void 0 || m(e.workerId)) && (e.failureCategory === void 0 || e.status === "failed" && Q.includes(e.failureCategory)) && (e.entrySurface === void 0 || ["extension_sidepanel", "extension_widget", "main_web_chat", "embedded_widget", "embedded_custom_ui", "automation", "mcp", "whatsapp", "email"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && ge.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && m(e.spanId) && m(e.requestId) && (e.clientMessageId === null || m(e.clientMessageId)) && (e.sessionId === null || m(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
769
780
  }
770
- function x(s, e) {
771
- if (e = { workerId: B, ...e }, !s) return {
781
+ function j(s, e) {
782
+ if (e = { workerId: H, ...e }, !s) return {
772
783
  identity: e,
773
784
  mark: (n) => {
774
785
  },
@@ -782,16 +793,16 @@ function x(s, e) {
782
793
  spanId: a,
783
794
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
784
795
  durationMs: Math.max(0, Math.round(performance.now() - o)),
785
- ...r === "failed" ? { failureCategory: he(d) } : {}
796
+ ...r === "failed" ? { failureCategory: fe(d) } : {}
786
797
  };
787
- s && E(c) && Promise.resolve().then(() => s(c)).catch(() => {
798
+ s && P(c) && Promise.resolve().then(() => s(c)).catch(() => {
788
799
  });
789
800
  };
790
801
  return {
791
802
  identity: e,
792
- mark: (n) => i(n, "observed", t, C()),
803
+ mark: (n) => i(n, "observed", t, D()),
793
804
  measure(n, r) {
794
- const o = performance.now(), a = C();
805
+ const o = performance.now(), a = D();
795
806
  return i(n, "started", o, a), r().then(
796
807
  (d) => (i(n, "completed", o, a), d),
797
808
  (d) => {
@@ -801,13 +812,13 @@ function x(s, e) {
801
812
  }
802
813
  };
803
814
  }
804
- const S = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
805
- function fe(s) {
815
+ const w = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
816
+ function ye(s) {
806
817
  if (!s || typeof s != "object") return !1;
807
818
  const e = s;
808
- return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && S(e.sessionId) && S(e.responseItemId) && S(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
819
+ return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && w(e.sessionId) && w(e.responseItemId) && w(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
809
820
  }
810
- function me(s, e, t = "stopped", i, n = "Run stopped by user.") {
821
+ function be(s, e, t = "stopped", i, n = "Run stopped by user.") {
811
822
  const r = new Set(i ?? [
812
823
  s.assistantDraftRespondsToUserMessageId,
813
824
  s.activeResponseUserMessageId,
@@ -834,7 +845,7 @@ function me(s, e, t = "stopped", i, n = "Run stopped by user.") {
834
845
  lastErrorCode: null
835
846
  };
836
847
  }
837
- const ye = {
848
+ const ve = {
838
849
  "stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
839
850
  "in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
840
851
  "stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
@@ -850,10 +861,10 @@ const ye = {
850
861
  "thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
851
862
  "thinking-without-progress": "Thinking remained visible without progress for five minutes."
852
863
  };
853
- function ve(s) {
854
- return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ye, s.slice(13));
864
+ function _e(s) {
865
+ return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ve, s.slice(13));
855
866
  }
856
- function D(s) {
867
+ function N(s) {
857
868
  return {
858
869
  ...s.id === void 0 ? {} : { id: s.id },
859
870
  name: s.name,
@@ -864,7 +875,7 @@ function D(s) {
864
875
  ...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
865
876
  };
866
877
  }
867
- function Oe(s) {
878
+ function Ce(s) {
868
879
  if (!s || typeof s != "object" || !("type" in s)) return !1;
869
880
  const e = s;
870
881
  switch (e.type) {
@@ -876,15 +887,15 @@ function Oe(s) {
876
887
  case "run.stop":
877
888
  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);
878
889
  case "runtime.report_response_visibility":
879
- return fe(e.observation);
890
+ return ye(e.observation);
880
891
  case "runtime.warmup":
881
892
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
882
893
  case "runtime.report_operation_timing":
883
- return E(e.timing);
894
+ return P(e.timing);
884
895
  case "runtime.report_displayed_error":
885
- return (e.errorDiagnostic === void 0 || ce(e.errorDiagnostic)) && (e.httpRequest === void 0 || G(e.httpRequest)) && (e.historyRefreshFailure === void 0 || $(e.historyRefreshFailure)) && (e.renderedError === void 0 || K(e.renderedError)) && (e.reason === "conversation_error" || e.reason === "attachment_error" || e.reason === "history_error" || e.reason === "action_error") && typeof e.errorFingerprint == "string" && /^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint) && (e.displayedMessage === void 0 || typeof e.displayedMessage == "string" && e.displayedMessage.length <= 500);
896
+ return (e.errorDiagnostic === void 0 || ue(e.errorDiagnostic)) && (e.httpRequest === void 0 || B(e.httpRequest)) && (e.historyRefreshFailure === void 0 || U(e.historyRefreshFailure)) && (e.renderedError === void 0 || L(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);
886
897
  case "runtime.report_invalid_state_transition":
887
- return (e.uiInvariant === void 0 || U(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || ve(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
898
+ return (e.uiInvariant === void 0 || F(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || _e(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
888
899
  case "runtime.prompt_presented":
889
900
  return (e.feature === "notifications" || e.feature === "tab_grouping") && typeof e.openingGeneration == "number" && Number.isSafeInteger(e.openingGeneration) && e.openingGeneration > 0;
890
901
  case "runtime.widget_lifecycle":
@@ -914,9 +925,9 @@ function Oe(s) {
914
925
  return !1;
915
926
  }
916
927
  }
917
- class Re {
928
+ class xe {
918
929
  constructor(e, t, i) {
919
- this.adapter = t, this.state = w(e), this.model = i;
930
+ this.adapter = t, this.state = A(e), this.model = i;
920
931
  }
921
932
  adapter;
922
933
  listeners = {};
@@ -925,7 +936,7 @@ class Re {
925
936
  interactionListeners = /* @__PURE__ */ new Set();
926
937
  accountListeners = /* @__PURE__ */ new Set();
927
938
  state;
928
- sessionHistoryState = y("unavailable");
939
+ sessionHistoryState = b("unavailable");
929
940
  model;
930
941
  interactions = [];
931
942
  account = null;
@@ -937,6 +948,7 @@ class Re {
937
948
  pendingStop = null;
938
949
  stopError = null;
939
950
  stopPreviews = /* @__PURE__ */ new Map();
951
+ durabilityWaiters = /* @__PURE__ */ new Set();
940
952
  operationQueue = Promise.resolve();
941
953
  destroyed = !1;
942
954
  on(e, t) {
@@ -944,13 +956,13 @@ class Re {
944
956
  return i.add(t), this.listeners[e] = i, () => i.delete(t);
945
957
  }
946
958
  getState() {
947
- const e = w(this.state);
959
+ const e = A(this.state);
948
960
  for (const [n, r] of this.submissionPreviews)
949
- e.messages.some((o) => o.id === n) || (e.messages.push({ ...r.message, attachments: r.message.attachments?.map((o) => ({ ...o })) }), e.segments && (e.segments = [...e.segments, { id: n, userMessageId: n, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, r.pending && (e.activeResponseUserMessageId = n, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), r.error && (e.lastError = r.error.message, e.lastErrorCode = ["unauthorized", "401", "auth_reconnecting", "submission_not_available"].includes(r.error.code) ? r.error.code : "message_delivery_failed"));
961
+ e.messages.some((o) => o.id === n) || (e.messages.push({ ...r.message, attachments: r.message.attachments?.map((o) => ({ ...o })) }), e.segments && (e.segments = [...e.segments, { id: n, userMessageId: n, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, r.pending && (e.activeResponseUserMessageId = n, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), r.error && (e.lastError = r.error.message, e.lastErrorCode = ["unauthorized", "401", "auth_reconnecting", "submission_not_available", "submission_checkpoint_pending"].includes(r.error.code) ? r.error.code : "message_delivery_failed"));
950
962
  this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
951
963
  const t = [...this.stopPreviews.keys()];
952
964
  if (!t.length) return e;
953
- const i = me(e, "", "stopping", t);
965
+ const i = be(e, "", "stopping", t);
954
966
  return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
955
967
  }
956
968
  updateProjection(e, t, i, n, r) {
@@ -959,19 +971,19 @@ class Re {
959
971
  (o.user?.id !== e.user?.id || o.selectionKey !== void 0 && o.selectionKey !== e.selectionKey || o.selectionKey === void 0 && o.sessionId !== null && o.sessionId !== e.sessionId) && (this.cancelPendingSubmissions(), this.submissionPreviews.clear());
960
972
  for (const a of e.messages)
961
973
  a.role === "user" && e.receipts?.find((d) => d.userMessageId === a.id)?.durable !== !1 && this.submissionPreviews.delete(a.id);
962
- this.state = w(e);
974
+ this.state = A(e);
963
975
  for (const [a, d] of this.stopPreviews) {
964
976
  const c = e.activity?.executionKey;
965
- (d !== void 0 && d !== "[]" && c !== void 0 && c !== "[]" && (c !== d || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (d === void 0 || d === "[]") && e.messages.some((u) => u.respondsToUserMessageId === a && !u.provisional && u.loading !== !0 && (u.dataType === "run_status" || u.dataType === "run_error" || u.role === "assistant" && u.phase !== "commentary" && (u.streamState === void 0 || ["finished", "stopped", "failed"].includes(u.streamState))))) && this.stopPreviews.delete(a);
977
+ (d !== void 0 && d !== "[]" && c !== void 0 && c !== "[]" && (c !== d || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (d === void 0 || d === "[]") && e.messages.some((l) => l.respondsToUserMessageId === a && !l.provisional && l.loading !== !0 && (l.dataType === "run_status" || l.dataType === "run_error" || l.role === "assistant" && l.phase !== "commentary" && (l.streamState === void 0 || ["finished", "stopped", "failed"].includes(l.streamState))))) && this.stopPreviews.delete(a);
966
978
  }
967
979
  if (this.pendingStop?.userMessageIds.every((a) => !this.stopPreviews.has(a)) && (this.pendingStop = null), o.user?.id === e.user?.id)
968
980
  for (const a of this.state.messages) {
969
981
  if (a.role !== "user" || !a.attachments?.length) continue;
970
982
  const d = o.messages.find((c) => c.role === "user" && c.id === a.id);
971
- o.sessionId !== e.sessionId && !(o.sessionId === null && d) || (a.attachments = be(d?.attachments, a.attachments));
983
+ o.sessionId !== e.sessionId && !(o.sessionId === null && d) || (a.attachments = Ie(d?.attachments, a.attachments));
972
984
  }
973
985
  if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
974
- this.sessionHistoryState = j(i);
986
+ this.sessionHistoryState = z(i);
975
987
  for (const a of this.sessionHistoryListeners)
976
988
  a(this.getSessionHistoryState());
977
989
  }
@@ -990,7 +1002,9 @@ class Re {
990
1002
  }
991
1003
  destroy() {
992
1004
  if (!this.destroyed) {
993
- this.destroyed = !0, this.pendingStop = null, this.stopPreviews.clear(), this.pendingTransfers.clear(), this.submissionPreviews.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
1005
+ this.destroyed = !0;
1006
+ for (const e of this.durabilityWaiters) e();
1007
+ this.pendingStop = null, this.stopPreviews.clear(), this.pendingTransfers.clear(), this.submissionPreviews.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
994
1008
  for (const e of Object.values(this.listeners)) e?.clear();
995
1009
  this.adapter.onDisconnect?.();
996
1010
  }
@@ -1006,7 +1020,7 @@ class Re {
1006
1020
  this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
1007
1021
  }
1008
1022
  reportOperationTiming(e) {
1009
- !this.destroyed && E(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
1023
+ !this.destroyed && P(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
1010
1024
  });
1011
1025
  }
1012
1026
  reportResponseVisibility(e) {
@@ -1014,7 +1028,7 @@ class Re {
1014
1028
  });
1015
1029
  }
1016
1030
  reportInvalidStateTransition(e, t, i) {
1017
- i !== void 0 && !U(i) || this.adapter.dispatch({
1031
+ i !== void 0 && !F(i) || this.adapter.dispatch({
1018
1032
  type: "runtime.report_invalid_state_transition",
1019
1033
  reason: e,
1020
1034
  clientMessageId: t,
@@ -1024,8 +1038,8 @@ class Re {
1024
1038
  }
1025
1039
  reportDisplayedError(e, t, i, n, r) {
1026
1040
  const o = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
1027
- if (n !== void 0 && !K(n) || r !== void 0 && !$(r)) return;
1028
- const a = le(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds);
1041
+ if (n !== void 0 && !L(n) || r !== void 0 && !U(r)) return;
1042
+ const a = pe(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds);
1029
1043
  this.adapter.dispatch({
1030
1044
  type: "runtime.report_displayed_error",
1031
1045
  errorDiagnostic: a,
@@ -1034,8 +1048,8 @@ class Re {
1034
1048
  errorFingerprint: t,
1035
1049
  ...n ? { renderedError: n } : {},
1036
1050
  ...r ? { historyRefreshFailure: r } : {},
1037
- ...G(o) ? { httpRequest: o } : {},
1038
- ...i ? { displayedMessage: L(i) } : {}
1051
+ ...B(o) ? { httpRequest: o } : {},
1052
+ ...i ? { displayedMessage: G(i) } : {}
1039
1053
  }).catch(() => {
1040
1054
  });
1041
1055
  }
@@ -1059,7 +1073,7 @@ class Re {
1059
1073
  });
1060
1074
  }
1061
1075
  async sendMessageNow(e, t, i) {
1062
- const n = e, r = t.clientMessageId, o = x((c) => {
1076
+ const n = e, r = t.clientMessageId, o = j((c) => {
1063
1077
  i === this.submissionGeneration && this.reportOperationTiming(c);
1064
1078
  }, {
1065
1079
  operation: "send",
@@ -1073,7 +1087,7 @@ class Re {
1073
1087
  if (i !== this.submissionGeneration) return null;
1074
1088
  try {
1075
1089
  if (!await o.measure("staging_ipc", async () => {
1076
- const l = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
1090
+ const u = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
1077
1091
  type: "conversation.stage",
1078
1092
  initiatedBy: t.initiatedBy,
1079
1093
  invocation: t.invocation,
@@ -1082,25 +1096,30 @@ class Re {
1082
1096
  clientMessageId: r,
1083
1097
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1084
1098
  // Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
1085
- attachments: a.length > 0 ? a.map(D) : void 0,
1099
+ attachments: a.length > 0 ? a.map(N) : void 0,
1086
1100
  submittedAt: t.submittedAt
1087
1101
  }) });
1088
- return l ? (await l.result, l) : null;
1102
+ return u && await u.result.then(() => !0, (f) => {
1103
+ const k = g(f);
1104
+ if (k.code !== "submission_checkpoint_pending") throw f;
1105
+ const q = this.submissionPreviews.get(r);
1106
+ return q && (q.error = k), this.emit("state", this.getState()), this.waitForSubmissionDurability(r, i);
1107
+ }) ? u : null;
1089
1108
  }) || i !== this.submissionGeneration) return null;
1090
1109
  if (d = !0, a.length > 0) {
1091
1110
  if (!this.adapter.uploadAttachment)
1092
1111
  throw new Error("The runtime does not support attachments.");
1093
- const l = [];
1094
- for (const u of a) {
1095
- if (u.sandboxPath || u.storageKey) {
1096
- l.push(u);
1112
+ const u = [];
1113
+ for (const l of a) {
1114
+ if (l.sandboxPath || l.storageKey) {
1115
+ u.push(l);
1097
1116
  continue;
1098
1117
  }
1099
- const P = u.id ? this.attachmentFiles.get(u.id) : void 0;
1100
- if (!P) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
1101
- if (l.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(P, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
1118
+ const f = l.id ? this.attachmentFiles.get(l.id) : void 0;
1119
+ if (!f) throw new Error(`Attachment bytes are unavailable for ${l.name}`);
1120
+ if (u.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(f, l, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
1102
1121
  }
1103
- a = l;
1122
+ a = u;
1104
1123
  }
1105
1124
  if (i !== this.submissionGeneration || (await this.adapter.dispatch({
1106
1125
  type: "conversation.send",
@@ -1110,18 +1129,18 @@ class Re {
1110
1129
  invocation: t.invocation,
1111
1130
  automationOnboarding: t.automationOnboarding,
1112
1131
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1113
- attachments: a.length > 0 ? a.map(D) : void 0
1132
+ attachments: a.length > 0 ? a.map(N) : void 0
1114
1133
  }), i !== this.submissionGeneration)) return null;
1115
- for (const l of t.attachments ?? [])
1116
- l.id && this.attachmentFiles.delete(l.id);
1134
+ for (const u of t.attachments ?? [])
1135
+ u.id && this.attachmentFiles.delete(u.id);
1117
1136
  return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
1118
1137
  } catch (c) {
1119
1138
  if (i !== this.submissionGeneration) return null;
1120
- if (Z(c))
1121
- for (const u of t.attachments ?? [])
1122
- u.id && this.attachmentFiles.delete(u.id);
1123
- const l = this.submissionPreviews.get(r);
1124
- throw l && (l.pending = !1, l.error = g(c), l.retry = !d && g(c).code === "command_not_received" ? () => this.sendMessageNow(e, t, i) : void 0, this.emit("state", this.getState())), d && await this.adapter.dispatch({
1139
+ if (W(c))
1140
+ for (const l of t.attachments ?? [])
1141
+ l.id && this.attachmentFiles.delete(l.id);
1142
+ const u = this.submissionPreviews.get(r);
1143
+ throw u && (u.pending = !1, u.error = g(c), u.retry = !d && g(c).code === "command_not_received" ? () => this.sendMessageNow(e, t, i) : void 0, this.emit("state", this.getState())), d && await this.adapter.dispatch({
1125
1144
  type: "conversation.fail_staged",
1126
1145
  clientMessageId: r,
1127
1146
  message: g(c).message
@@ -1165,7 +1184,7 @@ class Re {
1165
1184
  ...t,
1166
1185
  e.activeResponseUserMessageId,
1167
1186
  e.messages.filter((c) => c.role === "user").slice(-1)[0]?.id
1168
- ].filter((c) => !!c))], n = x((c) => this.reportOperationTiming(c), {
1187
+ ].filter((c) => !!c))], n = j((c) => this.reportOperationTiming(c), {
1169
1188
  operation: "stop",
1170
1189
  layer: "renderer",
1171
1190
  requestId: crypto.randomUUID(),
@@ -1181,8 +1200,8 @@ class Re {
1181
1200
  const a = this.submissionGeneration;
1182
1201
  r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
1183
1202
  }, (c) => {
1184
- if (!(a !== this.submissionGeneration || i.every((l) => !this.stopPreviews.has(l)))) {
1185
- for (const l of i) this.stopPreviews.delete(l);
1203
+ if (!(a !== this.submissionGeneration || i.every((u) => !this.stopPreviews.has(u)))) {
1204
+ for (const u of i) this.stopPreviews.delete(u);
1186
1205
  this.stopError = g(c).message;
1187
1206
  }
1188
1207
  }).finally(() => {
@@ -1194,15 +1213,46 @@ class Re {
1194
1213
  }), d.then(() => {
1195
1214
  });
1196
1215
  }
1216
+ async waitForSubmissionDurability(e, t) {
1217
+ let i = () => {
1218
+ }, n = () => {
1219
+ };
1220
+ return new Promise((r, o) => {
1221
+ n = () => {
1222
+ if (this.destroyed || t !== this.submissionGeneration) {
1223
+ r(!1);
1224
+ return;
1225
+ }
1226
+ const a = this.state;
1227
+ if (a.messages.some((c) => c.respondsToUserMessageId === e && c.dataType === "run_status" && !c.provisional)) {
1228
+ r(!1);
1229
+ return;
1230
+ }
1231
+ if (a.conversationDiagnostics?.failedClientMessageId === e && a.lastError && a.lastErrorCode !== "submission_checkpoint_pending") {
1232
+ o(Object.assign(new Error(a.lastError), { code: a.lastErrorCode }));
1233
+ return;
1234
+ }
1235
+ const d = a.messages.find((c) => c.id === `submission-error:${e}` && c.dataType === "run_error");
1236
+ if (d) {
1237
+ o(new Error(d.content));
1238
+ return;
1239
+ }
1240
+ a.receipts?.some((c) => c.userMessageId === e && c.durable) && r(!0);
1241
+ }, this.durabilityWaiters.add(n), i = this.on("state", n), n();
1242
+ }).finally(() => {
1243
+ i(), this.durabilityWaiters.delete(n);
1244
+ });
1245
+ }
1197
1246
  cancelPendingSubmissions(e = !0) {
1198
1247
  this.pendingStop = null, e && this.stopPreviews.clear(), this.stopError = null;
1199
1248
  const t = [...this.pendingTransfers.keys()];
1200
1249
  this.submissionGeneration++;
1250
+ for (const i of this.durabilityWaiters) i();
1201
1251
  for (const i of this.pendingTransfers.values())
1202
1252
  for (const n of i) this.attachmentFiles.delete(n);
1203
1253
  this.pendingTransfers.clear();
1204
1254
  for (const i of this.submissionPreviews.values()) {
1205
- i.pending = !1, i.retry = void 0;
1255
+ i.pending = !1, i.retry = void 0, i.error?.code === "submission_checkpoint_pending" && (i.error = void 0);
1206
1256
  for (const n of i.message.attachments ?? [])
1207
1257
  n.id && this.attachmentFiles.delete(n.id);
1208
1258
  }
@@ -1222,7 +1272,7 @@ class Re {
1222
1272
  return t.sessionHistoryPage;
1223
1273
  }
1224
1274
  getSessionHistoryState() {
1225
- return j(this.sessionHistoryState);
1275
+ return z(this.sessionHistoryState);
1226
1276
  }
1227
1277
  subscribeSessionHistory(e) {
1228
1278
  return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
@@ -1304,7 +1354,7 @@ class Re {
1304
1354
  for (const n of i ?? []) n(t);
1305
1355
  }
1306
1356
  }
1307
- function be(s, e) {
1357
+ function Ie(s, e) {
1308
1358
  if (!e || !s) return e;
1309
1359
  const t = /* @__PURE__ */ new Map();
1310
1360
  for (const i of s) {
@@ -1316,7 +1366,7 @@ function be(s, e) {
1316
1366
  return n ? { ...i, previewUrl: n } : i;
1317
1367
  });
1318
1368
  }
1319
- function w(s) {
1369
+ function A(s) {
1320
1370
  return {
1321
1371
  ...s,
1322
1372
  starterPrompts: [...s.starterPrompts],
@@ -1340,36 +1390,36 @@ function w(s) {
1340
1390
  activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
1341
1391
  };
1342
1392
  }
1343
- function j(s) {
1393
+ function z(s) {
1344
1394
  return {
1345
1395
  ...s,
1346
1396
  data: s.data ? v({
1347
- entities: H(s.data).map((e) => ({ ...e })),
1397
+ entities: Z(s.data).map((e) => ({ ...e })),
1348
1398
  nextCursor: s.data.nextCursor
1349
1399
  }) : null
1350
1400
  };
1351
1401
  }
1352
1402
  export {
1353
- V as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1354
- Ee as ProductAgentInteractionManager,
1355
- q as ProductAgentQueryController,
1356
- Re as ProductAgentRemoteRuntimeClient,
1357
- Te as ProductAgentSessionHistoryManager,
1358
- qe as ProductAgentTaskPageTitleController,
1359
- Ae as canSubmitPersonalProductAgentMessage,
1360
- Pe as createLocalStorageInteractionDecisionStorage,
1361
- y as createProductAgentQueryState,
1362
- ke as createProductAgentTaskPageTitleDocument,
1363
- se as formatProductAgentTaskPageTitle,
1364
- Se as hasProductAgentPaidCreditFallback,
1365
- Z as isProductAgentAuthReconnectError,
1366
- Oe as isProductAgentRuntimeCommand,
1367
- Q as mergeProductAgentEntityPages,
1403
+ J as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1404
+ ke as ProductAgentInteractionManager,
1405
+ O as ProductAgentQueryController,
1406
+ xe as ProductAgentRemoteRuntimeClient,
1407
+ Pe as ProductAgentSessionHistoryManager,
1408
+ Oe as ProductAgentTaskPageTitleController,
1409
+ Me as canSubmitPersonalProductAgentMessage,
1410
+ qe as createLocalStorageInteractionDecisionStorage,
1411
+ b as createProductAgentQueryState,
1412
+ Re as createProductAgentTaskPageTitleDocument,
1413
+ ne as formatProductAgentTaskPageTitle,
1414
+ Ae as hasProductAgentPaidCreditFallback,
1415
+ W as isProductAgentAuthReconnectError,
1416
+ Ce as isProductAgentRuntimeCommand,
1417
+ V as mergeProductAgentEntityPages,
1368
1418
  v as normalizeProductAgentEntityPage,
1369
- X as readLocalStorageInteractionDecisions,
1370
- _e as reconcileProductAgentSubmissionGate,
1371
- we as resolveProductAgentBillingPresentation,
1372
- Me as resolveProductAgentComposerAction,
1373
- Ie as resolveProductAgentWidgetPresentation,
1374
- H as selectProductAgentQueryEntities
1419
+ te as readLocalStorageInteractionDecisions,
1420
+ Se as reconcileProductAgentSubmissionGate,
1421
+ Ee as resolveProductAgentBillingPresentation,
1422
+ Te as resolveProductAgentComposerAction,
1423
+ we as resolveProductAgentWidgetPresentation,
1424
+ Z as selectProductAgentQueryEntities
1375
1425
  };