YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
hide ui monitoring on non mac os dtaa table
Louis Beaumontdc59ffcdcca1
diff --git a/pipes/data-table/package.json b/pipes/data-table/package.jsonindex 5c42cff19..cea193714 100644--- a/pipes/data-table/package.json+++ b/pipes/data-table/package.json@@ -1,12 +1,13 @@{"name": "data-table",- "version": "0.1.8",+ "version": "0.1.9","private": true,"scripts": {"dev": "next dev --turbopack","build": "next build --no-lint","start": "next start",- "lint": "next lint"+ "lint": "next lint",+ "publish": "bunx --bun @screenpipe/dev@latest pipe publish --name data-table"},"dependencies": {"@radix-ui/react-accordion": "^1.2.2",diff --git a/pipes/data-table/src/components/database-sidebar.tsx b/pipes/data-table/src/components/database-sidebar.tsxindex 554fe6ded..def6a5e69 100644--- a/pipes/data-table/src/components/database-sidebar.tsx+++ b/pipes/data-table/src/components/database-sidebar.tsx@@ -3,7 +3,7 @@import { Button } from "@/components/ui/button";import { cn } from "@/lib/utils";import { Database } from "lucide-react";-import { JSX } from "react";+import { JSX, useEffect, useState } from "react";interface TableItem {name: string;@@ -11,7 +11,7 @@ interface TableItem {icon: JSX.Element;}-const tables: TableItem[] = [+const allTables: TableItem[] = [{name: "ui_monitoring",displayName: "UI monitoring",@@ -43,6 +43,23 @@ export function DatabaseSidebar({currentTable,onTableSelect,}: DatabaseSidebarProps) {+ const [tables, setTables] = useState<TableItem[]>([]);++ useEffect(() => {+ // detect macos+ const isMacOS =+ navigator.platform.toUpperCase().indexOf("MAC") >= 0 ||+ /Mac/.test(navigator.userAgent);++ // filter tables based on os+ if (isMacOS) {+ setTables(allTables);+ } else {+ // exclude ui_monitoring on non-macos+ setTables(allTables.filter((table) => table.name !== "ui_monitoring"));+ }+ }, []);+return (<div className="pb-12 w-64 border-r"><div className="space-y-4 py-4">diff --git a/screenpipe-js/cli/dist/index.js b/screenpipe-js/cli/dist/index.jsindex 572f8bbd6..818cc3bd5 100755--- a/screenpipe-js/cli/dist/index.js+++ b/screenpipe-js/cli/dist/index.js@@ -664,13 +664,19 @@ async function httpRequest(url2, method, data, headers, onProgress, verbose = faconst contentLength = Buffer.isBuffer(bodyData) ? bodyData.length : Buffer.byteLength(bodyData, "utf8");headers = { ...headers, "Content-Length": contentLength.toString() };if (verbose) {- console.log(colors.dim(`${symbols.arrow} setting content-length: ${contentLength}`));+ console.log(+ colors.dim(`${symbols.arrow} setting content-length: ${contentLength}`)+ );}}for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {try {if (attempt > 1) {- console.log(colors.dim(`${symbols.arrow} retry attempt ${attempt}/${MAX_RETRIES}...`));+ console.log(+ colors.dim(+ `${symbols.arrow} retry attempt ${attempt}/${MAX_RETRIES}...`+ )+ );}const result = await new Promise((resolve, reject) => {const requestOptions = {@@ -681,11 +687,19 @@ async function httpRequest(url2, method, data, headers, onProgress, verbose = faheaders};if (verbose && attempt === 1) {- console.log(colors.dim(`${symbols.arrow} request options: ${JSON.stringify({- method,- url: parsedUrl.toString(),- headers- }, null, 2)}`));+ console.log(+ colors.dim(+ `${symbols.arrow} request options: ${JSON.stringify(+ {+ method,+ url: parsedUrl.toString(),+ headers+ },+ null,+ 2+ )}`+ )+ );}const req = requestModule.request(requestOptions, (res) => {const chunks = [];@@ -710,9 +724,15 @@ async function httpRequest(url2, method, data, headers, onProgress, verbose = faerrorMessage += `: ${responseData.toString("utf8")}`;} else if (contentType.includes("xml")) {const xmlString = responseData.toString("utf8");- console.log(colors.dim(`${symbols.arrow} error response (XML): ${xmlString}`));+ console.log(+ colors.dim(+ `${symbols.arrow} error response (XML): ${xmlString}`+ )+ );const errorCodeMatch = xmlString.match(/<Code>(.*?)<\/Code>/);- const errorMessageMatch = xmlString.match(/<Message>(.*?)<\/Message>/);+ const errorMessageMatch = xmlString.match(+ /<Message>(.*?)<\/Message>/+ );if (errorCodeMatch && errorMessageMatch) {errorMessage += `: ${errorCodeMatch[1]} - ${errorMessageMatch[1]}`;}@@ -737,7 +757,10 @@ async function httpRequest(url2, method, data, headers, onProgress, verbose = faif (Buffer.isBuffer(chunk)) {uploadedBytes += chunk.length;} else if (typeof chunk === "string") {- uploadedBytes += Buffer.byteLength(chunk, encoding);+ uploadedBytes += Buffer.byteLength(+ chunk,+ encoding+ );}onProgress(uploadedBytes, totalBytes);return result2;@@ -751,15 +774,27 @@ async function httpRequest(url2, method, data, headers, onProgress, verbose = fareturn result;} catch (error) {if (error instanceof Error && error.message.includes("400") && (error.message.includes("already exists") || error.message.includes("Version") || error.message.includes("version"))) {- console.log(colors.dim(`${symbols.arrow} detected version conflict, not retrying with same version`));+ console.log(+ colors.dim(+ `${symbols.arrow} detected version conflict, not retrying with same version`+ )+ );throw error;}if (attempt === MAX_RETRIES) {throw error;}- console.log(colors.dim(`${symbols.arrow} request failed (attempt ${attempt}/${MAX_RETRIES}): ${error instanceof Error ? error.message : "unknown error"}`));+ console.log(+ colors.dim(+ `${symbols.arrow} request failed (attempt ${attempt}/${MAX_RETRIES}): ${error instanceof Error ? error.message : "unknown error"}`+ )+ );const delay = INITIAL_DELAY * Math.pow(2, attempt - 1) * (0.5 + Math.random() * 0.5);- console.log(colors.dim(`${symbols.arrow} waiting ${Math.round(delay)}ms before retry...`));+ console.log(+ colors.dim(+ `${symbols.arrow} waiting ${Math.round(delay)}ms before retry...`+ )+ );await new Promise((resolve) => setTimeout(resolve, delay));}}@@ -805,13 +840,15 @@ function bumpVersion(version, type = "patch") {else newVersion = `${major}.${minor}.${patch + 1}`;console.log(colors.dim(`${symbols.arrow} new version: ${newVersion}`));return newVersion;- return `${major}.${minor}.${patch + 1}`;}function updatePackageVersion(newVersion) {const packageJsonPath = path2.join(process.cwd(), "package.json");const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));packageJson.version = newVersion;- fs3.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");+ fs3.writeFileSync(+ packageJsonPath,+ JSON.stringify(packageJson, null, 2) + "\n"+ );}var publishCommand = new Command4("publish").description("publish or update a pipe to the store").requiredOption("-n, --name <name>", "name of the pipe").option("-v, --verbose", "enable verbose logging", false).option("--skip-build-check",@@ -944,7 +981,11 @@ ${symbols.info} publishing ${colors.highlight(}try {console.log(colors.dim(`${symbols.arrow} getting upload URL...`));- console.log(colors.dim(`${symbols.arrow} requesting URL from: ${API_BASE_URL}/api/plugins/publish`));+ console.log(+ colors.dim(+ `${symbols.arrow} requesting URL from: ${API_BASE_URL}/api/plugins/publish`+ )+ );let urlResponse;try {const response = await httpRequest(@@ -966,19 +1007,35 @@ ${symbols.info} publishing ${colors.highlight();urlResponse = { data: JSON.parse(response.data.toString("utf8")) };console.log(colors.dim(`${symbols.arrow} storage provider: S3`));- console.log(colors.dim(`${symbols.arrow} url response status: ${response.statusCode}`));+ console.log(+ colors.dim(+ `${symbols.arrow} url response status: ${response.statusCode}`+ )+ );} catch (error) {- console.log(colors.dim(`${symbols.arrow} server error details: ${error instanceof Error ? error.message : "unknown error"}`));+ console.log(+ colors.dim(+ `${symbols.arrow} server error details: ${error instanceof Error ? error.message : "unknown error"}`+ )+ );if (error instanceof Error && (error.message.includes("already exists") || error.message.includes("Version") || error.message.includes("version"))) {- console.log(colors.dim(`${symbols.arrow} detected version conflict, preparing to bump version`));+ console.log(+ colors.dim(+ `${symbols.arrow} detected version conflict, preparing to bump version`+ )+ );const readline = __require("readline").createInterface({input: process.stdin,output: process.stdout});const newVersion = bumpVersion(packageJson.version);const question = `-${symbols.info} ${colors.info(`Version ${packageJson.version} already exists.`)}-${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/n): `)}`;+${symbols.info} ${colors.info(+ `Version ${packageJson.version} already exists.`+ )}+${colors.info(+ `Would you like to bump to version ${newVersion} and continue? (y/n): `+ )}`;const answer = await new Promise((resolve) => {readline.question(question, (ans) => {readline.close();@@ -987,21 +1044,31 @@ ${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/});if (answer === "y" || answer === "yes") {updatePackageVersion(newVersion);- logger.success(`${symbols.success} Updated package.json to version ${newVersion}`);+ logger.success(+ `${symbols.success} Updated package.json to version ${newVersion}`+ );packageJson.version = newVersion;if (fs3.existsSync(zipPath)) {fs3.unlinkSync(zipPath);if (opts.verbose) {- console.log(colors.dim(`${symbols.arrow} cleaned up old zip file`));+ console.log(+ colors.dim(`${symbols.arrow} cleaned up old zip file`)+ );}}try {- logger.info(colors.info(`-${symbols.info} Rebuilding project with new version ${newVersion}...`));+ logger.info(+ colors.info(+ `+${symbols.info} Rebuilding project with new version ${newVersion}...`+ )+ );runBuildCommand();} catch (error2) {if (error2 instanceof Error) {- console.error(colors.error(`${symbols.error} ${error2.message}`));+ console.error(+ colors.error(`${symbols.error} ${error2.message}`)+ );process.exit(1);}}@@ -1012,7 +1079,11 @@ ${symbols.info} Rebuilding project with new version ${newVersion}...`));const newOutput = fs3.createWriteStream(zipPath);const newArchive = archiver("zip", { zlib: { level: 9 } });newArchive.pipe(newOutput);- logger.log(colors.dim(`${symbols.arrow} creating new package archive with version ${newVersion}...`));+ logger.log(+ colors.dim(+ `${symbols.arrow} creating new package archive with version ${newVersion}...`+ )+ );if (isNextProject) {await archiveNextJsProject(newArchive);} else {@@ -1029,11 +1100,23 @@ ${symbols.info} Rebuilding project with new version ${newVersion}...`));fileHash = newHashSum.digest("hex");fileSize = fs3.statSync(zipPath).size;if (opts.verbose) {- console.log(colors.dim(`${symbols.arrow} new archive created: ${zipPath}`));- console.log(colors.dim(`${symbols.arrow} new file size: ${fileSize} bytes`));- console.log(colors.dim(`${symbols.arrow} new file hash: ${fileHash}`));+ console.log(+ colors.dim(`${symbols.arrow} new archive created: ${zipPath}`)+ );+ console.log(+ colors.dim(+ `${symbols.arrow} new file size: ${fileSize} bytes`+ )+ );+ console.log(+ colors.dim(`${symbols.arrow} new file hash: ${fileHash}`)+ );}- console.log(colors.dim(`${symbols.arrow} retrying with new version: ${newVersion}`));+ console.log(+ colors.dim(+ `${symbols.arrow} retrying with new version: ${newVersion}`+ )+ );const response = await httpRequest(`${API_BASE_URL}/api/plugins/publish`,"POST",@@ -1052,23 +1135,44 @@ ${symbols.info} Rebuilding project with new version ${newVersion}...`));void 0,opts.verbose);- urlResponse = { data: JSON.parse(response.data.toString("utf8")) };+ urlResponse = {+ data: JSON.parse(response.data.toString("utf8"))+ };} else {- throw new Error(`Publishing canceled. Please update the version manually in package.json.`);+ throw new Error(+ `Publishing canceled. Please update the version manually in package.json.`+ );}} else {throw error;}}const { uploadUrl, path: storagePath } = urlResponse.data;- console.log(colors.dim(`${symbols.arrow} received upload URL: ${uploadUrl.substring(0, 50)}...`));- console.log(colors.dim(`${symbols.arrow} storage path: ${storagePath}`));- console.log(colors.dim(`${symbols.arrow} file size: ${fileSize} bytes`));+ console.log(+ colors.dim(+ `${symbols.arrow} received upload URL: ${uploadUrl.substring(+ 0,+ 50+ )}...`+ )+ );+ console.log(+ colors.dim(`${symbols.arrow} storage path: ${storagePath}`)+ );+ console.log(+ colors.dim(`${symbols.arrow} file size: ${fileSize} bytes`)+ );let currentUploadUrl = uploadUrl;let currentStoragePath = storagePath;logger.log(colors.dim(`${symbols.arrow} uploading to storage...`));- console.log(colors.dim(`${symbols.arrow} starting upload with native http...`));- console.log(colors.dim(`${symbols.arrow} upload file size: ${(fileSize / (1024 * 1024)).toFixed(2)} MB`));+ console.log(+ colors.dim(`${symbols.arrow} starting upload with native http...`)+ );+ console.log(+ colors.dim(+ `${symbols.arrow} upload file size: ${(fileSize / (1024 * 1024)).toFixed(2)} MB`+ )+ );const progressBar = {current: 0,total: fileSize,@@ -1084,7 +1188,11 @@ ${symbols.info} Rebuilding project with new version ${newVersion}...`));const loadedSize = (loaded / (1024 * 1024)).toFixed(2);const totalSize = (total / (1024 * 1024)).toFixed(2);process.stdout.write(- `${colors.dim(`${symbols.arrow} uploading: [`)}${colors.info(bar)}${colors.dim(`] ${percent}%`)} ${colors.dim(`(${loadedSize}/${totalSize} MB)`)}`+ `${colors.dim(`${symbols.arrow} uploading: [`)}${colors.info(+ bar+ )}${colors.dim(`] ${percent}%`)} ${colors.dim(+ `(${loadedSize}/${totalSize} MB)`+ )}`);}},@@ -1105,11 +1213,23 @@ ${symbols.info} Rebuilding project with new version ${newVersion}...`));opts.verbose);progressBar.complete();- console.log(colors.dim(`${symbols.arrow} upload completed with status: ${uploadResponse.statusCode}`));- console.log(colors.dim(`${symbols.arrow} waiting for S3 to process the upload...`));+ console.log(+ colors.dim(+ `${symbols.arrow} upload completed with status: ${uploadResponse.statusCode}`+ )+ );+ console.log(+ colors.dim(`${symbols.arrow} waiting for S3 to process the upload...`)+ );await new Promise((resolve) => setTimeout(resolve, 5e3));- logger.log(colors.dim(`${symbols.arrow} finalizing upload with S3 storage...`));- console.log(colors.dim(`${symbols.arrow} sending finalize request to: ${API_BASE_URL}/api/plugins/publish/finalize`));+ logger.log(+ colors.dim(`${symbols.arrow} finalizing upload with S3 storage...`)+ );+ console.log(+ colors.dim(+ `${symbols.arrow} sending finalize request to: ${API_BASE_URL}/api/plugins/publish/finalize`+ )+ );const finalizeResponse = await httpRequest(`${API_BASE_URL}/api/plugins/publish/finalize`,"POST",@@ -1128,9 +1248,19 @@ ${symbols.info} Rebuilding project with new version ${newVersion}...`));void 0,opts.verbose);- console.log(colors.dim(`${symbols.arrow} finalize response status: ${finalizeResponse.statusCode}`));+ console.log(+ colors.dim(+ `${symbols.arrow} finalize response status: ${finalizeResponse.statusCode}`+ )+ );const finalizeData = JSON.parse(finalizeResponse.data.toString("utf8"));- console.log(colors.dim(`${symbols.arrow} finalize response data: ${JSON.stringify(finalizeData)}`));+ console.log(+ colors.dim(+ `${symbols.arrow} finalize response data: ${JSON.stringify(+ finalizeData+ )}`+ )+ );logger.success(`${symbols.success} successfully published plugin!`);console.log(@@ -1148,12 +1278,38 @@ ${symbols.success} successfully published plugin!`);logger.info(`${symbols.info} ${finalizeData.message}`);}+ if (fs3.existsSync(zipPath)) {+ if (opts.verbose) {+ console.log(+ colors.dim(`${symbols.arrow} cleaning up zip file: ${zipPath}`)+ );+ }+ fs3.unlinkSync(zipPath);+ }} catch (error) {- console.error(colors.error(`${symbols.error} ${error instanceof Error ? error.message : "unknown error"}`));+ console.error(+ colors.error(+ `${symbols.error} ${error instanceof Error ? error.message : "unknown error"}`+ )+ );+ if (zipPath && fs3.existsSync(zipPath)) {+ if (opts.verbose) {+ console.log(+ colors.dim(+ `${symbols.arrow} cleaning up zip file after error: ${zipPath}`+ )+ );+ }+ fs3.unlinkSync(zipPath);+ }process.exit(1);}} catch (error) {- console.error(colors.error(`${symbols.error} ${error instanceof Error ? error.message : "unknown error"}`));+ console.error(+ colors.error(+ `${symbols.error} ${error instanceof Error ? error.message : "unknown error"}`+ )+ );process.exit(1);}});diff --git a/screenpipe-js/cli/package.json b/screenpipe-js/cli/package.jsonindex f677d261f..02cc58069 100644--- a/screenpipe-js/cli/package.json+++ b/screenpipe-js/cli/package.json@@ -1,6 +1,6 @@{"name": "@screenpipe/dev",- "version": "1.2.1",+ "version": "1.2.2","description": "screenpipe development CLI","type": "module","main": "dist/index.js",diff --git a/screenpipe-js/cli/src/commands/pipe/publish.ts b/screenpipe-js/cli/src/commands/pipe/publish.tsindex 2fde0c185..aa220a708 100644--- a/screenpipe-js/cli/src/commands/pipe/publish.ts+++ b/screenpipe-js/cli/src/commands/pipe/publish.ts@@ -8,10 +8,10 @@ import ignore from "ignore";import { colors, symbols } from "../../utils/colors";import { Command } from "commander";import { logger } from "../components/commands/add/utils/logger";-import http from 'http';-import https from 'https';-import { URL } from 'url';-import { execSync } from 'child_process';+import http from "http";+import https from "https";+import { URL } from "url";+import { execSync } from "child_process";interface ProjectFiles {required: string[];@@ -75,171 +75,229 @@ function archiveStandardProject(// Add this function for HTTP requests with retry logicasync function httpRequest(- url: string,- method: string,- data?: Buffer | string | object,- headers?: Record<string, string>,+ url: string,+ method: string,+ data?: Buffer | string | object,+ headers?: Record<string, string>,onProgress?: (loaded: number, total: number) => void,verbose: boolean = false-): Promise<{ statusCode: number, headers: http.IncomingHttpHeaders, data: Buffer }> {+): Promise<{+ statusCode: number;+ headers: http.IncomingHttpHeaders;+ data: Buffer;+}> {const MAX_RETRIES = 10;const INITIAL_DELAY = 1000; // 1 second-+const parsedUrl = new URL(url);- const isHttps = parsedUrl.protocol === 'https:';+ const isHttps = parsedUrl.protocol === "https:";const requestModule = isHttps ? https : http;-+// Convert object data to JSON string if neededlet bodyData: Buffer | string | undefined = data as Buffer | string;- if (data && typeof data === 'object' && !(data instanceof Buffer)) {+ if (data && typeof data === "object" && !(data instanceof Buffer)) {bodyData = JSON.stringify(data);- headers = { ...headers, 'Content-Type': 'application/json' };+ headers = { ...headers, "Content-Type": "application/json" };}-+// Set content length if we have body dataif (bodyData) {- const contentLength = Buffer.isBuffer(bodyData)- ? bodyData.length- : Buffer.byteLength(bodyData, 'utf8');- headers = { ...headers, 'Content-Length': contentLength.toString() };-+ const contentLength = Buffer.isBuffer(bodyData)+ ? bodyData.length+ : Buffer.byteLength(bodyData, "utf8");+ headers = { ...headers, "Content-Length": contentLength.toString() };+if (verbose) {- console.log(colors.dim(`${symbols.arrow} setting content-length: ${contentLength}`));+ console.log(+ colors.dim(`${symbols.arrow} setting content-length: ${contentLength}`)+ );}}-+for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {try {if (attempt > 1) {- console.log(colors.dim(`${symbols.arrow} retry attempt ${attempt}/${MAX_RETRIES}...`));+ console.log(+ colors.dim(+ `${symbols.arrow} retry attempt ${attempt}/${MAX_RETRIES}...`+ )+ );}-- const result = await new Promise<{ statusCode: number, headers: http.IncomingHttpHeaders, data: Buffer }>((resolve, reject) => {++ const result = await new Promise<{+ statusCode: number;+ headers: http.IncomingHttpHeaders;+ data: Buffer;+ }>((resolve, reject) => {const requestOptions = {method,hostname: parsedUrl.hostname,port: parsedUrl.port || (isHttps ? 443 : 80),path: parsedUrl.pathname + parsedUrl.search,- headers+ headers,};-+if (verbose && attempt === 1) {- console.log(colors.dim(`${symbols.arrow} request options: ${JSON.stringify({- method,- url: parsedUrl.toString(),- headers- }, null, 2)}`));+ console.log(+ colors.dim(+ `${symbols.arrow} request options: ${JSON.stringify(+ {+ method,+ url: parsedUrl.toString(),+ headers,+ },+ null,+ 2+ )}`+ )+ );}-+const req = requestModule.request(requestOptions, (res) => {const chunks: Buffer[] = [];let receivedLength = 0;-- res.on('data', (chunk) => {++ res.on("data", (chunk) => {chunks.push(chunk);receivedLength += chunk.length;});-- res.on('end', () => {++ res.on("end", () => {const responseData = Buffer.concat(chunks);-- if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {++ if (+ res.statusCode &&+ res.statusCode >= 200 &&+ res.statusCode < 300+ ) {resolve({statusCode: res.statusCode,headers: res.headers,- data: responseData+ data: responseData,});} else {// Log error response detailslet errorMessage = `HTTP error ${res.statusCode}`;try {- const contentType = res.headers['content-type'] || '';- if (contentType.includes('json')) {- errorMessage += `: ${responseData.toString('utf8')}`;- } else if (contentType.includes('xml')) {- const xmlString = responseData.toString('utf8');- console.log(colors.dim(`${symbols.arrow} error response (XML): ${xmlString}`));-+ const contentType = res.headers["content-type"] || "";+ if (contentType.includes("json")) {+ errorMessage += `: ${responseData.toString("utf8")}`;+ } else if (contentType.includes("xml")) {+ const xmlString = responseData.toString("utf8");+ console.log(+ colors.dim(+ `${symbols.arrow} error response (XML): ${xmlString}`+ )+ );+// Extract error details from XMLconst errorCodeMatch = xmlString.match(/<Code>(.*?)<\/Code>/);- const errorMessageMatch = xmlString.match(/<Message>(.*?)<\/Message>/);-+ const errorMessageMatch = xmlString.match(+ /<Message>(.*?)<\/Message>/+ );+if (errorCodeMatch && errorMessageMatch) {errorMessage += `: ${errorCodeMatch[1]} - ${errorMessageMatch[1]}`;}- } else if (contentType.includes('text')) {- errorMessage += `: ${responseData.toString('utf8')}`;+ } else if (contentType.includes("text")) {+ errorMessage += `: ${responseData.toString("utf8")}`;}} catch (e) {// Ignore parsing errors}-+reject(new Error(errorMessage));}});});-- req.on('error', (error) => {++ req.on("error", (error) => {reject(error);});-+// Track upload progress if callback provided- if (onProgress && method === 'PUT' && bodyData) {+ if (onProgress && method === "PUT" && bodyData) {let uploadedBytes = 0;- const totalBytes = Buffer.isBuffer(bodyData)- ? bodyData.length- : Buffer.byteLength(bodyData, 'utf8');-+ const totalBytes = Buffer.isBuffer(bodyData)+ ? bodyData.length+ : Buffer.byteLength(bodyData, "utf8");+const originalWrite = req.write;- req.write = function(chunk: any, encoding?: BufferEncoding, callback?: (error: Error | null | undefined) => void) {+ req.write = function (+ chunk: any,+ encoding?: BufferEncoding,+ callback?: (error: Error | null | undefined) => void+ ) {const result = originalWrite.call(this, chunk, encoding, callback);-+if (Buffer.isBuffer(chunk)) {uploadedBytes += chunk.length;- } else if (typeof chunk === 'string') {- uploadedBytes += Buffer.byteLength(chunk, encoding as BufferEncoding);+ } else if (typeof chunk === "string") {+ uploadedBytes += Buffer.byteLength(+ chunk,+ encoding as BufferEncoding+ );}-+onProgress(uploadedBytes, totalBytes);return result;};}-+// Send the body dataif (bodyData) {req.write(bodyData);}-+req.end();});-+return result;} catch (error) {// Don't retry version conflicts - they won't resolve without version change- if (error instanceof Error &&- error.message.includes('400') &&- (error.message.includes('already exists') ||- error.message.includes('Version') ||- error.message.includes('version'))) {- console.log(colors.dim(`${symbols.arrow} detected version conflict, not retrying with same version`));+ if (+ error instanceof Error &&+ error.message.includes("400") &&+ (error.message.includes("already exists") ||+ error.message.includes("Version") ||+ error.message.includes("version"))+ ) {+ console.log(+ colors.dim(+ `${symbols.arrow} detected version conflict, not retrying with same version`+ )+ );throw error; // Immediately throw to handle at higher level}-+if (attempt === MAX_RETRIES) {throw error;}-+// Log the error- console.log(colors.dim(`${symbols.arrow} request failed (attempt ${attempt}/${MAX_RETRIES}): ${error instanceof Error ? error.message : 'unknown error'}`));-+ console.log(+ colors.dim(+ `${+ symbols.arrow+ } request failed (attempt ${attempt}/${MAX_RETRIES}): ${+ error instanceof Error ? error.message : "unknown error"+ }`+ )+ );+// Exponential backoff with jitter- const delay = INITIAL_DELAY * Math.pow(2, attempt - 1) * (0.5 + Math.random() * 0.5);- console.log(colors.dim(`${symbols.arrow} waiting ${Math.round(delay)}ms before retry...`));- await new Promise(resolve => setTimeout(resolve, delay));+ const delay =+ INITIAL_DELAY * Math.pow(2, attempt - 1) * (0.5 + Math.random() * 0.5);+ console.log(+ colors.dim(+ `${symbols.arrow} waiting ${Math.round(delay)}ms before retry...`+ )+ );+ await new Promise((resolve) => setTimeout(resolve, delay));}}-- throw new Error('Max retries exceeded'); // Should never reach here due to throw in the loop++ throw new Error("Max retries exceeded"); // Should never reach here due to throw in the loop}function runBuildCommand(): void {@@ -278,27 +336,32 @@ function runBuildCommand(): void {}// Add this function to bump semver version-function bumpVersion(version: string, type: 'patch' | 'minor' | 'major' = 'patch'): string {+function bumpVersion(+ version: string,+ type: "patch" | "minor" | "major" = "patch"+): string {console.log(colors.dim(`${symbols.arrow} bumping version from ${version}`));- const [major, minor, patch] = version.split('.').map(Number);-+ const [major, minor, patch] = version.split(".").map(Number);+let newVersion: string;- if (type === 'patch') newVersion = `${major}.${minor}.${patch + 1}`;- else if (type === 'minor') newVersion = `${major}.${minor + 1}.0`;- else if (type === 'major') newVersion = `${major + 1}.0.0`;+ if (type === "patch") newVersion = `${major}.${minor}.${patch + 1}`;+ else if (type === "minor") newVersion = `${major}.${minor + 1}.0`;+ else if (type === "major") newVersion = `${major + 1}.0.0`;else newVersion = `${major}.${minor}.${patch + 1}`; // Default to patch-+console.log(colors.dim(`${symbols.arrow} new version: ${newVersion}`));return newVersion;- return `${major}.${minor}.${patch + 1}`; // Default to patch}// Add this function to update package.jsonfunction updatePackageVersion(newVersion: string): void {- const packageJsonPath = path.join(process.cwd(), 'package.json');- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));+ const packageJsonPath = path.join(process.cwd(), "package.json");+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));packageJson.version = newVersion;- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');+ fs.writeFileSync(+ packageJsonPath,+ JSON.stringify(packageJson, null, 2) + "\n"+ );}export const publishCommand = new Command("publish")@@ -471,13 +534,17 @@ export const publishCommand = new Command("publish")try {// First get the signed URLconsole.log(colors.dim(`${symbols.arrow} getting upload URL...`));- console.log(colors.dim(`${symbols.arrow} requesting URL from: ${API_BASE_URL}/api/plugins/publish`));+ console.log(+ colors.dim(+ `${symbols.arrow} requesting URL from: ${API_BASE_URL}/api/plugins/publish`+ )+ );let urlResponse;try {const response = await httpRequest(`${API_BASE_URL}/api/plugins/publish`,- 'POST',+ "POST",{name: opts.name,version: packageJson.version,@@ -492,68 +559,97 @@ export const publishCommand = new Command("publish")},opts.verbose);-- urlResponse = { data: JSON.parse(response.data.toString('utf8')) };++ urlResponse = { data: JSON.parse(response.data.toString("utf8")) };console.log(colors.dim(`${symbols.arrow} storage provider: S3`));- console.log(colors.dim(`${symbols.arrow} url response status: ${response.statusCode}`));+ console.log(+ colors.dim(+ `${symbols.arrow} url response status: ${response.statusCode}`+ )+ );} catch (error) {// Handle version conflict specifically- console.log(colors.dim(`${symbols.arrow} server error details: ${error instanceof Error ? error.message : 'unknown error'}`));-+ console.log(+ colors.dim(+ `${symbols.arrow} server error details: ${+ error instanceof Error ? error.message : "unknown error"+ }`+ )+ );+// Check if this is a version conflict error- if (error instanceof Error &&- (error.message.includes('already exists') ||- error.message.includes('Version') ||- error.message.includes('version'))) {-+ if (+ error instanceof Error &&+ (error.message.includes("already exists") ||+ error.message.includes("Version") ||+ error.message.includes("version"))+ ) {// Log the detected version conflict- console.log(colors.dim(`${symbols.arrow} detected version conflict, preparing to bump version`));-+ console.log(+ colors.dim(+ `${symbols.arrow} detected version conflict, preparing to bump version`+ )+ );+// Ask user if they want to bump the version- const readline = require('readline').createInterface({+ const readline = require("readline").createInterface({input: process.stdin,- output: process.stdout+ output: process.stdout,});-+const newVersion = bumpVersion(packageJson.version);-- const question = `\n${symbols.info} ${colors.info(`Version ${packageJson.version} already exists.`)}-${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/n): `)}`;-- const answer = await new Promise<string>(resolve => {++ const question = `\n${symbols.info} ${colors.info(+ `Version ${packageJson.version} already exists.`+ )}+${colors.info(+ `Would you like to bump to version ${newVersion} and continue? (y/n): `+)}`;++ const answer = await new Promise<string>((resolve) => {readline.question(question, (ans: string) => {readline.close();resolve(ans.toLowerCase());});});-- if (answer === 'y' || answer === 'yes') {++ if (answer === "y" || answer === "yes") {// Update package.json with new versionupdatePackageVersion(newVersion);- logger.success(`${symbols.success} Updated package.json to version ${newVersion}`);-+ logger.success(+ `${symbols.success} Updated package.json to version ${newVersion}`+ );+// Update packageJson in memorypackageJson.version = newVersion;-+// Clean up the old zip fileif (fs.existsSync(zipPath)) {fs.unlinkSync(zipPath);if (opts.verbose) {- console.log(colors.dim(`${symbols.arrow} cleaned up old zip file`));+ console.log(+ colors.dim(`${symbols.arrow} cleaned up old zip file`)+ );}}-+// Rebuild the project with the new versiontry {- logger.info(colors.info(`\n${symbols.info} Rebuilding project with new version ${newVersion}...`));+ logger.info(+ colors.info(+ `\n${symbols.info} Rebuilding project with new version ${newVersion}...`+ )+ );runBuildCommand();} catch (error) {if (error instanceof Error) {- console.error(colors.error(`${symbols.error} ${error.message}`));+ console.error(+ colors.error(`${symbols.error} ${error.message}`)+ );process.exit(1);}}-+// Create a new zip file with the updated versionzipPath = path.join(process.cwd(),@@ -561,42 +657,58 @@ ${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/);const newOutput = fs.createWriteStream(zipPath);const newArchive = archiver("zip", { zlib: { level: 9 } });-+newArchive.pipe(newOutput);-- logger.log(colors.dim(`${symbols.arrow} creating new package archive with version ${newVersion}...`));-++ logger.log(+ colors.dim(+ `${symbols.arrow} creating new package archive with version ${newVersion}...`+ )+ );+// Archive the project againif (isNextProject) {await archiveNextJsProject(newArchive);} else {archiveStandardProject(newArchive, ig);}-+await new Promise((resolve, reject) => {newOutput.on("close", resolve);newArchive.on("error", reject);newArchive.finalize();});-+// Recalculate file hash and sizefileBuffer = fs.readFileSync(zipPath);const newHashSum = crypto.createHash("sha256");newHashSum.update(fileBuffer);fileHash = newHashSum.digest("hex");fileSize = fs.statSync(zipPath).size;-+if (opts.verbose) {- console.log(colors.dim(`${symbols.arrow} new archive created: ${zipPath}`));- console.log(colors.dim(`${symbols.arrow} new file size: ${fileSize} bytes`));- console.log(colors.dim(`${symbols.arrow} new file hash: ${fileHash}`));+ console.log(+ colors.dim(`${symbols.arrow} new archive created: ${zipPath}`)+ );+ console.log(+ colors.dim(+ `${symbols.arrow} new file size: ${fileSize} bytes`+ )+ );+ console.log(+ colors.dim(`${symbols.arrow} new file hash: ${fileHash}`)+ );}-+// Retry the request with new version- console.log(colors.dim(`${symbols.arrow} retrying with new version: ${newVersion}`));+ console.log(+ colors.dim(+ `${symbols.arrow} retrying with new version: ${newVersion}`+ )+ );const response = await httpRequest(`${API_BASE_URL}/api/plugins/publish`,- 'POST',+ "POST",{name: opts.name,version: newVersion,@@ -612,11 +724,15 @@ ${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/undefined,opts.verbose);-- urlResponse = { data: JSON.parse(response.data.toString('utf8')) };++ urlResponse = {+ data: JSON.parse(response.data.toString("utf8")),+ };} else {// User chose not to bump version- throw new Error(`Publishing canceled. Please update the version manually in package.json.`);+ throw new Error(+ `Publishing canceled. Please update the version manually in package.json.`+ );}} else {// Handle other errors@@ -626,9 +742,20 @@ ${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/// Get the upload URL and storage path from the responseconst { uploadUrl, path: storagePath } = urlResponse.data;- console.log(colors.dim(`${symbols.arrow} received upload URL: ${uploadUrl.substring(0, 50)}...`));- console.log(colors.dim(`${symbols.arrow} storage path: ${storagePath}`));- console.log(colors.dim(`${symbols.arrow} file size: ${fileSize} bytes`));+ console.log(+ colors.dim(+ `${symbols.arrow} received upload URL: ${uploadUrl.substring(+ 0,+ 50+ )}...`+ )+ );+ console.log(+ colors.dim(`${symbols.arrow} storage path: ${storagePath}`)+ );+ console.log(+ colors.dim(`${symbols.arrow} file size: ${fileSize} bytes`)+ );// Create variables that can be reassigned during retrylet currentUploadUrl = uploadUrl;@@ -636,9 +763,18 @@ ${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/// Upload directly to S3logger.log(colors.dim(`${symbols.arrow} uploading to storage...`));- console.log(colors.dim(`${symbols.arrow} starting upload with native http...`));- console.log(colors.dim(`${symbols.arrow} upload file size: ${(fileSize / (1024 * 1024)).toFixed(2)} MB`));-+ console.log(+ colors.dim(`${symbols.arrow} starting upload with native http...`)+ );+ console.log(+ colors.dim(+ `${symbols.arrow} upload file size: ${(+ fileSize /+ (1024 * 1024)+ ).toFixed(2)} MB`+ )+ );+// Create a progress barconst progressBar = {current: 0,@@ -648,38 +784,42 @@ ${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/const percent = Math.floor((loaded / total) * 100);const filledWidth = Math.floor((loaded / total) * this.width);const emptyWidth = this.width - filledWidth;-+// Only update if progress has changed by at least 1%if (percent > this.current) {this.current = percent;-+// Clear the current line and move to beginning- process.stdout.write('\r');-+ process.stdout.write("\r");+// Create the progress bar- const bar = '█'.repeat(filledWidth) + '░'.repeat(emptyWidth);-+ const bar = "█".repeat(filledWidth) + "░".repeat(emptyWidth);+// Format the size displayconst loadedSize = (loaded / (1024 * 1024)).toFixed(2);const totalSize = (total / (1024 * 1024)).toFixed(2);-+// Print the progress barprocess.stdout.write(- `${colors.dim(`${symbols.arrow} uploading: [`)}${colors.info(bar)}${colors.dim(`] ${percent}%`)} ${colors.dim(`(${loadedSize}/${totalSize} MB)`)}`+ `${colors.dim(`${symbols.arrow} uploading: [`)}${colors.info(+ bar+ )}${colors.dim(`] ${percent}%`)} ${colors.dim(+ `(${loadedSize}/${totalSize} MB)`+ )}`);}},complete() {// Move to next line after completion- process.stdout.write('\n');+ process.stdout.write("\n");logger.success(`${symbols.success} upload completed successfully`);- }+ },};-+// Upload the file with retry logicconst uploadResponse = await httpRequest(currentUploadUrl,- 'PUT',+ "PUT",fileBuffer,{"Content-Type": "application/zip",@@ -688,21 +828,33 @@ ${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/(loaded, total) => progressBar.update(loaded, total),opts.verbose);-+progressBar.complete();- console.log(colors.dim(`${symbols.arrow} upload completed with status: ${uploadResponse.statusCode}`));-+ console.log(+ colors.dim(+ `${symbols.arrow} upload completed with status: ${uploadResponse.statusCode}`+ )+ );+// Add a delay after upload to ensure S3 has processed the file- console.log(colors.dim(`${symbols.arrow} waiting for S3 to process the upload...`));- await new Promise(resolve => setTimeout(resolve, 5000)); // 5 second delay-+ console.log(+ colors.dim(`${symbols.arrow} waiting for S3 to process the upload...`)+ );+ await new Promise((resolve) => setTimeout(resolve, 5000)); // 5 second delay+// Notify server that upload is complete- logger.log(colors.dim(`${symbols.arrow} finalizing upload with S3 storage...`));- console.log(colors.dim(`${symbols.arrow} sending finalize request to: ${API_BASE_URL}/api/plugins/publish/finalize`));-+ logger.log(+ colors.dim(`${symbols.arrow} finalizing upload with S3 storage...`)+ );+ console.log(+ colors.dim(+ `${symbols.arrow} sending finalize request to: ${API_BASE_URL}/api/plugins/publish/finalize`+ )+ );+const finalizeResponse = await httpRequest(`${API_BASE_URL}/api/plugins/publish/finalize`,- 'POST',+ "POST",{name: opts.name,version: packageJson.version,@@ -719,10 +871,20 @@ ${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/opts.verbose);- console.log(colors.dim(`${symbols.arrow} finalize response status: ${finalizeResponse.statusCode}`));-- const finalizeData = JSON.parse(finalizeResponse.data.toString('utf8'));- console.log(colors.dim(`${symbols.arrow} finalize response data: ${JSON.stringify(finalizeData)}`));+ console.log(+ colors.dim(+ `${symbols.arrow} finalize response status: ${finalizeResponse.statusCode}`+ )+ );++ const finalizeData = JSON.parse(finalizeResponse.data.toString("utf8"));+ console.log(+ colors.dim(+ `${symbols.arrow} finalize response data: ${JSON.stringify(+ finalizeData+ )}`+ )+ );// Success messageslogger.success(`\n${symbols.success} successfully published plugin!`);@@ -742,12 +904,47 @@ ${colors.info(`Would you like to bump to version ${newVersion} and continue? (y/if (finalizeData.message) {logger.info(`\n${symbols.info} ${finalizeData.message}`);}++ // Clean up the zip file after successful publish+ if (fs.existsSync(zipPath)) {+ if (opts.verbose) {+ console.log(+ colors.dim(`${symbols.arrow} cleaning up zip file: ${zipPath}`)+ );+ }+ fs.unlinkSync(zipPath);+ }} catch (error) {- console.error(colors.error(`${symbols.error} ${error instanceof Error ? error.message : 'unknown error'}`));+ console.error(+ colors.error(+ `${symbols.error} ${+ error instanceof Error ? error.message : "unknown error"+ }`+ )+ );++ // Clean up the zip file on error+ if (zipPath && fs.existsSync(zipPath)) {+ if (opts.verbose) {+ console.log(+ colors.dim(+ `${symbols.arrow} cleaning up zip file after error: ${zipPath}`+ )+ );+ }+ fs.unlinkSync(zipPath);+ }process.exit(1);}} catch (error) {- console.error(colors.error(`${symbols.error} ${error instanceof Error ? error.message : 'unknown error'}`));+ console.error(+ colors.error(+ `${symbols.error} ${+ error instanceof Error ? error.message : "unknown error"+ }`+ )+ );+process.exit(1);}- });\ No newline at end of file+ });