@pluno/product-agent-web 0.1.229 → 0.1.230
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/index.d.ts +3 -2
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +280 -265
- package/dist/product-agent-sdk.js +305 -289
- package/dist/product-agent-widget.js +2753 -2704
- package/dist/runtime.d.ts +2 -2
- package/dist/runtimeState.d.ts +15 -0
- package/dist/uiInvariants.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function f(
|
|
1
|
+
function f(s) {
|
|
2
2
|
return {
|
|
3
|
-
key:
|
|
3
|
+
key: s,
|
|
4
4
|
status: "not_requested",
|
|
5
5
|
data: null,
|
|
6
6
|
error: null,
|
|
@@ -9,8 +9,8 @@ function f(i) {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
class w {
|
|
12
|
-
constructor(e, t,
|
|
13
|
-
this.loader = t, this.merge =
|
|
12
|
+
constructor(e, t, i = (n, a) => a) {
|
|
13
|
+
this.loader = t, this.merge = i, this.state = f(e);
|
|
14
14
|
}
|
|
15
15
|
loader;
|
|
16
16
|
merge;
|
|
@@ -52,16 +52,16 @@ class w {
|
|
|
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, i = 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: i
|
|
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 || i !== this.state.requestId) continue;
|
|
65
65
|
this.state = {
|
|
66
66
|
...this.state,
|
|
67
67
|
status: "ready",
|
|
@@ -70,7 +70,7 @@ class w {
|
|
|
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 || i !== this.state.requestId) continue;
|
|
74
74
|
this.state = {
|
|
75
75
|
...this.state,
|
|
76
76
|
status: "error",
|
|
@@ -83,53 +83,60 @@ class w {
|
|
|
83
83
|
for (const e of this.listeners) e(this.state);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function m(
|
|
86
|
+
function m(s) {
|
|
87
87
|
const e = {}, t = [];
|
|
88
|
-
for (const
|
|
89
|
-
e[
|
|
88
|
+
for (const i of s.entities)
|
|
89
|
+
e[i.id] || t.push(i.id), e[i.id] = i;
|
|
90
90
|
return {
|
|
91
91
|
entitiesById: e,
|
|
92
92
|
ids: t,
|
|
93
|
-
nextCursor:
|
|
93
|
+
nextCursor: s.nextCursor
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
if (t === "replace" ||
|
|
98
|
-
const
|
|
96
|
+
function D(s, e, t) {
|
|
97
|
+
if (t === "replace" || s === null) return e;
|
|
98
|
+
const i = { ...s.entitiesById, ...e.entitiesById }, n = [...s.ids];
|
|
99
99
|
for (const a of e.ids)
|
|
100
|
-
|
|
101
|
-
return { entitiesById:
|
|
100
|
+
s.entitiesById[a] || n.push(a);
|
|
101
|
+
return { entitiesById: i, ids: n, nextCursor: e.nextCursor };
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
return
|
|
103
|
+
function R(s) {
|
|
104
|
+
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
return
|
|
106
|
+
function F(s) {
|
|
107
|
+
return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
|
|
108
108
|
}
|
|
109
|
-
function
|
|
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 j(s, 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"] } : s ?? { allowed: !0, reason: "allowed", actions: [] };
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
if (!
|
|
114
|
-
const e =
|
|
112
|
+
function z(s) {
|
|
113
|
+
if (!s || typeof s != "object") return !1;
|
|
114
|
+
const e = s.paidCreditFallbackModel;
|
|
115
115
|
return typeof e == "string" && e.length > 0;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
return
|
|
117
|
+
function H(s) {
|
|
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
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
function G(s) {
|
|
121
|
+
return s.submissionAllowed && s.isAuthenticated && s.hasWorkspace && !s.isWebsiteBlocked && s.isCurrentPageResolved && !s.isSubmitting && !s.hasPendingMessage;
|
|
122
|
+
}
|
|
123
|
+
function V(s) {
|
|
124
|
+
const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
|
|
125
|
+
return s.hasRunningAssistantTurn && !e ? {
|
|
123
126
|
action: "stop",
|
|
124
|
-
disabled: !
|
|
127
|
+
disabled: !s.canStopRunningTurn
|
|
125
128
|
} : {
|
|
126
129
|
action: "send",
|
|
127
|
-
disabled: !e || !
|
|
130
|
+
disabled: !e || !s.canSubmitMessage
|
|
128
131
|
};
|
|
129
132
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
const k = "Pluno is reconnecting. Try again in a moment.";
|
|
134
|
+
function C(s) {
|
|
135
|
+
return (s instanceof Error ? s.message : s) === k;
|
|
136
|
+
}
|
|
137
|
+
class Z {
|
|
138
|
+
constructor(e, t, i = 20) {
|
|
139
|
+
this.loadPage = t, this.limit = i, this.recentQuery = new w(
|
|
133
140
|
`${e}:recent`,
|
|
134
141
|
async ({ cursor: n }) => m(
|
|
135
142
|
await this.loadPage({ cursor: n, limit: this.limit, pinned: !1 }).then((a) => ({
|
|
@@ -137,7 +144,7 @@ class H {
|
|
|
137
144
|
nextCursor: a.nextCursor
|
|
138
145
|
}))
|
|
139
146
|
),
|
|
140
|
-
|
|
147
|
+
D
|
|
141
148
|
), this.pinnedQuery = new w(
|
|
142
149
|
`${e}:pinned`,
|
|
143
150
|
async () => m({
|
|
@@ -159,18 +166,18 @@ class H {
|
|
|
159
166
|
completedRefreshSequence = 0;
|
|
160
167
|
activityReconciliationScheduled = !1;
|
|
161
168
|
getState() {
|
|
162
|
-
const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(),
|
|
169
|
+
const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), i = [
|
|
163
170
|
...g(t.data),
|
|
164
171
|
...g(e.data)
|
|
165
|
-
], n = new Map(
|
|
166
|
-
(
|
|
167
|
-
),
|
|
168
|
-
entities: [...
|
|
172
|
+
], n = new Map(i.map((l) => [l.id, l])), a = Array.from(n.values()).map(
|
|
173
|
+
(l) => this.applyOverrides(l, this.completedRefreshSequence)
|
|
174
|
+
), c = Array.from(this.optimisticEntities.values()).filter((l) => !n.has(l.id)).reverse(), r = e.data || t.data || c.length > 0 ? m({
|
|
175
|
+
entities: [...c, ...a],
|
|
169
176
|
nextCursor: e.data?.nextCursor ?? null
|
|
170
177
|
}) : null;
|
|
171
178
|
return {
|
|
172
179
|
key: e.key.slice(0, -7),
|
|
173
|
-
status:
|
|
180
|
+
status: x(e, t),
|
|
174
181
|
data: r,
|
|
175
182
|
error: e.error ?? t.error,
|
|
176
183
|
requestId: Math.max(e.requestId, t.requestId),
|
|
@@ -216,20 +223,20 @@ class H {
|
|
|
216
223
|
isActive: t,
|
|
217
224
|
confirmAfterRefresh: this.completedRefreshSequence + 1,
|
|
218
225
|
releaseAfterRefresh: this.completedRefreshSequence + 2
|
|
219
|
-
}), this.updateEntity(e, (
|
|
226
|
+
}), this.updateEntity(e, (i) => ({ ...i, isActive: t }));
|
|
220
227
|
}
|
|
221
228
|
setPinned(e, t) {
|
|
222
|
-
const
|
|
223
|
-
return this.pinnedOverrides.set(e,
|
|
229
|
+
const i = { pinned: t, confirmAfterRefresh: Number.POSITIVE_INFINITY };
|
|
230
|
+
return this.pinnedOverrides.set(e, i), this.updateEntity(e, (n) => ({ ...n, isPinned: t })), i;
|
|
224
231
|
}
|
|
225
232
|
confirmPinned(e, t) {
|
|
226
233
|
this.pinnedOverrides.get(e) === t && (t.confirmAfterRefresh = this.completedRefreshSequence + 1);
|
|
227
234
|
}
|
|
228
|
-
rollbackPinned(e, t,
|
|
229
|
-
this.pinnedOverrides.get(e) === t && (this.pinnedOverrides.delete(e), this.updateEntity(e, (n) => ({ ...n, isPinned:
|
|
235
|
+
rollbackPinned(e, t, i) {
|
|
236
|
+
this.pinnedOverrides.get(e) === t && (this.pinnedOverrides.delete(e), this.updateEntity(e, (n) => ({ ...n, isPinned: i })));
|
|
230
237
|
}
|
|
231
238
|
setTitle(e, t) {
|
|
232
|
-
this.titleOverrides.set(e, t), this.updateEntity(e, (
|
|
239
|
+
this.titleOverrides.set(e, t), this.updateEntity(e, (i) => ({ ...i, customTitle: t }));
|
|
233
240
|
}
|
|
234
241
|
confirmTitle(e) {
|
|
235
242
|
this.titleOverrides.delete(e);
|
|
@@ -238,34 +245,34 @@ class H {
|
|
|
238
245
|
const e = [
|
|
239
246
|
...g(this.pinnedQuery.getState().data),
|
|
240
247
|
...g(this.recentQuery.getState().data)
|
|
241
|
-
], t = new Set(e.map((
|
|
242
|
-
for (const
|
|
243
|
-
t.has(
|
|
244
|
-
for (const
|
|
248
|
+
], t = new Set(e.map((i) => i.id));
|
|
249
|
+
for (const i of this.optimisticEntities.keys())
|
|
250
|
+
t.has(i) && this.optimisticEntities.delete(i);
|
|
251
|
+
for (const i of e) this.applyOverrides(i, this.completedRefreshSequence);
|
|
245
252
|
this.publish();
|
|
246
253
|
}
|
|
247
254
|
async loadAllPinned() {
|
|
248
255
|
const e = [];
|
|
249
256
|
let t = null;
|
|
250
257
|
do {
|
|
251
|
-
const
|
|
252
|
-
e.push(...
|
|
258
|
+
const i = await this.loadPage({ cursor: t, limit: this.limit, pinned: !0 });
|
|
259
|
+
e.push(...i.sessions), t = i.nextCursor;
|
|
253
260
|
} while (t);
|
|
254
261
|
return e;
|
|
255
262
|
}
|
|
256
263
|
applyOverrides(e, t) {
|
|
257
|
-
let
|
|
264
|
+
let i = e;
|
|
258
265
|
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) :
|
|
266
|
+
n && (t >= n.confirmAfterRefresh && e.isActive === n.isActive ? this.activityOverrides.delete(e.id) : t >= n.releaseAfterRefresh ? this.activityOverrides.delete(e.id) : i = { ...i, isActive: n.isActive });
|
|
260
267
|
const a = this.pinnedOverrides.get(e.id);
|
|
261
|
-
return a && (t >= a.confirmAfterRefresh && e.isPinned === !0 === a.pinned ? this.pinnedOverrides.delete(e.id) :
|
|
268
|
+
return a && (t >= a.confirmAfterRefresh && e.isPinned === !0 === a.pinned ? this.pinnedOverrides.delete(e.id) : i = { ...i, isPinned: a.pinned }), this.titleOverrides.has(e.id) && (i = { ...i, customTitle: this.titleOverrides.get(e.id) ?? null }), i;
|
|
262
269
|
}
|
|
263
270
|
updateProjection() {
|
|
264
271
|
this.publish();
|
|
265
272
|
}
|
|
266
273
|
updateEntity(e, t) {
|
|
267
|
-
const
|
|
268
|
-
|
|
274
|
+
const i = this.optimisticEntities.get(e);
|
|
275
|
+
i && this.optimisticEntities.set(e, t(i)), this.publish();
|
|
269
276
|
}
|
|
270
277
|
hasUnconfirmedActivityOverride() {
|
|
271
278
|
return Array.from(this.activityOverrides.values()).some(
|
|
@@ -276,16 +283,16 @@ class H {
|
|
|
276
283
|
for (const e of this.listeners) e(this.getState());
|
|
277
284
|
}
|
|
278
285
|
}
|
|
279
|
-
function g(
|
|
280
|
-
return
|
|
286
|
+
function g(s) {
|
|
287
|
+
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
281
288
|
}
|
|
282
|
-
function
|
|
283
|
-
return
|
|
289
|
+
function x(s, e) {
|
|
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";
|
|
284
291
|
}
|
|
285
|
-
class
|
|
292
|
+
class J {
|
|
286
293
|
constructor(e, t = null) {
|
|
287
294
|
this.storage = e, t && (this.decisions = new Map(
|
|
288
|
-
t.filter(I).map((
|
|
295
|
+
t.filter(I).map((i) => [this.getDecisionKey(i), i])
|
|
289
296
|
), this.initialized = !0);
|
|
290
297
|
}
|
|
291
298
|
storage;
|
|
@@ -301,58 +308,58 @@ class G {
|
|
|
301
308
|
), this.initialized = !0;
|
|
302
309
|
}
|
|
303
310
|
isEligible(e, t = Date.now()) {
|
|
304
|
-
const
|
|
305
|
-
return
|
|
311
|
+
const i = this.scheduledEligibility.get(this.getExactKey(e));
|
|
312
|
+
return i !== void 0 && i > t ? !1 : this.isDecisionEligible(this.decisions.get(this.getExactKey(e)), t) && this.isDecisionEligible(this.decisions.get(this.getCategoryKey(e)), t);
|
|
306
313
|
}
|
|
307
314
|
getDecision(e) {
|
|
308
315
|
return this.decisions.get(this.getExactKey(e)) ?? this.decisions.get(this.getCategoryKey(e)) ?? null;
|
|
309
316
|
}
|
|
310
317
|
getStatus(e, t = Date.now()) {
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
318
|
+
const i = this.scheduledEligibility.get(this.getExactKey(e));
|
|
319
|
+
if (i !== void 0 && i > t) return "scheduled";
|
|
313
320
|
const n = this.getDecision(e);
|
|
314
321
|
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
322
|
}
|
|
316
323
|
scheduleEligibility(e, t) {
|
|
317
|
-
const
|
|
318
|
-
return n !== void 0 ? n : (this.scheduledEligibility.set(
|
|
324
|
+
const i = this.getExactKey(e), n = this.scheduledEligibility.get(i);
|
|
325
|
+
return n !== void 0 ? n : (this.scheduledEligibility.set(i, t), t);
|
|
319
326
|
}
|
|
320
327
|
getNextEligibilityAt(e = Date.now()) {
|
|
321
328
|
const t = [
|
|
322
|
-
...Array.from(this.scheduledEligibility.values()).filter((
|
|
323
|
-
...Array.from(this.decisions.values()).map((
|
|
329
|
+
...Array.from(this.scheduledEligibility.values()).filter((i) => i > e),
|
|
330
|
+
...Array.from(this.decisions.values()).map((i) => i.nextEligibleAt ? Date.parse(i.nextEligibleAt) : Number.NaN).filter((i) => Number.isFinite(i) && i > e)
|
|
324
331
|
];
|
|
325
332
|
return t.length > 0 ? Math.min(...t) : null;
|
|
326
333
|
}
|
|
327
|
-
act(e, t,
|
|
328
|
-
const n = this.actionQueue.then(() => this.applyAction(e, t,
|
|
334
|
+
act(e, t, i = {}) {
|
|
335
|
+
const n = this.actionQueue.then(() => this.applyAction(e, t, i));
|
|
329
336
|
return this.actionQueue = n.then(() => {
|
|
330
337
|
}, () => {
|
|
331
338
|
}), n;
|
|
332
339
|
}
|
|
333
|
-
async applyAction(e, t,
|
|
340
|
+
async applyAction(e, t, i) {
|
|
334
341
|
if (!e.allowedActions.includes(t))
|
|
335
342
|
throw new Error(`Interaction ${e.key} does not allow ${t}.`);
|
|
336
|
-
if (!
|
|
343
|
+
if (!O(t))
|
|
337
344
|
throw new Error(`Interaction action ${t} is not a persistence decision.`);
|
|
338
|
-
const n =
|
|
345
|
+
const n = i.now ?? /* @__PURE__ */ new Date(), a = {
|
|
339
346
|
promptKey: e.key,
|
|
340
347
|
category: e.category,
|
|
341
348
|
action: t,
|
|
342
349
|
scope: e.scope,
|
|
343
350
|
decidedAt: n.toISOString(),
|
|
344
|
-
nextEligibleAt: this.getNextEligibleAt(e, t, n,
|
|
345
|
-
},
|
|
346
|
-
return r.set(
|
|
351
|
+
nextEligibleAt: this.getNextEligibleAt(e, t, n, i.snoozeUntil)
|
|
352
|
+
}, c = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), r = new Map(this.decisions);
|
|
353
|
+
return r.set(c, a), await this.storage.save([...r.values()]), this.decisions = r, a;
|
|
347
354
|
}
|
|
348
355
|
isDecisionEligible(e, t) {
|
|
349
356
|
return e ? e.action === "dismiss" || e.action === "never" || e.action === "dont_show_again" ? !1 : !e.nextEligibleAt || Date.parse(e.nextEligibleAt) <= t : !0;
|
|
350
357
|
}
|
|
351
|
-
getNextEligibleAt(e, t,
|
|
358
|
+
getNextEligibleAt(e, t, i, n) {
|
|
352
359
|
if (t === "later")
|
|
353
|
-
return new Date(
|
|
360
|
+
return new Date(i.getTime() + (e.laterDelayMs ?? 3600 * 1e3)).toISOString();
|
|
354
361
|
if (t === "snooze") {
|
|
355
|
-
if (!n || n.getTime() <=
|
|
362
|
+
if (!n || n.getTime() <= i.getTime())
|
|
356
363
|
throw new Error("Snooze requires a future next-eligible time.");
|
|
357
364
|
return n.toISOString();
|
|
358
365
|
}
|
|
@@ -369,41 +376,41 @@ class G {
|
|
|
369
376
|
return `${b(e.scope)}:category:${e.category}`;
|
|
370
377
|
}
|
|
371
378
|
}
|
|
372
|
-
function
|
|
379
|
+
function W(s, e) {
|
|
373
380
|
return {
|
|
374
|
-
load: async () =>
|
|
375
|
-
save: async (t) =>
|
|
381
|
+
load: async () => L(s, e),
|
|
382
|
+
save: async (t) => s.setItem(e, JSON.stringify(t))
|
|
376
383
|
};
|
|
377
384
|
}
|
|
378
|
-
function
|
|
379
|
-
const t =
|
|
385
|
+
function L(s, e) {
|
|
386
|
+
const t = s.getItem(e);
|
|
380
387
|
if (!t) return [];
|
|
381
|
-
const
|
|
382
|
-
return Array.isArray(
|
|
388
|
+
const i = JSON.parse(t);
|
|
389
|
+
return Array.isArray(i) ? i.filter(I) : [];
|
|
383
390
|
}
|
|
384
|
-
function b(
|
|
385
|
-
return `${
|
|
391
|
+
function b(s) {
|
|
392
|
+
return `${s.level}:${s.key}`;
|
|
386
393
|
}
|
|
387
|
-
function
|
|
388
|
-
return
|
|
394
|
+
function O(s) {
|
|
395
|
+
return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
|
|
389
396
|
}
|
|
390
|
-
function I(
|
|
391
|
-
if (!
|
|
392
|
-
const e =
|
|
393
|
-
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") &&
|
|
397
|
+
function I(s) {
|
|
398
|
+
if (!s || typeof s != "object") return !1;
|
|
399
|
+
const e = s;
|
|
400
|
+
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && O(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
|
|
394
401
|
}
|
|
395
|
-
const
|
|
402
|
+
const q = {
|
|
396
403
|
working: "⏳",
|
|
397
404
|
completed: "✅",
|
|
398
405
|
failed: "❗",
|
|
399
406
|
stopped: "⏹️"
|
|
400
|
-
},
|
|
401
|
-
function
|
|
402
|
-
if (!e) return y(
|
|
403
|
-
const t = y(
|
|
404
|
-
return t ? `${
|
|
407
|
+
}, U = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
408
|
+
function Q(s, e) {
|
|
409
|
+
if (!e) return y(s);
|
|
410
|
+
const t = y(s), i = `${q[e]} Pluno`;
|
|
411
|
+
return t ? `${i}: ${t}` : i;
|
|
405
412
|
}
|
|
406
|
-
class
|
|
413
|
+
class Y {
|
|
407
414
|
constructor(e) {
|
|
408
415
|
this.titleDocument = e;
|
|
409
416
|
}
|
|
@@ -420,16 +427,16 @@ class Z {
|
|
|
420
427
|
this.liveStatusVersion += 1, this.applyClear();
|
|
421
428
|
}
|
|
422
429
|
async syncStatus(e) {
|
|
423
|
-
const t = this.liveStatusVersion,
|
|
424
|
-
|
|
430
|
+
const t = this.liveStatusVersion, i = await e();
|
|
431
|
+
i === void 0 || t !== this.liveStatusVersion || (i ? this.applyStatus(i) : this.applyClear());
|
|
425
432
|
}
|
|
426
433
|
applyStatus(e) {
|
|
427
434
|
const t = this.titleDocument.getTitle();
|
|
428
435
|
t !== this.lastAppliedTitle && (this.baseTitle = y(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
|
|
429
436
|
}
|
|
430
437
|
applyClear() {
|
|
431
|
-
const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle,
|
|
432
|
-
this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) :
|
|
438
|
+
const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, i = this.lastAppliedTitle === null ? y(e) : e;
|
|
439
|
+
this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : i !== e && this.titleDocument.setTitle(i);
|
|
433
440
|
}
|
|
434
441
|
handleTitleChanged() {
|
|
435
442
|
!this.status || this.titleDocument.getTitle() === this.lastAppliedTitle || this.applyTitle();
|
|
@@ -437,19 +444,19 @@ class Z {
|
|
|
437
444
|
applyTitle() {
|
|
438
445
|
if (!this.status)
|
|
439
446
|
return;
|
|
440
|
-
const e =
|
|
447
|
+
const e = Q(this.baseTitle, this.status);
|
|
441
448
|
this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
|
|
442
449
|
}
|
|
443
450
|
}
|
|
444
|
-
function
|
|
451
|
+
function X(s) {
|
|
445
452
|
return {
|
|
446
|
-
getTitle: () =>
|
|
453
|
+
getTitle: () => s.title,
|
|
447
454
|
setTitle: (e) => {
|
|
448
|
-
|
|
455
|
+
s.title = e;
|
|
449
456
|
},
|
|
450
457
|
observeTitle: (e) => {
|
|
451
458
|
const t = new MutationObserver(e);
|
|
452
|
-
return t.observe(
|
|
459
|
+
return t.observe(s.head, {
|
|
453
460
|
childList: !0,
|
|
454
461
|
subtree: !0,
|
|
455
462
|
characterData: !0
|
|
@@ -457,20 +464,20 @@ function J(i) {
|
|
|
457
464
|
}
|
|
458
465
|
};
|
|
459
466
|
}
|
|
460
|
-
function y(
|
|
461
|
-
return
|
|
467
|
+
function y(s) {
|
|
468
|
+
return s.replace(U, "");
|
|
462
469
|
}
|
|
463
|
-
function
|
|
470
|
+
function P(s, e) {
|
|
464
471
|
const t = new Set([
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
].filter((n) => !!n)),
|
|
472
|
+
s.assistantDraftRespondsToUserMessageId,
|
|
473
|
+
s.activeResponseUserMessageId,
|
|
474
|
+
s.messages.filter((n) => n.role === "user").slice(-1)[0]?.id
|
|
475
|
+
].filter((n) => !!n)), i = s.messages.filter((n) => !(n.dataType === "run_status" && n.loading && t.has(n.respondsToUserMessageId ?? ""))).map((n) => t.has(n.respondsToUserMessageId ?? "") ? { ...n, loading: !1 } : n);
|
|
469
476
|
for (const n of t)
|
|
470
|
-
|
|
477
|
+
i.some((a) => a.respondsToUserMessageId === n && (a.dataType === "run_status" || a.dataType === "run_error" || a.role === "assistant" && a.phase !== "commentary")) || i.push({ id: `local-interrupted:${n}`, role: "system", dataType: "run_status", content: "Run stopped by user.", createdAt: e, respondsToUserMessageId: n });
|
|
471
478
|
return {
|
|
472
|
-
...
|
|
473
|
-
messages:
|
|
479
|
+
...s,
|
|
480
|
+
messages: i,
|
|
474
481
|
isThinking: !1,
|
|
475
482
|
isRetrying: !1,
|
|
476
483
|
pendingMessageStatus: null,
|
|
@@ -480,18 +487,18 @@ function _(i, e) {
|
|
|
480
487
|
lastErrorCode: null
|
|
481
488
|
};
|
|
482
489
|
}
|
|
483
|
-
const S = (
|
|
484
|
-
function
|
|
485
|
-
if (!
|
|
486
|
-
const e =
|
|
490
|
+
const S = (s) => s === null || typeof s == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(s);
|
|
491
|
+
function N(s) {
|
|
492
|
+
if (!s || typeof s != "object") return !1;
|
|
493
|
+
const e = s;
|
|
487
494
|
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";
|
|
488
495
|
}
|
|
489
|
-
const
|
|
490
|
-
function
|
|
491
|
-
const e =
|
|
492
|
-
return e.length >
|
|
496
|
+
const _ = 500;
|
|
497
|
+
function $(s) {
|
|
498
|
+
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();
|
|
499
|
+
return e.length > _ ? `${e.slice(0, _ - 1)}…` : e;
|
|
493
500
|
}
|
|
494
|
-
const
|
|
501
|
+
const B = {
|
|
495
502
|
"in-progress-stop-unavailable": "An in-progress response has no visible enabled interrupt control.",
|
|
496
503
|
"stop-did-not-interrupt": "The stopped response remained in progress after an interrupt click.",
|
|
497
504
|
"duplicate-message-item": "A canonical message rendered more than once.",
|
|
@@ -506,23 +513,23 @@ const $ = {
|
|
|
506
513
|
"thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
|
|
507
514
|
"thinking-without-progress": "Thinking remained visible without progress for five minutes."
|
|
508
515
|
};
|
|
509
|
-
function K(
|
|
510
|
-
return typeof
|
|
516
|
+
function K(s) {
|
|
517
|
+
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(B, s.slice(13));
|
|
511
518
|
}
|
|
512
|
-
function
|
|
519
|
+
function E(s) {
|
|
513
520
|
return {
|
|
514
|
-
...
|
|
515
|
-
name:
|
|
516
|
-
mimeType:
|
|
517
|
-
sizeBytes:
|
|
518
|
-
...
|
|
519
|
-
...
|
|
520
|
-
...
|
|
521
|
+
...s.id === void 0 ? {} : { id: s.id },
|
|
522
|
+
name: s.name,
|
|
523
|
+
mimeType: s.mimeType,
|
|
524
|
+
sizeBytes: s.sizeBytes,
|
|
525
|
+
...s.sandboxPath === void 0 ? {} : { sandboxPath: s.sandboxPath },
|
|
526
|
+
...s.storageKey === void 0 ? {} : { storageKey: s.storageKey },
|
|
527
|
+
...s.fileUrl === void 0 ? {} : { fileUrl: s.fileUrl }
|
|
521
528
|
};
|
|
522
529
|
}
|
|
523
|
-
function
|
|
524
|
-
if (!
|
|
525
|
-
const e =
|
|
530
|
+
function ee(s) {
|
|
531
|
+
if (!s || typeof s != "object" || !("type" in s)) return !1;
|
|
532
|
+
const e = s;
|
|
526
533
|
switch (e.type) {
|
|
527
534
|
case "runtime.connect":
|
|
528
535
|
case "session.new":
|
|
@@ -531,7 +538,7 @@ function Y(i) {
|
|
|
531
538
|
case "run.stop":
|
|
532
539
|
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);
|
|
533
540
|
case "runtime.report_response_visibility":
|
|
534
|
-
return
|
|
541
|
+
return N(e.observation);
|
|
535
542
|
case "runtime.warmup":
|
|
536
543
|
return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
|
|
537
544
|
case "runtime.report_displayed_error":
|
|
@@ -565,9 +572,9 @@ function Y(i) {
|
|
|
565
572
|
return !1;
|
|
566
573
|
}
|
|
567
574
|
}
|
|
568
|
-
class
|
|
569
|
-
constructor(e, t,
|
|
570
|
-
this.adapter = t, this.state = A(e), this.model =
|
|
575
|
+
class te {
|
|
576
|
+
constructor(e, t, i) {
|
|
577
|
+
this.adapter = t, this.state = A(e), this.model = i;
|
|
571
578
|
}
|
|
572
579
|
adapter;
|
|
573
580
|
listeners = {};
|
|
@@ -587,57 +594,57 @@ class W {
|
|
|
587
594
|
operationQueue = Promise.resolve();
|
|
588
595
|
destroyed = !1;
|
|
589
596
|
on(e, t) {
|
|
590
|
-
const
|
|
591
|
-
return
|
|
597
|
+
const i = this.listeners[e] ?? /* @__PURE__ */ new Set();
|
|
598
|
+
return i.add(t), this.listeners[e] = i, () => i.delete(t);
|
|
592
599
|
}
|
|
593
600
|
getState() {
|
|
594
601
|
return A(this.state);
|
|
595
602
|
}
|
|
596
|
-
updateProjection(e, t,
|
|
603
|
+
updateProjection(e, t, i, n, a) {
|
|
597
604
|
if (this.destroyed) return;
|
|
598
|
-
const
|
|
599
|
-
if (this.state = A(e),
|
|
605
|
+
const c = this.state;
|
|
606
|
+
if (this.state = A(e), c.user?.id === e.user?.id)
|
|
600
607
|
for (const r of this.state.messages) {
|
|
601
608
|
if (r.role !== "user" || !r.attachments?.length) continue;
|
|
602
|
-
const
|
|
603
|
-
|
|
609
|
+
const l = r.clientMessageId, d = c.messages.find((u) => u.role === "user" && (u.id === r.id || l && u.clientMessageId === l));
|
|
610
|
+
c.sessionId !== e.sessionId && !(c.sessionId === null && l && d?.clientMessageId === l) || (r.attachments = M(d?.attachments, r.attachments));
|
|
604
611
|
}
|
|
605
612
|
if (this.stoppedProjection) {
|
|
606
|
-
const r = this.stoppedProjection,
|
|
607
|
-
if (!
|
|
613
|
+
const r = this.stoppedProjection, l = new Set(r.messages.filter((o) => o.role === "user").map((o) => o.id)), d = e.sessionId === r.sessionId && e.user?.id === r.user?.id, u = e.messages.some((o) => o.role === "user" && !l.has(o.id) && !r.messages.some((h) => h.clientMessageId && h.clientMessageId === o.clientMessageId));
|
|
614
|
+
if (!d || u)
|
|
608
615
|
this.stoppedProjection = null;
|
|
609
616
|
else {
|
|
610
|
-
const
|
|
617
|
+
const o = [
|
|
611
618
|
r.activeResponseUserMessageId,
|
|
612
619
|
r.assistantDraftRespondsToUserMessageId,
|
|
613
620
|
r.messages.filter((v) => v.role === "user").slice(-1)[0]?.id
|
|
614
|
-
].filter(Boolean), h =
|
|
615
|
-
this.state =
|
|
621
|
+
].filter(Boolean), h = o.length > 0 && o.every((v) => e.messages.some((p) => p.respondsToUserMessageId === v && !p.loading && (p.dataType === "run_status" || p.dataType === "run_error" || p.role === "assistant" && p.phase !== "commentary")));
|
|
622
|
+
this.state = P(h ? this.state : {
|
|
616
623
|
...this.state,
|
|
617
624
|
messages: r.messages,
|
|
618
625
|
assistantDraft: r.assistantDraft
|
|
619
626
|
}, (/* @__PURE__ */ new Date()).toISOString()), this.stoppedProjection = this.getState();
|
|
620
627
|
}
|
|
621
628
|
}
|
|
622
|
-
for (const [r,
|
|
623
|
-
if (e.user?.id !==
|
|
629
|
+
for (const [r, l] of this.unacknowledgedSubmissions) {
|
|
630
|
+
if (e.user?.id !== l.userId || l.sessionId !== null && e.sessionId !== l.sessionId) {
|
|
624
631
|
this.unacknowledgedSubmissions.delete(r);
|
|
625
632
|
continue;
|
|
626
633
|
}
|
|
627
|
-
const
|
|
634
|
+
const d = this.state.messages.find(
|
|
628
635
|
(u) => u.clientMessageId === r
|
|
629
636
|
);
|
|
630
|
-
if (
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
637
|
+
if (d) {
|
|
638
|
+
d.attachments = M(
|
|
639
|
+
l.message.attachments,
|
|
640
|
+
d.attachments
|
|
634
641
|
), this.unacknowledgedSubmissions.delete(r);
|
|
635
642
|
continue;
|
|
636
643
|
}
|
|
637
|
-
|
|
644
|
+
l.sessionId ??= e.sessionId, this.state.messages.push(l.message), this.state.pendingMessageStatus = "sending", this.state.turnPhase ??= "sending", this.state.taskStatus ??= "working";
|
|
638
645
|
}
|
|
639
|
-
if (t !== void 0 && (this.model = t),
|
|
640
|
-
this.sessionHistoryState =
|
|
646
|
+
if (t !== void 0 && (this.model = t), i && JSON.stringify(i) !== JSON.stringify(this.sessionHistoryState)) {
|
|
647
|
+
this.sessionHistoryState = T(i);
|
|
641
648
|
for (const r of this.sessionHistoryListeners)
|
|
642
649
|
r(this.getSessionHistoryState());
|
|
643
650
|
}
|
|
@@ -680,33 +687,33 @@ class W {
|
|
|
680
687
|
}).catch(() => {
|
|
681
688
|
});
|
|
682
689
|
}
|
|
683
|
-
reportDisplayedError(e, t,
|
|
690
|
+
reportDisplayedError(e, t, i) {
|
|
684
691
|
this.adapter.dispatch({
|
|
685
692
|
type: "runtime.report_displayed_error",
|
|
686
693
|
reason: e,
|
|
687
694
|
errorFingerprint: t,
|
|
688
|
-
...
|
|
695
|
+
...i ? { displayedMessage: $(i) } : {}
|
|
689
696
|
}).catch(() => {
|
|
690
697
|
});
|
|
691
698
|
}
|
|
692
699
|
sendMessage(e, t = {}) {
|
|
693
|
-
const
|
|
694
|
-
if (!
|
|
695
|
-
const a = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()),
|
|
700
|
+
const i = e.trim(), n = t.attachments ?? [];
|
|
701
|
+
if (!i && n.length === 0) return Promise.resolve(null);
|
|
702
|
+
const a = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), c = t.submittedAt ?? Date.now(), r = this.state, l = this.submissionGeneration, d = {
|
|
696
703
|
id: `local-${a}`,
|
|
697
704
|
role: "user",
|
|
698
|
-
content:
|
|
705
|
+
content: i,
|
|
699
706
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
700
707
|
...n.length > 0 ? { attachments: n } : {},
|
|
701
708
|
clientMessageId: a
|
|
702
709
|
};
|
|
703
710
|
this.unacknowledgedSubmissions.set(a, {
|
|
704
|
-
message: { ...
|
|
711
|
+
message: { ...d, attachments: d.attachments?.map((o) => ({ ...o })) },
|
|
705
712
|
sessionId: r.sessionId,
|
|
706
713
|
userId: r.user?.id
|
|
707
714
|
}), this.state = {
|
|
708
715
|
...this.state,
|
|
709
|
-
messages: [...this.state.messages,
|
|
716
|
+
messages: [...this.state.messages, d],
|
|
710
717
|
pendingMessageStatus: "sending",
|
|
711
718
|
turnPhase: this.state.isThinking ? this.state.turnPhase : "sending",
|
|
712
719
|
taskStatus: "working",
|
|
@@ -714,72 +721,77 @@ class W {
|
|
|
714
721
|
lastError: null
|
|
715
722
|
};
|
|
716
723
|
const u = this.enqueueOperation(() => this.sendMessageNow(
|
|
717
|
-
|
|
718
|
-
{ ...t, clientMessageId: a, submittedAt:
|
|
724
|
+
i,
|
|
725
|
+
{ ...t, clientMessageId: a, submittedAt: c },
|
|
719
726
|
r,
|
|
720
|
-
|
|
727
|
+
l
|
|
721
728
|
));
|
|
722
729
|
return this.emit("state", this.getState()), u;
|
|
723
730
|
}
|
|
724
|
-
async sendMessageNow(e, t,
|
|
725
|
-
const a = e,
|
|
726
|
-
let r = t.attachments ?? [],
|
|
731
|
+
async sendMessageNow(e, t, i, n) {
|
|
732
|
+
const a = e, c = t.clientMessageId;
|
|
733
|
+
let r = t.attachments ?? [], l = !1;
|
|
727
734
|
if (n !== this.submissionGeneration) return null;
|
|
728
735
|
try {
|
|
729
736
|
if (await this.adapter.dispatch({
|
|
730
737
|
type: "conversation.stage",
|
|
731
738
|
content: a,
|
|
732
|
-
clientMessageId:
|
|
739
|
+
clientMessageId: c,
|
|
733
740
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
734
741
|
// Preview URLs belong to the renderer's optimistic snapshot and are not valid runtime-command metadata.
|
|
735
|
-
attachments: r.length > 0 ? r.map(
|
|
742
|
+
attachments: r.length > 0 ? r.map(E) : void 0,
|
|
736
743
|
submittedAt: t.submittedAt
|
|
737
744
|
}), n !== this.submissionGeneration) return null;
|
|
738
|
-
if (
|
|
745
|
+
if (l = !0, r.length > 0) {
|
|
739
746
|
if (!this.adapter.uploadAttachment)
|
|
740
747
|
throw new Error("The runtime does not support attachments.");
|
|
741
748
|
const u = [];
|
|
742
|
-
for (const
|
|
743
|
-
if (
|
|
744
|
-
u.push(
|
|
749
|
+
for (const o of r) {
|
|
750
|
+
if (o.sandboxPath || o.storageKey) {
|
|
751
|
+
u.push(o);
|
|
745
752
|
continue;
|
|
746
753
|
}
|
|
747
|
-
const h =
|
|
748
|
-
if (!h) throw new Error(`Attachment bytes are unavailable for ${
|
|
749
|
-
if (u.push(await this.adapter.uploadAttachment(h,
|
|
754
|
+
const h = o.id ? this.attachmentFiles.get(o.id) : void 0;
|
|
755
|
+
if (!h) throw new Error(`Attachment bytes are unavailable for ${o.name}`);
|
|
756
|
+
if (u.push(await this.adapter.uploadAttachment(h, o, { clientMessageId: c })), n !== this.submissionGeneration) return null;
|
|
750
757
|
}
|
|
751
758
|
r = u;
|
|
752
759
|
}
|
|
753
|
-
const
|
|
760
|
+
const d = await this.adapter.dispatch({
|
|
754
761
|
type: "conversation.send",
|
|
755
762
|
content: a,
|
|
756
|
-
clientMessageId:
|
|
763
|
+
clientMessageId: c,
|
|
757
764
|
initiatedBy: t.initiatedBy,
|
|
758
765
|
invocation: t.invocation,
|
|
759
766
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
760
767
|
...t.automationOnboarding ? { automationOnboarding: !0 } : {},
|
|
761
|
-
attachments: r.length > 0 ? r.map(
|
|
768
|
+
attachments: r.length > 0 ? r.map(E) : void 0
|
|
762
769
|
});
|
|
763
770
|
if (n !== this.submissionGeneration) return null;
|
|
764
771
|
for (const u of t.attachments ?? [])
|
|
765
772
|
u.id && this.attachmentFiles.delete(u.id);
|
|
766
|
-
return
|
|
767
|
-
} catch (
|
|
773
|
+
return c === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), d?.clientMessageId ?? c;
|
|
774
|
+
} catch (d) {
|
|
768
775
|
if (n !== this.submissionGeneration) return null;
|
|
769
|
-
|
|
776
|
+
const u = C(d);
|
|
777
|
+
if (u)
|
|
778
|
+
for (const o of t.attachments ?? [])
|
|
779
|
+
o.id && this.attachmentFiles.delete(o.id);
|
|
780
|
+
throw this.unacknowledgedSubmissions.delete(c), this.state = {
|
|
770
781
|
...this.state,
|
|
771
|
-
messages: this.state.messages.filter(
|
|
772
|
-
(
|
|
782
|
+
messages: u ? this.state.messages : this.state.messages.filter(
|
|
783
|
+
(o) => o.id !== `local-${c}` && o.id !== `optimistic-user-message:${c}`
|
|
773
784
|
),
|
|
774
|
-
pendingMessageStatus:
|
|
775
|
-
turnPhase:
|
|
776
|
-
isThinking:
|
|
777
|
-
taskStatus:
|
|
778
|
-
|
|
785
|
+
pendingMessageStatus: i.pendingMessageStatus,
|
|
786
|
+
turnPhase: i.turnPhase,
|
|
787
|
+
isThinking: i.isThinking,
|
|
788
|
+
taskStatus: u ? "failed" : i.taskStatus,
|
|
789
|
+
...u ? { lastError: d instanceof Error ? d.message : String(d), lastErrorCode: "auth_reconnecting" } : {}
|
|
790
|
+
}, this.emit("state", this.getState()), l && await this.adapter.dispatch({
|
|
779
791
|
type: "conversation.fail_staged",
|
|
780
|
-
clientMessageId:
|
|
781
|
-
message:
|
|
782
|
-
}),
|
|
792
|
+
clientMessageId: c,
|
|
793
|
+
message: d instanceof Error ? d.message : String(d)
|
|
794
|
+
}), d;
|
|
783
795
|
}
|
|
784
796
|
}
|
|
785
797
|
getModel() {
|
|
@@ -803,7 +815,7 @@ class W {
|
|
|
803
815
|
}
|
|
804
816
|
stop() {
|
|
805
817
|
const e = this.cancelPendingSubmissions();
|
|
806
|
-
this.state =
|
|
818
|
+
this.state = P(this.state, (/* @__PURE__ */ new Date()).toISOString()), this.stoppedProjection = this.getState(), this.emit("state", this.getState());
|
|
807
819
|
const t = this.adapter.dispatch({ type: "run.stop", ...e.length ? { clientMessageIds: e } : {} });
|
|
808
820
|
return this.operationQueue = t.then(() => {
|
|
809
821
|
}, () => {
|
|
@@ -814,8 +826,8 @@ class W {
|
|
|
814
826
|
const e = [...this.unacknowledgedSubmissions.keys()];
|
|
815
827
|
this.submissionGeneration++;
|
|
816
828
|
for (const t of this.unacknowledgedSubmissions.values())
|
|
817
|
-
for (const
|
|
818
|
-
|
|
829
|
+
for (const i of t.message.attachments ?? [])
|
|
830
|
+
i.id && this.attachmentFiles.delete(i.id);
|
|
819
831
|
return this.unacknowledgedSubmissions.clear(), this.operationQueue = Promise.resolve(), e;
|
|
820
832
|
}
|
|
821
833
|
startNewSession(e = {}) {
|
|
@@ -825,14 +837,14 @@ class W {
|
|
|
825
837
|
async listSessions(e = {}) {
|
|
826
838
|
const t = await this.dispatch({ type: "session.list", ...e });
|
|
827
839
|
if (t === void 0) {
|
|
828
|
-
const
|
|
829
|
-
return { sessions:
|
|
840
|
+
const i = this.getSessionHistoryState().data;
|
|
841
|
+
return { sessions: i ? i.ids.map((n) => i.entitiesById[n]) : [], nextCursor: i?.nextCursor ?? null };
|
|
830
842
|
}
|
|
831
843
|
if (!t?.sessionHistoryPage) throw new Error("Session list command did not return a page.");
|
|
832
844
|
return t.sessionHistoryPage;
|
|
833
845
|
}
|
|
834
846
|
getSessionHistoryState() {
|
|
835
|
-
return
|
|
847
|
+
return T(this.sessionHistoryState);
|
|
836
848
|
}
|
|
837
849
|
subscribeSessionHistory(e) {
|
|
838
850
|
return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
|
|
@@ -860,12 +872,12 @@ class W {
|
|
|
860
872
|
subscribeInteractions(e) {
|
|
861
873
|
return this.interactionListeners.add(e), e(this.getInteractions()), () => this.interactionListeners.delete(e);
|
|
862
874
|
}
|
|
863
|
-
actOnInteraction(e, t,
|
|
875
|
+
actOnInteraction(e, t, i, n = {}) {
|
|
864
876
|
return this.dispatch({
|
|
865
877
|
type: "interaction.act",
|
|
866
878
|
interactionId: e,
|
|
867
879
|
action: t,
|
|
868
|
-
expectedRevision:
|
|
880
|
+
expectedRevision: i,
|
|
869
881
|
...n
|
|
870
882
|
}).then(() => {
|
|
871
883
|
});
|
|
@@ -886,11 +898,11 @@ class W {
|
|
|
886
898
|
stageProactiveSuggestionQuestion(e) {
|
|
887
899
|
const t = e.trim();
|
|
888
900
|
if (!t) return Promise.resolve();
|
|
889
|
-
const
|
|
890
|
-
return this.stagedProactiveSuggestionClientMessageId =
|
|
901
|
+
const i = this.stagedProactiveSuggestionClientMessageId ?? crypto.randomUUID();
|
|
902
|
+
return this.stagedProactiveSuggestionClientMessageId = i, this.dispatch({
|
|
891
903
|
type: "conversation.stage_proactive_suggestion",
|
|
892
904
|
question: t,
|
|
893
|
-
clientMessageId:
|
|
905
|
+
clientMessageId: i
|
|
894
906
|
}).then(() => {
|
|
895
907
|
});
|
|
896
908
|
}
|
|
@@ -907,73 +919,76 @@ class W {
|
|
|
907
919
|
), t;
|
|
908
920
|
}
|
|
909
921
|
emit(e, t) {
|
|
910
|
-
const
|
|
911
|
-
for (const n of
|
|
922
|
+
const i = this.listeners[e];
|
|
923
|
+
for (const n of i ?? []) n(t);
|
|
912
924
|
}
|
|
913
925
|
}
|
|
914
|
-
function
|
|
915
|
-
if (!e || !
|
|
926
|
+
function M(s, e) {
|
|
927
|
+
if (!e || !s) return e;
|
|
916
928
|
const t = /* @__PURE__ */ new Map();
|
|
917
|
-
for (const
|
|
918
|
-
const n =
|
|
919
|
-
|
|
929
|
+
for (const i of s) {
|
|
930
|
+
const n = i.previewUrl;
|
|
931
|
+
i.id && n && t.set(i.id, n);
|
|
920
932
|
}
|
|
921
|
-
return e.map((
|
|
922
|
-
const n =
|
|
923
|
-
return n ? { ...
|
|
933
|
+
return e.map((i) => {
|
|
934
|
+
const n = i.id ? t.get(i.id) : void 0;
|
|
935
|
+
return n ? { ...i, previewUrl: n } : i;
|
|
924
936
|
});
|
|
925
937
|
}
|
|
926
|
-
function A(
|
|
938
|
+
function A(s) {
|
|
927
939
|
return {
|
|
928
|
-
...
|
|
929
|
-
starterPrompts: [...
|
|
930
|
-
appearance:
|
|
931
|
-
messages:
|
|
940
|
+
...s,
|
|
941
|
+
starterPrompts: [...s.starterPrompts],
|
|
942
|
+
appearance: s.appearance ? { ...s.appearance } : null,
|
|
943
|
+
messages: s.messages.map((e) => {
|
|
932
944
|
const t = {
|
|
933
945
|
...e,
|
|
934
|
-
attachments: e.attachments?.map((
|
|
935
|
-
},
|
|
946
|
+
attachments: e.attachments?.map((c) => ({ ...c }))
|
|
947
|
+
}, i = e.assistantDraftItemId, n = e.clientMessageId, a = e.proactiveSuggestionClientMessageId;
|
|
936
948
|
return a && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
|
|
937
949
|
value: a,
|
|
938
950
|
enumerable: !1
|
|
939
|
-
}),
|
|
940
|
-
value:
|
|
951
|
+
}), i && Object.defineProperty(t, "assistantDraftItemId", {
|
|
952
|
+
value: i,
|
|
941
953
|
enumerable: !1
|
|
942
954
|
}), n && Object.defineProperty(t, "clientMessageId", {
|
|
943
955
|
value: n,
|
|
944
956
|
enumerable: !1
|
|
945
957
|
}), t;
|
|
946
958
|
}),
|
|
947
|
-
activeScheduledFollowUps:
|
|
959
|
+
activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
|
|
948
960
|
};
|
|
949
961
|
}
|
|
950
|
-
function
|
|
962
|
+
function T(s) {
|
|
951
963
|
return {
|
|
952
|
-
...
|
|
953
|
-
data:
|
|
954
|
-
entities:
|
|
955
|
-
nextCursor:
|
|
964
|
+
...s,
|
|
965
|
+
data: s.data ? m({
|
|
966
|
+
entities: R(s.data).map((e) => ({ ...e })),
|
|
967
|
+
nextCursor: s.data.nextCursor
|
|
956
968
|
}) : null
|
|
957
969
|
};
|
|
958
970
|
}
|
|
959
971
|
export {
|
|
960
|
-
|
|
972
|
+
k as PRODUCT_AGENT_AUTH_RECONNECTING_ERROR_MESSAGE,
|
|
973
|
+
J as ProductAgentInteractionManager,
|
|
961
974
|
w as ProductAgentQueryController,
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
975
|
+
te as ProductAgentRemoteRuntimeClient,
|
|
976
|
+
Z as ProductAgentSessionHistoryManager,
|
|
977
|
+
Y as ProductAgentTaskPageTitleController,
|
|
978
|
+
G as canSubmitPersonalProductAgentMessage,
|
|
979
|
+
W as createLocalStorageInteractionDecisionStorage,
|
|
966
980
|
f as createProductAgentQueryState,
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
981
|
+
X as createProductAgentTaskPageTitleDocument,
|
|
982
|
+
Q as formatProductAgentTaskPageTitle,
|
|
983
|
+
z as hasProductAgentPaidCreditFallback,
|
|
984
|
+
C as isProductAgentAuthReconnectError,
|
|
985
|
+
ee as isProductAgentRuntimeCommand,
|
|
986
|
+
D as mergeProductAgentEntityPages,
|
|
972
987
|
m as normalizeProductAgentEntityPage,
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
988
|
+
L as readLocalStorageInteractionDecisions,
|
|
989
|
+
j as reconcileProductAgentSubmissionGate,
|
|
990
|
+
H as resolveProductAgentBillingPresentation,
|
|
991
|
+
V as resolveProductAgentComposerAction,
|
|
992
|
+
F as resolveProductAgentWidgetPresentation,
|
|
993
|
+
R as selectProductAgentQueryEntities
|
|
979
994
|
};
|