@pluno/product-agent-web 0.1.315 → 0.1.317
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.
- package/README.md +4 -0
- package/dist/adapters/web/accountPresentation.d.ts +3 -3
- package/dist/adapters/web/directoryAdapters.d.ts +0 -1
- package/dist/adapters/web/featureHttp.d.ts +6 -22
- package/dist/adapters/web/featureLifecycle.d.ts +2 -15
- package/dist/adapters/web/featureOwner.d.ts +5 -6
- package/dist/adapters/web/featurePresentation.d.ts +4 -4
- package/dist/core/account/contracts.d.ts +6 -18
- package/dist/core/account/selectors.d.ts +2 -2
- package/dist/core/account/state.d.ts +1 -1
- package/dist/core/conversation/deliveryContracts.d.ts +1 -1
- package/dist/core/features/contracts.d.ts +37 -338
- package/dist/core/features/reducer.d.ts +5 -7
- package/dist/core/features/selectors.d.ts +1 -1
- package/dist/core/features/state.d.ts +1 -1
- package/dist/core/index.d.ts +0 -2
- package/dist/core/interactions/actions.d.ts +7 -7
- package/dist/core/interactions/contracts.d.ts +8 -121
- package/dist/core/interactions/selectors.d.ts +5 -25
- package/dist/core/interactions/state.d.ts +1 -1
- package/dist/core/kernel/capabilities.d.ts +0 -14
- package/dist/core/model-selection/selectors.d.ts +1 -1
- package/dist/core/session-directory/contracts.d.ts +0 -1
- package/dist/index.d.ts +2 -37
- package/dist/operationTiming.d.ts +1 -1
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +221 -274
- package/dist/product-agent-sdk.js +4717 -6136
- package/dist/product-agent-widget.js +5994 -8146
- package/dist/public/operationRoutes.d.ts +0 -3
- package/dist/runtime/composition.d.ts +3 -8
- package/dist/runtime/modelSelection.d.ts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtimeClient.d.ts +0 -6
- package/dist/runtimeState.d.ts +0 -10
- package/dist/shareCard.d.ts +0 -25
- package/dist/widget.d.ts +2 -28
- package/package.json +2 -3
- package/dist/activeUsersCounter.d.ts +0 -4
- package/dist/adapters/web/activeUsers.d.ts +0 -4
- package/dist/adapters/web/deviceHints.d.ts +0 -2
- package/dist/adapters/web/localPreferences.d.ts +0 -17
- package/dist/core/account/reducer.d.ts +0 -2
- package/dist/core/active-users/reducer.d.ts +0 -47
- package/dist/core/features/appearance.d.ts +0 -10
- package/dist/core/interactions/preferenceOpenings.d.ts +0 -22
- package/dist/core/interactions/reducer.d.ts +0 -6
- package/dist/featureActionFeedback.d.ts +0 -19
- package/dist/modelSelection.d.ts +0 -62
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _e(i, e) {
|
|
2
2
|
return e === "limit_exceeded" ? { allowed: !1, reason: "credits_exhausted", actions: ["upgrade", "earn_credits"] } : e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required" ? { allowed: !1, reason: "payment_issue", actions: ["upgrade"] } : i ?? { allowed: !0, reason: "allowed", actions: [] };
|
|
3
3
|
}
|
|
4
4
|
function S(i) {
|
|
@@ -96,31 +96,23 @@ function w(i) {
|
|
|
96
96
|
nextCursor: i.nextCursor
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function Z(i, e, t) {
|
|
100
100
|
if (t === "replace" || i === null) return e;
|
|
101
101
|
const s = { ...i.entitiesById, ...e.entitiesById }, n = [...i.ids];
|
|
102
102
|
for (const r of e.ids)
|
|
103
103
|
i.entitiesById[r] || n.push(r);
|
|
104
104
|
return { entitiesById: s, ids: n, nextCursor: e.nextCursor };
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function J(i) {
|
|
107
107
|
return i ? i.ids.map((e) => i.entitiesById[e]).filter((e) => !!e) : [];
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function Se(i) {
|
|
110
110
|
return i.visible ? i.minimized ? { state: "minimized" } : { state: i.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
if (!i || typeof i != "object") return !1;
|
|
114
|
-
const e = i.paidCreditFallbackModel;
|
|
115
|
-
return typeof e == "string" && e.length > 0;
|
|
116
|
-
}
|
|
117
|
-
function Ee(i) {
|
|
112
|
+
function we(i) {
|
|
118
113
|
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
114
|
}
|
|
120
|
-
function
|
|
121
|
-
return i.submissionAllowed && i.isAuthenticated && i.hasWorkspace && !i.isWebsiteBlocked && i.isCurrentPageResolved && !i.isSubmitting && !i.hasPendingMessage;
|
|
122
|
-
}
|
|
123
|
-
function Pe(i) {
|
|
115
|
+
function Ae(i) {
|
|
124
116
|
const e = i.hasDraftMessage || i.hasPreSubmittedAttachment;
|
|
125
117
|
return i.hasRunningAssistantTurn && !e ? {
|
|
126
118
|
action: "stop",
|
|
@@ -130,11 +122,11 @@ function Pe(i) {
|
|
|
130
122
|
disabled: !e || !i.canSubmitMessage
|
|
131
123
|
};
|
|
132
124
|
}
|
|
133
|
-
const
|
|
125
|
+
const W = "Pluno is reconnecting. Try again in a moment.";
|
|
134
126
|
function C(i) {
|
|
135
|
-
return (i instanceof Error ? i.message : i) ===
|
|
127
|
+
return (i instanceof Error ? i.message : i) === W;
|
|
136
128
|
}
|
|
137
|
-
class
|
|
129
|
+
class Me {
|
|
138
130
|
constructor(e, t, s = 20) {
|
|
139
131
|
this.loadPage = t, this.limit = s, this.recentQuery = new O(
|
|
140
132
|
`${e}:recent`,
|
|
@@ -144,7 +136,7 @@ class Re {
|
|
|
144
136
|
nextCursor: r.nextCursor
|
|
145
137
|
}))
|
|
146
138
|
),
|
|
147
|
-
|
|
139
|
+
Z
|
|
148
140
|
), this.pinnedQuery = new O(
|
|
149
141
|
`${e}:pinned`,
|
|
150
142
|
async () => w({
|
|
@@ -167,18 +159,18 @@ class Re {
|
|
|
167
159
|
activityReconciliationScheduled = !1;
|
|
168
160
|
getState() {
|
|
169
161
|
const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), s = [
|
|
170
|
-
...
|
|
171
|
-
...
|
|
162
|
+
...I(t.data),
|
|
163
|
+
...I(e.data)
|
|
172
164
|
], n = new Map(s.map((c) => [c.id, c])), r = Array.from(n.values()).map(
|
|
173
165
|
(c) => this.applyOverrides(c, this.completedRefreshSequence)
|
|
174
|
-
),
|
|
175
|
-
entities: [...
|
|
166
|
+
), a = Array.from(this.optimisticEntities.values()).filter((c) => !n.has(c.id)).reverse(), o = e.data || t.data || a.length > 0 ? w({
|
|
167
|
+
entities: [...a, ...r],
|
|
176
168
|
nextCursor: e.data?.nextCursor ?? null
|
|
177
169
|
}) : null;
|
|
178
170
|
return {
|
|
179
171
|
key: e.key.slice(0, -7),
|
|
180
|
-
status:
|
|
181
|
-
data:
|
|
172
|
+
status: Y(e, t),
|
|
173
|
+
data: o,
|
|
182
174
|
error: e.error ?? t.error,
|
|
183
175
|
requestId: Math.max(e.requestId, t.requestId),
|
|
184
176
|
updatedAt: Math.max(e.updatedAt ?? 0, t.updatedAt ?? 0) || null
|
|
@@ -243,8 +235,8 @@ class Re {
|
|
|
243
235
|
}
|
|
244
236
|
reconcileDurableEntities() {
|
|
245
237
|
const e = [
|
|
246
|
-
...
|
|
247
|
-
...
|
|
238
|
+
...I(this.pinnedQuery.getState().data),
|
|
239
|
+
...I(this.recentQuery.getState().data)
|
|
248
240
|
], t = new Set(e.map((s) => s.id));
|
|
249
241
|
for (const s of this.optimisticEntities.keys())
|
|
250
242
|
t.has(s) && this.optimisticEntities.delete(s);
|
|
@@ -283,17 +275,12 @@ class Re {
|
|
|
283
275
|
for (const e of this.listeners) e(this.getState());
|
|
284
276
|
}
|
|
285
277
|
}
|
|
286
|
-
function
|
|
278
|
+
function I(i) {
|
|
287
279
|
return i ? i.ids.map((e) => i.entitiesById[e]).filter((e) => !!e) : [];
|
|
288
280
|
}
|
|
289
|
-
function
|
|
281
|
+
function Y(i, e) {
|
|
290
282
|
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
283
|
}
|
|
292
|
-
function x(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
|
-
if (!e) throw new Error("Display timestamps must retain the backend UTC precision.");
|
|
295
|
-
return `${e[1]}.${(e[2] ?? "").padEnd(6, "0")}`;
|
|
296
|
-
}
|
|
297
284
|
function A(i) {
|
|
298
285
|
if (i === null || typeof i == "string" || typeof i == "boolean") return !0;
|
|
299
286
|
if (typeof i == "number") return Number.isFinite(i);
|
|
@@ -305,22 +292,11 @@ function A(i) {
|
|
|
305
292
|
function L(i) {
|
|
306
293
|
return i !== null && typeof i == "object" && !Object.isFrozen(i) && (Object.values(i).forEach(L), Object.freeze(i)), i;
|
|
307
294
|
}
|
|
308
|
-
function
|
|
295
|
+
function X(i) {
|
|
309
296
|
if (!A(i)) throw new Error("Conversation inputs must be JSON-safe values.");
|
|
310
297
|
return JSON.parse(JSON.stringify(i));
|
|
311
298
|
}
|
|
312
|
-
|
|
313
|
-
if (!e) return !1;
|
|
314
|
-
const t = i.executionByUserMessage[e];
|
|
315
|
-
if (t) return ["completed", "stopped", "failed"].includes(t.phase);
|
|
316
|
-
const s = Object.values(i.items).sort((r, o) => x(r.created_at).localeCompare(x(o.created_at)) || r.id.localeCompare(o.id));
|
|
317
|
-
let n = !1;
|
|
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
|
-
return !0;
|
|
321
|
-
return !1;
|
|
322
|
-
}
|
|
323
|
-
class ke {
|
|
299
|
+
class Ee {
|
|
324
300
|
constructor(e, t = null) {
|
|
325
301
|
this.storage = e, t && (this.decisions = new Map(
|
|
326
302
|
t.filter(P).map((s) => [this.getDecisionKey(s), s])
|
|
@@ -342,10 +318,10 @@ class ke {
|
|
|
342
318
|
for (const t of e) {
|
|
343
319
|
if (!Number.isSafeInteger(t.version) || t.version < 0) throw new Error("Invalid interaction source version.");
|
|
344
320
|
const s = JSON.stringify([t.conversation_id, t.id]), n = this.sources.get(s);
|
|
345
|
-
if (n && n.version >= t.version)
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
321
|
+
if (!(n && n.version >= t.version)) {
|
|
322
|
+
if (n && n.payload.kind !== t.payload.kind) throw new Error("Interaction kind changed.");
|
|
323
|
+
t.payload.kind === "integration_auth" && (this.sources.set(s, L(X(t))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id));
|
|
324
|
+
}
|
|
349
325
|
}
|
|
350
326
|
}
|
|
351
327
|
/** @internal */
|
|
@@ -355,41 +331,23 @@ class ke {
|
|
|
355
331
|
/** @internal */
|
|
356
332
|
getConversationInputs(e) {
|
|
357
333
|
if (!this.conversationReader) return;
|
|
358
|
-
const t = {
|
|
359
|
-
if (!
|
|
360
|
-
const n = [...this.sources.values()].filter((r) => r.conversation_id === e).sort((r,
|
|
334
|
+
const t = { integrations: [] };
|
|
335
|
+
if (!(e ? this.conversationReader(e) : null)) return t;
|
|
336
|
+
const n = [...this.sources.values()].filter((r) => r.conversation_id === e).sort((r, a) => r.version - a.version || r.id.localeCompare(a.id));
|
|
361
337
|
for (const r of n) {
|
|
362
|
-
const
|
|
363
|
-
|
|
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
|
-
t.share = {
|
|
367
|
-
revision: r.version,
|
|
368
|
-
candidate: {
|
|
369
|
-
id: r.id,
|
|
370
|
-
variant: o.variant,
|
|
371
|
-
userPrompt: a?.type === "user_message" ? a.data.content : "",
|
|
372
|
-
assistantAnswer: ""
|
|
373
|
-
},
|
|
374
|
-
terminal: !o.wait_for_terminal || te(s, r.user_message_id)
|
|
375
|
-
};
|
|
376
|
-
} else o.kind === "integration_auth" ? t.integrations.push({
|
|
338
|
+
const a = r.payload;
|
|
339
|
+
a.kind === "integration_auth" && t.integrations.push({
|
|
377
340
|
revision: r.version,
|
|
378
341
|
request: {
|
|
379
342
|
type: "pipedream_auth_required",
|
|
380
|
-
authRequestId:
|
|
381
|
-
appSlug:
|
|
382
|
-
appName:
|
|
383
|
-
appLogo:
|
|
384
|
-
expiresAt:
|
|
343
|
+
authRequestId: a.request_id,
|
|
344
|
+
appSlug: a.app_slug,
|
|
345
|
+
appName: a.app_name,
|
|
346
|
+
appLogo: a.app_logo ?? void 0,
|
|
347
|
+
expiresAt: a.expires_at
|
|
385
348
|
},
|
|
386
|
-
lifecycle: r.lifecycle === "pending" && Date.parse(
|
|
387
|
-
})
|
|
388
|
-
type: "personal_channel_connection_required",
|
|
389
|
-
requestId: o.request_id,
|
|
390
|
-
channel: o.channel,
|
|
391
|
-
managementUrl: o.management_url
|
|
392
|
-
}, lifecycle: r.lifecycle };
|
|
349
|
+
lifecycle: r.lifecycle === "pending" && Date.parse(a.expires_at) <= Date.now() ? "expired" : r.lifecycle
|
|
350
|
+
});
|
|
393
351
|
}
|
|
394
352
|
return t;
|
|
395
353
|
}
|
|
@@ -437,7 +395,7 @@ class ke {
|
|
|
437
395
|
async applyAction(e, t, s) {
|
|
438
396
|
if (!e.allowedActions.includes(t))
|
|
439
397
|
throw new Error(`Interaction ${e.key} does not allow ${t}.`);
|
|
440
|
-
if (
|
|
398
|
+
if (!$(t))
|
|
441
399
|
throw new Error(`Interaction action ${t} is not a persistence decision.`);
|
|
442
400
|
const n = s.now ?? /* @__PURE__ */ new Date(), r = {
|
|
443
401
|
promptKey: e.key,
|
|
@@ -446,8 +404,8 @@ class ke {
|
|
|
446
404
|
scope: e.scope,
|
|
447
405
|
decidedAt: n.toISOString(),
|
|
448
406
|
nextEligibleAt: this.getNextEligibleAt(e, t, n, s.snoozeUntil)
|
|
449
|
-
},
|
|
450
|
-
return
|
|
407
|
+
}, a = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), o = new Map(this.decisions);
|
|
408
|
+
return o.set(a, r), await this.storage.save([...o.values()]), this.decisions = o, r;
|
|
451
409
|
}
|
|
452
410
|
isDecisionEligible(e, t) {
|
|
453
411
|
return e ? e.action === "dismiss" || e.action === "never" || e.action === "dont_show_again" ? !1 : !e.nextEligibleAt || Date.parse(e.nextEligibleAt) <= t : !0;
|
|
@@ -473,13 +431,13 @@ class ke {
|
|
|
473
431
|
return `${E(e.scope)}:category:${e.category}`;
|
|
474
432
|
}
|
|
475
433
|
}
|
|
476
|
-
function
|
|
434
|
+
function Te(i, e) {
|
|
477
435
|
return {
|
|
478
|
-
load: async () =>
|
|
436
|
+
load: async () => ee(i, e),
|
|
479
437
|
save: async (t) => i.setItem(e, JSON.stringify(t))
|
|
480
438
|
};
|
|
481
439
|
}
|
|
482
|
-
function
|
|
440
|
+
function ee(i, e) {
|
|
483
441
|
const t = i.getItem(e);
|
|
484
442
|
if (!t) return [];
|
|
485
443
|
const s = JSON.parse(t);
|
|
@@ -488,26 +446,26 @@ function se(i, e) {
|
|
|
488
446
|
function E(i) {
|
|
489
447
|
return `${i.level}:${i.key}`;
|
|
490
448
|
}
|
|
491
|
-
function
|
|
449
|
+
function $(i) {
|
|
492
450
|
return i === "dismiss" || i === "later" || i === "snooze" || i === "never" || i === "dont_show_again";
|
|
493
451
|
}
|
|
494
452
|
function P(i) {
|
|
495
453
|
if (!i || typeof i != "object") return !1;
|
|
496
454
|
const e = i;
|
|
497
|
-
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") &&
|
|
455
|
+
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && $(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
|
|
498
456
|
}
|
|
499
|
-
const
|
|
457
|
+
const te = {
|
|
500
458
|
working: "⏳",
|
|
501
459
|
completed: "✅",
|
|
502
460
|
failed: "❗",
|
|
503
461
|
stopped: "⏹️"
|
|
504
|
-
},
|
|
505
|
-
function
|
|
462
|
+
}, se = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
463
|
+
function ie(i, e) {
|
|
506
464
|
if (!e) return M(i);
|
|
507
|
-
const t = M(i), s = `${
|
|
465
|
+
const t = M(i), s = `${te[e]} Pluno`;
|
|
508
466
|
return t ? `${s}: ${t}` : s;
|
|
509
467
|
}
|
|
510
|
-
class
|
|
468
|
+
class Pe {
|
|
511
469
|
constructor(e) {
|
|
512
470
|
this.titleDocument = e;
|
|
513
471
|
}
|
|
@@ -541,11 +499,11 @@ class Oe {
|
|
|
541
499
|
applyTitle() {
|
|
542
500
|
if (!this.status)
|
|
543
501
|
return;
|
|
544
|
-
const e =
|
|
502
|
+
const e = ie(this.baseTitle, this.status);
|
|
545
503
|
this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
|
|
546
504
|
}
|
|
547
505
|
}
|
|
548
|
-
function
|
|
506
|
+
function Re(i) {
|
|
549
507
|
return {
|
|
550
508
|
getTitle: () => i.title,
|
|
551
509
|
setTitle: (e) => {
|
|
@@ -562,12 +520,12 @@ function Ce(i) {
|
|
|
562
520
|
};
|
|
563
521
|
}
|
|
564
522
|
function M(i) {
|
|
565
|
-
return i.replace(
|
|
523
|
+
return i.replace(se, "");
|
|
566
524
|
}
|
|
567
|
-
const
|
|
568
|
-
version:
|
|
525
|
+
const ne = "0.1.317", re = {
|
|
526
|
+
version: ne
|
|
569
527
|
}, g = (i) => typeof i == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(i) ? i : null;
|
|
570
|
-
function
|
|
528
|
+
function oe(i) {
|
|
571
529
|
if (!i || typeof i != "object") return !1;
|
|
572
530
|
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
531
|
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);
|
|
@@ -577,32 +535,32 @@ function F(i) {
|
|
|
577
535
|
const e = i;
|
|
578
536
|
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
537
|
}
|
|
580
|
-
const
|
|
581
|
-
function
|
|
538
|
+
const x = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], R = (i) => typeof i == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(i), y = (i) => i === null || R(i), ae = (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));
|
|
539
|
+
function U(i) {
|
|
582
540
|
if (!i || typeof i != "object") return !1;
|
|
583
541
|
const e = i;
|
|
584
|
-
return Object.keys(i).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && y(e.sessionId) && R(e.itemId) && y(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && y(e.runId) && (e.createdAt === null ||
|
|
542
|
+
return Object.keys(i).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && y(e.sessionId) && R(e.itemId) && y(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && y(e.runId) && (e.createdAt === null || ae(e.createdAt));
|
|
585
543
|
}
|
|
586
|
-
function
|
|
544
|
+
function de(i) {
|
|
587
545
|
if (!i || typeof i != "object") return !1;
|
|
588
546
|
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 ||
|
|
547
|
+
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 || 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((s) => s === void 0 || t(s));
|
|
590
548
|
}
|
|
591
|
-
function
|
|
549
|
+
function G(i) {
|
|
592
550
|
if (!i || typeof i != "object" || Object.keys(i).some((s) => s !== "before" && s !== "current")) return !1;
|
|
593
551
|
const e = (s) => {
|
|
594
552
|
if (!s || typeof s != "object") return !1;
|
|
595
553
|
const n = s;
|
|
596
|
-
return Object.keys(s).every((r) => [...
|
|
554
|
+
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((a) => ["key", "count", "rows", "truncated"].includes(a)) && 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((a) => a && Object.keys(a).every((o) => ["itemId", "groupId"].includes(o)) && y(a.itemId) && y(a.groupId)))) && (n.context === void 0 || de(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(R));
|
|
597
555
|
}, t = i;
|
|
598
556
|
return (t.before === null || e(t.before)) && e(t.current);
|
|
599
557
|
}
|
|
600
|
-
const
|
|
601
|
-
function
|
|
558
|
+
const D = 500;
|
|
559
|
+
function B(i) {
|
|
602
560
|
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 >
|
|
561
|
+
return e.length > D ? `${e.slice(0, D - 1)}…` : e;
|
|
604
562
|
}
|
|
605
|
-
function
|
|
563
|
+
function ce(i) {
|
|
606
564
|
let e = 2166136261;
|
|
607
565
|
for (let t = 0; t < i.length; t += 1)
|
|
608
566
|
e ^= i.charCodeAt(t), e = Math.imul(e, 16777619);
|
|
@@ -613,23 +571,23 @@ function k(i) {
|
|
|
613
571
|
const e = i;
|
|
614
572
|
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
573
|
}
|
|
616
|
-
function
|
|
574
|
+
function le(i) {
|
|
617
575
|
if (!i || typeof i != "object") return !1;
|
|
618
576
|
const e = i;
|
|
619
577
|
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
578
|
}
|
|
621
|
-
function
|
|
622
|
-
const r = !s && e === "conversation_error" && t !== void 0 && i.conversationDiagnostics?.errorMessageFingerprint ===
|
|
579
|
+
function ue(i, e, t, s, n = {}) {
|
|
580
|
+
const r = !s && e === "conversation_error" && t !== void 0 && i.conversationDiagnostics?.errorMessageFingerprint === ce(B(t)) ? i.conversationDiagnostics : void 0;
|
|
623
581
|
return {
|
|
624
582
|
sessionId: g(i.sessionId),
|
|
625
583
|
requestId: g(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
|
|
626
584
|
...g(r?.failedClientMessageId) ? { clientMessageId: r.failedClientMessageId } : {},
|
|
627
585
|
code: r ? g(i.lastErrorCode) : null,
|
|
628
586
|
...k(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
|
|
629
|
-
builds: { sdk:
|
|
587
|
+
builds: { sdk: re.version, ...n }
|
|
630
588
|
};
|
|
631
589
|
}
|
|
632
|
-
function
|
|
590
|
+
function he(i) {
|
|
633
591
|
if (i.details !== void 0 && !A(i.details))
|
|
634
592
|
throw new TypeError("Product Agent transported error details must be JSON-safe.");
|
|
635
593
|
return {
|
|
@@ -640,30 +598,30 @@ function ge(i) {
|
|
|
640
598
|
};
|
|
641
599
|
}
|
|
642
600
|
function b(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,
|
|
644
|
-
...typeof
|
|
601
|
+
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, a = s && "details" in s ? s.details : null, o = a && typeof a == "object" ? a : {}, c = {
|
|
602
|
+
...typeof o.httpStatus == "number" && Number.isInteger(o.httpStatus) && o.httpStatus >= 100 && o.httpStatus <= 599 ? { httpStatus: o.httpStatus } : {},
|
|
645
603
|
// Preserve the first boundary's shape after normalization replaces the original message/prototype.
|
|
646
|
-
errorNormalization: k(
|
|
604
|
+
errorNormalization: k(o.errorNormalization) ? o.errorNormalization : {
|
|
647
605
|
boundary: t,
|
|
648
606
|
category: i instanceof Error ? "error" : i === null ? "null" : Array.isArray(i) ? "array" : typeof i,
|
|
649
607
|
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
608
|
},
|
|
651
|
-
...
|
|
652
|
-
...["unissued", "rejected"].includes(String(
|
|
653
|
-
...typeof
|
|
654
|
-
...typeof
|
|
655
|
-
...typeof
|
|
656
|
-
...typeof
|
|
657
|
-
...typeof
|
|
609
|
+
...o.allocation === "unissued" ? { allocation: "unissued" } : {},
|
|
610
|
+
...["unissued", "rejected"].includes(String(o.acceptance)) ? { acceptance: String(o.acceptance) } : {},
|
|
611
|
+
...typeof o.securitySettingsUrl == "string" ? { securitySettingsUrl: o.securitySettingsUrl } : {},
|
|
612
|
+
...typeof o.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(o.transportCode) ? { transportCode: o.transportCode } : {},
|
|
613
|
+
...typeof o.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(o.requestId) ? { requestId: o.requestId } : {},
|
|
614
|
+
...typeof o.durationMs == "number" && Number.isFinite(o.durationMs) && o.durationMs >= 0 ? { durationMs: o.durationMs } : {},
|
|
615
|
+
...typeof o.successfulRequests == "number" && Number.isSafeInteger(o.successfulRequests) && o.successfulRequests >= 0 ? { successfulRequests: o.successfulRequests } : {}
|
|
658
616
|
};
|
|
659
|
-
return
|
|
617
|
+
return he({
|
|
660
618
|
code: r,
|
|
661
619
|
message: n.trim() && n.trim() !== "[object Object]" ? n : "The Product Agent operation failed. Try again.",
|
|
662
620
|
retryable: !!(s && "retryable" in s && s.retryable === !0),
|
|
663
621
|
...Object.keys(c).length ? { details: c } : {}
|
|
664
622
|
});
|
|
665
623
|
}
|
|
666
|
-
function
|
|
624
|
+
function H(i) {
|
|
667
625
|
if (!i || typeof i != "object") return !1;
|
|
668
626
|
const e = i, t = (s) => Number.isSafeInteger(s) && s >= 0;
|
|
669
627
|
return Object.keys(e).every((s) => [
|
|
@@ -687,7 +645,7 @@ function Q(i) {
|
|
|
687
645
|
"upstreamTraceId"
|
|
688
646
|
].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
647
|
}
|
|
690
|
-
const
|
|
648
|
+
const pe = [
|
|
691
649
|
"submit",
|
|
692
650
|
"stop",
|
|
693
651
|
"staging_ipc",
|
|
@@ -723,9 +681,6 @@ const fe = [
|
|
|
723
681
|
"stopping_painted",
|
|
724
682
|
"progress_painted",
|
|
725
683
|
"stopped_painted",
|
|
726
|
-
"warmup_checkpoint",
|
|
727
|
-
"warmup_http",
|
|
728
|
-
"warmup_wait",
|
|
729
684
|
"session_tabs_snapshot",
|
|
730
685
|
"tab_window",
|
|
731
686
|
"tab_summary",
|
|
@@ -750,7 +705,7 @@ const fe = [
|
|
|
750
705
|
"acceptance_applied",
|
|
751
706
|
"cancellation_queue",
|
|
752
707
|
"cancellation_write"
|
|
753
|
-
],
|
|
708
|
+
], Q = [
|
|
754
709
|
"request_timed_out",
|
|
755
710
|
"delivery_unknown",
|
|
756
711
|
"invalid_ack",
|
|
@@ -766,86 +721,86 @@ const fe = [
|
|
|
766
721
|
"backend_refusal",
|
|
767
722
|
"unknown"
|
|
768
723
|
];
|
|
769
|
-
function
|
|
724
|
+
function ge(i) {
|
|
770
725
|
const e = i, t = e?.code;
|
|
771
|
-
return e?.backendRefusal === !0 ? "backend_refusal" : typeof t == "string" && t !== "backend_refusal" &&
|
|
726
|
+
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";
|
|
772
727
|
}
|
|
773
|
-
const
|
|
774
|
-
let
|
|
775
|
-
const
|
|
728
|
+
const V = Math.random().toString(36).slice(2);
|
|
729
|
+
let fe = 0;
|
|
730
|
+
const N = () => `timing:${V}:${++fe}`, v = (i) => typeof i == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(i);
|
|
776
731
|
function q(i) {
|
|
777
732
|
if (!i || typeof i != "object") return !1;
|
|
778
733
|
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 || v(e.workerId)) && (e.failureCategory === void 0 || e.status === "failed" &&
|
|
734
|
+
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 || v(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) && pe.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && v(e.spanId) && v(e.requestId) && (e.clientMessageId === null || v(e.clientMessageId)) && (e.sessionId === null || v(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
|
|
780
735
|
}
|
|
781
|
-
function
|
|
782
|
-
if (e = { workerId:
|
|
736
|
+
function j(i, e) {
|
|
737
|
+
if (e = { workerId: V, ...e }, !i) return {
|
|
783
738
|
identity: e,
|
|
784
739
|
mark: (n) => {
|
|
785
740
|
},
|
|
786
741
|
measure: (n, r) => r()
|
|
787
742
|
};
|
|
788
|
-
const t = performance.now(), s = (n, r,
|
|
743
|
+
const t = performance.now(), s = (n, r, a, o, c) => {
|
|
789
744
|
const d = {
|
|
790
745
|
...e,
|
|
791
746
|
stage: n,
|
|
792
747
|
status: r,
|
|
793
|
-
spanId:
|
|
748
|
+
spanId: o,
|
|
794
749
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
795
|
-
durationMs: Math.max(0, Math.round(performance.now() -
|
|
796
|
-
...r === "failed" ? { failureCategory:
|
|
750
|
+
durationMs: Math.max(0, Math.round(performance.now() - a)),
|
|
751
|
+
...r === "failed" ? { failureCategory: ge(c) } : {}
|
|
797
752
|
};
|
|
798
753
|
i && q(d) && Promise.resolve().then(() => i(d)).catch(() => {
|
|
799
754
|
});
|
|
800
755
|
};
|
|
801
756
|
return {
|
|
802
757
|
identity: e,
|
|
803
|
-
mark: (n) => s(n, "observed", t,
|
|
758
|
+
mark: (n) => s(n, "observed", t, N()),
|
|
804
759
|
measure(n, r) {
|
|
805
|
-
const
|
|
806
|
-
return s(n, "started",
|
|
807
|
-
(c) => (s(n, "completed",
|
|
760
|
+
const a = performance.now(), o = N();
|
|
761
|
+
return s(n, "started", a, o), r().then(
|
|
762
|
+
(c) => (s(n, "completed", a, o), c),
|
|
808
763
|
(c) => {
|
|
809
|
-
throw s(n, "failed",
|
|
764
|
+
throw s(n, "failed", a, o, c), c;
|
|
810
765
|
}
|
|
811
766
|
);
|
|
812
767
|
}
|
|
813
768
|
};
|
|
814
769
|
}
|
|
815
770
|
const T = (i) => i === null || typeof i == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(i);
|
|
816
|
-
function
|
|
771
|
+
function me(i) {
|
|
817
772
|
if (!i || typeof i != "object") return !1;
|
|
818
773
|
const e = i;
|
|
819
774
|
return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && T(e.sessionId) && T(e.responseItemId) && T(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
|
|
820
775
|
}
|
|
821
|
-
function
|
|
776
|
+
function ye(i, e, t = "stopped", s, n = "Run stopped by user.") {
|
|
822
777
|
const r = new Set(s ?? [
|
|
823
778
|
i.assistantDraftRespondsToUserMessageId,
|
|
824
779
|
i.activeResponseUserMessageId,
|
|
825
780
|
i.messages.filter((c) => c.role === "user").slice(-1)[0]?.id
|
|
826
|
-
].filter((c) => !!c)),
|
|
781
|
+
].filter((c) => !!c)), a = 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
782
|
for (const c of r)
|
|
828
|
-
|
|
829
|
-
const
|
|
783
|
+
a.some((d) => d.respondsToUserMessageId === c && (d.dataType === "run_status" || d.dataType === "run_error" || d.role === "assistant" && d.phase !== "commentary")) || a.some((d) => d.role === "user" && d.id === c) && a.push({ id: `local-interrupted:${c}`, role: "system", dataType: "run_status", provisional: t === "stopping", content: t === "stopping" ? "Stopping…" : n, createdAt: e, respondsToUserMessageId: c });
|
|
784
|
+
const o = i.segments?.map((c) => ({ ...c, outcomeIds: [
|
|
830
785
|
...c.outcomeIds,
|
|
831
|
-
...
|
|
786
|
+
...a.filter((d) => d.id === `local-interrupted:${c.userMessageId}` && !c.outcomeIds.includes(d.id)).map((d) => d.id)
|
|
832
787
|
] }));
|
|
833
788
|
return {
|
|
834
789
|
...i,
|
|
835
|
-
messages:
|
|
790
|
+
messages: a,
|
|
836
791
|
isThinking: !1,
|
|
837
792
|
isRetrying: !1,
|
|
838
793
|
pendingMessageStatus: null,
|
|
839
794
|
turnPhase: null,
|
|
840
|
-
segments:
|
|
795
|
+
segments: o,
|
|
841
796
|
activity: { phase: t, activeItemId: null },
|
|
842
|
-
isLoadingSession: i.isLoadingSession &&
|
|
797
|
+
isLoadingSession: i.isLoadingSession && a.length === 0,
|
|
843
798
|
taskStatus: t === "stopped" ? "stopped" : null,
|
|
844
799
|
lastError: null,
|
|
845
800
|
lastErrorCode: null
|
|
846
801
|
};
|
|
847
802
|
}
|
|
848
|
-
const
|
|
803
|
+
const be = {
|
|
849
804
|
"stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
|
|
850
805
|
"in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
|
|
851
806
|
"stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
|
|
@@ -861,10 +816,10 @@ const _e = {
|
|
|
861
816
|
"thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
|
|
862
817
|
"thinking-without-progress": "Thinking remained visible without progress for five minutes."
|
|
863
818
|
};
|
|
864
|
-
function
|
|
865
|
-
return typeof i == "string" && i.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(
|
|
819
|
+
function ve(i) {
|
|
820
|
+
return typeof i == "string" && i.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(be, i.slice(13));
|
|
866
821
|
}
|
|
867
|
-
function
|
|
822
|
+
function K(i) {
|
|
868
823
|
return {
|
|
869
824
|
...i.id === void 0 ? {} : { id: i.id },
|
|
870
825
|
name: i.name,
|
|
@@ -875,7 +830,7 @@ function z(i) {
|
|
|
875
830
|
...i.fileUrl === void 0 ? {} : { fileUrl: i.fileUrl }
|
|
876
831
|
};
|
|
877
832
|
}
|
|
878
|
-
function
|
|
833
|
+
function ke(i) {
|
|
879
834
|
if (!i || typeof i != "object" || !("type" in i)) return !1;
|
|
880
835
|
const e = i;
|
|
881
836
|
switch (e.type) {
|
|
@@ -887,15 +842,13 @@ function xe(i) {
|
|
|
887
842
|
case "run.stop":
|
|
888
843
|
return e.clientMessageIds === void 0 || Array.isArray(e.clientMessageIds) && e.clientMessageIds.length <= 100 && e.clientMessageIds.every((t) => typeof t == "string" && t.length > 0 && t.length <= 160);
|
|
889
844
|
case "runtime.report_response_visibility":
|
|
890
|
-
return
|
|
891
|
-
case "runtime.warmup":
|
|
892
|
-
return (e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input") && (e.requestedModel === void 0 || typeof e.requestedModel == "string");
|
|
845
|
+
return me(e.observation);
|
|
893
846
|
case "runtime.report_operation_timing":
|
|
894
847
|
return q(e.timing);
|
|
895
848
|
case "runtime.report_displayed_error":
|
|
896
|
-
return (e.errorDiagnostic === void 0 ||
|
|
849
|
+
return (e.errorDiagnostic === void 0 || le(e.errorDiagnostic)) && (e.httpRequest === void 0 || H(e.httpRequest)) && (e.historyRefreshFailure === void 0 || F(e.historyRefreshFailure)) && (e.renderedError === void 0 || U(e.renderedError)) && (e.reason === "conversation_error" || e.reason === "attachment_error" || e.reason === "history_error" || e.reason === "action_error") && typeof e.errorFingerprint == "string" && /^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint) && (e.displayedMessage === void 0 || typeof e.displayedMessage == "string" && e.displayedMessage.length <= 500);
|
|
897
850
|
case "runtime.report_invalid_state_transition":
|
|
898
|
-
return (e.uiInvariant === void 0 ||
|
|
851
|
+
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" || ve(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
|
|
899
852
|
case "runtime.prompt_presented":
|
|
900
853
|
return (e.feature === "notifications" || e.feature === "tab_grouping") && typeof e.openingGeneration == "number" && Number.isSafeInteger(e.openingGeneration) && e.openingGeneration > 0;
|
|
901
854
|
case "runtime.widget_lifecycle":
|
|
@@ -925,9 +878,9 @@ function xe(i) {
|
|
|
925
878
|
return !1;
|
|
926
879
|
}
|
|
927
880
|
}
|
|
928
|
-
class
|
|
881
|
+
class qe {
|
|
929
882
|
constructor(e, t, s) {
|
|
930
|
-
this.adapter = t, this.state =
|
|
883
|
+
this.adapter = t, this.state = _(e), this.hasBeenReady = e.status === "connected" && e.submissionReady !== !1, this.initialModel = s ?? "gpt-6.1-sol", this.model = this.initialModel;
|
|
931
884
|
}
|
|
932
885
|
adapter;
|
|
933
886
|
listeners = {};
|
|
@@ -965,42 +918,42 @@ class De {
|
|
|
965
918
|
return s.add(t), this.listeners[e] = s, () => s.delete(t);
|
|
966
919
|
}
|
|
967
920
|
getState() {
|
|
968
|
-
const e =
|
|
921
|
+
const e = _(this.state);
|
|
969
922
|
if (this.pendingNavigation && (e.isLoadingSession = !0), this.retainedTranscript) {
|
|
970
|
-
const n =
|
|
971
|
-
e.messages = [...n.messages, ...e.messages.filter((
|
|
972
|
-
...(n.segments ?? []).map((
|
|
973
|
-
...(e.segments ?? []).filter((
|
|
923
|
+
const n = _({ ...e, ...this.retainedTranscript }), r = new Set(n.messages.map((o) => o.id)), a = new Set(n.segments?.map((o) => o.id));
|
|
924
|
+
e.messages = [...n.messages, ...e.messages.filter((o) => !r.has(o.id))], (n.segments || e.segments) && (e.segments = [
|
|
925
|
+
...(n.segments ?? []).map((o) => ({ ...o })),
|
|
926
|
+
...(e.segments ?? []).filter((o) => !a.has(o.id))
|
|
974
927
|
]), e.removedItems = { ...n.removedItems, ...e.removedItems };
|
|
975
928
|
}
|
|
976
929
|
for (const [n, r] of this.submissionPreviews)
|
|
977
|
-
e.messages.some((
|
|
930
|
+
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"));
|
|
978
931
|
this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
|
|
979
932
|
const t = [...this.stopPreviews.keys()];
|
|
980
933
|
if (!t.length) return e;
|
|
981
|
-
const s =
|
|
934
|
+
const s = ye(e, "", "stopping", t);
|
|
982
935
|
return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: s.messages, segments: s.segments } : s;
|
|
983
936
|
}
|
|
984
937
|
updateProjection(e, t, s, n, r) {
|
|
985
938
|
if (this.destroyed) return;
|
|
986
|
-
const
|
|
987
|
-
!
|
|
939
|
+
const a = this.getState(), o = !this.hasBeenReady && (!a.user || a.user.id === e.user?.id), c = a.stableSelectionKey !== void 0 && a.stableSelectionKey === e.stableSelectionKey && a.user?.id === e.user?.id && a.sessionId === e.sessionId, d = c && this.pendingTransfers.size > 0 && this.submissionRetries.size === 0 && [...this.pendingTransfers.keys()].every((l) => this.readinessPendingSubmissions.has(l));
|
|
940
|
+
!o && !d && (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) && (c || (this.model = t ?? this.initialModel, this.modelExplicit = !1), this.cancelPendingSubmissions(), this.submissionPreviews.clear());
|
|
988
941
|
for (const l of e.messages)
|
|
989
942
|
l.role === "user" && e.receipts?.find((u) => u.userMessageId === l.id)?.durable !== !1 && this.submissionPreviews.delete(l.id);
|
|
990
|
-
const
|
|
991
|
-
this.retainedTranscript =
|
|
943
|
+
const h = c && e.sessionId !== null && e.isLoadingSession && !e.isDraftSession;
|
|
944
|
+
this.retainedTranscript = h ? this.retainedTranscript ?? (this.state.isLoadingSession || this.state.messages.length === 0 ? null : { messages: this.state.messages, segments: this.state.segments, removedItems: this.state.removedItems }) : null, this.state = _(e), t !== void 0 && !this.modelExplicit && (this.model = t), e.status === "connected" && e.submissionReady !== !1 && (this.hasBeenReady = !0);
|
|
992
945
|
for (const [l, u] of this.stopPreviews) {
|
|
993
|
-
const
|
|
994
|
-
(u !== void 0 && u !== "[]" &&
|
|
946
|
+
const p = e.activity?.executionKey;
|
|
947
|
+
(u !== void 0 && u !== "[]" && p !== void 0 && p !== "[]" && (p !== u || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (u === void 0 || u === "[]") && e.messages.some((m) => m.respondsToUserMessageId === l && !m.provisional && m.loading !== !0 && (m.dataType === "run_status" || m.dataType === "run_error" || m.role === "assistant" && m.phase !== "commentary" && (m.streamState === void 0 || ["finished", "stopped", "failed"].includes(m.streamState))))) && this.stopPreviews.delete(l);
|
|
995
948
|
}
|
|
996
|
-
if (this.pendingStop?.userMessageIds.every((l) => !this.stopPreviews.has(l)) && (this.pendingStop = null),
|
|
949
|
+
if (this.pendingStop?.userMessageIds.every((l) => !this.stopPreviews.has(l)) && (this.pendingStop = null), a.user?.id === e.user?.id)
|
|
997
950
|
for (const l of this.state.messages) {
|
|
998
951
|
if (l.role !== "user" || !l.attachments?.length) continue;
|
|
999
|
-
const u =
|
|
1000
|
-
|
|
952
|
+
const u = a.messages.find((p) => p.role === "user" && p.id === l.id);
|
|
953
|
+
a.sessionId !== e.sessionId && !(a.sessionId === null && u) || (l.attachments = Ie(u?.attachments, l.attachments));
|
|
1001
954
|
}
|
|
1002
955
|
if (s && JSON.stringify(s) !== JSON.stringify(this.sessionHistoryState)) {
|
|
1003
|
-
this.sessionHistoryState =
|
|
956
|
+
this.sessionHistoryState = z(s);
|
|
1004
957
|
for (const l of this.sessionHistoryListeners)
|
|
1005
958
|
l(this.getSessionHistoryState());
|
|
1006
959
|
}
|
|
@@ -1026,10 +979,6 @@ class De {
|
|
|
1026
979
|
this.adapter.onDisconnect?.();
|
|
1027
980
|
}
|
|
1028
981
|
}
|
|
1029
|
-
warmup(e = "panel_open", t = this.model) {
|
|
1030
|
-
return this.adapter.dispatch({ type: "runtime.warmup", reason: e, requestedModel: t }).then(() => {
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
982
|
recordPromptPresented(e, t) {
|
|
1034
983
|
this.dispatch({ type: "runtime.prompt_presented", feature: e, openingGeneration: t });
|
|
1035
984
|
}
|
|
@@ -1045,7 +994,7 @@ class De {
|
|
|
1045
994
|
});
|
|
1046
995
|
}
|
|
1047
996
|
reportInvalidStateTransition(e, t, s) {
|
|
1048
|
-
s !== void 0 && !
|
|
997
|
+
s !== void 0 && !G(s) || this.adapter.dispatch({
|
|
1049
998
|
type: "runtime.report_invalid_state_transition",
|
|
1050
999
|
reason: e,
|
|
1051
1000
|
clientMessageId: t,
|
|
@@ -1054,19 +1003,19 @@ class De {
|
|
|
1054
1003
|
});
|
|
1055
1004
|
}
|
|
1056
1005
|
reportDisplayedError(e, t, s, n, r) {
|
|
1057
|
-
const
|
|
1058
|
-
if (n !== void 0 && !
|
|
1059
|
-
const
|
|
1006
|
+
const a = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
|
|
1007
|
+
if (n !== void 0 && !U(n) || r !== void 0 && !F(r)) return;
|
|
1008
|
+
const o = ue(this.getState(), e, s, !!n, this.adapter.diagnosticBuilds);
|
|
1060
1009
|
this.adapter.dispatch({
|
|
1061
1010
|
type: "runtime.report_displayed_error",
|
|
1062
|
-
errorDiagnostic:
|
|
1063
|
-
...
|
|
1011
|
+
errorDiagnostic: o,
|
|
1012
|
+
...o.clientMessageId ? { clientMessageId: o.clientMessageId } : {},
|
|
1064
1013
|
reason: e,
|
|
1065
1014
|
errorFingerprint: t,
|
|
1066
1015
|
...n ? { renderedError: n } : {},
|
|
1067
1016
|
...r ? { historyRefreshFailure: r } : {},
|
|
1068
|
-
...
|
|
1069
|
-
...s ? { displayedMessage:
|
|
1017
|
+
...H(a) ? { httpRequest: a } : {},
|
|
1018
|
+
...s ? { displayedMessage: B(s) } : {}
|
|
1070
1019
|
}).catch(() => {
|
|
1071
1020
|
});
|
|
1072
1021
|
}
|
|
@@ -1081,7 +1030,7 @@ class De {
|
|
|
1081
1030
|
const n = t.attachments ?? [];
|
|
1082
1031
|
if (!s && n.length === 0) return Promise.resolve(null);
|
|
1083
1032
|
this.pendingStop = null, this.stopError = null;
|
|
1084
|
-
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()),
|
|
1033
|
+
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), a = t.submittedAt ?? Date.now(), o = this.submissionGeneration;
|
|
1085
1034
|
this.pendingTransfers.set(r, n.flatMap((d) => d.id ? [d.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
|
|
1086
1035
|
id: r,
|
|
1087
1036
|
role: "user",
|
|
@@ -1089,14 +1038,14 @@ class De {
|
|
|
1089
1038
|
createdAt: "",
|
|
1090
1039
|
attachments: n.map((d) => ({ ...d }))
|
|
1091
1040
|
} });
|
|
1092
|
-
const c = this.sendMessageNow(s, { ...t, clientMessageId: r, submittedAt:
|
|
1041
|
+
const c = this.sendMessageNow(s, { ...t, clientMessageId: r, submittedAt: a, selectionKey: this.state.selectionKey }, o);
|
|
1093
1042
|
return this.emit("state", this.getState()), c.finally(() => {
|
|
1094
1043
|
this.pendingTransfers.delete(r);
|
|
1095
1044
|
});
|
|
1096
1045
|
}
|
|
1097
1046
|
async sendMessageNow(e, t, s) {
|
|
1098
|
-
const n = e, r = t.clientMessageId,
|
|
1099
|
-
s === this.submissionGeneration && this.reportOperationTiming(
|
|
1047
|
+
const n = e, r = t.clientMessageId, a = j((h) => {
|
|
1048
|
+
s === this.submissionGeneration && this.reportOperationTiming(h);
|
|
1100
1049
|
}, {
|
|
1101
1050
|
operation: "send",
|
|
1102
1051
|
layer: "renderer",
|
|
@@ -1104,14 +1053,14 @@ class De {
|
|
|
1104
1053
|
clientMessageId: r,
|
|
1105
1054
|
sessionId: this.state.sessionId
|
|
1106
1055
|
});
|
|
1107
|
-
|
|
1108
|
-
let
|
|
1056
|
+
a.mark("submit");
|
|
1057
|
+
let o = t.attachments ?? [], c = !1, d = !this.hasBeenReady || this.state.submissionReady === !1;
|
|
1109
1058
|
if (s !== this.submissionGeneration) return null;
|
|
1110
1059
|
d && this.readinessPendingSubmissions.add(r);
|
|
1111
1060
|
try {
|
|
1112
|
-
const
|
|
1061
|
+
const h = await a.measure("staging_ipc", async () => {
|
|
1113
1062
|
if (d) {
|
|
1114
|
-
if (!await
|
|
1063
|
+
if (!await a.measure("authentication", () => this.waitForSubmissionReadiness(s))) return null;
|
|
1115
1064
|
this.readinessPendingSubmissions.delete(r), d = !1, t = { ...t, selectionKey: this.state.selectionKey };
|
|
1116
1065
|
}
|
|
1117
1066
|
return this.destroyed || s !== this.submissionGeneration ? null : this.adapter.dispatch({
|
|
@@ -1126,36 +1075,36 @@ class De {
|
|
|
1126
1075
|
clientMessageId: r,
|
|
1127
1076
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1128
1077
|
// Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
|
|
1129
|
-
attachments:
|
|
1078
|
+
attachments: o.length > 0 ? o.map(K) : void 0,
|
|
1130
1079
|
submittedAt: t.submittedAt
|
|
1131
1080
|
}).then((u) => ({ result: u }), async (u) => {
|
|
1132
|
-
const
|
|
1133
|
-
if (
|
|
1081
|
+
const p = b(u);
|
|
1082
|
+
if (p.code !== "submission_checkpoint_pending") throw u;
|
|
1134
1083
|
const f = this.submissionPreviews.get(r);
|
|
1135
|
-
return f && (f.error =
|
|
1084
|
+
return f && (f.error = p), this.emit("state", this.getState()), await this.waitForSubmissionDurability(r, s) ? { result: void 0 } : null;
|
|
1136
1085
|
});
|
|
1137
1086
|
});
|
|
1138
|
-
if (!
|
|
1139
|
-
if (c = !0, this.submissionRetries.delete(r),
|
|
1087
|
+
if (!h || s !== this.submissionGeneration) return null;
|
|
1088
|
+
if (c = !0, this.submissionRetries.delete(r), h.result?.submissionAccepted) {
|
|
1140
1089
|
r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null);
|
|
1141
1090
|
for (const l of t.attachments ?? [])
|
|
1142
1091
|
l.id && this.attachmentFiles.delete(l.id);
|
|
1143
1092
|
return r;
|
|
1144
1093
|
}
|
|
1145
|
-
if (
|
|
1094
|
+
if (o.length > 0) {
|
|
1146
1095
|
if (!this.adapter.uploadAttachment)
|
|
1147
1096
|
throw new Error("The runtime does not support attachments.");
|
|
1148
1097
|
const l = [];
|
|
1149
|
-
for (const u of
|
|
1098
|
+
for (const u of o) {
|
|
1150
1099
|
if (u.sandboxPath || u.storageKey) {
|
|
1151
1100
|
l.push(u);
|
|
1152
1101
|
continue;
|
|
1153
1102
|
}
|
|
1154
|
-
const
|
|
1155
|
-
if (!
|
|
1156
|
-
if (l.push(await
|
|
1103
|
+
const p = u.id ? this.attachmentFiles.get(u.id) : void 0;
|
|
1104
|
+
if (!p) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
|
|
1105
|
+
if (l.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(p, u, { clientMessageId: r }))), s !== this.submissionGeneration) return null;
|
|
1157
1106
|
}
|
|
1158
|
-
|
|
1107
|
+
o = l;
|
|
1159
1108
|
}
|
|
1160
1109
|
if (s !== this.submissionGeneration || (await this.adapter.dispatch({
|
|
1161
1110
|
type: "conversation.send",
|
|
@@ -1167,27 +1116,27 @@ class De {
|
|
|
1167
1116
|
invocation: t.invocation,
|
|
1168
1117
|
automationOnboarding: t.automationOnboarding,
|
|
1169
1118
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1170
|
-
attachments:
|
|
1119
|
+
attachments: o.length > 0 ? o.map(K) : void 0
|
|
1171
1120
|
}), s !== this.submissionGeneration)) return null;
|
|
1172
1121
|
for (const l of t.attachments ?? [])
|
|
1173
1122
|
l.id && this.attachmentFiles.delete(l.id);
|
|
1174
1123
|
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
|
|
1175
|
-
} catch (
|
|
1124
|
+
} catch (h) {
|
|
1176
1125
|
if (s !== this.submissionGeneration) return null;
|
|
1177
|
-
if (C(
|
|
1126
|
+
if (C(h))
|
|
1178
1127
|
for (const f of t.attachments ?? [])
|
|
1179
1128
|
f.id && this.attachmentFiles.delete(f.id);
|
|
1180
|
-
const u = b(
|
|
1181
|
-
!c && !C(
|
|
1129
|
+
const u = b(h).code === "command_not_received";
|
|
1130
|
+
!c && !C(h) && (d || u || t.selectionKey !== void 0) && this.submissionRetries.set(r, {
|
|
1182
1131
|
retry: async () => (d && await this.connect(), this.sendMessageNow(e, { ...t, reconcileAcceptance: !d && !u }, s)),
|
|
1183
1132
|
attachmentIds: (t.attachments ?? []).flatMap((f) => f.id ? [f.id] : [])
|
|
1184
1133
|
});
|
|
1185
|
-
const
|
|
1186
|
-
throw
|
|
1134
|
+
const p = this.submissionPreviews.get(r);
|
|
1135
|
+
throw p && (p.pending = !1, p.error = b(h), this.emit("state", this.getState())), c && await this.adapter.dispatch({
|
|
1187
1136
|
type: "conversation.fail_staged",
|
|
1188
1137
|
clientMessageId: r,
|
|
1189
|
-
message: b(
|
|
1190
|
-
}),
|
|
1138
|
+
message: b(h).message
|
|
1139
|
+
}), h;
|
|
1191
1140
|
} finally {
|
|
1192
1141
|
this.readinessPendingSubmissions.delete(r);
|
|
1193
1142
|
}
|
|
@@ -1199,18 +1148,18 @@ class De {
|
|
|
1199
1148
|
return this.modelExplicit = !0, this.model === e || (this.model = e, this.emit("state", this.getState())), Promise.resolve();
|
|
1200
1149
|
}
|
|
1201
1150
|
async retryLastMessage(e) {
|
|
1202
|
-
const t = e ?? [...this.submissionPreviews].reverse().find(([,
|
|
1151
|
+
const t = e ?? [...this.submissionPreviews].reverse().find(([, o]) => o.error)?.[0] ?? this.state.messages.filter((o) => o.role === "user").slice(-1)[0]?.id;
|
|
1203
1152
|
if (!t || this.destroyed) return !1;
|
|
1204
1153
|
const s = this.submissionPreviews.get(t);
|
|
1205
1154
|
if (s?.pending || this.pendingTransfers.has(t)) return !1;
|
|
1206
|
-
const n = this.submissionRetries.get(t), r = n?.retry,
|
|
1155
|
+
const n = this.submissionRetries.get(t), r = n?.retry, a = this.submissionGeneration;
|
|
1207
1156
|
try {
|
|
1208
1157
|
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;
|
|
1209
|
-
} catch (
|
|
1210
|
-
if (!s && !r) throw
|
|
1211
|
-
return s &&
|
|
1158
|
+
} catch (o) {
|
|
1159
|
+
if (!s && !r) throw o;
|
|
1160
|
+
return s && a === this.submissionGeneration && this.submissionPreviews.get(t) === s && (s.error = b(o), this.emit("state", this.getState())), !1;
|
|
1212
1161
|
} finally {
|
|
1213
|
-
r && this.pendingTransfers.delete(t), s &&
|
|
1162
|
+
r && this.pendingTransfers.delete(t), s && a === this.submissionGeneration && this.submissionPreviews.get(t) === s && (s.pending = !1, this.emit("state", this.getState()));
|
|
1214
1163
|
}
|
|
1215
1164
|
}
|
|
1216
1165
|
createLocalAttachment(e) {
|
|
@@ -1231,7 +1180,7 @@ class De {
|
|
|
1231
1180
|
...t,
|
|
1232
1181
|
e.activeResponseUserMessageId,
|
|
1233
1182
|
e.messages.filter((d) => d.role === "user").slice(-1)[0]?.id
|
|
1234
|
-
].filter((d) => !!d))], n =
|
|
1183
|
+
].filter((d) => !!d))], n = j((d) => this.reportOperationTiming(d), {
|
|
1235
1184
|
operation: "stop",
|
|
1236
1185
|
layer: "renderer",
|
|
1237
1186
|
requestId: crypto.randomUUID(),
|
|
@@ -1241,18 +1190,18 @@ class De {
|
|
|
1241
1190
|
n.mark("stop");
|
|
1242
1191
|
const r = { userMessageIds: s, promise: Promise.resolve() };
|
|
1243
1192
|
this.pendingStop = r;
|
|
1244
|
-
const
|
|
1193
|
+
const a = !e.pendingMessageStatus && ["thinking", "steering", "queued", "stopping"].includes(this.state.activity?.phase ?? "") ? this.state.activity?.executionKey : void 0;
|
|
1245
1194
|
for (const d of s)
|
|
1246
|
-
this.stopPreviews.set(d, t.includes(d) ? void 0 :
|
|
1247
|
-
const
|
|
1195
|
+
this.stopPreviews.set(d, t.includes(d) ? void 0 : a);
|
|
1196
|
+
const o = this.submissionGeneration;
|
|
1248
1197
|
return r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
|
|
1249
1198
|
}, (d) => {
|
|
1250
|
-
if (!(
|
|
1251
|
-
for (const
|
|
1199
|
+
if (!(o !== this.submissionGeneration || s.every((h) => !this.stopPreviews.has(h)))) {
|
|
1200
|
+
for (const h of s) this.stopPreviews.delete(h);
|
|
1252
1201
|
this.stopError = b(d).message;
|
|
1253
1202
|
}
|
|
1254
1203
|
}).finally(() => {
|
|
1255
|
-
this.destroyed ||
|
|
1204
|
+
this.destroyed || o !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
|
|
1256
1205
|
}), this.emit("state", this.getState()), r.promise.then(() => {
|
|
1257
1206
|
});
|
|
1258
1207
|
}
|
|
@@ -1280,27 +1229,27 @@ class De {
|
|
|
1280
1229
|
let s = () => {
|
|
1281
1230
|
}, n = () => {
|
|
1282
1231
|
};
|
|
1283
|
-
return new Promise((r,
|
|
1232
|
+
return new Promise((r, a) => {
|
|
1284
1233
|
n = () => {
|
|
1285
1234
|
if (this.destroyed || t !== this.submissionGeneration) {
|
|
1286
1235
|
r(!1);
|
|
1287
1236
|
return;
|
|
1288
1237
|
}
|
|
1289
|
-
const
|
|
1290
|
-
if (
|
|
1238
|
+
const o = this.state;
|
|
1239
|
+
if (o.messages.some((d) => d.respondsToUserMessageId === e && d.dataType === "run_status" && !d.provisional)) {
|
|
1291
1240
|
r(!1);
|
|
1292
1241
|
return;
|
|
1293
1242
|
}
|
|
1294
|
-
if (
|
|
1295
|
-
|
|
1243
|
+
if (o.conversationDiagnostics?.failedClientMessageId === e && o.lastError && o.lastErrorCode !== "submission_checkpoint_pending") {
|
|
1244
|
+
a(Object.assign(new Error(o.lastError), { code: o.lastErrorCode }));
|
|
1296
1245
|
return;
|
|
1297
1246
|
}
|
|
1298
|
-
const c =
|
|
1247
|
+
const c = o.messages.find((d) => d.id === `submission-error:${e}` && d.dataType === "run_error");
|
|
1299
1248
|
if (c) {
|
|
1300
|
-
|
|
1249
|
+
a(new Error(c.content));
|
|
1301
1250
|
return;
|
|
1302
1251
|
}
|
|
1303
|
-
|
|
1252
|
+
o.receipts?.some((d) => d.userMessageId === e && d.durable) && r(!0);
|
|
1304
1253
|
}, this.durabilityWaiters.add(n), s = this.on("state", n), n();
|
|
1305
1254
|
}).finally(() => {
|
|
1306
1255
|
s(), this.durabilityWaiters.delete(n);
|
|
@@ -1337,7 +1286,7 @@ class De {
|
|
|
1337
1286
|
return t.sessionHistoryPage;
|
|
1338
1287
|
}
|
|
1339
1288
|
getSessionHistoryState() {
|
|
1340
|
-
return
|
|
1289
|
+
return z(this.sessionHistoryState);
|
|
1341
1290
|
}
|
|
1342
1291
|
subscribeSessionHistory(e) {
|
|
1343
1292
|
return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
|
|
@@ -1366,7 +1315,7 @@ class De {
|
|
|
1366
1315
|
return this.interactionListeners.add(e), e(this.getInteractions()), () => this.interactionListeners.delete(e);
|
|
1367
1316
|
}
|
|
1368
1317
|
actOnInteraction(e, t, s, n = {}) {
|
|
1369
|
-
const r = n.expectedSourceVersion === void 0 ? this.getInteractions().find((
|
|
1318
|
+
const r = n.expectedSourceVersion === void 0 ? this.getInteractions().find((a) => a.id === e)?.sourceVersion ?? null : n.expectedSourceVersion;
|
|
1370
1319
|
return this.dispatch({
|
|
1371
1320
|
type: "interaction.act",
|
|
1372
1321
|
interactionId: e,
|
|
@@ -1419,7 +1368,7 @@ class De {
|
|
|
1419
1368
|
for (const n of s ?? []) n(t);
|
|
1420
1369
|
}
|
|
1421
1370
|
}
|
|
1422
|
-
function
|
|
1371
|
+
function Ie(i, e) {
|
|
1423
1372
|
if (!e || !i) return e;
|
|
1424
1373
|
const t = /* @__PURE__ */ new Map();
|
|
1425
1374
|
for (const s of i) {
|
|
@@ -1431,7 +1380,7 @@ function Se(i, e) {
|
|
|
1431
1380
|
return n ? { ...s, previewUrl: n } : s;
|
|
1432
1381
|
});
|
|
1433
1382
|
}
|
|
1434
|
-
function
|
|
1383
|
+
function _(i) {
|
|
1435
1384
|
return {
|
|
1436
1385
|
...i,
|
|
1437
1386
|
starterPrompts: [...i.starterPrompts],
|
|
@@ -1439,7 +1388,7 @@ function I(i) {
|
|
|
1439
1388
|
messages: i.messages.map((e) => {
|
|
1440
1389
|
const t = {
|
|
1441
1390
|
...e,
|
|
1442
|
-
attachments: e.attachments?.map((
|
|
1391
|
+
attachments: e.attachments?.map((a) => ({ ...a }))
|
|
1443
1392
|
}, s = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
|
|
1444
1393
|
return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
|
|
1445
1394
|
value: r,
|
|
@@ -1455,36 +1404,34 @@ function I(i) {
|
|
|
1455
1404
|
activeScheduledFollowUps: i.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
|
|
1456
1405
|
};
|
|
1457
1406
|
}
|
|
1458
|
-
function
|
|
1407
|
+
function z(i) {
|
|
1459
1408
|
return {
|
|
1460
1409
|
...i,
|
|
1461
1410
|
data: i.data ? w({
|
|
1462
|
-
entities:
|
|
1411
|
+
entities: J(i.data).map((e) => ({ ...e })),
|
|
1463
1412
|
nextCursor: i.data.nextCursor
|
|
1464
1413
|
}) : null
|
|
1465
1414
|
};
|
|
1466
1415
|
}
|
|
1467
1416
|
export {
|
|
1468
|
-
|
|
1469
|
-
|
|
1417
|
+
W as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
|
|
1418
|
+
Ee as ProductAgentInteractionManager,
|
|
1470
1419
|
O as ProductAgentQueryController,
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
Te as
|
|
1475
|
-
qe as createLocalStorageInteractionDecisionStorage,
|
|
1420
|
+
qe as ProductAgentRemoteRuntimeClient,
|
|
1421
|
+
Me as ProductAgentSessionHistoryManager,
|
|
1422
|
+
Pe as ProductAgentTaskPageTitleController,
|
|
1423
|
+
Te as createLocalStorageInteractionDecisionStorage,
|
|
1476
1424
|
S as createProductAgentQueryState,
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
Me as hasProductAgentPaidCreditFallback,
|
|
1425
|
+
Re as createProductAgentTaskPageTitleDocument,
|
|
1426
|
+
ie as formatProductAgentTaskPageTitle,
|
|
1480
1427
|
C as isProductAgentAuthReconnectError,
|
|
1481
|
-
|
|
1482
|
-
|
|
1428
|
+
ke as isProductAgentRuntimeCommand,
|
|
1429
|
+
Z as mergeProductAgentEntityPages,
|
|
1483
1430
|
w as normalizeProductAgentEntityPage,
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1431
|
+
ee as readLocalStorageInteractionDecisions,
|
|
1432
|
+
_e as reconcileProductAgentSubmissionGate,
|
|
1433
|
+
we as resolveProductAgentBillingPresentation,
|
|
1434
|
+
Ae as resolveProductAgentComposerAction,
|
|
1435
|
+
Se as resolveProductAgentWidgetPresentation,
|
|
1436
|
+
J as selectProductAgentQueryEntities
|
|
1490
1437
|
};
|