agentopia 1.1.3 → 1.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentopia",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Multi-Agent Collaboration Platform",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,9 +30,6 @@
30
30
  "node-cron": "^3.0.3",
31
31
  "uuid": "^11.1.0"
32
32
  },
33
- "optionalDependencies": {
34
- "node-pty": "^1.1.0"
35
- },
36
33
  "devDependencies": {
37
34
  "@types/better-sqlite3": "^7.6.12",
38
35
  "@types/node": "^22.10.0",
@@ -43,5 +40,8 @@
43
40
  "nodemon": "^3.1.14",
44
41
  "tsx": "^4.19.0",
45
42
  "typescript": "^5.7.0"
43
+ },
44
+ "optionalDependencies": {
45
+ "node-pty": "^1.1.0"
46
46
  }
47
47
  }
@@ -421,7 +421,7 @@
421
421
  iframe.style.cssText = 'width:100%;height:100%;border:none;background:#fff;';
422
422
  iframe.src = src;
423
423
  if (mode === 'html') {
424
- iframe.sandbox = 'allow-same-origin';
424
+ iframe.sandbox = 'allow-scripts allow-forms allow-popups';
425
425
  }
426
426
  editorEl.appendChild(iframe);
427
427
  this.state.previewMode = mode;
@@ -531,17 +531,32 @@
531
531
 
532
532
  async loadOfficeLib(mode) {
533
533
  if (mode === 'docx') {
534
- if (!window._mammothLoaded) {
534
+ if (!window.mammoth) {
535
535
  await this._loadScript('https://cdn.jsdelivr.net/npm/mammoth@1.8.0/mammoth.browser.min.js');
536
- window._mammothLoaded = true;
536
+ // Wait for the global to become available
537
+ await this._waitForGlobal('mammoth');
537
538
  }
538
539
  } else if (mode === 'xlsx') {
539
540
  if (!window.XLSX) {
540
541
  await this._loadScript('https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js');
542
+ await this._waitForGlobal('XLSX');
541
543
  }
542
544
  }
543
545
  }
544
546
 
547
+ _waitForGlobal(name, timeout = 5000) {
548
+ return new Promise((resolve, reject) => {
549
+ if (window[name]) return resolve();
550
+ const start = Date.now();
551
+ const check = () => {
552
+ if (window[name]) return resolve();
553
+ if (Date.now() - start > timeout) return reject(new Error(`${name} failed to load`));
554
+ setTimeout(check, 50);
555
+ };
556
+ check();
557
+ });
558
+ }
559
+
545
560
  _loadScript(url) {
546
561
  return new Promise((resolve, reject) => {
547
562
  const s = document.createElement('script');
@@ -563,7 +578,8 @@
563
578
 
564
579
  let html = '';
565
580
  if (mode === 'docx') {
566
- const result = await mammoth.convertToHtml({ arrayBuffer });
581
+ if (!window.mammoth) throw new Error('mammoth library not available');
582
+ const result = await window.mammoth.convertToHtml({ arrayBuffer });
567
583
  html = '<div style="max-width:800px;margin:0 auto;line-height:1.6">' + result.value + '</div>';
568
584
  if (result.messages && result.messages.length > 0) {
569
585
  html += '<div style="margin-top:16px;padding:8px;background:#fff3cd;border-radius:4px;font-size:12px;color:#856404">' +