@pluno/product-agent-web 0.1.316 → 0.1.318
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/featureHttp.d.ts +6 -20
- 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/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/index.d.ts +1 -29
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +221 -265
- package/dist/product-agent-sdk.js +4423 -5276
- package/dist/product-agent-widget.js +4991 -6608
- package/dist/runtime.d.ts +1 -1
- package/dist/runtimeState.d.ts +0 -10
- package/dist/scheduledCheckIn.d.ts +0 -5
- package/dist/shareCard.d.ts +0 -25
- package/dist/widget.d.ts +2 -26
- package/package.json +1 -1
- package/dist/adapters/web/deviceHints.d.ts +0 -2
- package/dist/core/account/reducer.d.ts +0 -2
- 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.318", 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",
|
|
@@ -747,7 +705,7 @@ const fe = [
|
|
|
747
705
|
"acceptance_applied",
|
|
748
706
|
"cancellation_queue",
|
|
749
707
|
"cancellation_write"
|
|
750
|
-
],
|
|
708
|
+
], Q = [
|
|
751
709
|
"request_timed_out",
|
|
752
710
|
"delivery_unknown",
|
|
753
711
|
"invalid_ack",
|
|
@@ -763,86 +721,86 @@ const fe = [
|
|
|
763
721
|
"backend_refusal",
|
|
764
722
|
"unknown"
|
|
765
723
|
];
|
|
766
|
-
function
|
|
724
|
+
function ge(i) {
|
|
767
725
|
const e = i, t = e?.code;
|
|
768
|
-
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";
|
|
769
727
|
}
|
|
770
|
-
const
|
|
771
|
-
let
|
|
772
|
-
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);
|
|
773
731
|
function q(i) {
|
|
774
732
|
if (!i || typeof i != "object") return !1;
|
|
775
733
|
const e = i;
|
|
776
|
-
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;
|
|
777
735
|
}
|
|
778
|
-
function
|
|
779
|
-
if (e = { workerId:
|
|
736
|
+
function j(i, e) {
|
|
737
|
+
if (e = { workerId: V, ...e }, !i) return {
|
|
780
738
|
identity: e,
|
|
781
739
|
mark: (n) => {
|
|
782
740
|
},
|
|
783
741
|
measure: (n, r) => r()
|
|
784
742
|
};
|
|
785
|
-
const t = performance.now(), s = (n, r,
|
|
743
|
+
const t = performance.now(), s = (n, r, a, o, c) => {
|
|
786
744
|
const d = {
|
|
787
745
|
...e,
|
|
788
746
|
stage: n,
|
|
789
747
|
status: r,
|
|
790
|
-
spanId:
|
|
748
|
+
spanId: o,
|
|
791
749
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
792
|
-
durationMs: Math.max(0, Math.round(performance.now() -
|
|
793
|
-
...r === "failed" ? { failureCategory:
|
|
750
|
+
durationMs: Math.max(0, Math.round(performance.now() - a)),
|
|
751
|
+
...r === "failed" ? { failureCategory: ge(c) } : {}
|
|
794
752
|
};
|
|
795
753
|
i && q(d) && Promise.resolve().then(() => i(d)).catch(() => {
|
|
796
754
|
});
|
|
797
755
|
};
|
|
798
756
|
return {
|
|
799
757
|
identity: e,
|
|
800
|
-
mark: (n) => s(n, "observed", t,
|
|
758
|
+
mark: (n) => s(n, "observed", t, N()),
|
|
801
759
|
measure(n, r) {
|
|
802
|
-
const
|
|
803
|
-
return s(n, "started",
|
|
804
|
-
(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),
|
|
805
763
|
(c) => {
|
|
806
|
-
throw s(n, "failed",
|
|
764
|
+
throw s(n, "failed", a, o, c), c;
|
|
807
765
|
}
|
|
808
766
|
);
|
|
809
767
|
}
|
|
810
768
|
};
|
|
811
769
|
}
|
|
812
770
|
const T = (i) => i === null || typeof i == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(i);
|
|
813
|
-
function
|
|
771
|
+
function me(i) {
|
|
814
772
|
if (!i || typeof i != "object") return !1;
|
|
815
773
|
const e = i;
|
|
816
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";
|
|
817
775
|
}
|
|
818
|
-
function
|
|
776
|
+
function ye(i, e, t = "stopped", s, n = "Run stopped by user.") {
|
|
819
777
|
const r = new Set(s ?? [
|
|
820
778
|
i.assistantDraftRespondsToUserMessageId,
|
|
821
779
|
i.activeResponseUserMessageId,
|
|
822
780
|
i.messages.filter((c) => c.role === "user").slice(-1)[0]?.id
|
|
823
|
-
].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);
|
|
824
782
|
for (const c of r)
|
|
825
|
-
|
|
826
|
-
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: [
|
|
827
785
|
...c.outcomeIds,
|
|
828
|
-
...
|
|
786
|
+
...a.filter((d) => d.id === `local-interrupted:${c.userMessageId}` && !c.outcomeIds.includes(d.id)).map((d) => d.id)
|
|
829
787
|
] }));
|
|
830
788
|
return {
|
|
831
789
|
...i,
|
|
832
|
-
messages:
|
|
790
|
+
messages: a,
|
|
833
791
|
isThinking: !1,
|
|
834
792
|
isRetrying: !1,
|
|
835
793
|
pendingMessageStatus: null,
|
|
836
794
|
turnPhase: null,
|
|
837
|
-
segments:
|
|
795
|
+
segments: o,
|
|
838
796
|
activity: { phase: t, activeItemId: null },
|
|
839
|
-
isLoadingSession: i.isLoadingSession &&
|
|
797
|
+
isLoadingSession: i.isLoadingSession && a.length === 0,
|
|
840
798
|
taskStatus: t === "stopped" ? "stopped" : null,
|
|
841
799
|
lastError: null,
|
|
842
800
|
lastErrorCode: null
|
|
843
801
|
};
|
|
844
802
|
}
|
|
845
|
-
const
|
|
803
|
+
const be = {
|
|
846
804
|
"stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
|
|
847
805
|
"in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
|
|
848
806
|
"stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
|
|
@@ -858,10 +816,10 @@ const _e = {
|
|
|
858
816
|
"thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
|
|
859
817
|
"thinking-without-progress": "Thinking remained visible without progress for five minutes."
|
|
860
818
|
};
|
|
861
|
-
function
|
|
862
|
-
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));
|
|
863
821
|
}
|
|
864
|
-
function
|
|
822
|
+
function K(i) {
|
|
865
823
|
return {
|
|
866
824
|
...i.id === void 0 ? {} : { id: i.id },
|
|
867
825
|
name: i.name,
|
|
@@ -872,7 +830,7 @@ function z(i) {
|
|
|
872
830
|
...i.fileUrl === void 0 ? {} : { fileUrl: i.fileUrl }
|
|
873
831
|
};
|
|
874
832
|
}
|
|
875
|
-
function
|
|
833
|
+
function ke(i) {
|
|
876
834
|
if (!i || typeof i != "object" || !("type" in i)) return !1;
|
|
877
835
|
const e = i;
|
|
878
836
|
switch (e.type) {
|
|
@@ -884,13 +842,13 @@ function xe(i) {
|
|
|
884
842
|
case "run.stop":
|
|
885
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);
|
|
886
844
|
case "runtime.report_response_visibility":
|
|
887
|
-
return
|
|
845
|
+
return me(e.observation);
|
|
888
846
|
case "runtime.report_operation_timing":
|
|
889
847
|
return q(e.timing);
|
|
890
848
|
case "runtime.report_displayed_error":
|
|
891
|
-
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);
|
|
892
850
|
case "runtime.report_invalid_state_transition":
|
|
893
|
-
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");
|
|
894
852
|
case "runtime.prompt_presented":
|
|
895
853
|
return (e.feature === "notifications" || e.feature === "tab_grouping") && typeof e.openingGeneration == "number" && Number.isSafeInteger(e.openingGeneration) && e.openingGeneration > 0;
|
|
896
854
|
case "runtime.widget_lifecycle":
|
|
@@ -920,9 +878,9 @@ function xe(i) {
|
|
|
920
878
|
return !1;
|
|
921
879
|
}
|
|
922
880
|
}
|
|
923
|
-
class
|
|
881
|
+
class qe {
|
|
924
882
|
constructor(e, t, s) {
|
|
925
|
-
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;
|
|
926
884
|
}
|
|
927
885
|
adapter;
|
|
928
886
|
listeners = {};
|
|
@@ -960,42 +918,42 @@ class De {
|
|
|
960
918
|
return s.add(t), this.listeners[e] = s, () => s.delete(t);
|
|
961
919
|
}
|
|
962
920
|
getState() {
|
|
963
|
-
const e =
|
|
921
|
+
const e = _(this.state);
|
|
964
922
|
if (this.pendingNavigation && (e.isLoadingSession = !0), this.retainedTranscript) {
|
|
965
|
-
const n =
|
|
966
|
-
e.messages = [...n.messages, ...e.messages.filter((
|
|
967
|
-
...(n.segments ?? []).map((
|
|
968
|
-
...(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))
|
|
969
927
|
]), e.removedItems = { ...n.removedItems, ...e.removedItems };
|
|
970
928
|
}
|
|
971
929
|
for (const [n, r] of this.submissionPreviews)
|
|
972
|
-
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"));
|
|
973
931
|
this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
|
|
974
932
|
const t = [...this.stopPreviews.keys()];
|
|
975
933
|
if (!t.length) return e;
|
|
976
|
-
const s =
|
|
934
|
+
const s = ye(e, "", "stopping", t);
|
|
977
935
|
return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: s.messages, segments: s.segments } : s;
|
|
978
936
|
}
|
|
979
937
|
updateProjection(e, t, s, n, r) {
|
|
980
938
|
if (this.destroyed) return;
|
|
981
|
-
const
|
|
982
|
-
!
|
|
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());
|
|
983
941
|
for (const l of e.messages)
|
|
984
942
|
l.role === "user" && e.receipts?.find((u) => u.userMessageId === l.id)?.durable !== !1 && this.submissionPreviews.delete(l.id);
|
|
985
|
-
const
|
|
986
|
-
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);
|
|
987
945
|
for (const [l, u] of this.stopPreviews) {
|
|
988
|
-
const
|
|
989
|
-
(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);
|
|
990
948
|
}
|
|
991
|
-
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)
|
|
992
950
|
for (const l of this.state.messages) {
|
|
993
951
|
if (l.role !== "user" || !l.attachments?.length) continue;
|
|
994
|
-
const u =
|
|
995
|
-
|
|
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));
|
|
996
954
|
}
|
|
997
955
|
if (s && JSON.stringify(s) !== JSON.stringify(this.sessionHistoryState)) {
|
|
998
|
-
this.sessionHistoryState =
|
|
956
|
+
this.sessionHistoryState = z(s);
|
|
999
957
|
for (const l of this.sessionHistoryListeners)
|
|
1000
958
|
l(this.getSessionHistoryState());
|
|
1001
959
|
}
|
|
@@ -1036,7 +994,7 @@ class De {
|
|
|
1036
994
|
});
|
|
1037
995
|
}
|
|
1038
996
|
reportInvalidStateTransition(e, t, s) {
|
|
1039
|
-
s !== void 0 && !
|
|
997
|
+
s !== void 0 && !G(s) || this.adapter.dispatch({
|
|
1040
998
|
type: "runtime.report_invalid_state_transition",
|
|
1041
999
|
reason: e,
|
|
1042
1000
|
clientMessageId: t,
|
|
@@ -1045,19 +1003,19 @@ class De {
|
|
|
1045
1003
|
});
|
|
1046
1004
|
}
|
|
1047
1005
|
reportDisplayedError(e, t, s, n, r) {
|
|
1048
|
-
const
|
|
1049
|
-
if (n !== void 0 && !
|
|
1050
|
-
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);
|
|
1051
1009
|
this.adapter.dispatch({
|
|
1052
1010
|
type: "runtime.report_displayed_error",
|
|
1053
|
-
errorDiagnostic:
|
|
1054
|
-
...
|
|
1011
|
+
errorDiagnostic: o,
|
|
1012
|
+
...o.clientMessageId ? { clientMessageId: o.clientMessageId } : {},
|
|
1055
1013
|
reason: e,
|
|
1056
1014
|
errorFingerprint: t,
|
|
1057
1015
|
...n ? { renderedError: n } : {},
|
|
1058
1016
|
...r ? { historyRefreshFailure: r } : {},
|
|
1059
|
-
...
|
|
1060
|
-
...s ? { displayedMessage:
|
|
1017
|
+
...H(a) ? { httpRequest: a } : {},
|
|
1018
|
+
...s ? { displayedMessage: B(s) } : {}
|
|
1061
1019
|
}).catch(() => {
|
|
1062
1020
|
});
|
|
1063
1021
|
}
|
|
@@ -1072,7 +1030,7 @@ class De {
|
|
|
1072
1030
|
const n = t.attachments ?? [];
|
|
1073
1031
|
if (!s && n.length === 0) return Promise.resolve(null);
|
|
1074
1032
|
this.pendingStop = null, this.stopError = null;
|
|
1075
|
-
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;
|
|
1076
1034
|
this.pendingTransfers.set(r, n.flatMap((d) => d.id ? [d.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
|
|
1077
1035
|
id: r,
|
|
1078
1036
|
role: "user",
|
|
@@ -1080,14 +1038,14 @@ class De {
|
|
|
1080
1038
|
createdAt: "",
|
|
1081
1039
|
attachments: n.map((d) => ({ ...d }))
|
|
1082
1040
|
} });
|
|
1083
|
-
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);
|
|
1084
1042
|
return this.emit("state", this.getState()), c.finally(() => {
|
|
1085
1043
|
this.pendingTransfers.delete(r);
|
|
1086
1044
|
});
|
|
1087
1045
|
}
|
|
1088
1046
|
async sendMessageNow(e, t, s) {
|
|
1089
|
-
const n = e, r = t.clientMessageId,
|
|
1090
|
-
s === this.submissionGeneration && this.reportOperationTiming(
|
|
1047
|
+
const n = e, r = t.clientMessageId, a = j((h) => {
|
|
1048
|
+
s === this.submissionGeneration && this.reportOperationTiming(h);
|
|
1091
1049
|
}, {
|
|
1092
1050
|
operation: "send",
|
|
1093
1051
|
layer: "renderer",
|
|
@@ -1095,14 +1053,14 @@ class De {
|
|
|
1095
1053
|
clientMessageId: r,
|
|
1096
1054
|
sessionId: this.state.sessionId
|
|
1097
1055
|
});
|
|
1098
|
-
|
|
1099
|
-
let
|
|
1056
|
+
a.mark("submit");
|
|
1057
|
+
let o = t.attachments ?? [], c = !1, d = !this.hasBeenReady || this.state.submissionReady === !1;
|
|
1100
1058
|
if (s !== this.submissionGeneration) return null;
|
|
1101
1059
|
d && this.readinessPendingSubmissions.add(r);
|
|
1102
1060
|
try {
|
|
1103
|
-
const
|
|
1061
|
+
const h = await a.measure("staging_ipc", async () => {
|
|
1104
1062
|
if (d) {
|
|
1105
|
-
if (!await
|
|
1063
|
+
if (!await a.measure("authentication", () => this.waitForSubmissionReadiness(s))) return null;
|
|
1106
1064
|
this.readinessPendingSubmissions.delete(r), d = !1, t = { ...t, selectionKey: this.state.selectionKey };
|
|
1107
1065
|
}
|
|
1108
1066
|
return this.destroyed || s !== this.submissionGeneration ? null : this.adapter.dispatch({
|
|
@@ -1117,36 +1075,36 @@ class De {
|
|
|
1117
1075
|
clientMessageId: r,
|
|
1118
1076
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1119
1077
|
// Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
|
|
1120
|
-
attachments:
|
|
1078
|
+
attachments: o.length > 0 ? o.map(K) : void 0,
|
|
1121
1079
|
submittedAt: t.submittedAt
|
|
1122
1080
|
}).then((u) => ({ result: u }), async (u) => {
|
|
1123
|
-
const
|
|
1124
|
-
if (
|
|
1081
|
+
const p = b(u);
|
|
1082
|
+
if (p.code !== "submission_checkpoint_pending") throw u;
|
|
1125
1083
|
const f = this.submissionPreviews.get(r);
|
|
1126
|
-
return f && (f.error =
|
|
1084
|
+
return f && (f.error = p), this.emit("state", this.getState()), await this.waitForSubmissionDurability(r, s) ? { result: void 0 } : null;
|
|
1127
1085
|
});
|
|
1128
1086
|
});
|
|
1129
|
-
if (!
|
|
1130
|
-
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) {
|
|
1131
1089
|
r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null);
|
|
1132
1090
|
for (const l of t.attachments ?? [])
|
|
1133
1091
|
l.id && this.attachmentFiles.delete(l.id);
|
|
1134
1092
|
return r;
|
|
1135
1093
|
}
|
|
1136
|
-
if (
|
|
1094
|
+
if (o.length > 0) {
|
|
1137
1095
|
if (!this.adapter.uploadAttachment)
|
|
1138
1096
|
throw new Error("The runtime does not support attachments.");
|
|
1139
1097
|
const l = [];
|
|
1140
|
-
for (const u of
|
|
1098
|
+
for (const u of o) {
|
|
1141
1099
|
if (u.sandboxPath || u.storageKey) {
|
|
1142
1100
|
l.push(u);
|
|
1143
1101
|
continue;
|
|
1144
1102
|
}
|
|
1145
|
-
const
|
|
1146
|
-
if (!
|
|
1147
|
-
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;
|
|
1148
1106
|
}
|
|
1149
|
-
|
|
1107
|
+
o = l;
|
|
1150
1108
|
}
|
|
1151
1109
|
if (s !== this.submissionGeneration || (await this.adapter.dispatch({
|
|
1152
1110
|
type: "conversation.send",
|
|
@@ -1158,27 +1116,27 @@ class De {
|
|
|
1158
1116
|
invocation: t.invocation,
|
|
1159
1117
|
automationOnboarding: t.automationOnboarding,
|
|
1160
1118
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1161
|
-
attachments:
|
|
1119
|
+
attachments: o.length > 0 ? o.map(K) : void 0
|
|
1162
1120
|
}), s !== this.submissionGeneration)) return null;
|
|
1163
1121
|
for (const l of t.attachments ?? [])
|
|
1164
1122
|
l.id && this.attachmentFiles.delete(l.id);
|
|
1165
1123
|
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
|
|
1166
|
-
} catch (
|
|
1124
|
+
} catch (h) {
|
|
1167
1125
|
if (s !== this.submissionGeneration) return null;
|
|
1168
|
-
if (C(
|
|
1126
|
+
if (C(h))
|
|
1169
1127
|
for (const f of t.attachments ?? [])
|
|
1170
1128
|
f.id && this.attachmentFiles.delete(f.id);
|
|
1171
|
-
const u = b(
|
|
1172
|
-
!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, {
|
|
1173
1131
|
retry: async () => (d && await this.connect(), this.sendMessageNow(e, { ...t, reconcileAcceptance: !d && !u }, s)),
|
|
1174
1132
|
attachmentIds: (t.attachments ?? []).flatMap((f) => f.id ? [f.id] : [])
|
|
1175
1133
|
});
|
|
1176
|
-
const
|
|
1177
|
-
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({
|
|
1178
1136
|
type: "conversation.fail_staged",
|
|
1179
1137
|
clientMessageId: r,
|
|
1180
|
-
message: b(
|
|
1181
|
-
}),
|
|
1138
|
+
message: b(h).message
|
|
1139
|
+
}), h;
|
|
1182
1140
|
} finally {
|
|
1183
1141
|
this.readinessPendingSubmissions.delete(r);
|
|
1184
1142
|
}
|
|
@@ -1190,18 +1148,18 @@ class De {
|
|
|
1190
1148
|
return this.modelExplicit = !0, this.model === e || (this.model = e, this.emit("state", this.getState())), Promise.resolve();
|
|
1191
1149
|
}
|
|
1192
1150
|
async retryLastMessage(e) {
|
|
1193
|
-
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;
|
|
1194
1152
|
if (!t || this.destroyed) return !1;
|
|
1195
1153
|
const s = this.submissionPreviews.get(t);
|
|
1196
1154
|
if (s?.pending || this.pendingTransfers.has(t)) return !1;
|
|
1197
|
-
const n = this.submissionRetries.get(t), r = n?.retry,
|
|
1155
|
+
const n = this.submissionRetries.get(t), r = n?.retry, a = this.submissionGeneration;
|
|
1198
1156
|
try {
|
|
1199
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;
|
|
1200
|
-
} catch (
|
|
1201
|
-
if (!s && !r) throw
|
|
1202
|
-
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;
|
|
1203
1161
|
} finally {
|
|
1204
|
-
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()));
|
|
1205
1163
|
}
|
|
1206
1164
|
}
|
|
1207
1165
|
createLocalAttachment(e) {
|
|
@@ -1222,7 +1180,7 @@ class De {
|
|
|
1222
1180
|
...t,
|
|
1223
1181
|
e.activeResponseUserMessageId,
|
|
1224
1182
|
e.messages.filter((d) => d.role === "user").slice(-1)[0]?.id
|
|
1225
|
-
].filter((d) => !!d))], n =
|
|
1183
|
+
].filter((d) => !!d))], n = j((d) => this.reportOperationTiming(d), {
|
|
1226
1184
|
operation: "stop",
|
|
1227
1185
|
layer: "renderer",
|
|
1228
1186
|
requestId: crypto.randomUUID(),
|
|
@@ -1232,18 +1190,18 @@ class De {
|
|
|
1232
1190
|
n.mark("stop");
|
|
1233
1191
|
const r = { userMessageIds: s, promise: Promise.resolve() };
|
|
1234
1192
|
this.pendingStop = r;
|
|
1235
|
-
const
|
|
1193
|
+
const a = !e.pendingMessageStatus && ["thinking", "steering", "queued", "stopping"].includes(this.state.activity?.phase ?? "") ? this.state.activity?.executionKey : void 0;
|
|
1236
1194
|
for (const d of s)
|
|
1237
|
-
this.stopPreviews.set(d, t.includes(d) ? void 0 :
|
|
1238
|
-
const
|
|
1195
|
+
this.stopPreviews.set(d, t.includes(d) ? void 0 : a);
|
|
1196
|
+
const o = this.submissionGeneration;
|
|
1239
1197
|
return r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
|
|
1240
1198
|
}, (d) => {
|
|
1241
|
-
if (!(
|
|
1242
|
-
for (const
|
|
1199
|
+
if (!(o !== this.submissionGeneration || s.every((h) => !this.stopPreviews.has(h)))) {
|
|
1200
|
+
for (const h of s) this.stopPreviews.delete(h);
|
|
1243
1201
|
this.stopError = b(d).message;
|
|
1244
1202
|
}
|
|
1245
1203
|
}).finally(() => {
|
|
1246
|
-
this.destroyed ||
|
|
1204
|
+
this.destroyed || o !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
|
|
1247
1205
|
}), this.emit("state", this.getState()), r.promise.then(() => {
|
|
1248
1206
|
});
|
|
1249
1207
|
}
|
|
@@ -1271,27 +1229,27 @@ class De {
|
|
|
1271
1229
|
let s = () => {
|
|
1272
1230
|
}, n = () => {
|
|
1273
1231
|
};
|
|
1274
|
-
return new Promise((r,
|
|
1232
|
+
return new Promise((r, a) => {
|
|
1275
1233
|
n = () => {
|
|
1276
1234
|
if (this.destroyed || t !== this.submissionGeneration) {
|
|
1277
1235
|
r(!1);
|
|
1278
1236
|
return;
|
|
1279
1237
|
}
|
|
1280
|
-
const
|
|
1281
|
-
if (
|
|
1238
|
+
const o = this.state;
|
|
1239
|
+
if (o.messages.some((d) => d.respondsToUserMessageId === e && d.dataType === "run_status" && !d.provisional)) {
|
|
1282
1240
|
r(!1);
|
|
1283
1241
|
return;
|
|
1284
1242
|
}
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1243
|
+
if (o.conversationDiagnostics?.failedClientMessageId === e && o.lastError && o.lastErrorCode !== "submission_checkpoint_pending") {
|
|
1244
|
+
a(Object.assign(new Error(o.lastError), { code: o.lastErrorCode }));
|
|
1287
1245
|
return;
|
|
1288
1246
|
}
|
|
1289
|
-
const c =
|
|
1247
|
+
const c = o.messages.find((d) => d.id === `submission-error:${e}` && d.dataType === "run_error");
|
|
1290
1248
|
if (c) {
|
|
1291
|
-
|
|
1249
|
+
a(new Error(c.content));
|
|
1292
1250
|
return;
|
|
1293
1251
|
}
|
|
1294
|
-
|
|
1252
|
+
o.receipts?.some((d) => d.userMessageId === e && d.durable) && r(!0);
|
|
1295
1253
|
}, this.durabilityWaiters.add(n), s = this.on("state", n), n();
|
|
1296
1254
|
}).finally(() => {
|
|
1297
1255
|
s(), this.durabilityWaiters.delete(n);
|
|
@@ -1328,7 +1286,7 @@ class De {
|
|
|
1328
1286
|
return t.sessionHistoryPage;
|
|
1329
1287
|
}
|
|
1330
1288
|
getSessionHistoryState() {
|
|
1331
|
-
return
|
|
1289
|
+
return z(this.sessionHistoryState);
|
|
1332
1290
|
}
|
|
1333
1291
|
subscribeSessionHistory(e) {
|
|
1334
1292
|
return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
|
|
@@ -1357,7 +1315,7 @@ class De {
|
|
|
1357
1315
|
return this.interactionListeners.add(e), e(this.getInteractions()), () => this.interactionListeners.delete(e);
|
|
1358
1316
|
}
|
|
1359
1317
|
actOnInteraction(e, t, s, n = {}) {
|
|
1360
|
-
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;
|
|
1361
1319
|
return this.dispatch({
|
|
1362
1320
|
type: "interaction.act",
|
|
1363
1321
|
interactionId: e,
|
|
@@ -1410,7 +1368,7 @@ class De {
|
|
|
1410
1368
|
for (const n of s ?? []) n(t);
|
|
1411
1369
|
}
|
|
1412
1370
|
}
|
|
1413
|
-
function
|
|
1371
|
+
function Ie(i, e) {
|
|
1414
1372
|
if (!e || !i) return e;
|
|
1415
1373
|
const t = /* @__PURE__ */ new Map();
|
|
1416
1374
|
for (const s of i) {
|
|
@@ -1422,7 +1380,7 @@ function Se(i, e) {
|
|
|
1422
1380
|
return n ? { ...s, previewUrl: n } : s;
|
|
1423
1381
|
});
|
|
1424
1382
|
}
|
|
1425
|
-
function
|
|
1383
|
+
function _(i) {
|
|
1426
1384
|
return {
|
|
1427
1385
|
...i,
|
|
1428
1386
|
starterPrompts: [...i.starterPrompts],
|
|
@@ -1430,7 +1388,7 @@ function I(i) {
|
|
|
1430
1388
|
messages: i.messages.map((e) => {
|
|
1431
1389
|
const t = {
|
|
1432
1390
|
...e,
|
|
1433
|
-
attachments: e.attachments?.map((
|
|
1391
|
+
attachments: e.attachments?.map((a) => ({ ...a }))
|
|
1434
1392
|
}, s = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
|
|
1435
1393
|
return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
|
|
1436
1394
|
value: r,
|
|
@@ -1446,36 +1404,34 @@ function I(i) {
|
|
|
1446
1404
|
activeScheduledFollowUps: i.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
|
|
1447
1405
|
};
|
|
1448
1406
|
}
|
|
1449
|
-
function
|
|
1407
|
+
function z(i) {
|
|
1450
1408
|
return {
|
|
1451
1409
|
...i,
|
|
1452
1410
|
data: i.data ? w({
|
|
1453
|
-
entities:
|
|
1411
|
+
entities: J(i.data).map((e) => ({ ...e })),
|
|
1454
1412
|
nextCursor: i.data.nextCursor
|
|
1455
1413
|
}) : null
|
|
1456
1414
|
};
|
|
1457
1415
|
}
|
|
1458
1416
|
export {
|
|
1459
|
-
|
|
1460
|
-
|
|
1417
|
+
W as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
|
|
1418
|
+
Ee as ProductAgentInteractionManager,
|
|
1461
1419
|
O as ProductAgentQueryController,
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
Te as
|
|
1466
|
-
qe as createLocalStorageInteractionDecisionStorage,
|
|
1420
|
+
qe as ProductAgentRemoteRuntimeClient,
|
|
1421
|
+
Me as ProductAgentSessionHistoryManager,
|
|
1422
|
+
Pe as ProductAgentTaskPageTitleController,
|
|
1423
|
+
Te as createLocalStorageInteractionDecisionStorage,
|
|
1467
1424
|
S as createProductAgentQueryState,
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
Me as hasProductAgentPaidCreditFallback,
|
|
1425
|
+
Re as createProductAgentTaskPageTitleDocument,
|
|
1426
|
+
ie as formatProductAgentTaskPageTitle,
|
|
1471
1427
|
C as isProductAgentAuthReconnectError,
|
|
1472
|
-
|
|
1473
|
-
|
|
1428
|
+
ke as isProductAgentRuntimeCommand,
|
|
1429
|
+
Z as mergeProductAgentEntityPages,
|
|
1474
1430
|
w as normalizeProductAgentEntityPage,
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1431
|
+
ee as readLocalStorageInteractionDecisions,
|
|
1432
|
+
_e as reconcileProductAgentSubmissionGate,
|
|
1433
|
+
we as resolveProductAgentBillingPresentation,
|
|
1434
|
+
Ae as resolveProductAgentComposerAction,
|
|
1435
|
+
Se as resolveProductAgentWidgetPresentation,
|
|
1436
|
+
J as selectProductAgentQueryEntities
|
|
1481
1437
|
};
|