@agent-foundry/studio 1.0.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.
Files changed (88) hide show
  1. package/README.md +96 -0
  2. package/dist/db/client.d.ts +59 -0
  3. package/dist/db/client.d.ts.map +1 -0
  4. package/dist/db/client.js +51 -0
  5. package/dist/db/client.js.map +1 -0
  6. package/dist/db/deployments.d.ts +65 -0
  7. package/dist/db/deployments.d.ts.map +1 -0
  8. package/dist/db/deployments.js +249 -0
  9. package/dist/db/deployments.js.map +1 -0
  10. package/dist/db/index.d.ts +7 -0
  11. package/dist/db/index.d.ts.map +1 -0
  12. package/dist/db/index.js +7 -0
  13. package/dist/db/index.js.map +1 -0
  14. package/dist/db/projects.d.ts +48 -0
  15. package/dist/db/projects.d.ts.map +1 -0
  16. package/dist/db/projects.js +192 -0
  17. package/dist/db/projects.js.map +1 -0
  18. package/dist/index.d.ts +11 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +15 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/oss/client.d.ts +65 -0
  23. package/dist/oss/client.d.ts.map +1 -0
  24. package/dist/oss/client.js +146 -0
  25. package/dist/oss/client.js.map +1 -0
  26. package/dist/oss/index.d.ts +7 -0
  27. package/dist/oss/index.d.ts.map +1 -0
  28. package/dist/oss/index.js +7 -0
  29. package/dist/oss/index.js.map +1 -0
  30. package/dist/oss/types.d.ts +96 -0
  31. package/dist/oss/types.d.ts.map +1 -0
  32. package/dist/oss/types.js +5 -0
  33. package/dist/oss/types.js.map +1 -0
  34. package/dist/oss/uploader.d.ts +72 -0
  35. package/dist/oss/uploader.d.ts.map +1 -0
  36. package/dist/oss/uploader.js +185 -0
  37. package/dist/oss/uploader.js.map +1 -0
  38. package/dist/types/deployment.d.ts +112 -0
  39. package/dist/types/deployment.d.ts.map +1 -0
  40. package/dist/types/deployment.js +7 -0
  41. package/dist/types/deployment.js.map +1 -0
  42. package/dist/types/index.d.ts +8 -0
  43. package/dist/types/index.d.ts.map +1 -0
  44. package/dist/types/index.js +8 -0
  45. package/dist/types/index.js.map +1 -0
  46. package/dist/types/project.d.ts +90 -0
  47. package/dist/types/project.d.ts.map +1 -0
  48. package/dist/types/project.js +8 -0
  49. package/dist/types/project.js.map +1 -0
  50. package/dist/types/user.d.ts +71 -0
  51. package/dist/types/user.d.ts.map +1 -0
  52. package/dist/types/user.js +8 -0
  53. package/dist/types/user.js.map +1 -0
  54. package/dist/types/workspace.d.ts +88 -0
  55. package/dist/types/workspace.d.ts.map +1 -0
  56. package/dist/types/workspace.js +27 -0
  57. package/dist/types/workspace.js.map +1 -0
  58. package/dist/utils/build.d.ts +78 -0
  59. package/dist/utils/build.d.ts.map +1 -0
  60. package/dist/utils/build.js +148 -0
  61. package/dist/utils/build.js.map +1 -0
  62. package/dist/utils/index.d.ts +6 -0
  63. package/dist/utils/index.d.ts.map +1 -0
  64. package/dist/utils/index.js +6 -0
  65. package/dist/utils/index.js.map +1 -0
  66. package/dist/utils/manifest.d.ts +106 -0
  67. package/dist/utils/manifest.d.ts.map +1 -0
  68. package/dist/utils/manifest.js +109 -0
  69. package/dist/utils/manifest.js.map +1 -0
  70. package/package.json +62 -0
  71. package/src/db/client.ts +92 -0
  72. package/src/db/deployments.ts +316 -0
  73. package/src/db/index.ts +7 -0
  74. package/src/db/projects.ts +246 -0
  75. package/src/db/schema.sql +156 -0
  76. package/src/index.ts +18 -0
  77. package/src/oss/client.ts +183 -0
  78. package/src/oss/index.ts +7 -0
  79. package/src/oss/types.ts +126 -0
  80. package/src/oss/uploader.ts +254 -0
  81. package/src/types/deployment.ts +147 -0
  82. package/src/types/index.ts +8 -0
  83. package/src/types/project.ts +114 -0
  84. package/src/types/user.ts +91 -0
  85. package/src/types/workspace.ts +124 -0
  86. package/src/utils/build.ts +199 -0
  87. package/src/utils/index.ts +6 -0
  88. package/src/utils/manifest.ts +224 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/types/workspace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgGH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAChD,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;IAC7C,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC,EAAE;IACpE,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC,EAAE;IACxE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,EAAE;CACjE,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,SAAS;IACT,KAAK;IACL,OAAO;IACP,MAAM;IACN,MAAM;IACN,SAAS;CACD,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Build utilities for Vite projects
