@pluno/product-agent-web 0.1.248 → 0.1.249
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/adapters/web/errorAdapter.d.ts +3 -1
- package/dist/core/protocol/errorNormalization.d.ts +6 -0
- package/dist/core/protocol/normalizeError.d.ts +2 -1
- package/dist/displayedErrors.d.ts +1 -0
- package/dist/errorDiagnostic.d.ts +16 -0
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +222 -186
- package/dist/product-agent-sdk.js +1348 -1308
- package/dist/product-agent-widget.js +2719 -2692
- package/dist/runtime/transitionDiagnostics.d.ts +3 -0
- package/dist/runtimeClient.d.ts +3 -0
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ function f(s) {
|
|
|
8
8
|
updatedAt: null
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
class
|
|
11
|
+
class q {
|
|
12
12
|
constructor(e, t, i = (n, r) => r) {
|
|
13
13
|
this.loader = t, this.merge = i, this.state = f(e);
|
|
14
14
|
}
|
|
@@ -93,34 +93,34 @@ function y(s) {
|
|
|
93
93
|
nextCursor: s.nextCursor
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function B(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 ve(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 be(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
|
-
function
|
|
112
|
+
function Ie(s) {
|
|
113
113
|
if (!s || typeof s != "object") return !1;
|
|
114
114
|
const e = s.paidCreditFallbackModel;
|
|
115
115
|
return typeof e == "string" && e.length > 0;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function _e(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 Se(s) {
|
|
121
121
|
return s.submissionAllowed && s.isAuthenticated && s.hasWorkspace && !s.isWebsiteBlocked && s.isCurrentPageResolved && !s.isSubmitting && !s.hasPendingMessage;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function Ae(s) {
|
|
124
124
|
const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
|
|
125
125
|
return s.hasRunningAssistantTurn && !e ? {
|
|
126
126
|
action: "stop",
|
|
@@ -130,13 +130,13 @@ function me(s) {
|
|
|
130
130
|
disabled: !e || !s.canSubmitMessage
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
-
const
|
|
134
|
-
function
|
|
135
|
-
return (s instanceof Error ? s.message : s) ===
|
|
133
|
+
const G = "Pluno is reconnecting. Try again in a moment.";
|
|
134
|
+
function H(s) {
|
|
135
|
+
return (s instanceof Error ? s.message : s) === G;
|
|
136
136
|
}
|
|
137
|
-
class
|
|
137
|
+
class we {
|
|
138
138
|
constructor(e, t, i = 20) {
|
|
139
|
-
this.loadPage = t, this.limit = i, this.recentQuery = new
|
|
139
|
+
this.loadPage = t, this.limit = i, this.recentQuery = new q(
|
|
140
140
|
`${e}:recent`,
|
|
141
141
|
async ({ cursor: n }) => y(
|
|
142
142
|
await this.loadPage({ cursor: n, limit: this.limit, pinned: !1 }).then((r) => ({
|
|
@@ -144,8 +144,8 @@ class ve {
|
|
|
144
144
|
nextCursor: r.nextCursor
|
|
145
145
|
}))
|
|
146
146
|
),
|
|
147
|
-
|
|
148
|
-
), this.pinnedQuery = new
|
|
147
|
+
B
|
|
148
|
+
), this.pinnedQuery = new q(
|
|
149
149
|
`${e}:pinned`,
|
|
150
150
|
async () => y({
|
|
151
151
|
entities: await this.loadAllPinned(),
|
|
@@ -171,14 +171,14 @@ class ve {
|
|
|
171
171
|
...h(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
|
+
), a = Array.from(this.optimisticEntities.values()).filter((d) => !n.has(d.id)).reverse(), o = e.data || t.data || a.length > 0 ? y({
|
|
175
|
+
entities: [...a, ...r],
|
|
176
176
|
nextCursor: e.data?.nextCursor ?? null
|
|
177
177
|
}) : null;
|
|
178
178
|
return {
|
|
179
179
|
key: e.key.slice(0, -7),
|
|
180
|
-
status:
|
|
181
|
-
data:
|
|
180
|
+
status: Z(e, t),
|
|
181
|
+
data: o,
|
|
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
|
|
@@ -286,7 +286,7 @@ class ve {
|
|
|
286
286
|
function h(s) {
|
|
287
287
|
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function Z(s, e) {
|
|
290
290
|
return s.status === "error" || e.status === "error" ? "error" : s.status === "loading" || e.status === "loading" ? "loading" : s.status === "refreshing" || e.status === "refreshing" ? "refreshing" : s.status === "loading_more" ? "loading_more" : s.status === "ready" || e.status === "ready" ? "ready" : "not_requested";
|
|
291
291
|
}
|
|
292
292
|
function O(s) {
|
|
@@ -302,25 +302,25 @@ function v(s) {
|
|
|
302
302
|
const e = Object.getPrototypeOf(s);
|
|
303
303
|
return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(v);
|
|
304
304
|
}
|
|
305
|
-
function
|
|
306
|
-
return s !== null && typeof s == "object" && !Object.isFrozen(s) && (Object.values(s).forEach(
|
|
305
|
+
function N(s) {
|
|
306
|
+
return s !== null && typeof s == "object" && !Object.isFrozen(s) && (Object.values(s).forEach(N), Object.freeze(s)), s;
|
|
307
307
|
}
|
|
308
|
-
function
|
|
308
|
+
function V(s) {
|
|
309
309
|
if (!v(s)) throw new Error("Conversation inputs must be JSON-safe values.");
|
|
310
310
|
return JSON.parse(JSON.stringify(s));
|
|
311
311
|
}
|
|
312
|
-
function
|
|
312
|
+
function J(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, a) => O(r.created_at).localeCompare(O(a.created_at)) || r.id.localeCompare(a.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 Ee {
|
|
324
324
|
constructor(e, t = null) {
|
|
325
325
|
this.storage = e, t && (this.decisions = new Map(
|
|
326
326
|
t.filter(w).map((i) => [this.getDecisionKey(i), i])
|
|
@@ -344,8 +344,8 @@ class be {
|
|
|
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,
|
|
347
|
+
const r = n?.payload.kind === "personal_channel" && n.lifecycle === "completed" ? "completed" : t.lifecycle, a = n?.payload.kind === "sharing" && t.payload.kind === "sharing" ? { ...t.payload, variant: n.payload.variant } : t.payload;
|
|
348
|
+
this.sources.set(i, N(V({ ...t, lifecycle: r, payload: a }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
/** @internal */
|
|
@@ -357,38 +357,38 @@ class be {
|
|
|
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, a) => r.version - a.version || r.id.localeCompare(a.id));
|
|
361
361
|
for (const r of n) {
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
if (t.share = null, !
|
|
365
|
-
const
|
|
362
|
+
const a = r.payload;
|
|
363
|
+
if (a.kind === "sharing") {
|
|
364
|
+
if (t.share = null, !a.eligible || r.lifecycle !== "pending" || r.invocation !== "user" || !["main_web_chat", "automation", "extension_sidepanel", "extension_widget"].includes(r.entry_surface ?? "")) continue;
|
|
365
|
+
const o = r.user_message_id ? i.items[r.user_message_id] : null;
|
|
366
366
|
t.share = {
|
|
367
367
|
revision: r.version,
|
|
368
368
|
candidate: {
|
|
369
369
|
id: r.id,
|
|
370
|
-
variant:
|
|
371
|
-
userPrompt:
|
|
370
|
+
variant: a.variant,
|
|
371
|
+
userPrompt: o?.type === "user_message" ? o.data.content : "",
|
|
372
372
|
assistantAnswer: ""
|
|
373
373
|
},
|
|
374
|
-
terminal: !
|
|
374
|
+
terminal: !a.wait_for_terminal || J(i, r.user_message_id)
|
|
375
375
|
};
|
|
376
|
-
} else
|
|
376
|
+
} else a.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: a.request_id,
|
|
381
|
+
appSlug: a.app_slug,
|
|
382
|
+
appName: a.app_name,
|
|
383
|
+
appLogo: a.app_logo ?? void 0,
|
|
384
|
+
expiresAt: a.expires_at
|
|
385
385
|
},
|
|
386
|
-
lifecycle: r.lifecycle === "pending" && Date.parse(
|
|
386
|
+
lifecycle: r.lifecycle === "pending" && Date.parse(a.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: a.request_id,
|
|
390
|
+
channel: a.channel,
|
|
391
|
+
managementUrl: a.management_url
|
|
392
392
|
}, lifecycle: r.lifecycle };
|
|
393
393
|
}
|
|
394
394
|
return t;
|
|
@@ -437,7 +437,7 @@ class be {
|
|
|
437
437
|
async applyAction(e, t, i) {
|
|
438
438
|
if (!e.allowedActions.includes(t))
|
|
439
439
|
throw new Error(`Interaction ${e.key} does not allow ${t}.`);
|
|
440
|
-
if (!
|
|
440
|
+
if (!z(t))
|
|
441
441
|
throw new Error(`Interaction action ${t} is not a persistence decision.`);
|
|
442
442
|
const n = i.now ?? /* @__PURE__ */ new Date(), r = {
|
|
443
443
|
promptKey: e.key,
|
|
@@ -446,8 +446,8 @@ class be {
|
|
|
446
446
|
scope: e.scope,
|
|
447
447
|
decidedAt: n.toISOString(),
|
|
448
448
|
nextEligibleAt: this.getNextEligibleAt(e, t, n, i.snoozeUntil)
|
|
449
|
-
},
|
|
450
|
-
return
|
|
449
|
+
}, a = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), o = new Map(this.decisions);
|
|
450
|
+
return o.set(a, r), await this.storage.save([...o.values()]), this.decisions = o, r;
|
|
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,13 +473,13 @@ class be {
|
|
|
473
473
|
return `${I(e.scope)}:category:${e.category}`;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function Pe(s, e) {
|
|
477
477
|
return {
|
|
478
|
-
load: async () =>
|
|
478
|
+
load: async () => W(s, e),
|
|
479
479
|
save: async (t) => s.setItem(e, JSON.stringify(t))
|
|
480
480
|
};
|
|
481
481
|
}
|
|
482
|
-
function
|
|
482
|
+
function W(s, e) {
|
|
483
483
|
const t = s.getItem(e);
|
|
484
484
|
if (!t) return [];
|
|
485
485
|
const i = JSON.parse(t);
|
|
@@ -488,26 +488,26 @@ function V(s, e) {
|
|
|
488
488
|
function I(s) {
|
|
489
489
|
return `${s.level}:${s.key}`;
|
|
490
490
|
}
|
|
491
|
-
function
|
|
491
|
+
function z(s) {
|
|
492
492
|
return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
|
|
493
493
|
}
|
|
494
494
|
function w(s) {
|
|
495
495
|
if (!s || typeof s != "object") return !1;
|
|
496
496
|
const e = s;
|
|
497
|
-
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") &&
|
|
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");
|
|
498
498
|
}
|
|
499
|
-
const
|
|
499
|
+
const Y = {
|
|
500
500
|
working: "⏳",
|
|
501
501
|
completed: "✅",
|
|
502
502
|
failed: "❗",
|
|
503
503
|
stopped: "⏹️"
|
|
504
|
-
},
|
|
505
|
-
function
|
|
504
|
+
}, X = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
505
|
+
function ee(s, e) {
|
|
506
506
|
if (!e) return b(s);
|
|
507
|
-
const t = b(s), i = `${
|
|
507
|
+
const t = b(s), i = `${Y[e]} Pluno`;
|
|
508
508
|
return t ? `${i}: ${t}` : i;
|
|
509
509
|
}
|
|
510
|
-
class
|
|
510
|
+
class Te {
|
|
511
511
|
constructor(e) {
|
|
512
512
|
this.titleDocument = e;
|
|
513
513
|
}
|
|
@@ -541,11 +541,11 @@ class _e {
|
|
|
541
541
|
applyTitle() {
|
|
542
542
|
if (!this.status)
|
|
543
543
|
return;
|
|
544
|
-
const e =
|
|
544
|
+
const e = ee(this.baseTitle, this.status);
|
|
545
545
|
this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function Me(s) {
|
|
549
549
|
return {
|
|
550
550
|
getTitle: () => s.title,
|
|
551
551
|
setTitle: (e) => {
|
|
@@ -562,40 +562,74 @@ function Se(s) {
|
|
|
562
562
|
};
|
|
563
563
|
}
|
|
564
564
|
function b(s) {
|
|
565
|
-
return s.replace(
|
|
565
|
+
return s.replace(X, "");
|
|
566
566
|
}
|
|
567
567
|
const p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
|
|
568
|
-
function
|
|
568
|
+
function te(s) {
|
|
569
569
|
if (!s || typeof s != "object") return !1;
|
|
570
570
|
const e = s, t = (n) => Number.isSafeInteger(n) && n >= 0, i = (n) => n && typeof n == "object" && Object.keys(n).every((r) => ["sequence", "at", "type", "changed", "generation", "sessionId", "scopeId", "requestId", "effectId", "clientScopeId", "reason", "effectKind", "eventType", "itemCount", "removedCount", "projectionReady"].includes(r)) && t(n.sequence) && t(n.at) && p(n.type) !== null && typeof n.changed == "boolean" && [n.generation, n.itemCount, n.removedCount].every((r) => r === null || t(r)) && [n.sessionId, n.scopeId, n.requestId, n.effectId, n.clientScopeId, n.reason, n.effectKind, n.eventType].every((r) => r === null || p(r) !== null) && (n.projectionReady === null || typeof n.projectionReady == "boolean");
|
|
571
571
|
return Object.keys(e).every((n) => ["ownerId", "revision", "dropped", "lastIntent", "lastSelection", "transitions"].includes(n)) && p(e.ownerId) !== null && t(e.revision) && t(e.dropped) && (e.lastIntent == null || i(e.lastIntent)) && (e.lastSelection === null || i(e.lastSelection)) && Array.isArray(e.transitions) && e.transitions.length <= 16 && e.transitions.every(i);
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function K(s) {
|
|
574
574
|
if (!s || typeof s != "object") return !1;
|
|
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
|
|
579
|
-
function
|
|
578
|
+
const R = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], E = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), m = (s) => s === null || E(s), se = (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
|
+
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)) && m(e.sessionId) &&
|
|
582
|
+
return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && m(e.sessionId) && E(e.itemId) && m(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && m(e.runId) && (e.createdAt === null || se(e.createdAt));
|
|
583
583
|
}
|
|
584
|
-
function
|
|
584
|
+
function ie(s) {
|
|
585
585
|
if (!s || typeof s != "object") return !1;
|
|
586
586
|
const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
|
|
587
|
-
return Object.keys(e).every((i) => ["capturedAt", "selectionKey", "userId", "loading", "draft", "thinking", "connected", "hasError", "phase", "queryStatus", "queryRequestId", "queryUpdatedAt", "renderSource", "selectionFencePending", "guardCreatedAt", "owner"].includes(i)) && t(e.capturedAt) && [e.queryUpdatedAt, e.guardCreatedAt].every((i) => i === null || t(i)) && [e.selectionKey, e.userId, e.phase, e.queryStatus, e.queryRequestId].every((i) => i === null || p(i) !== null) && [e.loading, e.draft, e.thinking, e.connected, e.hasError, e.selectionFencePending].every((i) => typeof i == "boolean") && ["state", "account", "interactions", "local", "sidepanel_layout"].includes(e.renderSource) && (e.owner === void 0 ||
|
|
587
|
+
return Object.keys(e).every((i) => ["capturedAt", "selectionKey", "userId", "loading", "draft", "thinking", "connected", "hasError", "phase", "queryStatus", "queryRequestId", "queryUpdatedAt", "renderSource", "selectionFencePending", "guardCreatedAt", "owner"].includes(i)) && t(e.capturedAt) && [e.queryUpdatedAt, e.guardCreatedAt].every((i) => i === null || t(i)) && [e.selectionKey, e.userId, e.phase, e.queryStatus, e.queryRequestId].every((i) => i === null || p(i) !== null) && [e.loading, e.draft, e.thinking, e.connected, e.hasError, e.selectionFencePending].every((i) => typeof i == "boolean") && ["state", "account", "interactions", "local", "sidepanel_layout"].includes(e.renderSource) && (e.owner === void 0 || te(e.owner));
|
|
588
588
|
}
|
|
589
589
|
function U(s) {
|
|
590
590
|
if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
|
|
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) => [...
|
|
594
|
+
return Object.keys(i).every((r) => [...R, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || ie(n.context)) && (n.thinkingSequence === void 0 || Array.isArray(n.thinkingSequence) && n.thinkingSequence.length <= 20 && n.thinkingSequence.every((r) => r === "user" || r === "thinking")) && m(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
|
}
|
|
598
|
-
|
|
598
|
+
const k = 500;
|
|
599
|
+
function L(s) {
|
|
600
|
+
const e = s.replace(/\n\s*at\s[\s\S]*$/, "").replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g, "[REDACTED]").replace(/\b(?:set-cookie|cookie)\s*[:=]\s*[^\n]+/gi, "cookie=[REDACTED]").replace(/\bdata:[^\s<>"']+/gi, "[DATA]").replace(/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi, "[URL]").replace(/\b(?:Bearer|Basic)\s+[^\s,;"']+/gi, "[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp)[-_][A-Za-z0-9_-]{8,}/g, "[REDACTED]").replace(/\b((?:access|refresh|id|auth)[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|pwd|secret|token|jwt|authorization|cookie|set-cookie)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;}&]+)/gi, "$1=[REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[EMAIL]").replace(/(?:[A-Z]:[\\/]|\\\\|(?:~|\.\.?)?\/|[\w.-]+[\\/])[^\s<>"']+/gi, "[FILE]").replace(new RegExp("(?<![\\w.])(?:[\\w.-]+\\.[A-Z][A-Z0-9]{0,15}|\\.[A-Z][\\w.-]*)\\b", "gi"), "[FILE]").replace(/\s+/g, " ").trim();
|
|
601
|
+
return e.length > k ? `${e.slice(0, k - 1)}…` : e;
|
|
602
|
+
}
|
|
603
|
+
function ne(s) {
|
|
604
|
+
let e = 2166136261;
|
|
605
|
+
for (let t = 0; t < s.length; t += 1)
|
|
606
|
+
e ^= s.charCodeAt(t), e = Math.imul(e, 16777619);
|
|
607
|
+
return `fnv1a-${(e >>> 0).toString(16).padStart(8, "0")}`;
|
|
608
|
+
}
|
|
609
|
+
const re = "0.1.249", oe = {
|
|
610
|
+
version: re
|
|
611
|
+
};
|
|
612
|
+
function P(s) {
|
|
613
|
+
if (!s || typeof s != "object") return !1;
|
|
614
|
+
const e = s;
|
|
615
|
+
return Object.keys(s).every((t) => ["boundary", "category", "messageKind"].includes(t)) && ["runtime", "web_transport", "extension_ipc"].includes(e.boundary) && ["error", "object", "null", "array", "string", "undefined", "number", "boolean", "bigint", "symbol", "function"].includes(e.category) && ["object_coercion", "text", "blank", "non_text"].includes(e.messageKind);
|
|
616
|
+
}
|
|
617
|
+
function ae(s) {
|
|
618
|
+
if (!s || typeof s != "object") return !1;
|
|
619
|
+
const e = s;
|
|
620
|
+
return Object.keys(e).every((t) => ["sessionId", "requestId", "code", "normalization", "builds"].includes(t)) && [e.sessionId, e.requestId, e.code].every((t) => t === null || p(t) !== null) && (e.normalization === void 0 || P(e.normalization)) && !!e.builds && typeof e.builds == "object" && typeof e.builds.sdk == "string" && Object.entries(e.builds).every(([t, i]) => ["sdk", "rendererExtension", "contentExtension", "backgroundExtension"].includes(t) && typeof i == "string" && /^\d{1,5}\.\d{1,5}\.\d{1,5}$/.test(i));
|
|
621
|
+
}
|
|
622
|
+
function de(s, e, t, i, n = {}) {
|
|
623
|
+
const r = !i && e === "conversation_error" && t !== void 0 && s.conversationDiagnostics?.errorMessageFingerprint === ne(L(t)) ? s.conversationDiagnostics : void 0;
|
|
624
|
+
return {
|
|
625
|
+
sessionId: p(s.sessionId),
|
|
626
|
+
requestId: p(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
|
|
627
|
+
code: r ? p(s.lastErrorCode) : null,
|
|
628
|
+
...P(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
|
|
629
|
+
builds: { sdk: oe.version, ...n }
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function ce(s) {
|
|
599
633
|
if (s.details !== void 0 && !v(s.details))
|
|
600
634
|
throw new TypeError("Product Agent transported error details must be JSON-safe.");
|
|
601
635
|
return {
|
|
@@ -605,8 +639,14 @@ function se(s) {
|
|
|
605
639
|
...s.details === void 0 ? {} : { details: s.details }
|
|
606
640
|
};
|
|
607
641
|
}
|
|
608
|
-
function _(s, e = "runtime_error") {
|
|
609
|
-
const
|
|
642
|
+
function _(s, e = "runtime_error", t = "runtime") {
|
|
643
|
+
const i = s !== null && typeof s == "object" ? s : null, n = typeof s == "string" ? s : i && "message" in i && typeof i.message == "string" ? i.message : "", r = i && "code" in i && typeof i.code == "string" && i.code.trim() ? i.code : e, a = i && "details" in i ? i.details : null, o = a && typeof a == "object" ? a : {}, d = {
|
|
644
|
+
// Preserve the first boundary's shape after normalization replaces the original message/prototype.
|
|
645
|
+
errorNormalization: P(o.errorNormalization) ? o.errorNormalization : {
|
|
646
|
+
boundary: t,
|
|
647
|
+
category: s instanceof Error ? "error" : s === null ? "null" : Array.isArray(s) ? "array" : typeof s,
|
|
648
|
+
messageKind: n.trim() === "[object Object]" ? "object_coercion" : n.trim() ? "text" : typeof s == "string" || i && "message" in i && typeof i.message == "string" ? "blank" : "non_text"
|
|
649
|
+
},
|
|
610
650
|
...o.allocation === "unissued" ? { allocation: "unissued" } : {},
|
|
611
651
|
...["unissued", "rejected"].includes(String(o.acceptance)) ? { acceptance: String(o.acceptance) } : {},
|
|
612
652
|
...typeof o.securitySettingsUrl == "string" ? { securitySettingsUrl: o.securitySettingsUrl } : {},
|
|
@@ -615,14 +655,14 @@ function _(s, e = "runtime_error") {
|
|
|
615
655
|
...typeof o.durationMs == "number" && Number.isFinite(o.durationMs) && o.durationMs >= 0 ? { durationMs: o.durationMs } : {},
|
|
616
656
|
...typeof o.successfulRequests == "number" && Number.isSafeInteger(o.successfulRequests) && o.successfulRequests >= 0 ? { successfulRequests: o.successfulRequests } : {}
|
|
617
657
|
};
|
|
618
|
-
return
|
|
619
|
-
code:
|
|
620
|
-
message:
|
|
621
|
-
retryable: !!(
|
|
622
|
-
...Object.keys(
|
|
658
|
+
return ce({
|
|
659
|
+
code: r,
|
|
660
|
+
message: n.trim() && n.trim() !== "[object Object]" ? n : "The Product Agent operation failed. Try again.",
|
|
661
|
+
retryable: !!(i && "retryable" in i && i.retryable === !0),
|
|
662
|
+
...Object.keys(d).length ? { details: d } : {}
|
|
623
663
|
});
|
|
624
664
|
}
|
|
625
|
-
function
|
|
665
|
+
function F(s) {
|
|
626
666
|
if (!s || typeof s != "object") return !1;
|
|
627
667
|
const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
|
|
628
668
|
return Object.keys(e).every((i) => [
|
|
@@ -646,7 +686,7 @@ function L(s) {
|
|
|
646
686
|
"upstreamTraceId"
|
|
647
687
|
].includes(i)) && p(e.requestId) !== null && ["GET", "POST", "PUT", "PATCH", "DELETE"].includes(e.method) && ["/api/product-agent/conversations/:sessionId/snapshot", "/api/product-agent/:namespace/commands", "/api/product-agent/:namespace/:operation"].includes(e.route) && (e.status === null || t(e.status) && e.status >= 100 && e.status <= 599) && (e.abortTrigger === null || ["deadline", "transport_disposed", "owner_disposed", "authority_retired", "observation_released", "request_replaced", "caller_cancelled", "unexpected_abort"].includes(e.abortTrigger)) && ["http_deadline", "http_transport", "conversation_query", "browser", "http_response"].includes(e.owner) && (e.category === void 0 || /^[a-z0-9_]{1,80}$/.test(e.category)) && [e.responseHeadersMs, e.responseBodyMs].every((i) => i == null || t(i)) && t(e.elapsedMs) && t(e.attempt) && e.attempt >= 1 && e.attempt <= 10 && [e.queryRequestId, e.ownerId, e.sessionId].every((i) => i === null || p(i) !== null) && (e.authorityGeneration === null || t(e.authorityGeneration)) && typeof e.release == "string" && /^[a-zA-Z0-9._-]{1,80}$/.test(e.release) && [e.upstreamRequestId, e.upstreamTraceId].every((i) => i === null || typeof i == "string" && /^[a-zA-Z0-9_:;=./-]{1,160}$/.test(i));
|
|
648
688
|
}
|
|
649
|
-
const
|
|
689
|
+
const le = [
|
|
650
690
|
"submit",
|
|
651
691
|
"stop",
|
|
652
692
|
"staging_ipc",
|
|
@@ -682,13 +722,13 @@ const ie = [
|
|
|
682
722
|
"stopping_painted",
|
|
683
723
|
"progress_painted",
|
|
684
724
|
"stopped_painted"
|
|
685
|
-
],
|
|
686
|
-
let
|
|
687
|
-
const
|
|
688
|
-
function
|
|
725
|
+
], ue = Math.random().toString(36).slice(2);
|
|
726
|
+
let pe = 0;
|
|
727
|
+
const x = () => `timing:${ue}:${++pe}`, g = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
|
|
728
|
+
function T(s) {
|
|
689
729
|
if (!s || typeof s != "object") return !1;
|
|
690
730
|
const e = s;
|
|
691
|
-
return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs"].includes(t)) && (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) &&
|
|
731
|
+
return Object.keys(e).every((t) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs"].includes(t)) && (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) && le.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && g(e.spanId) && g(e.requestId) && (e.clientMessageId === null || g(e.clientMessageId)) && (e.sessionId === null || g(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
|
|
692
732
|
}
|
|
693
733
|
function C(s, e) {
|
|
694
734
|
if (!s) return {
|
|
@@ -696,70 +736,65 @@ function C(s, e) {
|
|
|
696
736
|
},
|
|
697
737
|
measure: (n, r) => r()
|
|
698
738
|
};
|
|
699
|
-
const t = performance.now(), i = (n, r,
|
|
739
|
+
const t = performance.now(), i = (n, r, a, o) => {
|
|
700
740
|
const d = {
|
|
701
741
|
...e,
|
|
702
742
|
stage: n,
|
|
703
743
|
status: r,
|
|
704
|
-
spanId:
|
|
744
|
+
spanId: o,
|
|
705
745
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
706
|
-
durationMs: Math.max(0, Math.round(performance.now() -
|
|
746
|
+
durationMs: Math.max(0, Math.round(performance.now() - a))
|
|
707
747
|
};
|
|
708
|
-
s &&
|
|
748
|
+
s && T(d) && Promise.resolve().then(() => s(d)).catch(() => {
|
|
709
749
|
});
|
|
710
750
|
};
|
|
711
751
|
return {
|
|
712
|
-
mark: (n) => i(n, "observed", t,
|
|
752
|
+
mark: (n) => i(n, "observed", t, x()),
|
|
713
753
|
measure(n, r) {
|
|
714
|
-
const
|
|
715
|
-
return i(n, "started",
|
|
716
|
-
(d) => (i(n, "completed",
|
|
754
|
+
const a = performance.now(), o = x();
|
|
755
|
+
return i(n, "started", a, o), r().then(
|
|
756
|
+
(d) => (i(n, "completed", a, o), d),
|
|
717
757
|
(d) => {
|
|
718
|
-
throw i(n, "failed",
|
|
758
|
+
throw i(n, "failed", a, o), d;
|
|
719
759
|
}
|
|
720
760
|
);
|
|
721
761
|
}
|
|
722
762
|
};
|
|
723
763
|
}
|
|
724
764
|
const S = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
|
|
725
|
-
function
|
|
765
|
+
function he(s) {
|
|
726
766
|
if (!s || typeof s != "object") return !1;
|
|
727
767
|
const e = s;
|
|
728
768
|
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";
|
|
729
769
|
}
|
|
730
|
-
|
|
731
|
-
function ae(s) {
|
|
732
|
-
const e = s.replace(/\n\s*at\s[\s\S]*$/, "").replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g, "[REDACTED]").replace(/\b(?:set-cookie|cookie)\s*[:=]\s*[^\n]+/gi, "cookie=[REDACTED]").replace(/\bdata:[^\s<>"']+/gi, "[DATA]").replace(/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi, "[URL]").replace(/\b(?:Bearer|Basic)\s+[^\s,;"']+/gi, "[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp)[-_][A-Za-z0-9_-]{8,}/g, "[REDACTED]").replace(/\b((?:access|refresh|id|auth)[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|pwd|secret|token|jwt|authorization|cookie|set-cookie)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;}&]+)/gi, "$1=[REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[EMAIL]").replace(/(?:[A-Z]:[\\/]|\\\\|(?:~|\.\.?)?\/|[\w.-]+[\\/])[^\s<>"']+/gi, "[FILE]").replace(new RegExp("(?<![\\w.])(?:[\\w.-]+\\.[A-Z][A-Z0-9]{0,15}|\\.[A-Z][\\w.-]*)\\b", "gi"), "[FILE]").replace(/\s+/g, " ").trim();
|
|
733
|
-
return e.length > x ? `${e.slice(0, x - 1)}…` : e;
|
|
734
|
-
}
|
|
735
|
-
function de(s, e, t = "stopped", i, n = "Run stopped by user.") {
|
|
770
|
+
function ge(s, e, t = "stopped", i, n = "Run stopped by user.") {
|
|
736
771
|
const r = new Set(i ?? [
|
|
737
772
|
s.assistantDraftRespondsToUserMessageId,
|
|
738
773
|
s.activeResponseUserMessageId,
|
|
739
774
|
s.messages.filter((d) => d.role === "user").slice(-1)[0]?.id
|
|
740
|
-
].filter((d) => !!d)),
|
|
775
|
+
].filter((d) => !!d)), a = s.messages.filter((d) => !(d.dataType === "run_status" && d.loading && r.has(d.respondsToUserMessageId ?? ""))).map((d) => r.has(d.respondsToUserMessageId ?? "") ? { ...d, loading: !1 } : d);
|
|
741
776
|
for (const d of r)
|
|
742
|
-
|
|
743
|
-
const
|
|
777
|
+
a.some((c) => c.respondsToUserMessageId === d && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary")) || a.some((c) => c.role === "user" && c.id === d) && a.push({ id: `local-interrupted:${d}`, role: "system", dataType: "run_status", provisional: t === "stopping", content: t === "stopping" ? "Stopping…" : n, createdAt: e, respondsToUserMessageId: d });
|
|
778
|
+
const o = s.segments?.map((d) => ({ ...d, outcomeIds: [
|
|
744
779
|
...d.outcomeIds,
|
|
745
|
-
...
|
|
780
|
+
...a.filter((c) => c.id === `local-interrupted:${d.userMessageId}` && !d.outcomeIds.includes(c.id)).map((c) => c.id)
|
|
746
781
|
] }));
|
|
747
782
|
return {
|
|
748
783
|
...s,
|
|
749
|
-
messages:
|
|
784
|
+
messages: a,
|
|
750
785
|
isThinking: !1,
|
|
751
786
|
isRetrying: !1,
|
|
752
787
|
pendingMessageStatus: null,
|
|
753
788
|
turnPhase: null,
|
|
754
|
-
segments:
|
|
789
|
+
segments: o,
|
|
755
790
|
activity: { phase: t, activeItemId: null },
|
|
756
|
-
isLoadingSession: s.isLoadingSession &&
|
|
791
|
+
isLoadingSession: s.isLoadingSession && a.length === 0,
|
|
757
792
|
taskStatus: t === "stopped" ? "stopped" : null,
|
|
758
793
|
lastError: null,
|
|
759
794
|
lastErrorCode: null
|
|
760
795
|
};
|
|
761
796
|
}
|
|
762
|
-
const
|
|
797
|
+
const fe = {
|
|
763
798
|
"stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
|
|
764
799
|
"in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
|
|
765
800
|
"stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
|
|
@@ -775,10 +810,10 @@ const ce = {
|
|
|
775
810
|
"thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
|
|
776
811
|
"thinking-without-progress": "Thinking remained visible without progress for five minutes."
|
|
777
812
|
};
|
|
778
|
-
function
|
|
779
|
-
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(
|
|
813
|
+
function ye(s) {
|
|
814
|
+
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(fe, s.slice(13));
|
|
780
815
|
}
|
|
781
|
-
function
|
|
816
|
+
function D(s) {
|
|
782
817
|
return {
|
|
783
818
|
...s.id === void 0 ? {} : { id: s.id },
|
|
784
819
|
name: s.name,
|
|
@@ -789,7 +824,7 @@ function k(s) {
|
|
|
789
824
|
...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
|
|
790
825
|
};
|
|
791
826
|
}
|
|
792
|
-
function
|
|
827
|
+
function qe(s) {
|
|
793
828
|
if (!s || typeof s != "object" || !("type" in s)) return !1;
|
|
794
829
|
const e = s;
|
|
795
830
|
switch (e.type) {
|
|
@@ -801,15 +836,15 @@ function Ae(s) {
|
|
|
801
836
|
case "run.stop":
|
|
802
837
|
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);
|
|
803
838
|
case "runtime.report_response_visibility":
|
|
804
|
-
return
|
|
839
|
+
return he(e.observation);
|
|
805
840
|
case "runtime.warmup":
|
|
806
841
|
return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
|
|
807
842
|
case "runtime.report_operation_timing":
|
|
808
|
-
return
|
|
843
|
+
return T(e.timing);
|
|
809
844
|
case "runtime.report_displayed_error":
|
|
810
|
-
return (e.httpRequest === void 0 ||
|
|
845
|
+
return (e.errorDiagnostic === void 0 || ae(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);
|
|
811
846
|
case "runtime.report_invalid_state_transition":
|
|
812
|
-
return (e.uiInvariant === void 0 || U(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" ||
|
|
847
|
+
return (e.uiInvariant === void 0 || U(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || ye(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
|
|
813
848
|
case "runtime.widget_lifecycle":
|
|
814
849
|
return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
|
|
815
850
|
case "session.load":
|
|
@@ -837,7 +872,7 @@ function Ae(s) {
|
|
|
837
872
|
return !1;
|
|
838
873
|
}
|
|
839
874
|
}
|
|
840
|
-
class
|
|
875
|
+
class Oe {
|
|
841
876
|
constructor(e, t, i) {
|
|
842
877
|
this.adapter = t, this.state = A(e), this.model = i;
|
|
843
878
|
}
|
|
@@ -869,42 +904,42 @@ class we {
|
|
|
869
904
|
getState() {
|
|
870
905
|
const e = A(this.state);
|
|
871
906
|
for (const [n, r] of this.submissionPreviews)
|
|
872
|
-
e.messages.some((
|
|
907
|
+
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, e.lastErrorCode = "message_delivery_failed"));
|
|
873
908
|
this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
|
|
874
909
|
const t = [...this.stopPreviews.keys()];
|
|
875
910
|
if (!t.length) return e;
|
|
876
|
-
const i =
|
|
911
|
+
const i = ge(e, "", "stopping", t);
|
|
877
912
|
return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
|
|
878
913
|
}
|
|
879
914
|
updateProjection(e, t, i, n, r) {
|
|
880
915
|
if (this.destroyed) return;
|
|
881
|
-
const
|
|
882
|
-
(
|
|
883
|
-
for (const
|
|
884
|
-
|
|
916
|
+
const a = this.getState();
|
|
917
|
+
(a.user?.id !== e.user?.id || a.selectionKey !== void 0 && a.selectionKey !== e.selectionKey || a.selectionKey === void 0 && a.sessionId !== null && a.sessionId !== e.sessionId) && (this.cancelPendingSubmissions(), this.submissionPreviews.clear());
|
|
918
|
+
for (const o of e.messages)
|
|
919
|
+
o.role === "user" && this.submissionPreviews.delete(o.id);
|
|
885
920
|
this.state = A(e);
|
|
886
|
-
for (const [
|
|
921
|
+
for (const [o, d] of this.stopPreviews) {
|
|
887
922
|
const c = e.activity?.executionKey;
|
|
888
|
-
(d !== void 0 && d !== "[]" && c !== void 0 && c !== "[]" && (c !== d || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (d === void 0 || d === "[]") && e.messages.some((l) => l.respondsToUserMessageId ===
|
|
923
|
+
(d !== void 0 && d !== "[]" && c !== void 0 && c !== "[]" && (c !== d || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (d === void 0 || d === "[]") && e.messages.some((l) => l.respondsToUserMessageId === o && !l.provisional && l.loading !== !0 && (l.dataType === "run_status" || l.dataType === "run_error" || l.role === "assistant" && l.phase !== "commentary" && (l.streamState === void 0 || ["finished", "stopped", "failed"].includes(l.streamState))))) && this.stopPreviews.delete(o);
|
|
889
924
|
}
|
|
890
|
-
if (this.pendingStop?.userMessageIds.every((
|
|
891
|
-
for (const
|
|
892
|
-
if (
|
|
893
|
-
const d =
|
|
894
|
-
|
|
925
|
+
if (this.pendingStop?.userMessageIds.every((o) => !this.stopPreviews.has(o)) && (this.pendingStop = null), a.user?.id === e.user?.id)
|
|
926
|
+
for (const o of this.state.messages) {
|
|
927
|
+
if (o.role !== "user" || !o.attachments?.length) continue;
|
|
928
|
+
const d = a.messages.find((c) => c.role === "user" && c.id === o.id);
|
|
929
|
+
a.sessionId !== e.sessionId && !(a.sessionId === null && d) || (o.attachments = me(d?.attachments, o.attachments));
|
|
895
930
|
}
|
|
896
931
|
if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
|
|
897
|
-
this.sessionHistoryState =
|
|
898
|
-
for (const
|
|
899
|
-
|
|
932
|
+
this.sessionHistoryState = j(i);
|
|
933
|
+
for (const o of this.sessionHistoryListeners)
|
|
934
|
+
o(this.getSessionHistoryState());
|
|
900
935
|
}
|
|
901
936
|
if (n && JSON.stringify(n) !== JSON.stringify(this.interactions)) {
|
|
902
|
-
this.interactions = n.map((
|
|
903
|
-
for (const
|
|
937
|
+
this.interactions = n.map((o) => ({ ...o }));
|
|
938
|
+
for (const o of this.interactionListeners) o(this.getInteractions());
|
|
904
939
|
}
|
|
905
940
|
if (r !== void 0 && JSON.stringify(r) !== JSON.stringify(this.account)) {
|
|
906
941
|
this.account = r ? { ...r } : null;
|
|
907
|
-
for (const
|
|
942
|
+
for (const o of this.accountListeners) o(this.getAccount());
|
|
908
943
|
}
|
|
909
944
|
this.emit("state", this.getState());
|
|
910
945
|
}
|
|
@@ -926,7 +961,7 @@ class we {
|
|
|
926
961
|
this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
|
|
927
962
|
}
|
|
928
963
|
reportOperationTiming(e) {
|
|
929
|
-
!this.destroyed &&
|
|
964
|
+
!this.destroyed && T(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
|
|
930
965
|
});
|
|
931
966
|
}
|
|
932
967
|
reportResponseVisibility(e) {
|
|
@@ -943,15 +978,16 @@ class we {
|
|
|
943
978
|
});
|
|
944
979
|
}
|
|
945
980
|
reportDisplayedError(e, t, i, n, r) {
|
|
946
|
-
const
|
|
947
|
-
n !== void 0 &&
|
|
981
|
+
const a = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
|
|
982
|
+
n !== void 0 && !$(n) || r !== void 0 && !K(r) || this.adapter.dispatch({
|
|
948
983
|
type: "runtime.report_displayed_error",
|
|
984
|
+
errorDiagnostic: de(this.getState(), e, i, !!n, this.adapter.diagnosticBuilds),
|
|
949
985
|
reason: e,
|
|
950
986
|
errorFingerprint: t,
|
|
951
987
|
...n ? { renderedError: n } : {},
|
|
952
988
|
...r ? { historyRefreshFailure: r } : {},
|
|
953
|
-
...
|
|
954
|
-
...i ? { displayedMessage:
|
|
989
|
+
...F(a) ? { httpRequest: a } : {},
|
|
990
|
+
...i ? { displayedMessage: L(i) } : {}
|
|
955
991
|
}).catch(() => {
|
|
956
992
|
});
|
|
957
993
|
}
|
|
@@ -959,7 +995,7 @@ class we {
|
|
|
959
995
|
const i = e.trim(), n = t.attachments ?? [];
|
|
960
996
|
if (!i && n.length === 0) return Promise.resolve(null);
|
|
961
997
|
this.pendingStop = null, this.stopError = null;
|
|
962
|
-
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()),
|
|
998
|
+
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), a = t.submittedAt ?? Date.now(), o = this.submissionGeneration;
|
|
963
999
|
this.pendingTransfers.set(r, n.flatMap((c) => c.id ? [c.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
|
|
964
1000
|
id: r,
|
|
965
1001
|
role: "user",
|
|
@@ -967,13 +1003,13 @@ class we {
|
|
|
967
1003
|
createdAt: "",
|
|
968
1004
|
attachments: n.map((c) => ({ ...c }))
|
|
969
1005
|
} });
|
|
970
|
-
const d = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt:
|
|
1006
|
+
const d = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt: a }, o);
|
|
971
1007
|
return this.emit("state", this.getState()), d.finally(() => {
|
|
972
1008
|
this.pendingTransfers.delete(r);
|
|
973
1009
|
});
|
|
974
1010
|
}
|
|
975
1011
|
async sendMessageNow(e, t, i) {
|
|
976
|
-
const n = e, r = t.clientMessageId,
|
|
1012
|
+
const n = e, r = t.clientMessageId, a = C((c) => {
|
|
977
1013
|
i === this.submissionGeneration && this.reportOperationTiming(c);
|
|
978
1014
|
}, {
|
|
979
1015
|
operation: "send",
|
|
@@ -982,11 +1018,11 @@ class we {
|
|
|
982
1018
|
clientMessageId: r,
|
|
983
1019
|
sessionId: this.state.sessionId
|
|
984
1020
|
});
|
|
985
|
-
|
|
986
|
-
let
|
|
1021
|
+
a.mark("submit");
|
|
1022
|
+
let o = t.attachments ?? [], d = !1;
|
|
987
1023
|
if (i !== this.submissionGeneration) return null;
|
|
988
1024
|
try {
|
|
989
|
-
if (!await
|
|
1025
|
+
if (!await a.measure("staging_ipc", async () => {
|
|
990
1026
|
const u = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
|
|
991
1027
|
type: "conversation.stage",
|
|
992
1028
|
initiatedBy: t.initiatedBy,
|
|
@@ -996,25 +1032,25 @@ class we {
|
|
|
996
1032
|
clientMessageId: r,
|
|
997
1033
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
998
1034
|
// Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
|
|
999
|
-
attachments:
|
|
1035
|
+
attachments: o.length > 0 ? o.map(D) : void 0,
|
|
1000
1036
|
submittedAt: t.submittedAt
|
|
1001
1037
|
}) });
|
|
1002
1038
|
return u ? (await u.result, u) : null;
|
|
1003
1039
|
}) || i !== this.submissionGeneration) return null;
|
|
1004
|
-
if (d = !0,
|
|
1040
|
+
if (d = !0, o.length > 0) {
|
|
1005
1041
|
if (!this.adapter.uploadAttachment)
|
|
1006
1042
|
throw new Error("The runtime does not support attachments.");
|
|
1007
1043
|
const u = [];
|
|
1008
|
-
for (const l of
|
|
1044
|
+
for (const l of o) {
|
|
1009
1045
|
if (l.sandboxPath || l.storageKey) {
|
|
1010
1046
|
u.push(l);
|
|
1011
1047
|
continue;
|
|
1012
1048
|
}
|
|
1013
1049
|
const M = l.id ? this.attachmentFiles.get(l.id) : void 0;
|
|
1014
1050
|
if (!M) throw new Error(`Attachment bytes are unavailable for ${l.name}`);
|
|
1015
|
-
if (u.push(await
|
|
1051
|
+
if (u.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(M, l, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
|
|
1016
1052
|
}
|
|
1017
|
-
|
|
1053
|
+
o = u;
|
|
1018
1054
|
}
|
|
1019
1055
|
if (i !== this.submissionGeneration || (await this.adapter.dispatch({
|
|
1020
1056
|
type: "conversation.send",
|
|
@@ -1024,14 +1060,14 @@ class we {
|
|
|
1024
1060
|
invocation: t.invocation,
|
|
1025
1061
|
automationOnboarding: t.automationOnboarding,
|
|
1026
1062
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1027
|
-
attachments:
|
|
1063
|
+
attachments: o.length > 0 ? o.map(D) : void 0
|
|
1028
1064
|
}), i !== this.submissionGeneration)) return null;
|
|
1029
1065
|
for (const u of t.attachments ?? [])
|
|
1030
1066
|
u.id && this.attachmentFiles.delete(u.id);
|
|
1031
1067
|
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
|
|
1032
1068
|
} catch (c) {
|
|
1033
1069
|
if (i !== this.submissionGeneration) return null;
|
|
1034
|
-
if (
|
|
1070
|
+
if (H(c))
|
|
1035
1071
|
for (const l of t.attachments ?? [])
|
|
1036
1072
|
l.id && this.attachmentFiles.delete(l.id);
|
|
1037
1073
|
const u = this.submissionPreviews.get(r);
|
|
@@ -1077,18 +1113,18 @@ class we {
|
|
|
1077
1113
|
n.mark("stop");
|
|
1078
1114
|
const r = { userMessageIds: i, promise: Promise.resolve() };
|
|
1079
1115
|
this.pendingStop = r;
|
|
1080
|
-
const
|
|
1116
|
+
const a = !e.pendingMessageStatus && ["thinking", "steering", "queued", "stopping"].includes(this.state.activity?.phase ?? "") ? this.state.activity?.executionKey : void 0;
|
|
1081
1117
|
for (const c of i)
|
|
1082
|
-
this.stopPreviews.set(c, t.includes(c) ? void 0 :
|
|
1083
|
-
const
|
|
1118
|
+
this.stopPreviews.set(c, t.includes(c) ? void 0 : a);
|
|
1119
|
+
const o = this.submissionGeneration;
|
|
1084
1120
|
r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
|
|
1085
1121
|
}, (c) => {
|
|
1086
|
-
if (!(
|
|
1122
|
+
if (!(o !== this.submissionGeneration || i.every((u) => !this.stopPreviews.has(u)))) {
|
|
1087
1123
|
for (const u of i) this.stopPreviews.delete(u);
|
|
1088
1124
|
this.stopError = _(c).message;
|
|
1089
1125
|
}
|
|
1090
1126
|
}).finally(() => {
|
|
1091
|
-
this.destroyed ||
|
|
1127
|
+
this.destroyed || o !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
|
|
1092
1128
|
}), this.emit("state", this.getState());
|
|
1093
1129
|
const d = r.promise;
|
|
1094
1130
|
return this.operationQueue = d.then(() => {
|
|
@@ -1120,7 +1156,7 @@ class we {
|
|
|
1120
1156
|
return t.sessionHistoryPage;
|
|
1121
1157
|
}
|
|
1122
1158
|
getSessionHistoryState() {
|
|
1123
|
-
return
|
|
1159
|
+
return j(this.sessionHistoryState);
|
|
1124
1160
|
}
|
|
1125
1161
|
subscribeSessionHistory(e) {
|
|
1126
1162
|
return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
|
|
@@ -1199,7 +1235,7 @@ class we {
|
|
|
1199
1235
|
for (const n of i ?? []) n(t);
|
|
1200
1236
|
}
|
|
1201
1237
|
}
|
|
1202
|
-
function
|
|
1238
|
+
function me(s, e) {
|
|
1203
1239
|
if (!e || !s) return e;
|
|
1204
1240
|
const t = /* @__PURE__ */ new Map();
|
|
1205
1241
|
for (const i of s) {
|
|
@@ -1219,7 +1255,7 @@ function A(s) {
|
|
|
1219
1255
|
messages: s.messages.map((e) => {
|
|
1220
1256
|
const t = {
|
|
1221
1257
|
...e,
|
|
1222
|
-
attachments: e.attachments?.map((
|
|
1258
|
+
attachments: e.attachments?.map((a) => ({ ...a }))
|
|
1223
1259
|
}, i = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
|
|
1224
1260
|
return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
|
|
1225
1261
|
value: r,
|
|
@@ -1235,36 +1271,36 @@ function A(s) {
|
|
|
1235
1271
|
activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
|
|
1236
1272
|
};
|
|
1237
1273
|
}
|
|
1238
|
-
function
|
|
1274
|
+
function j(s) {
|
|
1239
1275
|
return {
|
|
1240
1276
|
...s,
|
|
1241
1277
|
data: s.data ? y({
|
|
1242
|
-
entities:
|
|
1278
|
+
entities: Q(s.data).map((e) => ({ ...e })),
|
|
1243
1279
|
nextCursor: s.data.nextCursor
|
|
1244
1280
|
}) : null
|
|
1245
1281
|
};
|
|
1246
1282
|
}
|
|
1247
1283
|
export {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1284
|
+
G as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
|
|
1285
|
+
Ee as ProductAgentInteractionManager,
|
|
1286
|
+
q as ProductAgentQueryController,
|
|
1287
|
+
Oe as ProductAgentRemoteRuntimeClient,
|
|
1288
|
+
we as ProductAgentSessionHistoryManager,
|
|
1289
|
+
Te as ProductAgentTaskPageTitleController,
|
|
1290
|
+
Se as canSubmitPersonalProductAgentMessage,
|
|
1291
|
+
Pe as createLocalStorageInteractionDecisionStorage,
|
|
1256
1292
|
f as createProductAgentQueryState,
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1293
|
+
Me as createProductAgentTaskPageTitleDocument,
|
|
1294
|
+
ee as formatProductAgentTaskPageTitle,
|
|
1295
|
+
Ie as hasProductAgentPaidCreditFallback,
|
|
1296
|
+
H as isProductAgentAuthReconnectError,
|
|
1297
|
+
qe as isProductAgentRuntimeCommand,
|
|
1298
|
+
B as mergeProductAgentEntityPages,
|
|
1263
1299
|
y as normalizeProductAgentEntityPage,
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1300
|
+
W as readLocalStorageInteractionDecisions,
|
|
1301
|
+
be as reconcileProductAgentSubmissionGate,
|
|
1302
|
+
_e as resolveProductAgentBillingPresentation,
|
|
1303
|
+
Ae as resolveProductAgentComposerAction,
|
|
1304
|
+
ve as resolveProductAgentWidgetPresentation,
|
|
1305
|
+
Q as selectProductAgentQueryEntities
|
|
1270
1306
|
};
|