@pluno/product-agent-web 0.1.209 → 0.1.210
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 +336 -322
- package/dist/product-agent-sdk.js +298 -283
- package/dist/product-agent-widget.js +2956 -2799
- package/dist/uiFlightRecorder.d.ts +42 -0
- package/dist/uiInvariants.d.ts +31 -0
- package/package.json +1 -1
|
@@ -9,8 +9,8 @@ function h(s) {
|
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
class b {
|
|
12
|
-
constructor(
|
|
13
|
-
this.loader =
|
|
12
|
+
constructor(e, t, i = (n, r) => r) {
|
|
13
|
+
this.loader = t, this.merge = i, this.state = h(e);
|
|
14
14
|
}
|
|
15
15
|
loader;
|
|
16
16
|
merge;
|
|
@@ -21,11 +21,11 @@ class b {
|
|
|
21
21
|
getState() {
|
|
22
22
|
return this.state;
|
|
23
23
|
}
|
|
24
|
-
subscribe(
|
|
25
|
-
return this.listeners.add(
|
|
24
|
+
subscribe(e) {
|
|
25
|
+
return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
|
|
26
26
|
}
|
|
27
|
-
setKey(
|
|
28
|
-
|
|
27
|
+
setKey(e) {
|
|
28
|
+
e !== this.state.key && (this.state = h(e), this.trailingLoad = null, this.publish());
|
|
29
29
|
}
|
|
30
30
|
reset() {
|
|
31
31
|
this.state = h(this.state.key), this.trailingLoad = null, this.publish();
|
|
@@ -37,40 +37,40 @@ class b {
|
|
|
37
37
|
updatedAt: null
|
|
38
38
|
}, this.publish();
|
|
39
39
|
}
|
|
40
|
-
load(
|
|
41
|
-
return this.trailingLoad = { mode:
|
|
40
|
+
load(e = "replace", t = null) {
|
|
41
|
+
return this.trailingLoad = { mode: e, cursor: t }, this.inFlight ? this.inFlight : (this.inFlight = this.runLoads().finally(() => {
|
|
42
42
|
this.inFlight = null;
|
|
43
43
|
}), this.inFlight);
|
|
44
44
|
}
|
|
45
|
-
update(
|
|
45
|
+
update(e) {
|
|
46
46
|
this.state = {
|
|
47
47
|
...this.state,
|
|
48
|
-
data:
|
|
48
|
+
data: e(this.state.data)
|
|
49
49
|
}, this.publish();
|
|
50
50
|
}
|
|
51
51
|
async runLoads() {
|
|
52
52
|
for (; this.trailingLoad; ) {
|
|
53
|
-
const
|
|
53
|
+
const e = this.trailingLoad;
|
|
54
54
|
this.trailingLoad = null;
|
|
55
|
-
const
|
|
55
|
+
const t = this.state.key, i = this.state.requestId + 1;
|
|
56
56
|
this.state = {
|
|
57
57
|
...this.state,
|
|
58
|
-
status:
|
|
58
|
+
status: e.mode === "append" ? "loading_more" : this.state.data === null ? "loading" : "refreshing",
|
|
59
59
|
error: null,
|
|
60
60
|
requestId: i
|
|
61
61
|
}, this.publish();
|
|
62
62
|
try {
|
|
63
|
-
const n = await this.loader({ key:
|
|
64
|
-
if (
|
|
63
|
+
const n = await this.loader({ key: t, cursor: e.cursor });
|
|
64
|
+
if (t !== this.state.key || i !== this.state.requestId) continue;
|
|
65
65
|
this.state = {
|
|
66
66
|
...this.state,
|
|
67
67
|
status: "ready",
|
|
68
|
-
data: this.merge(this.state.data, n,
|
|
68
|
+
data: this.merge(this.state.data, n, e.mode),
|
|
69
69
|
error: null,
|
|
70
70
|
updatedAt: Date.now()
|
|
71
71
|
}, this.publish();
|
|
72
72
|
} catch (n) {
|
|
73
|
-
if (
|
|
73
|
+
if (t !== this.state.key || i !== this.state.requestId) continue;
|
|
74
74
|
this.state = {
|
|
75
75
|
...this.state,
|
|
76
76
|
status: "error",
|
|
@@ -80,57 +80,57 @@ class b {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
publish() {
|
|
83
|
-
for (const
|
|
83
|
+
for (const e of this.listeners) e(this.state);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
function p(s) {
|
|
87
|
-
const
|
|
87
|
+
const e = {}, t = [];
|
|
88
88
|
for (const i of s.entities)
|
|
89
|
-
|
|
89
|
+
e[i.id] || t.push(i.id), e[i.id] = i;
|
|
90
90
|
return {
|
|
91
|
-
entitiesById:
|
|
92
|
-
ids:
|
|
91
|
+
entitiesById: e,
|
|
92
|
+
ids: t,
|
|
93
93
|
nextCursor: s.nextCursor
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
function _(s,
|
|
97
|
-
if (
|
|
98
|
-
const i = { ...s.entitiesById, ...
|
|
99
|
-
for (const r of
|
|
96
|
+
function _(s, e, t) {
|
|
97
|
+
if (t === "replace" || s === null) return e;
|
|
98
|
+
const i = { ...s.entitiesById, ...e.entitiesById }, n = [...s.ids];
|
|
99
|
+
for (const r of e.ids)
|
|
100
100
|
s.entitiesById[r] || n.push(r);
|
|
101
|
-
return { entitiesById: i, ids: n, nextCursor:
|
|
101
|
+
return { entitiesById: i, ids: n, nextCursor: e.nextCursor };
|
|
102
102
|
}
|
|
103
103
|
function w(s) {
|
|
104
|
-
return s ? s.ids.map((
|
|
104
|
+
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function C(s) {
|
|
107
107
|
return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
return
|
|
109
|
+
function L(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
|
|
112
|
+
function k(s) {
|
|
113
113
|
if (!s || typeof s != "object") return !1;
|
|
114
|
-
const
|
|
115
|
-
return typeof
|
|
114
|
+
const e = s.paidCreditFallbackModel;
|
|
115
|
+
return typeof e == "string" && e.length > 0;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function q(s) {
|
|
118
118
|
return s ? s.submissionGate?.allowed === !1 ? { state: "action_required", reason: s.submissionGate.reason } : s.usingPaidCreditFallback === !0 ? { state: "paid_credit_fallback" } : s.creditLimit !== null && s.creditLimit > 0 && s.creditsRemaining !== null && s.creditsRemaining > 0 && s.creditsRemaining / s.creditLimit <= 0.2 ? { state: "low_credits" } : s.creditsUsed !== null ? { state: "usage" } : { state: "hidden" } : { state: "hidden" };
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
-
return s.hasRunningAssistantTurn && !
|
|
120
|
+
function Q(s) {
|
|
121
|
+
const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
|
|
122
|
+
return s.hasRunningAssistantTurn && !e ? {
|
|
123
123
|
action: "stop",
|
|
124
124
|
disabled: !s.canStopRunningTurn
|
|
125
125
|
} : {
|
|
126
126
|
action: "send",
|
|
127
|
-
disabled: !
|
|
127
|
+
disabled: !e || !s.canSubmitMessage
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
class
|
|
131
|
-
constructor(
|
|
132
|
-
this.loadPage =
|
|
133
|
-
`${
|
|
130
|
+
class $ {
|
|
131
|
+
constructor(e, t, i = 20) {
|
|
132
|
+
this.loadPage = t, this.limit = i, this.recentQuery = new b(
|
|
133
|
+
`${e}:recent`,
|
|
134
134
|
async ({ cursor: n }) => p(
|
|
135
135
|
await this.loadPage({ cursor: n, limit: this.limit, pinned: !1 }).then((r) => ({
|
|
136
136
|
entities: r.sessions,
|
|
@@ -139,7 +139,7 @@ class q {
|
|
|
139
139
|
),
|
|
140
140
|
_
|
|
141
141
|
), this.pinnedQuery = new b(
|
|
142
|
-
`${
|
|
142
|
+
`${e}:pinned`,
|
|
143
143
|
async () => p({
|
|
144
144
|
entities: await this.loadAllPinned(),
|
|
145
145
|
nextCursor: null
|
|
@@ -159,133 +159,133 @@ class q {
|
|
|
159
159
|
completedRefreshSequence = 0;
|
|
160
160
|
activityReconciliationScheduled = !1;
|
|
161
161
|
getState() {
|
|
162
|
-
const
|
|
163
|
-
...u(
|
|
164
|
-
...u(
|
|
162
|
+
const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), i = [
|
|
163
|
+
...u(t.data),
|
|
164
|
+
...u(e.data)
|
|
165
165
|
], n = new Map(i.map((o) => [o.id, o])), r = Array.from(n.values()).map(
|
|
166
166
|
(o) => this.applyOverrides(o, this.completedRefreshSequence)
|
|
167
|
-
), a = Array.from(this.optimisticEntities.values()).filter((o) => !n.has(o.id)).reverse(), l =
|
|
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],
|
|
169
|
-
nextCursor:
|
|
169
|
+
nextCursor: e.data?.nextCursor ?? null
|
|
170
170
|
}) : null;
|
|
171
171
|
return {
|
|
172
|
-
key:
|
|
173
|
-
status: I(
|
|
172
|
+
key: e.key.slice(0, -7),
|
|
173
|
+
status: I(e, t),
|
|
174
174
|
data: l,
|
|
175
|
-
error:
|
|
176
|
-
requestId: Math.max(
|
|
177
|
-
updatedAt: Math.max(
|
|
175
|
+
error: e.error ?? t.error,
|
|
176
|
+
requestId: Math.max(e.requestId, t.requestId),
|
|
177
|
+
updatedAt: Math.max(e.updatedAt ?? 0, t.updatedAt ?? 0) || null
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
|
-
subscribe(
|
|
181
|
-
return this.listeners.add(
|
|
180
|
+
subscribe(e) {
|
|
181
|
+
return this.listeners.add(e), e(this.getState()), () => this.listeners.delete(e);
|
|
182
182
|
}
|
|
183
|
-
getEntity(
|
|
184
|
-
return this.getState().data?.entitiesById[
|
|
183
|
+
getEntity(e) {
|
|
184
|
+
return this.getState().data?.entitiesById[e] ?? null;
|
|
185
185
|
}
|
|
186
|
-
setKey(
|
|
187
|
-
this.optimisticEntities.clear(), this.activityOverrides.clear(), this.pinnedOverrides.clear(), this.titleOverrides.clear(), this.refreshSequence = 0, this.completedRefreshSequence = 0, this.activityReconciliationScheduled = !1, this.recentQuery.setKey(`${
|
|
186
|
+
setKey(e) {
|
|
187
|
+
this.optimisticEntities.clear(), this.activityOverrides.clear(), this.pinnedOverrides.clear(), this.titleOverrides.clear(), this.refreshSequence = 0, this.completedRefreshSequence = 0, this.activityReconciliationScheduled = !1, this.recentQuery.setKey(`${e}:recent`), this.pinnedQuery.setKey(`${e}:pinned`);
|
|
188
188
|
}
|
|
189
189
|
refresh() {
|
|
190
|
-
const
|
|
190
|
+
const e = ++this.refreshSequence, t = Promise.all([
|
|
191
191
|
this.recentQuery.load("replace"),
|
|
192
192
|
this.pinnedQuery.load("replace")
|
|
193
193
|
]).then(() => {
|
|
194
|
-
this.completedRefreshSequence = Math.max(this.completedRefreshSequence,
|
|
194
|
+
this.completedRefreshSequence = Math.max(this.completedRefreshSequence, e), this.reconcileDurableEntities();
|
|
195
195
|
});
|
|
196
|
-
return
|
|
196
|
+
return t.then(() => {
|
|
197
197
|
!this.hasUnconfirmedActivityOverride() || this.activityReconciliationScheduled || (this.activityReconciliationScheduled = !0, this.refresh().finally(() => {
|
|
198
198
|
this.activityReconciliationScheduled = !1;
|
|
199
199
|
}));
|
|
200
|
-
}),
|
|
200
|
+
}), t;
|
|
201
201
|
}
|
|
202
|
-
loadMore(
|
|
203
|
-
return this.recentQuery.load("append",
|
|
202
|
+
loadMore(e) {
|
|
203
|
+
return this.recentQuery.load("append", e);
|
|
204
204
|
}
|
|
205
|
-
addOptimistic(
|
|
206
|
-
this.optimisticEntities.set(
|
|
205
|
+
addOptimistic(e) {
|
|
206
|
+
this.optimisticEntities.set(e.id, e), this.updateProjection();
|
|
207
207
|
}
|
|
208
|
-
removeOptimistic(
|
|
209
|
-
this.optimisticEntities.delete(
|
|
208
|
+
removeOptimistic(e) {
|
|
209
|
+
this.optimisticEntities.delete(e) && this.updateProjection();
|
|
210
210
|
}
|
|
211
|
-
acknowledgeOptimistic(
|
|
212
|
-
this.optimisticEntities.delete(
|
|
211
|
+
acknowledgeOptimistic(e, t) {
|
|
212
|
+
this.optimisticEntities.delete(e), this.optimisticEntities.set(t.id, t), this.updateProjection();
|
|
213
213
|
}
|
|
214
|
-
setActivity(
|
|
215
|
-
this.activityOverrides.set(
|
|
216
|
-
isActive:
|
|
214
|
+
setActivity(e, t) {
|
|
215
|
+
this.activityOverrides.set(e, {
|
|
216
|
+
isActive: t,
|
|
217
217
|
confirmAfterRefresh: this.completedRefreshSequence + 1,
|
|
218
218
|
releaseAfterRefresh: this.completedRefreshSequence + 2
|
|
219
|
-
}), this.updateEntity(
|
|
219
|
+
}), this.updateEntity(e, (i) => ({ ...i, isActive: t }));
|
|
220
220
|
}
|
|
221
|
-
setPinned(
|
|
222
|
-
const i = { pinned:
|
|
223
|
-
return this.pinnedOverrides.set(
|
|
221
|
+
setPinned(e, t) {
|
|
222
|
+
const i = { pinned: t, confirmAfterRefresh: Number.POSITIVE_INFINITY };
|
|
223
|
+
return this.pinnedOverrides.set(e, i), this.updateEntity(e, (n) => ({ ...n, isPinned: t })), i;
|
|
224
224
|
}
|
|
225
|
-
confirmPinned(
|
|
226
|
-
this.pinnedOverrides.get(
|
|
225
|
+
confirmPinned(e, t) {
|
|
226
|
+
this.pinnedOverrides.get(e) === t && (t.confirmAfterRefresh = this.completedRefreshSequence + 1);
|
|
227
227
|
}
|
|
228
|
-
rollbackPinned(
|
|
229
|
-
this.pinnedOverrides.get(
|
|
228
|
+
rollbackPinned(e, t, i) {
|
|
229
|
+
this.pinnedOverrides.get(e) === t && (this.pinnedOverrides.delete(e), this.updateEntity(e, (n) => ({ ...n, isPinned: i })));
|
|
230
230
|
}
|
|
231
|
-
setTitle(
|
|
232
|
-
this.titleOverrides.set(
|
|
231
|
+
setTitle(e, t) {
|
|
232
|
+
this.titleOverrides.set(e, t), this.updateEntity(e, (i) => ({ ...i, customTitle: t }));
|
|
233
233
|
}
|
|
234
|
-
confirmTitle(
|
|
235
|
-
this.titleOverrides.delete(
|
|
234
|
+
confirmTitle(e) {
|
|
235
|
+
this.titleOverrides.delete(e);
|
|
236
236
|
}
|
|
237
237
|
reconcileDurableEntities() {
|
|
238
|
-
const
|
|
238
|
+
const e = [
|
|
239
239
|
...u(this.pinnedQuery.getState().data),
|
|
240
240
|
...u(this.recentQuery.getState().data)
|
|
241
|
-
],
|
|
241
|
+
], t = new Set(e.map((i) => i.id));
|
|
242
242
|
for (const i of this.optimisticEntities.keys())
|
|
243
|
-
|
|
244
|
-
for (const i of
|
|
243
|
+
t.has(i) && this.optimisticEntities.delete(i);
|
|
244
|
+
for (const i of e) this.applyOverrides(i, this.completedRefreshSequence);
|
|
245
245
|
this.publish();
|
|
246
246
|
}
|
|
247
247
|
async loadAllPinned() {
|
|
248
|
-
const
|
|
249
|
-
let
|
|
248
|
+
const e = [];
|
|
249
|
+
let t = null;
|
|
250
250
|
do {
|
|
251
|
-
const i = await this.loadPage({ cursor:
|
|
252
|
-
|
|
253
|
-
} while (
|
|
254
|
-
return
|
|
255
|
-
}
|
|
256
|
-
applyOverrides(
|
|
257
|
-
let i =
|
|
258
|
-
const n = this.activityOverrides.get(
|
|
259
|
-
n && (
|
|
260
|
-
const r = this.pinnedOverrides.get(
|
|
261
|
-
return r && (
|
|
251
|
+
const i = await this.loadPage({ cursor: t, limit: this.limit, pinned: !0 });
|
|
252
|
+
e.push(...i.sessions), t = i.nextCursor;
|
|
253
|
+
} while (t);
|
|
254
|
+
return e;
|
|
255
|
+
}
|
|
256
|
+
applyOverrides(e, t) {
|
|
257
|
+
let i = e;
|
|
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) : i = { ...i, isActive: n.isActive });
|
|
260
|
+
const r = this.pinnedOverrides.get(e.id);
|
|
261
|
+
return r && (t >= r.confirmAfterRefresh && e.isPinned === !0 === r.pinned ? this.pinnedOverrides.delete(e.id) : i = { ...i, isPinned: r.pinned }), this.titleOverrides.has(e.id) && (i = { ...i, customTitle: this.titleOverrides.get(e.id) ?? null }), i;
|
|
262
262
|
}
|
|
263
263
|
updateProjection() {
|
|
264
264
|
this.publish();
|
|
265
265
|
}
|
|
266
|
-
updateEntity(
|
|
267
|
-
const i = this.optimisticEntities.get(
|
|
268
|
-
i && this.optimisticEntities.set(
|
|
266
|
+
updateEntity(e, t) {
|
|
267
|
+
const i = this.optimisticEntities.get(e);
|
|
268
|
+
i && this.optimisticEntities.set(e, t(i)), this.publish();
|
|
269
269
|
}
|
|
270
270
|
hasUnconfirmedActivityOverride() {
|
|
271
271
|
return Array.from(this.activityOverrides.values()).some(
|
|
272
|
-
(
|
|
272
|
+
(e) => this.completedRefreshSequence < e.releaseAfterRefresh
|
|
273
273
|
);
|
|
274
274
|
}
|
|
275
275
|
publish() {
|
|
276
|
-
for (const
|
|
276
|
+
for (const e of this.listeners) e(this.getState());
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
function u(s) {
|
|
280
|
-
return s ? s.ids.map((
|
|
280
|
+
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
281
281
|
}
|
|
282
|
-
function I(s,
|
|
283
|
-
return s.status === "error" ||
|
|
282
|
+
function I(s, e) {
|
|
283
|
+
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
284
|
}
|
|
285
|
-
class
|
|
286
|
-
constructor(
|
|
287
|
-
this.storage =
|
|
288
|
-
|
|
285
|
+
class K {
|
|
286
|
+
constructor(e, t = null) {
|
|
287
|
+
this.storage = e, t && (this.decisions = new Map(
|
|
288
|
+
t.filter(m).map((i) => [this.getDecisionKey(i), i])
|
|
289
289
|
), this.initialized = !0);
|
|
290
290
|
}
|
|
291
291
|
storage;
|
|
@@ -295,92 +295,92 @@ class Q {
|
|
|
295
295
|
actionQueue = Promise.resolve();
|
|
296
296
|
async initialize() {
|
|
297
297
|
if (this.initialized) return;
|
|
298
|
-
const
|
|
298
|
+
const e = await this.storage.load();
|
|
299
299
|
this.decisions = new Map(
|
|
300
|
-
|
|
300
|
+
e.filter(m).map((t) => [this.getDecisionKey(t), t])
|
|
301
301
|
), this.initialized = !0;
|
|
302
302
|
}
|
|
303
|
-
isEligible(
|
|
304
|
-
const i = this.scheduledEligibility.get(this.getExactKey(
|
|
305
|
-
return i !== void 0 && i >
|
|
303
|
+
isEligible(e, t = Date.now()) {
|
|
304
|
+
const i = this.scheduledEligibility.get(this.getExactKey(e));
|
|
305
|
+
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
306
|
}
|
|
307
|
-
getDecision(
|
|
308
|
-
return this.decisions.get(this.getExactKey(
|
|
307
|
+
getDecision(e) {
|
|
308
|
+
return this.decisions.get(this.getExactKey(e)) ?? this.decisions.get(this.getCategoryKey(e)) ?? null;
|
|
309
309
|
}
|
|
310
|
-
getStatus(
|
|
311
|
-
const i = this.scheduledEligibility.get(this.getExactKey(
|
|
312
|
-
if (i !== void 0 && i >
|
|
313
|
-
const n = this.getDecision(
|
|
314
|
-
return n ? n.action === "never" || n.action === "dont_show_again" ? "suppressed" : n.action === "dismiss" ? "resolved" : n.nextEligibleAt && Date.parse(n.nextEligibleAt) >
|
|
310
|
+
getStatus(e, t = Date.now()) {
|
|
311
|
+
const i = this.scheduledEligibility.get(this.getExactKey(e));
|
|
312
|
+
if (i !== void 0 && i > t) return "scheduled";
|
|
313
|
+
const n = this.getDecision(e);
|
|
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
|
-
scheduleEligibility(
|
|
317
|
-
const i = this.getExactKey(
|
|
318
|
-
return n !== void 0 ? n : (this.scheduledEligibility.set(i,
|
|
316
|
+
scheduleEligibility(e, t) {
|
|
317
|
+
const i = this.getExactKey(e), n = this.scheduledEligibility.get(i);
|
|
318
|
+
return n !== void 0 ? n : (this.scheduledEligibility.set(i, t), t);
|
|
319
319
|
}
|
|
320
|
-
getNextEligibilityAt(
|
|
320
|
+
getNextEligibilityAt(e = Date.now()) {
|
|
321
321
|
for (const [i, n] of this.scheduledEligibility)
|
|
322
|
-
n <=
|
|
323
|
-
const
|
|
322
|
+
n <= e && this.scheduledEligibility.delete(i);
|
|
323
|
+
const t = [
|
|
324
324
|
...this.scheduledEligibility.values(),
|
|
325
|
-
...Array.from(this.decisions.values()).map((i) => i.nextEligibleAt ? Date.parse(i.nextEligibleAt) : Number.NaN).filter((i) => Number.isFinite(i) && i >
|
|
325
|
+
...Array.from(this.decisions.values()).map((i) => i.nextEligibleAt ? Date.parse(i.nextEligibleAt) : Number.NaN).filter((i) => Number.isFinite(i) && i > e)
|
|
326
326
|
];
|
|
327
|
-
return
|
|
327
|
+
return t.length > 0 ? Math.min(...t) : null;
|
|
328
328
|
}
|
|
329
|
-
act(
|
|
330
|
-
const n = this.actionQueue.then(() => this.applyAction(
|
|
329
|
+
act(e, t, i = {}) {
|
|
330
|
+
const n = this.actionQueue.then(() => this.applyAction(e, t, i));
|
|
331
331
|
return this.actionQueue = n.then(() => {
|
|
332
332
|
}, () => {
|
|
333
333
|
}), n;
|
|
334
334
|
}
|
|
335
|
-
async applyAction(
|
|
336
|
-
if (!
|
|
337
|
-
throw new Error(`Interaction ${
|
|
338
|
-
if (!E(
|
|
339
|
-
throw new Error(`Interaction action ${
|
|
335
|
+
async applyAction(e, t, i) {
|
|
336
|
+
if (!e.allowedActions.includes(t))
|
|
337
|
+
throw new Error(`Interaction ${e.key} does not allow ${t}.`);
|
|
338
|
+
if (!E(t))
|
|
339
|
+
throw new Error(`Interaction action ${t} is not a persistence decision.`);
|
|
340
340
|
const n = i.now ?? /* @__PURE__ */ new Date(), r = {
|
|
341
|
-
promptKey:
|
|
342
|
-
category:
|
|
343
|
-
action:
|
|
344
|
-
scope:
|
|
341
|
+
promptKey: e.key,
|
|
342
|
+
category: e.category,
|
|
343
|
+
action: t,
|
|
344
|
+
scope: e.scope,
|
|
345
345
|
decidedAt: n.toISOString(),
|
|
346
|
-
nextEligibleAt: this.getNextEligibleAt(
|
|
347
|
-
}, a =
|
|
346
|
+
nextEligibleAt: this.getNextEligibleAt(e, t, n, i.snoozeUntil)
|
|
347
|
+
}, a = t === "dont_show_again" ? this.getCategoryKey(e) : this.getExactKey(e), l = new Map(this.decisions);
|
|
348
348
|
return l.set(a, r), await this.storage.save([...l.values()]), this.decisions = l, r;
|
|
349
349
|
}
|
|
350
|
-
isDecisionEligible(
|
|
351
|
-
return
|
|
350
|
+
isDecisionEligible(e, t) {
|
|
351
|
+
return e ? e.action === "dismiss" || e.action === "never" || e.action === "dont_show_again" ? !1 : !e.nextEligibleAt || Date.parse(e.nextEligibleAt) <= t : !0;
|
|
352
352
|
}
|
|
353
|
-
getNextEligibleAt(
|
|
354
|
-
if (
|
|
355
|
-
return new Date(i.getTime() + (
|
|
356
|
-
if (
|
|
353
|
+
getNextEligibleAt(e, t, i, n) {
|
|
354
|
+
if (t === "later")
|
|
355
|
+
return new Date(i.getTime() + (e.laterDelayMs ?? 3600 * 1e3)).toISOString();
|
|
356
|
+
if (t === "snooze") {
|
|
357
357
|
if (!n || n.getTime() <= i.getTime())
|
|
358
358
|
throw new Error("Snooze requires a future next-eligible time.");
|
|
359
359
|
return n.toISOString();
|
|
360
360
|
}
|
|
361
361
|
return null;
|
|
362
362
|
}
|
|
363
|
-
getDecisionKey(
|
|
364
|
-
const
|
|
365
|
-
return
|
|
363
|
+
getDecisionKey(e) {
|
|
364
|
+
const t = f(e.scope);
|
|
365
|
+
return e.action === "dont_show_again" ? `${t}:category:${e.category}` : `${t}:interaction:${e.promptKey}`;
|
|
366
366
|
}
|
|
367
|
-
getExactKey(
|
|
368
|
-
return `${f(
|
|
367
|
+
getExactKey(e) {
|
|
368
|
+
return `${f(e.scope)}:interaction:${e.key}`;
|
|
369
369
|
}
|
|
370
|
-
getCategoryKey(
|
|
371
|
-
return `${f(
|
|
370
|
+
getCategoryKey(e) {
|
|
371
|
+
return `${f(e.scope)}:category:${e.category}`;
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
|
-
function
|
|
374
|
+
function F(s, e) {
|
|
375
375
|
return {
|
|
376
|
-
load: async () => P(s,
|
|
377
|
-
save: async (
|
|
376
|
+
load: async () => P(s, e),
|
|
377
|
+
save: async (t) => s.setItem(e, JSON.stringify(t))
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
-
function P(s,
|
|
381
|
-
const
|
|
382
|
-
if (!
|
|
383
|
-
const i = JSON.parse(
|
|
380
|
+
function P(s, e) {
|
|
381
|
+
const t = s.getItem(e);
|
|
382
|
+
if (!t) return [];
|
|
383
|
+
const i = JSON.parse(t);
|
|
384
384
|
return Array.isArray(i) ? i.filter(m) : [];
|
|
385
385
|
}
|
|
386
386
|
function f(s) {
|
|
@@ -391,8 +391,8 @@ function E(s) {
|
|
|
391
391
|
}
|
|
392
392
|
function m(s) {
|
|
393
393
|
if (!s || typeof s != "object") return !1;
|
|
394
|
-
const
|
|
395
|
-
return typeof
|
|
394
|
+
const e = s;
|
|
395
|
+
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
396
|
}
|
|
397
397
|
const T = {
|
|
398
398
|
working: "⏳",
|
|
@@ -400,14 +400,14 @@ const T = {
|
|
|
400
400
|
failed: "❗",
|
|
401
401
|
stopped: "⏹️"
|
|
402
402
|
}, M = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
403
|
-
function D(s,
|
|
404
|
-
if (!
|
|
405
|
-
const
|
|
406
|
-
return
|
|
403
|
+
function D(s, e) {
|
|
404
|
+
if (!e) return g(s);
|
|
405
|
+
const t = g(s), i = `${T[e]} Pluno`;
|
|
406
|
+
return t ? `${i}: ${t}` : i;
|
|
407
407
|
}
|
|
408
|
-
class
|
|
409
|
-
constructor(
|
|
410
|
-
this.titleDocument =
|
|
408
|
+
class z {
|
|
409
|
+
constructor(e) {
|
|
410
|
+
this.titleDocument = e;
|
|
411
411
|
}
|
|
412
412
|
titleDocument;
|
|
413
413
|
status = null;
|
|
@@ -415,23 +415,23 @@ class K {
|
|
|
415
415
|
lastAppliedTitle = null;
|
|
416
416
|
stopObserving = null;
|
|
417
417
|
liveStatusVersion = 0;
|
|
418
|
-
setStatus(
|
|
419
|
-
this.liveStatusVersion += 1, this.applyStatus(
|
|
418
|
+
setStatus(e) {
|
|
419
|
+
this.liveStatusVersion += 1, this.applyStatus(e);
|
|
420
420
|
}
|
|
421
421
|
clear() {
|
|
422
422
|
this.liveStatusVersion += 1, this.applyClear();
|
|
423
423
|
}
|
|
424
|
-
async syncStatus(
|
|
425
|
-
const
|
|
426
|
-
i === void 0 ||
|
|
424
|
+
async syncStatus(e) {
|
|
425
|
+
const t = this.liveStatusVersion, i = await e();
|
|
426
|
+
i === void 0 || t !== this.liveStatusVersion || (i ? this.applyStatus(i) : this.applyClear());
|
|
427
427
|
}
|
|
428
|
-
applyStatus(
|
|
429
|
-
const
|
|
430
|
-
|
|
428
|
+
applyStatus(e) {
|
|
429
|
+
const t = this.titleDocument.getTitle();
|
|
430
|
+
t !== this.lastAppliedTitle && (this.baseTitle = g(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
|
|
431
431
|
}
|
|
432
432
|
applyClear() {
|
|
433
|
-
const
|
|
434
|
-
this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null,
|
|
433
|
+
const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, i = this.lastAppliedTitle === null ? g(e) : e;
|
|
434
|
+
this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : i !== e && this.titleDocument.setTitle(i);
|
|
435
435
|
}
|
|
436
436
|
handleTitleChanged() {
|
|
437
437
|
!this.status || this.titleDocument.getTitle() === this.lastAppliedTitle || this.applyTitle();
|
|
@@ -439,78 +439,92 @@ class K {
|
|
|
439
439
|
applyTitle() {
|
|
440
440
|
if (!this.status)
|
|
441
441
|
return;
|
|
442
|
-
const
|
|
443
|
-
this.lastAppliedTitle =
|
|
442
|
+
const e = D(this.baseTitle, this.status);
|
|
443
|
+
this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
|
-
function
|
|
446
|
+
function B(s) {
|
|
447
447
|
return {
|
|
448
448
|
getTitle: () => s.title,
|
|
449
|
-
setTitle: (
|
|
450
|
-
s.title =
|
|
449
|
+
setTitle: (e) => {
|
|
450
|
+
s.title = e;
|
|
451
451
|
},
|
|
452
|
-
observeTitle: (
|
|
453
|
-
const
|
|
454
|
-
return
|
|
452
|
+
observeTitle: (e) => {
|
|
453
|
+
const t = new MutationObserver(e);
|
|
454
|
+
return t.observe(s.head, {
|
|
455
455
|
childList: !0,
|
|
456
456
|
subtree: !0,
|
|
457
457
|
characterData: !0
|
|
458
|
-
}), () =>
|
|
458
|
+
}), () => t.disconnect();
|
|
459
459
|
}
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
462
|
function g(s) {
|
|
463
463
|
return s.replace(M, "");
|
|
464
464
|
}
|
|
465
|
-
const
|
|
465
|
+
const A = 500;
|
|
466
466
|
function O(s) {
|
|
467
|
-
const
|
|
468
|
-
return
|
|
467
|
+
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();
|
|
468
|
+
return e.length > A ? `${e.slice(0, A - 1)}…` : e;
|
|
469
|
+
}
|
|
470
|
+
const x = {
|
|
471
|
+
"duplicate-message-item": "A canonical message rendered more than once.",
|
|
472
|
+
"duplicate-canonical-item": "A canonical session item rendered more than once.",
|
|
473
|
+
"duplicate-tool-call": "A tool call rendered more than once.",
|
|
474
|
+
"duplicate-attachment": "An attachment rendered more than once.",
|
|
475
|
+
"duplicate-terminal-outcome": "A response rendered more than one terminal outcome.",
|
|
476
|
+
"foreign-session-item-visible": "The visible transcript contains state owned by another session.",
|
|
477
|
+
"terminal-response-reactivated": "A terminal response became active again.",
|
|
478
|
+
"terminal-history-not-append-only": "An established terminal outcome disappeared or changed order.",
|
|
479
|
+
"runtime-transcript-not-rendered": "A nonempty runtime transcript is displaying starter prompts."
|
|
480
|
+
};
|
|
481
|
+
function R(s) {
|
|
482
|
+
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(x, s.slice(13));
|
|
469
483
|
}
|
|
470
|
-
function
|
|
484
|
+
function N(s) {
|
|
471
485
|
if (!s || typeof s != "object" || !("type" in s)) return !1;
|
|
472
|
-
const
|
|
473
|
-
switch (
|
|
486
|
+
const e = s;
|
|
487
|
+
switch (e.type) {
|
|
474
488
|
case "runtime.connect":
|
|
475
489
|
case "session.new":
|
|
476
490
|
case "run.stop":
|
|
477
491
|
case "run.retry":
|
|
478
492
|
return !0;
|
|
479
493
|
case "runtime.warmup":
|
|
480
|
-
return
|
|
494
|
+
return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
|
|
481
495
|
case "runtime.report_displayed_error":
|
|
482
|
-
return (
|
|
496
|
+
return (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);
|
|
483
497
|
case "runtime.report_invalid_state_transition":
|
|
484
|
-
return (
|
|
498
|
+
return (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || R(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
|
|
485
499
|
case "runtime.widget_lifecycle":
|
|
486
|
-
return (
|
|
500
|
+
return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
|
|
487
501
|
case "session.load":
|
|
488
|
-
return typeof
|
|
502
|
+
return typeof e.sessionId == "string" && e.sessionId.length > 0;
|
|
489
503
|
case "session.list":
|
|
490
|
-
return (
|
|
504
|
+
return (e.cursor === void 0 || e.cursor === null || typeof e.cursor == "string") && (e.limit === void 0 || typeof e.limit == "number") && (e.pinned === void 0 || typeof e.pinned == "boolean");
|
|
491
505
|
case "session.set_model":
|
|
492
|
-
return typeof
|
|
506
|
+
return typeof e.model == "string";
|
|
493
507
|
case "session.pin":
|
|
494
|
-
return typeof
|
|
508
|
+
return typeof e.sessionId == "string" && typeof e.pinned == "boolean";
|
|
495
509
|
case "session.rename":
|
|
496
|
-
return typeof
|
|
510
|
+
return typeof e.sessionId == "string" && typeof e.title == "string";
|
|
497
511
|
case "interaction.act":
|
|
498
|
-
return typeof
|
|
512
|
+
return typeof e.interactionId == "string" && typeof e.action == "string" && typeof e.expectedRevision == "number";
|
|
499
513
|
case "conversation.stage_proactive_suggestion":
|
|
500
|
-
return typeof
|
|
514
|
+
return typeof e.question == "string" && typeof e.clientMessageId == "string";
|
|
501
515
|
case "conversation.stage":
|
|
502
|
-
return typeof
|
|
516
|
+
return typeof e.content == "string" && typeof e.clientMessageId == "string" && (e.submittedAt === void 0 || typeof e.submittedAt == "number") && (e.attachments === void 0 || Array.isArray(e.attachments));
|
|
503
517
|
case "conversation.fail_staged":
|
|
504
|
-
return typeof
|
|
518
|
+
return typeof e.clientMessageId == "string" && typeof e.message == "string";
|
|
505
519
|
case "conversation.send":
|
|
506
|
-
return typeof
|
|
520
|
+
return typeof e.content == "string" && typeof e.clientMessageId == "string" && (e.attachments === void 0 || Array.isArray(e.attachments));
|
|
507
521
|
default:
|
|
508
522
|
return !1;
|
|
509
523
|
}
|
|
510
524
|
}
|
|
511
|
-
class
|
|
512
|
-
constructor(
|
|
513
|
-
this.adapter =
|
|
525
|
+
class H {
|
|
526
|
+
constructor(e, t, i) {
|
|
527
|
+
this.adapter = t, this.state = y(e), this.model = i;
|
|
514
528
|
}
|
|
515
529
|
adapter;
|
|
516
530
|
listeners = {};
|
|
@@ -526,17 +540,17 @@ class B {
|
|
|
526
540
|
stagedProactiveSuggestionClientMessageId = null;
|
|
527
541
|
operationQueue = Promise.resolve();
|
|
528
542
|
destroyed = !1;
|
|
529
|
-
on(
|
|
530
|
-
const i = this.listeners[
|
|
531
|
-
return i.add(
|
|
543
|
+
on(e, t) {
|
|
544
|
+
const i = this.listeners[e] ?? /* @__PURE__ */ new Set();
|
|
545
|
+
return i.add(t), this.listeners[e] = i, () => i.delete(t);
|
|
532
546
|
}
|
|
533
547
|
getState() {
|
|
534
548
|
return y(this.state);
|
|
535
549
|
}
|
|
536
|
-
updateProjection(
|
|
550
|
+
updateProjection(e, t, i, n, r) {
|
|
537
551
|
if (!this.destroyed) {
|
|
538
|
-
if (this.state = y(
|
|
539
|
-
this.sessionHistoryState =
|
|
552
|
+
if (this.state = y(e), t !== void 0 && (this.model = t), i) {
|
|
553
|
+
this.sessionHistoryState = S(i);
|
|
540
554
|
for (const a of this.sessionHistoryListeners)
|
|
541
555
|
a(this.getSessionHistoryState());
|
|
542
556
|
}
|
|
@@ -557,38 +571,38 @@ class B {
|
|
|
557
571
|
destroy() {
|
|
558
572
|
if (!this.destroyed) {
|
|
559
573
|
this.destroyed = !0, this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
|
|
560
|
-
for (const
|
|
574
|
+
for (const e of Object.values(this.listeners)) e?.clear();
|
|
561
575
|
this.adapter.onDisconnect?.();
|
|
562
576
|
}
|
|
563
577
|
}
|
|
564
|
-
warmup(
|
|
565
|
-
return this.adapter.dispatch({ type: "runtime.warmup", reason:
|
|
578
|
+
warmup(e = "panel_open") {
|
|
579
|
+
return this.adapter.dispatch({ type: "runtime.warmup", reason: e }).then(() => {
|
|
566
580
|
});
|
|
567
581
|
}
|
|
568
|
-
recordWidgetLifecycle(
|
|
569
|
-
this.dispatch({ type: "runtime.widget_lifecycle", action:
|
|
582
|
+
recordWidgetLifecycle(e, t) {
|
|
583
|
+
this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
|
|
570
584
|
}
|
|
571
|
-
reportInvalidStateTransition(
|
|
585
|
+
reportInvalidStateTransition(e, t) {
|
|
572
586
|
this.adapter.dispatch({
|
|
573
587
|
type: "runtime.report_invalid_state_transition",
|
|
574
|
-
reason:
|
|
575
|
-
clientMessageId:
|
|
588
|
+
reason: e,
|
|
589
|
+
clientMessageId: t
|
|
576
590
|
}).catch(() => {
|
|
577
591
|
});
|
|
578
592
|
}
|
|
579
|
-
reportDisplayedError(
|
|
593
|
+
reportDisplayedError(e, t, i) {
|
|
580
594
|
this.adapter.dispatch({
|
|
581
595
|
type: "runtime.report_displayed_error",
|
|
582
|
-
reason:
|
|
583
|
-
errorFingerprint:
|
|
596
|
+
reason: e,
|
|
597
|
+
errorFingerprint: t,
|
|
584
598
|
...i ? { displayedMessage: O(i) } : {}
|
|
585
599
|
}).catch(() => {
|
|
586
600
|
});
|
|
587
601
|
}
|
|
588
|
-
sendMessage(
|
|
589
|
-
const i =
|
|
602
|
+
sendMessage(e, t = {}) {
|
|
603
|
+
const i = e.trim(), n = t.attachments ?? [];
|
|
590
604
|
if (!i && n.length === 0) return Promise.resolve(null);
|
|
591
|
-
const r =
|
|
605
|
+
const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), a = t.submittedAt ?? Date.now(), l = this.state, o = {
|
|
592
606
|
id: `local-${r}`,
|
|
593
607
|
role: "user",
|
|
594
608
|
content: i,
|
|
@@ -606,21 +620,21 @@ class B {
|
|
|
606
620
|
lastError: null
|
|
607
621
|
}, this.emit("state", this.getState()), this.enqueueOperation(() => this.sendMessageNow(
|
|
608
622
|
i,
|
|
609
|
-
{ ...
|
|
623
|
+
{ ...t, clientMessageId: r, submittedAt: a },
|
|
610
624
|
l
|
|
611
625
|
));
|
|
612
626
|
}
|
|
613
|
-
async sendMessageNow(
|
|
614
|
-
const n =
|
|
615
|
-
let a =
|
|
627
|
+
async sendMessageNow(e, t, i) {
|
|
628
|
+
const n = e, r = t.clientMessageId;
|
|
629
|
+
let a = t.attachments ?? [], l = !1;
|
|
616
630
|
try {
|
|
617
631
|
if (await this.adapter.dispatch({
|
|
618
632
|
type: "conversation.stage",
|
|
619
633
|
content: n,
|
|
620
634
|
clientMessageId: r,
|
|
621
|
-
proactiveSuggestionQuestion:
|
|
635
|
+
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
622
636
|
attachments: a.length > 0 ? a : void 0,
|
|
623
|
-
submittedAt:
|
|
637
|
+
submittedAt: t.submittedAt
|
|
624
638
|
}), l = !0, a.length > 0) {
|
|
625
639
|
if (!this.adapter.uploadAttachment)
|
|
626
640
|
throw new Error("The runtime does not support attachments.");
|
|
@@ -640,12 +654,12 @@ class B {
|
|
|
640
654
|
type: "conversation.send",
|
|
641
655
|
content: n,
|
|
642
656
|
clientMessageId: r,
|
|
643
|
-
initiatedBy:
|
|
644
|
-
invocation:
|
|
645
|
-
proactiveSuggestionQuestion:
|
|
657
|
+
initiatedBy: t.initiatedBy,
|
|
658
|
+
invocation: t.invocation,
|
|
659
|
+
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
646
660
|
attachments: a.length > 0 ? a : void 0
|
|
647
661
|
});
|
|
648
|
-
for (const c of
|
|
662
|
+
for (const c of t.attachments ?? [])
|
|
649
663
|
c.id && this.attachmentFiles.delete(c.id);
|
|
650
664
|
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), o?.clientMessageId ?? r;
|
|
651
665
|
} catch (o) {
|
|
@@ -668,72 +682,72 @@ class B {
|
|
|
668
682
|
getModel() {
|
|
669
683
|
return this.model;
|
|
670
684
|
}
|
|
671
|
-
setModel(
|
|
672
|
-
return this.dispatch({ type: "session.set_model", model:
|
|
685
|
+
setModel(e) {
|
|
686
|
+
return this.dispatch({ type: "session.set_model", model: e }).then(() => {
|
|
673
687
|
});
|
|
674
688
|
}
|
|
675
689
|
retryLastMessage() {
|
|
676
690
|
return this.dispatch({ type: "run.retry" }), !0;
|
|
677
691
|
}
|
|
678
|
-
createLocalAttachment(
|
|
679
|
-
const
|
|
680
|
-
return this.attachmentFiles.set(
|
|
681
|
-
id:
|
|
682
|
-
name:
|
|
683
|
-
mimeType:
|
|
684
|
-
sizeBytes:
|
|
692
|
+
createLocalAttachment(e) {
|
|
693
|
+
const t = crypto.randomUUID();
|
|
694
|
+
return this.attachmentFiles.set(t, e), {
|
|
695
|
+
id: t,
|
|
696
|
+
name: e.name || "attachment",
|
|
697
|
+
mimeType: e.type || "application/octet-stream",
|
|
698
|
+
sizeBytes: e.size
|
|
685
699
|
};
|
|
686
700
|
}
|
|
687
701
|
stop() {
|
|
688
702
|
return this.dispatch({ type: "run.stop" }).then(() => {
|
|
689
703
|
});
|
|
690
704
|
}
|
|
691
|
-
startNewSession(
|
|
692
|
-
return
|
|
705
|
+
startNewSession(e = {}) {
|
|
706
|
+
return e.notifyTransport === !1 ? Promise.resolve() : this.dispatch({ type: "session.new" }).then(() => {
|
|
693
707
|
});
|
|
694
708
|
}
|
|
695
|
-
async listSessions(
|
|
696
|
-
await this.dispatch({ type: "session.list", ...
|
|
697
|
-
const
|
|
709
|
+
async listSessions(e = {}) {
|
|
710
|
+
await this.dispatch({ type: "session.list", ...e });
|
|
711
|
+
const t = this.sessionHistoryState.data;
|
|
698
712
|
return {
|
|
699
|
-
sessions: w(
|
|
700
|
-
nextCursor:
|
|
713
|
+
sessions: w(t),
|
|
714
|
+
nextCursor: t?.nextCursor ?? null
|
|
701
715
|
};
|
|
702
716
|
}
|
|
703
717
|
getSessionHistoryState() {
|
|
704
|
-
return
|
|
718
|
+
return S(this.sessionHistoryState);
|
|
705
719
|
}
|
|
706
|
-
subscribeSessionHistory(
|
|
707
|
-
return this.sessionHistoryListeners.add(
|
|
720
|
+
subscribeSessionHistory(e) {
|
|
721
|
+
return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
|
|
708
722
|
}
|
|
709
723
|
refreshSessionHistory() {
|
|
710
724
|
return this.dispatch({ type: "session.list", limit: 20 }).then(() => {
|
|
711
725
|
});
|
|
712
726
|
}
|
|
713
727
|
loadMoreSessionHistory() {
|
|
714
|
-
const
|
|
715
|
-
return
|
|
728
|
+
const e = this.sessionHistoryState.data?.nextCursor ?? null;
|
|
729
|
+
return e ? this.dispatch({ type: "session.list", cursor: e, limit: 20 }).then(() => {
|
|
716
730
|
}) : Promise.resolve();
|
|
717
731
|
}
|
|
718
|
-
setSessionPinned(
|
|
719
|
-
return this.dispatch({ type: "session.pin", sessionId:
|
|
732
|
+
setSessionPinned(e, t) {
|
|
733
|
+
return this.dispatch({ type: "session.pin", sessionId: e, pinned: t }).then(() => {
|
|
720
734
|
});
|
|
721
735
|
}
|
|
722
|
-
renameSession(
|
|
723
|
-
return this.dispatch({ type: "session.rename", sessionId:
|
|
736
|
+
renameSession(e, t) {
|
|
737
|
+
return this.dispatch({ type: "session.rename", sessionId: e, title: t }).then(() => {
|
|
724
738
|
});
|
|
725
739
|
}
|
|
726
740
|
getInteractions() {
|
|
727
|
-
return this.interactions.map((
|
|
741
|
+
return this.interactions.map((e) => ({ ...e }));
|
|
728
742
|
}
|
|
729
|
-
subscribeInteractions(
|
|
730
|
-
return this.interactionListeners.add(
|
|
743
|
+
subscribeInteractions(e) {
|
|
744
|
+
return this.interactionListeners.add(e), e(this.getInteractions()), () => this.interactionListeners.delete(e);
|
|
731
745
|
}
|
|
732
|
-
actOnInteraction(
|
|
746
|
+
actOnInteraction(e, t, i, n = {}) {
|
|
733
747
|
return this.dispatch({
|
|
734
748
|
type: "interaction.act",
|
|
735
|
-
interactionId:
|
|
736
|
-
action:
|
|
749
|
+
interactionId: e,
|
|
750
|
+
action: t,
|
|
737
751
|
expectedRevision: i,
|
|
738
752
|
...n
|
|
739
753
|
}).then(() => {
|
|
@@ -742,42 +756,42 @@ class B {
|
|
|
742
756
|
getAccount() {
|
|
743
757
|
return this.account ? { ...this.account } : null;
|
|
744
758
|
}
|
|
745
|
-
subscribeAccount(
|
|
746
|
-
return this.accountListeners.add(
|
|
759
|
+
subscribeAccount(e) {
|
|
760
|
+
return this.accountListeners.add(e), e(this.getAccount()), () => this.accountListeners.delete(e);
|
|
747
761
|
}
|
|
748
762
|
refreshAccount() {
|
|
749
763
|
return Promise.resolve();
|
|
750
764
|
}
|
|
751
|
-
loadSession(
|
|
752
|
-
return this.dispatch({ type: "session.load", sessionId:
|
|
765
|
+
loadSession(e) {
|
|
766
|
+
return this.dispatch({ type: "session.load", sessionId: e }).then(() => {
|
|
753
767
|
});
|
|
754
768
|
}
|
|
755
|
-
stageProactiveSuggestionQuestion(
|
|
756
|
-
const
|
|
757
|
-
if (!
|
|
769
|
+
stageProactiveSuggestionQuestion(e) {
|
|
770
|
+
const t = e.trim();
|
|
771
|
+
if (!t) return Promise.resolve();
|
|
758
772
|
const i = this.stagedProactiveSuggestionClientMessageId ?? crypto.randomUUID();
|
|
759
773
|
return this.stagedProactiveSuggestionClientMessageId = i, this.dispatch({
|
|
760
774
|
type: "conversation.stage_proactive_suggestion",
|
|
761
|
-
question:
|
|
775
|
+
question: t,
|
|
762
776
|
clientMessageId: i
|
|
763
777
|
}).then(() => {
|
|
764
778
|
});
|
|
765
779
|
}
|
|
766
|
-
dispatch(
|
|
767
|
-
return this.enqueueOperation(() => this.adapter.dispatch(
|
|
780
|
+
dispatch(e) {
|
|
781
|
+
return this.enqueueOperation(() => this.adapter.dispatch(e));
|
|
768
782
|
}
|
|
769
|
-
enqueueOperation(
|
|
770
|
-
const
|
|
771
|
-
return this.operationQueue =
|
|
783
|
+
enqueueOperation(e) {
|
|
784
|
+
const t = this.operationQueue.then(e);
|
|
785
|
+
return this.operationQueue = t.then(
|
|
772
786
|
() => {
|
|
773
787
|
},
|
|
774
788
|
() => {
|
|
775
789
|
}
|
|
776
|
-
),
|
|
790
|
+
), t;
|
|
777
791
|
}
|
|
778
|
-
emit(
|
|
779
|
-
const i = this.listeners[
|
|
780
|
-
for (const n of i ?? []) n(
|
|
792
|
+
emit(e, t) {
|
|
793
|
+
const i = this.listeners[e];
|
|
794
|
+
for (const n of i ?? []) n(t);
|
|
781
795
|
}
|
|
782
796
|
}
|
|
783
797
|
function y(s) {
|
|
@@ -785,52 +799,52 @@ function y(s) {
|
|
|
785
799
|
...s,
|
|
786
800
|
starterPrompts: [...s.starterPrompts],
|
|
787
801
|
appearance: s.appearance ? { ...s.appearance } : null,
|
|
788
|
-
messages: s.messages.map((
|
|
789
|
-
const
|
|
790
|
-
...
|
|
791
|
-
attachments:
|
|
792
|
-
}, i =
|
|
793
|
-
return r && Object.defineProperty(
|
|
802
|
+
messages: s.messages.map((e) => {
|
|
803
|
+
const t = {
|
|
804
|
+
...e,
|
|
805
|
+
attachments: e.attachments?.map((a) => ({ ...a }))
|
|
806
|
+
}, i = e.assistantDraftItemId, n = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
|
|
807
|
+
return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
|
|
794
808
|
value: r,
|
|
795
809
|
enumerable: !1
|
|
796
|
-
}), i && Object.defineProperty(
|
|
810
|
+
}), i && Object.defineProperty(t, "assistantDraftItemId", {
|
|
797
811
|
value: i,
|
|
798
812
|
enumerable: !1
|
|
799
|
-
}), n && Object.defineProperty(
|
|
813
|
+
}), n && Object.defineProperty(t, "clientMessageId", {
|
|
800
814
|
value: n,
|
|
801
815
|
enumerable: !1
|
|
802
|
-
}),
|
|
816
|
+
}), t;
|
|
803
817
|
}),
|
|
804
|
-
activeScheduledFollowUps: s.activeScheduledFollowUps?.map((
|
|
818
|
+
activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
|
|
805
819
|
};
|
|
806
820
|
}
|
|
807
|
-
function
|
|
821
|
+
function S(s) {
|
|
808
822
|
return {
|
|
809
823
|
...s,
|
|
810
824
|
data: s.data ? p({
|
|
811
|
-
entities: w(s.data).map((
|
|
825
|
+
entities: w(s.data).map((e) => ({ ...e })),
|
|
812
826
|
nextCursor: s.data.nextCursor
|
|
813
827
|
}) : null
|
|
814
828
|
};
|
|
815
829
|
}
|
|
816
830
|
export {
|
|
817
|
-
|
|
831
|
+
K as ProductAgentInteractionManager,
|
|
818
832
|
b as ProductAgentQueryController,
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
833
|
+
H as ProductAgentRemoteRuntimeClient,
|
|
834
|
+
$ as ProductAgentSessionHistoryManager,
|
|
835
|
+
z as ProductAgentTaskPageTitleController,
|
|
836
|
+
F as createLocalStorageInteractionDecisionStorage,
|
|
823
837
|
h as createProductAgentQueryState,
|
|
824
|
-
|
|
838
|
+
B as createProductAgentTaskPageTitleDocument,
|
|
825
839
|
D as formatProductAgentTaskPageTitle,
|
|
826
|
-
|
|
827
|
-
|
|
840
|
+
k as hasProductAgentPaidCreditFallback,
|
|
841
|
+
N as isProductAgentRuntimeCommand,
|
|
828
842
|
_ as mergeProductAgentEntityPages,
|
|
829
843
|
p as normalizeProductAgentEntityPage,
|
|
830
844
|
P as readLocalStorageInteractionDecisions,
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
845
|
+
L as reconcileProductAgentSubmissionGate,
|
|
846
|
+
q as resolveProductAgentBillingPresentation,
|
|
847
|
+
Q as resolveProductAgentComposerAction,
|
|
848
|
+
C as resolveProductAgentWidgetPresentation,
|
|
835
849
|
w as selectProductAgentQueryEntities
|
|
836
850
|
};
|