@hasna/connectors 0.4.2 → 0.5.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 (205) hide show
  1. package/bin/index.js +113 -1
  2. package/bin/mcp.js +113 -1
  3. package/bin/serve.js +112 -0
  4. package/connectors/connect-assemblyai/.env.example +11 -0
  5. package/connectors/connect-assemblyai/CLAUDE.md +128 -0
  6. package/connectors/connect-assemblyai/README.md +193 -0
  7. package/connectors/connect-assemblyai/package.json +50 -0
  8. package/connectors/connect-assemblyai/src/api/client.ts +192 -0
  9. package/connectors/connect-assemblyai/src/api/index.ts +71 -0
  10. package/connectors/connect-assemblyai/src/cli/index.ts +384 -0
  11. package/connectors/connect-assemblyai/src/index.ts +19 -0
  12. package/connectors/connect-assemblyai/src/types/index.ts +277 -0
  13. package/connectors/connect-assemblyai/src/utils/config.ts +103 -0
  14. package/connectors/connect-assemblyai/src/utils/output.ts +119 -0
  15. package/connectors/connect-assemblyai/tsconfig.json +16 -0
  16. package/connectors/connect-baseten/.env.example +11 -0
  17. package/connectors/connect-baseten/CLAUDE.md +128 -0
  18. package/connectors/connect-baseten/README.md +193 -0
  19. package/connectors/connect-baseten/package.json +51 -0
  20. package/connectors/connect-baseten/src/api/client.ts +71 -0
  21. package/connectors/connect-baseten/src/api/index.ts +40 -0
  22. package/connectors/connect-baseten/src/cli/index.ts +244 -0
  23. package/connectors/connect-baseten/src/index.ts +19 -0
  24. package/connectors/connect-baseten/src/types/index.ts +55 -0
  25. package/connectors/connect-baseten/src/utils/config.ts +103 -0
  26. package/connectors/connect-baseten/src/utils/output.ts +119 -0
  27. package/connectors/connect-baseten/tsconfig.json +16 -0
  28. package/connectors/connect-cerebras/.env.example +11 -0
  29. package/connectors/connect-cerebras/CLAUDE.md +128 -0
  30. package/connectors/connect-cerebras/README.md +193 -0
  31. package/connectors/connect-cerebras/package.json +51 -0
  32. package/connectors/connect-cerebras/src/api/client.ts +64 -0
  33. package/connectors/connect-cerebras/src/api/index.ts +32 -0
  34. package/connectors/connect-cerebras/src/cli/index.ts +244 -0
  35. package/connectors/connect-cerebras/src/index.ts +19 -0
  36. package/connectors/connect-cerebras/src/types/index.ts +65 -0
  37. package/connectors/connect-cerebras/src/utils/config.ts +103 -0
  38. package/connectors/connect-cerebras/src/utils/output.ts +119 -0
  39. package/connectors/connect-cerebras/tsconfig.json +16 -0
  40. package/connectors/connect-cohere/.env.example +11 -0
  41. package/connectors/connect-cohere/CLAUDE.md +128 -0
  42. package/connectors/connect-cohere/README.md +193 -0
  43. package/connectors/connect-cohere/package.json +53 -0
  44. package/connectors/connect-cohere/src/api/client.ts +109 -0
  45. package/connectors/connect-cohere/src/api/index.ts +59 -0
  46. package/connectors/connect-cohere/src/cli/index.ts +255 -0
  47. package/connectors/connect-cohere/src/index.ts +19 -0
  48. package/connectors/connect-cohere/src/types/index.ts +132 -0
  49. package/connectors/connect-cohere/src/utils/config.ts +197 -0
  50. package/connectors/connect-cohere/src/utils/output.ts +119 -0
  51. package/connectors/connect-cohere/tsconfig.json +16 -0
  52. package/connectors/connect-deepgram/.env.example +11 -0
  53. package/connectors/connect-deepgram/CLAUDE.md +128 -0
  54. package/connectors/connect-deepgram/README.md +193 -0
  55. package/connectors/connect-deepgram/package.json +51 -0
  56. package/connectors/connect-deepgram/src/api/client.ts +235 -0
  57. package/connectors/connect-deepgram/src/api/index.ts +57 -0
  58. package/connectors/connect-deepgram/src/cli/index.ts +339 -0
  59. package/connectors/connect-deepgram/src/index.ts +19 -0
  60. package/connectors/connect-deepgram/src/types/index.ts +232 -0
  61. package/connectors/connect-deepgram/src/utils/config.ts +103 -0
  62. package/connectors/connect-deepgram/src/utils/output.ts +119 -0
  63. package/connectors/connect-deepgram/tsconfig.json +16 -0
  64. package/connectors/connect-deepseek/.env.example +11 -0
  65. package/connectors/connect-deepseek/CLAUDE.md +128 -0
  66. package/connectors/connect-deepseek/README.md +193 -0
  67. package/connectors/connect-deepseek/package.json +51 -0
  68. package/connectors/connect-deepseek/src/api/client.ts +108 -0
  69. package/connectors/connect-deepseek/src/api/index.ts +36 -0
  70. package/connectors/connect-deepseek/src/cli/index.ts +167 -0
  71. package/connectors/connect-deepseek/src/index.ts +19 -0
  72. package/connectors/connect-deepseek/src/types/index.ts +72 -0
  73. package/connectors/connect-deepseek/src/utils/config.ts +103 -0
  74. package/connectors/connect-deepseek/src/utils/output.ts +119 -0
  75. package/connectors/connect-deepseek/tsconfig.json +16 -0
  76. package/connectors/connect-fal/.env.example +11 -0
  77. package/connectors/connect-fal/CLAUDE.md +128 -0
  78. package/connectors/connect-fal/README.md +193 -0
  79. package/connectors/connect-fal/package.json +51 -0
  80. package/connectors/connect-fal/src/api/client.ts +172 -0
  81. package/connectors/connect-fal/src/api/index.ts +55 -0
  82. package/connectors/connect-fal/src/cli/index.ts +341 -0
  83. package/connectors/connect-fal/src/index.ts +19 -0
  84. package/connectors/connect-fal/src/types/index.ts +135 -0
  85. package/connectors/connect-fal/src/utils/config.ts +103 -0
  86. package/connectors/connect-fal/src/utils/output.ts +119 -0
  87. package/connectors/connect-fal/tsconfig.json +16 -0
  88. package/connectors/connect-fireworks/.env.example +11 -0
  89. package/connectors/connect-fireworks/CLAUDE.md +128 -0
  90. package/connectors/connect-fireworks/README.md +193 -0
  91. package/connectors/connect-fireworks/package.json +51 -0
  92. package/connectors/connect-fireworks/src/api/client.ts +63 -0
  93. package/connectors/connect-fireworks/src/api/index.ts +36 -0
  94. package/connectors/connect-fireworks/src/cli/index.ts +244 -0
  95. package/connectors/connect-fireworks/src/index.ts +19 -0
  96. package/connectors/connect-fireworks/src/types/index.ts +70 -0
  97. package/connectors/connect-fireworks/src/utils/config.ts +103 -0
  98. package/connectors/connect-fireworks/src/utils/output.ts +119 -0
  99. package/connectors/connect-fireworks/tsconfig.json +16 -0
  100. package/connectors/connect-groq/.env.example +11 -0
  101. package/connectors/connect-groq/CLAUDE.md +128 -0
  102. package/connectors/connect-groq/README.md +193 -0
  103. package/connectors/connect-groq/package.json +52 -0
  104. package/connectors/connect-groq/src/api/client.ts +108 -0
  105. package/connectors/connect-groq/src/api/index.ts +36 -0
  106. package/connectors/connect-groq/src/cli/index.ts +171 -0
  107. package/connectors/connect-groq/src/index.ts +19 -0
  108. package/connectors/connect-groq/src/types/index.ts +69 -0
  109. package/connectors/connect-groq/src/utils/config.ts +103 -0
  110. package/connectors/connect-groq/src/utils/output.ts +119 -0
  111. package/connectors/connect-groq/tsconfig.json +16 -0
  112. package/connectors/connect-luma/.env.example +11 -0
  113. package/connectors/connect-luma/CLAUDE.md +128 -0
  114. package/connectors/connect-luma/README.md +193 -0
  115. package/connectors/connect-luma/package.json +53 -0
  116. package/connectors/connect-luma/src/api/client.ts +85 -0
  117. package/connectors/connect-luma/src/api/index.ts +44 -0
  118. package/connectors/connect-luma/src/cli/index.ts +300 -0
  119. package/connectors/connect-luma/src/index.ts +19 -0
  120. package/connectors/connect-luma/src/types/index.ts +60 -0
  121. package/connectors/connect-luma/src/utils/config.ts +103 -0
  122. package/connectors/connect-luma/src/utils/output.ts +119 -0
  123. package/connectors/connect-luma/tsconfig.json +16 -0
  124. package/connectors/connect-modal/.env.example +11 -0
  125. package/connectors/connect-modal/CLAUDE.md +128 -0
  126. package/connectors/connect-modal/README.md +193 -0
  127. package/connectors/connect-modal/package.json +51 -0
  128. package/connectors/connect-modal/src/api/client.ts +119 -0
  129. package/connectors/connect-modal/src/api/index.ts +69 -0
  130. package/connectors/connect-modal/src/cli/index.ts +224 -0
  131. package/connectors/connect-modal/src/index.ts +21 -0
  132. package/connectors/connect-modal/src/types/index.ts +60 -0
  133. package/connectors/connect-modal/src/utils/config.ts +114 -0
  134. package/connectors/connect-modal/src/utils/output.ts +119 -0
  135. package/connectors/connect-modal/tsconfig.json +16 -0
  136. package/connectors/connect-perplexity/.env.example +4 -0
  137. package/connectors/connect-perplexity/CLAUDE.md +156 -0
  138. package/connectors/connect-perplexity/README.md +184 -0
  139. package/connectors/connect-perplexity/package.json +58 -0
  140. package/connectors/connect-perplexity/scripts/publish.ts +210 -0
  141. package/connectors/connect-perplexity/src/api/client.ts +119 -0
  142. package/connectors/connect-perplexity/src/api/example.ts +118 -0
  143. package/connectors/connect-perplexity/src/api/index.ts +48 -0
  144. package/connectors/connect-perplexity/src/cli/index.ts +421 -0
  145. package/connectors/connect-perplexity/src/index.ts +24 -0
  146. package/connectors/connect-perplexity/src/types/index.ts +140 -0
  147. package/connectors/connect-perplexity/src/utils/config.ts +208 -0
  148. package/connectors/connect-perplexity/src/utils/output.ts +119 -0
  149. package/connectors/connect-perplexity/tsconfig.json +16 -0
  150. package/connectors/connect-replicate/.env.example +11 -0
  151. package/connectors/connect-replicate/CLAUDE.md +128 -0
  152. package/connectors/connect-replicate/README.md +193 -0
  153. package/connectors/connect-replicate/package.json +51 -0
  154. package/connectors/connect-replicate/src/api/client.ts +109 -0
  155. package/connectors/connect-replicate/src/api/index.ts +71 -0
  156. package/connectors/connect-replicate/src/cli/index.ts +250 -0
  157. package/connectors/connect-replicate/src/index.ts +19 -0
  158. package/connectors/connect-replicate/src/types/index.ts +85 -0
  159. package/connectors/connect-replicate/src/utils/config.ts +103 -0
  160. package/connectors/connect-replicate/src/utils/output.ts +119 -0
  161. package/connectors/connect-replicate/tsconfig.json +16 -0
  162. package/connectors/connect-roboflow/.env.example +11 -0
  163. package/connectors/connect-roboflow/CLAUDE.md +272 -0
  164. package/connectors/connect-roboflow/README.md +193 -0
  165. package/connectors/connect-roboflow/package.json +51 -0
  166. package/connectors/connect-roboflow/scripts/release.ts +179 -0
  167. package/connectors/connect-roboflow/src/api/client.ts +213 -0
  168. package/connectors/connect-roboflow/src/api/example.ts +48 -0
  169. package/connectors/connect-roboflow/src/api/index.ts +51 -0
  170. package/connectors/connect-roboflow/src/cli/index.ts +254 -0
  171. package/connectors/connect-roboflow/src/index.ts +103 -0
  172. package/connectors/connect-roboflow/src/types/index.ts +237 -0
  173. package/connectors/connect-roboflow/src/utils/auth.ts +274 -0
  174. package/connectors/connect-roboflow/src/utils/bulk.ts +212 -0
  175. package/connectors/connect-roboflow/src/utils/config.ts +326 -0
  176. package/connectors/connect-roboflow/src/utils/output.ts +175 -0
  177. package/connectors/connect-roboflow/src/utils/settings.ts +114 -0
  178. package/connectors/connect-roboflow/src/utils/storage.ts +198 -0
  179. package/connectors/connect-roboflow/tsconfig.json +16 -0
  180. package/connectors/connect-runway/.env.example +11 -0
  181. package/connectors/connect-runway/CLAUDE.md +128 -0
  182. package/connectors/connect-runway/README.md +193 -0
  183. package/connectors/connect-runway/package.json +52 -0
  184. package/connectors/connect-runway/src/api/client.ts +78 -0
  185. package/connectors/connect-runway/src/api/index.ts +40 -0
  186. package/connectors/connect-runway/src/cli/index.ts +283 -0
  187. package/connectors/connect-runway/src/index.ts +19 -0
  188. package/connectors/connect-runway/src/types/index.ts +52 -0
  189. package/connectors/connect-runway/src/utils/config.ts +103 -0
  190. package/connectors/connect-runway/src/utils/output.ts +119 -0
  191. package/connectors/connect-runway/tsconfig.json +16 -0
  192. package/connectors/connect-together/.env.example +11 -0
  193. package/connectors/connect-together/CLAUDE.md +128 -0
  194. package/connectors/connect-together/README.md +193 -0
  195. package/connectors/connect-together/package.json +52 -0
  196. package/connectors/connect-together/src/api/client.ts +106 -0
  197. package/connectors/connect-together/src/api/index.ts +47 -0
  198. package/connectors/connect-together/src/cli/index.ts +228 -0
  199. package/connectors/connect-together/src/index.ts +19 -0
  200. package/connectors/connect-together/src/types/index.ts +91 -0
  201. package/connectors/connect-together/src/utils/config.ts +142 -0
  202. package/connectors/connect-together/src/utils/output.ts +119 -0
  203. package/connectors/connect-together/tsconfig.json +16 -0
  204. package/dist/index.js +112 -0
  205. package/package.json +1 -1
