@larkup/marketplace 0.1.1

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/src/types.ts ADDED
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Marketplace type contracts.
3
+ *
4
+ * These types define the plugin/tool system that powers the Larkup Hub.
5
+ * Tools are optional features users can install from the marketplace UI.
6
+ *
7
+ * Architecture:
8
+ * - Tools are standalone npm packages published as `@larkup/tool-*`
9
+ * - Each package ships a `tool.manifest.json` describing its capabilities
10
+ * - Install downloads real packages into `.larkup/tools/node_modules/`
11
+ * - The Hub API (apps/hub) serves the remote catalog and tracks installs
12
+ * - The loader resolves installed tools at runtime from the isolated dir
13
+ */
14
+
15
+ /* ------------------------------------------------------------------ */
16
+ /* Tool lifecycle */
17
+ /* ------------------------------------------------------------------ */
18
+
19
+ export type ToolStatus = 'available' | 'installing' | 'installed' | 'error';
20
+
21
+ export type ToolCategory =
22
+ | 'media'
23
+ | 'search'
24
+ | 'analytics'
25
+ | 'integration'
26
+ | 'embedding'
27
+ | 'ai'
28
+ | 'automation'
29
+ | 'utility';
30
+
31
+ export type ToolPricing = 'free' | 'pro' | 'enterprise';
32
+
33
+ /* ------------------------------------------------------------------ */
34
+ /* Tool descriptor (the registry entry / manifest schema) */
35
+ /* ------------------------------------------------------------------ */
36
+
37
+ /**
38
+ * The canonical shape for every marketplace tool. Each tool defines
39
+ * one of these — either hardcoded in the registry or loaded from a
40
+ * `tool.manifest.json` file inside the package (future).
41
+ *
42
+ * Schema version: 1.0
43
+ */
44
+ export interface ToolDescriptor {
45
+ /** Unique identifier: "video-audio", "clip-embeddings", etc. */
46
+ id: string;
47
+ /** User-facing display name */
48
+ name: string;
49
+ /** Short one-line description */
50
+ description: string;
51
+ /** Longer description shown in detail view */
52
+ longDescription?: string;
53
+ category: ToolCategory;
54
+ version: string;
55
+ /** Current pricing tier — "free" for all launch tools */
56
+ pricing: ToolPricing;
57
+
58
+ /* ---- Icon system (priority: emoji > iconUrl > icon) ------------ */
59
+
60
+ /** Emoji icon for lightweight display (e.g., "🎬"). Primary choice. */
61
+ emoji?: string;
62
+ /**
63
+ * URL or path to a custom icon image (PNG/SVG/WebP).
64
+ * Future: will be served from CDN via the API gateway.
65
+ */
66
+ iconUrl?: string;
67
+ /** Lucide icon name — fallback when no emoji/image is set */
68
+ icon: string;
69
+
70
+ /* ---- Package metadata ------------------------------------------ */
71
+
72
+ /** npm package name or "built-in" */
73
+ packageName: string;
74
+ /** Approximate install size for user display */
75
+ installSize: string;
76
+ /** System dependencies required (e.g., "ffmpeg") */
77
+ systemDeps?: string[];
78
+ /** Author / publisher */
79
+ author: string;
80
+
81
+ /* ---- Capabilities & config ------------------------------------- */
82
+
83
+ /** Features this tool provides (used by core to route work) */
84
+ capabilities: string[];
85
+ /** Tool-specific configuration schema */
86
+ configSchema?: ToolConfigField[];
87
+
88
+ /* ---- Marketplace metadata -------------------------------------- */
89
+
90
+ /** Tags for search and filtering (e.g., ["transcription", "ffmpeg"]) */
91
+ tags?: string[];
92
+ /** Total download/install count (local tracking; future: remote API) */
93
+ downloads: number;
94
+ /** Repository or homepage URL — enables collaboration */
95
+ repositoryUrl?: string;
96
+ /** License type (e.g., "MIT", "Apache-2.0") */
97
+ license?: string;
98
+ /** Changelog / what's new in this version */
99
+ changelog?: string;
100
+ /** Minimum Larkup version required */
101
+ minLarkupVersion?: string;
102
+ /** Last updated date (ISO 8601) */
103
+ updatedAt?: string;
104
+
105
+ /* ---- Flags ----------------------------------------------------- */
106
+
107
+ /** Whether this tool is a placeholder (coming soon) */
108
+ comingSoon?: boolean;
109
+ }
110
+
111
+ export interface ToolConfigField {
112
+ key: string;
113
+ label: string;
114
+ type: 'text' | 'password' | 'select' | 'toggle';
115
+ defaultValue?: string;
116
+ help?: string;
117
+ required?: boolean;
118
+ options?: { label: string; value: string }[];
119
+ }
120
+
121
+ /* ------------------------------------------------------------------ */
122
+ /* Installed tool state (persisted to disk) */
123
+ /* ------------------------------------------------------------------ */
124
+
125
+ /**
126
+ * Where the tool was installed from.
127
+ * - `registry`: Downloaded from npm / Hub API (the standard path)
128
+ * - `local`: Workspace package (monorepo development mode)
129
+ * - `sandbox`: Installed inside a remote sandbox (E2B / Modal)
130
+ */
131
+ export type ToolSource = 'registry' | 'local' | 'sandbox';
132
+
133
+ export interface InstalledTool {
134
+ id: string;
135
+ version: string;
136
+ installedAt: string;
137
+ /** npm package name (e.g., "@larkup/tool-video-audio") */
138
+ packageName: string;
139
+ /**
140
+ * Absolute path to the resolved module entry point.
141
+ * Set after install — used by the loader for `import(resolvedPath)`.
142
+ * For local (monorepo) installs, this is the workspace path.
143
+ * For registry installs, this is inside `.larkup/tools/node_modules/`.
144
+ */
145
+ resolvedPath: string;
146
+ /** Where this tool was installed from */
147
+ source: ToolSource;
148
+ /** User-provided configuration values */
149
+ config: Record<string, any>;
150
+ }
151
+
152
+ export interface InstalledToolsManifest {
153
+ tools: InstalledTool[];
154
+ /** Per-tool download/install counts (keyed by tool id) */
155
+ downloadCounts: Record<string, number>;
156
+ updatedAt: string;
157
+ }
158
+
159
+ /* ------------------------------------------------------------------ */
160
+ /* Install progress */
161
+ /* ------------------------------------------------------------------ */
162
+
163
+ export type InstallStage =
164
+ | 'checking-deps'
165
+ | 'downloading'
166
+ | 'installing'
167
+ | 'configuring'
168
+ | 'completed'
169
+ | 'failed';
170
+
171
+ export interface InstallProgress {
172
+ toolId: string;
173
+ stage: InstallStage;
174
+ /** 0–100 */
175
+ percent: number;
176
+ message: string;
177
+ error?: string;
178
+ }
179
+
180
+ /* ------------------------------------------------------------------ */
181
+ /* Deployment target */
182
+ /* ------------------------------------------------------------------ */
183
+
184
+ /**
185
+ * Determines how tool installation and loading behaves.
186
+ * - `local`: User's machine (CLI, Desktop, or `pnpm run dev`)
187
+ * - `docker`: Inside a Docker container (VPS / self-hosted)
188
+ * - `serverless`: Vercel / AWS Lambda (cannot install at runtime)
189
+ * - `sandbox`: E2B / Modal sandbox (ephemeral, can install dynamically)
190
+ */
191
+ export type DeploymentTarget = 'local' | 'docker' | 'serverless' | 'sandbox';
192
+
193
+ /* ------------------------------------------------------------------ */
194
+ /* Hub API configuration */
195
+ /* ------------------------------------------------------------------ */
196
+
197
+ export interface HubConfig {
198
+ /** Base URL of the Hub API (e.g., "https://hub.larkup.de") */
199
+ baseUrl: string;
200
+ /** Optional API key for authenticated requests */
201
+ apiKey?: string;
202
+ }
203
+
204
+ /** Default Hub API URL. Can be overridden via LARKUP_HUB_URL env var. */
205
+ export const DEFAULT_HUB_URL = process.env.LARKUP_HUB_URL ?? 'https://hub.larkup.de';
206
+
207
+ /* ------------------------------------------------------------------ */
208
+ /* Storage provider abstraction */
209
+ /* ------------------------------------------------------------------ */
210
+
211
+ /**
212
+ * Abstraction over where media files are stored. Ships with a local
213
+ * provider; cloud providers (S3, UploadThing, GCS) can be added later
214
+ * without changing any upstream code.
215
+ */
216
+ export interface StorageProvider {
217
+ id: string;
218
+ name: string;
219
+ /** Store a file and return a resolvable URI */
220
+ store(key: string, data: Buffer, mimeType: string): Promise<string>;
221
+ /** Store an existing local file without buffering it in memory, when supported. */
222
+ storeFile?(key: string, sourcePath: string, mimeType: string): Promise<string>;
223
+ /** Retrieve a file by its storage URI */
224
+ retrieve(uri: string): Promise<Buffer>;
225
+ /** Resolve a URI to a local file without buffering it in memory, when supported. */
226
+ resolvePath?(uri: string): Promise<string | undefined>;
227
+ /** Delete a file by its storage URI */
228
+ delete(uri: string): Promise<void>;
229
+ /** Get storage usage stats */
230
+ stats(): Promise<StorageStats>;
231
+ }
232
+
233
+ export interface StorageStats {
234
+ usedBytes: number;
235
+ fileCount: number;
236
+ /** If set, storage has a configured limit */
237
+ limitBytes?: number;
238
+ }
239
+
240
+ /** Thresholds for storage warnings (in bytes) */
241
+ export const STORAGE_WARNING_THRESHOLDS = [
242
+ 1 * 1024 * 1024 * 1024, // 1 GB
243
+ 5 * 1024 * 1024 * 1024, // 5 GB
244
+ 10 * 1024 * 1024 * 1024, // 10 GB
245
+ ] as const;
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "declaration": true,
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "outDir": "dist",
11
+ "rootDir": "src"
12
+ },
13
+ "include": ["src"]
14
+ }