@pluno/product-agent-web 0.1.282 → 0.1.284

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,9 +1,9 @@
1
- function Ie(s, e) {
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: [] };
1
+ function Se(i, e) {
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"] } : i ?? { allowed: !0, reason: "allowed", actions: [] };
3
3
  }
4
- function v(s) {
4
+ function _(i) {
5
5
  return {
6
- key: s,
6
+ key: i,
7
7
  status: "not_requested",
8
8
  data: null,
9
9
  error: null,
@@ -12,8 +12,8 @@ function v(s) {
12
12
  };
13
13
  }
14
14
  class q {
15
- constructor(e, t, i = (n, r) => r) {
16
- this.loader = t, this.merge = i, this.state = v(e);
15
+ constructor(e, t, s = (n, r) => r) {
16
+ this.loader = t, this.merge = s, this.state = _(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 = v(e), this.trailingLoad = null, this.publish());
31
+ e !== this.state.key && (this.state = _(e), this.trailingLoad = null, this.publish());
32
32
  }
33
33
  reset() {
34
- this.state = v(this.state.key), this.trailingLoad = null, this.publish();
34
+ this.state = _(this.state.key), this.trailingLoad = null, this.publish();
35
35
  }
36
36
  invalidate() {
37
37
  this.state = {
@@ -55,16 +55,16 @@ class q {
55
55
  for (; this.trailingLoad; ) {
56
56
  const e = this.trailingLoad;
57
57
  this.trailingLoad = null;
58
- const t = this.state.key, i = this.state.requestId + 1;
58
+ const t = this.state.key, s = this.state.requestId + 1;
59
59
  this.state = {
60
60
  ...this.state,
61
61
  status: e.mode === "append" ? "loading_more" : this.state.data === null ? "loading" : "refreshing",
62
62
  error: null,
63
- requestId: i
63
+ requestId: s
64
64
  }, this.publish();
65
65
  try {
66
66
  const n = await this.loader({ key: t, cursor: e.cursor });
67
- if (t !== this.state.key || i !== this.state.requestId) continue;
67
+ if (t !== this.state.key || s !== this.state.requestId) continue;
68
68
  this.state = {
69
69
  ...this.state,
70
70
  status: "ready",
@@ -73,7 +73,7 @@ class q {
73
73
  updatedAt: Date.now()
74
74
  }, this.publish();
75
75
  } catch (n) {
76
- if (t !== this.state.key || i !== this.state.requestId) continue;
76
+ if (t !== this.state.key || s !== this.state.requestId) continue;
77
77
  this.state = {
78
78
  ...this.state,
79
79
  status: "error",
@@ -86,68 +86,68 @@ class q {
86
86
  for (const e of this.listeners) e(this.state);
87
87
  }
88
88
  }
89
- function _(s) {
89
+ function I(i) {
90
90
  const e = {}, t = [];
91
- for (const i of s.entities)
92
- e[i.id] || t.push(i.id), e[i.id] = i;
91
+ for (const s of i.entities)
92
+ e[s.id] || t.push(s.id), e[s.id] = s;
93
93
  return {
94
94
  entitiesById: e,
95
95
  ids: t,
96
- nextCursor: s.nextCursor
96
+ nextCursor: i.nextCursor
97
97
  };
98
98
  }
99
- function V(s, e, t) {
100
- if (t === "replace" || s === null) return e;
101
- const i = { ...s.entitiesById, ...e.entitiesById }, n = [...s.ids];
99
+ function Z(i, e, t) {
100
+ if (t === "replace" || i === null) return e;
101
+ const s = { ...i.entitiesById, ...e.entitiesById }, n = [...i.ids];
102
102
  for (const r of e.ids)
103
- s.entitiesById[r] || n.push(r);
104
- return { entitiesById: i, ids: n, nextCursor: e.nextCursor };
103
+ i.entitiesById[r] || n.push(r);
104
+ return { entitiesById: s, ids: n, nextCursor: e.nextCursor };
105
105
  }
106
- function Z(s) {
107
- return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
106
+ function J(i) {
107
+ return i ? i.ids.map((e) => i.entitiesById[e]).filter((e) => !!e) : [];
108
108
  }
109
- function Se(s) {
110
- return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
109
+ function we(i) {
110
+ return i.visible ? i.minimized ? { state: "minimized" } : { state: i.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
111
111
  }
112
- function we(s) {
113
- if (!s || typeof s != "object") return !1;
114
- const e = s.paidCreditFallbackModel;
112
+ function Ae(i) {
113
+ if (!i || typeof i != "object") return !1;
114
+ const e = i.paidCreditFallbackModel;
115
115
  return typeof e == "string" && e.length > 0;
116
116
  }
117
- function Ae(s) {
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" };
117
+ function Ee(i) {
118
+ return i ? i.submissionGate?.allowed === !1 ? ["credits_exhausted", "payment_issue", "onboarding_required"].includes(i.submissionGate.reason) ? { state: "action_required", reason: i.submissionGate.reason } : { state: "hidden" } : i.usingPaidCreditFallback === !0 ? { state: "paid_credit_fallback" } : i.creditLimit !== null && i.creditLimit > 0 && i.creditsRemaining !== null && i.creditsRemaining > 0 && i.creditsRemaining / i.creditLimit <= 0.2 ? { state: "low_credits" } : i.creditsUsed !== null ? { state: "usage" } : { state: "hidden" } : { state: "hidden" };
119
119
  }
120
- function Me(s) {
121
- return s.submissionAllowed && s.isAuthenticated && s.hasWorkspace && !s.isWebsiteBlocked && s.isCurrentPageResolved && !s.isSubmitting && !s.hasPendingMessage;
120
+ function Pe(i) {
121
+ return i.submissionAllowed && i.isAuthenticated && i.hasWorkspace && !i.isWebsiteBlocked && i.isCurrentPageResolved && !i.isSubmitting && !i.hasPendingMessage;
122
122
  }
123
- function Ee(s) {
124
- const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
125
- return s.hasRunningAssistantTurn && !e ? {
123
+ function Me(i) {
124
+ const e = i.hasDraftMessage || i.hasPreSubmittedAttachment;
125
+ return i.hasRunningAssistantTurn && !e ? {
126
126
  action: "stop",
127
- disabled: !s.canStopRunningTurn
127
+ disabled: !i.canStopRunningTurn
128
128
  } : {
129
129
  action: "send",
130
- disabled: !e || !s.canSubmitMessage
130
+ disabled: !e || !i.canSubmitMessage
131
131
  };
132
132
  }
133
- const J = "Pluno is reconnecting. Try again in a moment.";
134
- function O(s) {
135
- return (s instanceof Error ? s.message : s) === J;
133
+ const W = "Pluno is reconnecting. Try again in a moment.";
134
+ function O(i) {
135
+ return (i instanceof Error ? i.message : i) === W;
136
136
  }
137
137
  class Te {
138
- constructor(e, t, i = 20) {
139
- this.loadPage = t, this.limit = i, this.recentQuery = new q(
138
+ constructor(e, t, s = 20) {
139
+ this.loadPage = t, this.limit = s, this.recentQuery = new q(
140
140
  `${e}:recent`,
141
- async ({ cursor: n }) => _(
141
+ async ({ cursor: n }) => I(
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
- V
147
+ Z
148
148
  ), this.pinnedQuery = new q(
149
149
  `${e}:pinned`,
150
- async () => _({
150
+ async () => I({
151
151
  entities: await this.loadAllPinned(),
152
152
  nextCursor: null
153
153
  })
@@ -166,19 +166,19 @@ class Te {
166
166
  completedRefreshSequence = 0;
167
167
  activityReconciliationScheduled = !1;
168
168
  getState() {
169
- const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), i = [
170
- ...b(t.data),
171
- ...b(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 ? _({
175
- entities: [...a, ...r],
169
+ const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), s = [
170
+ ...v(t.data),
171
+ ...v(e.data)
172
+ ], n = new Map(s.map((c) => [c.id, c])), r = Array.from(n.values()).map(
173
+ (c) => this.applyOverrides(c, this.completedRefreshSequence)
174
+ ), o = Array.from(this.optimisticEntities.values()).filter((c) => !n.has(c.id)).reverse(), a = e.data || t.data || o.length > 0 ? I({
175
+ entities: [...o, ...r],
176
176
  nextCursor: e.data?.nextCursor ?? null
177
177
  }) : null;
178
178
  return {
179
179
  key: e.key.slice(0, -7),
180
- status: W(e, t),
181
- data: o,
180
+ status: Y(e, t),
181
+ data: a,
182
182
  error: e.error ?? t.error,
183
183
  requestId: Math.max(e.requestId, t.requestId),
184
184
  updatedAt: Math.max(e.updatedAt ?? 0, t.updatedAt ?? 0) || null
@@ -223,56 +223,56 @@ class Te {
223
223
  isActive: t,
224
224
  confirmAfterRefresh: this.completedRefreshSequence + 1,
225
225
  releaseAfterRefresh: this.completedRefreshSequence + 2
226
- }), this.updateEntity(e, (i) => ({ ...i, isActive: t }));
226
+ }), this.updateEntity(e, (s) => ({ ...s, isActive: t }));
227
227
  }
228
228
  setPinned(e, t) {
229
- const i = { pinned: t, confirmAfterRefresh: Number.POSITIVE_INFINITY };
230
- return this.pinnedOverrides.set(e, i), this.updateEntity(e, (n) => ({ ...n, isPinned: t })), i;
229
+ const s = { pinned: t, confirmAfterRefresh: Number.POSITIVE_INFINITY };
230
+ return this.pinnedOverrides.set(e, s), this.updateEntity(e, (n) => ({ ...n, isPinned: t })), s;
231
231
  }
232
232
  confirmPinned(e, t) {
233
233
  this.pinnedOverrides.get(e) === t && (t.confirmAfterRefresh = this.completedRefreshSequence + 1);
234
234
  }
235
- rollbackPinned(e, t, i) {
236
- this.pinnedOverrides.get(e) === t && (this.pinnedOverrides.delete(e), this.updateEntity(e, (n) => ({ ...n, isPinned: i })));
235
+ rollbackPinned(e, t, s) {
236
+ this.pinnedOverrides.get(e) === t && (this.pinnedOverrides.delete(e), this.updateEntity(e, (n) => ({ ...n, isPinned: s })));
237
237
  }
238
238
  setTitle(e, t) {
239
- this.titleOverrides.set(e, t), this.updateEntity(e, (i) => ({ ...i, customTitle: t }));
239
+ this.titleOverrides.set(e, t), this.updateEntity(e, (s) => ({ ...s, customTitle: t }));
240
240
  }
241
241
  confirmTitle(e) {
242
242
  this.titleOverrides.delete(e);
243
243
  }
244
244
  reconcileDurableEntities() {
245
245
  const e = [
246
- ...b(this.pinnedQuery.getState().data),
247
- ...b(this.recentQuery.getState().data)
248
- ], t = new Set(e.map((i) => i.id));
249
- for (const i of this.optimisticEntities.keys())
250
- t.has(i) && this.optimisticEntities.delete(i);
251
- for (const i of e) this.applyOverrides(i, this.completedRefreshSequence);
246
+ ...v(this.pinnedQuery.getState().data),
247
+ ...v(this.recentQuery.getState().data)
248
+ ], t = new Set(e.map((s) => s.id));
249
+ for (const s of this.optimisticEntities.keys())
250
+ t.has(s) && this.optimisticEntities.delete(s);
251
+ for (const s of e) this.applyOverrides(s, this.completedRefreshSequence);
252
252
  this.publish();
253
253
  }
254
254
  async loadAllPinned() {
255
255
  const e = [];
256
256
  let t = null;
257
257
  do {
258
- const i = await this.loadPage({ cursor: t, limit: this.limit, pinned: !0 });
259
- e.push(...i.sessions), t = i.nextCursor;
258
+ const s = await this.loadPage({ cursor: t, limit: this.limit, pinned: !0 });
259
+ e.push(...s.sessions), t = s.nextCursor;
260
260
  } while (t);
261
261
  return e;
262
262
  }
263
263
  applyOverrides(e, t) {
264
- let i = e;
264
+ let s = e;
265
265
  const n = this.activityOverrides.get(e.id);
266
- n && (t >= n.confirmAfterRefresh && e.isActive === n.isActive ? this.activityOverrides.delete(e.id) : t >= n.releaseAfterRefresh ? this.activityOverrides.delete(e.id) : i = { ...i, isActive: n.isActive });
266
+ n && (t >= n.confirmAfterRefresh && e.isActive === n.isActive ? this.activityOverrides.delete(e.id) : t >= n.releaseAfterRefresh ? this.activityOverrides.delete(e.id) : s = { ...s, isActive: n.isActive });
267
267
  const r = this.pinnedOverrides.get(e.id);
268
- return r && (t >= r.confirmAfterRefresh && e.isPinned === !0 === r.pinned ? this.pinnedOverrides.delete(e.id) : i = { ...i, isPinned: r.pinned }), this.titleOverrides.has(e.id) && (i = { ...i, customTitle: this.titleOverrides.get(e.id) ?? null }), i;
268
+ return r && (t >= r.confirmAfterRefresh && e.isPinned === !0 === r.pinned ? this.pinnedOverrides.delete(e.id) : s = { ...s, isPinned: r.pinned }), this.titleOverrides.has(e.id) && (s = { ...s, customTitle: this.titleOverrides.get(e.id) ?? null }), s;
269
269
  }
270
270
  updateProjection() {
271
271
  this.publish();
272
272
  }
273
273
  updateEntity(e, t) {
274
- const i = this.optimisticEntities.get(e);
275
- i && this.optimisticEntities.set(e, t(i)), this.publish();
274
+ const s = this.optimisticEntities.get(e);
275
+ s && this.optimisticEntities.set(e, t(s)), this.publish();
276
276
  }
277
277
  hasUnconfirmedActivityOverride() {
278
278
  return Array.from(this.activityOverrides.values()).some(
@@ -283,47 +283,47 @@ class Te {
283
283
  for (const e of this.listeners) e(this.getState());
284
284
  }
285
285
  }
286
- function b(s) {
287
- return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
286
+ function v(i) {
287
+ return i ? i.ids.map((e) => i.entitiesById[e]).filter((e) => !!e) : [];
288
288
  }
289
- function W(s, e) {
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";
289
+ function Y(i, e) {
290
+ return i.status === "error" || e.status === "error" ? "error" : i.status === "loading" || e.status === "loading" ? "loading" : i.status === "refreshing" || e.status === "refreshing" ? "refreshing" : i.status === "loading_more" ? "loading_more" : i.status === "ready" || e.status === "ready" ? "ready" : "not_requested";
291
291
  }
292
- function R(s) {
293
- const e = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?(?:Z|\+00:00)$/.exec(s);
292
+ function C(i) {
293
+ const e = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?(?:Z|\+00:00)$/.exec(i);
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 I(s) {
298
- if (s === null || typeof s == "string" || typeof s == "boolean") return !0;
299
- if (typeof s == "number") return Number.isFinite(s);
300
- if (Array.isArray(s)) return s.every(I);
301
- if (typeof s != "object") return !1;
302
- const e = Object.getPrototypeOf(s);
303
- return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(I);
297
+ function S(i) {
298
+ if (i === null || typeof i == "string" || typeof i == "boolean") return !0;
299
+ if (typeof i == "number") return Number.isFinite(i);
300
+ if (Array.isArray(i)) return i.every(S);
301
+ if (typeof i != "object") return !1;
302
+ const e = Object.getPrototypeOf(i);
303
+ return e !== Object.prototype && e !== null ? !1 : Object.values(i).every(S);
304
304
  }
305
- function z(s) {
306
- return s !== null && typeof s == "object" && !Object.isFrozen(s) && (Object.values(s).forEach(z), Object.freeze(s)), s;
305
+ function $(i) {
306
+ return i !== null && typeof i == "object" && !Object.isFrozen(i) && (Object.values(i).forEach($), Object.freeze(i)), i;
307
307
  }
308
- function Y(s) {
309
- if (!I(s)) throw new Error("Conversation inputs must be JSON-safe values.");
310
- return JSON.parse(JSON.stringify(s));
308
+ function X(i) {
309
+ if (!S(i)) throw new Error("Conversation inputs must be JSON-safe values.");
310
+ return JSON.parse(JSON.stringify(i));
311
311
  }
312
- function X(s, e) {
312
+ function ee(i, e) {
313
313
  if (!e) return !1;
314
- const t = s.executionByUserMessage[e];
314
+ const t = i.executionByUserMessage[e];
315
315
  if (t) return ["completed", "stopped", "failed"].includes(t.phase);
316
- const i = Object.values(s.items).sort((r, a) => R(r.created_at).localeCompare(R(a.created_at)) || r.id.localeCompare(a.id));
316
+ const s = Object.values(i.items).sort((r, o) => C(r.created_at).localeCompare(C(o.created_at)) || r.id.localeCompare(o.id));
317
317
  let n = !1;
318
- for (const r of i)
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))
318
+ for (const r of s)
319
+ if (r.type === "user_message" && (n = r.id === e), !!n && (r.type === "stopped" || r.type === "error" || r.type === "final_response" && i.streams[r.id]?.state === "finished" && i.streams[r.id].revision >= r.data.revision))
320
320
  return !0;
321
321
  return !1;
322
322
  }
323
- class Pe {
323
+ class ke {
324
324
  constructor(e, t = null) {
325
325
  this.storage = e, t && (this.decisions = new Map(
326
- t.filter(E).map((i) => [this.getDecisionKey(i), i])
326
+ t.filter(M).map((s) => [this.getDecisionKey(s), s])
327
327
  ), this.initialized = !0);
328
328
  }
329
329
  storage;
@@ -341,11 +341,11 @@ class Pe {
341
341
  receiveConversationSources(e) {
342
342
  for (const t of e) {
343
343
  if (!Number.isSafeInteger(t.version) || t.version < 0) throw new Error("Invalid interaction source version.");
344
- const i = JSON.stringify([t.conversation_id, t.id]), n = this.sources.get(i);
344
+ const s = JSON.stringify([t.conversation_id, t.id]), n = this.sources.get(s);
345
345
  if (n && n.version >= t.version) continue;
346
346
  if (n && n.payload.kind !== t.payload.kind) throw new Error("Interaction kind changed.");
347
- const r = n?.payload.kind === "personal_channel" && n.lifecycle === "completed" ? "completed" : t.lifecycle, a = n?.payload.kind === "sharing" && t.payload.kind === "sharing" ? { ...t.payload, variant: n.payload.variant } : t.payload;
348
- this.sources.set(i, z(Y({ ...t, lifecycle: r, payload: a }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
347
+ const r = n?.payload.kind === "personal_channel" && n.lifecycle === "completed" ? "completed" : t.lifecycle, o = n?.payload.kind === "sharing" && t.payload.kind === "sharing" ? { ...t.payload, variant: n.payload.variant } : t.payload;
348
+ this.sources.set(s, $(X({ ...t, lifecycle: r, payload: o }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
349
349
  }
350
350
  }
351
351
  /** @internal */
@@ -355,40 +355,40 @@ class Pe {
355
355
  /** @internal */
356
356
  getConversationInputs(e) {
357
357
  if (!this.conversationReader) return;
358
- const t = { share: null, integrations: [], channel: null }, i = e ? this.conversationReader(e) : null;
359
- if (!i) return t;
360
- const n = [...this.sources.values()].filter((r) => r.conversation_id === e).sort((r, a) => r.version - a.version || r.id.localeCompare(a.id));
358
+ const t = { share: null, integrations: [], channel: null }, s = e ? this.conversationReader(e) : null;
359
+ if (!s) return t;
360
+ const n = [...this.sources.values()].filter((r) => r.conversation_id === e).sort((r, o) => r.version - o.version || r.id.localeCompare(o.id));
361
361
  for (const r of n) {
362
- const a = r.payload;
363
- if (a.kind === "sharing") {
364
- if (t.share = null, !a.eligible || r.lifecycle !== "pending" || r.invocation !== "user" || !["main_web_chat", "automation", "extension_sidepanel", "extension_widget"].includes(r.entry_surface ?? "")) continue;
365
- const o = r.user_message_id ? i.items[r.user_message_id] : null;
362
+ const o = r.payload;
363
+ if (o.kind === "sharing") {
364
+ if (t.share = null, !o.eligible || r.lifecycle !== "pending" || r.invocation !== "user" || !["main_web_chat", "automation", "extension_sidepanel", "extension_widget"].includes(r.entry_surface ?? "")) continue;
365
+ const a = r.user_message_id ? s.items[r.user_message_id] : null;
366
366
  t.share = {
367
367
  revision: r.version,
368
368
  candidate: {
369
369
  id: r.id,
370
- variant: a.variant,
371
- userPrompt: o?.type === "user_message" ? o.data.content : "",
370
+ variant: o.variant,
371
+ userPrompt: a?.type === "user_message" ? a.data.content : "",
372
372
  assistantAnswer: ""
373
373
  },
374
- terminal: !a.wait_for_terminal || X(i, r.user_message_id)
374
+ terminal: !o.wait_for_terminal || ee(s, r.user_message_id)
375
375
  };
376
- } else a.kind === "integration_auth" ? t.integrations.push({
376
+ } else o.kind === "integration_auth" ? t.integrations.push({
377
377
  revision: r.version,
378
378
  request: {
379
379
  type: "pipedream_auth_required",
380
- authRequestId: a.request_id,
381
- appSlug: a.app_slug,
382
- appName: a.app_name,
383
- appLogo: a.app_logo ?? void 0,
384
- expiresAt: a.expires_at
380
+ authRequestId: o.request_id,
381
+ appSlug: o.app_slug,
382
+ appName: o.app_name,
383
+ appLogo: o.app_logo ?? void 0,
384
+ expiresAt: o.expires_at
385
385
  },
386
- lifecycle: r.lifecycle === "pending" && Date.parse(a.expires_at) <= Date.now() ? "expired" : r.lifecycle
386
+ lifecycle: r.lifecycle === "pending" && Date.parse(o.expires_at) <= Date.now() ? "expired" : r.lifecycle
387
387
  }) : t.channel = { revision: r.version, request: {
388
388
  type: "personal_channel_connection_required",
389
- requestId: a.request_id,
390
- channel: a.channel,
391
- managementUrl: a.management_url
389
+ requestId: o.request_id,
390
+ channel: o.channel,
391
+ managementUrl: o.management_url
392
392
  }, lifecycle: r.lifecycle };
393
393
  }
394
394
  return t;
@@ -401,111 +401,111 @@ class Pe {
401
401
  if (this.initialized) return;
402
402
  const e = await this.storage.load();
403
403
  this.decisions = new Map(
404
- e.filter(E).map((t) => [this.getDecisionKey(t), t])
404
+ e.filter(M).map((t) => [this.getDecisionKey(t), t])
405
405
  ), this.initialized = !0;
406
406
  }
407
407
  isEligible(e, t = Date.now()) {
408
- const i = this.scheduledEligibility.get(this.getExactKey(e));
409
- return i !== void 0 && i > t ? !1 : this.isDecisionEligible(this.decisions.get(this.getExactKey(e)), t) && this.isDecisionEligible(this.decisions.get(this.getCategoryKey(e)), t);
408
+ const s = this.scheduledEligibility.get(this.getExactKey(e));
409
+ return s !== void 0 && s > t ? !1 : this.isDecisionEligible(this.decisions.get(this.getExactKey(e)), t) && this.isDecisionEligible(this.decisions.get(this.getCategoryKey(e)), t);
410
410
  }
411
411
  getDecision(e) {
412
412
  return this.decisions.get(this.getExactKey(e)) ?? this.decisions.get(this.getCategoryKey(e)) ?? null;
413
413
  }
414
414
  getStatus(e, t = Date.now()) {
415
- const i = this.scheduledEligibility.get(this.getExactKey(e));
416
- if (i !== void 0 && i > t) return "scheduled";
415
+ const s = this.scheduledEligibility.get(this.getExactKey(e));
416
+ if (s !== void 0 && s > t) return "scheduled";
417
417
  const n = this.getDecision(e);
418
418
  return n ? n.action === "never" || n.action === "dont_show_again" ? "suppressed" : n.action === "dismiss" ? "resolved" : n.nextEligibleAt && Date.parse(n.nextEligibleAt) > t ? "snoozed" : "presentable" : "presentable";
419
419
  }
420
420
  scheduleEligibility(e, t) {
421
- const i = this.getExactKey(e), n = this.scheduledEligibility.get(i);
422
- return n !== void 0 ? n : (this.scheduledEligibility.set(i, t), t);
421
+ const s = this.getExactKey(e), n = this.scheduledEligibility.get(s);
422
+ return n !== void 0 ? n : (this.scheduledEligibility.set(s, t), t);
423
423
  }
424
424
  getNextEligibilityAt(e = Date.now()) {
425
425
  const t = [
426
- ...Array.from(this.scheduledEligibility.values()).filter((i) => i > e),
427
- ...Array.from(this.decisions.values()).map((i) => i.nextEligibleAt ? Date.parse(i.nextEligibleAt) : Number.NaN).filter((i) => Number.isFinite(i) && i > e)
426
+ ...Array.from(this.scheduledEligibility.values()).filter((s) => s > e),
427
+ ...Array.from(this.decisions.values()).map((s) => s.nextEligibleAt ? Date.parse(s.nextEligibleAt) : Number.NaN).filter((s) => Number.isFinite(s) && s > e)
428
428
  ];
429
429
  return t.length > 0 ? Math.min(...t) : null;
430
430
  }
431
- act(e, t, i = {}) {
432
- const n = this.actionQueue.then(() => this.applyAction(e, t, i));
431
+ act(e, t, s = {}) {
432
+ const n = this.actionQueue.then(() => this.applyAction(e, t, s));
433
433
  return this.actionQueue = n.then(() => {
434
434
  }, () => {
435
435
  }), n;
436
436
  }
437
- async applyAction(e, t, i) {
437
+ async applyAction(e, t, s) {
438
438
  if (!e.allowedActions.includes(t))
439
439
  throw new Error(`Interaction ${e.key} does not allow ${t}.`);
440
- if (!$(t))
440
+ if (!U(t))
441
441
  throw new Error(`Interaction action ${t} is not a persistence decision.`);
442
- const n = i.now ?? /* @__PURE__ */ new Date(), r = {
442
+ const n = s.now ?? /* @__PURE__ */ new Date(), r = {
443
443
  promptKey: e.key,
444
444
  category: e.category,
445
445
  action: t,
446
446
  scope: e.scope,
447
447
  decidedAt: n.toISOString(),
448
- nextEligibleAt: this.getNextEligibleAt(e, t, n, i.snoozeUntil)
449
- }, a = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), o = new Map(this.decisions);
450
- return o.set(a, r), await this.storage.save([...o.values()]), this.decisions = o, r;
448
+ nextEligibleAt: this.getNextEligibleAt(e, t, n, s.snoozeUntil)
449
+ }, o = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), a = new Map(this.decisions);
450
+ return a.set(o, r), await this.storage.save([...a.values()]), this.decisions = a, r;
451
451
  }
452
452
  isDecisionEligible(e, t) {
453
453
  return e ? e.action === "dismiss" || e.action === "never" || e.action === "dont_show_again" ? !1 : !e.nextEligibleAt || Date.parse(e.nextEligibleAt) <= t : !0;
454
454
  }
455
- getNextEligibleAt(e, t, i, n) {
455
+ getNextEligibleAt(e, t, s, n) {
456
456
  if (t === "later")
457
- return new Date(i.getTime() + (e.laterDelayMs ?? 3600 * 1e3)).toISOString();
457
+ return new Date(s.getTime() + (e.laterDelayMs ?? 3600 * 1e3)).toISOString();
458
458
  if (t === "snooze") {
459
- if (!n || n.getTime() <= i.getTime())
459
+ if (!n || n.getTime() <= s.getTime())
460
460
  throw new Error("Snooze requires a future next-eligible time.");
461
461
  return n.toISOString();
462
462
  }
463
463
  return null;
464
464
  }
465
465
  getDecisionKey(e) {
466
- const t = w(e.scope);
466
+ const t = A(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 `${w(e.scope)}:interaction:${e.key}`;
470
+ return `${A(e.scope)}:interaction:${e.key}`;
471
471
  }
472
472
  getCategoryKey(e) {
473
- return `${w(e.scope)}:category:${e.category}`;
473
+ return `${A(e.scope)}:category:${e.category}`;
474
474
  }
475
475
  }
476
- function ke(s, e) {
476
+ function Re(i, e) {
477
477
  return {
478
- load: async () => ee(s, e),
479
- save: async (t) => s.setItem(e, JSON.stringify(t))
478
+ load: async () => te(i, e),
479
+ save: async (t) => i.setItem(e, JSON.stringify(t))
480
480
  };
481
481
  }
482
- function ee(s, e) {
483
- const t = s.getItem(e);
482
+ function te(i, e) {
483
+ const t = i.getItem(e);
484
484
  if (!t) return [];
485
- const i = JSON.parse(t);
486
- return Array.isArray(i) ? i.filter(E) : [];
485
+ const s = JSON.parse(t);
486
+ return Array.isArray(s) ? s.filter(M) : [];
487
487
  }
488
- function w(s) {
489
- return `${s.level}:${s.key}`;
488
+ function A(i) {
489
+ return `${i.level}:${i.key}`;
490
490
  }
491
- function $(s) {
492
- return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
491
+ function U(i) {
492
+ return i === "dismiss" || i === "later" || i === "snooze" || i === "never" || i === "dont_show_again";
493
493
  }
494
- function E(s) {
495
- if (!s || typeof s != "object") return !1;
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") && $(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
494
+ function M(i) {
495
+ if (!i || typeof i != "object") return !1;
496
+ const e = i;
497
+ return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && U(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
498
498
  }
499
- const te = {
499
+ const se = {
500
500
  working: "⏳",
501
501
  completed: "✅",
502
502
  failed: "❗",
503
503
  stopped: "⏹️"
504
- }, se = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
- function ie(s, e) {
506
- if (!e) return S(s);
507
- const t = S(s), i = `${te[e]} Pluno`;
508
- return t ? `${i}: ${t}` : i;
504
+ }, ie = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
505
+ function ne(i, e) {
506
+ if (!e) return w(i);
507
+ const t = w(i), s = `${se[e]} Pluno`;
508
+ return t ? `${s}: ${t}` : s;
509
509
  }
510
510
  class qe {
511
511
  constructor(e) {
@@ -524,16 +524,16 @@ class qe {
524
524
  this.liveStatusVersion += 1, this.applyClear();
525
525
  }
526
526
  async syncStatus(e) {
527
- const t = this.liveStatusVersion, i = await e();
528
- i === void 0 || t !== this.liveStatusVersion || (i ? this.applyStatus(i) : this.applyClear());
527
+ const t = this.liveStatusVersion, s = await e();
528
+ s === void 0 || t !== this.liveStatusVersion || (s ? this.applyStatus(s) : this.applyClear());
529
529
  }
530
530
  applyStatus(e) {
531
531
  const t = this.titleDocument.getTitle();
532
- t !== this.lastAppliedTitle && (this.baseTitle = S(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
532
+ t !== this.lastAppliedTitle && (this.baseTitle = w(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
533
533
  }
534
534
  applyClear() {
535
- const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, i = this.lastAppliedTitle === null ? S(e) : e;
536
- this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : i !== e && this.titleDocument.setTitle(i);
535
+ const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, s = this.lastAppliedTitle === null ? w(e) : e;
536
+ this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : s !== e && this.titleDocument.setTitle(s);
537
537
  }
538
538
  handleTitleChanged() {
539
539
  !this.status || this.titleDocument.getTitle() === this.lastAppliedTitle || this.applyTitle();
@@ -541,19 +541,19 @@ class qe {
541
541
  applyTitle() {
542
542
  if (!this.status)
543
543
  return;
544
- const e = ie(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 Oe(s) {
548
+ function Oe(i) {
549
549
  return {
550
- getTitle: () => s.title,
550
+ getTitle: () => i.title,
551
551
  setTitle: (e) => {
552
- s.title = e;
552
+ i.title = e;
553
553
  },
554
554
  observeTitle: (e) => {
555
555
  const t = new MutationObserver(e);
556
- return t.observe(s.head, {
556
+ return t.observe(i.head, {
557
557
  childList: !0,
558
558
  subtree: !0,
559
559
  characterData: !0
@@ -561,112 +561,112 @@ function Oe(s) {
561
561
  }
562
562
  };
563
563
  }
564
- function S(s) {
565
- return s.replace(se, "");
564
+ function w(i) {
565
+ return i.replace(ie, "");
566
566
  }
567
- const ne = "0.1.282", re = {
568
- version: ne
569
- }, p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
570
- function oe(s) {
571
- if (!s || typeof s != "object") return !1;
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
- 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);
567
+ const re = "0.1.284", oe = {
568
+ version: re
569
+ }, g = (i) => typeof i == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(i) ? i : null;
570
+ function ae(i) {
571
+ if (!i || typeof i != "object") return !1;
572
+ const e = i, t = (n) => Number.isSafeInteger(n) && n >= 0, s = (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) && g(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 || g(r) !== null) && (n.projectionReady === null || typeof n.projectionReady == "boolean");
573
+ return Object.keys(e).every((n) => ["ownerId", "revision", "dropped", "lastIntent", "lastSelection", "transitions"].includes(n)) && g(e.ownerId) !== null && t(e.revision) && t(e.dropped) && (e.lastIntent == null || s(e.lastIntent)) && (e.lastSelection === null || s(e.lastSelection)) && Array.isArray(e.transitions) && e.transitions.length <= 16 && e.transitions.every(s);
574
574
  }
575
- function U(s) {
576
- if (!s || typeof s != "object") return !1;
577
- const e = s;
575
+ function F(i) {
576
+ if (!i || typeof i != "object") return !1;
577
+ const e = i;
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 C = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], T = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), f = (s) => s === null || T(s), ae = (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
- if (!s || typeof s != "object") return !1;
583
- const e = s;
584
- return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && f(e.sessionId) && T(e.itemId) && f(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && f(e.runId) && (e.createdAt === null || ae(e.createdAt));
580
+ const x = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], T = (i) => typeof i == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(i), y = (i) => i === null || T(i), de = (i) => typeof i == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(i) && Number.isFinite(Date.parse(i));
581
+ function L(i) {
582
+ if (!i || typeof i != "object") return !1;
583
+ const e = i;
584
+ return Object.keys(i).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && y(e.sessionId) && T(e.itemId) && y(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && y(e.runId) && (e.createdAt === null || de(e.createdAt));
585
585
  }
586
- function ce(s) {
587
- if (!s || typeof s != "object") return !1;
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 || oe(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));
586
+ function ce(i) {
587
+ if (!i || typeof i != "object") return !1;
588
+ const e = i, t = (s) => Number.isSafeInteger(s) && s >= 0;
589
+ return Object.keys(e).every((s) => ["capturedAt", "selectionKey", "userId", "loading", "draft", "thinking", "connected", "hasError", "phase", "queryStatus", "queryRequestId", "queryUpdatedAt", "renderSource", "selectionFencePending", "guardCreatedAt", "owner", "sdkVersion", "presentationGate", "firstObservedAt", "confirmationMs"].includes(s)) && t(e.capturedAt) && [e.queryUpdatedAt, e.guardCreatedAt].every((s) => s === null || t(s)) && [e.selectionKey, e.userId, e.phase, e.queryStatus, e.queryRequestId].every((s) => s === null || g(s) !== null) && [e.loading, e.draft, e.thinking, e.connected, e.hasError, e.selectionFencePending].every((s) => typeof s == "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((s) => s === void 0 || t(s));
590
590
  }
591
- function F(s) {
592
- if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
593
- const e = (i) => {
594
- if (!i || typeof i != "object") return !1;
595
- const n = i;
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((a) => ["key", "count", "rows", "truncated"].includes(a)) && f(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((a) => a && Object.keys(a).every((o) => ["itemId", "groupId"].includes(o)) && f(a.itemId) && f(a.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")) && f(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(T));
597
- }, t = s;
591
+ function G(i) {
592
+ if (!i || typeof i != "object" || Object.keys(i).some((s) => s !== "before" && s !== "current")) return !1;
593
+ const e = (s) => {
594
+ if (!s || typeof s != "object") return !1;
595
+ const n = s;
596
+ return Object.keys(s).every((r) => [...x, "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)) && y(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)) && y(o.itemId) && y(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")) && y(n.sessionId) && Number.isSafeInteger(n.runtimeItemCount) && n.runtimeItemCount >= 0 && typeof n.welcome == "boolean" && typeof n.truncated == "boolean" && x.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(T));
597
+ }, t = i;
598
598
  return (t.before === null || e(t.before)) && e(t.current);
599
599
  }
600
- const x = 500;
601
- function G(s) {
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 > x ? `${e.slice(0, x - 1)}…` : e;
600
+ const D = 500;
601
+ function B(i) {
602
+ const e = i.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 > D ? `${e.slice(0, D - 1)}…` : e;
604
604
  }
605
- function de(s) {
605
+ function le(i) {
606
606
  let e = 2166136261;
607
- for (let t = 0; t < s.length; t += 1)
608
- e ^= s.charCodeAt(t), e = Math.imul(e, 16777619);
607
+ for (let t = 0; t < i.length; t += 1)
608
+ e ^= i.charCodeAt(t), e = Math.imul(e, 16777619);
609
609
  return `fnv1a-${(e >>> 0).toString(16).padStart(8, "0")}`;
610
610
  }
611
- function P(s) {
612
- if (!s || typeof s != "object") return !1;
613
- const e = s;
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);
611
+ function k(i) {
612
+ if (!i || typeof i != "object") return !1;
613
+ const e = i;
614
+ return Object.keys(i).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 le(s) {
617
- if (!s || typeof s != "object") return !1;
618
- const e = s;
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 || P(e.normalization)) && !!e.builds && typeof e.builds == "object" && typeof e.builds.sdk == "string" && Object.entries(e.builds).every(([t, i]) => ["sdk", "rendererExtension", "contentExtension", "backgroundExtension"].includes(t) && typeof i == "string" && /^\d{1,5}\.\d{1,5}\.\d{1,5}$/.test(i));
616
+ function ue(i) {
617
+ if (!i || typeof i != "object") return !1;
618
+ const e = i;
619
+ return Object.keys(e).every((t) => ["sessionId", "requestId", "code", "normalization", "builds", "clientMessageId"].includes(t)) && (e.clientMessageId === void 0 || g(e.clientMessageId) !== null) && [e.sessionId, e.requestId, e.code].every((t) => t === null || g(t) !== null) && (e.normalization === void 0 || k(e.normalization)) && !!e.builds && typeof e.builds == "object" && typeof e.builds.sdk == "string" && Object.entries(e.builds).every(([t, s]) => ["sdk", "rendererExtension", "contentExtension", "backgroundExtension"].includes(t) && typeof s == "string" && /^\d{1,5}\.\d{1,5}\.\d{1,5}$/.test(s));
620
620
  }
621
- function ue(s, e, t, i, n = {}) {
622
- const r = !i && e === "conversation_error" && t !== void 0 && s.conversationDiagnostics?.errorMessageFingerprint === de(G(t)) ? s.conversationDiagnostics : void 0;
621
+ function pe(i, e, t, s, n = {}) {
622
+ const r = !s && e === "conversation_error" && t !== void 0 && i.conversationDiagnostics?.errorMessageFingerprint === le(B(t)) ? i.conversationDiagnostics : void 0;
623
623
  return {
624
- sessionId: p(s.sessionId),
625
- requestId: p(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
626
- ...p(r?.failedClientMessageId) ? { clientMessageId: r.failedClientMessageId } : {},
627
- code: r ? p(s.lastErrorCode) : null,
628
- ...P(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
629
- builds: { sdk: re.version, ...n }
624
+ sessionId: g(i.sessionId),
625
+ requestId: g(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
626
+ ...g(r?.failedClientMessageId) ? { clientMessageId: r.failedClientMessageId } : {},
627
+ code: r ? g(i.lastErrorCode) : null,
628
+ ...k(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
629
+ builds: { sdk: oe.version, ...n }
630
630
  };
631
631
  }
632
- function pe(s) {
633
- if (s.details !== void 0 && !I(s.details))
632
+ function he(i) {
633
+ if (i.details !== void 0 && !S(i.details))
634
634
  throw new TypeError("Product Agent transported error details must be JSON-safe.");
635
635
  return {
636
- code: s.code,
637
- message: s.message,
638
- retryable: s.retryable,
639
- ...s.details === void 0 ? {} : { details: s.details }
636
+ code: i.code,
637
+ message: i.message,
638
+ retryable: i.retryable,
639
+ ...i.details === void 0 ? {} : { details: i.details }
640
640
  };
641
641
  }
642
- function m(s, e = "runtime_error", t = "runtime") {
643
- const i = s !== null && typeof s == "object" ? s : null, n = typeof s == "string" ? s : i && "message" in i && typeof i.message == "string" ? i.message : "", r = i && "code" in i && typeof i.code == "string" && i.code.trim() ? i.code : e, a = i && "details" in i ? i.details : null, o = a && typeof a == "object" ? a : {}, d = {
644
- ...typeof o.httpStatus == "number" && Number.isInteger(o.httpStatus) && o.httpStatus >= 100 && o.httpStatus <= 599 ? { httpStatus: o.httpStatus } : {},
642
+ function m(i, e = "runtime_error", t = "runtime") {
643
+ const s = i !== null && typeof i == "object" ? i : null, n = typeof i == "string" ? i : s && "message" in s && typeof s.message == "string" ? s.message : "", r = s && "code" in s && typeof s.code == "string" && s.code.trim() ? s.code : e, o = s && "details" in s ? s.details : null, a = o && typeof o == "object" ? o : {}, c = {
644
+ ...typeof a.httpStatus == "number" && Number.isInteger(a.httpStatus) && a.httpStatus >= 100 && a.httpStatus <= 599 ? { httpStatus: a.httpStatus } : {},
645
645
  // Preserve the first boundary's shape after normalization replaces the original message/prototype.
646
- errorNormalization: P(o.errorNormalization) ? o.errorNormalization : {
646
+ errorNormalization: k(a.errorNormalization) ? a.errorNormalization : {
647
647
  boundary: t,
648
- category: s instanceof Error ? "error" : s === null ? "null" : Array.isArray(s) ? "array" : typeof s,
649
- messageKind: n.trim() === "[object Object]" ? "object_coercion" : n.trim() ? "text" : typeof s == "string" || i && "message" in i && typeof i.message == "string" ? "blank" : "non_text"
648
+ category: i instanceof Error ? "error" : i === null ? "null" : Array.isArray(i) ? "array" : typeof i,
649
+ messageKind: n.trim() === "[object Object]" ? "object_coercion" : n.trim() ? "text" : typeof i == "string" || s && "message" in s && typeof s.message == "string" ? "blank" : "non_text"
650
650
  },
651
- ...o.allocation === "unissued" ? { allocation: "unissued" } : {},
652
- ...["unissued", "rejected"].includes(String(o.acceptance)) ? { acceptance: String(o.acceptance) } : {},
653
- ...typeof o.securitySettingsUrl == "string" ? { securitySettingsUrl: o.securitySettingsUrl } : {},
654
- ...typeof o.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(o.transportCode) ? { transportCode: o.transportCode } : {},
655
- ...typeof o.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(o.requestId) ? { requestId: o.requestId } : {},
656
- ...typeof o.durationMs == "number" && Number.isFinite(o.durationMs) && o.durationMs >= 0 ? { durationMs: o.durationMs } : {},
657
- ...typeof o.successfulRequests == "number" && Number.isSafeInteger(o.successfulRequests) && o.successfulRequests >= 0 ? { successfulRequests: o.successfulRequests } : {}
651
+ ...a.allocation === "unissued" ? { allocation: "unissued" } : {},
652
+ ...["unissued", "rejected"].includes(String(a.acceptance)) ? { acceptance: String(a.acceptance) } : {},
653
+ ...typeof a.securitySettingsUrl == "string" ? { securitySettingsUrl: a.securitySettingsUrl } : {},
654
+ ...typeof a.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(a.transportCode) ? { transportCode: a.transportCode } : {},
655
+ ...typeof a.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(a.requestId) ? { requestId: a.requestId } : {},
656
+ ...typeof a.durationMs == "number" && Number.isFinite(a.durationMs) && a.durationMs >= 0 ? { durationMs: a.durationMs } : {},
657
+ ...typeof a.successfulRequests == "number" && Number.isSafeInteger(a.successfulRequests) && a.successfulRequests >= 0 ? { successfulRequests: a.successfulRequests } : {}
658
658
  };
659
- return pe({
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
- retryable: !!(i && "retryable" in i && i.retryable === !0),
663
- ...Object.keys(d).length ? { details: d } : {}
662
+ retryable: !!(s && "retryable" in s && s.retryable === !0),
663
+ ...Object.keys(c).length ? { details: c } : {}
664
664
  });
665
665
  }
666
- function B(s) {
667
- if (!s || typeof s != "object") return !1;
668
- const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
669
- return Object.keys(e).every((i) => [
666
+ function Q(i) {
667
+ if (!i || typeof i != "object") return !1;
668
+ const e = i, t = (s) => Number.isSafeInteger(s) && s >= 0;
669
+ return Object.keys(e).every((s) => [
670
670
  "requestId",
671
671
  "method",
672
672
  "route",
@@ -685,9 +685,9 @@ function B(s) {
685
685
  "release",
686
686
  "upstreamRequestId",
687
687
  "upstreamTraceId"
688
- ].includes(i)) && p(e.requestId) !== null && ["GET", "POST", "PUT", "PATCH", "DELETE"].includes(e.method) && ["/api/product-agent/conversations/:sessionId/snapshot", "/api/product-agent/:namespace/commands", "/api/product-agent/:namespace/:operation"].includes(e.route) && (e.status === null || t(e.status) && e.status >= 100 && e.status <= 599) && (e.abortTrigger === null || ["deadline", "transport_disposed", "owner_disposed", "authority_retired", "observation_released", "request_replaced", "caller_cancelled", "unexpected_abort"].includes(e.abortTrigger)) && ["http_deadline", "http_transport", "conversation_query", "browser", "http_response"].includes(e.owner) && (e.category === void 0 || /^[a-z0-9_]{1,80}$/.test(e.category)) && [e.responseHeadersMs, e.responseBodyMs].every((i) => i == null || t(i)) && t(e.elapsedMs) && t(e.attempt) && e.attempt >= 1 && e.attempt <= 10 && [e.queryRequestId, e.ownerId, e.sessionId].every((i) => i === null || p(i) !== null) && (e.authorityGeneration === null || t(e.authorityGeneration)) && typeof e.release == "string" && /^[a-zA-Z0-9._-]{1,80}$/.test(e.release) && [e.upstreamRequestId, e.upstreamTraceId].every((i) => i === null || typeof i == "string" && /^[a-zA-Z0-9_:;=./-]{1,160}$/.test(i));
688
+ ].includes(s)) && g(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((s) => s == null || t(s)) && t(e.elapsedMs) && t(e.attempt) && e.attempt >= 1 && e.attempt <= 10 && [e.queryRequestId, e.ownerId, e.sessionId].every((s) => s === null || g(s) !== 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((s) => s === null || typeof s == "string" && /^[a-zA-Z0-9_:;=./-]{1,160}$/.test(s));
689
689
  }
690
- const he = [
690
+ const ge = [
691
691
  "submit",
692
692
  "stop",
693
693
  "staging_ipc",
@@ -750,7 +750,7 @@ const he = [
750
750
  "acceptance_applied",
751
751
  "cancellation_queue",
752
752
  "cancellation_write"
753
- ], Q = [
753
+ ], H = [
754
754
  "request_timed_out",
755
755
  "delivery_unknown",
756
756
  "invalid_ack",
@@ -766,86 +766,86 @@ const he = [
766
766
  "backend_refusal",
767
767
  "unknown"
768
768
  ];
769
- function ge(s) {
770
- const e = s, t = e?.code;
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";
769
+ function fe(i) {
770
+ const e = i, t = e?.code;
771
+ return e?.backendRefusal === !0 ? "backend_refusal" : typeof t == "string" && t !== "backend_refusal" && H.includes(t) ? t : e?.name === "AbortError" ? "aborted" : e?.name === "TypeError" ? "type_error" : "unknown";
772
772
  }
773
- const H = Math.random().toString(36).slice(2);
774
- let fe = 0;
775
- const D = () => `timing:${H}:${++fe}`, y = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
776
- function k(s) {
777
- if (!s || typeof s != "object") return !1;
778
- const e = s;
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 || y(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) && he.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && y(e.spanId) && y(e.requestId) && (e.clientMessageId === null || y(e.clientMessageId)) && (e.sessionId === null || y(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
773
+ const V = Math.random().toString(36).slice(2);
774
+ let ye = 0;
775
+ const j = () => `timing:${V}:${++ye}`, b = (i) => typeof i == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(i);
776
+ function R(i) {
777
+ if (!i || typeof i != "object") return !1;
778
+ const e = i;
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 || b(e.workerId)) && (e.failureCategory === void 0 || e.status === "failed" && H.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) && b(e.spanId) && b(e.requestId) && (e.clientMessageId === null || b(e.clientMessageId)) && (e.sessionId === null || b(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
780
780
  }
781
- function j(s, e) {
782
- if (e = { workerId: H, ...e }, !s) return {
781
+ function N(i, e) {
782
+ if (e = { workerId: V, ...e }, !i) return {
783
783
  identity: e,
784
784
  mark: (n) => {
785
785
  },
786
786
  measure: (n, r) => r()
787
787
  };
788
- const t = performance.now(), i = (n, r, a, o, d) => {
789
- const c = {
788
+ const t = performance.now(), s = (n, r, o, a, c) => {
789
+ const d = {
790
790
  ...e,
791
791
  stage: n,
792
792
  status: r,
793
- spanId: o,
793
+ spanId: a,
794
794
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
795
- durationMs: Math.max(0, Math.round(performance.now() - a)),
796
- ...r === "failed" ? { failureCategory: ge(d) } : {}
795
+ durationMs: Math.max(0, Math.round(performance.now() - o)),
796
+ ...r === "failed" ? { failureCategory: fe(c) } : {}
797
797
  };
798
- s && k(c) && Promise.resolve().then(() => s(c)).catch(() => {
798
+ i && R(d) && Promise.resolve().then(() => i(d)).catch(() => {
799
799
  });
800
800
  };
801
801
  return {
802
802
  identity: e,
803
- mark: (n) => i(n, "observed", t, D()),
803
+ mark: (n) => s(n, "observed", t, j()),
804
804
  measure(n, r) {
805
- const a = performance.now(), o = D();
806
- return i(n, "started", a, o), r().then(
807
- (d) => (i(n, "completed", a, o), d),
808
- (d) => {
809
- throw i(n, "failed", a, o, d), d;
805
+ const o = performance.now(), a = j();
806
+ return s(n, "started", o, a), r().then(
807
+ (c) => (s(n, "completed", o, a), c),
808
+ (c) => {
809
+ throw s(n, "failed", o, a, c), c;
810
810
  }
811
811
  );
812
812
  }
813
813
  };
814
814
  }
815
- const A = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
816
- function me(s) {
817
- if (!s || typeof s != "object") return !1;
818
- const e = s;
819
- 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";
815
+ const E = (i) => i === null || typeof i == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(i);
816
+ function me(i) {
817
+ if (!i || typeof i != "object") return !1;
818
+ const e = i;
819
+ return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && E(e.sessionId) && E(e.responseItemId) && E(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
820
820
  }
821
- function ye(s, e, t = "stopped", i, n = "Run stopped by user.") {
822
- const r = new Set(i ?? [
823
- s.assistantDraftRespondsToUserMessageId,
824
- s.activeResponseUserMessageId,
825
- s.messages.filter((d) => d.role === "user").slice(-1)[0]?.id
826
- ].filter((d) => !!d)), a = s.messages.filter((d) => !(d.dataType === "run_status" && d.loading && r.has(d.respondsToUserMessageId ?? ""))).map((d) => r.has(d.respondsToUserMessageId ?? "") ? { ...d, loading: !1 } : d);
827
- for (const d of r)
828
- a.some((c) => c.respondsToUserMessageId === d && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary")) || a.some((c) => c.role === "user" && c.id === d) && a.push({ id: `local-interrupted:${d}`, role: "system", dataType: "run_status", provisional: t === "stopping", content: t === "stopping" ? "Stopping…" : n, createdAt: e, respondsToUserMessageId: d });
829
- const o = s.segments?.map((d) => ({ ...d, outcomeIds: [
830
- ...d.outcomeIds,
831
- ...a.filter((c) => c.id === `local-interrupted:${d.userMessageId}` && !d.outcomeIds.includes(c.id)).map((c) => c.id)
821
+ function be(i, e, t = "stopped", s, n = "Run stopped by user.") {
822
+ const r = new Set(s ?? [
823
+ i.assistantDraftRespondsToUserMessageId,
824
+ i.activeResponseUserMessageId,
825
+ i.messages.filter((c) => c.role === "user").slice(-1)[0]?.id
826
+ ].filter((c) => !!c)), o = i.messages.filter((c) => !(c.dataType === "run_status" && c.loading && r.has(c.respondsToUserMessageId ?? ""))).map((c) => r.has(c.respondsToUserMessageId ?? "") ? { ...c, loading: !1 } : c);
827
+ for (const c of r)
828
+ o.some((d) => d.respondsToUserMessageId === c && (d.dataType === "run_status" || d.dataType === "run_error" || d.role === "assistant" && d.phase !== "commentary")) || o.some((d) => d.role === "user" && d.id === c) && o.push({ id: `local-interrupted:${c}`, role: "system", dataType: "run_status", provisional: t === "stopping", content: t === "stopping" ? "Stopping…" : n, createdAt: e, respondsToUserMessageId: c });
829
+ const a = i.segments?.map((c) => ({ ...c, outcomeIds: [
830
+ ...c.outcomeIds,
831
+ ...o.filter((d) => d.id === `local-interrupted:${c.userMessageId}` && !c.outcomeIds.includes(d.id)).map((d) => d.id)
832
832
  ] }));
833
833
  return {
834
- ...s,
835
- messages: a,
834
+ ...i,
835
+ messages: o,
836
836
  isThinking: !1,
837
837
  isRetrying: !1,
838
838
  pendingMessageStatus: null,
839
839
  turnPhase: null,
840
- segments: o,
840
+ segments: a,
841
841
  activity: { phase: t, activeItemId: null },
842
- isLoadingSession: s.isLoadingSession && a.length === 0,
842
+ isLoadingSession: i.isLoadingSession && o.length === 0,
843
843
  taskStatus: t === "stopped" ? "stopped" : null,
844
844
  lastError: null,
845
845
  lastErrorCode: null
846
846
  };
847
847
  }
848
- const be = {
848
+ const ve = {
849
849
  "stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
850
850
  "in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
851
851
  "stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
@@ -861,23 +861,23 @@ const be = {
861
861
  "thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
862
862
  "thinking-without-progress": "Thinking remained visible without progress for five minutes."
863
863
  };
864
- function ve(s) {
865
- return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(be, s.slice(13));
864
+ function _e(i) {
865
+ return typeof i == "string" && i.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ve, i.slice(13));
866
866
  }
867
- function N(s) {
867
+ function K(i) {
868
868
  return {
869
- ...s.id === void 0 ? {} : { id: s.id },
870
- name: s.name,
871
- mimeType: s.mimeType,
872
- sizeBytes: s.sizeBytes,
873
- ...s.sandboxPath === void 0 ? {} : { sandboxPath: s.sandboxPath },
874
- ...s.storageKey === void 0 ? {} : { storageKey: s.storageKey },
875
- ...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
869
+ ...i.id === void 0 ? {} : { id: i.id },
870
+ name: i.name,
871
+ mimeType: i.mimeType,
872
+ sizeBytes: i.sizeBytes,
873
+ ...i.sandboxPath === void 0 ? {} : { sandboxPath: i.sandboxPath },
874
+ ...i.storageKey === void 0 ? {} : { storageKey: i.storageKey },
875
+ ...i.fileUrl === void 0 ? {} : { fileUrl: i.fileUrl }
876
876
  };
877
877
  }
878
- function Re(s) {
879
- if (!s || typeof s != "object" || !("type" in s)) return !1;
880
- const e = s;
878
+ function Ce(i) {
879
+ if (!i || typeof i != "object" || !("type" in i)) return !1;
880
+ const e = i;
881
881
  switch (e.type) {
882
882
  case "runtime.connect":
883
883
  case "session.new":
@@ -891,11 +891,11 @@ function Re(s) {
891
891
  case "runtime.warmup":
892
892
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
893
893
  case "runtime.report_operation_timing":
894
- return k(e.timing);
894
+ return R(e.timing);
895
895
  case "runtime.report_displayed_error":
896
- return (e.errorDiagnostic === void 0 || le(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);
896
+ return (e.errorDiagnostic === void 0 || ue(e.errorDiagnostic)) && (e.httpRequest === void 0 || Q(e.httpRequest)) && (e.historyRefreshFailure === void 0 || F(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);
897
897
  case "runtime.report_invalid_state_transition":
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" || ve(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
898
+ return (e.uiInvariant === void 0 || G(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");
899
899
  case "runtime.prompt_presented":
900
900
  return (e.feature === "notifications" || e.feature === "tab_grouping") && typeof e.openingGeneration == "number" && Number.isSafeInteger(e.openingGeneration) && e.openingGeneration > 0;
901
901
  case "runtime.widget_lifecycle":
@@ -925,9 +925,9 @@ function Re(s) {
925
925
  return !1;
926
926
  }
927
927
  }
928
- class Ce {
929
- constructor(e, t, i) {
930
- this.adapter = t, this.state = M(e), this.model = i;
928
+ class xe {
929
+ constructor(e, t, s) {
930
+ this.adapter = t, this.state = P(e), this.hasBeenReady = e.status === "connected" && e.submissionReady !== !1, this.model = s;
931
931
  }
932
932
  adapter;
933
933
  listeners = {};
@@ -936,11 +936,12 @@ class Ce {
936
936
  interactionListeners = /* @__PURE__ */ new Set();
937
937
  accountListeners = /* @__PURE__ */ new Set();
938
938
  state;
939
- sessionHistoryState = v("unavailable");
939
+ sessionHistoryState = _("unavailable");
940
940
  model;
941
941
  interactions = [];
942
942
  account = null;
943
943
  stagedProactiveSuggestionClientMessageId = null;
944
+ readinessPendingSubmissions = /* @__PURE__ */ new Set();
944
945
  pendingTransfers = /* @__PURE__ */ new Map();
945
946
  // Presentation of commands in transit only; the background remains the submission/delivery owner.
946
947
  submissionPreviews = /* @__PURE__ */ new Map();
@@ -953,49 +954,50 @@ class Ce {
953
954
  durabilityWaiters = /* @__PURE__ */ new Set();
954
955
  operationQueue = Promise.resolve();
955
956
  destroyed = !1;
957
+ hasBeenReady;
956
958
  on(e, t) {
957
- const i = this.listeners[e] ?? /* @__PURE__ */ new Set();
958
- return i.add(t), this.listeners[e] = i, () => i.delete(t);
959
+ const s = this.listeners[e] ?? /* @__PURE__ */ new Set();
960
+ return s.add(t), this.listeners[e] = s, () => s.delete(t);
959
961
  }
960
962
  getState() {
961
- const e = M(this.state);
963
+ const e = P(this.state);
962
964
  for (const [n, r] of this.submissionPreviews)
963
- e.messages.some((a) => a.id === n) || (e.messages.push({ ...r.message, attachments: r.message.attachments?.map((a) => ({ ...a })) }), 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"));
965
+ 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"));
964
966
  this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
965
967
  const t = [...this.stopPreviews.keys()];
966
968
  if (!t.length) return e;
967
- const i = ye(e, "", "stopping", t);
968
- return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
969
+ const s = be(e, "", "stopping", t);
970
+ return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: s.messages, segments: s.segments } : s;
969
971
  }
970
- updateProjection(e, t, i, n, r) {
972
+ updateProjection(e, t, s, n, r) {
971
973
  if (this.destroyed) return;
972
- const a = this.getState();
973
- (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());
974
- for (const o of e.messages)
975
- o.role === "user" && e.receipts?.find((d) => d.userMessageId === o.id)?.durable !== !1 && this.submissionPreviews.delete(o.id);
976
- this.state = M(e);
977
- for (const [o, d] of this.stopPreviews) {
978
- const c = e.activity?.executionKey;
979
- (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 === o && !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(o);
974
+ const o = this.getState(), a = !this.hasBeenReady && (!o.user || o.user.id === e.user?.id), c = o.stableSelectionKey !== void 0 && o.stableSelectionKey === e.stableSelectionKey && o.user?.id === e.user?.id && o.sessionId === e.sessionId && this.pendingTransfers.size > 0 && this.submissionRetries.size === 0 && [...this.pendingTransfers.keys()].every((d) => this.readinessPendingSubmissions.has(d));
975
+ !a && !c && (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());
976
+ for (const d of e.messages)
977
+ d.role === "user" && e.receipts?.find((l) => l.userMessageId === d.id)?.durable !== !1 && this.submissionPreviews.delete(d.id);
978
+ this.state = P(e), e.status === "connected" && e.submissionReady !== !1 && (this.hasBeenReady = !0);
979
+ for (const [d, l] of this.stopPreviews) {
980
+ const u = e.activity?.executionKey;
981
+ (l !== void 0 && l !== "[]" && u !== void 0 && u !== "[]" && (u !== l || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (l === void 0 || l === "[]") && e.messages.some((p) => p.respondsToUserMessageId === d && !p.provisional && p.loading !== !0 && (p.dataType === "run_status" || p.dataType === "run_error" || p.role === "assistant" && p.phase !== "commentary" && (p.streamState === void 0 || ["finished", "stopped", "failed"].includes(p.streamState))))) && this.stopPreviews.delete(d);
980
982
  }
981
- if (this.pendingStop?.userMessageIds.every((o) => !this.stopPreviews.has(o)) && (this.pendingStop = null), a.user?.id === e.user?.id)
982
- for (const o of this.state.messages) {
983
- if (o.role !== "user" || !o.attachments?.length) continue;
984
- const d = a.messages.find((c) => c.role === "user" && c.id === o.id);
985
- a.sessionId !== e.sessionId && !(a.sessionId === null && d) || (o.attachments = _e(d?.attachments, o.attachments));
983
+ if (this.pendingStop?.userMessageIds.every((d) => !this.stopPreviews.has(d)) && (this.pendingStop = null), o.user?.id === e.user?.id)
984
+ for (const d of this.state.messages) {
985
+ if (d.role !== "user" || !d.attachments?.length) continue;
986
+ const l = o.messages.find((u) => u.role === "user" && u.id === d.id);
987
+ o.sessionId !== e.sessionId && !(o.sessionId === null && l) || (d.attachments = Ie(l?.attachments, d.attachments));
986
988
  }
987
- if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
988
- this.sessionHistoryState = K(i);
989
- for (const o of this.sessionHistoryListeners)
990
- o(this.getSessionHistoryState());
989
+ if (t !== void 0 && (this.model = t), s && JSON.stringify(s) !== JSON.stringify(this.sessionHistoryState)) {
990
+ this.sessionHistoryState = z(s);
991
+ for (const d of this.sessionHistoryListeners)
992
+ d(this.getSessionHistoryState());
991
993
  }
992
994
  if (n && JSON.stringify(n) !== JSON.stringify(this.interactions)) {
993
- this.interactions = n.map((o) => ({ ...o }));
994
- for (const o of this.interactionListeners) o(this.getInteractions());
995
+ this.interactions = n.map((d) => ({ ...d }));
996
+ for (const d of this.interactionListeners) d(this.getInteractions());
995
997
  }
996
998
  if (r !== void 0 && JSON.stringify(r) !== JSON.stringify(this.account)) {
997
999
  this.account = r ? { ...r } : null;
998
- for (const o of this.accountListeners) o(this.getAccount());
1000
+ for (const d of this.accountListeners) d(this.getAccount());
999
1001
  }
1000
1002
  this.emit("state", this.getState());
1001
1003
  }
@@ -1022,61 +1024,61 @@ class Ce {
1022
1024
  this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
1023
1025
  }
1024
1026
  reportOperationTiming(e) {
1025
- !this.destroyed && k(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
1027
+ !this.destroyed && R(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
1026
1028
  });
1027
1029
  }
1028
1030
  reportResponseVisibility(e) {
1029
1031
  this.adapter.dispatch({ type: "runtime.report_response_visibility", observation: e }).catch(() => {
1030
1032
  });
1031
1033
  }
1032
- reportInvalidStateTransition(e, t, i) {
1033
- i !== void 0 && !F(i) || this.adapter.dispatch({
1034
+ reportInvalidStateTransition(e, t, s) {
1035
+ s !== void 0 && !G(s) || this.adapter.dispatch({
1034
1036
  type: "runtime.report_invalid_state_transition",
1035
1037
  reason: e,
1036
1038
  clientMessageId: t,
1037
- ...i ? { uiInvariant: i } : {}
1039
+ ...s ? { uiInvariant: s } : {}
1038
1040
  }).catch(() => {
1039
1041
  });
1040
1042
  }
1041
- reportDisplayedError(e, t, i, n, r) {
1042
- const a = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
1043
- if (n !== void 0 && !L(n) || r !== void 0 && !U(r)) return;
1044
- const o = ue(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds);
1043
+ reportDisplayedError(e, t, s, n, r) {
1044
+ const o = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
1045
+ if (n !== void 0 && !L(n) || r !== void 0 && !F(r)) return;
1046
+ const a = pe(this.getState(), e, s, !!n, this.adapter.diagnosticBuilds);
1045
1047
  this.adapter.dispatch({
1046
1048
  type: "runtime.report_displayed_error",
1047
- errorDiagnostic: o,
1048
- ...o.clientMessageId ? { clientMessageId: o.clientMessageId } : {},
1049
+ errorDiagnostic: a,
1050
+ ...a.clientMessageId ? { clientMessageId: a.clientMessageId } : {},
1049
1051
  reason: e,
1050
1052
  errorFingerprint: t,
1051
1053
  ...n ? { renderedError: n } : {},
1052
1054
  ...r ? { historyRefreshFailure: r } : {},
1053
- ...B(a) ? { httpRequest: a } : {},
1054
- ...i ? { displayedMessage: G(i) } : {}
1055
+ ...Q(o) ? { httpRequest: o } : {},
1056
+ ...s ? { displayedMessage: B(s) } : {}
1055
1057
  }).catch(() => {
1056
1058
  });
1057
1059
  }
1058
1060
  sendMessage(e, t = {}) {
1059
- const i = e.trim();
1060
- t = { ...t, attachments: t.attachments?.map((c) => ({ ...c })) };
1061
+ const s = e.trim();
1062
+ t = { ...t, attachments: t.attachments?.map((d) => ({ ...d })) };
1061
1063
  const n = t.attachments ?? [];
1062
- if (!i && n.length === 0) return Promise.resolve(null);
1064
+ if (!s && n.length === 0) return Promise.resolve(null);
1063
1065
  this.pendingStop = null, this.stopError = null;
1064
- const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), a = t.submittedAt ?? Date.now(), o = this.submissionGeneration;
1065
- this.pendingTransfers.set(r, n.flatMap((c) => c.id ? [c.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
1066
+ const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), o = t.submittedAt ?? Date.now(), a = this.submissionGeneration;
1067
+ this.pendingTransfers.set(r, n.flatMap((d) => d.id ? [d.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
1066
1068
  id: r,
1067
1069
  role: "user",
1068
- content: i,
1070
+ content: s,
1069
1071
  createdAt: "",
1070
- attachments: n.map((c) => ({ ...c }))
1072
+ attachments: n.map((d) => ({ ...d }))
1071
1073
  } });
1072
- const d = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt: a, selectionKey: this.state.selectionKey }, o);
1073
- return this.emit("state", this.getState()), d.finally(() => {
1074
+ const c = this.sendMessageNow(s, { ...t, clientMessageId: r, submittedAt: o, selectionKey: this.state.selectionKey }, a);
1075
+ return this.emit("state", this.getState()), c.finally(() => {
1074
1076
  this.pendingTransfers.delete(r);
1075
1077
  });
1076
1078
  }
1077
- async sendMessageNow(e, t, i) {
1078
- const n = e, r = t.clientMessageId, a = j((c) => {
1079
- i === this.submissionGeneration && this.reportOperationTiming(c);
1079
+ async sendMessageNow(e, t, s) {
1080
+ const n = e, r = t.clientMessageId, o = N((l) => {
1081
+ s === this.submissionGeneration && this.reportOperationTiming(l);
1080
1082
  }, {
1081
1083
  operation: "send",
1082
1084
  layer: "renderer",
@@ -1084,54 +1086,61 @@ class Ce {
1084
1086
  clientMessageId: r,
1085
1087
  sessionId: this.state.sessionId
1086
1088
  });
1087
- a.mark("submit");
1088
- let o = t.attachments ?? [], d = !1;
1089
- if (i !== this.submissionGeneration) return null;
1089
+ o.mark("submit");
1090
+ let a = t.attachments ?? [], c = !1, d = !this.hasBeenReady || this.state.submissionReady === !1;
1091
+ if (s !== this.submissionGeneration) return null;
1092
+ d && this.readinessPendingSubmissions.add(r);
1090
1093
  try {
1091
- const c = await a.measure("staging_ipc", async () => {
1092
- const u = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
1093
- type: "conversation.stage",
1094
- ...t.reconcileAcceptance ? { reconcileAcceptance: !0, selectionKey: t.selectionKey } : {},
1095
- initiatedBy: t.initiatedBy,
1096
- invocation: t.invocation,
1097
- automationOnboarding: t.automationOnboarding,
1098
- content: n,
1099
- clientMessageId: r,
1100
- proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1101
- // Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
1102
- attachments: o.length > 0 ? o.map(N) : void 0,
1103
- submittedAt: t.submittedAt
1104
- }) });
1105
- return u ? u.result.then((l) => ({ result: l }), async (l) => {
1106
- const h = m(l);
1107
- if (h.code !== "submission_checkpoint_pending") throw l;
1108
- const g = this.submissionPreviews.get(r);
1109
- return g && (g.error = h), this.emit("state", this.getState()), await this.waitForSubmissionDurability(r, i) ? { result: void 0 } : null;
1094
+ const l = await o.measure("staging_ipc", async () => {
1095
+ const u = await this.enqueueOperation(async () => {
1096
+ if (d) {
1097
+ if (!await o.measure("authentication", () => this.waitForSubmissionReadiness(s))) return null;
1098
+ this.readinessPendingSubmissions.delete(r), d = !1, t = { ...t, selectionKey: this.state.selectionKey };
1099
+ }
1100
+ return this.destroyed || s !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
1101
+ type: "conversation.stage",
1102
+ ...t.reconcileAcceptance ? { reconcileAcceptance: !0, selectionKey: t.selectionKey } : {},
1103
+ initiatedBy: t.initiatedBy,
1104
+ invocation: t.invocation,
1105
+ automationOnboarding: t.automationOnboarding,
1106
+ content: n,
1107
+ clientMessageId: r,
1108
+ proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1109
+ // Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
1110
+ attachments: a.length > 0 ? a.map(K) : void 0,
1111
+ submittedAt: t.submittedAt
1112
+ }) };
1113
+ });
1114
+ return u ? u.result.then((h) => ({ result: h }), async (h) => {
1115
+ const p = m(h);
1116
+ if (p.code !== "submission_checkpoint_pending") throw h;
1117
+ const f = this.submissionPreviews.get(r);
1118
+ return f && (f.error = p), this.emit("state", this.getState()), await this.waitForSubmissionDurability(r, s) ? { result: void 0 } : null;
1110
1119
  }) : null;
1111
1120
  });
1112
- if (!c || i !== this.submissionGeneration) return null;
1113
- if (d = !0, this.submissionRetries.delete(r), c.result?.submissionAccepted) {
1121
+ if (!l || s !== this.submissionGeneration) return null;
1122
+ if (c = !0, this.submissionRetries.delete(r), l.result?.submissionAccepted) {
1114
1123
  r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null);
1115
1124
  for (const u of t.attachments ?? [])
1116
1125
  u.id && this.attachmentFiles.delete(u.id);
1117
1126
  return r;
1118
1127
  }
1119
- if (o.length > 0) {
1128
+ if (a.length > 0) {
1120
1129
  if (!this.adapter.uploadAttachment)
1121
1130
  throw new Error("The runtime does not support attachments.");
1122
1131
  const u = [];
1123
- for (const l of o) {
1124
- if (l.sandboxPath || l.storageKey) {
1125
- u.push(l);
1132
+ for (const h of a) {
1133
+ if (h.sandboxPath || h.storageKey) {
1134
+ u.push(h);
1126
1135
  continue;
1127
1136
  }
1128
- const h = l.id ? this.attachmentFiles.get(l.id) : void 0;
1129
- if (!h) throw new Error(`Attachment bytes are unavailable for ${l.name}`);
1130
- if (u.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(h, l, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
1137
+ const p = h.id ? this.attachmentFiles.get(h.id) : void 0;
1138
+ if (!p) throw new Error(`Attachment bytes are unavailable for ${h.name}`);
1139
+ if (u.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(p, h, { clientMessageId: r }))), s !== this.submissionGeneration) return null;
1131
1140
  }
1132
- o = u;
1141
+ a = u;
1133
1142
  }
1134
- if (i !== this.submissionGeneration || (await this.adapter.dispatch({
1143
+ if (s !== this.submissionGeneration || (await this.adapter.dispatch({
1135
1144
  type: "conversation.send",
1136
1145
  content: n,
1137
1146
  clientMessageId: r,
@@ -1139,27 +1148,29 @@ class Ce {
1139
1148
  invocation: t.invocation,
1140
1149
  automationOnboarding: t.automationOnboarding,
1141
1150
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1142
- attachments: o.length > 0 ? o.map(N) : void 0
1143
- }), i !== this.submissionGeneration)) return null;
1151
+ attachments: a.length > 0 ? a.map(K) : void 0
1152
+ }), s !== this.submissionGeneration)) return null;
1144
1153
  for (const u of t.attachments ?? [])
1145
1154
  u.id && this.attachmentFiles.delete(u.id);
1146
1155
  return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
1147
- } catch (c) {
1148
- if (i !== this.submissionGeneration) return null;
1149
- if (O(c))
1150
- for (const g of t.attachments ?? [])
1151
- g.id && this.attachmentFiles.delete(g.id);
1152
- const l = m(c).code === "command_not_received";
1153
- !d && !O(c) && (l || t.selectionKey !== void 0) && this.submissionRetries.set(r, {
1154
- retry: () => this.sendMessageNow(e, { ...t, reconcileAcceptance: !l }, i),
1155
- attachmentIds: (t.attachments ?? []).flatMap((g) => g.id ? [g.id] : [])
1156
+ } catch (l) {
1157
+ if (s !== this.submissionGeneration) return null;
1158
+ if (O(l))
1159
+ for (const f of t.attachments ?? [])
1160
+ f.id && this.attachmentFiles.delete(f.id);
1161
+ const h = m(l).code === "command_not_received";
1162
+ !c && !O(l) && (d || h || t.selectionKey !== void 0) && this.submissionRetries.set(r, {
1163
+ retry: async () => (d && await this.connect(), this.sendMessageNow(e, { ...t, reconcileAcceptance: !d && !h }, s)),
1164
+ attachmentIds: (t.attachments ?? []).flatMap((f) => f.id ? [f.id] : [])
1156
1165
  });
1157
- const h = this.submissionPreviews.get(r);
1158
- throw h && (h.pending = !1, h.error = m(c), this.emit("state", this.getState())), d && await this.adapter.dispatch({
1166
+ const p = this.submissionPreviews.get(r);
1167
+ throw p && (p.pending = !1, p.error = m(l), this.emit("state", this.getState())), c && await this.adapter.dispatch({
1159
1168
  type: "conversation.fail_staged",
1160
1169
  clientMessageId: r,
1161
- message: m(c).message
1162
- }), c;
1170
+ message: m(l).message
1171
+ }), l;
1172
+ } finally {
1173
+ this.readinessPendingSubmissions.delete(r);
1163
1174
  }
1164
1175
  }
1165
1176
  getModel() {
@@ -1170,18 +1181,18 @@ class Ce {
1170
1181
  });
1171
1182
  }
1172
1183
  async retryLastMessage(e) {
1173
- const t = e ?? [...this.submissionPreviews].reverse().find(([, o]) => o.error)?.[0] ?? this.state.messages.filter((o) => o.role === "user").slice(-1)[0]?.id;
1184
+ const t = e ?? [...this.submissionPreviews].reverse().find(([, a]) => a.error)?.[0] ?? this.state.messages.filter((a) => a.role === "user").slice(-1)[0]?.id;
1174
1185
  if (!t || this.destroyed) return !1;
1175
- const i = this.submissionPreviews.get(t);
1176
- if (i?.pending || this.pendingTransfers.has(t)) return !1;
1177
- const n = this.submissionRetries.get(t), r = n?.retry, a = this.submissionGeneration;
1186
+ const s = this.submissionPreviews.get(t);
1187
+ if (s?.pending || this.pendingTransfers.has(t)) return !1;
1188
+ const n = this.submissionRetries.get(t), r = n?.retry, o = this.submissionGeneration;
1178
1189
  try {
1179
- return n && r ? (i && (i.pending = !0, i.error = void 0), this.submissionRetries.delete(t), this.pendingTransfers.set(t, n.attachmentIds), this.emit("state", this.getState()), await r()) : await this.dispatch({ type: "run.retry", clientMessageId: t }), !0;
1180
- } catch (o) {
1181
- if (!i && !r) throw o;
1182
- return i && a === this.submissionGeneration && this.submissionPreviews.get(t) === i && (i.error = m(o), this.emit("state", this.getState())), !1;
1190
+ return n && r ? (s && (s.pending = !0, s.error = void 0), this.submissionRetries.delete(t), this.pendingTransfers.set(t, n.attachmentIds), this.emit("state", this.getState()), await r()) : await this.dispatch({ type: "run.retry", clientMessageId: t }), !0;
1191
+ } catch (a) {
1192
+ if (!s && !r) throw a;
1193
+ return s && o === this.submissionGeneration && this.submissionPreviews.get(t) === s && (s.error = m(a), this.emit("state", this.getState())), !1;
1183
1194
  } finally {
1184
- r && this.pendingTransfers.delete(t), i && a === this.submissionGeneration && this.submissionPreviews.get(t) === i && (i.pending = !1, this.emit("state", this.getState()));
1195
+ r && this.pendingTransfers.delete(t), s && o === this.submissionGeneration && this.submissionPreviews.get(t) === s && (s.pending = !1, this.emit("state", this.getState()));
1185
1196
  }
1186
1197
  }
1187
1198
  createLocalAttachment(e) {
@@ -1195,83 +1206,106 @@ class Ce {
1195
1206
  }
1196
1207
  stop() {
1197
1208
  if (this.pendingStop) return this.pendingStop.promise;
1198
- const e = this.getState(), t = this.cancelPendingSubmissions(!1), i = [...new Set([
1209
+ const e = this.getState(), t = this.cancelPendingSubmissions(!1);
1210
+ if (!this.hasBeenReady && t.length > 0 && !this.state.isThinking && this.state.turnPhase === null && this.state.pendingMessageStatus === null)
1211
+ return this.emit("state", this.getState()), Promise.resolve();
1212
+ const s = [...new Set([
1199
1213
  ...t,
1200
1214
  e.activeResponseUserMessageId,
1201
- e.messages.filter((c) => c.role === "user").slice(-1)[0]?.id
1202
- ].filter((c) => !!c))], n = j((c) => this.reportOperationTiming(c), {
1215
+ e.messages.filter((d) => d.role === "user").slice(-1)[0]?.id
1216
+ ].filter((d) => !!d))], n = N((d) => this.reportOperationTiming(d), {
1203
1217
  operation: "stop",
1204
1218
  layer: "renderer",
1205
1219
  requestId: crypto.randomUUID(),
1206
- clientMessageId: i[0] ?? null,
1220
+ clientMessageId: s[0] ?? null,
1207
1221
  sessionId: e.sessionId
1208
1222
  });
1209
1223
  n.mark("stop");
1210
- const r = { userMessageIds: i, promise: Promise.resolve() };
1224
+ const r = { userMessageIds: s, promise: Promise.resolve() };
1211
1225
  this.pendingStop = r;
1212
- const a = !e.pendingMessageStatus && ["thinking", "steering", "queued", "stopping"].includes(this.state.activity?.phase ?? "") ? this.state.activity?.executionKey : void 0;
1213
- for (const c of i)
1214
- this.stopPreviews.set(c, t.includes(c) ? void 0 : a);
1215
- const o = this.submissionGeneration;
1226
+ const o = !e.pendingMessageStatus && ["thinking", "steering", "queued", "stopping"].includes(this.state.activity?.phase ?? "") ? this.state.activity?.executionKey : void 0;
1227
+ for (const d of s)
1228
+ this.stopPreviews.set(d, t.includes(d) ? void 0 : o);
1229
+ const a = this.submissionGeneration;
1216
1230
  r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
1217
- }, (c) => {
1218
- if (!(o !== this.submissionGeneration || i.every((u) => !this.stopPreviews.has(u)))) {
1219
- for (const u of i) this.stopPreviews.delete(u);
1220
- this.stopError = m(c).message;
1231
+ }, (d) => {
1232
+ if (!(a !== this.submissionGeneration || s.every((l) => !this.stopPreviews.has(l)))) {
1233
+ for (const l of s) this.stopPreviews.delete(l);
1234
+ this.stopError = m(d).message;
1221
1235
  }
1222
1236
  }).finally(() => {
1223
- this.destroyed || o !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
1237
+ this.destroyed || a !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
1224
1238
  }), this.emit("state", this.getState());
1225
- const d = r.promise;
1226
- return this.operationQueue = d.then(() => {
1239
+ const c = r.promise;
1240
+ return this.operationQueue = c.then(() => {
1227
1241
  }, () => {
1228
- }), d.then(() => {
1242
+ }), c.then(() => {
1243
+ });
1244
+ }
1245
+ async waitForSubmissionReadiness(e) {
1246
+ let t = () => {
1247
+ }, s = () => {
1248
+ };
1249
+ return new Promise((n, r) => {
1250
+ s = () => {
1251
+ if (this.destroyed || e !== this.submissionGeneration) {
1252
+ n(!1);
1253
+ return;
1254
+ }
1255
+ if (this.state.lastError && ["connection_failed", "unauthorized", "update_required"].includes(this.state.lastErrorCode ?? "")) {
1256
+ r(Object.assign(new Error(this.state.lastError), { code: this.state.lastErrorCode }));
1257
+ return;
1258
+ }
1259
+ this.hasBeenReady && this.state.submissionReady !== !1 && n(!0);
1260
+ }, this.durabilityWaiters.add(s), t = this.on("state", s), s();
1261
+ }).finally(() => {
1262
+ t(), this.durabilityWaiters.delete(s);
1229
1263
  });
1230
1264
  }
1231
1265
  async waitForSubmissionDurability(e, t) {
1232
- let i = () => {
1266
+ let s = () => {
1233
1267
  }, n = () => {
1234
1268
  };
1235
- return new Promise((r, a) => {
1269
+ return new Promise((r, o) => {
1236
1270
  n = () => {
1237
1271
  if (this.destroyed || t !== this.submissionGeneration) {
1238
1272
  r(!1);
1239
1273
  return;
1240
1274
  }
1241
- const o = this.state;
1242
- if (o.messages.some((c) => c.respondsToUserMessageId === e && c.dataType === "run_status" && !c.provisional)) {
1275
+ const a = this.state;
1276
+ if (a.messages.some((d) => d.respondsToUserMessageId === e && d.dataType === "run_status" && !d.provisional)) {
1243
1277
  r(!1);
1244
1278
  return;
1245
1279
  }
1246
- if (o.conversationDiagnostics?.failedClientMessageId === e && o.lastError && o.lastErrorCode !== "submission_checkpoint_pending") {
1247
- a(Object.assign(new Error(o.lastError), { code: o.lastErrorCode }));
1280
+ if (a.conversationDiagnostics?.failedClientMessageId === e && a.lastError && a.lastErrorCode !== "submission_checkpoint_pending") {
1281
+ o(Object.assign(new Error(a.lastError), { code: a.lastErrorCode }));
1248
1282
  return;
1249
1283
  }
1250
- const d = o.messages.find((c) => c.id === `submission-error:${e}` && c.dataType === "run_error");
1251
- if (d) {
1252
- a(new Error(d.content));
1284
+ const c = a.messages.find((d) => d.id === `submission-error:${e}` && d.dataType === "run_error");
1285
+ if (c) {
1286
+ o(new Error(c.content));
1253
1287
  return;
1254
1288
  }
1255
- o.receipts?.some((c) => c.userMessageId === e && c.durable) && r(!0);
1256
- }, this.durabilityWaiters.add(n), i = this.on("state", n), n();
1289
+ a.receipts?.some((d) => d.userMessageId === e && d.durable) && r(!0);
1290
+ }, this.durabilityWaiters.add(n), s = this.on("state", n), n();
1257
1291
  }).finally(() => {
1258
- i(), this.durabilityWaiters.delete(n);
1292
+ s(), this.durabilityWaiters.delete(n);
1259
1293
  });
1260
1294
  }
1261
1295
  cancelPendingSubmissions(e = !0) {
1262
1296
  this.pendingStop = null, e && this.stopPreviews.clear(), this.stopError = null;
1263
1297
  const t = [.../* @__PURE__ */ new Set([...this.pendingTransfers.keys(), ...this.submissionRetries.keys()])];
1264
1298
  this.submissionGeneration++;
1265
- for (const i of this.durabilityWaiters) i();
1266
- for (const i of this.pendingTransfers.values())
1267
- for (const n of i) this.attachmentFiles.delete(n);
1299
+ for (const s of this.durabilityWaiters) s();
1300
+ for (const s of this.pendingTransfers.values())
1301
+ for (const n of s) this.attachmentFiles.delete(n);
1268
1302
  this.pendingTransfers.clear();
1269
- for (const i of this.submissionRetries.values())
1270
- for (const n of i.attachmentIds) this.attachmentFiles.delete(n);
1303
+ for (const s of this.submissionRetries.values())
1304
+ for (const n of s.attachmentIds) this.attachmentFiles.delete(n);
1271
1305
  this.submissionRetries.clear();
1272
- for (const i of this.submissionPreviews.values()) {
1273
- i.pending = !1, i.error?.code === "submission_checkpoint_pending" && (i.error = void 0);
1274
- for (const n of i.message.attachments ?? [])
1306
+ for (const s of this.submissionPreviews.values()) {
1307
+ s.pending = !1, s.error?.code === "submission_checkpoint_pending" && (s.error = void 0);
1308
+ for (const n of s.message.attachments ?? [])
1275
1309
  n.id && this.attachmentFiles.delete(n.id);
1276
1310
  }
1277
1311
  return this.operationQueue = Promise.resolve(), t;
@@ -1283,14 +1317,14 @@ class Ce {
1283
1317
  async listSessions(e = {}) {
1284
1318
  const t = await this.dispatch({ type: "session.list", ...e });
1285
1319
  if (t === void 0) {
1286
- const i = this.getSessionHistoryState().data;
1287
- return { sessions: i ? i.ids.map((n) => i.entitiesById[n]) : [], nextCursor: i?.nextCursor ?? null };
1320
+ const s = this.getSessionHistoryState().data;
1321
+ return { sessions: s ? s.ids.map((n) => s.entitiesById[n]) : [], nextCursor: s?.nextCursor ?? null };
1288
1322
  }
1289
1323
  if (!t?.sessionHistoryPage) throw new Error("Session list command did not return a page.");
1290
1324
  return t.sessionHistoryPage;
1291
1325
  }
1292
1326
  getSessionHistoryState() {
1293
- return K(this.sessionHistoryState);
1327
+ return z(this.sessionHistoryState);
1294
1328
  }
1295
1329
  subscribeSessionHistory(e) {
1296
1330
  return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
@@ -1318,13 +1352,13 @@ class Ce {
1318
1352
  subscribeInteractions(e) {
1319
1353
  return this.interactionListeners.add(e), e(this.getInteractions()), () => this.interactionListeners.delete(e);
1320
1354
  }
1321
- actOnInteraction(e, t, i, n = {}) {
1322
- const r = n.expectedSourceVersion === void 0 ? this.getInteractions().find((a) => a.id === e)?.sourceVersion ?? null : n.expectedSourceVersion;
1355
+ actOnInteraction(e, t, s, n = {}) {
1356
+ const r = n.expectedSourceVersion === void 0 ? this.getInteractions().find((o) => o.id === e)?.sourceVersion ?? null : n.expectedSourceVersion;
1323
1357
  return this.dispatch({
1324
1358
  type: "interaction.act",
1325
1359
  interactionId: e,
1326
1360
  action: t,
1327
- expectedRevision: i,
1361
+ expectedRevision: s,
1328
1362
  ...n,
1329
1363
  expectedSourceVersion: r
1330
1364
  }).then(() => {
@@ -1347,11 +1381,11 @@ class Ce {
1347
1381
  stageProactiveSuggestionQuestion(e) {
1348
1382
  const t = e.trim();
1349
1383
  if (!t) return Promise.resolve();
1350
- const i = this.stagedProactiveSuggestionClientMessageId ?? crypto.randomUUID();
1351
- return this.stagedProactiveSuggestionClientMessageId = i, this.dispatch({
1384
+ const s = this.stagedProactiveSuggestionClientMessageId ?? crypto.randomUUID();
1385
+ return this.stagedProactiveSuggestionClientMessageId = s, this.dispatch({
1352
1386
  type: "conversation.stage_proactive_suggestion",
1353
1387
  question: t,
1354
- clientMessageId: i
1388
+ clientMessageId: s
1355
1389
  }).then(() => {
1356
1390
  });
1357
1391
  }
@@ -1368,76 +1402,76 @@ class Ce {
1368
1402
  ), t;
1369
1403
  }
1370
1404
  emit(e, t) {
1371
- const i = this.listeners[e];
1372
- for (const n of i ?? []) n(t);
1405
+ const s = this.listeners[e];
1406
+ for (const n of s ?? []) n(t);
1373
1407
  }
1374
1408
  }
1375
- function _e(s, e) {
1376
- if (!e || !s) return e;
1409
+ function Ie(i, e) {
1410
+ if (!e || !i) return e;
1377
1411
  const t = /* @__PURE__ */ new Map();
1378
- for (const i of s) {
1379
- const n = i.previewUrl;
1380
- i.id && n && t.set(i.id, n);
1412
+ for (const s of i) {
1413
+ const n = s.previewUrl;
1414
+ s.id && n && t.set(s.id, n);
1381
1415
  }
1382
- return e.map((i) => {
1383
- const n = i.id ? t.get(i.id) : void 0;
1384
- return n ? { ...i, previewUrl: n } : i;
1416
+ return e.map((s) => {
1417
+ const n = s.id ? t.get(s.id) : void 0;
1418
+ return n ? { ...s, previewUrl: n } : s;
1385
1419
  });
1386
1420
  }
1387
- function M(s) {
1421
+ function P(i) {
1388
1422
  return {
1389
- ...s,
1390
- starterPrompts: [...s.starterPrompts],
1391
- appearance: s.appearance ? { ...s.appearance } : null,
1392
- messages: s.messages.map((e) => {
1423
+ ...i,
1424
+ starterPrompts: [...i.starterPrompts],
1425
+ appearance: i.appearance ? { ...i.appearance } : null,
1426
+ messages: i.messages.map((e) => {
1393
1427
  const t = {
1394
1428
  ...e,
1395
- attachments: e.attachments?.map((a) => ({ ...a }))
1396
- }, i = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
1429
+ attachments: e.attachments?.map((o) => ({ ...o }))
1430
+ }, s = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
1397
1431
  return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
1398
1432
  value: r,
1399
1433
  enumerable: !1
1400
- }), i && Object.defineProperty(t, "assistantDraftItemId", {
1401
- value: i,
1434
+ }), s && Object.defineProperty(t, "assistantDraftItemId", {
1435
+ value: s,
1402
1436
  enumerable: !1
1403
1437
  }), n && Object.defineProperty(t, "clientMessageId", {
1404
1438
  value: n,
1405
1439
  enumerable: !1
1406
1440
  }), t;
1407
1441
  }),
1408
- activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
1442
+ activeScheduledFollowUps: i.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
1409
1443
  };
1410
1444
  }
1411
- function K(s) {
1445
+ function z(i) {
1412
1446
  return {
1413
- ...s,
1414
- data: s.data ? _({
1415
- entities: Z(s.data).map((e) => ({ ...e })),
1416
- nextCursor: s.data.nextCursor
1447
+ ...i,
1448
+ data: i.data ? I({
1449
+ entities: J(i.data).map((e) => ({ ...e })),
1450
+ nextCursor: i.data.nextCursor
1417
1451
  }) : null
1418
1452
  };
1419
1453
  }
1420
1454
  export {
1421
- J as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1422
- Pe as ProductAgentInteractionManager,
1455
+ W as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
1456
+ ke as ProductAgentInteractionManager,
1423
1457
  q as ProductAgentQueryController,
1424
- Ce as ProductAgentRemoteRuntimeClient,
1458
+ xe as ProductAgentRemoteRuntimeClient,
1425
1459
  Te as ProductAgentSessionHistoryManager,
1426
1460
  qe as ProductAgentTaskPageTitleController,
1427
- Me as canSubmitPersonalProductAgentMessage,
1428
- ke as createLocalStorageInteractionDecisionStorage,
1429
- v as createProductAgentQueryState,
1461
+ Pe as canSubmitPersonalProductAgentMessage,
1462
+ Re as createLocalStorageInteractionDecisionStorage,
1463
+ _ as createProductAgentQueryState,
1430
1464
  Oe as createProductAgentTaskPageTitleDocument,
1431
- ie as formatProductAgentTaskPageTitle,
1432
- we as hasProductAgentPaidCreditFallback,
1465
+ ne as formatProductAgentTaskPageTitle,
1466
+ Ae as hasProductAgentPaidCreditFallback,
1433
1467
  O as isProductAgentAuthReconnectError,
1434
- Re as isProductAgentRuntimeCommand,
1435
- V as mergeProductAgentEntityPages,
1436
- _ as normalizeProductAgentEntityPage,
1437
- ee as readLocalStorageInteractionDecisions,
1438
- Ie as reconcileProductAgentSubmissionGate,
1439
- Ae as resolveProductAgentBillingPresentation,
1440
- Ee as resolveProductAgentComposerAction,
1441
- Se as resolveProductAgentWidgetPresentation,
1442
- Z as selectProductAgentQueryEntities
1468
+ Ce as isProductAgentRuntimeCommand,
1469
+ Z as mergeProductAgentEntityPages,
1470
+ I as normalizeProductAgentEntityPage,
1471
+ te as readLocalStorageInteractionDecisions,
1472
+ Se as reconcileProductAgentSubmissionGate,
1473
+ Ee as resolveProductAgentBillingPresentation,
1474
+ Me as resolveProductAgentComposerAction,
1475
+ we as resolveProductAgentWidgetPresentation,
1476
+ J as selectProductAgentQueryEntities
1443
1477
  };