@@ -0,0 +1,40 @@
1
+ import type { RunwayConfig, ImageToVideoRequest, TextToVideoRequest, VideoTask, TaskResponse } from '../types';
2
+ import { RunwayClient } from './client';
3
+
4
+ export class Runway {
5
+ private readonly client: RunwayClient;
6
+
7
+ constructor(config: RunwayConfig) {
8
+ this.client = new RunwayClient(config);
9
+ }
10
+
11
+ async imageToVideo(params: ImageToVideoRequest): Promise<TaskResponse> {
12
+ return this.client.imageToVideo(params);
13
+ }
14
+
15
+ async textToVideo(params: TextToVideoRequest): Promise<TaskResponse> {
16
+ return this.client.textToVideo(params);
17
+ }
18
+
19
+ async getTask(taskId: string): Promise<VideoTask> {
20
+ return this.client.getTask(taskId);
21
+ }
22
+
23
+ async cancelTask(taskId: string): Promise<void> {
24
+ return this.client.cancelTask(taskId);
25
+ }
26
+
27
+ static fromEnv(): Runway {
28
+ const apiKey = process.env.RUNWAY_API_KEY || process.env.RUNWAYML_API_SECRET;
29
+ if (!apiKey) {
30
+ throw new Error('RUNWAY_API_KEY environment variable is required');
31
+ }
32
+ return new Runway({ apiKey });
33
+ }
34
+
35
+ getApiKeyPreview(): string {
36
+ return this.client.getApiKeyPreview();
37
+ }
38
+ }
39
+
40
+ export { RunwayClient } from './client';
@@ -0,0 +1,283 @@
1
+ #!/usr/bin/env bun
2
+ import { Command } from 'commander';
3
+ import chalk from 'chalk';
4
+ import { Runway } from '../api';
5
+ import {
6
+ getApiKey,
7
+ setApiKey,
8
+ clearConfig,
9
+ getConfigDir,
10
+ setProfileOverride,
11
+ getCurrentProfile,
12
+ setCurrentProfile,
13
+ listProfiles,
14
+ createProfile,
15
+ deleteProfile,
16
+ profileExists,
17
+ loadProfile,
18
+ } from '../utils/config';
19
+ import type { OutputFormat } from '../utils/output';
20
+ import { success, error, info, print } from '../utils/output';
21
+
22
+ const CONNECTOR_NAME = 'connect-runway';
23
+ const VERSION = '0.0.1';
24
+
25
+ const program = new Command();
26
+
27
+ program
28
+ .name(CONNECTOR_NAME)
29
+ .description('Runway connector CLI - AI video generation with multi-profile support')
30
+ .version(VERSION)
31
+ .option('-k, --api-key <key>', 'API key (overrides config)')
32
+ .option('-f, --format <format>', 'Output format (json, pretty)', 'pretty')
33
+ .option('-p, --profile <profile>', 'Use a specific profile')
34
+ .hook('preAction', (thisCommand) => {
35
+ const opts = thisCommand.opts();
36
+ if (opts.profile) {
37
+ if (!profileExists(opts.profile)) {
38
+ error(`Profile "${opts.profile}" does not exist. Create it with "${CONNECTOR_NAME} profile create ${opts.profile}"`);
39
+ process.exit(1);
40
+ }
41
+ setProfileOverride(opts.profile);
42
+ }
43
+ if (opts.apiKey) {
44
+ process.env.RUNWAY_API_KEY = opts.apiKey;
45
+ }
46
+ });
47
+
48
+ function getFormat(cmd: Command): OutputFormat {
49
+ const parent = cmd.parent;
50
+ return (parent?.opts().format || 'pretty') as OutputFormat;
51
+ }
52
+
53
+ function getClient(): Runway {
54
+ const apiKey = getApiKey();
55
+ if (!apiKey) {
56
+ error(`No API key configured. Run "${CONNECTOR_NAME} config set-key <key>" or set RUNWAY_API_KEY environment variable.`);
57
+ process.exit(1);
58
+ }
59
+ return new Runway({ apiKey });
60
+ }
61
+
62
+ // ============================================
63
+ // Profile Commands
64
+ // ============================================
65
+ const profileCmd = program
66
+ .command('profile')
67
+ .description('Manage configuration profiles');
68
+
69
+ profileCmd
70
+ .command('list')
71
+ .description('List all profiles')
72
+ .action(() => {
73
+ const profiles = listProfiles();
74
+ const current = getCurrentProfile();
75
+ if (profiles.length === 0) {
76
+ info('No profiles found. Use "profile create <name>" to create one.');
77
+ return;
78
+ }
79
+ success(`Profiles:`);
80
+ profiles.forEach(p => {
81
+ const isActive = p === current ? chalk.green(' (active)') : '';
82
+ console.log(` ${p}${isActive}`);
83
+ });
84
+ });
85
+
86
+ profileCmd
87
+ .command('use <name>')
88
+ .description('Switch to a profile')
89
+ .action((name: string) => {
90
+ if (!profileExists(name)) {
91
+ error(`Profile "${name}" does not exist. Create it with "profile create ${name}"`);
92
+ process.exit(1);
93
+ }
94
+ setCurrentProfile(name);
95
+ success(`Switched to profile: ${name}`);
96
+ });
97
+
98
+ profileCmd
99
+ .command('create <name>')
100
+ .description('Create a new profile')
101
+ .option('--api-key <key>', 'API key')
102
+ .option('--use', 'Switch to this profile after creation')
103
+ .action((name: string, opts) => {
104
+ if (profileExists(name)) {
105
+ error(`Profile "${name}" already exists`);
106
+ process.exit(1);
107
+ }
108
+ createProfile(name, { apiKey: opts.apiKey });
109
+ success(`Profile "${name}" created`);
110
+ if (opts.use) {
111
+ setCurrentProfile(name);
112
+ info(`Switched to profile: ${name}`);
113
+ }
114
+ });
115
+
116
+ profileCmd
117
+ .command('delete <name>')
118
+ .description('Delete a profile')
119
+ .action((name: string) => {
120
+ if (name === 'default') {
121
+ error('Cannot delete the default profile');
122
+ process.exit(1);
123
+ }
124
+ if (deleteProfile(name)) {
125
+ success(`Profile "${name}" deleted`);
126
+ } else {
127
+ error(`Profile "${name}" not found`);
128
+ process.exit(1);
129
+ }
130
+ });
131
+
132
+ profileCmd
133
+ .command('show [name]')
134
+ .description('Show profile configuration')
135
+ .action((name?: string) => {
136
+ const profileName = name || getCurrentProfile();
137
+ const config = loadProfile(profileName);
138
+ const active = getCurrentProfile();
139
+ console.log(chalk.bold(`Profile: ${profileName}${profileName === active ? chalk.green(' (active)') : ''}`));
140
+ info(`API Key: ${config.apiKey ? `${config.apiKey.substring(0, 8)}...` : chalk.gray('not set')}`);
141
+ });
142
+
143
+ // ============================================
144
+ // Config Commands
145
+ // ============================================
146
+ const configCmd = program
147
+ .command('config')
148
+ .description('Manage CLI configuration (for active profile)');
149
+
150
+ configCmd
151
+ .command('set-key <apiKey>')
152
+ .description('Set API key')
153
+ .action((apiKey: string) => {
154
+ setApiKey(apiKey);
155
+ success(`API key saved to profile: ${getCurrentProfile()}`);
156
+ });
157
+
158
+ configCmd
159
+ .command('show')
160
+ .description('Show current configuration')
161
+ .action(() => {
162
+ const profileName = getCurrentProfile();
163
+ const apiKey = getApiKey();
164
+ console.log(chalk.bold(`Active Profile: ${profileName}`));
165
+ info(`Config directory: ${getConfigDir()}`);
166
+ info(`API Key: ${apiKey ? `${apiKey.substring(0, 8)}...` : chalk.gray('not set')}`);
167
+ });
168
+
169
+ configCmd
170
+ .command('clear')
171
+ .description('Clear configuration for active profile')
172
+ .action(() => {
173
+ clearConfig();
174
+ success(`Configuration cleared for profile: ${getCurrentProfile()}`);
175
+ });
176
+
177
+ // ============================================
178
+ // Video Commands
179
+ // ============================================
180
+ const videoCmd = program
181
+ .command('video')
182
+ .description('Video generation commands');
183
+
184
+ videoCmd
185
+ .command('generate')
186
+ .description('Generate video from image or text')
187
+ .option('-m, --model <model>', 'Model to use', 'gen3a_turbo')
188
+ .option('-i, --image <url>', 'Image URL for image-to-video')
189
+ .option('-t, --text <prompt>', 'Text prompt')
190
+ .option('-d, --duration <seconds>', 'Duration in seconds', '5')
191
+ .option('-r, --ratio <ratio>', 'Aspect ratio', '16:9')
192
+ .option('-s, --seed <seed>', 'Random seed')
193
+ .action(async (opts) => {
194
+ try {
195
+ const client = getClient();
196
+ let result;
197
+
198
+ if (opts.image) {
199
+ result = await client.imageToVideo({
200
+ model: opts.model,
201
+ promptImage: opts.image,
202
+ promptText: opts.text,
203
+ duration: parseInt(opts.duration),
204
+ ratio: opts.ratio,
205
+ seed: opts.seed ? parseInt(opts.seed) : undefined,
206
+ });
207
+ } else if (opts.text) {
208
+ result = await client.textToVideo({
209
+ model: opts.model,
210
+ promptText: opts.text,
211
+ duration: parseInt(opts.duration),
212
+ ratio: opts.ratio,
213
+ seed: opts.seed ? parseInt(opts.seed) : undefined,
214
+ });
215
+ } else {
216
+ error('Either --image or --text is required');
217
+ process.exit(1);
218
+ }
219
+
220
+ const format = getFormat(videoCmd);
221
+ if (format === 'json') {
222
+ print(result, format);
223
+ } else {
224
+ success(`Task created: ${result.id}`);
225
+ info(`Check status with: ${CONNECTOR_NAME} task get ${result.id}`);
226
+ }
227
+ } catch (err) {
228
+ error(String(err));
229
+ process.exit(1);
230
+ }
231
+ });
232
+
233
+ // ============================================
234
+ // Task Commands
235
+ // ============================================
236
+ const taskCmd = program
237
+ .command('task')
238
+ .description('Manage video generation tasks');
239
+
240
+ taskCmd
241
+ .command('get <taskId>')
242
+ .description('Get task status')
243
+ .action(async (taskId: string) => {
244
+ try {
245
+ const client = getClient();
246
+ const result = await client.getTask(taskId);
247
+ const format = getFormat(taskCmd);
248
+ if (format === 'json') {
249
+ print(result, format);
250
+ } else {
251
+ console.log(chalk.bold(`Task: ${result.id}`));
252
+ info(`Status: ${result.status}`);
253
+ if (result.progress !== undefined) {
254
+ info(`Progress: ${result.progress}%`);
255
+ }
256
+ if (result.output && result.output.length > 0) {
257
+ success(`Output: ${result.output.join(', ')}`);
258
+ }
259
+ if (result.failure) {
260
+ error(`Failure: ${result.failure}`);
261
+ }
262
+ }
263
+ } catch (err) {
264
+ error(String(err));
265
+ process.exit(1);
266
+ }
267
+ });
268
+
269
+ taskCmd
270
+ .command('cancel <taskId>')
271
+ .description('Cancel a task')
272
+ .action(async (taskId: string) => {
273
+ try {
274
+ const client = getClient();
275
+ await client.cancelTask(taskId);
276
+ success(`Task ${taskId} cancelled`);
277
+ } catch (err) {
278
+ error(String(err));
279
+ process.exit(1);
280
+ }
281
+ });
282
+
283
+ program.parse();
@@ -0,0 +1,19 @@
1
+ // Runway Connector
2
+ // TypeScript wrapper for Runway API
3
+
4
+ export { Runway } from './api';
5
+ export * from './types';
6
+ export { RunwayClient } from './api';
7
+
8
+ export {
9
+ getApiKey,
10
+ setApiKey,
11
+ getCurrentProfile,
12
+ setCurrentProfile,
13
+ listProfiles,
14
+ createProfile,
15
+ deleteProfile,
16
+ loadProfile,
17
+ saveProfile,
18
+ clearConfig,
19
+ } from './utils/config';
@@ -0,0 +1,52 @@
1
+ // Runway API Types
2
+
3
+ export interface RunwayConfig {
4
+ apiKey: string;
5
+ baseUrl?: string;
6
+ }
7
+
8
+ export interface ImageToVideoRequest {
9
+ model: string;
10
+ promptImage: string;
11
+ promptText?: string;
12
+ seed?: number;
13
+ duration?: number;
14
+ ratio?: string;
15
+ }
16
+
17
+ export interface TextToVideoRequest {
18
+ model: string;
19
+ promptText: string;
20
+ seed?: number;
21
+ duration?: number;
22
+ ratio?: string;
23
+ }
24
+
25
+ export interface VideoTask {
26
+ id: string;
27
+ status: 'PENDING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED';
28
+ createdAt: string;
29
+ progress?: number;
30
+ output?: string[];
31
+ failure?: string;
32
+ failureCode?: string;
33
+ }
34
+
35
+ export interface TaskResponse {
36
+ id: string;
37
+ }
38
+
39
+ export interface TaskListResponse {
40
+ tasks: VideoTask[];
41
+ }
42
+
43
+ export class RunwayApiError extends Error {
44
+ constructor(
45
+ message: string,
46
+ public readonly status: number,
47
+ public readonly code?: string
48
+ ) {
49
+ super(message);
50
+ this.name = 'RunwayApiError';
51
+ }
52
+ }
@@ -0,0 +1,103 @@
1
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync } from 'fs';
2
+ import { homedir } from 'os';
3
+ import { join } from 'path';
4
+
5
+ const CONNECTOR_NAME = 'connect-runway';
6
+ const DEFAULT_PROFILE = 'default';
7
+
8
+ export interface ProfileConfig {
9
+ apiKey?: string;
10
+ }
11
+
12
+ let profileOverride: string | undefined;
13
+
14
+ const CONFIG_DIR = join(homedir(), '.connect', CONNECTOR_NAME);
15
+ const PROFILES_DIR = join(CONFIG_DIR, 'profiles');
16
+ const CURRENT_PROFILE_FILE = join(CONFIG_DIR, 'current_profile');
17
+
18
+ export function setProfileOverride(profile: string | undefined): void {
19
+ profileOverride = profile;
20
+ }
21
+
22
+ export function ensureConfigDir(): void {
23
+ if (!existsSync(CONFIG_DIR)) mkdirSync(CONFIG_DIR, { recursive: true });
24
+ if (!existsSync(PROFILES_DIR)) mkdirSync(PROFILES_DIR, { recursive: true });
25
+ }
26
+
27
+ function getProfilePath(profile: string): string {
28
+ return join(PROFILES_DIR, `${profile}.json`);
29
+ }
30
+
31
+ export function getCurrentProfile(): string {
32
+ if (profileOverride) return profileOverride;
33
+ ensureConfigDir();
34
+ if (existsSync(CURRENT_PROFILE_FILE)) {
35
+ try {
36
+ const profile = readFileSync(CURRENT_PROFILE_FILE, 'utf-8').trim();
37
+ if (profile && profileExists(profile)) return profile;
38
+ } catch { /* fall through */ }
39
+ }
40
+ return DEFAULT_PROFILE;
41
+ }
42
+
43
+ export function setCurrentProfile(profile: string): void {
44
+ ensureConfigDir();
45
+ if (!profileExists(profile) && profile !== DEFAULT_PROFILE) {
46
+ throw new Error(`Profile "${profile}" does not exist`);
47
+ }
48
+ writeFileSync(CURRENT_PROFILE_FILE, profile);
49
+ }
50
+
51
+ export function profileExists(profile: string): boolean {
52
+ return existsSync(getProfilePath(profile));
53
+ }
54
+
55
+ export function listProfiles(): string[] {
56
+ ensureConfigDir();
57
+ if (!existsSync(PROFILES_DIR)) return [];
58
+ return readdirSync(PROFILES_DIR).filter(f => f.endsWith('.json')).map(f => f.replace('.json', '')).sort();
59
+ }
60
+
61
+ export function createProfile(profile: string, config: ProfileConfig = {}): boolean {
62
+ ensureConfigDir();
63
+ if (profileExists(profile)) return false;
64
+ if (!/^[a-zA-Z0-9_-]+$/.test(profile)) {
65
+ throw new Error('Profile name can only contain letters, numbers, hyphens, and underscores');
66
+ }
67
+ writeFileSync(getProfilePath(profile), JSON.stringify(config, null, 2));
68
+ return true;
69
+ }
70
+
71
+ export function deleteProfile(profile: string): boolean {
72
+ if (profile === DEFAULT_PROFILE) return false;
73
+ if (!profileExists(profile)) return false;
74
+ if (getCurrentProfile() === profile) setCurrentProfile(DEFAULT_PROFILE);
75
+ rmSync(getProfilePath(profile));
76
+ return true;
77
+ }
78
+
79
+ export function loadProfile(profile?: string): ProfileConfig {
80
+ ensureConfigDir();
81
+ const profilePath = getProfilePath(profile || getCurrentProfile());
82
+ if (!existsSync(profilePath)) return {};
83
+ try { return JSON.parse(readFileSync(profilePath, 'utf-8')); } catch { return {}; }
84
+ }
85
+
86
+ export function saveProfile(config: ProfileConfig, profile?: string): void {
87
+ ensureConfigDir();
88
+ writeFileSync(getProfilePath(profile || getCurrentProfile()), JSON.stringify(config, null, 2));
89
+ }
90
+
91
+ export function getApiKey(): string | undefined {
92
+ return process.env.RUNWAY_API_KEY || process.env.RUNWAYML_API_SECRET || loadProfile().apiKey;
93
+ }
94
+
95
+ export function setApiKey(apiKey: string): void {
96
+ const config = loadProfile();
97
+ config.apiKey = apiKey;
98
+ saveProfile(config);
99
+ }
100
+
101
+ export function clearConfig(): void { saveProfile({}); }
102
+ export function getConfigDir(): string { return CONFIG_DIR; }
103
+ export function getActiveProfileName(): string { return getCurrentProfile(); }
@@ -0,0 +1,119 @@
1
+ import chalk from 'chalk';
2
+
3
+ export type OutputFormat = 'json' | 'table' | 'pretty';
4
+
5
+ export function formatOutput(data: unknown, format: OutputFormat = 'pretty'): string {
6
+ switch (format) {
7
+ case 'json':
8
+ return JSON.stringify(data, null, 2);
9
+ case 'table':
10
+ return formatAsTable(data);
11
+ case 'pretty':
12
+ default:
13
+ return formatPretty(data);
14
+ }
15
+ }
16
+
17
+ function formatAsTable(data: unknown): string {
18
+ if (!Array.isArray(data)) {
19
+ data = [data];
20
+ }
21
+
22
+ const items = data as Record<string, unknown>[];
23
+ if (items.length === 0) {
24
+ return 'No data';
25
+ }
26
+
27
+ const firstItem = items[0];
28
+ if (!firstItem || typeof firstItem !== 'object') {
29
+ return 'No data';
30
+ }
31
+
32
+ const keys = Object.keys(firstItem);
33
+ const colWidths = keys.map(key => {
34
+ const maxValue = Math.max(
35
+ key.length,
36
+ ...items.map(item => String(item[key] ?? '').length)
37
+ );
38
+ return Math.min(maxValue, 40);
39
+ });
40
+
41
+ const header = keys.map((key, i) => key.padEnd(colWidths[i] ?? 10)).join(' | ');
42
+ const separator = colWidths.map(w => '-'.repeat(w)).join('-+-');
43
+
44
+ const rows = items.map(item =>
45
+ keys.map((key, i) => {
46
+ const value = String(item[key] ?? '');
47
+ const width = colWidths[i] ?? 10;
48
+ return value.length > width
49
+ ? value.substring(0, width - 3) + '...'
50
+ : value.padEnd(width);
51
+ }).join(' | ')
52
+ );
53
+
54
+ return [header, separator, ...rows].join('\n');
55
+ }
56
+
57
+ function formatPretty(data: unknown): string {
58
+ if (Array.isArray(data)) {
59
+ return data.map((item, i) => `${chalk.cyan(`[${i + 1}]`)} ${formatPrettyItem(item)}`).join('\n\n');
60
+ }
61
+ return formatPrettyItem(data);
62
+ }
63
+
64
+ function formatPrettyItem(item: unknown, indent = 0): string {
65
+ if (item === null || item === undefined) {
66
+ return chalk.gray('null');
67
+ }
68
+
69
+ if (typeof item !== 'object') {
70
+ return String(item);
71
+ }
72
+
73
+ const spaces = ' '.repeat(indent);
74
+ const entries = Object.entries(item as Record<string, unknown>);
75
+
76
+ return entries
77
+ .map(([key, value]) => {
78
+ if (Array.isArray(value)) {
79
+ if (value.length === 0) {
80
+ return `${spaces}${chalk.blue(key)}: ${chalk.gray('[]')}`;
81
+ }
82
+ if (typeof value[0] === 'object') {
83
+ return `${spaces}${chalk.blue(key)}:\n${value.map(v => formatPrettyItem(v, indent + 1)).join('\n')}`;
84
+ }
85
+ return `${spaces}${chalk.blue(key)}: ${value.join(', ')}`;
86
+ }
87
+
88
+ if (typeof value === 'object' && value !== null) {
89
+ return `${spaces}${chalk.blue(key)}:\n${formatPrettyItem(value, indent + 1)}`;
90
+ }
91
+
92
+ return `${spaces}${chalk.blue(key)}: ${chalk.white(String(value))}`;
93
+ })
94
+ .join('\n');
95
+ }
96
+
97
+ export function success(message: string): void {
98
+ console.log(chalk.green('✓'), message);
99
+ }
100
+
101
+ export function error(message: string): void {
102
+ console.error(chalk.red('✗'), message);
103
+ }
104
+
105
+ export function warn(message: string): void {
106
+ console.warn(chalk.yellow('⚠'), message);
107
+ }
108
+
109
+ export function info(message: string): void {
110
+ console.log(chalk.blue('ℹ'), message);
111
+ }
112
+
113
+ export function heading(message: string): void {
114
+ console.log(chalk.bold.cyan(`\n${message}\n`));
115
+ }
116
+
117
+ export function print(data: unknown, format: OutputFormat = 'pretty'): void {
118
+ console.log(formatOutput(data, format));
119
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "declaration": true,
10
+ "outDir": "./dist",
11
+ "rootDir": "./src",
12
+ "types": ["bun-types"]
13
+ },
14
+ "include": ["src/**/*"],
15
+ "exclude": ["node_modules", "dist", "bin"]
16
+ }
@@ -0,0 +1,11 @@
1
+ # API Credentials
2
+ # TODO: Update variable names and instructions for your API
3
+ # Example: PERPLEXITY_API_KEY, OPENAI_API_KEY, etc.
4
+
5
+ CONNECTOR_API_KEY=your-api-key-here
6
+
7
+ # Optional: API secret (if your API requires it)
8
+ # CONNECTOR_API_SECRET=your-api-secret-here
9
+
10
+ # Optional: Custom base URL (if needed)
11
+ # CONNECTOR_BASE_URL=https://api.example.com