@pluno/product-agent-web 0.1.11 → 0.1.13

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.
@@ -1,2 +1,4 @@
1
1
  export declare function createProductAgentCharacterSvg(primaryColor: string): string;
2
2
  export declare function createProductAgentCharacterDataUri(primaryColor: string): string;
3
+ export declare function createScribbleProductAgentCharacterSvg(primaryColor: string): string;
4
+ export declare function createScribbleProductAgentCharacterDataUri(primaryColor: string): string;
@@ -129,7 +129,7 @@ class q {
129
129
  isThinking: !0,
130
130
  lastError: null
131
131
  }), this.emit("message", i);
132
- const a = {
132
+ const o = {
133
133
  type: "chat.user_message",
134
134
  sessionId: this.state.sessionId ?? void 0,
135
135
  clientMessageId: r,
@@ -138,7 +138,7 @@ class q {
138
138
  model: this.options.model,
139
139
  metadata: this.options.metadata
140
140
  };
141
- this.activeClientMessageId = r, this.activeUserMessageEvent = a, this.markThinkingProgress(), this.send(a);
141
+ this.activeClientMessageId = r, this.activeUserMessageEvent = o, this.markThinkingProgress(), this.send(o);
142
142
  }
143
143
  stop() {
144
144
  this.state.sessionId && (this.send({ type: "run.stop", sessionId: this.state.sessionId }), this.setState({ isThinking: !1 }), this.clearThinkingWatchdog());
@@ -196,12 +196,11 @@ class q {
196
196
  rawAppearance: t.appearance,
197
197
  normalizedAppearance: s
198
198
  }), this.runtimeHelperJavascript = tt(t.runtimeHelpers)?.javascript ?? null;
199
- const r = {
199
+ const r = V(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = {
200
200
  user: ot(t.user),
201
- starterPrompts: V(t, "starterPrompts"),
202
201
  status: "connected"
203
202
  };
204
- (n || s) && (r.appearance = s), this.setState(r), this.state.sessionId && this.send({
203
+ (i || this.state.starterPrompts.length === 0) && (o.starterPrompts = r), (n || s) && (o.appearance = s), this.setState(o), this.state.sessionId && this.send({
205
204
  type: "page.upsert",
206
205
  sessionId: this.state.sessionId,
207
206
  page: g(),
@@ -212,14 +211,14 @@ class q {
212
211
  if (t.type === "conversation.state") {
213
212
  const s = Array.isArray(t.items) ? t.items : [];
214
213
  gt(s) && this.clearRetryTimers(), this.setState({
215
- sessionId: D(t.session, "id") ?? this.state.sessionId,
214
+ sessionId: P(t.session, "id") ?? this.state.sessionId,
216
215
  messages: at(s),
217
- ...N(s) ? { assistantDraft: "", isThinking: !1 } : {}
218
- }), N(s) && this.clearThinkingWatchdog();
216
+ ...b(s) ? { assistantDraft: "", isThinking: !1 } : {}
217
+ }), b(s) && this.clearThinkingWatchdog();
219
218
  return;
220
219
  }
221
220
  if (t.type === "session.updated") {
222
- this.setState({ sessionId: D(t.session, "id") ?? this.state.sessionId });
221
+ this.setState({ sessionId: P(t.session, "id") ?? this.state.sessionId });
223
222
  return;
224
223
  }
225
224
  if (t.type === "session.item") {
@@ -260,14 +259,14 @@ class q {
260
259
  if (i >= 1)
261
260
  return !1;
262
261
  this.retryAttemptsByClientMessageId[n] = i + 1;
263
- const a = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
262
+ const o = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
264
263
  return this.setState({ status: "reconnecting", isThinking: !0, lastError: null }), this.retryTimersByClientMessageId[n] = window.setTimeout(() => {
265
264
  delete this.retryTimersByClientMessageId[n], this.setState({ status: "connected", isThinking: !0, lastError: null }), this.markThinkingProgress(), this.send({
266
265
  type: "chat.retry_last_user_message",
267
266
  sessionId: s,
268
267
  clientMessageId: n
269
268
  });
270
- }, a), !0;
269
+ }, o), !0;
271
270
  }
272
271
  clearRetryTimers() {
273
272
  for (const t of Object.values(this.retryTimersByClientMessageId))
@@ -338,10 +337,10 @@ class q {
338
337
  const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = t.rawInput;
339
338
  if (!s || !n || !It(r))
340
339
  return;
341
- const i = await this.executeRuntimeHelper(), a = await M(r).catch((o) => ({
340
+ const i = await this.executeRuntimeHelper(), o = await M(r).catch((a) => ({
342
341
  ok: !1,
343
342
  exception: {
344
- message: o instanceof Error ? o.message : String(o)
343
+ message: a instanceof Error ? a.message : String(a)
345
344
  }
346
345
  }));
347
346
  this.send({
@@ -351,7 +350,7 @@ class q {
351
350
  toolName: "execute_code",
352
351
  summary: r.summary,
353
352
  rawInput: f(r),
354
- rawOutput: f(et(a, i))
353
+ rawOutput: f(et(o, i))
355
354
  });
356
355
  }
357
356
  async executeRuntimeHelper() {
@@ -366,10 +365,10 @@ class q {
366
365
  if (this.networkCaptureCleanup)
367
366
  return;
368
367
  const t = window.fetch.bind(window), s = XMLHttpRequest.prototype.open, n = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send;
369
- window.fetch = async (i, a) => {
370
- const o = Date.now(), c = new Date(o).toISOString(), u = i instanceof Request ? i : null, y = typeof i == "string" ? i : i instanceof URL ? i.toString() : u?.url ?? "", w = (a?.method ?? u?.method ?? "GET").toUpperCase(), A = H(new Headers(a?.headers ?? u?.headers ?? void 0)), C = await _t(u, a);
368
+ window.fetch = async (i, o) => {
369
+ const a = Date.now(), c = new Date(a).toISOString(), u = i instanceof Request ? i : null, y = typeof i == "string" ? i : i instanceof URL ? i.toString() : u?.url ?? "", w = (o?.method ?? u?.method ?? "GET").toUpperCase(), A = H(new Headers(o?.headers ?? u?.headers ?? void 0)), C = await _t(u, o);
371
370
  try {
372
- const d = await t(i, a);
371
+ const d = await t(i, o);
373
372
  return this.enqueueNetworkEvent({
374
373
  requestId: T("fetch"),
375
374
  url: y,
@@ -381,7 +380,7 @@ class q {
381
380
  responseHeaders: H(d.headers),
382
381
  responseBody: await Et(d),
383
382
  startedAt: c,
384
- durationMs: Date.now() - o
383
+ durationMs: Date.now() - a
385
384
  }), d;
386
385
  } catch (d) {
387
386
  throw this.enqueueNetworkEvent({
@@ -393,27 +392,27 @@ class q {
393
392
  resourceType: "fetch",
394
393
  errorText: d instanceof Error ? d.message : String(d),
395
394
  startedAt: c,
396
- durationMs: Date.now() - o
395
+ durationMs: Date.now() - a
397
396
  }), d;
398
397
  }
399
- }, XMLHttpRequest.prototype.open = function(a, o, c, u, y) {
398
+ }, XMLHttpRequest.prototype.open = function(o, a, c, u, y) {
400
399
  return this.__plunoMeta = {
401
400
  requestId: T("xhr"),
402
- method: String(a ?? "GET").toUpperCase(),
403
- url: typeof o == "string" ? o : o.toString(),
401
+ method: String(o ?? "GET").toUpperCase(),
402
+ url: typeof a == "string" ? a : a.toString(),
404
403
  requestHeaders: {},
405
404
  startedAtMs: Date.now(),
406
405
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
407
- }, s.call(this, a, o, c ?? !0, u ?? void 0, y ?? void 0);
408
- }, XMLHttpRequest.prototype.setRequestHeader = function(a, o) {
406
+ }, s.call(this, o, a, c ?? !0, u ?? void 0, y ?? void 0);
407
+ }, XMLHttpRequest.prototype.setRequestHeader = function(o, a) {
409
408
  const c = this.__plunoMeta;
410
409
  if (c) {
411
410
  const u = c.requestHeaders ?? {};
412
- u[a] = o, c.requestHeaders = u;
411
+ u[o] = a, c.requestHeaders = u;
413
412
  }
414
- return n.call(this, a, o);
415
- }, XMLHttpRequest.prototype.send = function(a) {
416
- const o = window.__plunoProductAgentInstance, c = this.__plunoMeta ?? {
413
+ return n.call(this, o, a);
414
+ }, XMLHttpRequest.prototype.send = function(o) {
415
+ const a = window.__plunoProductAgentInstance, c = this.__plunoMeta ?? {
417
416
  requestId: T("xhr"),
418
417
  method: "GET",
419
418
  url: "",
@@ -421,10 +420,10 @@ class q {
421
420
  startedAtMs: Date.now(),
422
421
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
423
422
  };
424
- return c.requestBody = B(a), this.__plunoMeta = c, this.addEventListener(
423
+ return c.requestBody = B(o), this.__plunoMeta = c, this.addEventListener(
425
424
  "loadend",
426
425
  function() {
427
- !o || !this.__plunoMeta || o.enqueueNetworkEvent({
426
+ !a || !this.__plunoMeta || a.enqueueNetworkEvent({
428
427
  requestId: String(this.__plunoMeta.requestId),
429
428
  url: String(this.__plunoMeta.url ?? ""),
430
429
  method: String(this.__plunoMeta.method ?? "GET"),
@@ -440,7 +439,7 @@ class q {
440
439
  });
441
440
  },
442
441
  { once: !0 }
443
- ), r.call(this, a ?? null);
442
+ ), r.call(this, o ?? null);
444
443
  }, window.__plunoProductAgentInstance = this, this.networkCaptureCleanup = () => {
445
444
  window.fetch = t, XMLHttpRequest.prototype.open = s, XMLHttpRequest.prototype.setRequestHeader = n, XMLHttpRequest.prototype.send = r, window.__plunoProductAgentInstance === this && delete window.__plunoProductAgentInstance;
446
445
  };
@@ -505,10 +504,10 @@ async function M(e) {
505
504
  info: console.info,
506
505
  warn: console.warn,
507
506
  error: console.error
508
- }, a = (o) => (...c) => {
509
- r.push({ level: o, args: c }), i[o](...c);
507
+ }, o = (a) => (...c) => {
508
+ r.push({ level: a, args: c }), i[a](...c);
510
509
  };
511
- console.log = a("log"), console.info = a("info"), console.warn = a("warn"), console.error = a("error");
510
+ console.log = o("log"), console.info = o("info"), console.warn = o("warn"), console.error = o("error");
512
511
  try {
513
512
  return {
514
513
  ok: !0,
@@ -525,14 +524,14 @@ async function M(e) {
525
524
  origin: location.origin
526
525
  }
527
526
  };
528
- } catch (o) {
527
+ } catch (a) {
529
528
  return {
530
529
  ok: !1,
531
530
  console: r,
532
531
  exception: {
533
- name: o instanceof Error ? o.name : "Error",
534
- message: o instanceof Error ? o.message : String(o),
535
- stack: o instanceof Error ? o.stack : void 0
532
+ name: a instanceof Error ? a.name : "Error",
533
+ message: a instanceof Error ? a.message : String(a),
534
+ stack: a instanceof Error ? a.stack : void 0
536
535
  },
537
536
  metadata: {
538
537
  durationMs: Date.now() - n,
@@ -578,11 +577,11 @@ function Z(e) {
578
577
  function Q(e) {
579
578
  if (!e || typeof e != "object")
580
579
  return null;
581
- const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, a = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null;
582
- return !r && !i && !a ? null : {
580
+ const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null;
581
+ return !r && !i && !o ? null : {
583
582
  ...r ? { accentColor: r } : {},
584
583
  ...i ? { colorScheme: i } : {},
585
- ...a ? { fontFamily: a } : {}
584
+ ...o ? { fontFamily: o } : {}
586
585
  };
587
586
  }
588
587
  function tt(e) {
@@ -727,13 +726,13 @@ function pt(e, t) {
727
726
  const n = [...e];
728
727
  return n.splice(s, 1), n;
729
728
  }
730
- function N(e) {
729
+ function b(e) {
731
730
  const t = W(e);
732
731
  return t === null ? !1 : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : I(s.data));
733
732
  }
734
733
  function gt(e) {
735
734
  const t = W(e);
736
- return t === null ? e.some((s) => !s || typeof s != "object" ? !1 : b(s.data)) : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : b(s.data));
735
+ return t === null ? e.some((s) => !s || typeof s != "object" ? !1 : N(s.data)) : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : N(s.data));
737
736
  }
738
737
  function W(e) {
739
738
  for (let t = e.length - 1; t >= 0; t -= 1) {
@@ -749,7 +748,7 @@ function W(e) {
749
748
  }
750
749
  return null;
751
750
  }
752
- function b(e) {
751
+ function N(e) {
753
752
  if (!e || typeof e != "object")
754
753
  return !1;
755
754
  const t = e;
@@ -777,7 +776,7 @@ function yt(e, t) {
777
776
  }
778
777
  return !1;
779
778
  }
780
- function D(e, t) {
779
+ function P(e, t) {
781
780
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
782
781
  }
783
782
  function mt(e) {
@@ -837,9 +836,9 @@ function x(e) {
837
836
  if (!e || typeof e != "object")
838
837
  return !1;
839
838
  const t = e;
840
- return t.type === "chat.user_message" ? typeof t.content == "string" && P(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? P(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" : !1;
839
+ return t.type === "chat.user_message" ? typeof t.content == "string" && D(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? D(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" : !1;
841
840
  }
842
- function P(e) {
841
+ function D(e) {
843
842
  if (!e || typeof e != "object")
844
843
  return !1;
845
844
  const t = e;
@@ -924,7 +923,7 @@ function p(e) {
924
923
  function T(e) {
925
924
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
926
925
  }
927
- const E = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]", Ct = "[REDACTED_SIGNED_URL]", Rt = 20, Mt = /^(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, L = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, j = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, v = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, G = /\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, Nt = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, bt = /\bhttps?:\/\/[^\s"'<>]+/gi, Dt = /[),.;\]]+$/;
926
+ const E = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]", Ct = "[REDACTED_SIGNED_URL]", Rt = 20, Mt = /^(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, L = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, j = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, G = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, v = /\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, bt = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Nt = /\bhttps?:\/\/[^\s"'<>]+/gi, Pt = /[),.;\]]+$/;
928
927
  function f(e) {
929
928
  return S(e, 0, /* @__PURE__ */ new WeakSet());
930
929
  }
@@ -941,10 +940,10 @@ function S(e, t, s) {
941
940
  return e.map((r) => S(r, t + 1, s));
942
941
  const n = {};
943
942
  for (const [r, i] of Object.entries(e))
944
- Pt(r) ? n[r] = E : n[r] = r.toLowerCase() === "url" ? Ht(i) : S(i, t + 1, s);
943
+ Dt(r) ? n[r] = E : n[r] = r.toLowerCase() === "url" ? Ht(i) : S(i, t + 1, s);
945
944
  return n;
946
945
  }
947
- function Pt(e) {
946
+ function Dt(e) {
948
947
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
949
948
  return t.includes("authorization") || t.includes("cookie") || t.includes("password") || t.includes("passwd") || t === "pwd" || t.includes("secret") || t === "token" || t.endsWith("token") || t.includes("apikey") || t.includes("csrf") || t.includes("xsrf") || t === "jwt" || t === "session" || t === "signature" || t.includes("privatekey");
950
949
  }
@@ -962,13 +961,13 @@ function $(e) {
962
961
  }
963
962
  }
964
963
  function Ot(e) {
965
- return e.replace(Nt, Ct).replace(bt, Ut).replace(L, `Bearer ${h}`).replace(j, `Basic ${h}`).replace(v, h).replace(G, (t, s) => `${s}: ${E}`);
964
+ return e.replace(bt, Ct).replace(Nt, Ut).replace(L, `Bearer ${h}`).replace(j, `Basic ${h}`).replace(G, h).replace(v, (t, s) => `${s}: ${E}`);
966
965
  }
967
966
  function qt(e) {
968
- return e.replace(L, `Bearer ${h}`).replace(j, `Basic ${h}`).replace(v, h).replace(G, (t, s) => `${s}: ${E}`);
967
+ return e.replace(L, `Bearer ${h}`).replace(j, `Basic ${h}`).replace(G, h).replace(v, (t, s) => `${s}: ${E}`);
969
968
  }
970
969
  function Ut(e) {
971
- const t = e.match(Dt)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
970
+ const t = e.match(Pt)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
972
971
  return `${$(s)}${t}`;
973
972
  }
974
973
  export {