@tangle-network/agent-app 0.60.140 → 0.60.142

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 (35) hide show
  1. package/dist/assistant/index.js +10 -10
  2. package/dist/chat-react/index.js +5 -5
  3. package/dist/chatgpt-react/index.js +1 -1
  4. package/dist/{chunk-GE7Y7ODP.js → chunk-AA4FKEQW.js} +2 -2
  5. package/dist/{chunk-GHOXLL2T.js → chunk-CW6F6GDP.js} +3 -3
  6. package/dist/{chunk-JTBPQEGM.js → chunk-EGEULRT2.js} +2 -2
  7. package/dist/{chunk-NTSZGBHZ.js → chunk-ILZQAXJH.js} +2 -2
  8. package/dist/{chunk-2DJSGH52.js → chunk-MOFLIBQW.js} +3 -3
  9. package/dist/{chunk-WTHMHOU2.js → chunk-R5K5ML3Q.js} +2 -2
  10. package/dist/chunk-RASGKEAL.js +40 -0
  11. package/dist/chunk-RASGKEAL.js.map +1 -0
  12. package/dist/{chunk-ZBKUJXD7.js → chunk-S5QRYJW5.js} +3 -3
  13. package/dist/{chunk-T6BAHD5S.js → chunk-XSPUKVHF.js} +3 -3
  14. package/dist/{chunk-WAMJU3G4.js → chunk-ZEMO7S2G.js} +4 -4
  15. package/dist/{mention-editor-2WLBHH3A.js → mention-editor-JO2Y6C6S.js} +3 -3
  16. package/dist/studio-react/index.js +4 -4
  17. package/dist/web-react/agent-profile-editor.js +5 -5
  18. package/dist/web-react/index.js +10 -10
  19. package/dist/web-react/provider-logo.d.ts +7 -6
  20. package/dist/workspace-export/index.js +129 -43
  21. package/dist/workspace-export/index.js.map +1 -1
  22. package/dist/workspace-react/index.js +5 -5
  23. package/package.json +2 -2
  24. package/dist/chunk-MLG6XKPV.js +0 -44
  25. package/dist/chunk-MLG6XKPV.js.map +0 -1
  26. /package/dist/{chunk-GE7Y7ODP.js.map → chunk-AA4FKEQW.js.map} +0 -0
  27. /package/dist/{chunk-GHOXLL2T.js.map → chunk-CW6F6GDP.js.map} +0 -0
  28. /package/dist/{chunk-JTBPQEGM.js.map → chunk-EGEULRT2.js.map} +0 -0
  29. /package/dist/{chunk-NTSZGBHZ.js.map → chunk-ILZQAXJH.js.map} +0 -0
  30. /package/dist/{chunk-2DJSGH52.js.map → chunk-MOFLIBQW.js.map} +0 -0
  31. /package/dist/{chunk-WTHMHOU2.js.map → chunk-R5K5ML3Q.js.map} +0 -0
  32. /package/dist/{chunk-ZBKUJXD7.js.map → chunk-S5QRYJW5.js.map} +0 -0
  33. /package/dist/{chunk-T6BAHD5S.js.map → chunk-XSPUKVHF.js.map} +0 -0
  34. /package/dist/{chunk-WAMJU3G4.js.map → chunk-ZEMO7S2G.js.map} +0 -0
  35. /package/dist/{mention-editor-2WLBHH3A.js.map → mention-editor-JO2Y6C6S.js.map} +0 -0
@@ -660,14 +660,22 @@ function createExportEngine(options) {
660
660
  pendingLength = 0;
661
661
  };
662
662
  const reader = stream.getReader();
