@pluno/product-agent-web 0.1.245 → 0.1.246
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/conversationAdapters.d.ts +1 -0
- package/dist/adapters/web/conversationPresentation.d.ts +7 -2
- package/dist/core/conversation/contracts.d.ts +2 -0
- package/dist/core/conversation/deliveryContracts.d.ts +22 -1
- package/dist/core/conversation/selectors.d.ts +7 -0
- package/dist/index.d.ts +2 -2
- package/dist/interruptState.d.ts +1 -1
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +204 -198
- package/dist/product-agent-sdk.js +4132 -3945
- package/dist/product-agent-widget.js +3797 -3613
- package/dist/runtimeClient.d.ts +3 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(s) {
|
|
2
2
|
return {
|
|
3
3
|
key: s,
|
|
4
4
|
status: "not_requested",
|
|
@@ -8,9 +8,9 @@ function m(s) {
|
|
|
8
8
|
updatedAt: null
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
class
|
|
11
|
+
class E {
|
|
12
12
|
constructor(e, t, i = (n, r) => r) {
|
|
13
|
-
this.loader = t, this.merge = i, this.state =
|
|
13
|
+
this.loader = t, this.merge = i, this.state = f(e);
|
|
14
14
|
}
|
|
15
15
|
loader;
|
|
16
16
|
merge;
|
|
@@ -25,10 +25,10 @@ class O {
|
|
|
25
25
|
return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
|
|
26
26
|
}
|
|
27
27
|
setKey(e) {
|
|
28
|
-
e !== this.state.key && (this.state =
|
|
28
|
+
e !== this.state.key && (this.state = f(e), this.trailingLoad = null, this.publish());
|
|
29
29
|
}
|
|
30
30
|
reset() {
|
|
31
|
-
this.state =
|
|
31
|
+
this.state = f(this.state.key), this.trailingLoad = null, this.publish();
|
|
32
32
|
}
|
|
33
33
|
invalidate() {
|
|
34
34
|
this.state = {
|
|
@@ -93,34 +93,34 @@ function y(s) {
|
|
|
93
93
|
nextCursor: s.nextCursor
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function z(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 F(s) {
|
|
104
104
|
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function pe(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 he(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 ge(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 fe(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
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 me(s) {
|
|
124
124
|
const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
|
|
125
125
|
return s.hasRunningAssistantTurn && !e ? {
|
|
126
126
|
action: "stop",
|
|
@@ -130,13 +130,13 @@ function ve(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 B = "Pluno is reconnecting. Try again in a moment.";
|
|
134
|
+
function Q(s) {
|
|
135
|
+
return (s instanceof Error ? s.message : s) === B;
|
|
136
136
|
}
|
|
137
|
-
class
|
|
137
|
+
class ve {
|
|
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 E(
|
|
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 be {
|
|
|
144
144
|
nextCursor: r.nextCursor
|
|
145
145
|
}))
|
|
146
146
|
),
|
|
147
|
-
|
|
148
|
-
), this.pinnedQuery = new
|
|
147
|
+
z
|
|
148
|
+
), this.pinnedQuery = new E(
|
|
149
149
|
`${e}:pinned`,
|
|
150
150
|
async () => y({
|
|
151
151
|
entities: await this.loadAllPinned(),
|
|
@@ -167,8 +167,8 @@ class be {
|
|
|
167
167
|
activityReconciliationScheduled = !1;
|
|
168
168
|
getState() {
|
|
169
169
|
const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), i = [
|
|
170
|
-
...
|
|
171
|
-
...
|
|
170
|
+
...h(t.data),
|
|
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
174
|
), o = Array.from(this.optimisticEntities.values()).filter((d) => !n.has(d.id)).reverse(), a = e.data || t.data || o.length > 0 ? y({
|
|
@@ -177,7 +177,7 @@ class be {
|
|
|
177
177
|
}) : null;
|
|
178
178
|
return {
|
|
179
179
|
key: e.key.slice(0, -7),
|
|
180
|
-
status:
|
|
180
|
+
status: G(e, t),
|
|
181
181
|
data: a,
|
|
182
182
|
error: e.error ?? t.error,
|
|
183
183
|
requestId: Math.max(e.requestId, t.requestId),
|
|
@@ -243,8 +243,8 @@ class be {
|
|
|
243
243
|
}
|
|
244
244
|
reconcileDurableEntities() {
|
|
245
245
|
const e = [
|
|
246
|
-
...
|
|
247
|
-
...
|
|
246
|
+
...h(this.pinnedQuery.getState().data),
|
|
247
|
+
...h(this.recentQuery.getState().data)
|
|
248
248
|
], t = new Set(e.map((i) => i.id));
|
|
249
249
|
for (const i of this.optimisticEntities.keys())
|
|
250
250
|
t.has(i) && this.optimisticEntities.delete(i);
|
|
@@ -283,47 +283,47 @@ class be {
|
|
|
283
283
|
for (const e of this.listeners) e(this.getState());
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function h(s) {
|
|
287
287
|
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function G(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 O(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")}`;
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function v(s) {
|
|
298
298
|
if (s === null || typeof s == "string" || typeof s == "boolean") return !0;
|
|
299
299
|
if (typeof s == "number") return Number.isFinite(s);
|
|
300
|
-
if (Array.isArray(s)) return s.every(
|
|
300
|
+
if (Array.isArray(s)) return s.every(v);
|
|
301
301
|
if (typeof s != "object") return !1;
|
|
302
302
|
const e = Object.getPrototypeOf(s);
|
|
303
|
-
return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(
|
|
303
|
+
return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(v);
|
|
304
304
|
}
|
|
305
|
-
function
|
|
306
|
-
return s !== null && typeof s == "object" && !Object.isFrozen(s) && (Object.values(s).forEach(
|
|
305
|
+
function j(s) {
|
|
306
|
+
return s !== null && typeof s == "object" && !Object.isFrozen(s) && (Object.values(s).forEach(j), Object.freeze(s)), s;
|
|
307
307
|
}
|
|
308
|
-
function
|
|
309
|
-
if (!
|
|
308
|
+
function H(s) {
|
|
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 Z(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, o) =>
|
|
316
|
+
const i = Object.values(s.items).sort((r, o) => O(r.created_at).localeCompare(O(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 be {
|
|
324
324
|
constructor(e, t = null) {
|
|
325
325
|
this.storage = e, t && (this.decisions = new Map(
|
|
326
|
-
t.filter(
|
|
326
|
+
t.filter(w).map((i) => [this.getDecisionKey(i), i])
|
|
327
327
|
), this.initialized = !0);
|
|
328
328
|
}
|
|
329
329
|
storage;
|
|
@@ -345,7 +345,7 @@ class Ie {
|
|
|
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
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,
|
|
348
|
+
this.sources.set(i, j(H({ ...t, lifecycle: r, payload: o }))), t.payload.kind === "integration_auth" && this.invalidateAuth(t.payload.request_id);
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
/** @internal */
|
|
@@ -371,7 +371,7 @@ class Ie {
|
|
|
371
371
|
userPrompt: a?.type === "user_message" ? a.data.content : "",
|
|
372
372
|
assistantAnswer: ""
|
|
373
373
|
},
|
|
374
|
-
terminal: !o.wait_for_terminal ||
|
|
374
|
+
terminal: !o.wait_for_terminal || Z(i, r.user_message_id)
|
|
375
375
|
};
|
|
376
376
|
} else o.kind === "integration_auth" ? t.integrations.push({
|
|
377
377
|
revision: r.version,
|
|
@@ -401,7 +401,7 @@ class Ie {
|
|
|
401
401
|
if (this.initialized) return;
|
|
402
402
|
const e = await this.storage.load();
|
|
403
403
|
this.decisions = new Map(
|
|
404
|
-
e.filter(
|
|
404
|
+
e.filter(w).map((t) => [this.getDecisionKey(t), t])
|
|
405
405
|
), this.initialized = !0;
|
|
406
406
|
}
|
|
407
407
|
isEligible(e, t = Date.now()) {
|
|
@@ -437,7 +437,7 @@ class Ie {
|
|
|
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 (!N(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,
|
|
@@ -463,51 +463,51 @@ class Ie {
|
|
|
463
463
|
return null;
|
|
464
464
|
}
|
|
465
465
|
getDecisionKey(e) {
|
|
466
|
-
const t =
|
|
466
|
+
const t = I(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 `${I(e.scope)}:interaction:${e.key}`;
|
|
471
471
|
}
|
|
472
472
|
getCategoryKey(e) {
|
|
473
|
-
return `${
|
|
473
|
+
return `${I(e.scope)}:category:${e.category}`;
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function Ie(s, e) {
|
|
477
477
|
return {
|
|
478
|
-
load: async () =>
|
|
478
|
+
load: async () => V(s, e),
|
|
479
479
|
save: async (t) => s.setItem(e, JSON.stringify(t))
|
|
480
480
|
};
|
|
481
481
|
}
|
|
482
|
-
function
|
|
482
|
+
function V(s, e) {
|
|
483
483
|
const t = s.getItem(e);
|
|
484
484
|
if (!t) return [];
|
|
485
485
|
const i = JSON.parse(t);
|
|
486
|
-
return Array.isArray(i) ? i.filter(
|
|
486
|
+
return Array.isArray(i) ? i.filter(w) : [];
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function I(s) {
|
|
489
489
|
return `${s.level}:${s.key}`;
|
|
490
490
|
}
|
|
491
|
-
function
|
|
491
|
+
function N(s) {
|
|
492
492
|
return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
|
|
493
493
|
}
|
|
494
|
-
function
|
|
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") && N(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
|
|
498
498
|
}
|
|
499
|
-
const
|
|
499
|
+
const J = {
|
|
500
500
|
working: "⏳",
|
|
501
501
|
completed: "✅",
|
|
502
502
|
failed: "❗",
|
|
503
503
|
stopped: "⏹️"
|
|
504
|
-
},
|
|
505
|
-
function
|
|
506
|
-
if (!e) return
|
|
507
|
-
const t =
|
|
504
|
+
}, W = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
505
|
+
function Y(s, e) {
|
|
506
|
+
if (!e) return b(s);
|
|
507
|
+
const t = b(s), i = `${J[e]} Pluno`;
|
|
508
508
|
return t ? `${i}: ${t}` : i;
|
|
509
509
|
}
|
|
510
|
-
class
|
|
510
|
+
class _e {
|
|
511
511
|
constructor(e) {
|
|
512
512
|
this.titleDocument = e;
|
|
513
513
|
}
|
|
@@ -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 = b(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 ? b(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 = Y(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 Se(s) {
|
|
549
549
|
return {
|
|
550
550
|
getTitle: () => s.title,
|
|
551
551
|
setTitle: (e) => {
|
|
@@ -561,42 +561,42 @@ function Ae(s) {
|
|
|
561
561
|
}
|
|
562
562
|
};
|
|
563
563
|
}
|
|
564
|
-
function
|
|
565
|
-
return s.replace(
|
|
564
|
+
function b(s) {
|
|
565
|
+
return s.replace(W, "");
|
|
566
566
|
}
|
|
567
567
|
const p = (s) => typeof s == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(s) ? s : null;
|
|
568
|
-
function
|
|
568
|
+
function X(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 $(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 q = ["messageKeys", "canonicalItemKeys", "terminalResponseKeys", "toolCallKeys", "activeResponseKeys"], T = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s), m = (s) => s === null || T(s), ee = (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 K(s) {
|
|
580
580
|
if (!s || typeof s != "object") return !1;
|
|
581
581
|
const e = s;
|
|
582
|
-
return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) &&
|
|
582
|
+
return Object.keys(s).every((t) => ["sessionId", "itemId", "userMessageId", "createdAt", "runId", "retryable"].includes(t)) && m(e.sessionId) && T(e.itemId) && m(e.userMessageId) && (e.retryable === void 0 || typeof e.retryable == "boolean") && m(e.runId) && (e.createdAt === null || ee(e.createdAt));
|
|
583
583
|
}
|
|
584
|
-
function
|
|
584
|
+
function te(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 || X(e.owner));
|
|
588
588
|
}
|
|
589
|
-
function
|
|
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) => [...q, "sessionId", "runtimeItemCount", "welcome", "truncated", "thinkingSequence", "context"].includes(r)) && (n.context === void 0 || te(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" && q.every((r) => Array.isArray(n[r]) && n[r].length <= 20 && n[r].every(T));
|
|
595
595
|
}, t = s;
|
|
596
596
|
return (t.before === null || e(t.before)) && e(t.current);
|
|
597
597
|
}
|
|
598
|
-
function
|
|
599
|
-
if (s.details !== void 0 && !
|
|
598
|
+
function se(s) {
|
|
599
|
+
if (s.details !== void 0 && !v(s.details))
|
|
600
600
|
throw new TypeError("Product Agent transported error details must be JSON-safe.");
|
|
601
601
|
return {
|
|
602
602
|
code: s.code,
|
|
@@ -605,22 +605,24 @@ function ie(s) {
|
|
|
605
605
|
...s.details === void 0 ? {} : { details: s.details }
|
|
606
606
|
};
|
|
607
607
|
}
|
|
608
|
-
function
|
|
608
|
+
function _(s, e = "runtime_error") {
|
|
609
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
|
+
...o.allocation === "unissued" ? { allocation: "unissued" } : {},
|
|
611
|
+
...["unissued", "rejected"].includes(String(o.acceptance)) ? { acceptance: String(o.acceptance) } : {},
|
|
610
612
|
...typeof o.securitySettingsUrl == "string" ? { securitySettingsUrl: o.securitySettingsUrl } : {},
|
|
611
613
|
...typeof o.transportCode == "string" && /^[a-z0-9_]{1,80}$/.test(o.transportCode) ? { transportCode: o.transportCode } : {},
|
|
612
614
|
...typeof o.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(o.requestId) ? { requestId: o.requestId } : {},
|
|
613
615
|
...typeof o.durationMs == "number" && Number.isFinite(o.durationMs) && o.durationMs >= 0 ? { durationMs: o.durationMs } : {},
|
|
614
616
|
...typeof o.successfulRequests == "number" && Number.isSafeInteger(o.successfulRequests) && o.successfulRequests >= 0 ? { successfulRequests: o.successfulRequests } : {}
|
|
615
617
|
};
|
|
616
|
-
return
|
|
618
|
+
return se({
|
|
617
619
|
code: n,
|
|
618
620
|
message: i.trim() && i.trim() !== "[object Object]" ? i : "The Product Agent operation failed. Try again.",
|
|
619
621
|
retryable: !!(t && "retryable" in t && t.retryable === !0),
|
|
620
622
|
...Object.keys(a).length ? { details: a } : {}
|
|
621
623
|
});
|
|
622
624
|
}
|
|
623
|
-
function
|
|
625
|
+
function L(s) {
|
|
624
626
|
if (!s || typeof s != "object") return !1;
|
|
625
627
|
const e = s, t = (i) => Number.isSafeInteger(i) && i >= 0;
|
|
626
628
|
return Object.keys(e).every((i) => [
|
|
@@ -644,7 +646,7 @@ function z(s) {
|
|
|
644
646
|
"upstreamTraceId"
|
|
645
647
|
].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));
|
|
646
648
|
}
|
|
647
|
-
const
|
|
649
|
+
const ie = [
|
|
648
650
|
"submit",
|
|
649
651
|
"stop",
|
|
650
652
|
"staging_ipc",
|
|
@@ -680,15 +682,15 @@ const ne = [
|
|
|
680
682
|
"stopping_painted",
|
|
681
683
|
"progress_painted",
|
|
682
684
|
"stopped_painted"
|
|
683
|
-
],
|
|
684
|
-
let
|
|
685
|
-
const
|
|
686
|
-
function
|
|
685
|
+
], ne = Math.random().toString(36).slice(2);
|
|
686
|
+
let re = 0;
|
|
687
|
+
const R = () => `timing:${ne}:${++re}`, g = (s) => typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
|
|
688
|
+
function P(s) {
|
|
687
689
|
if (!s || typeof s != "object") return !1;
|
|
688
690
|
const e = s;
|
|
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", "email"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) &&
|
|
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) && ie.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;
|
|
690
692
|
}
|
|
691
|
-
function
|
|
693
|
+
function C(s, e) {
|
|
692
694
|
if (!s) return {
|
|
693
695
|
mark: (n) => {
|
|
694
696
|
},
|
|
@@ -703,13 +705,13 @@ function k(s, e) {
|
|
|
703
705
|
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
704
706
|
durationMs: Math.max(0, Math.round(performance.now() - o))
|
|
705
707
|
};
|
|
706
|
-
s &&
|
|
708
|
+
s && P(d) && Promise.resolve().then(() => s(d)).catch(() => {
|
|
707
709
|
});
|
|
708
710
|
};
|
|
709
711
|
return {
|
|
710
|
-
mark: (n) => i(n, "observed", t,
|
|
712
|
+
mark: (n) => i(n, "observed", t, R()),
|
|
711
713
|
measure(n, r) {
|
|
712
|
-
const o = performance.now(), a =
|
|
714
|
+
const o = performance.now(), a = R();
|
|
713
715
|
return i(n, "started", o, a), r().then(
|
|
714
716
|
(d) => (i(n, "completed", o, a), d),
|
|
715
717
|
(d) => {
|
|
@@ -719,45 +721,45 @@ function k(s, e) {
|
|
|
719
721
|
}
|
|
720
722
|
};
|
|
721
723
|
}
|
|
722
|
-
const
|
|
723
|
-
function
|
|
724
|
+
const S = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
|
|
725
|
+
function oe(s) {
|
|
724
726
|
if (!s || typeof s != "object") return !1;
|
|
725
727
|
const e = s;
|
|
726
|
-
return typeof e.observedAt == "string" && e.observedAt.length <= 40 && Number.isFinite(Date.parse(e.observedAt)) &&
|
|
728
|
+
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";
|
|
727
729
|
}
|
|
728
|
-
const
|
|
729
|
-
function
|
|
730
|
+
const x = 500;
|
|
731
|
+
function ae(s) {
|
|
730
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();
|
|
731
|
-
return e.length >
|
|
733
|
+
return e.length > x ? `${e.slice(0, x - 1)}…` : e;
|
|
732
734
|
}
|
|
733
|
-
function
|
|
734
|
-
const
|
|
735
|
+
function de(s, e, t = "stopped", i, n = "Run stopped by user.") {
|
|
736
|
+
const r = new Set(i ?? [
|
|
735
737
|
s.assistantDraftRespondsToUserMessageId,
|
|
736
738
|
s.activeResponseUserMessageId,
|
|
737
|
-
s.messages.filter((
|
|
738
|
-
].filter((
|
|
739
|
-
for (const
|
|
740
|
-
|
|
741
|
-
const
|
|
742
|
-
...
|
|
743
|
-
...
|
|
739
|
+
s.messages.filter((d) => d.role === "user").slice(-1)[0]?.id
|
|
740
|
+
].filter((d) => !!d)), o = s.messages.filter((d) => !(d.dataType === "run_status" && d.loading && r.has(d.respondsToUserMessageId ?? ""))).map((d) => r.has(d.respondsToUserMessageId ?? "") ? { ...d, loading: !1 } : d);
|
|
741
|
+
for (const d of r)
|
|
742
|
+
o.some((c) => c.respondsToUserMessageId === d && (c.dataType === "run_status" || c.dataType === "run_error" || c.role === "assistant" && c.phase !== "commentary")) || o.some((c) => c.role === "user" && c.id === d) && o.push({ id: `local-interrupted:${d}`, role: "system", dataType: "run_status", provisional: t === "stopping", content: t === "stopping" ? "Stopping…" : n, createdAt: e, respondsToUserMessageId: d });
|
|
743
|
+
const a = s.segments?.map((d) => ({ ...d, outcomeIds: [
|
|
744
|
+
...d.outcomeIds,
|
|
745
|
+
...o.filter((c) => c.id === `local-interrupted:${d.userMessageId}` && !d.outcomeIds.includes(c.id)).map((c) => c.id)
|
|
744
746
|
] }));
|
|
745
747
|
return {
|
|
746
748
|
...s,
|
|
747
|
-
messages:
|
|
749
|
+
messages: o,
|
|
748
750
|
isThinking: !1,
|
|
749
751
|
isRetrying: !1,
|
|
750
752
|
pendingMessageStatus: null,
|
|
751
753
|
turnPhase: null,
|
|
752
|
-
segments:
|
|
754
|
+
segments: a,
|
|
753
755
|
activity: { phase: t, activeItemId: null },
|
|
754
|
-
isLoadingSession: s.isLoadingSession &&
|
|
756
|
+
isLoadingSession: s.isLoadingSession && o.length === 0,
|
|
755
757
|
taskStatus: t === "stopped" ? "stopped" : null,
|
|
756
758
|
lastError: null,
|
|
757
759
|
lastErrorCode: null
|
|
758
760
|
};
|
|
759
761
|
}
|
|
760
|
-
const
|
|
762
|
+
const ce = {
|
|
761
763
|
"stop-without-rendered-message": "Stop is enabled while no message is rendered or the welcome screen is still visible.",
|
|
762
764
|
"in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
|
|
763
765
|
"stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
|
|
@@ -773,10 +775,10 @@ const le = {
|
|
|
773
775
|
"thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
|
|
774
776
|
"thinking-without-progress": "Thinking remained visible without progress for five minutes."
|
|
775
777
|
};
|
|
776
|
-
function
|
|
777
|
-
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(
|
|
778
|
+
function le(s) {
|
|
779
|
+
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(ce, s.slice(13));
|
|
778
780
|
}
|
|
779
|
-
function
|
|
781
|
+
function k(s) {
|
|
780
782
|
return {
|
|
781
783
|
...s.id === void 0 ? {} : { id: s.id },
|
|
782
784
|
name: s.name,
|
|
@@ -787,26 +789,27 @@ function x(s) {
|
|
|
787
789
|
...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
|
|
788
790
|
};
|
|
789
791
|
}
|
|
790
|
-
function
|
|
792
|
+
function Ae(s) {
|
|
791
793
|
if (!s || typeof s != "object" || !("type" in s)) return !1;
|
|
792
794
|
const e = s;
|
|
793
795
|
switch (e.type) {
|
|
794
796
|
case "runtime.connect":
|
|
795
797
|
case "session.new":
|
|
796
|
-
case "run.retry":
|
|
797
798
|
return !0;
|
|
799
|
+
case "run.retry":
|
|
800
|
+
return e.clientMessageId === void 0 || typeof e.clientMessageId == "string" && e.clientMessageId.length > 0 && e.clientMessageId.length <= 160;
|
|
798
801
|
case "run.stop":
|
|
799
802
|
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);
|
|
800
803
|
case "runtime.report_response_visibility":
|
|
801
|
-
return
|
|
804
|
+
return oe(e.observation);
|
|
802
805
|
case "runtime.warmup":
|
|
803
806
|
return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
|
|
804
807
|
case "runtime.report_operation_timing":
|
|
805
|
-
return
|
|
808
|
+
return P(e.timing);
|
|
806
809
|
case "runtime.report_displayed_error":
|
|
807
|
-
return (e.httpRequest === void 0 ||
|
|
810
|
+
return (e.httpRequest === void 0 || L(e.httpRequest)) && (e.historyRefreshFailure === void 0 || $(e.historyRefreshFailure)) && (e.renderedError === void 0 || K(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);
|
|
808
811
|
case "runtime.report_invalid_state_transition":
|
|
809
|
-
return (e.uiInvariant === void 0 ||
|
|
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" || le(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
|
|
810
813
|
case "runtime.widget_lifecycle":
|
|
811
814
|
return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
|
|
812
815
|
case "session.load":
|
|
@@ -834,9 +837,9 @@ function we(s) {
|
|
|
834
837
|
return !1;
|
|
835
838
|
}
|
|
836
839
|
}
|
|
837
|
-
class
|
|
840
|
+
class we {
|
|
838
841
|
constructor(e, t, i) {
|
|
839
|
-
this.adapter = t, this.state =
|
|
842
|
+
this.adapter = t, this.state = A(e), this.model = i;
|
|
840
843
|
}
|
|
841
844
|
adapter;
|
|
842
845
|
listeners = {};
|
|
@@ -845,7 +848,7 @@ class Te {
|
|
|
845
848
|
interactionListeners = /* @__PURE__ */ new Set();
|
|
846
849
|
accountListeners = /* @__PURE__ */ new Set();
|
|
847
850
|
state;
|
|
848
|
-
sessionHistoryState =
|
|
851
|
+
sessionHistoryState = f("unavailable");
|
|
849
852
|
model;
|
|
850
853
|
interactions = [];
|
|
851
854
|
account = null;
|
|
@@ -856,7 +859,7 @@ class Te {
|
|
|
856
859
|
submissionGeneration = 0;
|
|
857
860
|
pendingStop = null;
|
|
858
861
|
stopError = null;
|
|
859
|
-
stopPreviews = /* @__PURE__ */ new
|
|
862
|
+
stopPreviews = /* @__PURE__ */ new Map();
|
|
860
863
|
operationQueue = Promise.resolve();
|
|
861
864
|
destroyed = !1;
|
|
862
865
|
on(e, t) {
|
|
@@ -864,13 +867,13 @@ class Te {
|
|
|
864
867
|
return i.add(t), this.listeners[e] = i, () => i.delete(t);
|
|
865
868
|
}
|
|
866
869
|
getState() {
|
|
867
|
-
const e =
|
|
870
|
+
const e = A(this.state);
|
|
868
871
|
for (const [n, r] of this.submissionPreviews)
|
|
869
872
|
e.messages.some((o) => o.id === n) || (e.messages.push({ ...r.message, attachments: r.message.attachments?.map((o) => ({ ...o })) }), e.segments && (e.segments = [...e.segments, { id: n, userMessageId: n, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, r.pending && (e.activeResponseUserMessageId = n, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), r.error && (e.lastError = r.error, e.lastErrorCode = "message_delivery_failed"));
|
|
870
873
|
this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
|
|
871
|
-
const t = [...this.stopPreviews];
|
|
874
|
+
const t = [...this.stopPreviews.keys()];
|
|
872
875
|
if (!t.length) return e;
|
|
873
|
-
const i =
|
|
876
|
+
const i = de(e, "", "stopping", t);
|
|
874
877
|
return e.activeResponseUserMessageId && !this.stopPreviews.has(e.activeResponseUserMessageId) ? { ...e, messages: i.messages, segments: i.segments } : i;
|
|
875
878
|
}
|
|
876
879
|
updateProjection(e, t, i, n, r) {
|
|
@@ -879,17 +882,19 @@ class Te {
|
|
|
879
882
|
(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());
|
|
880
883
|
for (const a of e.messages)
|
|
881
884
|
a.role === "user" && this.submissionPreviews.delete(a.id);
|
|
882
|
-
this.state =
|
|
883
|
-
for (const a of this.stopPreviews)
|
|
884
|
-
|
|
885
|
-
|
|
885
|
+
this.state = A(e);
|
|
886
|
+
for (const [a, d] of this.stopPreviews) {
|
|
887
|
+
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 === a && !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(a);
|
|
889
|
+
}
|
|
890
|
+
if (this.pendingStop?.userMessageIds.every((a) => !this.stopPreviews.has(a)) && (this.pendingStop = null), o.user?.id === e.user?.id)
|
|
886
891
|
for (const a of this.state.messages) {
|
|
887
892
|
if (a.role !== "user" || !a.attachments?.length) continue;
|
|
888
893
|
const d = o.messages.find((c) => c.role === "user" && c.id === a.id);
|
|
889
|
-
o.sessionId !== e.sessionId && !(o.sessionId === null && d) || (a.attachments =
|
|
894
|
+
o.sessionId !== e.sessionId && !(o.sessionId === null && d) || (a.attachments = ue(d?.attachments, a.attachments));
|
|
890
895
|
}
|
|
891
896
|
if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
|
|
892
|
-
this.sessionHistoryState =
|
|
897
|
+
this.sessionHistoryState = D(i);
|
|
893
898
|
for (const a of this.sessionHistoryListeners)
|
|
894
899
|
a(this.getSessionHistoryState());
|
|
895
900
|
}
|
|
@@ -921,7 +926,7 @@ class Te {
|
|
|
921
926
|
this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
|
|
922
927
|
}
|
|
923
928
|
reportOperationTiming(e) {
|
|
924
|
-
!this.destroyed &&
|
|
929
|
+
!this.destroyed && P(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
|
|
925
930
|
});
|
|
926
931
|
}
|
|
927
932
|
reportResponseVisibility(e) {
|
|
@@ -929,7 +934,7 @@ class Te {
|
|
|
929
934
|
});
|
|
930
935
|
}
|
|
931
936
|
reportInvalidStateTransition(e, t, i) {
|
|
932
|
-
i !== void 0 && !
|
|
937
|
+
i !== void 0 && !U(i) || this.adapter.dispatch({
|
|
933
938
|
type: "runtime.report_invalid_state_transition",
|
|
934
939
|
reason: e,
|
|
935
940
|
clientMessageId: t,
|
|
@@ -939,14 +944,14 @@ class Te {
|
|
|
939
944
|
}
|
|
940
945
|
reportDisplayedError(e, t, i, n, r) {
|
|
941
946
|
const o = e === "conversation_error" && !n ? this.getState().conversationDiagnostics?.httpRequest : void 0;
|
|
942
|
-
n !== void 0 && !
|
|
947
|
+
n !== void 0 && !K(n) || r !== void 0 && !$(r) || this.adapter.dispatch({
|
|
943
948
|
type: "runtime.report_displayed_error",
|
|
944
949
|
reason: e,
|
|
945
950
|
errorFingerprint: t,
|
|
946
951
|
...n ? { renderedError: n } : {},
|
|
947
952
|
...r ? { historyRefreshFailure: r } : {},
|
|
948
|
-
...
|
|
949
|
-
...i ? { displayedMessage:
|
|
953
|
+
...L(o) ? { httpRequest: o } : {},
|
|
954
|
+
...i ? { displayedMessage: ae(i) } : {}
|
|
950
955
|
}).catch(() => {
|
|
951
956
|
});
|
|
952
957
|
}
|
|
@@ -968,7 +973,7 @@ class Te {
|
|
|
968
973
|
});
|
|
969
974
|
}
|
|
970
975
|
async sendMessageNow(e, t, i) {
|
|
971
|
-
const n = e, r = t.clientMessageId, o =
|
|
976
|
+
const n = e, r = t.clientMessageId, o = C((c) => {
|
|
972
977
|
i === this.submissionGeneration && this.reportOperationTiming(c);
|
|
973
978
|
}, {
|
|
974
979
|
operation: "send",
|
|
@@ -982,7 +987,7 @@ class Te {
|
|
|
982
987
|
if (i !== this.submissionGeneration) return null;
|
|
983
988
|
try {
|
|
984
989
|
if (!await o.measure("staging_ipc", async () => {
|
|
985
|
-
const
|
|
990
|
+
const u = await this.enqueueOperation(async () => this.destroyed || i !== this.submissionGeneration ? null : { result: this.adapter.dispatch({
|
|
986
991
|
type: "conversation.stage",
|
|
987
992
|
initiatedBy: t.initiatedBy,
|
|
988
993
|
invocation: t.invocation,
|
|
@@ -991,50 +996,49 @@ class Te {
|
|
|
991
996
|
clientMessageId: r,
|
|
992
997
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
993
998
|
// Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
|
|
994
|
-
attachments: a.length > 0 ? a.map(
|
|
999
|
+
attachments: a.length > 0 ? a.map(k) : void 0,
|
|
995
1000
|
submittedAt: t.submittedAt
|
|
996
1001
|
}) });
|
|
997
|
-
return
|
|
1002
|
+
return u ? (await u.result, u) : null;
|
|
998
1003
|
}) || i !== this.submissionGeneration) return null;
|
|
999
1004
|
if (d = !0, a.length > 0) {
|
|
1000
1005
|
if (!this.adapter.uploadAttachment)
|
|
1001
1006
|
throw new Error("The runtime does not support attachments.");
|
|
1002
|
-
const
|
|
1003
|
-
for (const
|
|
1004
|
-
if (
|
|
1005
|
-
|
|
1007
|
+
const u = [];
|
|
1008
|
+
for (const l of a) {
|
|
1009
|
+
if (l.sandboxPath || l.storageKey) {
|
|
1010
|
+
u.push(l);
|
|
1006
1011
|
continue;
|
|
1007
1012
|
}
|
|
1008
|
-
const M =
|
|
1009
|
-
if (!M) throw new Error(`Attachment bytes are unavailable for ${
|
|
1010
|
-
if (
|
|
1013
|
+
const M = l.id ? this.attachmentFiles.get(l.id) : void 0;
|
|
1014
|
+
if (!M) throw new Error(`Attachment bytes are unavailable for ${l.name}`);
|
|
1015
|
+
if (u.push(await o.measure("attachment_transfer", () => this.adapter.uploadAttachment(M, l, { clientMessageId: r }))), i !== this.submissionGeneration) return null;
|
|
1011
1016
|
}
|
|
1012
|
-
a =
|
|
1017
|
+
a = u;
|
|
1013
1018
|
}
|
|
1014
|
-
|
|
1019
|
+
if (i !== this.submissionGeneration || (await this.adapter.dispatch({
|
|
1015
1020
|
type: "conversation.send",
|
|
1016
1021
|
content: n,
|
|
1017
1022
|
clientMessageId: r,
|
|
1018
1023
|
initiatedBy: t.initiatedBy,
|
|
1019
1024
|
invocation: t.invocation,
|
|
1025
|
+
automationOnboarding: t.automationOnboarding,
|
|
1020
1026
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
l.id && this.attachmentFiles.delete(l.id);
|
|
1027
|
-
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), h?.clientMessageId ?? r;
|
|
1027
|
+
attachments: a.length > 0 ? a.map(k) : void 0
|
|
1028
|
+
}), i !== this.submissionGeneration)) return null;
|
|
1029
|
+
for (const u of t.attachments ?? [])
|
|
1030
|
+
u.id && this.attachmentFiles.delete(u.id);
|
|
1031
|
+
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
|
|
1028
1032
|
} catch (c) {
|
|
1029
1033
|
if (i !== this.submissionGeneration) return null;
|
|
1030
|
-
if (
|
|
1034
|
+
if (Q(c))
|
|
1031
1035
|
for (const l of t.attachments ?? [])
|
|
1032
1036
|
l.id && this.attachmentFiles.delete(l.id);
|
|
1033
|
-
const
|
|
1034
|
-
throw
|
|
1037
|
+
const u = this.submissionPreviews.get(r);
|
|
1038
|
+
throw u && (u.pending = !1, u.error = _(c).message, this.emit("state", this.getState())), d && await this.adapter.dispatch({
|
|
1035
1039
|
type: "conversation.fail_staged",
|
|
1036
1040
|
clientMessageId: r,
|
|
1037
|
-
message:
|
|
1041
|
+
message: _(c).message
|
|
1038
1042
|
}), c;
|
|
1039
1043
|
}
|
|
1040
1044
|
}
|
|
@@ -1045,8 +1049,8 @@ class Te {
|
|
|
1045
1049
|
return this.dispatch({ type: "session.set_model", model: e }).then(() => {
|
|
1046
1050
|
});
|
|
1047
1051
|
}
|
|
1048
|
-
retryLastMessage() {
|
|
1049
|
-
return this.dispatch({ type: "run.retry" })
|
|
1052
|
+
async retryLastMessage(e) {
|
|
1053
|
+
return await this.dispatch({ type: "run.retry", ...e ? { clientMessageId: e } : {} }), !0;
|
|
1050
1054
|
}
|
|
1051
1055
|
createLocalAttachment(e) {
|
|
1052
1056
|
const t = crypto.randomUUID();
|
|
@@ -1062,8 +1066,8 @@ class Te {
|
|
|
1062
1066
|
const e = this.getState(), t = this.cancelPendingSubmissions(!1), i = [...new Set([
|
|
1063
1067
|
...t,
|
|
1064
1068
|
e.activeResponseUserMessageId,
|
|
1065
|
-
e.messages.filter((
|
|
1066
|
-
].filter((
|
|
1069
|
+
e.messages.filter((c) => c.role === "user").slice(-1)[0]?.id
|
|
1070
|
+
].filter((c) => !!c))], n = C((c) => this.reportOperationTiming(c), {
|
|
1067
1071
|
operation: "stop",
|
|
1068
1072
|
layer: "renderer",
|
|
1069
1073
|
requestId: crypto.randomUUID(),
|
|
@@ -1073,21 +1077,23 @@ class Te {
|
|
|
1073
1077
|
n.mark("stop");
|
|
1074
1078
|
const r = { userMessageIds: i, promise: Promise.resolve() };
|
|
1075
1079
|
this.pendingStop = r;
|
|
1076
|
-
|
|
1077
|
-
const
|
|
1080
|
+
const o = !e.pendingMessageStatus && ["thinking", "steering", "queued", "stopping"].includes(this.state.activity?.phase ?? "") ? this.state.activity?.executionKey : void 0;
|
|
1081
|
+
for (const c of i)
|
|
1082
|
+
this.stopPreviews.set(c, t.includes(c) ? void 0 : o);
|
|
1083
|
+
const a = this.submissionGeneration;
|
|
1078
1084
|
r.promise = n.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...t.length ? { clientMessageIds: t } : {} })).then(() => {
|
|
1079
|
-
}, (
|
|
1080
|
-
if (
|
|
1081
|
-
for (const
|
|
1082
|
-
this.stopError =
|
|
1085
|
+
}, (c) => {
|
|
1086
|
+
if (!(a !== this.submissionGeneration || i.every((u) => !this.stopPreviews.has(u)))) {
|
|
1087
|
+
for (const u of i) this.stopPreviews.delete(u);
|
|
1088
|
+
this.stopError = _(c).message;
|
|
1083
1089
|
}
|
|
1084
1090
|
}).finally(() => {
|
|
1085
|
-
this.destroyed ||
|
|
1091
|
+
this.destroyed || a !== this.submissionGeneration || (this.pendingStop === r && (this.pendingStop = null), this.emit("state", this.getState()));
|
|
1086
1092
|
}), this.emit("state", this.getState());
|
|
1087
|
-
const
|
|
1088
|
-
return this.operationQueue =
|
|
1093
|
+
const d = r.promise;
|
|
1094
|
+
return this.operationQueue = d.then(() => {
|
|
1089
1095
|
}, () => {
|
|
1090
|
-
}),
|
|
1096
|
+
}), d.then(() => {
|
|
1091
1097
|
});
|
|
1092
1098
|
}
|
|
1093
1099
|
cancelPendingSubmissions(e = !0) {
|
|
@@ -1114,7 +1120,7 @@ class Te {
|
|
|
1114
1120
|
return t.sessionHistoryPage;
|
|
1115
1121
|
}
|
|
1116
1122
|
getSessionHistoryState() {
|
|
1117
|
-
return
|
|
1123
|
+
return D(this.sessionHistoryState);
|
|
1118
1124
|
}
|
|
1119
1125
|
subscribeSessionHistory(e) {
|
|
1120
1126
|
return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
|
|
@@ -1193,7 +1199,7 @@ class Te {
|
|
|
1193
1199
|
for (const n of i ?? []) n(t);
|
|
1194
1200
|
}
|
|
1195
1201
|
}
|
|
1196
|
-
function
|
|
1202
|
+
function ue(s, e) {
|
|
1197
1203
|
if (!e || !s) return e;
|
|
1198
1204
|
const t = /* @__PURE__ */ new Map();
|
|
1199
1205
|
for (const i of s) {
|
|
@@ -1205,7 +1211,7 @@ function pe(s, e) {
|
|
|
1205
1211
|
return n ? { ...i, previewUrl: n } : i;
|
|
1206
1212
|
});
|
|
1207
1213
|
}
|
|
1208
|
-
function
|
|
1214
|
+
function A(s) {
|
|
1209
1215
|
return {
|
|
1210
1216
|
...s,
|
|
1211
1217
|
starterPrompts: [...s.starterPrompts],
|
|
@@ -1229,36 +1235,36 @@ function w(s) {
|
|
|
1229
1235
|
activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
|
|
1230
1236
|
};
|
|
1231
1237
|
}
|
|
1232
|
-
function
|
|
1238
|
+
function D(s) {
|
|
1233
1239
|
return {
|
|
1234
1240
|
...s,
|
|
1235
1241
|
data: s.data ? y({
|
|
1236
|
-
entities:
|
|
1242
|
+
entities: F(s.data).map((e) => ({ ...e })),
|
|
1237
1243
|
nextCursor: s.data.nextCursor
|
|
1238
1244
|
}) : null
|
|
1239
1245
|
};
|
|
1240
1246
|
}
|
|
1241
1247
|
export {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
+
B as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
|
|
1249
|
+
be as ProductAgentInteractionManager,
|
|
1250
|
+
E as ProductAgentQueryController,
|
|
1251
|
+
we as ProductAgentRemoteRuntimeClient,
|
|
1252
|
+
ve as ProductAgentSessionHistoryManager,
|
|
1253
|
+
_e as ProductAgentTaskPageTitleController,
|
|
1248
1254
|
ye as canSubmitPersonalProductAgentMessage,
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1255
|
+
Ie as createLocalStorageInteractionDecisionStorage,
|
|
1256
|
+
f as createProductAgentQueryState,
|
|
1257
|
+
Se as createProductAgentTaskPageTitleDocument,
|
|
1258
|
+
Y as formatProductAgentTaskPageTitle,
|
|
1259
|
+
ge as hasProductAgentPaidCreditFallback,
|
|
1260
|
+
Q as isProductAgentAuthReconnectError,
|
|
1261
|
+
Ae as isProductAgentRuntimeCommand,
|
|
1262
|
+
z as mergeProductAgentEntityPages,
|
|
1257
1263
|
y as normalizeProductAgentEntityPage,
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
+
V as readLocalStorageInteractionDecisions,
|
|
1265
|
+
he as reconcileProductAgentSubmissionGate,
|
|
1266
|
+
fe as resolveProductAgentBillingPresentation,
|
|
1267
|
+
me as resolveProductAgentComposerAction,
|
|
1268
|
+
pe as resolveProductAgentWidgetPresentation,
|
|
1269
|
+
F as selectProductAgentQueryEntities
|
|
1264
1270
|
};
|