@metagptx/web-sdk 0.0.64 → 0.0.65

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.
Files changed (2) hide show
  1. package/dist/plugins.js +31 -7
  2. package/package.json +1 -1
package/dist/plugins.js CHANGED
@@ -239,6 +239,8 @@ if (window.__MGX_VITE_ERROR_OVERLAY_INSTALLED__) {
239
239
 
240
240
  let overlayElement = null;
241
241
  let cleanupRegistered = false;
242
+ let latestOverlayError = null;
243
+ let chatInfoStatus = 'not_working';
242
244
  const mascotImage = 'https://public-frontend-cos.metadl.com/commonfile/engineer.svg';
243
245
  const isInMGXIframe = window.self !== window.top && window.name && window.name.includes('devIframe');
244
246
 
@@ -264,6 +266,14 @@ function removeOverlay() {
264
266
  }
265
267
  }
266
268
 
269
+ function getOverlayTitle() {
270
+ if (chatInfoStatus === 'working') {
271
+ return 'Agent is on the job! Please check back in a bit.';
272
+ }
273
+
274
+ return 'Something is wrong';
275
+ }
276
+
267
277
  function onEscape(e) {
268
278
  if (e.key === 'Escape') removeOverlay();
269
279
  }
@@ -296,6 +306,7 @@ function postResolveMessage(err) {
296
306
 
297
307
  function createOverlay(err) {
298
308
  removeOverlay();
309
+ latestOverlayError = err;
299
310
 
300
311
  const overlay = document.createElement('div');
301
312
  overlay.id = 'custom-vite-error-overlay';
@@ -308,14 +319,14 @@ function createOverlay(err) {
308
319
  '<img alt="" src="' + mascotImage + '" style="width:80px;height:80px;object-fit:cover;pointer-events:none;" />' +
309
320
  '</div>' +
310
321
 
311
- '<div style="font-size:14px;line-height:24px;font-weight:400;color:rgba(12,12,12,0.8);text-align:center;">Something is wrong</div>' +
312
- '<div style="font-size:12px;line-height:18px;color:rgba(12,12,12,0.48);text-align:center;max-width:280px;">' + escapeHtml(err.message || 'Unknown error') + '</div>' +
322
+ '<div style="font-size:14px;line-height:24px;font-weight:400;color:rgba(12,12,12,0.8);text-align:center;">' + getOverlayTitle() + '</div>' +
323
+
313
324
  '<div style="display:flex;align-items:flex-start;gap:8px;">' +
314
325
  '<button id="cve-reload" style="display:inline-flex;align-items:center;justify-content:center;gap:4px;height:28px;padding:0 12px;border:none;border-radius:8px;background:rgba(12,12,12,0.06);color:rgba(12,12,12,0.95);font-size:14px;font-weight:500;line-height:22px;cursor:pointer;">' +
315
326
  '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path d="M11.105 5.20813C11.3465 5.20827 11.5425 5.40409 11.5425 5.64563C11.5425 8.78666 8.99598 11.333 5.85498 11.3331C4.11675 11.3331 2.56217 10.5521 1.51929 9.32422V10.1779C1.51929 10.4195 1.32341 10.6154 1.08179 10.6154C0.840163 10.6154 0.644287 10.4195 0.644287 10.1779V8.26892C0.644287 8.0273 0.840163 7.83142 1.08179 7.83142H2.99072C3.23235 7.83142 3.42822 8.0273 3.42822 8.26892C3.42814 8.51048 3.2323 8.70642 2.99072 8.70642H2.14392C3.02711 9.77583 4.36095 10.4581 5.85498 10.4581C8.51273 10.458 10.6675 8.30342 10.6675 5.64563C10.6675 5.40401 10.8634 5.20813 11.105 5.20813Z" fill="#0C0C0C" fill-opacity="0.95"/><path d="M5.6875 0C7.42573 0 8.98031 0.781055 10.0232 2.00891V1.15527C10.0232 0.913649 10.2191 0.717773 10.4607 0.717773C10.7023 0.717773 10.8982 0.913649 10.8982 1.15527V3.06421C10.898 3.30566 10.7022 3.50171 10.4607 3.50171H8.55176C8.31026 3.50171 8.11446 3.30566 8.11426 3.06421C8.11434 2.82265 8.31018 2.62671 8.55176 2.62671H9.39856C8.51537 1.5573 7.18153 0.875 5.6875 0.875C3.02975 0.87514 0.875 3.02971 0.875 5.6875C0.874798 5.92895 0.679 6.125 0.4375 6.125C0.196119 6.12486 0.000202109 5.92887 0 5.6875C0 2.54647 2.5465 0.000140261 5.6875 0Z" fill="#0C0C0C" fill-opacity="0.95"/></svg>' +
316
327
  '<span>Reload</span>' +
317
328
  '</button>' +
318
- (isInMGXIframe
329
+ (isInMGXIframe && chatInfoStatus !== 'working'
319
330
  ? '<button id="cve-resolve" style="display:inline-flex;align-items:center;justify-content:center;gap:4px;height:28px;padding:0 12px;border:none;border-radius:8px;background:#111111;color:rgba(255,255,255,0.95);font-size:14px;font-weight:500;line-height:22px;cursor:pointer;">' +
320
331
  '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none"><path d="M12.4186 3.77422C12.3921 3.70862 12.35 3.65045 12.296 3.60467C12.2421 3.5589 12.1778 3.5269 12.1088 3.51141C12.0397 3.49593 11.968 3.49742 11.8996 3.51576C11.8313 3.5341 11.7684 3.56874 11.7164 3.61672L9.5125 5.65054L8.57023 5.4482L8.36789 4.50593L10.4017 2.30203C10.4497 2.25002 10.4843 2.18714 10.5027 2.1188C10.521 2.05046 10.5225 1.97869 10.507 1.90965C10.4915 1.84061 10.4595 1.77635 10.4138 1.72239C10.368 1.66843 10.3098 1.62638 10.2442 1.59984C9.64645 1.35803 8.99844 1.26673 8.35713 1.33396C7.71581 1.40119 7.10083 1.62489 6.5662 1.98542C6.03158 2.34594 5.59367 2.83224 5.29097 3.4016C4.98827 3.97096 4.83003 4.60595 4.83015 5.25078C4.82945 5.79529 4.94115 6.33409 5.15828 6.83343L1.86554 9.68047C1.85734 9.68703 1.84968 9.69468 1.84203 9.70179C1.5138 10.03 1.32941 10.4752 1.32941 10.9394C1.32941 11.1692 1.37468 11.3968 1.46263 11.6091C1.55059 11.8215 1.67951 12.0144 1.84203 12.177C2.00455 12.3395 2.19749 12.4684 2.40983 12.5563C2.62218 12.6443 2.84977 12.6896 3.07961 12.6896C3.54379 12.6896 3.98896 12.5052 4.31718 12.177C4.32429 12.1698 4.33195 12.1616 4.33851 12.154L7.185 8.86015C7.78461 9.12336 8.4404 9.23287 9.09299 9.17876C9.74559 9.12466 10.3744 8.90865 10.9225 8.55028C11.4705 8.19192 11.9206 7.70253 12.2319 7.1264C12.5431 6.55028 12.7058 5.90562 12.7052 5.25078C12.706 4.74469 12.6087 4.24324 12.4186 3.77422ZM8.76765 8.31328C8.2498 8.31257 7.74054 8.18088 7.28726 7.93047C7.19945 7.88195 7.09762 7.86509 6.99886 7.88272C6.90009 7.90034 6.81038 7.95137 6.74476 8.02726L3.68773 11.5677C3.5223 11.7249 3.30202 11.8112 3.07385 11.8083C2.84569 11.8054 2.62769 11.7134 2.46634 11.5521C2.30499 11.3907 2.21305 11.1727 2.21013 10.9446C2.20721 10.7164 2.29353 10.4961 2.4507 10.3307L5.98843 7.27422C6.06446 7.20857 6.11557 7.11876 6.1332 7.01987C6.15082 6.92098 6.13389 6.81904 6.08523 6.73117C5.80634 6.22675 5.67546 5.65387 5.70763 5.07839C5.7398 4.50291 5.93372 3.94819 6.2671 3.478C6.60047 3.00782 7.05977 2.64125 7.59218 2.42045C8.12459 2.19965 8.70851 2.13359 9.27679 2.22984L7.57054 4.07883C7.52307 4.13033 7.48865 4.19247 7.47019 4.26004C7.45173 4.32761 7.44976 4.39862 7.46445 4.46711L7.77398 5.90703C7.79169 5.98938 7.83279 6.06488 7.89235 6.12444C7.95192 6.184 8.02741 6.22511 8.10976 6.24281L9.55078 6.55234C9.61927 6.56703 9.69028 6.56506 9.75784 6.5466C9.82541 6.52814 9.88756 6.49372 9.93906 6.44625L11.788 4.74C11.8618 5.17914 11.8389 5.62907 11.7211 6.0585C11.6033 6.48792 11.3934 6.88654 11.106 7.22661C10.8185 7.56669 10.4604 7.84006 10.0566 8.02772C9.65279 8.21538 9.21294 8.31283 8.76765 8.31328Z" fill="white" fill-opacity="0.95"/></svg>' +
321
332
  '<span>Resolve</span>' +
@@ -330,10 +341,6 @@ function createOverlay(err) {
330
341
  const backdrop = overlay.firstElementChild;
331
342
  const card = backdrop && backdrop.firstElementChild;
332
343
 
333
- if (backdrop) {
334
- backdrop.addEventListener('click', removeOverlay);
335
- }
336
-
337
344
  if (card) {
338
345
  card.addEventListener('click', function(e) {
339
346
  e.stopPropagation();
@@ -397,6 +404,23 @@ window.addEventListener('error', function(event) {
397
404
 
398
405
  window.addEventListener('unhandledrejection', function(event) {
399
406
  createOverlay(normalizeRuntimeError(event.reason));
407
+ });
408
+ window.addEventListener('message', function(event) {
409
+ const payload = event.data;
410
+ if (!payload || payload.type !== 'chat_info' || !payload.data) {
411
+ return;
412
+ }
413
+
414
+ const nextStatus = payload.data.status;
415
+ if (nextStatus !== 'working' && nextStatus !== 'not_working') {
416
+ return;
417
+ }
418
+
419
+ chatInfoStatus = nextStatus;
420
+
421
+ if (overlayElement && latestOverlayError) {
422
+ createOverlay(latestOverlayError);
423
+ }
400
424
  });
401
425
 
402
426
  if (import.meta.hot) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metagptx/web-sdk",
3
3
  "type": "module",
4
- "version": "0.0.64",
4
+ "version": "0.0.65",
5
5
  "description": "TypeScript SDK for interacting with FuncSea API",
6
6
  "author": "MetaGPTX",
7
7
  "license": "MIT",