663
- for (; ; ) {
664
- const { done, value } = await reader.read();
665
- if (done) break;
666
- pending.push(value);
667
- pendingLength += value.length;
668
- if (pendingLength >= SEGMENT_BYTES) await flush();
663
+ try {
664
+ for (; ; ) {
665
+ const { done, value } = await reader.read();
666
+ if (done) break;
667
+ pending.push(value);
668
+ pendingLength += value.length;
669
+ if (pendingLength >= SEGMENT_BYTES) await flush();
670
+ }
671
+ await flush();
672
+ } catch (err) {
673
+ await reader.cancel(err).catch(() => {
674
+ });
675
+ throw err;
676
+ } finally {
677
+ reader.releaseLock();
669
678
  }
670
- await flush();
671
679
  return {
672
680
  path,
673
681
  method: compress ? 8 : 0,
@@ -708,7 +716,7 @@ function createExportEngine(options) {
708
716
  const omit = new Set(source.omitColumns ?? []);
709
717
  unit.expectedRows = source.expectedCount ? await source.expectedCount() : void 0;
710
718
  const csv = source.format === "csv";
711
- const columns = source.columns ?? [];
719
+ const columns = (source.columns ?? []).filter((column) => !omit.has(column));
712
720
  if (csv && !columns.length) throw new Error(`workspace-export: csv source "${source.name}" needs columns`);
713
721
  let rows = 0;
714
722
  const iterator = source.rows()[Symbol.asyncIterator]();
@@ -766,37 +774,47 @@ function createExportEngine(options) {
766
774
  const used = new Set(unit.entries.map((e) => e.path.slice(folder.length)));
767
775
  const start = unit.cursor ?? 0;
768
776
  let seen = 0;
769
- let written = 0;
770
777
  let chunk = [];
771
778
  const flush = async () => {
772
- const written_ = await Promise.all(
773
- chunk.map(async ({ file, position, path }) => {
779
+ const results = await Promise.allSettled(chunk.map(({ entry }) => entry));
780
+ for (const result of results) if (result.status === "rejected") throw result.reason;
781
+ for (const result of results) {
782
+ if (result.status === "fulfilled" && result.value) {
783
+ unit.entries.push(result.value);
784
+ }
785
+ }
786
+ unit.cursor = chunk.at(-1).position + 1;
787
+ chunk = [];
788
+ };
789
+ try {
790
+ for await (const file of source.files()) {
791
+ if (seen < start) {
792
+ seen += 1;
793
+ continue;
794
+ }
795
+ if (seen - start >= FILES_PER_REQUEST || now() > deadline) {
796
+ if (chunk.length) await flush();
797
+ unit.cursor = seen;
798
+ return;
799
+ }
800
+ const position = seen;
801
+ const path = folder + safePath(file.path, used);
802
+ const entry = (async () => {
774
803
  const body = await file.open();
775
804
  if (body === null) return null;
776
805
  const masked = toStream(body).pipeThrough(scanner.maskBytes((n) => unit.redactions += n));
777
806
  return writeEntry(`${keyBase}/p${position}`, path, masked, false);
778
- })
779
- );
780
- for (const entry of written_) if (entry) unit.entries.push(entry);
781
- written += written_.filter(Boolean).length;
782
- unit.cursor = chunk.at(-1).position + 1;
783
- chunk = [];
784
- };
785
- for await (const file of source.files()) {
786
- if (seen < start) {
807
+ })();
808
+ void entry.catch(() => {
809
+ });
810
+ chunk.push({ position, entry });
787
811
  seen += 1;
788
- continue;
789
- }
790
- if (written + chunk.length >= FILES_PER_REQUEST || now() > deadline) {
791
- if (chunk.length) await flush();
792
- unit.cursor = seen;
793
- return;
812
+ if (chunk.length >= FILES_IN_PARALLEL) await flush();
794
813
  }
795
- chunk.push({ file, position: seen, path: folder + safePath(file.path, used) });
796
- seen += 1;
797
- if (chunk.length >= FILES_IN_PARALLEL) await flush();
814
+ if (chunk.length) await flush();
815
+ } finally {
816
+ await Promise.allSettled(chunk.map(({ entry }) => entry));
798
817
  }
799
- if (chunk.length) await flush();
800
818
  unit.cursor = void 0;
801
819
  unit.files = unit.entries.length;
802
820
  unit.status = unit.entries.length ? "done" : "empty";
@@ -808,8 +826,17 @@ function createExportEngine(options) {
808
826
  return;
809
827
  }
810
828
  const stats = { files: 0, bytes: 0, blanked: [] };
811
- const tarGz = archive.pipeThrough(new DecompressionStream("gzip")).pipeThrough(createTarInspector(stats, source.exclude)).pipeThrough(scanner.maskBytes((n) => unit.redactions += n)).pipeThrough(new CompressionStream("gzip"));
812
- unit.entries.push(await writeEntry(`${keyBase}/0`, `sandbox/${source.name}.tar.gz`, tarGz, false));
829
+ const decompressor = new DecompressionStream("gzip");
830
+ const pumping = archive.pipeTo(decompressor.writable);
831
+ void pumping.catch(() => {
832
+ });
833
+ const tarGz = decompressor.readable.pipeThrough(createTarInspector(stats, source.exclude)).pipeThrough(scanner.maskBytes((n) => unit.redactions += n)).pipeThrough(new CompressionStream("gzip"));
834
+ try {
835
+ unit.entries.push(await writeEntry(`${keyBase}/0`, `sandbox/${source.name}.tar.gz`, tarGz, false));
836
+ } finally {
837
+ await pumping.catch(() => {
838
+ });
839
+ }
813
840
  unit.archive = stats;
814
841
  unit.files = stats.files;
815
842
  unit.status = "done";
@@ -1522,18 +1549,28 @@ async function openRunning(getBox, timeoutMs) {
1522
1549
  const box = await getBox();
1523
1550
  if (!box || GONE.has(box.status)) return null;
1524
1551
  const wasStopped = box.status === "stopped";
1552
+ let resumed = false;
1553
+ let restoring;
1554
+ const restore = () => restoring ??= (async () => {
1555
+ if (resumed && box.stop) {
1556
+ try {
1557
+ await box.stop();
1558
+ } catch {
1559
+ }
1560
+ }
1561
+ })();
1525
1562
  try {
1526
- if (wasStopped) await box.resume();
1563
+ if (wasStopped) {
1564
+ await box.resume();
1565
+ resumed = true;
1566
+ }
1527
1567
  if (box.status !== "running" || wasStopped) await box.waitFor("running", { timeoutMs });
1528
1568
  } catch (err) {
1569
+ await restore();
1529
1570
  if (isLifecycleBusy(err)) throw new ExportRetryLater("the sandbox is busy with another operation; retrying shortly");
1530
1571
  if (isServerFailure(err)) throw new ExportRetryLater("the sandbox could not be started; retrying shortly");
1531
1572
  throw err;
1532
1573
  }
1533
- const restore = async () => {
1534
- if (wasStopped && box.stop) await box.stop().catch(() => {
1535
- });
1536
- };
1537
1574
  return { box, restore };
1538
1575
  }
1539
1576
  function sandboxArchive(args) {
@@ -1546,8 +1583,45 @@ function sandboxArchive(args) {
1546
1583
  async open() {
1547
1584
  const opened = await openRunning(args.getBox, args.resumeTimeoutMs ?? 12e4);
1548
1585
  if (!opened) return null;
1549
- const archive = await opened.box.fs.openArchive(args.dir ?? ".");
1550
- return archive.pipeThrough(new TransformStream({ flush: () => opened.restore() }));
1586
+ try {
1587
+ const archive = await opened.box.fs.openArchive(args.dir ?? ".");
1588
+ const reader = archive.getReader();
1589
+ let ended = false;
1590
+ return new ReadableStream({
1591
+ async pull(controller) {
1592
+ try {
1593
+ const { done, value } = await reader.read();
1594
+ if (ended) return;
1595
+ if (!done) {
1596
+ controller.enqueue(value);
1597
+ return;
1598
+ }
1599
+ ended = true;
1600
+ await opened.restore();
1601
+ reader.releaseLock();
1602
+ controller.close();
1603
+ } catch (err) {
1604
+ if (ended) return;
1605
+ ended = true;
1606
+ await opened.restore();
1607
+ reader.releaseLock();
1608
+ controller.error(err);
1609
+ }
1610
+ },
1611
+ async cancel(reason) {
1612
+ ended = true;
1613
+ try {
1614
+ await reader.cancel(reason);
1615
+ } finally {
1616
+ await opened.restore();
1617
+ reader.releaseLock();
1618
+ }
1619
+ }
1620
+ });
1621
+ } catch (err) {
1622
+ await opened.restore();
1623
+ throw err;
1624
+ }
1551
1625
  }
1552
1626
  };
1553
1627
  }
@@ -1562,14 +1636,26 @@ function sandboxFiles(args) {
1562
1636
  if (!listed.length) return;
1563
1637
  const opened = await openRunning(args.getBox, args.resumeTimeoutMs ?? 12e4);
1564
1638
  if (!opened) return;
1565
- const read = opened.box.fs.read;
1566
- if (!read) throw new Error("workspace-export: this sandbox client cannot read files");
1639
+ const reading = /* @__PURE__ */ new Set();
1567
1640
  try {
1641
+ const read = opened.box.fs.read;
1642
+ if (!read) throw new Error("workspace-export: this sandbox client cannot read files");
1568
1643
  for (const file of listed) {
1569
- const text = await read.call(opened.box.fs, file.boxPath);
1570
- yield { path: file.path, open: async () => text };
1644
+ yield {
1645
+ path: file.path,
1646
+ async open() {
1647
+ const pending = read.call(opened.box.fs, file.boxPath);
1648
+ reading.add(pending);
1649
+ try {
1650
+ return await pending;
1651
+ } finally {
1652
+ reading.delete(pending);
1653
+ }
1654
+ }
1655
+ };
1571
1656
  }
1572
1657
  } finally {
1658
+ await Promise.allSettled(reading);
1573
1659
  await opened.restore();
1574
1660
  }
1575
1661
  }