@pluno/product-agent-web 0.1.252 → 0.1.254
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/dist/operationTiming.d.ts +1 -1
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +191 -170
- package/dist/product-agent-sdk.js +1359 -1313
- package/dist/product-agent-widget.js +1197 -1169
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(s) {
|
|
2
2
|
return {
|
|
3
3
|
key: s,
|
|
4
4
|
status: "not_requested",
|
|
@@ -10,7 +10,7 @@ function f(s) {
|
|
|
10
10
|
}
|
|
11
11
|
class O {
|
|
12
12
|
constructor(e, t, i = (n, r) => r) {
|
|
13
|
-
this.loader = t, this.merge = i, this.state =
|
|
13
|
+
this.loader = t, this.merge = i, this.state = m(e);
|
|
14
14
|
}
|
|
15
15
|
loader;
|
|
16
16
|
merge;
|
|
@@ -25,10 +25,10 @@ class O {
|
|
|
25
25
|
return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
|
|
26
26
|
}
|
|
27
27
|
setKey(e) {
|
|
28
|
-
e !== this.state.key && (this.state =
|
|
28
|
+
e !== this.state.key && (this.state = m(e), this.trailingLoad = null, this.publish());
|
|
29
29
|
}
|
|
30
30
|
reset() {
|
|
31
|
-
this.state =
|
|
31
|
+
this.state = m(this.state.key), this.trailingLoad = null, this.publish();
|
|
32
32
|
}
|
|
33
33
|
invalidate() {
|
|
34
34
|
this.state = {
|
|
@@ -93,20 +93,20 @@ function y(s) {
|
|
|
93
93
|
nextCursor: s.nextCursor
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function G(s, e, t) {
|
|
97
97
|
if (t === "replace" || s === null) return e;
|
|
98
98
|
const i = { ...s.entitiesById, ...e.entitiesById }, n = [...s.ids];
|
|
99
99
|
for (const r of e.ids)
|
|
100
100
|
s.entitiesById[r] || n.push(r);
|
|
101
101
|
return { entitiesById: i, ids: n, nextCursor: e.nextCursor };
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function Q(s) {
|
|
104
104
|
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function _e(s) {
|
|
107
107
|
return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function Ie(s, e) {
|
|
110
110
|
return e === "limit_exceeded" ? { allowed: !1, reason: "credits_exhausted", actions: ["upgrade", "earn_credits"] } : e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required" ? { allowed: !1, reason: "payment_issue", actions: ["upgrade"] } : s ?? { allowed: !0, reason: "allowed", actions: [] };
|
|
111
111
|
}
|
|
112
112
|
function Se(s) {
|
|
@@ -114,10 +114,10 @@ function Se(s) {
|
|
|
114
114
|
const e = s.paidCreditFallbackModel;
|
|
115
115
|
return typeof e == "string" && e.length > 0;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function we(s) {
|
|
118
118
|
return s ? s.submissionGate?.allowed === !1 ? { state: "action_required", reason: s.submissionGate.reason } : s.usingPaidCreditFallback === !0 ? { state: "paid_credit_fallback" } : s.creditLimit !== null && s.creditLimit > 0 && s.creditsRemaining !== null && s.creditsRemaining > 0 && s.creditsRemaining / s.creditLimit <= 0.2 ? { state: "low_credits" } : s.creditsUsed !== null ? { state: "usage" } : { state: "hidden" } : { state: "hidden" };
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function Ae(s) {
|
|
121
121
|
return s.submissionAllowed && s.isAuthenticated && s.hasWorkspace && !s.isWebsiteBlocked && s.isCurrentPageResolved && !s.isSubmitting && !s.hasPendingMessage;
|
|
122
122
|
}
|
|
123
123
|
function Ee(s) {
|
|
@@ -144,7 +144,7 @@ class Me {
|
|
|
144
144
|
nextCursor: r.nextCursor
|
|
145
145
|
}))
|
|
146
146
|
),
|
|
147
|
-
|
|
147
|
+
G
|
|
148
148
|
), this.pinnedQuery = new O(
|
|
149
149
|
`${e}:pinned`,
|
|
150
150
|
async () => y({
|
|
@@ -167,18 +167,18 @@ class Me {
|
|
|
167
167
|
activityReconciliationScheduled = !1;
|
|
168
168
|
getState() {
|
|
169
169
|
const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), i = [
|
|
170
|
-
...
|
|
171
|
-
...
|
|
170
|
+
...g(t.data),
|
|
171
|
+
...g(e.data)
|
|
172
172
|
], n = new Map(i.map((d) => [d.id, d])), r = Array.from(n.values()).map(
|
|
173
173
|
(d) => this.applyOverrides(d, this.completedRefreshSequence)
|
|
174
|
-
),
|
|
175
|
-
entities: [...
|
|
174
|
+
), o = Array.from(this.optimisticEntities.values()).filter((d) => !n.has(d.id)).reverse(), a = e.data || t.data || o.length > 0 ? y({
|
|
175
|
+
entities: [...o, ...r],
|
|
176
176
|
nextCursor: e.data?.nextCursor ?? null
|
|
177
177
|
}) : null;
|
|
178
178
|
return {
|
|
179
179
|
key: e.key.slice(0, -7),
|
|
180
180
|
status: V(e, t),
|
|
181
|
-
data:
|
|
181
|
+
data: a,
|
|
182
182
|
error: e.error ?? t.error,
|
|
183
183
|
requestId: Math.max(e.requestId, t.requestId),
|
|
184
184
|
updatedAt: Math.max(e.updatedAt ?? 0, t.updatedAt ?? 0) || null
|
|
@@ -243,8 +243,8 @@ class Me {
|
|
|
243
243
|
}
|
|
244
244
|
reconcileDurableEntities() {
|
|
245
245
|
const e = [
|
|
246
|
-
...
|
|
247
|
-
...
|
|
246
|
+
...g(this.pinnedQuery.getState().data),
|
|
247
|
+
...g(this.recentQuery.getState().data)
|
|
248
248
|
], t = new Set(e.map((i) => i.id));
|
|
249
249
|
for (const i of this.optimisticEntities.keys())
|
|
250
250
|
t.has(i) && this.optimisticEntities.delete(i);
|
|
@@ -283,7 +283,7 @@ class Me {
|
|
|
283
283
|
for (const e of this.listeners) e(this.getState());
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function g(s) {
|
|
287
287
|
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
288
288
|
}
|
|
289
289
|
function V(s, e) {
|
|
@@ -294,36 +294,36 @@ function q(s) {
|
|
|
294
294
|
if (!e) throw new Error("Display timestamps must retain the backend UTC precision.");
|
|
295
295
|
return `${e[1]}.${(e[2] ?? "").padEnd(6, "0")}`;
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function b(s) {
|
|
298
298
|
if (s === null || typeof s == "string" || typeof s == "boolean") return !0;
|
|
299
299
|
if (typeof s == "number") return Number.isFinite(s);
|
|
300
|
-
if (Array.isArray(s)) return s.every(
|
|
300
|
+
if (Array.isArray(s)) return s.every(b);
|
|
301
301
|
if (typeof s != "object") return !1;
|
|
302
302
|
const e = Object.getPrototypeOf(s);
|
|
303
|
-
return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(
|
|
303
|
+
return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(b);
|
|
304
304
|
}
|
|
305
305
|
function N(s) {
|
|
306
306
|
return s !== null && typeof s == "object" && !Object.isFrozen(s) && (Object.values(s).forEach(N), Object.freeze(s)), s;
|
|
307
307
|
}
|
|
308
308
|
function J(s) {
|
|
309
|
-
if (!
|
|
309
|
+
if (!b(s)) throw new Error("Conversation inputs must be JSON-safe values.");
|
|
310
310
|
return JSON.parse(JSON.stringify(s));
|
|
311
311
|
}
|
|
312
312
|
function W(s, e) {
|
|
313
313
|
if (!e) return !1;
|
|
314
314
|
const t = s.executionByUserMessage[e];
|
|
315
315
|
if (t) return ["completed", "stopped", "failed"].includes(t.phase);
|
|
316
|
-
const i = Object.values(s.items).sort((r,
|
|
316
|
+
const i = Object.values(s.items).sort((r, o) => q(r.created_at).localeCompare(q(o.created_at)) || r.id.localeCompare(o.id));
|
|
317
317
|
let n = !1;
|
|
318
318
|
for (const r of i)
|
|
319
319
|
if (r.type === "user_message" && (n = r.id === e), !!n && (r.type === "stopped" || r.type === "error" || r.type === "final_response" && s.streams[r.id]?.state === "finished" && s.streams[r.id].revision >= r.data.revision))
|
|
320
320
|
return !0;
|
|
321
321
|
return !1;
|
|
322
322
|
}
|
|
323
|
-
class
|
|
323
|
+
class Pe {
|
|
324
324
|
constructor(e, t = null) {
|
|
325
325
|
this.storage = e, t && (this.decisions = new Map(
|
|
326
|
-
t.filter(
|
|
326
|
+
t.filter(A).map((i) => [this.getDecisionKey(i), i])
|
|
327
327
|
), this.initialized = !0);
|
|
328
328
|
}
|
|
329
329
|
storage;
|
|
@@ -344,8 +344,8 @@ class Te {
|
|
|
344
344
|
const i = JSON.stringify([t.conversation_id, t.id]), n = this.sources.get(i);
|
|
345
345
|
if (n && n.version >= t.version) continue;
|
|
346
346
|
if (n && n.payload.kind !== t.payload.kind) throw new Error("Interaction kind changed.");
|
|
347
|
-
const r = n?.payload.kind === "personal_channel" && n.lifecycle === "completed" ? "completed" : t.lifecycle,
|
|
348
|
-
this.sources.set(i, N(J({ ...t, lifecycle: r, payload:
|
|
347
|
+
const r = n?.payload.kind === "personal_channel" && n.lifecycle === "completed" ? "completed" : t.lifecycle, o = n?.payload.kind === "sharing" && t.payload.kind === "sharing" ? { ...t.payload, variant: n.payload.variant } : t.payload;
|
|
348
|
+
this.sources.set(i, N(J({ ...t, lifecycle: r, payload: o }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
/** @internal */
|
|
@@ -357,38 +357,38 @@ class Te {
|
|
|
357
357
|
if (!this.conversationReader) return;
|
|
358
358
|
const t = { share: null, integrations: [], channel: null }, i = e ? this.conversationReader(e) : null;
|
|
359
359
|
if (!i) return t;
|
|
360
|
-
const n = [...this.sources.values()].filter((r) => r.conversation_id === e).sort((r,
|
|
360
|
+
const n = [...this.sources.values()].filter((r) => r.conversation_id === e).sort((r, o) => r.version - o.version || r.id.localeCompare(o.id));
|
|
361
361
|
for (const r of n) {
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
if (t.share = null, !
|
|
365
|
-
const
|
|
362
|
+
const o = r.payload;
|
|
363
|
+
if (o.kind === "sharing") {
|
|
364
|
+
if (t.share = null, !o.eligible || r.lifecycle !== "pending" || r.invocation !== "user" || !["main_web_chat", "automation", "extension_sidepanel", "extension_widget"].includes(r.entry_surface ?? "")) continue;
|
|
365
|
+
const a = r.user_message_id ? i.items[r.user_message_id] : null;
|
|
366
366
|
t.share = {
|
|
367
367
|
revision: r.version,
|
|
368
368
|
candidate: {
|
|
369
369
|
id: r.id,
|
|
370
|
-
variant:
|
|
371
|
-
userPrompt:
|
|
370
|
+
variant: o.variant,
|
|
371
|
+
userPrompt: a?.type === "user_message" ? a.data.content : "",
|
|
372
372
|
assistantAnswer: ""
|
|
373
373
|
},
|
|
374
|
-
terminal: !
|
|
374
|
+
terminal: !o.wait_for_terminal || W(i, r.user_message_id)
|
|
375
375
|
};
|
|
376
|
-
} else
|
|
376
|
+
} else o.kind === "integration_auth" ? t.integrations.push({
|
|
377
377
|
revision: r.version,
|
|
378
378
|
request: {
|
|
379
379
|
type: "pipedream_auth_required",
|
|
380
|
-
authRequestId:
|
|
381
|
-
appSlug:
|
|
382
|
-
appName:
|
|
383
|
-
appLogo:
|
|
384
|
-
expiresAt:
|
|
380
|
+
authRequestId: o.request_id,
|
|
381
|
+
appSlug: o.app_slug,
|
|
382
|
+
appName: o.app_name,
|
|
383
|
+
appLogo: o.app_logo ?? void 0,
|
|
384
|
+
expiresAt: o.expires_at
|
|
385
385
|
},
|
|
386
|
-
lifecycle: r.lifecycle === "pending" && Date.parse(
|
|
386
|
+
lifecycle: r.lifecycle === "pending" && Date.parse(o.expires_at) <= Date.now() ? "expired" : r.lifecycle
|
|
387
387
|
}) : t.channel = { revision: r.version, request: {
|
|
388
388
|
type: "personal_channel_connection_required",
|
|
389
|
-
requestId:
|
|
390
|
-
channel:
|
|
391
|
-
managementUrl:
|
|
389
|
+
requestId: o.request_id,
|
|
390
|
+
channel: o.channel,
|
|
391
|
+
managementUrl: o.management_url
|
|
392
392
|
}, lifecycle: r.lifecycle };
|
|
393
393
|
}
|
|
394
394
|
return t;
|
|
@@ -401,7 +401,7 @@ class Te {
|
|
|
401
401
|
if (this.initialized) return;
|
|
402
402
|
const e = await this.storage.load();
|
|
403
403
|
this.decisions = new Map(
|
|
404
|
-
e.filter(
|
|
404
|
+
e.filter(A).map((t) => [this.getDecisionKey(t), t])
|
|
405
405
|
), this.initialized = !0;
|
|
406
406
|
}
|
|
407
407
|
isEligible(e, t = Date.now()) {
|
|
@@ -446,8 +446,8 @@ class Te {
|
|
|
446
446
|
scope: e.scope,
|
|
447
447
|
decidedAt: n.toISOString(),
|
|
448
448
|
nextEligibleAt: this.getNextEligibleAt(e, t, n, i.snoozeUntil)
|
|
449
|
-
},
|
|
450
|
-
return
|
|
449
|
+
}, o = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), a = new Map(this.decisions);
|
|
450
|
+
return a.set(o, r), await this.storage.save([...a.values()]), this.decisions = a, r;
|
|
451
451
|
}
|
|
452
452
|
isDecisionEligible(e, t) {
|
|
453
453
|
return e ? e.action === "dismiss" || e.action === "never" || e.action === "dont_show_again" ? !1 : !e.nextEligibleAt || Date.parse(e.nextEligibleAt) <= t : !0;
|
|
@@ -473,7 +473,7 @@ class Te {
|
|
|
473
473
|
return `${I(e.scope)}:category:${e.category}`;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function Te(s, e) {
|
|
477
477
|
return {
|
|
478
478
|
load: async () => Y(s, e),
|
|
479
479
|
save: async (t) => s.setItem(e, JSON.stringify(t))
|
|
@@ -483,7 +483,7 @@ function Y(s, e) {
|
|
|
483
483
|
const t = s.getItem(e);
|
|
484
484
|
if (!t) return [];
|
|
485
485
|
const i = JSON.parse(t);
|
|
486
|
-
return Array.isArray(i) ? i.filter(
|
|
486
|
+
return Array.isArray(i) ? i.filter(A) : [];
|
|
487
487
|
}
|
|
488
488
|
function I(s) {
|
|
489
489
|
return `${s.level}:${s.key}`;
|
|
@@ -491,7 +491,7 @@ function I(s) {
|
|
|
491
491
|
function z(s) {
|
|
492
492
|
return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
|
|
493
493
|
}
|
|
494
|
-
function
|
|
494
|
+
function A(s) {
|
|
495
495
|
if (!s || typeof s != "object") return !1;
|
|
496
496
|
const e = s;
|
|
497
497
|
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && z(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
|
|
@@ -503,8 +503,8 @@ const X = {
|
|
|
503
503
|
stopped: "⏹️"
|
|
504
504
|
}, ee = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
505
505
|
function te(s, e) {
|
|
506
|
-
if (!e) return
|
|
507
|
-
const t =
|
|
506
|
+
if (!e) return _(s);
|
|
507
|
+
const t = _(s), i = `${X[e]} Pluno`;
|
|
508
508
|
return t ? `${i}: ${t}` : i;
|
|
509
509
|
}
|
|
510
510
|
class Oe {
|
|
@@ -529,10 +529,10 @@ class Oe {
|
|
|
529
529
|
}
|
|
530
530
|
applyStatus(e) {
|
|
531
531
|
const t = this.titleDocument.getTitle();
|
|
532
|
-
t !== this.lastAppliedTitle && (this.baseTitle =
|
|
532
|
+
t !== this.lastAppliedTitle && (this.baseTitle = _(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
|
|
533
533
|
}
|
|
534
534
|
applyClear() {
|
|
535
|
-
const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, i = this.lastAppliedTitle === null ?
|
|
535
|
+
const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, i = this.lastAppliedTitle === null ? _(e) : e;
|
|
536
536
|
this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : i !== e && this.titleDocument.setTitle(i);
|
|
537
537
|
}
|
|
538
538
|
handleTitleChanged() {
|
|
@@ -561,7 +561,7 @@ function qe(s) {
|
|
|
561
561
|
}
|
|
562
562
|
};
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function _(s) {
|
|
565
565
|
return s.replace(ee, "");
|
|
566
566
|
}
|
|
567
567
|
const p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
|
|
@@ -575,11 +575,11 @@ function K(s) {
|
|
|
575
575
|
const e = s;
|
|
576
576
|
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;
|
|
577
577
|
}
|
|
578
|
-
const R = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], E = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s),
|
|
578
|
+
const R = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], E = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), v = (s) => s === null || E(s), ie = (s) => typeof s == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|\+00:00)$/.test(s) && Number.isFinite(Date.parse(s));
|
|
579
579
|
function $(s) {
|
|
580
580
|
if (!s || typeof s != "object") return !1;
|
|
581
581
|
const e = s;
|
|
582
|
-
return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) &&
|
|
582
|
+
return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && v(e.sessionId) && E(e.itemId) && v(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && v(e.runId) && (e.createdAt === null || ie(e.createdAt));
|
|
583
583
|
}
|
|
584
584
|
function ne(s) {
|
|
585
585
|
if (!s || typeof s != "object") return !1;
|
|
@@ -591,7 +591,7 @@ function U(s) {
|
|
|
591
591
|
const e = (i) => {
|
|
592
592
|
if (!i || typeof i != "object") return !1;
|
|
593
593
|
const n = i;
|
|
594
|
-
return Object.keys(i).every((r) => [...R, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || ne(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) &&
|
|
594
|
+
return Object.keys(i).every((r) => [...R, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || ne(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) && v(n.sessionId) && Number.isSafeInteger(n.runtimeItemCount) && n.runtimeItemCount >= 0 && typeof n.welcome == "boolean" && typeof n.truncated == "boolean" && R.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(E));
|
|
595
595
|
}, t = s;
|
|
596
596
|
return (t.before === null || e(t.before)) && e(t.current);
|
|
597
597
|
}
|
|
@@ -606,7 +606,7 @@ function re(s) {
|
|
|
606
606
|
e ^= s.charCodeAt(t), e = Math.imul(e, 16777619);
|
|
607
607
|
return `fnv1a-${(e >>> 0).toString(16).padStart(8, "0")}`;
|
|
608
608
|
}
|
|
609
|
-
const oe = "0.1.
|
|
609
|
+
const oe = "0.1.254", ae = {
|
|
610
610
|
version: oe
|
|
611
611
|
};
|
|
612
612
|
function M(s) {
|
|
@@ -631,7 +631,7 @@ function ce(s, e, t, i, n = {}) {
|
|
|
631
631
|
};
|
|
632
632
|
}
|
|
633
633
|
function le(s) {
|
|
634
|
-
if (s.details !== void 0 && !
|
|
634
|
+
if (s.details !== void 0 && !b(s.details))
|
|
635
635
|
throw new TypeError("Product Agent transported error details must be JSON-safe.");
|
|
636
636
|
return {
|
|
637
637
|
code: s.code,
|
|
@@ -640,21 +640,21 @@ function le(s) {
|
|
|
640
640
|
...s.details === void 0 ? {} : { details: s.details }
|
|
641
641
|
};
|
|
642
642
|
}
|
|
643
|
-
function
|
|
644
|
-
const i = s !== null && typeof s == "object" ? s : null, n = typeof s == "string" ? s : i && "message" in i && typeof i.message == "string" ? i.message : "", r = i && "code" in i && typeof i.code == "string" && i.code.trim() ? i.code : e,
|
|
643
|
+
function h(s, e = "runtime_error", t = "runtime") {
|
|
644
|
+
const i = s !== null && typeof s == "object" ? s : null, n = typeof s == "string" ? s : i && "message" in i && typeof i.message == "string" ? i.message : "", r = i && "code" in i && typeof i.code == "string" && i.code.trim() ? i.code : e, o = i && "details" in i ? i.details : null, a = o && typeof o == "object" ? o : {}, d = {
|
|
645
645
|
// Preserve the first boundary's shape after normalization replaces the original message/prototype.
|
|
646
|
-
errorNormalization: M(
|
|
646
|
+
errorNormalization: M(a.errorNormalization) ? a.errorNormalization : {
|
|
647
647
|
boundary: t,
|
|
648
648
|
category: s instanceof Error ? "error" : s === null ? "null" : Array.isArray(s) ? "array" : typeof s,
|
|
649
649
|
messageKind: n.trim() === "[object Object]" ? "object_coercion" : n.trim() ? "text" : typeof s == "string" || i && "message" in i && typeof i.message == "string" ? "blank" : "non_text"
|
|
650
650
|
},
|
|
651
|
-
...
|
|
652
|
-
...["unissued", "rejected"].includes(String(
|
|
653
|
-
...typeof
|
|
654
|
-
...typeof
|
|
655
|
-
...typeof
|
|
656
|
-
...typeof
|
|
657
|
-
...typeof
|
|
651
|
+
...a.allocation === "unissued" ? { allocation: "unissued" } : {},
|
|
652
|
+
...["unissued", "rejected"].includes(String(a.acceptance)) ? { acceptance: String(a.acceptance) } : {},
|
|
653
|
+
...typeof a.securitySettingsUrl == "string" ? { securitySettingsUrl: a.securitySettingsUrl } : {},
|
|
654
|
+
...typeof a.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(a.transportCode) ? { transportCode: a.transportCode } : {},
|
|
655
|
+
...typeof a.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(a.requestId) ? { requestId: a.requestId } : {},
|
|
656
|
+
...typeof a.durationMs == "number" && Number.isFinite(a.durationMs) && a.durationMs >= 0 ? { durationMs: a.durationMs } : {},
|
|
657
|
+
...typeof a.successfulRequests == "number" && Number.isSafeInteger(a.successfulRequests) && a.successfulRequests >= 0 ? { successfulRequests: a.successfulRequests } : {}
|
|
658
658
|
};
|
|
659
659
|
return le({
|
|
660
660
|
code: r,
|
|
@@ -723,6 +723,9 @@ const ue = [
|
|
|
723
723
|
"stopping_painted",
|
|
724
724
|
"progress_painted",
|
|
725
725
|
"stopped_painted",
|
|
726
|
+
"warmup_checkpoint",
|
|
727
|
+
"warmup_http",
|
|
728
|
+
"warmup_wait",
|
|
726
729
|
"acceptance_received",
|
|
727
730
|
"acceptance_applied"
|
|
728
731
|
], B = [
|
|
@@ -747,11 +750,11 @@ function pe(s) {
|
|
|
747
750
|
}
|
|
748
751
|
const he = Math.random().toString(36).slice(2);
|
|
749
752
|
let ge = 0;
|
|
750
|
-
const C = () => `timing:${he}:${++ge}`,
|
|
751
|
-
function
|
|
753
|
+
const C = () => `timing:${he}:${++ge}`, f = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
|
|
754
|
+
function P(s) {
|
|
752
755
|
if (!s || typeof s != "object") return !1;
|
|
753
756
|
const e = s;
|
|
754
|
-
return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory"].includes(t)) && (e.failureCategory === void 0 || e.status === "failed" && B.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) && ue.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) &&
|
|
757
|
+
return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory"].includes(t)) && (e.failureCategory === void 0 || e.status === "failed" && B.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) && ue.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && f(e.spanId) && f(e.requestId) && (e.clientMessageId === null || f(e.clientMessageId)) && (e.sessionId === null || f(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
|
|
755
758
|
}
|
|
756
759
|
function x(s, e) {
|
|
757
760
|
if (!s) return {
|
|
@@ -759,27 +762,27 @@ function x(s, e) {
|
|
|
759
762
|
},
|
|
760
763
|
measure: (n, r) => r()
|
|
761
764
|
};
|
|
762
|
-
const t = performance.now(), i = (n, r,
|
|
765
|
+
const t = performance.now(), i = (n, r, o, a, d) => {
|
|
763
766
|
const c = {
|
|
764
767
|
...e,
|
|
765
768
|
stage: n,
|
|
766
769
|
status: r,
|
|
767
|
-
spanId:
|
|
770
|
+
spanId: a,
|
|
768
771
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
769
|
-
durationMs: Math.max(0, Math.round(performance.now() -
|
|
772
|
+
durationMs: Math.max(0, Math.round(performance.now() - o)),
|
|
770
773
|
...r === "failed" ? { failureCategory: pe(d) } : {}
|
|
771
774
|
};
|
|
772
|
-
s &&
|
|
775
|
+
s && P(c) && Promise.resolve().then(() => s(c)).catch(() => {
|
|
773
776
|
});
|
|
774
777
|
};
|
|
775
778
|
return {
|
|
776
779
|
mark: (n) => i(n, "observed", t, C()),
|
|
777
780
|
measure(n, r) {
|
|
778
|
-
const
|
|
779
|
-
return i(n, "started",
|
|
780
|
-
(d) => (i(n, "completed",
|
|
781
|
+
const o = performance.now(), a = C();
|
|
782
|
+
return i(n, "started", o, a), r().then(
|
|
783
|
+
(d) => (i(n, "completed", o, a), d),
|
|
781
784
|
(d) => {
|
|
782
|
-
throw i(n, "failed",
|
|
785
|
+
throw i(n, "failed", o, a, d), d;
|
|
783
786
|
}
|
|
784
787
|
);
|
|
785
788
|
}
|
|
@@ -791,34 +794,34 @@ function fe(s) {
|
|
|
791
794
|
const e = s;
|
|
792
795
|
return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && S(e.sessionId) && S(e.responseItemId) && S(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
|
|
793
796
|
}
|
|
794
|
-
function
|
|
797
|
+
function me(s, e, t = "stopped", i, n = "Run stopped by user.") {
|
|
795
798
|
const r = new Set(i ?? [
|
|
796
799
|
s.assistantDraftRespondsToUserMessageId,
|
|
797
800
|
s.activeResponseUserMessageId,
|
|
798
801
|
s.messages.filter((d) => d.role === "user").slice(-1)[0]?.id
|
|
799
|
-
].filter((d) => !!d)),
|
|
802
|
+
].filter((d) => !!d)), o = s.messages.filter((d) => !(d.dataType === "run_status" && d.loading && r.has(d.respondsToUserMessageId ?? ""))).map((d) => r.has(d.respondsToUserMessageId ?? "") ? { ...d, loading: !1 } : d);
|
|
800
803
|
for (const d of r)
|
|
801
|
-
|
|
802
|
-
const
|
|
804
|
+
o.some((c) => c.respondsToUserMessageId === d && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary")) || o.some((c) => c.role === "user" && c.id === d) && o.push({ id: `local-interrupted:${d}`, role: "system", dataType: "run_status", provisional: t === "stopping", content: t === "stopping" ? "Stopping…" : n, createdAt: e, respondsToUserMessageId: d });
|
|
805
|
+
const a = s.segments?.map((d) => ({ ...d, outcomeIds: [
|
|
803
806
|
...d.outcomeIds,
|
|
804
|
-
...
|
|
807
|
+
...o.filter((c) => c.id === `local-interrupted:${d.userMessageId}` && !d.outcomeIds.includes(c.id)).map((c) => c.id)
|
|
805
808
|
] }));
|
|
806
809
|
return {
|
|
807
810
|
...s,
|
|
808
|
-
messages:
|
|
811
|
+
messages: o,
|
|
809
812
|
isThinking: !1,
|
|
810
813
|
isRetrying: !1,
|
|
811
814
|
pendingMessageStatus: null,
|
|
812
815
|
turnPhase: null,
|
|
813
|
-
segments:
|
|
816
|
+
segments: a,
|
|
814
817
|
activity: { phase: t, activeItemId: null },
|
|
815
|
-
isLoadingSession: s.isLoadingSession &&
|
|
818
|
+
isLoadingSession: s.isLoadingSession && o.length === 0,
|
|
816
819
|
taskStatus: t === "stopped" ? "stopped" : null,
|
|
817
820
|
lastError: null,
|
|
818
821
|
lastErrorCode: null
|
|
819
822
|
};
|
|
820
823
|
}
|
|
821
|
-
const
|
|
824
|
+
const ye = {
|
|
822
825
|
"stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
|
|
823
826
|
"in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
|
|
824
827
|
"stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
|
|
@@ -835,7 +838,7 @@ const me = {
|
|
|
835
838
|
"thinking-without-progress": "Thinking remained visible without progress for five minutes."
|
|
836
839
|
};
|
|
837
840
|
function ve(s) {
|
|
838
|
-
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(
|
|
841
|
+
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ye, s.slice(13));
|
|
839
842
|
}
|
|
840
843
|
function D(s) {
|
|
841
844
|
return {
|
|
@@ -864,7 +867,7 @@ function Re(s) {
|
|
|
864
867
|
case "runtime.warmup":
|
|
865
868
|
return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
|
|
866
869
|
case "runtime.report_operation_timing":
|
|
867
|
-
return
|
|
870
|
+
return P(e.timing);
|
|
868
871
|
case "runtime.report_displayed_error":
|
|
869
872
|
return (e.errorDiagnostic === void 0 || de(e.errorDiagnostic)) && (e.httpRequest === void 0 || F(e.httpRequest)) && (e.historyRefreshFailure === void 0 || K(e.historyRefreshFailure)) && (e.renderedError === void 0 || $(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);
|
|
870
873
|
case "runtime.report_invalid_state_transition":
|
|
@@ -898,7 +901,7 @@ function Re(s) {
|
|
|
898
901
|
}
|
|
899
902
|
class ke {
|
|
900
903
|
constructor(e, t, i) {
|
|
901
|
-
this.adapter = t, this.state =
|
|
904
|
+
this.adapter = t, this.state = w(e), this.model = i;
|
|
902
905
|
}
|
|
903
906
|
adapter;
|
|
904
907
|
listeners = {};
|
|
@@ -907,7 +910,7 @@ class ke {
|
|
|
907
910
|
interactionListeners = /* @__PURE__ */ new Set();
|
|
908
911
|
accountListeners = /* @__PURE__ */ new Set();
|
|
909
912
|
state;
|
|
910
|
-
sessionHistoryState =
|
|
913
|
+
sessionHistoryState = m("unavailable");
|
|
911
914
|
model;
|
|
912
915
|
interactions = [];
|
|
913
916
|
account = null;
|
|
@@ -926,44 +929,44 @@ class ke {
|
|
|
926
929
|
return i.add(t), this.listeners[e] = i, () => i.delete(t);
|
|
927
930
|
}
|
|
928
931
|
getState() {
|
|
929
|
-
const e =
|
|
932
|
+
const e = w(this.state);
|
|
930
933
|
for (const [n, r] of this.submissionPreviews)
|
|
931
|
-
e.messages.some((
|
|
934
|
+
e.messages.some((o) => o.id === n) || (e.messages.push({ ...r.message, attachments: r.message.attachments?.map((o) => ({ ...o })) }), e.segments && (e.segments = [...e.segments, { id: n, userMessageId: n, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, r.pending && (e.activeResponseUserMessageId = n, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), r.error && (e.lastError = r.error, e.lastErrorCode = "message_delivery_failed"));
|
|
932
935
|
this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
|
|
933
936
|
const t = [...this.stopPreviews.keys()];
|
|
934
937
|
if (!t.length) return e;
|
|
935
|
-
const i =
|
|
938
|
+
const i = me(e, "", "stopping", t);
|
|
936
939
|
return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
|
|
937
940
|
}
|
|
938
941
|
updateProjection(e, t, i, n, r) {
|
|
939
942
|
if (this.destroyed) return;
|
|
940
|
-
const
|
|
941
|
-
(
|
|
942
|
-
for (const
|
|
943
|
-
|
|
944
|
-
this.state =
|
|
945
|
-
for (const [
|
|
943
|
+
const o = this.getState();
|
|
944
|
+
(o.user?.id !== e.user?.id || o.selectionKey !== void 0 && o.selectionKey !== e.selectionKey || o.selectionKey === void 0 && o.sessionId !== null && o.sessionId !== e.sessionId) && (this.cancelPendingSubmissions(), this.submissionPreviews.clear());
|
|
945
|
+
for (const a of e.messages)
|
|
946
|
+
a.role === "user" && this.submissionPreviews.delete(a.id);
|
|
947
|
+
this.state = w(e);
|
|
948
|
+
for (const [a, d] of this.stopPreviews) {
|
|
946
949
|
const c = e.activity?.executionKey;
|
|
947
|
-
(d !== void 0 && d !== "[]" && c !== void 0 && c !== "[]" && (c !== d || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (d === void 0 || d === "[]") && e.messages.some((
|
|
950
|
+
(d !== void 0 && d !== "[]" && c !== void 0 && c !== "[]" && (c !== d || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (d === void 0 || d === "[]") && e.messages.some((u) => u.respondsToUserMessageId === a && !u.provisional && u.loading !== !0 && (u.dataType === "run_status" || u.dataType === "run_error" || u.role === "assistant" && u.phase !== "commentary" && (u.streamState === void 0 || ["finished", "stopped", "failed"].includes(u.streamState))))) && this.stopPreviews.delete(a);
|
|
948
951
|
}
|
|
949
|
-
if (this.pendingStop?.userMessageIds.every((
|
|
950
|
-
for (const
|
|
951
|
-
if (
|
|
952
|
-
const d =
|
|
953
|
-
|
|
952
|
+
if (this.pendingStop?.userMessageIds.every((a) => !this.stopPreviews.has(a)) && (this.pendingStop = null), o.user?.id === e.user?.id)
|
|
953
|
+
for (const a of this.state.messages) {
|
|
954
|
+
if (a.role !== "user" || !a.attachments?.length) continue;
|
|
955
|
+
const d = o.messages.find((c) => c.role === "user" && c.id === a.id);
|
|
956
|
+
o.sessionId !== e.sessionId && !(o.sessionId === null && d) || (a.attachments = be(d?.attachments, a.attachments));
|
|
954
957
|
}
|
|
955
958
|
if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
|
|
956
959
|
this.sessionHistoryState = j(i);
|
|
957
|
-
for (const
|
|
958
|
-
|
|
960
|
+
for (const a of this.sessionHistoryListeners)
|
|
961
|
+
a(this.getSessionHistoryState());
|
|
959
962
|
}
|
|
960
963
|
if (n && JSON.stringify(n) !== JSON.stringify(this.interactions)) {
|
|
961
|
-
this.interactions = n.map((
|
|
962
|
-
for (const
|
|
964
|
+
this.interactions = n.map((a) => ({ ...a }));
|
|
965
|
+
for (const a of this.interactionListeners) a(this.getInteractions());
|
|
963
966
|
}
|
|
964
967
|
if (r !== void 0 && JSON.stringify(r) !== JSON.stringify(this.account)) {
|
|
965
968
|
this.account = r ? { ...r } : null;
|
|
966
|
-
for (const
|
|
969
|
+
for (const a of this.accountListeners) a(this.getAccount());
|
|
967
970
|
}
|
|
968
971
|
this.emit("state", this.getState());
|
|
969
972
|
}
|
|
@@ -985,7 +988,7 @@ class ke {
|
|
|
985
988
|
this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
|
|
986
989
|
}
|
|
987
990
|
reportOperationTiming(e) {
|
|
988
|
-
!this.destroyed &&
|
|
991
|
+
!this.destroyed && P(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
|
|
989
992
|
});
|
|
990
993
|
}
|
|
991
994
|
reportResponseVisibility(e) {
|
|
@@ -1002,27 +1005,29 @@ class ke {
|
|
|
1002
1005
|
});
|
|
1003
1006
|
}
|
|
1004
1007
|
reportDisplayedError(e, t, i, n, r) {
|
|
1005
|
-
const
|
|
1008
|
+
const o = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
|
|
1006
1009
|
if (n !== void 0 && !$(n) || r !== void 0 && !K(r)) return;
|
|
1007
|
-
const
|
|
1010
|
+
const a = ce(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds);
|
|
1008
1011
|
this.adapter.dispatch({
|
|
1009
1012
|
type: "runtime.report_displayed_error",
|
|
1010
|
-
errorDiagnostic:
|
|
1011
|
-
...
|
|
1013
|
+
errorDiagnostic: a,
|
|
1014
|
+
...a.clientMessageId ? { clientMessageId: a.clientMessageId } : {},
|
|
1012
1015
|
reason: e,
|
|
1013
1016
|
errorFingerprint: t,
|
|
1014
1017
|
...n ? { renderedError: n } : {},
|
|
1015
1018
|
...r ? { historyRefreshFailure: r } : {},
|
|
1016
|
-
...F(
|
|
1019
|
+
...F(o) ? { httpRequest: o } : {},
|
|
1017
1020
|
...i ? { displayedMessage: L(i) } : {}
|
|
1018
1021
|
}).catch(() => {
|
|
1019
1022
|
});
|
|
1020
1023
|
}
|
|
1021
1024
|
sendMessage(e, t = {}) {
|
|
1022
|
-
const i = e.trim()
|
|
1025
|
+
const i = e.trim();
|
|
1026
|
+
t = { ...t, attachments: t.attachments?.map((c) => ({ ...c })) };
|
|
1027
|
+
const n = t.attachments ?? [];
|
|
1023
1028
|
if (!i && n.length === 0) return Promise.resolve(null);
|
|
1024
1029
|
this.pendingStop = null, this.stopError = null;
|
|
1025
|
-
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()),
|
|
1030
|
+
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), o = t.submittedAt ?? Date.now(), a = this.submissionGeneration;
|
|
1026
1031
|
this.pendingTransfers.set(r, n.flatMap((c) => c.id ? [c.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
|
|
1027
1032
|
id: r,
|
|
1028
1033
|
role: "user",
|
|
@@ -1030,13 +1035,13 @@ class ke {
|
|
|
1030
1035
|
createdAt: "",
|
|
1031
1036
|
attachments: n.map((c) => ({ ...c }))
|
|
1032
1037
|
} });
|
|
1033
|
-
const d = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt:
|
|
1038
|
+
const d = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt: o }, a);
|
|
1034
1039
|
return this.emit("state", this.getState()), d.finally(() => {
|
|
1035
1040
|
this.pendingTransfers.delete(r);
|
|
1036
1041
|
});
|
|
1037
1042
|
}
|
|
1038
1043
|
async sendMessageNow(e, t, i) {
|
|
1039
|
-
const n = e, r = t.clientMessageId,
|
|
1044
|
+
const n = e, r = t.clientMessageId, o = x((c) => {
|
|
1040
1045
|
i === this.submissionGeneration && this.reportOperationTiming(c);
|
|
1041
1046
|
}, {
|
|
1042
1047
|
operation: "send",
|
|
@@ -1045,12 +1050,12 @@ class ke {
|
|
|
1045
1050
|
clientMessageId: r,
|
|
1046
1051
|
sessionId: this.state.sessionId
|
|
1047
1052
|
});
|
|
1048
|
-
|
|
1049
|
-
let
|
|
1053
|
+
o.mark("submit");
|
|
1054
|
+
let a = t.attachments ?? [], d = !1;
|
|
1050
1055
|
if (i !== this.submissionGeneration) return null;
|
|
1051
1056
|
try {
|
|
1052
|
-
if (!await
|
|
1053
|
-
const
|
|
1057
|
+
if (!await o.measure("staging_ipc", async () => {
|
|
1058
|
+
const l = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
|
|
1054
1059
|
type: "conversation.stage",
|
|
1055
1060
|
initiatedBy: t.initiatedBy,
|
|
1056
1061
|
invocation: t.invocation,
|
|
@@ -1059,25 +1064,25 @@ class ke {
|
|
|
1059
1064
|
clientMessageId: r,
|
|
1060
1065
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1061
1066
|
// Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
|
|
1062
|
-
attachments:
|
|
1067
|
+
attachments: a.length > 0 ? a.map(D) : void 0,
|
|
1063
1068
|
submittedAt: t.submittedAt
|
|
1064
1069
|
}) });
|
|
1065
|
-
return
|
|
1070
|
+
return l ? (await l.result, l) : null;
|
|
1066
1071
|
}) || i !== this.submissionGeneration) return null;
|
|
1067
|
-
if (d = !0,
|
|
1072
|
+
if (d = !0, a.length > 0) {
|
|
1068
1073
|
if (!this.adapter.uploadAttachment)
|
|
1069
1074
|
throw new Error("The runtime does not support attachments.");
|
|
1070
|
-
const
|
|
1071
|
-
for (const
|
|
1072
|
-
if (
|
|
1073
|
-
|
|
1075
|
+
const l = [];
|
|
1076
|
+
for (const u of a) {
|
|
1077
|
+
if (u.sandboxPath || u.storageKey) {
|
|
1078
|
+
l.push(u);
|
|
1074
1079
|
continue;
|
|
1075
1080
|
}
|
|
1076
|
-
const
|
|
1077
|
-
if (!
|
|
1078
|
-
if (
|
|
1081
|
+
const T = u.id ? this.attachmentFiles.get(u.id) : void 0;
|
|
1082
|
+
if (!T) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
|
|
1083
|
+
if (l.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(T, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
|
|
1079
1084
|
}
|
|
1080
|
-
|
|
1085
|
+
a = l;
|
|
1081
1086
|
}
|
|
1082
1087
|
if (i !== this.submissionGeneration || (await this.adapter.dispatch({
|
|
1083
1088
|
type: "conversation.send",
|
|
@@ -1087,21 +1092,21 @@ class ke {
|
|
|
1087
1092
|
invocation: t.invocation,
|
|
1088
1093
|
automationOnboarding: t.automationOnboarding,
|
|
1089
1094
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1090
|
-
attachments:
|
|
1095
|
+
attachments: a.length > 0 ? a.map(D) : void 0
|
|
1091
1096
|
}), i !== this.submissionGeneration)) return null;
|
|
1092
|
-
for (const
|
|
1093
|
-
|
|
1097
|
+
for (const l of t.attachments ?? [])
|
|
1098
|
+
l.id && this.attachmentFiles.delete(l.id);
|
|
1094
1099
|
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
|
|
1095
1100
|
} catch (c) {
|
|
1096
1101
|
if (i !== this.submissionGeneration) return null;
|
|
1097
1102
|
if (Z(c))
|
|
1098
|
-
for (const
|
|
1099
|
-
|
|
1100
|
-
const
|
|
1101
|
-
throw
|
|
1103
|
+
for (const u of t.attachments ?? [])
|
|
1104
|
+
u.id && this.attachmentFiles.delete(u.id);
|
|
1105
|
+
const l = this.submissionPreviews.get(r);
|
|
1106
|
+
throw l && (l.pending = !1, l.error = h(c).message, l.retry = !d && h(c).code === "command_not_received" ? () => this.sendMessageNow(e, t, i) : void 0, this.emit("state", this.getState())), d && await this.adapter.dispatch({
|
|
1102
1107
|
type: "conversation.fail_staged",
|
|
1103
1108
|
clientMessageId: r,
|
|
1104
|
-
message:
|
|
1109
|
+
message: h(c).message
|
|
1105
1110
|
}), c;
|
|
1106
1111
|
}
|
|
1107
1112
|
}
|
|
@@ -1113,7 +1118,19 @@ class ke {
|
|
|
1113
1118
|
});
|
|
1114
1119
|
}
|
|
1115
1120
|
async retryLastMessage(e) {
|
|
1116
|
-
|
|
1121
|
+
const t = e ?? [...this.submissionPreviews].reverse().find(([, o]) => o.error)?.[0] ?? this.state.messages.filter((o) => o.role === "user").slice(-1)[0]?.id;
|
|
1122
|
+
if (!t || this.destroyed) return !1;
|
|
1123
|
+
const i = this.submissionPreviews.get(t);
|
|
1124
|
+
if (i?.pending) return !1;
|
|
1125
|
+
const n = i?.retry, r = this.submissionGeneration;
|
|
1126
|
+
try {
|
|
1127
|
+
return i && n ? (i.pending = !0, i.error = void 0, i.retry = void 0, this.pendingTransfers.set(t, (i.message.attachments ?? []).flatMap((o) => o.id ? [o.id] : [])), this.emit("state", this.getState()), await n()) : await this.dispatch({ type: "run.retry", clientMessageId: t }), !0;
|
|
1128
|
+
} catch (o) {
|
|
1129
|
+
if (!i) throw o;
|
|
1130
|
+
return r === this.submissionGeneration && this.submissionPreviews.get(t) === i && (i.error = h(o).message, this.emit("state", this.getState())), !1;
|
|
1131
|
+
} finally {
|
|
1132
|
+
n && this.pendingTransfers.delete(t), i && r === this.submissionGeneration && this.submissionPreviews.get(t) === i && (i.pending = !1, this.emit("state", this.getState()));
|
|
1133
|
+
}
|
|
1117
1134
|
}
|
|
1118
1135
|
createLocalAttachment(e) {
|
|
1119
1136
|
const t = crypto.randomUUID();
|
|
@@ -1140,18 +1157,18 @@ class ke {
|
|
|
1140
1157
|
n.mark("stop");
|
|
1141
1158
|
const r = { userMessageIds: i, promise: Promise.resolve() };
|
|
1142
1159
|
this.pendingStop = r;
|
|
1143
|
-
const
|
|
1160
|
+
const o = !e.pendingMessageStatus && ["thinking", "steering", "queued", "stopping"].includes(this.state.activity?.phase ?? "") ? this.state.activity?.executionKey : void 0;
|
|
1144
1161
|
for (const c of i)
|
|
1145
|
-
this.stopPreviews.set(c, t.includes(c) ? void 0 :
|
|
1146
|
-
const
|
|
1162
|
+
this.stopPreviews.set(c, t.includes(c) ? void 0 : o);
|
|
1163
|
+
const a = this.submissionGeneration;
|
|
1147
1164
|
r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
|
|
1148
1165
|
}, (c) => {
|
|
1149
|
-
if (!(
|
|
1150
|
-
for (const
|
|
1151
|
-
this.stopError =
|
|
1166
|
+
if (!(a !== this.submissionGeneration || i.every((l) => !this.stopPreviews.has(l)))) {
|
|
1167
|
+
for (const l of i) this.stopPreviews.delete(l);
|
|
1168
|
+
this.stopError = h(c).message;
|
|
1152
1169
|
}
|
|
1153
1170
|
}).finally(() => {
|
|
1154
|
-
this.destroyed ||
|
|
1171
|
+
this.destroyed || a !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
|
|
1155
1172
|
}), this.emit("state", this.getState());
|
|
1156
1173
|
const d = r.promise;
|
|
1157
1174
|
return this.operationQueue = d.then(() => {
|
|
@@ -1166,7 +1183,11 @@ class ke {
|
|
|
1166
1183
|
for (const i of this.pendingTransfers.values())
|
|
1167
1184
|
for (const n of i) this.attachmentFiles.delete(n);
|
|
1168
1185
|
this.pendingTransfers.clear();
|
|
1169
|
-
for (const i of this.submissionPreviews.values())
|
|
1186
|
+
for (const i of this.submissionPreviews.values()) {
|
|
1187
|
+
i.pending = !1, i.retry = void 0;
|
|
1188
|
+
for (const n of i.message.attachments ?? [])
|
|
1189
|
+
n.id && this.attachmentFiles.delete(n.id);
|
|
1190
|
+
}
|
|
1170
1191
|
return this.operationQueue = Promise.resolve(), t;
|
|
1171
1192
|
}
|
|
1172
1193
|
startNewSession(e = {}) {
|
|
@@ -1275,7 +1296,7 @@ function be(s, e) {
|
|
|
1275
1296
|
return n ? { ...i, previewUrl: n } : i;
|
|
1276
1297
|
});
|
|
1277
1298
|
}
|
|
1278
|
-
function
|
|
1299
|
+
function w(s) {
|
|
1279
1300
|
return {
|
|
1280
1301
|
...s,
|
|
1281
1302
|
starterPrompts: [...s.starterPrompts],
|
|
@@ -1283,7 +1304,7 @@ function A(s) {
|
|
|
1283
1304
|
messages: s.messages.map((e) => {
|
|
1284
1305
|
const t = {
|
|
1285
1306
|
...e,
|
|
1286
|
-
attachments: e.attachments?.map((
|
|
1307
|
+
attachments: e.attachments?.map((o) => ({ ...o }))
|
|
1287
1308
|
}, i = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
|
|
1288
1309
|
return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
|
|
1289
1310
|
value: r,
|
|
@@ -1303,32 +1324,32 @@ function j(s) {
|
|
|
1303
1324
|
return {
|
|
1304
1325
|
...s,
|
|
1305
1326
|
data: s.data ? y({
|
|
1306
|
-
entities:
|
|
1327
|
+
entities: Q(s.data).map((e) => ({ ...e })),
|
|
1307
1328
|
nextCursor: s.data.nextCursor
|
|
1308
1329
|
}) : null
|
|
1309
1330
|
};
|
|
1310
1331
|
}
|
|
1311
1332
|
export {
|
|
1312
1333
|
H as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
|
|
1313
|
-
|
|
1334
|
+
Pe as ProductAgentInteractionManager,
|
|
1314
1335
|
O as ProductAgentQueryController,
|
|
1315
1336
|
ke as ProductAgentRemoteRuntimeClient,
|
|
1316
1337
|
Me as ProductAgentSessionHistoryManager,
|
|
1317
1338
|
Oe as ProductAgentTaskPageTitleController,
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1339
|
+
Ae as canSubmitPersonalProductAgentMessage,
|
|
1340
|
+
Te as createLocalStorageInteractionDecisionStorage,
|
|
1341
|
+
m as createProductAgentQueryState,
|
|
1321
1342
|
qe as createProductAgentTaskPageTitleDocument,
|
|
1322
1343
|
te as formatProductAgentTaskPageTitle,
|
|
1323
1344
|
Se as hasProductAgentPaidCreditFallback,
|
|
1324
1345
|
Z as isProductAgentAuthReconnectError,
|
|
1325
1346
|
Re as isProductAgentRuntimeCommand,
|
|
1326
|
-
|
|
1347
|
+
G as mergeProductAgentEntityPages,
|
|
1327
1348
|
y as normalizeProductAgentEntityPage,
|
|
1328
1349
|
Y as readLocalStorageInteractionDecisions,
|
|
1329
|
-
|
|
1330
|
-
|
|
1350
|
+
Ie as reconcileProductAgentSubmissionGate,
|
|
1351
|
+
we as resolveProductAgentBillingPresentation,
|
|
1331
1352
|
Ee as resolveProductAgentComposerAction,
|
|
1332
|
-
|
|
1333
|
-
|
|
1353
|
+
_e as resolveProductAgentWidgetPresentation,
|
|
1354
|
+
Q as selectProductAgentQueryEntities
|
|
1334
1355
|
};
|