@pluno/product-agent-web 0.1.217 → 0.1.218
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/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +165 -167
- package/dist/product-agent-sdk.js +69 -68
- package/dist/product-agent-widget.js +11 -10
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function h(
|
|
1
|
+
function h(i) {
|
|
2
2
|
return {
|
|
3
|
-
key:
|
|
3
|
+
key: i,
|
|
4
4
|
status: "not_requested",
|
|
5
5
|
data: null,
|
|
6
6
|
error: null,
|
|
@@ -9,8 +9,8 @@ function h(s) {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
class b {
|
|
12
|
-
constructor(e, t,
|
|
13
|
-
this.loader = t, this.merge =
|
|
12
|
+
constructor(e, t, s = (n, r) => r) {
|
|
13
|
+
this.loader = t, this.merge = s, this.state = h(e);
|
|
14
14
|
}
|
|
15
15
|
loader;
|
|
16
16
|
merge;
|
|
@@ -52,16 +52,16 @@ class b {
|
|
|
52
52
|
for (; this.trailingLoad; ) {
|
|
53
53
|
const e = this.trailingLoad;
|
|
54
54
|
this.trailingLoad = null;
|
|
55
|
-
const t = this.state.key,
|
|
55
|
+
const t = this.state.key, s = this.state.requestId + 1;
|
|
56
56
|
this.state = {
|
|
57
57
|
...this.state,
|
|
58
58
|
status: e.mode === "append" ? "loading_more" : this.state.data === null ? "loading" : "refreshing",
|
|
59
59
|
error: null,
|
|
60
|
-
requestId:
|
|
60
|
+
requestId: s
|
|
61
61
|
}, this.publish();
|
|
62
62
|
try {
|
|
63
63
|
const n = await this.loader({ key: t, cursor: e.cursor });
|
|
64
|
-
if (t !== this.state.key ||
|
|
64
|
+
if (t !== this.state.key || s !== this.state.requestId) continue;
|
|
65
65
|
this.state = {
|
|
66
66
|
...this.state,
|
|
67
67
|
status: "ready",
|
|
@@ -70,7 +70,7 @@ class b {
|
|
|
70
70
|
updatedAt: Date.now()
|
|
71
71
|
}, this.publish();
|
|
72
72
|
} catch (n) {
|
|
73
|
-
if (t !== this.state.key ||
|
|
73
|
+
if (t !== this.state.key || s !== this.state.requestId) continue;
|
|
74
74
|
this.state = {
|
|
75
75
|
...this.state,
|
|
76
76
|
status: "error",
|
|
@@ -83,53 +83,53 @@ class b {
|
|
|
83
83
|
for (const e of this.listeners) e(this.state);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function p(
|
|
86
|
+
function p(i) {
|
|
87
87
|
const e = {}, t = [];
|
|
88
|
-
for (const
|
|
89
|
-
e[
|
|
88
|
+
for (const s of i.entities)
|
|
89
|
+
e[s.id] || t.push(s.id), e[s.id] = s;
|
|
90
90
|
return {
|
|
91
91
|
entitiesById: e,
|
|
92
92
|
ids: t,
|
|
93
|
-
nextCursor:
|
|
93
|
+
nextCursor: i.nextCursor
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
function _(
|
|
97
|
-
if (t === "replace" ||
|
|
98
|
-
const
|
|
96
|
+
function _(i, e, t) {
|
|
97
|
+
if (t === "replace" || i === null) return e;
|
|
98
|
+
const s = { ...i.entitiesById, ...e.entitiesById }, n = [...i.ids];
|
|
99
99
|
for (const r of e.ids)
|
|
100
|
-
|
|
101
|
-
return { entitiesById:
|
|
100
|
+
i.entitiesById[r] || n.push(r);
|
|
101
|
+
return { entitiesById: s, ids: n, nextCursor: e.nextCursor };
|
|
102
102
|
}
|
|
103
|
-
function I(
|
|
104
|
-
return
|
|
103
|
+
function I(i) {
|
|
104
|
+
return i ? i.ids.map((e) => i.entitiesById[e]).filter((e) => !!e) : [];
|
|
105
105
|
}
|
|
106
|
-
function L(
|
|
107
|
-
return
|
|
106
|
+
function L(i) {
|
|
107
|
+
return i.visible ? i.minimized ? { state: "minimized" } : { state: i.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
|
|
108
108
|
}
|
|
109
|
-
function q(
|
|
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"] } :
|
|
109
|
+
function q(i, e) {
|
|
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"] } : i ?? { allowed: !0, reason: "allowed", actions: [] };
|
|
111
111
|
}
|
|
112
|
-
function Q(
|
|
113
|
-
if (!
|
|
114
|
-
const e =
|
|
112
|
+
function Q(i) {
|
|
113
|
+
if (!i || typeof i != "object") return !1;
|
|
114
|
+
const e = i.paidCreditFallbackModel;
|
|
115
115
|
return typeof e == "string" && e.length > 0;
|
|
116
116
|
}
|
|
117
|
-
function $(
|
|
118
|
-
return
|
|
117
|
+
function $(i) {
|
|
118
|
+
return i ? i.submissionGate?.allowed === !1 ? { state: "action_required", reason: i.submissionGate.reason } : i.usingPaidCreditFallback === !0 ? { state: "paid_credit_fallback" } : i.creditLimit !== null && i.creditLimit > 0 && i.creditsRemaining !== null && i.creditsRemaining > 0 && i.creditsRemaining / i.creditLimit <= 0.2 ? { state: "low_credits" } : i.creditsUsed !== null ? { state: "usage" } : { state: "hidden" } : { state: "hidden" };
|
|
119
119
|
}
|
|
120
|
-
function K(
|
|
121
|
-
const e =
|
|
122
|
-
return
|
|
120
|
+
function K(i) {
|
|
121
|
+
const e = i.hasDraftMessage || i.hasPreSubmittedAttachment;
|
|
122
|
+
return i.hasRunningAssistantTurn && !e ? {
|
|
123
123
|
action: "stop",
|
|
124
|
-
disabled: !
|
|
124
|
+
disabled: !i.canStopRunningTurn
|
|
125
125
|
} : {
|
|
126
126
|
action: "send",
|
|
127
|
-
disabled: !e || !
|
|
127
|
+
disabled: !e || !i.canSubmitMessage
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
class B {
|
|
131
|
-
constructor(e, t,
|
|
132
|
-
this.loadPage = t, this.limit =
|
|
131
|
+
constructor(e, t, s = 20) {
|
|
132
|
+
this.loadPage = t, this.limit = s, this.recentQuery = new b(
|
|
133
133
|
`${e}:recent`,
|
|
134
134
|
async ({ cursor: n }) => p(
|
|
135
135
|
await this.loadPage({ cursor: n, limit: this.limit, pinned: !1 }).then((r) => ({
|
|
@@ -159,10 +159,10 @@ class B {
|
|
|
159
159
|
completedRefreshSequence = 0;
|
|
160
160
|
activityReconciliationScheduled = !1;
|
|
161
161
|
getState() {
|
|
162
|
-
const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(),
|
|
162
|
+
const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), s = [
|
|
163
163
|
...u(t.data),
|
|
164
164
|
...u(e.data)
|
|
165
|
-
], n = new Map(
|
|
165
|
+
], n = new Map(s.map((o) => [o.id, o])), r = Array.from(n.values()).map(
|
|
166
166
|
(o) => this.applyOverrides(o, this.completedRefreshSequence)
|
|
167
167
|
), a = Array.from(this.optimisticEntities.values()).filter((o) => !n.has(o.id)).reverse(), l = e.data || t.data || a.length > 0 ? p({
|
|
168
168
|
entities: [...a, ...r],
|
|
@@ -216,20 +216,20 @@ class B {
|
|
|
216
216
|
isActive: t,
|
|
217
217
|
confirmAfterRefresh: this.completedRefreshSequence + 1,
|
|
218
218
|
releaseAfterRefresh: this.completedRefreshSequence + 2
|
|
219
|
-
}), this.updateEntity(e, (
|
|
219
|
+
}), this.updateEntity(e, (s) => ({ ...s, isActive: t }));
|
|
220
220
|
}
|
|
221
221
|
setPinned(e, t) {
|
|
222
|
-
const
|
|
223
|
-
return this.pinnedOverrides.set(e,
|
|
222
|
+
const s = { pinned: t, confirmAfterRefresh: Number.POSITIVE_INFINITY };
|
|
223
|
+
return this.pinnedOverrides.set(e, s), this.updateEntity(e, (n) => ({ ...n, isPinned: t })), s;
|
|
224
224
|
}
|
|
225
225
|
confirmPinned(e, t) {
|
|
226
226
|
this.pinnedOverrides.get(e) === t && (t.confirmAfterRefresh = this.completedRefreshSequence + 1);
|
|
227
227
|
}
|
|
228
|
-
rollbackPinned(e, t,
|
|
229
|
-
this.pinnedOverrides.get(e) === t && (this.pinnedOverrides.delete(e), this.updateEntity(e, (n) => ({ ...n, isPinned:
|
|
228
|
+
rollbackPinned(e, t, s) {
|
|
229
|
+
this.pinnedOverrides.get(e) === t && (this.pinnedOverrides.delete(e), this.updateEntity(e, (n) => ({ ...n, isPinned: s })));
|
|
230
230
|
}
|
|
231
231
|
setTitle(e, t) {
|
|
232
|
-
this.titleOverrides.set(e, t), this.updateEntity(e, (
|
|
232
|
+
this.titleOverrides.set(e, t), this.updateEntity(e, (s) => ({ ...s, customTitle: t }));
|
|
233
233
|
}
|
|
234
234
|
confirmTitle(e) {
|
|
235
235
|
this.titleOverrides.delete(e);
|
|
@@ -238,34 +238,34 @@ class B {
|
|
|
238
238
|
const e = [
|
|
239
239
|
...u(this.pinnedQuery.getState().data),
|
|
240
240
|
...u(this.recentQuery.getState().data)
|
|
241
|
-
], t = new Set(e.map((
|
|
242
|
-
for (const
|
|
243
|
-
t.has(
|
|
244
|
-
for (const
|
|
241
|
+
], t = new Set(e.map((s) => s.id));
|
|
242
|
+
for (const s of this.optimisticEntities.keys())
|
|
243
|
+
t.has(s) && this.optimisticEntities.delete(s);
|
|
244
|
+
for (const s of e) this.applyOverrides(s, this.completedRefreshSequence);
|
|
245
245
|
this.publish();
|
|
246
246
|
}
|
|
247
247
|
async loadAllPinned() {
|
|
248
248
|
const e = [];
|
|
249
249
|
let t = null;
|
|
250
250
|
do {
|
|
251
|
-
const
|
|
252
|
-
e.push(...
|
|
251
|
+
const s = await this.loadPage({ cursor: t, limit: this.limit, pinned: !0 });
|
|
252
|
+
e.push(...s.sessions), t = s.nextCursor;
|
|
253
253
|
} while (t);
|
|
254
254
|
return e;
|
|
255
255
|
}
|
|
256
256
|
applyOverrides(e, t) {
|
|
257
|
-
let
|
|
257
|
+
let s = e;
|
|
258
258
|
const n = this.activityOverrides.get(e.id);
|
|
259
|
-
n && (t >= n.confirmAfterRefresh && e.isActive === n.isActive ? this.activityOverrides.delete(e.id) : t >= n.releaseAfterRefresh ? this.activityOverrides.delete(e.id) :
|
|
259
|
+
n && (t >= n.confirmAfterRefresh && e.isActive === n.isActive ? this.activityOverrides.delete(e.id) : t >= n.releaseAfterRefresh ? this.activityOverrides.delete(e.id) : s = { ...s, isActive: n.isActive });
|
|
260
260
|
const r = this.pinnedOverrides.get(e.id);
|
|
261
|
-
return r && (t >= r.confirmAfterRefresh && e.isPinned === !0 === r.pinned ? this.pinnedOverrides.delete(e.id) :
|
|
261
|
+
return r && (t >= r.confirmAfterRefresh && e.isPinned === !0 === r.pinned ? this.pinnedOverrides.delete(e.id) : s = { ...s, isPinned: r.pinned }), this.titleOverrides.has(e.id) && (s = { ...s, customTitle: this.titleOverrides.get(e.id) ?? null }), s;
|
|
262
262
|
}
|
|
263
263
|
updateProjection() {
|
|
264
264
|
this.publish();
|
|
265
265
|
}
|
|
266
266
|
updateEntity(e, t) {
|
|
267
|
-
const
|
|
268
|
-
|
|
267
|
+
const s = this.optimisticEntities.get(e);
|
|
268
|
+
s && this.optimisticEntities.set(e, t(s)), this.publish();
|
|
269
269
|
}
|
|
270
270
|
hasUnconfirmedActivityOverride() {
|
|
271
271
|
return Array.from(this.activityOverrides.values()).some(
|
|
@@ -276,16 +276,16 @@ class B {
|
|
|
276
276
|
for (const e of this.listeners) e(this.getState());
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
function u(
|
|
280
|
-
return
|
|
279
|
+
function u(i) {
|
|
280
|
+
return i ? i.ids.map((e) => i.entitiesById[e]).filter((e) => !!e) : [];
|
|
281
281
|
}
|
|
282
|
-
function P(
|
|
283
|
-
return
|
|
282
|
+
function P(i, e) {
|
|
283
|
+
return i.status === "error" || e.status === "error" ? "error" : i.status === "loading" || e.status === "loading" ? "loading" : i.status === "refreshing" || e.status === "refreshing" ? "refreshing" : i.status === "loading_more" ? "loading_more" : i.status === "ready" || e.status === "ready" ? "ready" : "not_requested";
|
|
284
284
|
}
|
|
285
285
|
class z {
|
|
286
286
|
constructor(e, t = null) {
|
|
287
287
|
this.storage = e, t && (this.decisions = new Map(
|
|
288
|
-
t.filter(y).map((
|
|
288
|
+
t.filter(y).map((s) => [this.getDecisionKey(s), s])
|
|
289
289
|
), this.initialized = !0);
|
|
290
290
|
}
|
|
291
291
|
storage;
|
|
@@ -301,60 +301,58 @@ class z {
|
|
|
301
301
|
), this.initialized = !0;
|
|
302
302
|
}
|
|
303
303
|
isEligible(e, t = Date.now()) {
|
|
304
|
-
const
|
|
305
|
-
return
|
|
304
|
+
const s = this.scheduledEligibility.get(this.getExactKey(e));
|
|
305
|
+
return s !== void 0 && s > t ? !1 : this.isDecisionEligible(this.decisions.get(this.getExactKey(e)), t) && this.isDecisionEligible(this.decisions.get(this.getCategoryKey(e)), t);
|
|
306
306
|
}
|
|
307
307
|
getDecision(e) {
|
|
308
308
|
return this.decisions.get(this.getExactKey(e)) ?? this.decisions.get(this.getCategoryKey(e)) ?? null;
|
|
309
309
|
}
|
|
310
310
|
getStatus(e, t = Date.now()) {
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
311
|
+
const s = this.scheduledEligibility.get(this.getExactKey(e));
|
|
312
|
+
if (s !== void 0 && s > t) return "scheduled";
|
|
313
313
|
const n = this.getDecision(e);
|
|
314
314
|
return n ? n.action === "never" || n.action === "dont_show_again" ? "suppressed" : n.action === "dismiss" ? "resolved" : n.nextEligibleAt && Date.parse(n.nextEligibleAt) > t ? "snoozed" : "presentable" : "presentable";
|
|
315
315
|
}
|
|
316
316
|
scheduleEligibility(e, t) {
|
|
317
|
-
const
|
|
318
|
-
return n !== void 0 ? n : (this.scheduledEligibility.set(
|
|
317
|
+
const s = this.getExactKey(e), n = this.scheduledEligibility.get(s);
|
|
318
|
+
return n !== void 0 ? n : (this.scheduledEligibility.set(s, t), t);
|
|
319
319
|
}
|
|
320
320
|
getNextEligibilityAt(e = Date.now()) {
|
|
321
|
-
for (const [i, n] of this.scheduledEligibility)
|
|
322
|
-
n <= e && this.scheduledEligibility.delete(i);
|
|
323
321
|
const t = [
|
|
324
|
-
...this.scheduledEligibility.values(),
|
|
325
|
-
...Array.from(this.decisions.values()).map((
|
|
322
|
+
...Array.from(this.scheduledEligibility.values()).filter((s) => s > e),
|
|
323
|
+
...Array.from(this.decisions.values()).map((s) => s.nextEligibleAt ? Date.parse(s.nextEligibleAt) : Number.NaN).filter((s) => Number.isFinite(s) && s > e)
|
|
326
324
|
];
|
|
327
325
|
return t.length > 0 ? Math.min(...t) : null;
|
|
328
326
|
}
|
|
329
|
-
act(e, t,
|
|
330
|
-
const n = this.actionQueue.then(() => this.applyAction(e, t,
|
|
327
|
+
act(e, t, s = {}) {
|
|
328
|
+
const n = this.actionQueue.then(() => this.applyAction(e, t, s));
|
|
331
329
|
return this.actionQueue = n.then(() => {
|
|
332
330
|
}, () => {
|
|
333
331
|
}), n;
|
|
334
332
|
}
|
|
335
|
-
async applyAction(e, t,
|
|
333
|
+
async applyAction(e, t, s) {
|
|
336
334
|
if (!e.allowedActions.includes(t))
|
|
337
335
|
throw new Error(`Interaction ${e.key} does not allow ${t}.`);
|
|
338
336
|
if (!E(t))
|
|
339
337
|
throw new Error(`Interaction action ${t} is not a persistence decision.`);
|
|
340
|
-
const n =
|
|
338
|
+
const n = s.now ?? /* @__PURE__ */ new Date(), r = {
|
|
341
339
|
promptKey: e.key,
|
|
342
340
|
category: e.category,
|
|
343
341
|
action: t,
|
|
344
342
|
scope: e.scope,
|
|
345
343
|
decidedAt: n.toISOString(),
|
|
346
|
-
nextEligibleAt: this.getNextEligibleAt(e, t, n,
|
|
344
|
+
nextEligibleAt: this.getNextEligibleAt(e, t, n, s.snoozeUntil)
|
|
347
345
|
}, a = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), l = new Map(this.decisions);
|
|
348
346
|
return l.set(a, r), await this.storage.save([...l.values()]), this.decisions = l, r;
|
|
349
347
|
}
|
|
350
348
|
isDecisionEligible(e, t) {
|
|
351
349
|
return e ? e.action === "dismiss" || e.action === "never" || e.action === "dont_show_again" ? !1 : !e.nextEligibleAt || Date.parse(e.nextEligibleAt) <= t : !0;
|
|
352
350
|
}
|
|
353
|
-
getNextEligibleAt(e, t,
|
|
351
|
+
getNextEligibleAt(e, t, s, n) {
|
|
354
352
|
if (t === "later")
|
|
355
|
-
return new Date(
|
|
353
|
+
return new Date(s.getTime() + (e.laterDelayMs ?? 3600 * 1e3)).toISOString();
|
|
356
354
|
if (t === "snooze") {
|
|
357
|
-
if (!n || n.getTime() <=
|
|
355
|
+
if (!n || n.getTime() <= s.getTime())
|
|
358
356
|
throw new Error("Snooze requires a future next-eligible time.");
|
|
359
357
|
return n.toISOString();
|
|
360
358
|
}
|
|
@@ -371,27 +369,27 @@ class z {
|
|
|
371
369
|
return `${m(e.scope)}:category:${e.category}`;
|
|
372
370
|
}
|
|
373
371
|
}
|
|
374
|
-
function F(
|
|
372
|
+
function F(i, e) {
|
|
375
373
|
return {
|
|
376
|
-
load: async () => T(
|
|
377
|
-
save: async (t) =>
|
|
374
|
+
load: async () => T(i, e),
|
|
375
|
+
save: async (t) => i.setItem(e, JSON.stringify(t))
|
|
378
376
|
};
|
|
379
377
|
}
|
|
380
|
-
function T(
|
|
381
|
-
const t =
|
|
378
|
+
function T(i, e) {
|
|
379
|
+
const t = i.getItem(e);
|
|
382
380
|
if (!t) return [];
|
|
383
|
-
const
|
|
384
|
-
return Array.isArray(
|
|
381
|
+
const s = JSON.parse(t);
|
|
382
|
+
return Array.isArray(s) ? s.filter(y) : [];
|
|
385
383
|
}
|
|
386
|
-
function m(
|
|
387
|
-
return `${
|
|
384
|
+
function m(i) {
|
|
385
|
+
return `${i.level}:${i.key}`;
|
|
388
386
|
}
|
|
389
|
-
function E(
|
|
390
|
-
return
|
|
387
|
+
function E(i) {
|
|
388
|
+
return i === "dismiss" || i === "later" || i === "snooze" || i === "never" || i === "dont_show_again";
|
|
391
389
|
}
|
|
392
|
-
function y(
|
|
393
|
-
if (!
|
|
394
|
-
const e =
|
|
390
|
+
function y(i) {
|
|
391
|
+
if (!i || typeof i != "object") return !1;
|
|
392
|
+
const e = i;
|
|
395
393
|
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && E(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
|
|
396
394
|
}
|
|
397
395
|
const M = {
|
|
@@ -400,10 +398,10 @@ const M = {
|
|
|
400
398
|
failed: "❗",
|
|
401
399
|
stopped: "⏹️"
|
|
402
400
|
}, D = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
403
|
-
function O(
|
|
404
|
-
if (!e) return g(
|
|
405
|
-
const t = g(
|
|
406
|
-
return t ? `${
|
|
401
|
+
function O(i, e) {
|
|
402
|
+
if (!e) return g(i);
|
|
403
|
+
const t = g(i), s = `${M[e]} Pluno`;
|
|
404
|
+
return t ? `${s}: ${t}` : s;
|
|
407
405
|
}
|
|
408
406
|
class U {
|
|
409
407
|
constructor(e) {
|
|
@@ -422,16 +420,16 @@ class U {
|
|
|
422
420
|
this.liveStatusVersion += 1, this.applyClear();
|
|
423
421
|
}
|
|
424
422
|
async syncStatus(e) {
|
|
425
|
-
const t = this.liveStatusVersion,
|
|
426
|
-
|
|
423
|
+
const t = this.liveStatusVersion, s = await e();
|
|
424
|
+
s === void 0 || t !== this.liveStatusVersion || (s ? this.applyStatus(s) : this.applyClear());
|
|
427
425
|
}
|
|
428
426
|
applyStatus(e) {
|
|
429
427
|
const t = this.titleDocument.getTitle();
|
|
430
428
|
t !== this.lastAppliedTitle && (this.baseTitle = g(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
|
|
431
429
|
}
|
|
432
430
|
applyClear() {
|
|
433
|
-
const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle,
|
|
434
|
-
this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) :
|
|
431
|
+
const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, s = this.lastAppliedTitle === null ? g(e) : e;
|
|
432
|
+
this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : s !== e && this.titleDocument.setTitle(s);
|
|
435
433
|
}
|
|
436
434
|
handleTitleChanged() {
|
|
437
435
|
!this.status || this.titleDocument.getTitle() === this.lastAppliedTitle || this.applyTitle();
|
|
@@ -443,15 +441,15 @@ class U {
|
|
|
443
441
|
this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
|
|
444
442
|
}
|
|
445
443
|
}
|
|
446
|
-
function N(
|
|
444
|
+
function N(i) {
|
|
447
445
|
return {
|
|
448
|
-
getTitle: () =>
|
|
446
|
+
getTitle: () => i.title,
|
|
449
447
|
setTitle: (e) => {
|
|
450
|
-
|
|
448
|
+
i.title = e;
|
|
451
449
|
},
|
|
452
450
|
observeTitle: (e) => {
|
|
453
451
|
const t = new MutationObserver(e);
|
|
454
|
-
return t.observe(
|
|
452
|
+
return t.observe(i.head, {
|
|
455
453
|
childList: !0,
|
|
456
454
|
subtree: !0,
|
|
457
455
|
characterData: !0
|
|
@@ -459,12 +457,12 @@ function N(s) {
|
|
|
459
457
|
}
|
|
460
458
|
};
|
|
461
459
|
}
|
|
462
|
-
function g(
|
|
463
|
-
return
|
|
460
|
+
function g(i) {
|
|
461
|
+
return i.replace(D, "");
|
|
464
462
|
}
|
|
465
463
|
const S = 500;
|
|
466
|
-
function k(
|
|
467
|
-
const e =
|
|
464
|
+
function k(i) {
|
|
465
|
+
const e = i.replace(/\n\s*at\s[\s\S]*$/, "").replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g, "[REDACTED]").replace(/\b(?:set-cookie|cookie)\s*[:=]\s*[^\n]+/gi, "cookie=[REDACTED]").replace(/\bdata:[^\s<>"']+/gi, "[DATA]").replace(/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi, "[URL]").replace(/\b(?:Bearer|Basic)\s+[^\s,;"']+/gi, "[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp)[-_][A-Za-z0-9_-]{8,}/g, "[REDACTED]").replace(/\b((?:access|refresh|id|auth)[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|pwd|secret|token|jwt|authorization|cookie|set-cookie)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;}&]+)/gi, "$1=[REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[EMAIL]").replace(/(?:[A-Z]:[\\/]|\\\\|(?:~|\.\.?)?\/|[\w.-]+[\\/])[^\s<>"']+/gi, "[FILE]").replace(new RegExp("(?<![\\w.])(?:[\\w.-]+\\.[A-Z][A-Z0-9]{0,15}|\\.[A-Z][\\w.-]*)\\b", "gi"), "[FILE]").replace(/\s+/g, " ").trim();
|
|
468
466
|
return e.length > S ? `${e.slice(0, S - 1)}…` : e;
|
|
469
467
|
}
|
|
470
468
|
const x = {
|
|
@@ -480,23 +478,23 @@ const x = {
|
|
|
480
478
|
"thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
|
|
481
479
|
"thinking-without-progress": "Thinking remained visible without progress for five minutes."
|
|
482
480
|
};
|
|
483
|
-
function R(
|
|
484
|
-
return typeof
|
|
481
|
+
function R(i) {
|
|
482
|
+
return typeof i == "string" && i.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(x, i.slice(13));
|
|
485
483
|
}
|
|
486
|
-
function A(
|
|
484
|
+
function A(i) {
|
|
487
485
|
return {
|
|
488
|
-
...
|
|
489
|
-
name:
|
|
490
|
-
mimeType:
|
|
491
|
-
sizeBytes:
|
|
492
|
-
...
|
|
493
|
-
...
|
|
494
|
-
...
|
|
486
|
+
...i.id === void 0 ? {} : { id: i.id },
|
|
487
|
+
name: i.name,
|
|
488
|
+
mimeType: i.mimeType,
|
|
489
|
+
sizeBytes: i.sizeBytes,
|
|
490
|
+
...i.sandboxPath === void 0 ? {} : { sandboxPath: i.sandboxPath },
|
|
491
|
+
...i.storageKey === void 0 ? {} : { storageKey: i.storageKey },
|
|
492
|
+
...i.fileUrl === void 0 ? {} : { fileUrl: i.fileUrl }
|
|
495
493
|
};
|
|
496
494
|
}
|
|
497
|
-
function H(
|
|
498
|
-
if (!
|
|
499
|
-
const e =
|
|
495
|
+
function H(i) {
|
|
496
|
+
if (!i || typeof i != "object" || !("type" in i)) return !1;
|
|
497
|
+
const e = i;
|
|
500
498
|
switch (e.type) {
|
|
501
499
|
case "runtime.connect":
|
|
502
500
|
case "session.new":
|
|
@@ -536,8 +534,8 @@ function H(s) {
|
|
|
536
534
|
}
|
|
537
535
|
}
|
|
538
536
|
class j {
|
|
539
|
-
constructor(e, t,
|
|
540
|
-
this.adapter = t, this.state = f(e), this.model =
|
|
537
|
+
constructor(e, t, s) {
|
|
538
|
+
this.adapter = t, this.state = f(e), this.model = s;
|
|
541
539
|
}
|
|
542
540
|
adapter;
|
|
543
541
|
listeners = {};
|
|
@@ -555,13 +553,13 @@ class j {
|
|
|
555
553
|
operationQueue = Promise.resolve();
|
|
556
554
|
destroyed = !1;
|
|
557
555
|
on(e, t) {
|
|
558
|
-
const
|
|
559
|
-
return
|
|
556
|
+
const s = this.listeners[e] ?? /* @__PURE__ */ new Set();
|
|
557
|
+
return s.add(t), this.listeners[e] = s, () => s.delete(t);
|
|
560
558
|
}
|
|
561
559
|
getState() {
|
|
562
560
|
return f(this.state);
|
|
563
561
|
}
|
|
564
|
-
updateProjection(e, t,
|
|
562
|
+
updateProjection(e, t, s, n, r) {
|
|
565
563
|
if (!this.destroyed) {
|
|
566
564
|
this.state = f(e);
|
|
567
565
|
for (const [a, l] of this.unacknowledgedSubmissions) {
|
|
@@ -581,8 +579,8 @@ class j {
|
|
|
581
579
|
}
|
|
582
580
|
l.sessionId ??= e.sessionId, this.state.messages.push(l.message), this.state.pendingMessageStatus = "sending", this.state.turnPhase ??= "sending", this.state.taskStatus ??= "working";
|
|
583
581
|
}
|
|
584
|
-
if (t !== void 0 && (this.model = t),
|
|
585
|
-
this.sessionHistoryState = w(
|
|
582
|
+
if (t !== void 0 && (this.model = t), s) {
|
|
583
|
+
this.sessionHistoryState = w(s);
|
|
586
584
|
for (const a of this.sessionHistoryListeners)
|
|
587
585
|
a(this.getSessionHistoryState());
|
|
588
586
|
}
|
|
@@ -622,22 +620,22 @@ class j {
|
|
|
622
620
|
}).catch(() => {
|
|
623
621
|
});
|
|
624
622
|
}
|
|
625
|
-
reportDisplayedError(e, t,
|
|
623
|
+
reportDisplayedError(e, t, s) {
|
|
626
624
|
this.adapter.dispatch({
|
|
627
625
|
type: "runtime.report_displayed_error",
|
|
628
626
|
reason: e,
|
|
629
627
|
errorFingerprint: t,
|
|
630
|
-
...
|
|
628
|
+
...s ? { displayedMessage: k(s) } : {}
|
|
631
629
|
}).catch(() => {
|
|
632
630
|
});
|
|
633
631
|
}
|
|
634
632
|
sendMessage(e, t = {}) {
|
|
635
|
-
const
|
|
636
|
-
if (!
|
|
633
|
+
const s = e.trim(), n = t.attachments ?? [];
|
|
634
|
+
if (!s && n.length === 0) return Promise.resolve(null);
|
|
637
635
|
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), a = t.submittedAt ?? Date.now(), l = this.state, o = {
|
|
638
636
|
id: `local-${r}`,
|
|
639
637
|
role: "user",
|
|
640
|
-
content:
|
|
638
|
+
content: s,
|
|
641
639
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
642
640
|
...n.length > 0 ? { attachments: n } : {},
|
|
643
641
|
clientMessageId: r
|
|
@@ -655,12 +653,12 @@ class j {
|
|
|
655
653
|
isRetrying: !1,
|
|
656
654
|
lastError: null
|
|
657
655
|
}, this.emit("state", this.getState()), this.enqueueOperation(() => this.sendMessageNow(
|
|
658
|
-
|
|
656
|
+
s,
|
|
659
657
|
{ ...t, clientMessageId: r, submittedAt: a },
|
|
660
658
|
l
|
|
661
659
|
));
|
|
662
660
|
}
|
|
663
|
-
async sendMessageNow(e, t,
|
|
661
|
+
async sendMessageNow(e, t, s) {
|
|
664
662
|
const n = e, r = t.clientMessageId;
|
|
665
663
|
let a = t.attachments ?? [], l = !1;
|
|
666
664
|
try {
|
|
@@ -706,10 +704,10 @@ class j {
|
|
|
706
704
|
messages: this.state.messages.filter(
|
|
707
705
|
(c) => c.id !== `local-${r}` && c.id !== `optimistic-user-message:${r}`
|
|
708
706
|
),
|
|
709
|
-
pendingMessageStatus:
|
|
710
|
-
turnPhase:
|
|
711
|
-
isThinking:
|
|
712
|
-
taskStatus:
|
|
707
|
+
pendingMessageStatus: s.pendingMessageStatus,
|
|
708
|
+
turnPhase: s.turnPhase,
|
|
709
|
+
isThinking: s.isThinking,
|
|
710
|
+
taskStatus: s.taskStatus
|
|
713
711
|
}, this.emit("state", this.getState()), l && await this.adapter.dispatch({
|
|
714
712
|
type: "conversation.fail_staged",
|
|
715
713
|
clientMessageId: r,
|
|
@@ -781,12 +779,12 @@ class j {
|
|
|
781
779
|
subscribeInteractions(e) {
|
|
782
780
|
return this.interactionListeners.add(e), e(this.getInteractions()), () => this.interactionListeners.delete(e);
|
|
783
781
|
}
|
|
784
|
-
actOnInteraction(e, t,
|
|
782
|
+
actOnInteraction(e, t, s, n = {}) {
|
|
785
783
|
return this.dispatch({
|
|
786
784
|
type: "interaction.act",
|
|
787
785
|
interactionId: e,
|
|
788
786
|
action: t,
|
|
789
|
-
expectedRevision:
|
|
787
|
+
expectedRevision: s,
|
|
790
788
|
...n
|
|
791
789
|
}).then(() => {
|
|
792
790
|
});
|
|
@@ -807,11 +805,11 @@ class j {
|
|
|
807
805
|
stageProactiveSuggestionQuestion(e) {
|
|
808
806
|
const t = e.trim();
|
|
809
807
|
if (!t) return Promise.resolve();
|
|
810
|
-
const
|
|
811
|
-
return this.stagedProactiveSuggestionClientMessageId =
|
|
808
|
+
const s = this.stagedProactiveSuggestionClientMessageId ?? crypto.randomUUID();
|
|
809
|
+
return this.stagedProactiveSuggestionClientMessageId = s, this.dispatch({
|
|
812
810
|
type: "conversation.stage_proactive_suggestion",
|
|
813
811
|
question: t,
|
|
814
|
-
clientMessageId:
|
|
812
|
+
clientMessageId: s
|
|
815
813
|
}).then(() => {
|
|
816
814
|
});
|
|
817
815
|
}
|
|
@@ -828,52 +826,52 @@ class j {
|
|
|
828
826
|
), t;
|
|
829
827
|
}
|
|
830
828
|
emit(e, t) {
|
|
831
|
-
const
|
|
832
|
-
for (const n of
|
|
829
|
+
const s = this.listeners[e];
|
|
830
|
+
for (const n of s ?? []) n(t);
|
|
833
831
|
}
|
|
834
832
|
}
|
|
835
|
-
function C(
|
|
836
|
-
if (!e || !
|
|
833
|
+
function C(i, e) {
|
|
834
|
+
if (!e || !i) return e;
|
|
837
835
|
const t = /* @__PURE__ */ new Map();
|
|
838
|
-
for (const
|
|
839
|
-
const n =
|
|
840
|
-
|
|
836
|
+
for (const s of i) {
|
|
837
|
+
const n = s.previewUrl;
|
|
838
|
+
s.id && n && t.set(s.id, n);
|
|
841
839
|
}
|
|
842
|
-
return e.map((
|
|
843
|
-
const n =
|
|
844
|
-
return n ? { ...
|
|
840
|
+
return e.map((s) => {
|
|
841
|
+
const n = s.id ? t.get(s.id) : void 0;
|
|
842
|
+
return n ? { ...s, previewUrl: n } : s;
|
|
845
843
|
});
|
|
846
844
|
}
|
|
847
|
-
function f(
|
|
845
|
+
function f(i) {
|
|
848
846
|
return {
|
|
849
|
-
...
|
|
850
|
-
starterPrompts: [...
|
|
851
|
-
appearance:
|
|
852
|
-
messages:
|
|
847
|
+
...i,
|
|
848
|
+
starterPrompts: [...i.starterPrompts],
|
|
849
|
+
appearance: i.appearance ? { ...i.appearance } : null,
|
|
850
|
+
messages: i.messages.map((e) => {
|
|
853
851
|
const t = {
|
|
854
852
|
...e,
|
|
855
853
|
attachments: e.attachments?.map((a) => ({ ...a }))
|
|
856
|
-
},
|
|
854
|
+
}, s = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
|
|
857
855
|
return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
|
|
858
856
|
value: r,
|
|
859
857
|
enumerable: !1
|
|
860
|
-
}),
|
|
861
|
-
value:
|
|
858
|
+
}), s && Object.defineProperty(t, "assistantDraftItemId", {
|
|
859
|
+
value: s,
|
|
862
860
|
enumerable: !1
|
|
863
861
|
}), n && Object.defineProperty(t, "clientMessageId", {
|
|
864
862
|
value: n,
|
|
865
863
|
enumerable: !1
|
|
866
864
|
}), t;
|
|
867
865
|
}),
|
|
868
|
-
activeScheduledFollowUps:
|
|
866
|
+
activeScheduledFollowUps: i.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
|
|
869
867
|
};
|
|
870
868
|
}
|
|
871
|
-
function w(
|
|
869
|
+
function w(i) {
|
|
872
870
|
return {
|
|
873
|
-
...
|
|
874
|
-
data:
|
|
875
|
-
entities: I(
|
|
876
|
-
nextCursor:
|
|
871
|
+
...i,
|
|
872
|
+
data: i.data ? p({
|
|
873
|
+
entities: I(i.data).map((e) => ({ ...e })),
|
|
874
|
+
nextCursor: i.data.nextCursor
|
|
877
875
|
}) : null
|
|
878
876
|
};
|
|
879
877
|
}
|