computesdk 1.12.0 → 1.13.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/dist/index.mjs CHANGED
@@ -1845,6 +1845,87 @@ var Child = class {
1845
1845
  }
1846
1846
  };
1847
1847
 
1848
+ // src/client/resources/overlay.ts
1849
+ var Overlay = class {
1850
+ constructor(handlers) {
1851
+ this.createHandler = handlers.create;
1852
+ this.listHandler = handlers.list;
1853
+ this.retrieveHandler = handlers.retrieve;
1854
+ this.destroyHandler = handlers.destroy;
1855
+ }
1856
+ /**
1857
+ * Create a new overlay from a template directory
1858
+ *
1859
+ * The overlay symlinks files from the source directory into the target path,
1860
+ * allowing instant access to template files. Heavy directories (node_modules,
1861
+ * .venv, etc.) are copied in the background.
1862
+ *
1863
+ * @param options - Overlay creation options
1864
+ * @param options.source - Absolute path to source directory
1865
+ * @param options.target - Relative path in sandbox
1866
+ * @returns Overlay info with copy status
1867
+ */
1868
+ async create(options) {
1869
+ const response = await this.createHandler(options);
1870
+ return this.toOverlayInfo(response);
1871
+ }
1872
+ /**
1873
+ * List all overlays for the current sandbox
1874
+ * @returns Array of overlay info
1875
+ */
1876
+ async list() {
1877
+ const response = await this.listHandler();
1878
+ return response.overlays.map((o) => this.toOverlayInfo(o));
1879
+ }
1880
+ /**
1881
+ * Retrieve a specific overlay by ID
1882
+ *
1883
+ * Useful for polling the copy status of an overlay.
1884
+ *
1885
+ * @param id - Overlay ID
1886
+ * @returns Overlay info
1887
+ */
1888
+ async retrieve(id) {
1889
+ const response = await this.retrieveHandler(id);
1890
+ return this.toOverlayInfo(response);
1891
+ }
1892
+ /**
1893
+ * Destroy (delete) an overlay
1894
+ * @param id - Overlay ID
1895
+ */
1896
+ async destroy(id) {
1897
+ return this.destroyHandler(id);
1898
+ }
1899
+ /**
1900
+ * Convert API response to OverlayInfo
1901
+ */
1902
+ toOverlayInfo(response) {
1903
+ return {
1904
+ id: response.id,
1905
+ source: response.source,
1906
+ target: response.target,
1907
+ createdAt: response.created_at,
1908
+ stats: {
1909
+ symlinkedFiles: response.stats.symlinked_files,
1910
+ symlinkedDirs: response.stats.symlinked_dirs,
1911
+ skipped: response.stats.skipped
1912
+ },
1913
+ copyStatus: this.validateCopyStatus(response.copy_status),
1914
+ copyError: response.copy_error
1915
+ };
1916
+ }
1917
+ /**
1918
+ * Validate and return copy status, defaulting to 'pending' for unknown values
1919
+ */
1920
+ validateCopyStatus(status) {
1921
+ const validStatuses = ["pending", "in_progress", "complete", "failed"];
1922
+ if (validStatuses.includes(status)) {
1923
+ return status;
1924
+ }
1925
+ return "pending";
1926
+ }
1927
+ };
1928
+
1848
1929
  // src/client/types.ts
1849
1930
  var CommandExitError = class extends Error {
1850
1931
  constructor(result) {
@@ -1939,7 +2020,13 @@ var Sandbox = class {
1939
2020
  },
1940
2021
  remove: async (path) => {
1941
2022
  await this.deleteFile(path);
1942
- }
2023
+ },
2024
+ overlay: new Overlay({
2025
+ create: async (options) => this.createOverlay(options),
2026
+ list: async () => this.listOverlays(),
2027
+ retrieve: async (id) => this.getOverlay(id),
2028
+ destroy: async (id) => this.deleteOverlay(id)
2029
+ })
1943
2030
  };
1944
2031
  this.terminal = new Terminal({
1945
2032
  create: async (options) => this.createTerminal(options),
@@ -2424,6 +2511,63 @@ API request failed (${response.status}): ${error}`
2424
2511
  });
2425
2512
  }
2426
2513
  // ============================================================================
2514
+ // Filesystem Overlays
2515
+ // ============================================================================
2516
+ /**
2517
+ * Create a new filesystem overlay from a template directory
2518
+ *
2519
+ * Overlays enable instant sandbox setup by symlinking template files first,
2520
+ * then copying heavy directories (node_modules, .venv, etc.) in the background.
2521
+ *
2522
+ * @param options - Overlay creation options
2523
+ * @param options.source - Absolute path to source directory (template)
2524
+ * @param options.target - Relative path in sandbox where overlay will be mounted
2525
+ * @returns Overlay response with copy status
2526
+ *
2527
+ * @example
2528
+ * ```typescript
2529
+ * // Prefer using sandbox.filesystem.overlay.create() for camelCase response
2530
+ * const overlay = await sandbox.filesystem.overlay.create({
2531
+ * source: '/templates/nextjs',
2532
+ * target: 'project',
2533
+ * });
2534
+ * console.log(overlay.copyStatus); // 'pending' | 'in_progress' | 'complete' | 'failed'
2535
+ * ```
2536
+ */
2537
+ async createOverlay(options) {
2538
+ return this.request("/filesystem/overlays", {
2539
+ method: "POST",
2540
+ body: JSON.stringify(options)
2541
+ });
2542
+ }
2543
+ /**
2544
+ * List all filesystem overlays for the current sandbox
2545
+ * @returns List of overlays with their copy status
2546
+ */
2547
+ async listOverlays() {
2548
+ return this.request("/filesystem/overlays");
2549
+ }
2550
+ /**
2551
+ * Get a specific filesystem overlay by ID
2552
+ *
2553
+ * Useful for polling the copy status of an overlay.
2554
+ *
2555
+ * @param id - Overlay ID
2556
+ * @returns Overlay details with current copy status
2557
+ */
2558
+ async getOverlay(id) {
2559
+ return this.request(`/filesystem/overlays/${id}`);
2560
+ }
2561
+ /**
2562
+ * Delete a filesystem overlay
2563
+ * @param id - Overlay ID
2564
+ */
2565
+ async deleteOverlay(id) {
2566
+ return this.request(`/filesystem/overlays/${id}`, {
2567
+ method: "DELETE"
2568
+ });
2569
+ }
2570
+ // ============================================================================
2427
2571
  // Terminal Management
2428
2572
  // ============================================================================
2429
2573
  /**