3
+ *
4
+ * Provides helpers for running builds and collecting output files.
5
+ */
6
+ import type { UploadFile } from '../oss/types';
7
+ import type { ProjectConfig } from '../types/project';
8
+ /**
9
+ * Get MIME type for a file based on extension
10
+ */
11
+ export declare function getMimeType(filename: string): string;
12
+ /**
13
+ * Build command configuration
14
+ */
15
+ export interface BuildConfig {
16
+ /** Working directory (project root) */
17
+ cwd: string;
18
+ /** Build command (default: "pnpm build") */
19
+ command?: string;
20
+ /** Environment variables to set */
21
+ env?: Record<string, string>;
22
+ /** Timeout in milliseconds (default: 5 minutes) */
23
+ timeout?: number;
24
+ }
25
+ /**
26
+ * Build result
27
+ */
28
+ export interface BuildResult {
29
+ /** Whether build was successful */
30
+ success: boolean;
31
+ /** Output directory path */
32
+ outputDir: string;
33
+ /** Build output log */
34
+ log: string;
35
+ /** Error message if failed */
36
+ error?: string;
37
+ /** Build duration in milliseconds */
38
+ durationMs: number;
39
+ }
40
+ /**
41
+ * Get the default build command based on project config
42
+ */
43
+ export declare function getDefaultBuildCommand(config: ProjectConfig): string;
44
+ /**
45
+ * Get the output directory based on project config
46
+ */
47
+ export declare function getOutputDir(config: ProjectConfig): string;
48
+ /**
49
+ * Convert a File object to UploadFile format
50
+ *
51
+ * @param file - File object from file input or FileList
52
+ * @param relativePath - Relative path within the bundle
53
+ */
54
+ export declare function fileToUploadFile(file: File, relativePath: string): UploadFile;
55
+ /**
56
+ * Calculate total size of files
57
+ */
58
+ export declare function calculateTotalSize(files: UploadFile[]): number;
59
+ /**
60
+ * Format file size for display
61
+ */
62
+ export declare function formatFileSize(bytes: number): string;
63
+ /**
64
+ * Validate that required files exist in the bundle
65
+ */
66
+ export declare function validateBundle(files: UploadFile[]): {
67
+ valid: boolean;
68
+ errors: string[];
69
+ };
70
+ /**
71
+ * Files to exclude from upload (common patterns)
72
+ */
73
+ export declare const EXCLUDE_PATTERNS: RegExp[];
74
+ /**
75
+ * Check if a file should be excluded from upload
76
+ */
77
+ export declare function shouldExclude(path: string, includeSourceMaps?: boolean): boolean;
78
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/utils/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AA6BtD;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IAEZ,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mCAAmC;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IAEjB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAElB,uBAAuB;IACvB,GAAG,EAAE,MAAM,CAAC;IAEZ,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAEpE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,GAAG,UAAU,CAM7E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CAY9D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CA4BxF;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,UAO5B,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,UAAQ,GAAG,OAAO,CAW9E"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Build utilities for Vite projects
3
+ *
4
+ * Provides helpers for running builds and collecting output files.
5
+ */
6
+ /**
7
+ * MIME type mapping for common file extensions
8
+ */
9
+ const MIME_TYPES = {
10
+ '.html': 'text/html',
11
+ '.css': 'text/css',
12
+ '.js': 'application/javascript',
13
+ '.mjs': 'application/javascript',
14
+ '.json': 'application/json',
15
+ '.svg': 'image/svg+xml',
16
+ '.png': 'image/png',
17
+ '.jpg': 'image/jpeg',
18
+ '.jpeg': 'image/jpeg',
19
+ '.gif': 'image/gif',
20
+ '.webp': 'image/webp',
21
+ '.ico': 'image/x-icon',
22
+ '.woff': 'font/woff',
23
+ '.woff2': 'font/woff2',
24
+ '.ttf': 'font/ttf',
25
+ '.eot': 'application/vnd.ms-fontobject',
26
+ '.otf': 'font/otf',
27
+ '.map': 'application/json',
28
+ '.txt': 'text/plain',
29
+ '.xml': 'application/xml',
30
+ '.webmanifest': 'application/manifest+json',
31
+ };
32
+ /**
33
+ * Get MIME type for a file based on extension
34
+ */
35
+ export function getMimeType(filename) {
36
+ const ext = filename.substring(filename.lastIndexOf('.')).toLowerCase();
37
+ return MIME_TYPES[ext] || 'application/octet-stream';
38
+ }
39
+ /**
40
+ * Get the default build command based on project config
41
+ */
42
+ export function getDefaultBuildCommand(config) {
43
+ return config.buildCommand || 'pnpm build';
44
+ }
45
+ /**
46
+ * Get the output directory based on project config
47
+ */
48
+ export function getOutputDir(config) {
49
+ return config.outputDir || 'dist';
50
+ }
51
+ /**
52
+ * Convert a File object to UploadFile format
53
+ *
54
+ * @param file - File object from file input or FileList
55
+ * @param relativePath - Relative path within the bundle
56
+ */
57
+ export function fileToUploadFile(file, relativePath) {
58
+ return {
59
+ path: relativePath,
60
+ content: file,
61
+ contentType: file.type || getMimeType(file.name),
62
+ };
63
+ }
64
+ /**
65
+ * Calculate total size of files
66
+ */
67
+ export function calculateTotalSize(files) {
68
+ let total = 0;
69
+ for (const file of files) {
70
+ if (file.content instanceof Blob) {
71
+ total += file.content.size;
72
+ }
73
+ else if (file.content instanceof ArrayBuffer) {
74
+ total += file.content.byteLength;
75
+ }
76
+ else if (typeof file.content === 'string') {
77
+ total += new Blob([file.content]).size;
78
+ }
79
+ }
80
+ return total;
81
+ }
82
+ /**
83
+ * Format file size for display
84
+ */
85
+ export function formatFileSize(bytes) {
86
+ if (bytes === 0)
87
+ return '0 B';
88
+ const units = ['B', 'KB', 'MB', 'GB'];
89
+ const k = 1024;
90
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
91
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${units[i]}`;
92
+ }
93
+ /**
94
+ * Validate that required files exist in the bundle
95
+ */
96
+ export function validateBundle(files) {
97
+ const errors = [];
98
+ const paths = new Set(files.map(f => f.path));
99
+ // Check for index.html
100
+ if (!paths.has('index.html')) {
101
+ errors.push('Missing index.html - required for web deployment');
102
+ }
103
+ // Warn about large files
104
+ for (const file of files) {
105
+ let size = 0;
106
+ if (file.content instanceof Blob) {
107
+ size = file.content.size;
108
+ }
109
+ else if (file.content instanceof ArrayBuffer) {
110
+ size = file.content.byteLength;
111
+ }
112
+ // Warn if file is larger than 10MB
113
+ if (size > 10 * 1024 * 1024) {
114
+ errors.push(`Large file detected: ${file.path} (${formatFileSize(size)})`);
115
+ }
116
+ }
117
+ return {
118
+ valid: errors.length === 0 || !errors.some(e => e.includes('Missing')),
119
+ errors,
120
+ };
121
+ }
122
+ /**
123
+ * Files to exclude from upload (common patterns)
124
+ */
125
+ export const EXCLUDE_PATTERNS = [
126
+ /^\.git\//,
127
+ /^node_modules\//,
128
+ /^\.DS_Store$/,
129
+ /^Thumbs\.db$/,
130
+ /\.map$/, // Source maps (optional)
131
+ /^\.env/,
132
+ ];
133
+ /**
134
+ * Check if a file should be excluded from upload
135
+ */
136
+ export function shouldExclude(path, includeSourceMaps = false) {
137
+ for (const pattern of EXCLUDE_PATTERNS) {
138
+ if (pattern.test(path)) {
139
+ // Allow source maps if requested
140
+ if (pattern.source === '\\.map$' && includeSourceMaps) {
141
+ continue;
142
+ }
143
+ return true;
144
+ }
145
+ }
146
+ return false;
147
+ }
148
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {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AAG,yBAAyB;IACpC,QAAQ;CACT,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,iBAAiB,GAAG,KAAK;IACnE,KAAK,MAAM,OAAO,IAAI,gBAAgB,EAAE,CAAC;QACvC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,iCAAiC;YACjC,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,iBAAiB,EAAE,CAAC;gBACtD,SAAS;YACX,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utility functions for Studio
3
+ */
4
+ export * from './build';
5
+ export * from './manifest';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Utility functions for Studio
3
+ */
4
+ export * from './build';
5
+ export * from './manifest';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * WebApp Manifest utilities
3
+ *
4
+ * Generates manifest files for deployed web applications,
5
+ * compatible with Agent Foundry's app registry.
6
+ */
7
+ import type { StudioProject } from '../types/project';
8
+ import type { Deployment } from '../types/deployment';
9
+ /**
10
+ * WebApp manifest structure for Agent Foundry
11
+ */
12
+ export interface WebAppManifest {
13
+ /** Schema version */
14
+ schema: string;
15
+ /** App ID (e.g., "com.agentfoundry.myapp") */
16
+ id: string;
17
+ /** Display name */
18
+ name: string;
19
+ /** Short name for icons */
20
+ shortName?: string;
21
+ /** App description */
22
+ description?: string;
23
+ /** App version */
24
+ version: string;
25
+ /** Entry URL (index.html) */
26
+ entryUrl: string;
27
+ /** Icon URLs */
28
+ icons?: {
29
+ src: string;
30
+ sizes: string;
31
+ type?: string;
32
+ }[];
33
+ /** Theme color */
34
+ themeColor?: string;
35
+ /** Background color */
36
+ backgroundColor?: string;
37
+ /** Display mode */
38
+ display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser';
39
+ /** Orientation preference */
40
+ orientation?: 'any' | 'portrait' | 'landscape';
41
+ /** Categories */
42
+ categories?: string[];
43
+ /** Agent Foundry specific metadata */
44
+ agentFoundry?: {
45
+ /** Creator user ID */
46
+ createdBy: string;
47
+ /** Deployment ID */
48
+ deploymentId: string;
49
+ /** Project ID */
50
+ projectId: string;
51
+ /** Framework used */
52
+ framework: string;
53
+ /** Build timestamp */
54
+ builtAt: string;
55
+ /** Bundle size in bytes */
56
+ bundleSize?: number;
57
+ };
58
+ }
59
+ /**
60
+ * Options for generating a manifest
61
+ */
62
+ export interface ManifestOptions {
63
+ /** App ID prefix (default: "com.agentfoundry.studio") */
64
+ idPrefix?: string;
65
+ /** Theme color */
66
+ themeColor?: string;
67
+ /** Background color */
68
+ backgroundColor?: string;
69
+ /** Icon URL */
70
+ iconUrl?: string;
71
+ /** Categories */
72
+ categories?: string[];
73
+ }
74
+ /**
75
+ * Generate a WebApp manifest for a deployed project
76
+ *
77
+ * @param project - The Studio project
78
+ * @param deployment - The deployment record
79
+ * @param options - Optional manifest configuration
80
+ */
81
+ export declare function generateManifest(project: StudioProject, deployment: Deployment, options?: ManifestOptions): WebAppManifest;
82
+ /**
83
+ * Generate a standard web app manifest (PWA compatible)
84
+ */
85
+ export declare function generateWebManifest(project: StudioProject, options?: ManifestOptions): Record<string, unknown>;
86
+ /**
87
+ * Serialize manifest to JSON string
88
+ */
89
+ export declare function serializeManifest(manifest: WebAppManifest): string;
90
+ /**
91
+ * Parse manifest from JSON string
92
+ */
93
+ export declare function parseManifest(json: string): WebAppManifest;
94
+ /**
95
+ * Generate deployment URL path
96
+ *
97
+ * @param userId - User ID
98
+ * @param projectSlug - Project slug
99
+ * @param version - Deployment version
100
+ */
101
+ export declare function generateDeploymentPath(userId: string, projectSlug: string, version: string): string;
102
+ /**
103
+ * Generate a unique deployment version based on timestamp
104
+ */
105
+ export declare function generateVersionFromTimestamp(date?: Date): string;
106
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/utils/manifest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IAEf,8CAA8C;IAC9C,EAAE,EAAE,MAAM,CAAC;IAEX,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IAEb,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,sBAAsB;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,kBAAkB;IAClB,OAAO,EAAE,MAAM,CAAC;IAEhB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IAEjB,gBAAgB;IAChB,KAAK,CAAC,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IAEJ,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,uBAAuB;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,mBAAmB;IACnB,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,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,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,MAAM,CAER;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,IAAiB,GAAG,MAAM,CAS5E"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * WebApp Manifest utilities
3
+ *
4
+ * Generates manifest files for deployed web applications,
5
+ * compatible with Agent Foundry's app registry.
6
+ */
7
+ /**
8
+ * Generate a WebApp manifest for a deployed project
9
+ *
10
+ * @param project - The Studio project
11
+ * @param deployment - The deployment record
12
+ * @param options - Optional manifest configuration
13
+ */
14
+ export function generateManifest(project, deployment, options = {}) {
15
+ const idPrefix = options.idPrefix ?? 'com.agentfoundry.studio';
16
+ const appId = `${idPrefix}.${project.slug}`;
17
+ const manifest = {
18
+ schema: 'agent-foundry.webapp.v1',
19
+ id: appId,
20
+ name: project.name,
21
+ shortName: project.slug,
22
+ description: project.description,
23
+ version: deployment.version,
24
+ entryUrl: deployment.ossUrl ?? `https://placeholder/${deployment.id}/index.html`,
25
+ display: 'standalone',
26
+ orientation: 'any',
27
+ themeColor: options.themeColor ?? '#000000',
28
+ backgroundColor: options.backgroundColor ?? '#ffffff',
29
+ categories: options.categories ?? ['tools', 'productivity'],
30
+ agentFoundry: {
31
+ createdBy: project.userId,
32
+ deploymentId: deployment.id,
33
+ projectId: project.id,
34
+ framework: project.framework,
35
+ builtAt: deployment.publishedAt ?? deployment.createdAt,
36
+ bundleSize: deployment.bundleSizeBytes,
37
+ },
38
+ };
39
+ if (options.iconUrl) {
40
+ manifest.icons = [
41
+ { src: options.iconUrl, sizes: '192x192', type: 'image/png' },
42
+ { src: options.iconUrl, sizes: '512x512', type: 'image/png' },
43
+ ];
44
+ }
45
+ return manifest;
46
+ }
47
+ /**
48
+ * Generate a standard web app manifest (PWA compatible)
49
+ */
50
+ export function generateWebManifest(project, options = {}) {
51
+ return {
52
+ name: project.name,
53
+ short_name: project.slug,
54
+ description: project.description,
55
+ start_url: '/',
56
+ display: 'standalone',
57
+ background_color: options.backgroundColor ?? '#ffffff',
58
+ theme_color: options.themeColor ?? '#000000',
59
+ icons: options.iconUrl
60
+ ? [
61
+ { src: options.iconUrl, sizes: '192x192', type: 'image/png' },
62
+ { src: options.iconUrl, sizes: '512x512', type: 'image/png' },
63
+ ]
64
+ : [],
65
+ };
66
+ }
67
+ /**
68
+ * Serialize manifest to JSON string
69
+ */
70
+ export function serializeManifest(manifest) {
71
+ return JSON.stringify(manifest, null, 2);
72
+ }
73
+ /**
74
+ * Parse manifest from JSON string
75
+ */
76
+ export function parseManifest(json) {
77
+ const parsed = JSON.parse(json);
78
+ // Validate schema
79
+ if (!parsed.schema || !parsed.schema.startsWith('agent-foundry.webapp.')) {
80
+ throw new Error('Invalid manifest: missing or invalid schema');
81
+ }
82
+ if (!parsed.id || !parsed.name || !parsed.version) {
83
+ throw new Error('Invalid manifest: missing required fields (id, name, version)');
84
+ }
85
+ return parsed;
86
+ }
87
+ /**
88
+ * Generate deployment URL path
89
+ *
90
+ * @param userId - User ID
91
+ * @param projectSlug - Project slug
92
+ * @param version - Deployment version
93
+ */
94
+ export function generateDeploymentPath(userId, projectSlug, version) {
95
+ return `${userId}/${projectSlug}/${version}`;
96
+ }
97
+ /**
98
+ * Generate a unique deployment version based on timestamp
99
+ */
100
+ export function generateVersionFromTimestamp(date = new Date()) {
101
+ const year = date.getFullYear();
102
+ const month = String(date.getMonth() + 1).padStart(2, '0');
103
+ const day = String(date.getDate()).padStart(2, '0');
104
+ const hours = String(date.getHours()).padStart(2, '0');
105
+ const minutes = String(date.getMinutes()).padStart(2, '0');
106
+ const seconds = String(date.getSeconds()).padStart(2, '0');
107
+ return `${year}.${month}.${day}-${hours}${minutes}${seconds}`;
108
+ }
109
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../src/utils/manifest.ts"],"names":[],"mapp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ent-foundry/studio",
3
+ "version": "1.0.0",
4
+ "description": "Full SDK for Agent Foundry Build Studio - types, OSS upload, and Supabase client",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./types": {
15
+ "import": "./dist/types/index.js",
16
+ "types": "./dist/types/index.d.ts"
17
+ },
18
+ "./oss": {
19
+ "import": "./dist/oss/index.js",
20
+ "types": "./dist/oss/index.d.ts"
21
+ },
22
+ "./db": {
23
+ "import": "./dist/db/index.js",
24
+ "types": "./dist/db/index.d.ts"
25
+ }
26
+ },
27
+ "scripts": {
28
+ "build": "tsc",
29
+ "dev": "tsc --watch",
30
+ "clean": "rimraf dist",
31
+ "prepublishOnly": "pnpm run clean && pnpm run build"
32
+ },
33
+ "keywords": [
34
+ "agent-foundry",
35
+ "studio",
36
+ "build-studio",
37
+ "oss",
38
+ "supabase",
39
+ "typescript",
40
+ "sdk"
41
+ ],
42
+ "author": "Agent Foundry",
43
+ "license": "MIT",
44
+ "dependencies": {
45
+ "@supabase/supabase-js": "^2.47.0",
46
+ "ali-oss": "^6.21.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/ali-oss": "^6.16.0",
50
+ "@types/node": "^20.10.0",
51
+ "typescript": "^5.3.3",
52
+ "rimraf": "^5.0.5"
53
+ },
54
+ "files": [
55
+ "dist",
56
+ "src",
57
+ "README.md"
58
+ ],
59
+ "publishConfig": {
60
+ "access": "public"
61
+ }
62
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Supabase Studio Client
3
+ *
4
+ * Wrapper around @supabase/supabase-js providing typed access to
5
+ * Studio-specific tables (studio_projects, studio_deployments).
6
+ */
7
+
8
+ import { createClient, SupabaseClient } from '@supabase/supabase-js';
9
+ import { ProjectsRepository } from './projects';
10
+ import { DeploymentsRepository } from './deployments';
11
+
12
+ /**
13
+ * Configuration for creating a Studio client
14
+ */
15
+ export interface StudioClientConfig {
16
+ /** Supabase project URL */
17
+ supabaseUrl: string;
18
+
19
+ /** Supabase anon key (or service role key for server-side) */
20
+ supabaseKey: string;
21
+
22
+ /** Optional: Pass an existing Supabase client instance */
23
+ existingClient?: SupabaseClient;
24
+ }
25
+
26
+ /**
27
+ * Studio Client - main entry point for database operations
28
+ */
29
+ export interface StudioClient {
30
+ /** Raw Supabase client for advanced operations */
31
+ readonly supabase: SupabaseClient;
32
+
33
+ /** Projects repository */
34
+ readonly projects: ProjectsRepository;
35
+
36
+ /** Deployments repository */
37
+ readonly deployments: DeploymentsRepository;
38
+
39
+ /**
40
+ * Get current authenticated user ID
41
+ * @throws Error if not authenticated
42
+ */
43
+ getCurrentUserId(): Promise<string>;
44
+ }
45
+
46
+ /**
47
+ * Create a new Studio client
48
+ *
49
+ * @param config - Client configuration
50
+ * @returns StudioClient instance
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const client = createStudioClient({
55
+ * supabaseUrl: 'https://your-project.supabase.co',
56
+ * supabaseKey: 'your-anon-key',
57
+ * });
58
+ *
59
+ * // Create a project
60
+ * const project = await client.projects.create({
61
+ * name: 'My App',
62
+ * slug: 'my-app',
63
+ * rootPath: '/Users/me/projects/my-app',
64
+ * });
65
+ * ```
66
+ */
67
+ export function createStudioClient(config: StudioClientConfig): StudioClient {
68
+ const supabase = config.existingClient ?? createClient(
69
+ config.supabaseUrl,
70
+ config.supabaseKey
71
+ );
72
+
73
+ const projects = new ProjectsRepository(supabase);
74
+ const deployments = new DeploymentsRepository(supabase);
75
+
76
+ return {
77
+ supabase,
78
+ projects,
79
+ deployments,
80
+
81
+ async getCurrentUserId(): Promise<string> {
82
+ const { data: { user }, error } = await supabase.auth.getUser();
83
+ if (error) {
84
+ throw new Error(`Failed to get current user: ${error.message}`);
85
+ }
86
+ if (!user) {
87
+ throw new Error('Not authenticated');
88
+ }
89
+ return user.id;
90
+ },
91
+ };
92
+ }