@tilt-launcher/sdk 1.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matthew Eric
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # @tilt-launcher/sdk
2
+
3
+ SDK for managing [Tilt](https://tilt.dev) dev environments — start, stop, monitor, and control resources programmatically.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ bun add @tilt-launcher/sdk
9
+ # or
10
+ npm install @tilt-launcher/sdk
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```ts
16
+ import { TiltManagerSDK } from '@tilt-launcher/sdk';
17
+ import type { Config, StatusUpdate, LogDelta } from '@tilt-launcher/sdk';
18
+
19
+ const config: Config = {
20
+ environments: [
21
+ {
22
+ id: 'my-app',
23
+ name: 'My App',
24
+ repoDir: '/path/to/repo',
25
+ tiltfile: 'Tiltfile',
26
+ tiltPort: 10350,
27
+ selectedResources: [],
28
+ cachedResources: [],
29
+ },
30
+ ],
31
+ };
32
+
33
+ const sdk = new TiltManagerSDK(config, {
34
+ onStatusUpdate: (update: StatusUpdate) => {
35
+ console.log('Status:', update.envs);
36
+ },
37
+ onLogDelta: (delta: LogDelta) => {
38
+ console.log('Logs:', delta);
39
+ },
40
+ });
41
+
42
+ // Start polling the Tilt API
43
+ sdk.startPolling(5000);
44
+
45
+ // Start an environment
46
+ await sdk.startEnv('my-app');
47
+
48
+ // Get current status
49
+ const status = sdk.currentStatusUpdate();
50
+
51
+ // Control resources
52
+ await sdk.triggerResource('my-app', 'web-server');
53
+ await sdk.disableResource('my-app', 'slow-service');
54
+ await sdk.enableResource('my-app', 'slow-service');
55
+
56
+ // Stop
57
+ await sdk.stopEnv('my-app');
58
+ sdk.stopPolling();
59
+ ```
60
+
61
+ ## API
62
+
63
+ ### `TiltManagerSDK`
64
+
65
+ | Method | Description |
66
+ | ------------------------------ | ---------------------------------- |
67
+ | `startEnv(envId)` | Start a Tilt environment |
68
+ | `stopEnv(envId)` | Stop a running environment |
69
+ | `restartEnv(envId)` | Kill and restart an environment |
70
+ | `triggerResource(envId, name)` | Manually trigger a resource update |
71
+ | `enableResource(envId, name)` | Re-enable a disabled resource |
72
+ | `disableResource(envId, name)` | Disable a resource |
73
+ | `getEnvLogs(envId)` | Get env + resource log lines |
74
+ | `currentStatusUpdate()` | Get latest status snapshot |
75
+ | `setConfig(config)` | Update config at runtime |
76
+ | `discoverResources(input)` | Discover resources from a Tiltfile |
77
+ | `startPolling(intervalMs)` | Start polling Tilt APIs |
78
+ | `stopPolling()` | Stop polling |
79
+
80
+ ### Types
81
+
82
+ - `Config` — app configuration with environment list
83
+ - `Environment` — a single Tilt environment definition
84
+ - `StatusUpdate` — full status snapshot (all envs + resources)
85
+ - `ResourceRow` — individual resource status (health, pid, labels, etc.)
86
+ - `LogDelta` — incremental log update
87
+ - `DiscoverResult` — result of resource discovery
88
+ - `LauncherBridge` — abstract UI bridge interface
89
+
90
+ ### Callbacks
91
+
92
+ | Callback | Fires when |
93
+ | ----------------- | -------------------------------------------------------- |
94
+ | `onStatusUpdate` | Tilt API poll returns new data |
95
+ | `onLogDelta` | New log lines arrive via WebSocket |
96
+ | `onConfigMutated` | SDK internally modifies config (e.g., caching resources) |
97
+
98
+ ## Requirements
99
+
100
+ - `tilt` must be on `$PATH`
101
+ - Node.js ≥ 18 or Bun
102
+
103
+ ## License
104
+
105
+ MIT
@@ -0,0 +1,43 @@
1
+ import type { Config, DiscoverResult, LoginItemSettings, LogDelta, PickedTiltfile, ReadDirResult, StatusUpdate } from './types.ts';
2
+ type Result = {
3
+ ok: boolean;
4
+ error?: string;
5
+ };
6
+ /**
7
+ * Abstract bridge interface between the UI and the host shell.
8
+ *
9
+ * Each shell (Electron, Tauri, etc.) provides its own implementation.
10
+ * The UI layer consumes this interface exclusively — it never imports
11
+ * from Electron, Tauri, or any other shell-specific API directly.
12
+ */
13
+ export interface LauncherBridge {
14
+ getConfig(): Promise<Config>;
15
+ getStatus(): Promise<StatusUpdate>;
16
+ getLogs(envId: string): Promise<{
17
+ envLogs: string[];
18
+ resourceLogs: Record<string, string[]>;
19
+ }>;
20
+ startEnv(envId: string): Promise<Result>;
21
+ stopEnv(envId: string): Promise<Result>;
22
+ restartEnv(envId: string): Promise<Result>;
23
+ triggerResource(envId: string, resourceName: string): Promise<Result>;
24
+ enableResource(envId: string, resourceName: string): Promise<Result>;
25
+ disableResource(envId: string, resourceName: string): Promise<Result>;
26
+ saveConfig(config: Config): Promise<Result>;
27
+ pickTiltfile(): Promise<PickedTiltfile | null>;
28
+ classifyTiltfilePath(filePath: string): Promise<PickedTiltfile>;
29
+ openExternal(url: string): Promise<void>;
30
+ getHomeDir(): Promise<string>;
31
+ readDir(dirPath: string): Promise<ReadDirResult>;
32
+ discoverResources(input: {
33
+ tiltfilePath: string;
34
+ tiltPort: number;
35
+ timeoutMs?: number;
36
+ }): Promise<DiscoverResult>;
37
+ getLoginItemSettings(): Promise<LoginItemSettings>;
38
+ setLoginItemSettings(openAtLogin: boolean): Promise<Result>;
39
+ onStatusUpdate(listener: (update: StatusUpdate) => void): () => void;
40
+ onLogDelta(listener: (delta: LogDelta) => void): () => void;
41
+ onConfigUpdated(listener: (config: Config) => void): () => void;
42
+ }
43
+ export {};
package/dist/bridge.js ADDED
File without changes
@@ -0,0 +1,3 @@
1
+ export * from './types.ts';
2
+ export { type LauncherBridge } from './bridge.ts';
3
+ export { TiltManagerSDK } from './tiltManagerSDK.ts';