@pluno/product-agent-web 0.1.160 → 0.1.161
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 +2 -0
- package/dist/product-agent-sdk.js +35 -34
- package/dist/product-agent-widget.js +152 -149
- package/dist/widget.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type ProductAgentModel = "gpt-5.4-nano" | "gpt-5.4-mini" | "gpt-5.4" | "gpt-5.6-luna" | "gpt-5.6-terra" | "gpt-5.6-sol";
|
|
2
2
|
export type ProductAgentEntrySurface = "extension_sidepanel" | "extension_widget" | "main_web_chat" | "automation" | "mcp" | "embedded_widget" | "embedded_custom_ui";
|
|
3
|
+
export type ProductAgentProductVariant = "personal" | "customer_embedded";
|
|
3
4
|
export type ProductAgentLegacyEntrySurface = "sidepanel" | "browser_extension_page_ui" | "sdk_preview_widget" | "browser_extension_sdk_preview" | "sdk-preview" | "main_chat" | "automation_run";
|
|
4
5
|
export type ProductAgentInvocation = "user" | "automation" | "scheduled_continuation" | "private_continuation";
|
|
5
6
|
export type ProductAgentUser = {
|
|
@@ -136,6 +137,7 @@ export type ProductAgentInitOptions = {
|
|
|
136
137
|
model?: ProductAgentModel;
|
|
137
138
|
clientId?: string;
|
|
138
139
|
metadata?: Record<string, unknown> | (() => Record<string, unknown> | undefined);
|
|
140
|
+
productVariant?: ProductAgentProductVariant;
|
|
139
141
|
entrySurface?: ProductAgentEntrySurface | ProductAgentLegacyEntrySurface;
|
|
140
142
|
autoConnect?: boolean;
|
|
141
143
|
initialStarterPrompts?: string[];
|
|
@@ -333,7 +333,7 @@ const Ds = "https://app.pluno.ai", vs = "gpt-5.6-terra", Os = 2e4, Ns = 1e4, xs
|
|
|
333
333
|
".pdf:application/pdf",
|
|
334
334
|
".png:image/png",
|
|
335
335
|
".webp:image/webp"
|
|
336
|
-
]), oi = ".pdf,.png,.jpg,.jpeg,.webp",
|
|
336
|
+
]), oi = ".pdf,.png,.jpg,.jpeg,.webp", Ve = 64e3, Ue = 4e3, Je = 30, Xs = 2e3, Vs = 1e3, Ot = "Image is too large for model vision input.", Js = 100, Nt = "pluno.productAgent.state.", qe = "pluno.productAgent.pendingEvents.", pe = "pluno.productAgent.activeToolCalls.", Ys = 100;
|
|
337
337
|
function G(t, e = 0) {
|
|
338
338
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
339
339
|
return Math.max(e, s);
|
|
@@ -473,6 +473,7 @@ class xt {
|
|
|
473
473
|
backendUrl: Tn(e.backendUrl ?? Ds),
|
|
474
474
|
clientId: e.clientId ?? Bn(),
|
|
475
475
|
model: e.model ?? vs,
|
|
476
|
+
productVariant: e.productVariant ?? "customer_embedded",
|
|
476
477
|
entrySurface: wn(e.entrySurface)
|
|
477
478
|
}, s);
|
|
478
479
|
try {
|
|
@@ -584,7 +585,7 @@ class xt {
|
|
|
584
585
|
}
|
|
585
586
|
async sendMessage(e, s = {}) {
|
|
586
587
|
const n = e.trim(), r = s.attachments ?? [];
|
|
587
|
-
if (
|
|
588
|
+
if (this.options.productVariant === "customer_embedded" && (r.forEach(Jt), r.reduce(
|
|
588
589
|
(T, f) => T + f.sizeBytes,
|
|
589
590
|
0
|
|
590
591
|
) > vt))
|
|
@@ -675,7 +676,7 @@ class xt {
|
|
|
675
676
|
return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(s), this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
|
|
676
677
|
}
|
|
677
678
|
createLocalAttachment(e) {
|
|
678
|
-
this.options.
|
|
679
|
+
this.options.productVariant === "customer_embedded" && vr(e);
|
|
679
680
|
const s = X(), n = {
|
|
680
681
|
id: s,
|
|
681
682
|
name: e.name || "attachment",
|
|
@@ -749,7 +750,7 @@ class xt {
|
|
|
749
750
|
}, "Failed to upload attachment"), o = l;
|
|
750
751
|
}
|
|
751
752
|
this.setState({ sessionId: o.sessionId });
|
|
752
|
-
const a =
|
|
753
|
+
const a = Vt(o.attachment, this.options.backendUrl);
|
|
753
754
|
return this.updateAttachmentInState(s.id, a), s.id && cs(s.id, {
|
|
754
755
|
sessionId: o.sessionId,
|
|
755
756
|
fileUrl: a.fileUrl,
|
|
@@ -781,7 +782,7 @@ class xt {
|
|
|
781
782
|
const n = await this.fetchEmbedAttachmentUpload(e);
|
|
782
783
|
if (n.ok)
|
|
783
784
|
return await n.json();
|
|
784
|
-
if (
|
|
785
|
+
if (Jr(n.status) && this.options.tokenProvider && !s) {
|
|
785
786
|
s = !0;
|
|
786
787
|
const r = await this.fetchEmbedAttachmentUpload(e);
|
|
787
788
|
if (r.ok)
|
|
@@ -1919,7 +1920,7 @@ function tn() {
|
|
|
1919
1920
|
}), T;
|
|
1920
1921
|
}, l = function(y, u) {
|
|
1921
1922
|
const d = r.call(this, y, u), g = Pe.get(this);
|
|
1922
|
-
return g && Object.keys(g.requestHeaders).length <
|
|
1923
|
+
return g && Object.keys(g.requestHeaders).length < Je && (g.requestHeaders[y] = et(y, u), g.excluded = g.excluded || q(g.url, g.requestHeaders)), d;
|
|
1923
1924
|
}, c = function(y) {
|
|
1924
1925
|
try {
|
|
1925
1926
|
const u = Pe.get(this);
|
|
@@ -2330,9 +2331,9 @@ function Ye() {
|
|
|
2330
2331
|
(d) => Lt(d) && !d.parentElement?.closest(n)
|
|
2331
2332
|
);
|
|
2332
2333
|
for (const d of r.slice(0, 3))
|
|
2333
|
-
s("Active overlay", ve(
|
|
2334
|
-
const i = Cn(), o = i ? ve(
|
|
2335
|
-
s("Main page content", o), s("Additional visible page text", ve(
|
|
2334
|
+
s("Active overlay", ve(V(d), e));
|
|
2335
|
+
const i = Cn(), o = i ? ve(V(i), e) : "";
|
|
2336
|
+
s("Main page content", o), s("Additional visible page text", ve(V(document.body), e));
|
|
2336
2337
|
const a = t.map(([d, g]) => `${d}:
|
|
2337
2338
|
${g}`).join(`
|
|
2338
2339
|
|
|
@@ -2343,7 +2344,7 @@ Visible page text:
|
|
|
2343
2344
|
`, p = 12e3 - c.length - h.length, w = Math.min(a.length, 7900), y = l.slice(0, p - w), u = a.slice(0, p - y.length);
|
|
2344
2345
|
return `${c}${y}${h}${u}`;
|
|
2345
2346
|
}
|
|
2346
|
-
function
|
|
2347
|
+
function V(t) {
|
|
2347
2348
|
return t.innerText ?? t.textContent ?? "";
|
|
2348
2349
|
}
|
|
2349
2350
|
function W(t) {
|
|
@@ -2365,7 +2366,7 @@ function Lt(t) {
|
|
|
2365
2366
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
2366
2367
|
}
|
|
2367
2368
|
function Cn() {
|
|
2368
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Lt).sort((t, e) =>
|
|
2369
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Lt).sort((t, e) => V(e).length - V(t).length)[0] ?? null;
|
|
2369
2370
|
}
|
|
2370
2371
|
function _n(t, e) {
|
|
2371
2372
|
const s = /* @__PURE__ */ new Set([
|
|
@@ -2781,7 +2782,7 @@ function Wt(t, e) {
|
|
|
2781
2782
|
role: i,
|
|
2782
2783
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2783
2784
|
content: gs(
|
|
2784
|
-
|
|
2785
|
+
Vn(r.content),
|
|
2785
2786
|
e
|
|
2786
2787
|
),
|
|
2787
2788
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2932,7 +2933,7 @@ function Oe(t) {
|
|
|
2932
2933
|
function O(t) {
|
|
2933
2934
|
return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
|
|
2934
2935
|
}
|
|
2935
|
-
function
|
|
2936
|
+
function Vn(t) {
|
|
2936
2937
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
|
|
2937
2938
|
if (!e || typeof e != "object")
|
|
2938
2939
|
return "";
|
|
@@ -2942,7 +2943,7 @@ function Jn(t) {
|
|
|
2942
2943
|
}
|
|
2943
2944
|
function Be(t, e) {
|
|
2944
2945
|
const s = Ft(t, e), n = sr(
|
|
2945
|
-
|
|
2946
|
+
Jn(
|
|
2946
2947
|
or(t, e),
|
|
2947
2948
|
s
|
|
2948
2949
|
),
|
|
@@ -2955,7 +2956,7 @@ function Be(t, e) {
|
|
|
2955
2956
|
const i = [...n];
|
|
2956
2957
|
return i[r] = s, $e(i);
|
|
2957
2958
|
}
|
|
2958
|
-
function
|
|
2959
|
+
function Jn(t, e) {
|
|
2959
2960
|
const s = e.assistantDraftItemId;
|
|
2960
2961
|
return s ? t.map(
|
|
2961
2962
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
@@ -3042,7 +3043,7 @@ function nr(t, e) {
|
|
|
3042
3043
|
);
|
|
3043
3044
|
}
|
|
3044
3045
|
function jt(t) {
|
|
3045
|
-
const e =
|
|
3046
|
+
const e = J(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3046
3047
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3047
3048
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3048
3049
|
];
|
|
@@ -3092,13 +3093,13 @@ function or(t, e) {
|
|
|
3092
3093
|
return n.splice(s, 1), n;
|
|
3093
3094
|
}
|
|
3094
3095
|
function $t(t, e) {
|
|
3095
|
-
const s =
|
|
3096
|
+
const s = J(t), n = J(e);
|
|
3096
3097
|
return s && n ? s === n : t.content === e.content;
|
|
3097
3098
|
}
|
|
3098
3099
|
function ge(t) {
|
|
3099
3100
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3100
3101
|
}
|
|
3101
|
-
function
|
|
3102
|
+
function J(t) {
|
|
3102
3103
|
const e = t.clientMessageId;
|
|
3103
3104
|
if (e)
|
|
3104
3105
|
return e;
|
|
@@ -3288,14 +3289,14 @@ function fr(t, e, s, n) {
|
|
|
3288
3289
|
(l) => l.role === "user" && l.id === o
|
|
3289
3290
|
) : null;
|
|
3290
3291
|
return {
|
|
3291
|
-
clientMessageId: a ?
|
|
3292
|
+
clientMessageId: a ? J(a) : o ? null : n,
|
|
3292
3293
|
runId: s ?? i?.runId ?? null
|
|
3293
3294
|
};
|
|
3294
3295
|
}
|
|
3295
3296
|
function oe(t, e, s) {
|
|
3296
3297
|
const n = new Set(
|
|
3297
3298
|
t.filter(
|
|
3298
|
-
(r) => r.role === "user" && e !== null &&
|
|
3299
|
+
(r) => r.role === "user" && e !== null && J(r) === e
|
|
3299
3300
|
).map((r) => r.id)
|
|
3300
3301
|
);
|
|
3301
3302
|
return t.filter(
|
|
@@ -3411,7 +3412,7 @@ function Er(t, e) {
|
|
|
3411
3412
|
`${Nt}${t}`,
|
|
3412
3413
|
JSON.stringify({
|
|
3413
3414
|
sessionId: e.sessionId,
|
|
3414
|
-
messages: e.messages.slice(-
|
|
3415
|
+
messages: e.messages.slice(-Js).map(Lr)
|
|
3415
3416
|
})
|
|
3416
3417
|
);
|
|
3417
3418
|
} catch {
|
|
@@ -3544,10 +3545,10 @@ function Xt(t, e) {
|
|
|
3544
3545
|
return !1;
|
|
3545
3546
|
const i = r;
|
|
3546
3547
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
3547
|
-
}), n = e ? s.map((r) =>
|
|
3548
|
+
}), n = e ? s.map((r) => Vt(r, e)) : s;
|
|
3548
3549
|
return n.length > 0 ? n : void 0;
|
|
3549
3550
|
}
|
|
3550
|
-
function
|
|
3551
|
+
function Vt(t, e) {
|
|
3551
3552
|
return t.fileUrl?.startsWith("/") ? {
|
|
3552
3553
|
...t,
|
|
3553
3554
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
@@ -3557,13 +3558,13 @@ function ze(t) {
|
|
|
3557
3558
|
return t.type || Nr(t.name) || "application/octet-stream";
|
|
3558
3559
|
}
|
|
3559
3560
|
function vr(t) {
|
|
3560
|
-
|
|
3561
|
+
Jt({
|
|
3561
3562
|
name: t.name,
|
|
3562
3563
|
mimeType: ze(t),
|
|
3563
3564
|
sizeBytes: t.size
|
|
3564
3565
|
});
|
|
3565
3566
|
}
|
|
3566
|
-
function
|
|
3567
|
+
function Jt(t) {
|
|
3567
3568
|
const e = Or(t.name), s = t.mimeType.trim().toLowerCase();
|
|
3568
3569
|
if (!Gs.has(`${e}:${s}`))
|
|
3569
3570
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
@@ -3630,7 +3631,7 @@ function Yt(t) {
|
|
|
3630
3631
|
const e = {};
|
|
3631
3632
|
try {
|
|
3632
3633
|
new Headers(t).forEach((s, n) => {
|
|
3633
|
-
Object.keys(e).length <
|
|
3634
|
+
Object.keys(e).length < Je && (e[n] = et(n, s));
|
|
3634
3635
|
});
|
|
3635
3636
|
} catch {
|
|
3636
3637
|
return {};
|
|
@@ -3663,7 +3664,7 @@ async function Wr(t) {
|
|
|
3663
3664
|
const n = new Promise((a) => {
|
|
3664
3665
|
s = window.setTimeout(() => {
|
|
3665
3666
|
e?.cancel(), a("timeout");
|
|
3666
|
-
},
|
|
3667
|
+
}, Vs);
|
|
3667
3668
|
}), r = new TextDecoder();
|
|
3668
3669
|
let i = "", o = 0;
|
|
3669
3670
|
for (; ; ) {
|
|
@@ -3673,7 +3674,7 @@ async function Wr(t) {
|
|
|
3673
3674
|
const { done: l, value: c } = a;
|
|
3674
3675
|
if (l)
|
|
3675
3676
|
return P(i + r.decode());
|
|
3676
|
-
const h =
|
|
3677
|
+
const h = Ve - o;
|
|
3677
3678
|
if (c.byteLength > h)
|
|
3678
3679
|
return i += r.decode(c.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${P(i)}... [truncated]`;
|
|
3679
3680
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
@@ -3720,7 +3721,7 @@ function Qt(t) {
|
|
|
3720
3721
|
if (!t)
|
|
3721
3722
|
return !1;
|
|
3722
3723
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
3723
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3724
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= Ve && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
3724
3725
|
}
|
|
3725
3726
|
function q(t, e = {}, s) {
|
|
3726
3727
|
if (zr(s))
|
|
@@ -3757,14 +3758,14 @@ function Kr(t) {
|
|
|
3757
3758
|
const n = s.indexOf(":");
|
|
3758
3759
|
if (n <= 0)
|
|
3759
3760
|
continue;
|
|
3760
|
-
if (Object.keys(e).length >=
|
|
3761
|
+
if (Object.keys(e).length >= Je)
|
|
3761
3762
|
break;
|
|
3762
3763
|
const r = s.slice(0, n).trim();
|
|
3763
3764
|
e[r] = et(r, s.slice(n + 1).trim());
|
|
3764
3765
|
}
|
|
3765
3766
|
return e;
|
|
3766
3767
|
}
|
|
3767
|
-
function P(t, e =
|
|
3768
|
+
function P(t, e = Ve) {
|
|
3768
3769
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
3769
3770
|
}
|
|
3770
3771
|
function Ne(t) {
|
|
@@ -3794,12 +3795,12 @@ function Gr(t) {
|
|
|
3794
3795
|
});
|
|
3795
3796
|
}
|
|
3796
3797
|
function Xr(t) {
|
|
3797
|
-
return t instanceof ue ?
|
|
3798
|
+
return t instanceof ue ? Vr(t.status) : t instanceof TypeError;
|
|
3798
3799
|
}
|
|
3799
|
-
function
|
|
3800
|
+
function Vr(t) {
|
|
3800
3801
|
return t === 408 || t === 409 || t === 429 || t >= 500;
|
|
3801
3802
|
}
|
|
3802
|
-
function
|
|
3803
|
+
function Jr(t) {
|
|
3803
3804
|
return t === 401 || t === 403;
|
|
3804
3805
|
}
|
|
3805
3806
|
const fe = "[REDACTED_SECRET]", D = "[REDACTED_TOKEN]", Yr = "[REDACTED_SIGNED_URL]", Qr = 20, Zr = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Zt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, es = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ts = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ss = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, ei = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, ti = /\bhttps?:\/\/[^\s"'<>]+/gi, si = /[),.;\]]+$/;
|