@pluno/product-agent-web 0.1.237 → 0.1.238
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/backendHttp.d.ts +0 -1
- package/dist/adapters/web/conversationPresentation.d.ts +1 -1
- package/dist/core/conversation/contracts.d.ts +3 -0
- package/dist/core/conversation/historyRefreshFailure.d.ts +8 -0
- package/dist/core/conversation/selectors.d.ts +1 -0
- package/dist/core/conversation/state.d.ts +1 -0
- package/dist/displayedErrors.d.ts +2 -1
- package/dist/httpDiagnostics.d.ts +3 -0
- package/dist/index.d.ts +3 -1
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +215 -201
- package/dist/product-agent-sdk.js +1724 -1681
- package/dist/product-agent-widget.js +2487 -2442
- package/dist/renderDiagnostics.d.ts +3 -0
- package/dist/runtimeClient.d.ts +4 -2
- package/package.json +1 -1
|
@@ -93,34 +93,34 @@ function y(s) {
|
|
|
93
93
|
nextCursor: s.nextCursor
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function F(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 B(s) {
|
|
104
104
|
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function he(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 ge(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 fe(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 me(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 ye(s) {
|
|
121
121
|
return s.submissionAllowed && s.isAuthenticated && s.hasWorkspace && !s.isWebsiteBlocked && s.isCurrentPageResolved && !s.isSubmitting && !s.hasPendingMessage;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function ve(s) {
|
|
124
124
|
const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
|
|
125
125
|
return s.hasRunningAssistantTurn && !e ? {
|
|
126
126
|
action: "stop",
|
|
@@ -131,10 +131,10 @@ function ye(s) {
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
const Q = "Pluno is reconnecting. Try again in a moment.";
|
|
134
|
-
function
|
|
134
|
+
function G(s) {
|
|
135
135
|
return (s instanceof Error ? s.message : s) === Q;
|
|
136
136
|
}
|
|
137
|
-
class
|
|
137
|
+
class be {
|
|
138
138
|
constructor(e, t, i = 20) {
|
|
139
139
|
this.loadPage = t, this.limit = i, this.recentQuery = new O(
|
|
140
140
|
`${e}:recent`,
|
|
@@ -144,7 +144,7 @@ class ve {
|
|
|
144
144
|
nextCursor: r.nextCursor
|
|
145
145
|
}))
|
|
146
146
|
),
|
|
147
|
-
|
|
147
|
+
F
|
|
148
148
|
), this.pinnedQuery = new O(
|
|
149
149
|
`${e}:pinned`,
|
|
150
150
|
async () => y({
|
|
@@ -171,14 +171,14 @@ class ve {
|
|
|
171
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
|
-
status:
|
|
181
|
-
data:
|
|
180
|
+
status: H(e, t),
|
|
181
|
+
data: a,
|
|
182
182
|
error: e.error ?? t.error,
|
|
183
183
|
requestId: Math.max(e.requestId, t.requestId),
|
|
184
184
|
updatedAt: Math.max(e.updatedAt ?? 0, t.updatedAt ?? 0) || null
|
|
@@ -286,10 +286,10 @@ class ve {
|
|
|
286
286
|
function g(s) {
|
|
287
287
|
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function H(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
|
-
function
|
|
292
|
+
function q(s) {
|
|
293
293
|
const e = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?(?:Z|\+00:00)$/.exec(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")}`;
|
|
@@ -305,22 +305,22 @@ function b(s) {
|
|
|
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
|
-
function
|
|
308
|
+
function Z(s) {
|
|
309
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
|
-
function
|
|
312
|
+
function V(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 Ie {
|
|
324
324
|
constructor(e, t = null) {
|
|
325
325
|
this.storage = e, t && (this.decisions = new Map(
|
|
326
326
|
t.filter(T).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, N(
|
|
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(Z({ ...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 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, 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 || V(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;
|
|
@@ -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 (!$(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
|
+
}, 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;
|
|
@@ -463,48 +463,48 @@ class be {
|
|
|
463
463
|
return null;
|
|
464
464
|
}
|
|
465
465
|
getDecisionKey(e) {
|
|
466
|
-
const t =
|
|
466
|
+
const t = _(e.scope);
|
|
467
467
|
return e.action === "dont_show_again" ? `${t}:category:${e.category}` : `${t}:interaction:${e.promptKey}`;
|
|
468
468
|
}
|
|
469
469
|
getExactKey(e) {
|
|
470
|
-
return `${
|
|
470
|
+
return `${_(e.scope)}:interaction:${e.key}`;
|
|
471
471
|
}
|
|
472
472
|
getCategoryKey(e) {
|
|
473
|
-
return `${
|
|
473
|
+
return `${_(e.scope)}:category:${e.category}`;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
function _e(s, e) {
|
|
477
477
|
return {
|
|
478
|
-
load: async () =>
|
|
478
|
+
load: async () => J(s, e),
|
|
479
479
|
save: async (t) => s.setItem(e, JSON.stringify(t))
|
|
480
480
|
};
|
|
481
481
|
}
|
|
482
|
-
function
|
|
482
|
+
function J(s, e) {
|
|
483
483
|
const t = s.getItem(e);
|
|
484
484
|
if (!t) return [];
|
|
485
485
|
const i = JSON.parse(t);
|
|
486
486
|
return Array.isArray(i) ? i.filter(T) : [];
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function _(s) {
|
|
489
489
|
return `${s.level}:${s.key}`;
|
|
490
490
|
}
|
|
491
|
-
function
|
|
491
|
+
function $(s) {
|
|
492
492
|
return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
|
|
493
493
|
}
|
|
494
494
|
function T(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") && $(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
|
|
498
498
|
}
|
|
499
|
-
const
|
|
499
|
+
const W = {
|
|
500
500
|
working: "⏳",
|
|
501
501
|
completed: "✅",
|
|
502
502
|
failed: "❗",
|
|
503
503
|
stopped: "⏹️"
|
|
504
|
-
},
|
|
505
|
-
function
|
|
506
|
-
if (!e) return
|
|
507
|
-
const t =
|
|
504
|
+
}, Y = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
505
|
+
function X(s, e) {
|
|
506
|
+
if (!e) return I(s);
|
|
507
|
+
const t = I(s), i = `${W[e]} Pluno`;
|
|
508
508
|
return t ? `${i}: ${t}` : i;
|
|
509
509
|
}
|
|
510
510
|
class Se {
|
|
@@ -529,10 +529,10 @@ class Se {
|
|
|
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 = I(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 ? I(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() {
|
|
@@ -541,11 +541,11 @@ class Se {
|
|
|
541
541
|
applyTitle() {
|
|
542
542
|
if (!this.status)
|
|
543
543
|
return;
|
|
544
|
-
const e =
|
|
544
|
+
const e = X(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 Ae(s) {
|
|
549
549
|
return {
|
|
550
550
|
getTitle: () => s.title,
|
|
551
551
|
setTitle: (e) => {
|
|
@@ -561,10 +561,41 @@ function Ie(s) {
|
|
|
561
561
|
}
|
|
562
562
|
};
|
|
563
563
|
}
|
|
564
|
-
function
|
|
565
|
-
return s.replace(
|
|
564
|
+
function I(s) {
|
|
565
|
+
return s.replace(Y, "");
|
|
566
|
+
}
|
|
567
|
+
const p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
|
|
568
|
+
function ee(s) {
|
|
569
|
+
if (!s || typeof s != "object") return !1;
|
|
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
|
+
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
|
+
}
|
|
573
|
+
function L(s) {
|
|
574
|
+
if (!s || typeof s != "object") return !1;
|
|
575
|
+
const e = s;
|
|
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
|
+
}
|
|
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), te = (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 U(s) {
|
|
580
|
+
if (!s || typeof s != "object") return !1;
|
|
581
|
+
const e = s;
|
|
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 || te(e.createdAt));
|
|
583
|
+
}
|
|
584
|
+
function se(s) {
|
|
585
|
+
if (!s || typeof s != "object") return !1;
|
|
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 || ee(e.owner));
|
|
566
588
|
}
|
|
567
|
-
function
|
|
589
|
+
function K(s) {
|
|
590
|
+
if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
|
|
591
|
+
const e = (i) => {
|
|
592
|
+
if (!i || typeof i != "object") return !1;
|
|
593
|
+
const n = i;
|
|
594
|
+
return Object.keys(i).every((r) => [...R, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || se(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
|
+
}, t = s;
|
|
596
|
+
return (t.before === null || e(t.before)) && e(t.current);
|
|
597
|
+
}
|
|
598
|
+
function ie(s) {
|
|
568
599
|
if (s.details !== void 0 && !b(s.details))
|
|
569
600
|
throw new TypeError("Product Agent transported error details must be JSON-safe.");
|
|
570
601
|
return {
|
|
@@ -574,23 +605,22 @@ function X(s) {
|
|
|
574
605
|
...s.details === void 0 ? {} : { details: s.details }
|
|
575
606
|
};
|
|
576
607
|
}
|
|
577
|
-
function
|
|
578
|
-
const t = s !== null && typeof s == "object" ? s : null, i = typeof s == "string" ? s : t && "message" in t && typeof t.message == "string" ? t.message : "", n = t && "code" in t && typeof t.code == "string" && t.code.trim() ? t.code : e, r = t && "details" in t ? t.details : null
|
|
579
|
-
|
|
608
|
+
function S(s, e = "runtime_error") {
|
|
609
|
+
const t = s !== null && typeof s == "object" ? s : null, i = typeof s == "string" ? s : t && "message" in t && typeof t.message == "string" ? t.message : "", n = t && "code" in t && typeof t.code == "string" && t.code.trim() ? t.code : e, r = t && "details" in t ? t.details : null, o = r && typeof r == "object" ? r : {}, a = {
|
|
610
|
+
...typeof o.securitySettingsUrl == "string" ? { securitySettingsUrl: o.securitySettingsUrl } : {},
|
|
611
|
+
...typeof o.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(o.transportCode) ? { transportCode: o.transportCode } : {},
|
|
612
|
+
...typeof o.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(o.requestId) ? { requestId: o.requestId } : {},
|
|
613
|
+
...typeof o.durationMs == "number" && Number.isFinite(o.durationMs) && o.durationMs >= 0 ? { durationMs: o.durationMs } : {},
|
|
614
|
+
...typeof o.successfulRequests == "number" && Number.isSafeInteger(o.successfulRequests) && o.successfulRequests >= 0 ? { successfulRequests: o.successfulRequests } : {}
|
|
615
|
+
};
|
|
616
|
+
return ie({
|
|
580
617
|
code: n,
|
|
581
618
|
message: i.trim() && i.trim() !== "[object Object]" ? i : "The Product Agent operation failed. Try again.",
|
|
582
619
|
retryable: !!(t && "retryable" in t && t.retryable === !0),
|
|
583
|
-
|
|
584
|
-
...r && typeof r == "object" && "securitySettingsUrl" in r && typeof r.securitySettingsUrl == "string" ? { details: { securitySettingsUrl: r.securitySettingsUrl } } : {}
|
|
620
|
+
...Object.keys(a).length ? { details: a } : {}
|
|
585
621
|
});
|
|
586
622
|
}
|
|
587
|
-
|
|
588
|
-
function ee(s) {
|
|
589
|
-
if (!s || typeof s != "object") return !1;
|
|
590
|
-
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");
|
|
591
|
-
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);
|
|
592
|
-
}
|
|
593
|
-
function U(s) {
|
|
623
|
+
function z(s) {
|
|
594
624
|
if (!s || typeof s != "object") return !1;
|
|
595
625
|
const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
|
|
596
626
|
return Object.keys(e).every((i) => [
|
|
@@ -602,6 +632,9 @@ function U(s) {
|
|
|
602
632
|
"owner",
|
|
603
633
|
"elapsedMs",
|
|
604
634
|
"attempt",
|
|
635
|
+
"category",
|
|
636
|
+
"responseHeadersMs",
|
|
637
|
+
"responseBodyMs",
|
|
605
638
|
"queryRequestId",
|
|
606
639
|
"ownerId",
|
|
607
640
|
"authorityGeneration",
|
|
@@ -609,9 +642,9 @@ function U(s) {
|
|
|
609
642
|
"release",
|
|
610
643
|
"upstreamRequestId",
|
|
611
644
|
"upstreamTraceId"
|
|
612
|
-
].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) && 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));
|
|
645
|
+
].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));
|
|
613
646
|
}
|
|
614
|
-
const
|
|
647
|
+
const ne = [
|
|
615
648
|
"submit",
|
|
616
649
|
"stop",
|
|
617
650
|
"staging_ipc",
|
|
@@ -647,87 +680,67 @@ const te = [
|
|
|
647
680
|
"stopping_painted",
|
|
648
681
|
"progress_painted",
|
|
649
682
|
"stopped_painted"
|
|
650
|
-
],
|
|
651
|
-
let
|
|
652
|
-
const
|
|
653
|
-
function
|
|
683
|
+
], re = Math.random().toString(36).slice(2);
|
|
684
|
+
let oe = 0;
|
|
685
|
+
const C = () => `timing:${re}:${++oe}`, f = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
|
|
686
|
+
function M(s) {
|
|
654
687
|
if (!s || typeof s != "object") return !1;
|
|
655
688
|
const e = s;
|
|
656
|
-
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"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) &&
|
|
689
|
+
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"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && ne.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;
|
|
657
690
|
}
|
|
658
|
-
function
|
|
691
|
+
function k(s, e) {
|
|
659
692
|
if (!s) return {
|
|
660
693
|
mark: (n) => {
|
|
661
694
|
},
|
|
662
695
|
measure: (n, r) => r()
|
|
663
696
|
};
|
|
664
|
-
const t = performance.now(), i = (n, r,
|
|
697
|
+
const t = performance.now(), i = (n, r, o, a) => {
|
|
665
698
|
const d = {
|
|
666
699
|
...e,
|
|
667
700
|
stage: n,
|
|
668
701
|
status: r,
|
|
669
|
-
spanId:
|
|
702
|
+
spanId: a,
|
|
670
703
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
671
|
-
durationMs: Math.max(0, Math.round(performance.now() -
|
|
704
|
+
durationMs: Math.max(0, Math.round(performance.now() - o))
|
|
672
705
|
};
|
|
673
|
-
s &&
|
|
706
|
+
s && M(d) && Promise.resolve().then(() => s(d)).catch(() => {
|
|
674
707
|
});
|
|
675
708
|
};
|
|
676
709
|
return {
|
|
677
|
-
mark: (n) => i(n, "observed", t,
|
|
710
|
+
mark: (n) => i(n, "observed", t, C()),
|
|
678
711
|
measure(n, r) {
|
|
679
|
-
const
|
|
680
|
-
return i(n, "started",
|
|
681
|
-
(d) => (i(n, "completed",
|
|
712
|
+
const o = performance.now(), a = C();
|
|
713
|
+
return i(n, "started", o, a), r().then(
|
|
714
|
+
(d) => (i(n, "completed", o, a), d),
|
|
682
715
|
(d) => {
|
|
683
|
-
throw i(n, "failed",
|
|
716
|
+
throw i(n, "failed", o, a), d;
|
|
684
717
|
}
|
|
685
718
|
);
|
|
686
719
|
}
|
|
687
720
|
};
|
|
688
721
|
}
|
|
689
|
-
const D = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], P = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), v = (s) => s === null || P(s), ne = (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));
|
|
690
|
-
function K(s) {
|
|
691
|
-
if (!s || typeof s != "object") return !1;
|
|
692
|
-
const e = s;
|
|
693
|
-
return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && v(e.sessionId) && P(e.itemId) && v(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && v(e.runId) && (e.createdAt === null || ne(e.createdAt));
|
|
694
|
-
}
|
|
695
|
-
function re(s) {
|
|
696
|
-
if (!s || typeof s != "object") return !1;
|
|
697
|
-
const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
|
|
698
|
-
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 || ee(e.owner));
|
|
699
|
-
}
|
|
700
|
-
function $(s) {
|
|
701
|
-
if (!s || typeof s != "object" || Object.keys(s).some((i) => i !== "before" && i !== "current")) return !1;
|
|
702
|
-
const e = (i) => {
|
|
703
|
-
if (!i || typeof i != "object") return !1;
|
|
704
|
-
const n = i;
|
|
705
|
-
return Object.keys(i).every((r) => [...D, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || re(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" && D.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(P));
|
|
706
|
-
}, t = s;
|
|
707
|
-
return (t.before === null || e(t.before)) && e(t.current);
|
|
708
|
-
}
|
|
709
722
|
const A = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
|
|
710
|
-
function
|
|
723
|
+
function ae(s) {
|
|
711
724
|
if (!s || typeof s != "object") return !1;
|
|
712
725
|
const e = s;
|
|
713
726
|
return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) && A(e.sessionId) && A(e.responseItemId) && A(e.respondsToUserMessageId) && typeof e.panelVisible == "boolean" && typeof e.documentVisible == "boolean" && typeof e.loading == "boolean";
|
|
714
727
|
}
|
|
715
|
-
const
|
|
716
|
-
function
|
|
728
|
+
const D = 500;
|
|
729
|
+
function de(s) {
|
|
717
730
|
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();
|
|
718
|
-
return e.length >
|
|
731
|
+
return e.length > D ? `${e.slice(0, D - 1)}…` : e;
|
|
719
732
|
}
|
|
720
|
-
function
|
|
733
|
+
function ce(s, e, t = "stopped", i) {
|
|
721
734
|
const n = new Set(i ?? [
|
|
722
735
|
s.assistantDraftRespondsToUserMessageId,
|
|
723
736
|
s.activeResponseUserMessageId,
|
|
724
|
-
s.messages.filter((
|
|
725
|
-
].filter((
|
|
726
|
-
for (const
|
|
727
|
-
r.some((d) => d.respondsToUserMessageId ===
|
|
728
|
-
const
|
|
729
|
-
...
|
|
730
|
-
...r.filter((d) => d.id === `local-interrupted:${
|
|
737
|
+
s.messages.filter((a) => a.role === "user").slice(-1)[0]?.id
|
|
738
|
+
].filter((a) => !!a)), r = s.messages.filter((a) => !(a.dataType === "run_status" && a.loading && n.has(a.respondsToUserMessageId ?? ""))).map((a) => n.has(a.respondsToUserMessageId ?? "") ? { ...a, loading: !1 } : a);
|
|
739
|
+
for (const a of n)
|
|
740
|
+
r.some((d) => d.respondsToUserMessageId === a && (d.dataType === "run_status" || d.dataType === "run_error" || d.role === "assistant" && d.phase !== "commentary")) || r.some((d) => d.role === "user" && d.id === a) && r.push({ id: `local-interrupted:${a}`, role: "system", dataType: "run_status", content: t === "stopping" ? "Stopping…" : "Run stopped by user.", createdAt: e, respondsToUserMessageId: a });
|
|
741
|
+
const o = s.segments?.map((a) => ({ ...a, outcomeIds: [
|
|
742
|
+
...a.outcomeIds,
|
|
743
|
+
...r.filter((d) => d.id === `local-interrupted:${a.userMessageId}` && !a.outcomeIds.includes(d.id)).map((d) => d.id)
|
|
731
744
|
] }));
|
|
732
745
|
return {
|
|
733
746
|
...s,
|
|
@@ -736,7 +749,7 @@ function de(s, e, t = "stopped", i) {
|
|
|
736
749
|
isRetrying: !1,
|
|
737
750
|
pendingMessageStatus: null,
|
|
738
751
|
turnPhase: null,
|
|
739
|
-
segments:
|
|
752
|
+
segments: o,
|
|
740
753
|
activity: { phase: t, activeItemId: null },
|
|
741
754
|
isLoadingSession: s.isLoadingSession && r.length === 0,
|
|
742
755
|
taskStatus: t === "stopped" ? "stopped" : null,
|
|
@@ -744,7 +757,7 @@ function de(s, e, t = "stopped", i) {
|
|
|
744
757
|
lastErrorCode: null
|
|
745
758
|
};
|
|
746
759
|
}
|
|
747
|
-
const
|
|
760
|
+
const le = {
|
|
748
761
|
"stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
|
|
749
762
|
"in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
|
|
750
763
|
"stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
|
|
@@ -760,8 +773,8 @@ const ce = {
|
|
|
760
773
|
"thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
|
|
761
774
|
"thinking-without-progress": "Thinking remained visible without progress for five minutes."
|
|
762
775
|
};
|
|
763
|
-
function
|
|
764
|
-
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(
|
|
776
|
+
function ue(s) {
|
|
777
|
+
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(le, s.slice(13));
|
|
765
778
|
}
|
|
766
779
|
function x(s) {
|
|
767
780
|
return {
|
|
@@ -774,7 +787,7 @@ function x(s) {
|
|
|
774
787
|
...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
|
|
775
788
|
};
|
|
776
789
|
}
|
|
777
|
-
function
|
|
790
|
+
function we(s) {
|
|
778
791
|
if (!s || typeof s != "object" || !("type" in s)) return !1;
|
|
779
792
|
const e = s;
|
|
780
793
|
switch (e.type) {
|
|
@@ -785,15 +798,15 @@ function Ae(s) {
|
|
|
785
798
|
case "run.stop":
|
|
786
799
|
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);
|
|
787
800
|
case "runtime.report_response_visibility":
|
|
788
|
-
return
|
|
801
|
+
return ae(e.observation);
|
|
789
802
|
case "runtime.warmup":
|
|
790
803
|
return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
|
|
791
804
|
case "runtime.report_operation_timing":
|
|
792
|
-
return
|
|
805
|
+
return M(e.timing);
|
|
793
806
|
case "runtime.report_displayed_error":
|
|
794
|
-
return (e.httpRequest === void 0 ||
|
|
807
|
+
return (e.httpRequest === void 0 || z(e.httpRequest)) && (e.historyRefreshFailure === void 0 || L(e.historyRefreshFailure)) && (e.renderedError === void 0 || U(e.renderedError)) && (e.reason === "conversation_error" || e.reason === "attachment_error" || e.reason === "history_error" || e.reason === "action_error") && typeof e.errorFingerprint == "string" && /^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint) && (e.displayedMessage === void 0 || typeof e.displayedMessage == "string" && e.displayedMessage.length <= 500);
|
|
795
808
|
case "runtime.report_invalid_state_transition":
|
|
796
|
-
return (e.uiInvariant === void 0 ||
|
|
809
|
+
return (e.uiInvariant === void 0 || K(e.uiInvariant)) && (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || ue(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
|
|
797
810
|
case "runtime.widget_lifecycle":
|
|
798
811
|
return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
|
|
799
812
|
case "session.load":
|
|
@@ -821,7 +834,7 @@ function Ae(s) {
|
|
|
821
834
|
return !1;
|
|
822
835
|
}
|
|
823
836
|
}
|
|
824
|
-
class
|
|
837
|
+
class Te {
|
|
825
838
|
constructor(e, t, i) {
|
|
826
839
|
this.adapter = t, this.state = w(e), this.model = i;
|
|
827
840
|
}
|
|
@@ -853,32 +866,32 @@ class we {
|
|
|
853
866
|
const e = w(this.state);
|
|
854
867
|
for (const [t, i] of this.submissionPreviews)
|
|
855
868
|
e.messages.some((n) => n.id === t) || (e.messages.push({ ...i.message, attachments: i.message.attachments?.map((n) => ({ ...n })) }), e.segments && (e.segments = [...e.segments, { id: t, userMessageId: t, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, i.pending && (e.activeResponseUserMessageId = t, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), i.error && (e.lastError = i.error, e.lastErrorCode = "message_delivery_failed"));
|
|
856
|
-
return this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed"), this.pendingStop ?
|
|
869
|
+
return this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed"), this.pendingStop ? ce(e, "", "stopping", this.pendingStop.userMessageIds) : e;
|
|
857
870
|
}
|
|
858
871
|
updateProjection(e, t, i, n, r) {
|
|
859
872
|
if (this.destroyed) return;
|
|
860
|
-
const
|
|
861
|
-
(
|
|
862
|
-
for (const
|
|
863
|
-
|
|
864
|
-
if (this.state = w(e),
|
|
865
|
-
for (const
|
|
866
|
-
if (
|
|
867
|
-
const d =
|
|
868
|
-
|
|
873
|
+
const o = this.getState();
|
|
874
|
+
(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());
|
|
875
|
+
for (const a of e.messages)
|
|
876
|
+
a.role === "user" && this.submissionPreviews.delete(a.id);
|
|
877
|
+
if (this.state = w(e), o.user?.id === e.user?.id)
|
|
878
|
+
for (const a of this.state.messages) {
|
|
879
|
+
if (a.role !== "user" || !a.attachments?.length) continue;
|
|
880
|
+
const d = o.messages.find((c) => c.role === "user" && c.id === a.id);
|
|
881
|
+
o.sessionId !== e.sessionId && !(o.sessionId === null && d) || (a.attachments = pe(d?.attachments, a.attachments));
|
|
869
882
|
}
|
|
870
883
|
if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
|
|
871
884
|
this.sessionHistoryState = j(i);
|
|
872
|
-
for (const
|
|
873
|
-
|
|
885
|
+
for (const a of this.sessionHistoryListeners)
|
|
886
|
+
a(this.getSessionHistoryState());
|
|
874
887
|
}
|
|
875
888
|
if (n && JSON.stringify(n) !== JSON.stringify(this.interactions)) {
|
|
876
|
-
this.interactions = n.map((
|
|
877
|
-
for (const
|
|
889
|
+
this.interactions = n.map((a) => ({ ...a }));
|
|
890
|
+
for (const a of this.interactionListeners) a(this.getInteractions());
|
|
878
891
|
}
|
|
879
892
|
if (r !== void 0 && JSON.stringify(r) !== JSON.stringify(this.account)) {
|
|
880
893
|
this.account = r ? { ...r } : null;
|
|
881
|
-
for (const
|
|
894
|
+
for (const a of this.accountListeners) a(this.getAccount());
|
|
882
895
|
}
|
|
883
896
|
this.emit("state", this.getState());
|
|
884
897
|
}
|
|
@@ -900,7 +913,7 @@ class we {
|
|
|
900
913
|
this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
|
|
901
914
|
}
|
|
902
915
|
reportOperationTiming(e) {
|
|
903
|
-
!this.destroyed &&
|
|
916
|
+
!this.destroyed && M(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
|
|
904
917
|
});
|
|
905
918
|
}
|
|
906
919
|
reportResponseVisibility(e) {
|
|
@@ -908,7 +921,7 @@ class we {
|
|
|
908
921
|
});
|
|
909
922
|
}
|
|
910
923
|
reportInvalidStateTransition(e, t, i) {
|
|
911
|
-
i !== void 0 &&
|
|
924
|
+
i !== void 0 && !K(i) || this.adapter.dispatch({
|
|
912
925
|
type: "runtime.report_invalid_state_transition",
|
|
913
926
|
reason: e,
|
|
914
927
|
clientMessageId: t,
|
|
@@ -916,15 +929,16 @@ class we {
|
|
|
916
929
|
}).catch(() => {
|
|
917
930
|
});
|
|
918
931
|
}
|
|
919
|
-
reportDisplayedError(e, t, i, n) {
|
|
920
|
-
const
|
|
921
|
-
n !== void 0 && !
|
|
932
|
+
reportDisplayedError(e, t, i, n, r) {
|
|
933
|
+
const o = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
|
|
934
|
+
n !== void 0 && !U(n) || r !== void 0 && !L(r) || this.adapter.dispatch({
|
|
922
935
|
type: "runtime.report_displayed_error",
|
|
923
936
|
reason: e,
|
|
924
937
|
errorFingerprint: t,
|
|
925
938
|
...n ? { renderedError: n } : {},
|
|
926
|
-
...
|
|
927
|
-
...
|
|
939
|
+
...r ? { historyRefreshFailure: r } : {},
|
|
940
|
+
...z(o) ? { httpRequest: o } : {},
|
|
941
|
+
...i ? { displayedMessage: de(i) } : {}
|
|
928
942
|
}).catch(() => {
|
|
929
943
|
});
|
|
930
944
|
}
|
|
@@ -932,7 +946,7 @@ class we {
|
|
|
932
946
|
const i = e.trim(), n = t.attachments ?? [];
|
|
933
947
|
if (!i && n.length === 0) return Promise.resolve(null);
|
|
934
948
|
this.pendingStop = null, this.stopError = null;
|
|
935
|
-
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()),
|
|
949
|
+
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), o = t.submittedAt ?? Date.now(), a = this.submissionGeneration;
|
|
936
950
|
this.pendingTransfers.set(r, n.flatMap((c) => c.id ? [c.id] : [])), this.submissionPreviews.set(r, { pending: !0, message: {
|
|
937
951
|
id: r,
|
|
938
952
|
role: "user",
|
|
@@ -940,13 +954,13 @@ class we {
|
|
|
940
954
|
createdAt: "",
|
|
941
955
|
attachments: n.map((c) => ({ ...c }))
|
|
942
956
|
} });
|
|
943
|
-
const d = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt:
|
|
957
|
+
const d = this.sendMessageNow(i, { ...t, clientMessageId: r, submittedAt: o }, a);
|
|
944
958
|
return this.emit("state", this.getState()), d.finally(() => {
|
|
945
959
|
this.pendingTransfers.delete(r);
|
|
946
960
|
});
|
|
947
961
|
}
|
|
948
962
|
async sendMessageNow(e, t, i) {
|
|
949
|
-
const n = e, r = t.clientMessageId,
|
|
963
|
+
const n = e, r = t.clientMessageId, o = k((c) => {
|
|
950
964
|
i === this.submissionGeneration && this.reportOperationTiming(c);
|
|
951
965
|
}, {
|
|
952
966
|
operation: "send",
|
|
@@ -955,11 +969,11 @@ class we {
|
|
|
955
969
|
clientMessageId: r,
|
|
956
970
|
sessionId: this.state.sessionId
|
|
957
971
|
});
|
|
958
|
-
|
|
959
|
-
let
|
|
972
|
+
o.mark("submit");
|
|
973
|
+
let a = t.attachments ?? [], d = !1;
|
|
960
974
|
if (i !== this.submissionGeneration) return null;
|
|
961
975
|
try {
|
|
962
|
-
if (!await
|
|
976
|
+
if (!await o.measure("staging_ipc", async () => {
|
|
963
977
|
const l = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
|
|
964
978
|
type: "conversation.stage",
|
|
965
979
|
initiatedBy: t.initiatedBy,
|
|
@@ -969,27 +983,27 @@ class we {
|
|
|
969
983
|
clientMessageId: r,
|
|
970
984
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
971
985
|
// Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
|
|
972
|
-
attachments:
|
|
986
|
+
attachments: a.length > 0 ? a.map(x) : void 0,
|
|
973
987
|
submittedAt: t.submittedAt
|
|
974
988
|
}) });
|
|
975
989
|
return l ? (await l.result, l) : null;
|
|
976
990
|
}) || i !== this.submissionGeneration) return null;
|
|
977
|
-
if (d = !0,
|
|
991
|
+
if (d = !0, a.length > 0) {
|
|
978
992
|
if (!this.adapter.uploadAttachment)
|
|
979
993
|
throw new Error("The runtime does not support attachments.");
|
|
980
994
|
const l = [];
|
|
981
|
-
for (const u of
|
|
995
|
+
for (const u of a) {
|
|
982
996
|
if (u.sandboxPath || u.storageKey) {
|
|
983
997
|
l.push(u);
|
|
984
998
|
continue;
|
|
985
999
|
}
|
|
986
|
-
const
|
|
987
|
-
if (!
|
|
988
|
-
if (l.push(await
|
|
1000
|
+
const P = u.id ? this.attachmentFiles.get(u.id) : void 0;
|
|
1001
|
+
if (!P) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
|
|
1002
|
+
if (l.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(P, u, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
|
|
989
1003
|
}
|
|
990
|
-
|
|
1004
|
+
a = l;
|
|
991
1005
|
}
|
|
992
|
-
const h = await
|
|
1006
|
+
const h = await o.measure("send_ipc", () => this.adapter.dispatch({
|
|
993
1007
|
type: "conversation.send",
|
|
994
1008
|
content: n,
|
|
995
1009
|
clientMessageId: r,
|
|
@@ -997,7 +1011,7 @@ class we {
|
|
|
997
1011
|
invocation: t.invocation,
|
|
998
1012
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
999
1013
|
...t.automationOnboarding ? { automationOnboarding: !0 } : {},
|
|
1000
|
-
attachments:
|
|
1014
|
+
attachments: a.length > 0 ? a.map(x) : void 0
|
|
1001
1015
|
}));
|
|
1002
1016
|
if (i !== this.submissionGeneration) return null;
|
|
1003
1017
|
for (const l of t.attachments ?? [])
|
|
@@ -1005,14 +1019,14 @@ class we {
|
|
|
1005
1019
|
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), h?.clientMessageId ?? r;
|
|
1006
1020
|
} catch (c) {
|
|
1007
1021
|
if (i !== this.submissionGeneration) return null;
|
|
1008
|
-
if (
|
|
1022
|
+
if (G(c))
|
|
1009
1023
|
for (const l of t.attachments ?? [])
|
|
1010
1024
|
l.id && this.attachmentFiles.delete(l.id);
|
|
1011
1025
|
const h = this.submissionPreviews.get(r);
|
|
1012
|
-
throw h && (h.pending = !1, h.error =
|
|
1026
|
+
throw h && (h.pending = !1, h.error = S(c).message, this.emit("state", this.getState())), d && await this.adapter.dispatch({
|
|
1013
1027
|
type: "conversation.fail_staged",
|
|
1014
1028
|
clientMessageId: r,
|
|
1015
|
-
message:
|
|
1029
|
+
message: S(c).message
|
|
1016
1030
|
}), c;
|
|
1017
1031
|
}
|
|
1018
1032
|
}
|
|
@@ -1040,8 +1054,8 @@ class we {
|
|
|
1040
1054
|
const e = this.getState(), t = this.cancelPendingSubmissions(), i = [...new Set([
|
|
1041
1055
|
...t,
|
|
1042
1056
|
e.activeResponseUserMessageId,
|
|
1043
|
-
e.messages.filter((
|
|
1044
|
-
].filter((
|
|
1057
|
+
e.messages.filter((a) => a.role === "user").slice(-1)[0]?.id
|
|
1058
|
+
].filter((a) => !!a))], n = k((a) => this.reportOperationTiming(a), {
|
|
1045
1059
|
operation: "stop",
|
|
1046
1060
|
layer: "renderer",
|
|
1047
1061
|
requestId: crypto.randomUUID(),
|
|
@@ -1051,15 +1065,15 @@ class we {
|
|
|
1051
1065
|
n.mark("stop");
|
|
1052
1066
|
const r = { userMessageIds: i, promise: Promise.resolve() };
|
|
1053
1067
|
this.pendingStop = r, r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
|
|
1054
|
-
}, (
|
|
1055
|
-
this.pendingStop === r && (this.stopError =
|
|
1068
|
+
}, (a) => {
|
|
1069
|
+
this.pendingStop === r && (this.stopError = S(a).message);
|
|
1056
1070
|
}).finally(() => {
|
|
1057
1071
|
this.pendingStop === r && (this.pendingStop = null, this.emit("state", this.getState()));
|
|
1058
1072
|
}), this.emit("state", this.getState());
|
|
1059
|
-
const
|
|
1060
|
-
return this.operationQueue =
|
|
1073
|
+
const o = r.promise;
|
|
1074
|
+
return this.operationQueue = o.then(() => {
|
|
1061
1075
|
}, () => {
|
|
1062
|
-
}),
|
|
1076
|
+
}), o.then(() => {
|
|
1063
1077
|
});
|
|
1064
1078
|
}
|
|
1065
1079
|
cancelPendingSubmissions() {
|
|
@@ -1165,7 +1179,7 @@ class we {
|
|
|
1165
1179
|
for (const n of i ?? []) n(t);
|
|
1166
1180
|
}
|
|
1167
1181
|
}
|
|
1168
|
-
function
|
|
1182
|
+
function pe(s, e) {
|
|
1169
1183
|
if (!e || !s) return e;
|
|
1170
1184
|
const t = /* @__PURE__ */ new Map();
|
|
1171
1185
|
for (const i of s) {
|
|
@@ -1185,7 +1199,7 @@ function w(s) {
|
|
|
1185
1199
|
messages: s.messages.map((e) => {
|
|
1186
1200
|
const t = {
|
|
1187
1201
|
...e,
|
|
1188
|
-
attachments: e.attachments?.map((
|
|
1202
|
+
attachments: e.attachments?.map((o) => ({ ...o }))
|
|
1189
1203
|
}, i = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
|
|
1190
1204
|
return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
|
|
1191
1205
|
value: r,
|
|
@@ -1205,32 +1219,32 @@ function j(s) {
|
|
|
1205
1219
|
return {
|
|
1206
1220
|
...s,
|
|
1207
1221
|
data: s.data ? y({
|
|
1208
|
-
entities:
|
|
1222
|
+
entities: B(s.data).map((e) => ({ ...e })),
|
|
1209
1223
|
nextCursor: s.data.nextCursor
|
|
1210
1224
|
}) : null
|
|
1211
1225
|
};
|
|
1212
1226
|
}
|
|
1213
1227
|
export {
|
|
1214
1228
|
Q as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
|
|
1215
|
-
|
|
1229
|
+
Ie as ProductAgentInteractionManager,
|
|
1216
1230
|
O as ProductAgentQueryController,
|
|
1217
|
-
|
|
1218
|
-
|
|
1231
|
+
Te as ProductAgentRemoteRuntimeClient,
|
|
1232
|
+
be as ProductAgentSessionHistoryManager,
|
|
1219
1233
|
Se as ProductAgentTaskPageTitleController,
|
|
1220
|
-
|
|
1234
|
+
ye as canSubmitPersonalProductAgentMessage,
|
|
1221
1235
|
_e as createLocalStorageInteractionDecisionStorage,
|
|
1222
1236
|
m as createProductAgentQueryState,
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1237
|
+
Ae as createProductAgentTaskPageTitleDocument,
|
|
1238
|
+
X as formatProductAgentTaskPageTitle,
|
|
1239
|
+
fe as hasProductAgentPaidCreditFallback,
|
|
1240
|
+
G as isProductAgentAuthReconnectError,
|
|
1241
|
+
we as isProductAgentRuntimeCommand,
|
|
1242
|
+
F as mergeProductAgentEntityPages,
|
|
1229
1243
|
y as normalizeProductAgentEntityPage,
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1244
|
+
J as readLocalStorageInteractionDecisions,
|
|
1245
|
+
ge as reconcileProductAgentSubmissionGate,
|
|
1246
|
+
me as resolveProductAgentBillingPresentation,
|
|
1247
|
+
ve as resolveProductAgentComposerAction,
|
|
1248
|
+
he as resolveProductAgentWidgetPresentation,
|
|
1249
|
+
B as selectProductAgentQueryEntities
|
|
1236
1250
|
};
|