@ebowwa/codespaces-types 1.1.0 → 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.
Files changed (67) hide show
  1. package/{dist/compile → compile}/index.js +41 -15
  2. package/compile/index.ts +553 -0
  3. package/compile/resources.js +116 -0
  4. package/compile/resources.ts +157 -0
  5. package/compile/schemas/resources.js +127 -0
  6. package/compile/schemas/resources.ts +144 -0
  7. package/{dist/compile → compile}/terminal-websocket.js +4 -1
  8. package/compile/terminal-websocket.ts +133 -0
  9. package/compile/time.js +30 -0
  10. package/compile/time.ts +32 -0
  11. package/{dist/compile → compile}/user/distributions.js +0 -1
  12. package/{dist/compile/user/distributions.d.ts → compile/user/distributions.ts} +0 -1
  13. package/{dist/compile → compile}/validation.js +23 -17
  14. package/compile/validation.ts +98 -0
  15. package/index.js +21 -0
  16. package/index.ts +5 -0
  17. package/package.json +38 -45
  18. package/runtime/ai.js +505 -0
  19. package/runtime/ai.ts +501 -0
  20. package/runtime/api.js +677 -0
  21. package/runtime/api.ts +857 -0
  22. package/runtime/database.js +94 -0
  23. package/runtime/database.ts +107 -0
  24. package/runtime/env.js +63 -0
  25. package/runtime/env.ts +68 -0
  26. package/{dist/runtime → runtime}/glm.js +7 -4
  27. package/runtime/glm.ts +36 -0
  28. package/runtime/index.js +28 -0
  29. package/{dist/runtime/index.js → runtime/index.ts} +1 -0
  30. package/runtime/ssh.js +47 -0
  31. package/runtime/ssh.ts +58 -0
  32. package/README.md +0 -65
  33. package/dist/compile/index.d.ts +0 -437
  34. package/dist/compile/index.d.ts.map +0 -1
  35. package/dist/compile/resources.d.ts +0 -69
  36. package/dist/compile/resources.d.ts.map +0 -1
  37. package/dist/compile/resources.js +0 -113
  38. package/dist/compile/schemas/resources.d.ts +0 -166
  39. package/dist/compile/schemas/resources.d.ts.map +0 -1
  40. package/dist/compile/schemas/resources.js +0 -123
  41. package/dist/compile/terminal-websocket.d.ts +0 -109
  42. package/dist/compile/terminal-websocket.d.ts.map +0 -1
  43. package/dist/compile/time.d.ts +0 -7
  44. package/dist/compile/time.d.ts.map +0 -1
  45. package/dist/compile/time.js +0 -27
  46. package/dist/compile/user/distributions.d.ts.map +0 -1
  47. package/dist/compile/validation.d.ts +0 -44
  48. package/dist/compile/validation.d.ts.map +0 -1
  49. package/dist/runtime/ai.d.ts +0 -1336
  50. package/dist/runtime/ai.d.ts.map +0 -1
  51. package/dist/runtime/ai.js +0 -416
  52. package/dist/runtime/api.d.ts +0 -1304
  53. package/dist/runtime/api.d.ts.map +0 -1
  54. package/dist/runtime/api.js +0 -673
  55. package/dist/runtime/database.d.ts +0 -376
  56. package/dist/runtime/database.d.ts.map +0 -1
  57. package/dist/runtime/database.js +0 -91
  58. package/dist/runtime/env.d.ts +0 -121
  59. package/dist/runtime/env.d.ts.map +0 -1
  60. package/dist/runtime/env.js +0 -54
  61. package/dist/runtime/glm.d.ts +0 -17
  62. package/dist/runtime/glm.d.ts.map +0 -1
  63. package/dist/runtime/index.d.ts +0 -13
  64. package/dist/runtime/index.d.ts.map +0 -1
  65. package/dist/runtime/ssh.d.ts +0 -111
  66. package/dist/runtime/ssh.d.ts.map +0 -1
  67. package/dist/runtime/ssh.js +0 -44
package/runtime/api.ts ADDED
@@ -0,0 +1,857 @@
1
+ /**
2
+ * Zod schemas for API request/response validation
3
+ */
4
+
5
+ import { GLMModelSchema } from "./glm.js";
6
+
7
+ import { z } from "zod";
8
+
9
+ /**
10
+ * Environment ID validation
11
+ */
12
+ export const EnvironmentIdSchema = z
13
+ .string()
14
+ .transform((val) => parseInt(val, 10))
15
+ .pipe(z.number().int().positive("Environment ID must be a positive integer"));
16
+
17
+ /**
18
+ * Create Environment Request
19
+ */
20
+ export const CreateEnvironmentRequestSchema = z.object({
21
+ name: z
22
+ .string()
23
+ .min(1, "Name is required")
24
+ .max(64, "Name must be 64 characters or less")
25
+ .regex(
26
+ /^[a-zA-Z0-9][a-zA-Z0-9-]*$/,
27
+ "Name must start with letter/number and contain only letters, numbers, and hyphens",
28
+ ),
29
+ serverType: z.string().min(1, "Server type is required"),
30
+ location: z.string().min(1, "Location is required"),
31
+ sshKeys: z.array(z.string()).optional(),
32
+ autoInstallSeed: z.boolean().default(false).optional(),
33
+ metadata: z
34
+ .object({
35
+ description: z.string().optional(),
36
+ project: z.string().optional(),
37
+ owner: z.string().optional(),
38
+ purpose: z.string().optional(),
39
+ environmentType: z
40
+ .enum(["development", "staging", "production", "testing"])
41
+ .optional(),
42
+ })
43
+ .optional(),
44
+ });
45
+
46
+ /**
47
+ * Update Metadata Request
48
+ */
49
+ export const UpdateMetadataRequestSchema = z.object({
50
+ description: z.string().optional(),
51
+ project: z.string().optional(),
52
+ owner: z.string().optional(),
53
+ purpose: z.string().optional(),
54
+ environmentType: z
55
+ .enum(["development", "staging", "production", "testing"])
56
+ .optional(),
57
+ });
58
+
59
+ /**
60
+ * Update Activity Request
61
+ */
62
+ export const UpdateActivityRequestSchema = z.object({
63
+ hoursActive: z.number().min(0).optional(),
64
+ lastActive: z.string().datetime().optional(),
65
+ activePorts: z
66
+ .array(
67
+ z.object({
68
+ port: z.number().int().min(1).max(65535),
69
+ protocol: z.enum(["tcp", "udp"]),
70
+ service: z.string().optional(),
71
+ state: z.enum(["open", "closed", "filtered"]),
72
+ }),
73
+ )
74
+ .optional(),
75
+ });
76
+
77
+ /**
78
+ * Update Plugins Request
79
+ */
80
+ export const UpdatePluginsRequestSchema = z.object({
81
+ plugins: z
82
+ .record(
83
+ z.string(),
84
+ z.object({
85
+ enabled: z.boolean(),
86
+ config: z.record(z.string(), z.any()).optional(),
87
+ }),
88
+ )
89
+ .optional(),
90
+ });
91
+
92
+ /**
93
+ * SSH Connection Request
94
+ */
95
+ export const SSHConnectionRequestSchema = z.object({
96
+ host: z.string().min(1, "Host is required"),
97
+ user: z.string().default("root").optional(),
98
+ });
99
+
100
+ /**
101
+ * SSH Test Request
102
+ */
103
+ export const SSHTestRequestSchema = z.object({
104
+ host: z.string().min(1, "Host is required"),
105
+ user: z.string().default("root").optional(),
106
+ port: z.number().int().positive().max(65535).default(22).optional(),
107
+ });
108
+
109
+ /**
110
+ * SSH Fingerprint Request
111
+ */
112
+ export const SSHFingerprintRequestSchema = z.object({
113
+ host: z.string().min(1, "Host is required"),
114
+ user: z.string().default("root").optional(),
115
+ port: z.number().int().positive().max(65535).default(22).optional(),
116
+ });
117
+
118
+ /**
119
+ * Terminal Create Session Request
120
+ */
121
+ export const TerminalCreateSessionSchema = z.object({
122
+ host: z.string().min(1, "Host is required"),
123
+ user: z.string().default("root").optional(),
124
+ port: z.number().int().positive().max(65535).default(22).optional(),
125
+ rows: z.number().int().positive().max(200).default(24).optional(),
126
+ cols: z.number().int().positive().max(500).default(80).optional(),
127
+ });
128
+
129
+ /**
130
+ * Terminal Resize Request
131
+ */
132
+ export const TerminalResizeSchema = z.object({
133
+ sessionId: z.string().min(1, "Session ID is required"),
134
+ rows: z.number().int().positive().max(200),
135
+ cols: z.number().int().positive().max(500),
136
+ });
137
+
138
+ /**
139
+ * SCP Upload Request
140
+ */
141
+ export const SCPUploadRequestSchema = z.object({
142
+ host: z.string().min(1, "Host is required"),
143
+ user: z.string().default("root").optional(),
144
+ source: z.string().min(1, "Source path is required"),
145
+ destination: z.string().min(1, "Destination path is required"),
146
+ recursive: z.boolean().default(false).optional(),
147
+ preserve: z.boolean().default(false).optional(),
148
+ });
149
+
150
+ /**
151
+ * SCP Download Request
152
+ */
153
+ export const SCPDownloadRequestSchema = z.object({
154
+ host: z.string().min(1, "Host is required"),
155
+ user: z.string().default("root").optional(),
156
+ source: z.string().min(1, "Source path is required"),
157
+ destination: z.string().min(1, "Destination path is required"),
158
+ recursive: z.boolean().default(false).optional(),
159
+ preserve: z.boolean().default(false).optional(),
160
+ });
161
+
162
+ /**
163
+ * Files List Request
164
+ */
165
+ export const FilesListRequestSchema = z.object({
166
+ host: z.string().min(1, "Host is required"),
167
+ user: z.string().default("root").optional(),
168
+ path: z.string().default(".").optional(),
169
+ });
170
+
171
+ /**
172
+ * Files Preview Request
173
+ */
174
+ export const FilesPreviewRequestSchema = z.object({
175
+ host: z.string().min(1, "Host is required"),
176
+ user: z.string().default("root").optional(),
177
+ path: z.string().min(1, "Path is required"),
178
+ });
179
+
180
+ /**
181
+ * SSH Key ID validation
182
+ */
183
+ export const SSHKeyIdSchema = z
184
+ .string()
185
+ .transform((val) => parseInt(val, 10))
186
+ .pipe(z.number().int().positive("SSH Key ID must be a positive integer"));
187
+
188
+ /**
189
+ * Create SSH Key Request
190
+ */
191
+ export const CreateSSHKeyRequestSchema = z.object({
192
+ name: z
193
+ .string()
194
+ .min(1, "Name is required")
195
+ .max(64, "Name must be 64 characters or less")
196
+ .regex(
197
+ /^[a-zA-Z0-9][a-zA-Z0-9-]*$/,
198
+ "Name must start with letter/number and contain only letters, numbers, and hyphens",
199
+ ),
200
+ public_key: z.string().min(1, "Public key is required"),
201
+ labels: z.record(z.string(), z.any()).optional(),
202
+ });
203
+
204
+ /**
205
+ * AI Generate Request
206
+ */
207
+ export const AIGenerateRequestSchema = z.object({
208
+ prompt: z.string().min(1, "Prompt is required"),
209
+ model: z.string().optional(), // Generic string for any AI provider
210
+ temperature: z.number().min(0).max(2).optional(),
211
+ maxTokens: z.number().int().positive().optional(),
212
+ });
213
+
214
+ /**
215
+ * AI Chat Request
216
+ */
217
+ export const AIChatRequestSchema = z.object({
218
+ messages: z.array(z.any()).min(1, "At least one message is required"),
219
+ model: z.string().optional(), // Generic string for any AI provider
220
+ temperature: z.number().min(0).max(2).optional(),
221
+ maxTokens: z.number().int().positive().optional(),
222
+ });
223
+
224
+ /**
225
+ * AI Suggest Name Request
226
+ */
227
+ export const AISuggestNameRequestSchema = z.object({
228
+ project: z.string().optional(),
229
+ description: z.string().optional(),
230
+ });
231
+
232
+ /**
233
+ * AI Suggest Server Type Request
234
+ */
235
+ export const AISuggestServerTypeRequestSchema = z.object({
236
+ workload: z.string().min(1, "Workload description is required"),
237
+ });
238
+
239
+ /**
240
+ * AI Analyze Resources Request
241
+ */
242
+ export const AIAnalyzeResourcesRequestSchema = z.object({
243
+ cpu: z.number().min(0).max(100),
244
+ memory: z.number().min(0).max(100),
245
+ disk: z.number().min(0).max(100),
246
+ });
247
+
248
+ /**
249
+ * AI Troubleshoot SSH Request
250
+ */
251
+ export const AITroubleshootSSHRequestSchema = z.object({
252
+ error: z.string().min(1, "Error message is required"),
253
+ });
254
+
255
+ /**
256
+ * AI Suggest Actions Request
257
+ */
258
+ export const AISuggestActionsRequestSchema = z.object({
259
+ status: z.string().min(1, "Status is required"),
260
+ age: z.string().optional(),
261
+ });
262
+
263
+ /**
264
+ * AI Status Message Request
265
+ */
266
+ export const AIStatusMessageRequestSchema = z.object({
267
+ status: z.string().min(1, "Status is required"),
268
+ name: z.string().min(1, "Name is required"),
269
+ });
270
+
271
+ /**
272
+ * Metrics Query Schema (for query parameters)
273
+ */
274
+ export const MetricsQuerySchema = z.object({
275
+ hours: z
276
+ .string()
277
+ .default("24")
278
+ .transform((val) => parseInt(val, 10))
279
+ .pipe(z.number().int().positive().max(8760)),
280
+ limit: z
281
+ .string()
282
+ .default("100")
283
+ .transform((val) => parseInt(val, 10))
284
+ .pipe(z.number().int().positive().max(1000)),
285
+ });
286
+
287
+ /**
288
+ * Insert Metric Request
289
+ */
290
+ export const InsertMetricRequestSchema = z.object({
291
+ environmentId: z.number().int().positive(),
292
+ cpuPercent: z.number().min(0).max(100),
293
+ memoryPercent: z.number().min(0).max(100),
294
+ memoryUsed: z.number().min(0),
295
+ memoryTotal: z.number().min(0),
296
+ diskPercent: z.number().min(0).max(100),
297
+ diskUsed: z.number().min(0),
298
+ diskTotal: z.number().min(0),
299
+ gpuPercent: z.number().min(0).max(100).optional(),
300
+ gpuMemoryUsed: z.number().min(0).optional(),
301
+ gpuMemoryTotal: z.number().min(0).optional(),
302
+ });
303
+
304
+ /**
305
+ * AI Analyze Historical Request
306
+ */
307
+ export const AIAnalyzeHistoricalRequestSchema = z.object({
308
+ environmentId: z.number().int().positive(),
309
+ hours: z.number().int().positive().max(8760).default(24),
310
+ });
311
+
312
+ /**
313
+ * Type exports for TypeScript inference
314
+ */
315
+ export type CreateEnvironmentRequest = z.infer<
316
+ typeof CreateEnvironmentRequestSchema
317
+ >;
318
+ export type UpdateMetadataRequest = z.infer<typeof UpdateMetadataRequestSchema>;
319
+ export type UpdateActivityRequest = z.infer<typeof UpdateActivityRequestSchema>;
320
+ export type UpdatePluginsRequest = z.infer<typeof UpdatePluginsRequestSchema>;
321
+ export type SSHConnectionRequest = z.infer<typeof SSHConnectionRequestSchema>;
322
+ export type SSHTestRequest = z.infer<typeof SSHTestRequestSchema>;
323
+ export type SSHFingerprintRequest = z.infer<typeof SSHFingerprintRequestSchema>;
324
+ export type SCPUploadRequest = z.infer<typeof SCPUploadRequestSchema>;
325
+ export type SCPDownloadRequest = z.infer<typeof SCPDownloadRequestSchema>;
326
+ export type FilesListRequest = z.infer<typeof FilesListRequestSchema>;
327
+ export type FilesPreviewRequest = z.infer<typeof FilesPreviewRequestSchema>;
328
+ export type AIGenerateRequest = z.infer<typeof AIGenerateRequestSchema>;
329
+ export type AIChatRequest = z.infer<typeof AIChatRequestSchema>;
330
+ export type AISuggestNameRequest = z.infer<typeof AISuggestNameRequestSchema>;
331
+ export type AISuggestServerTypeRequest = z.infer<
332
+ typeof AISuggestServerTypeRequestSchema
333
+ >;
334
+ export type AIAnalyzeResourcesRequest = z.infer<
335
+ typeof AIAnalyzeResourcesRequestSchema
336
+ >;
337
+ export type AITroubleshootSSHRequest = z.infer<
338
+ typeof AITroubleshootSSHRequestSchema
339
+ >;
340
+ export type AISuggestActionsRequest = z.infer<
341
+ typeof AISuggestActionsRequestSchema
342
+ >;
343
+ export type AIStatusMessageRequest = z.infer<
344
+ typeof AIStatusMessageRequestSchema
345
+ >;
346
+ export type InsertMetricRequest = z.infer<typeof InsertMetricRequestSchema>;
347
+ export type AIAnalyzeHistoricalRequest = z.infer<
348
+ typeof AIAnalyzeHistoricalRequestSchema
349
+ >;
350
+ export type TerminalCreateSession = z.infer<typeof TerminalCreateSessionSchema>;
351
+ export type TerminalResize = z.infer<typeof TerminalResizeSchema>;
352
+ export type SSHKeyId = z.infer<typeof SSHKeyIdSchema>;
353
+ export type CreateSSHKeyRequest = z.infer<typeof CreateSSHKeyRequestSchema>;
354
+
355
+ /**
356
+ * Seed Install Request
357
+ */
358
+ export const SeedInstallRequestSchema = z.object({
359
+ environmentId: z.string().min(1, "Environment ID is required"),
360
+ autoConfirm: z.boolean().default(true).optional(),
361
+ });
362
+
363
+ /**
364
+ * Seed Install Response (partial - actual response includes more fields)
365
+ */
366
+ export const SeedInstallResponseSchema = z.object({
367
+ success: z.boolean(),
368
+ cloned: z.boolean(),
369
+ setupRun: z.boolean(),
370
+ seedPath: z.string(),
371
+ error: z.string().optional(),
372
+ output: z.array(z.string()),
373
+ });
374
+
375
+ /**
376
+ * Seed Status Response
377
+ */
378
+ export const SeedStatusResponseSchema = z.object({
379
+ installed: z.boolean(),
380
+ setupComplete: z.boolean(),
381
+ version: z.string().optional(),
382
+ branch: z.string().optional(),
383
+ });
384
+
385
+ /**
386
+ * Login Commands Response
387
+ */
388
+ export const LoginCommandsResponseSchema = z.object({
389
+ ssh: z.string(),
390
+ web: z.string(),
391
+ claude: z.string(),
392
+ quick: z.string(),
393
+ });
394
+
395
+ export type SeedInstallRequest = z.infer<typeof SeedInstallRequestSchema>;
396
+ export type SeedInstallResponse = z.infer<typeof SeedInstallResponseSchema>;
397
+ export type SeedStatusResponse = z.infer<typeof SeedStatusResponseSchema>;
398
+ export type LoginCommandsResponse = z.infer<typeof LoginCommandsResponseSchema>;
399
+
400
+ // ============================================
401
+ // Volume Schemas
402
+ // ============================================
403
+
404
+ /**
405
+ * Volume ID validation
406
+ */
407
+ export const VolumeIdSchema = z
408
+ .string()
409
+ .transform((val) => parseInt(val, 10))
410
+ .pipe(z.number().int().positive("Volume ID must be a positive integer"));
411
+
412
+ /**
413
+ * Create Volume Request
414
+ */
415
+ export const CreateVolumeRequestSchema = z.object({
416
+ name: z
417
+ .string()
418
+ .min(1, "Name is required")
419
+ .max(64, "Name must be 64 characters or less")
420
+ .regex(
421
+ /^[a-zA-Z0-9][a-zA-Z0-9-]*$/,
422
+ "Name must start with letter/number and contain only letters, numbers, and hyphens",
423
+ ),
424
+ size: z
425
+ .number()
426
+ .int()
427
+ .positive("Size must be a positive integer")
428
+ .min(10, "Minimum volume size is 10 GB")
429
+ .max(10240, "Maximum volume size is 10 TB"),
430
+ server: z.string().optional(), // Server ID to attach to
431
+ location: z.string().optional(), // Location if not attaching to server
432
+ automount: z.boolean().default(true).optional(),
433
+ format: z.enum(["ext4", "xfs"]).optional(),
434
+ labels: z.record(z.string(), z.any()).optional(),
435
+ });
436
+
437
+ /**
438
+ * Update Volume Request
439
+ */
440
+ export const UpdateVolumeRequestSchema = z.object({
441
+ name: z.string().min(1).max(64).optional(),
442
+ labels: z.record(z.string(), z.any()).optional(),
443
+ });
444
+
445
+ /**
446
+ * Attach Volume Request
447
+ */
448
+ export const AttachVolumeRequestSchema = z.object({
449
+ volumeId: z.number().int().positive("Volume ID is required"),
450
+ serverId: z.number().int().positive("Server ID is required"),
451
+ automount: z.boolean().default(true).optional(),
452
+ });
453
+
454
+ /**
455
+ * Detach Volume Request
456
+ */
457
+ export const DetachVolumeRequestSchema = z.object({
458
+ volumeId: z.number().int().positive("Volume ID is required"),
459
+ });
460
+
461
+ /**
462
+ * Resize Volume Request
463
+ */
464
+ export const ResizeVolumeRequestSchema = z.object({
465
+ volumeId: z.number().int().positive("Volume ID is required"),
466
+ size: z
467
+ .number()
468
+ .int()
469
+ .positive("Size must be a positive integer")
470
+ .min(10, "Minimum volume size is 10 GB")
471
+ .max(10240, "Maximum volume size is 10 TB"),
472
+ });
473
+
474
+ /**
475
+ * Volume Protection Request
476
+ */
477
+ export const VolumeProtectionRequestSchema = z.object({
478
+ delete: z.boolean(),
479
+ });
480
+
481
+ /**
482
+ * Volume Price Query
483
+ */
484
+ export const VolumePriceQuerySchema = z.object({
485
+ size: z
486
+ .number()
487
+ .int()
488
+ .positive("Size must be a positive integer")
489
+ .min(10, "Minimum volume size is 10 GB")
490
+ .max(10240, "Maximum volume size is 10 TB"),
491
+ });
492
+
493
+ export type VolumeId = z.infer<typeof VolumeIdSchema>;
494
+ export type CreateVolumeRequest = z.infer<typeof CreateVolumeRequestSchema>;
495
+ export type UpdateVolumeRequest = z.infer<typeof UpdateVolumeRequestSchema>;
496
+ export type AttachVolumeRequest = z.infer<typeof AttachVolumeRequestSchema>;
497
+ export type DetachVolumeRequest = z.infer<typeof DetachVolumeRequestSchema>;
498
+ export type ResizeVolumeRequest = z.infer<typeof ResizeVolumeRequestSchema>;
499
+ export type VolumeProtectionRequest = z.infer<typeof VolumeProtectionRequestSchema>;
500
+ export type VolumePriceQuery = z.infer<typeof VolumePriceQuerySchema>;
501
+
502
+ // ============================================
503
+ // Tmux Session Management Schemas
504
+ // ============================================
505
+
506
+ /**
507
+ * Tmux Send Command Request
508
+ */
509
+ export const TmuxSendCommandSchema = z.object({
510
+ sessionId: z.string().min(1, "Session ID is required"),
511
+ command: z.string().min(1, "Command is required"),
512
+ paneIndex: z.string().default("0").optional(),
513
+ });
514
+
515
+ /**
516
+ * Tmux Split Pane Request
517
+ */
518
+ export const TmuxSplitPaneSchema = z.object({
519
+ sessionId: z.string().min(1, "Session ID is required"),
520
+ direction: z.enum(["h", "v"]).default("v"),
521
+ command: z.string().optional(),
522
+ });
523
+
524
+ /**
525
+ * Tmux List Windows Request
526
+ */
527
+ export const TmuxListWindowsSchema = z.object({
528
+ sessionId: z.string().min(1, "Session ID is required"),
529
+ });
530
+
531
+ /**
532
+ * Tmux List Panes Request
533
+ */
534
+ export const TmuxListPanesSchema = z.object({
535
+ sessionId: z.string().min(1, "Session ID is required"),
536
+ windowIndex: z.string().default("0").optional(),
537
+ });
538
+
539
+ /**
540
+ * Tmux Capture Pane Request
541
+ */
542
+ export const TmuxCapturePaneSchema = z.object({
543
+ sessionId: z.string().min(1, "Session ID is required"),
544
+ paneIndex: z.string().default("0").optional(),
545
+ });
546
+
547
+ /**
548
+ * Tmux Get History Request
549
+ */
550
+ export const TmuxGetHistorySchema = z.object({
551
+ sessionId: z.string().min(1, "Session ID is required"),
552
+ paneIndex: z.string().default("0").optional(),
553
+ lines: z.number().int().default(-1).optional(),
554
+ });
555
+
556
+ /**
557
+ * Tmux Switch Window Request
558
+ */
559
+ export const TmuxSwitchWindowSchema = z.object({
560
+ sessionId: z.string().min(1, "Session ID is required"),
561
+ windowIndex: z.string().min(1, "Window index is required"),
562
+ });
563
+
564
+ /**
565
+ * Tmux Switch Pane Request
566
+ */
567
+ export const TmuxSwitchPaneSchema = z.object({
568
+ sessionId: z.string().min(1, "Session ID is required"),
569
+ paneIndex: z.string().min(1, "Pane index is required"),
570
+ });
571
+
572
+ /**
573
+ * Tmux Rename Window Request
574
+ */
575
+ export const TmuxRenameWindowSchema = z.object({
576
+ sessionId: z.string().min(1, "Session ID is required"),
577
+ windowIndex: z.string().min(1, "Window index is required"),
578
+ newName: z.string().min(1, "New name is required").max(64),
579
+ });
580
+
581
+ /**
582
+ * Tmux Kill Pane Request
583
+ */
584
+ export const TmuxKillPaneSchema = z.object({
585
+ sessionId: z.string().min(1, "Session ID is required"),
586
+ paneIndex: z.string().min(1, "Pane index is required"),
587
+ });
588
+
589
+ /**
590
+ * Tmux Detailed Info Request
591
+ */
592
+ export const TmuxDetailedInfoSchema = z.object({
593
+ sessionId: z.string().min(1, "Session ID is required"),
594
+ });
595
+
596
+ export type TmuxSendCommand = z.infer<typeof TmuxSendCommandSchema>;
597
+ export type TmuxSplitPane = z.infer<typeof TmuxSplitPaneSchema>;
598
+ export type TmuxListWindows = z.infer<typeof TmuxListWindowsSchema>;
599
+ export type TmuxListPanes = z.infer<typeof TmuxListPanesSchema>;
600
+ export type TmuxCapturePane = z.infer<typeof TmuxCapturePaneSchema>;
601
+ export type TmuxGetHistory = z.infer<typeof TmuxGetHistorySchema>;
602
+ export type TmuxSwitchWindow = z.infer<typeof TmuxSwitchWindowSchema>;
603
+ export type TmuxSwitchPane = z.infer<typeof TmuxSwitchPaneSchema>;
604
+ export type TmuxRenameWindow = z.infer<typeof TmuxRenameWindowSchema>;
605
+ export type TmuxKillPane = z.infer<typeof TmuxKillPaneSchema>;
606
+ export type TmuxDetailedInfo = z.infer<typeof TmuxDetailedInfoSchema>;
607
+
608
+ // ============================================
609
+ // Multi-Node Tmux Manager Schemas
610
+ // ============================================
611
+
612
+ /**
613
+ * Tmux Manager Add Node Request
614
+ */
615
+ export const TmuxManagerAddNodeSchema = z.object({
616
+ id: z.string().min(1, "Node ID is required"),
617
+ name: z.string().min(1, "Node name is required"),
618
+ ip: z.string().min(1, "IP address is required"),
619
+ ipv6: z.string().nullable().optional(),
620
+ user: z.string().default("root"),
621
+ port: z.number().int().positive().max(65535).default(22),
622
+ keyPath: z.string().optional(),
623
+ status: z.enum(["running", "stopped", "unreachable"]).default("running"),
624
+ tags: z.array(z.string()).optional(),
625
+ location: z.string().optional(),
626
+ });
627
+
628
+ /**
629
+ * Tmux Manager Create Session Request
630
+ */
631
+ export const TmuxManagerCreateSessionSchema = z.object({
632
+ nodeId: z.string().min(1, "Node ID is required"),
633
+ sessionName: z.string().optional(),
634
+ cwd: z.string().optional(),
635
+ initialCommand: z.string().optional(),
636
+ layout: z.enum(["even-horizontal", "even-vertical", "main-horizontal", "main-vertical", "tiled"]).optional(),
637
+ });
638
+
639
+ /**
640
+ * Tmux Manager Attach Session Request
641
+ */
642
+ export const TmuxManagerAttachSessionSchema = z.object({
643
+ nodeId: z.string().min(1, "Node ID is required"),
644
+ sessionName: z.string().optional(),
645
+ });
646
+
647
+ /**
648
+ * Tmux Manager Kill Session Request
649
+ */
650
+ export const TmuxManagerKillSessionSchema = z.object({
651
+ nodeId: z.string().min(1, "Node ID is required"),
652
+ sessionName: z.string().min(1, "Session name is required"),
653
+ });
654
+
655
+ /**
656
+ * Tmux Manager Send Command Request
657
+ */
658
+ export const TmuxManagerSendCommandSchema = z.object({
659
+ nodeId: z.string().min(1, "Node ID is required"),
660
+ sessionName: z.string().min(1, "Session name is required"),
661
+ command: z.string().min(1, "Command is required"),
662
+ paneIndex: z.string().default("0"),
663
+ });
664
+
665
+ /**
666
+ * Tmux Manager Batch Send Command Request
667
+ */
668
+ export const TmuxManagerBatchSendCommandSchema = z.object({
669
+ nodeIds: z.array(z.string().min(1)).min(1, "At least one node ID is required"),
670
+ sessionName: z.string().min(1, "Session name is required"),
671
+ command: z.string().min(1, "Command is required"),
672
+ paneIndex: z.string().default("0"),
673
+ parallel: z.boolean().default(true),
674
+ continueOnError: z.boolean().default(true),
675
+ timeout: z.number().int().positive().default(30),
676
+ });
677
+
678
+ /**
679
+ * Tmux Manager Split Pane Request
680
+ */
681
+ export const TmuxManagerSplitPaneSchema = z.object({
682
+ nodeId: z.string().min(1, "Node ID is required"),
683
+ sessionName: z.string().min(1, "Session name is required"),
684
+ direction: z.enum(["h", "v"]).default("v"),
685
+ command: z.string().nullable().optional(),
686
+ windowIndex: z.string().default("0"),
687
+ });
688
+
689
+ /**
690
+ * Tmux Manager Capture Pane Request
691
+ */
692
+ export const TmuxManagerCapturePaneSchema = z.object({
693
+ nodeId: z.string().min(1, "Node ID is required"),
694
+ sessionName: z.string().min(1, "Session name is required"),
695
+ paneIndex: z.string().default("0"),
696
+ });
697
+
698
+ /**
699
+ * Tmux Manager Get History Request
700
+ */
701
+ export const TmuxManagerGetHistorySchema = z.object({
702
+ nodeId: z.string().min(1, "Node ID is required"),
703
+ sessionName: z.string().min(1, "Session name is required"),
704
+ paneIndex: z.string().default("0"),
705
+ lines: z.number().int().default(-1),
706
+ });
707
+
708
+ /**
709
+ * Tmux Manager List Windows Request
710
+ */
711
+ export const TmuxManagerListWindowsSchema = z.object({
712
+ nodeId: z.string().min(1, "Node ID is required"),
713
+ sessionName: z.string().min(1, "Session name is required"),
714
+ });
715
+
716
+ /**
717
+ * Tmux Manager List Panes Request
718
+ */
719
+ export const TmuxManagerListPanesSchema = z.object({
720
+ nodeId: z.string().min(1, "Node ID is required"),
721
+ sessionName: z.string().min(1, "Session name is required"),
722
+ windowIndex: z.string().default("0"),
723
+ });
724
+
725
+ /**
726
+ * Tmux Manager Switch Window Request
727
+ */
728
+ export const TmuxManagerSwitchWindowSchema = z.object({
729
+ nodeId: z.string().min(1, "Node ID is required"),
730
+ sessionName: z.string().min(1, "Session name is required"),
731
+ windowIndex: z.string().min(1, "Window index is required"),
732
+ });
733
+
734
+ /**
735
+ * Tmux Manager Switch Pane Request
736
+ */
737
+ export const TmuxManagerSwitchPaneSchema = z.object({
738
+ nodeId: z.string().min(1, "Node ID is required"),
739
+ sessionName: z.string().min(1, "Session name is required"),
740
+ paneIndex: z.string().min(1, "Pane index is required"),
741
+ });
742
+
743
+ /**
744
+ * Tmux Manager Rename Window Request
745
+ */
746
+ export const TmuxManagerRenameWindowSchema = z.object({
747
+ nodeId: z.string().min(1, "Node ID is required"),
748
+ sessionName: z.string().min(1, "Session name is required"),
749
+ windowIndex: z.string().min(1, "Window index is required"),
750
+ newName: z.string().min(1, "New name is required").max(64),
751
+ });
752
+
753
+ /**
754
+ * Tmux Manager Kill Pane Request
755
+ */
756
+ export const TmuxManagerKillPaneSchema = z.object({
757
+ nodeId: z.string().min(1, "Node ID is required"),
758
+ sessionName: z.string().min(1, "Session name is required"),
759
+ paneIndex: z.string().min(1, "Pane index is required"),
760
+ });
761
+
762
+ /**
763
+ * Tmux Manager Cleanup Old Sessions Request
764
+ */
765
+ export const TmuxManagerCleanupOldSessionsSchema = z.object({
766
+ nodeId: z.string().min(1, "Node ID is required"),
767
+ ageLimitMs: z.number().int().positive().default(30 * 24 * 60 * 60 * 1000), // 30 days
768
+ });
769
+
770
+ /**
771
+ * Tmux Manager Detailed Session Request
772
+ */
773
+ export const TmuxManagerDetailedSessionSchema = z.object({
774
+ nodeId: z.string().min(1, "Node ID is required"),
775
+ sessionName: z.string().min(1, "Session name is required"),
776
+ });
777
+
778
+ /**
779
+ * Tmux Manager List Sessions Query
780
+ */
781
+ export const TmuxManagerListSessionsQuerySchema = z.object({
782
+ nodeIds: z.array(z.string()).optional(),
783
+ tags: z.array(z.string()).optional(),
784
+ detailed: z.boolean().default(false).optional(),
785
+ includeInactive: z.boolean().default(false).optional(),
786
+ });
787
+
788
+ export type TmuxManagerAddNode = z.infer<typeof TmuxManagerAddNodeSchema>;
789
+ export type TmuxManagerCreateSession = z.infer<typeof TmuxManagerCreateSessionSchema>;
790
+ export type TmuxManagerAttachSession = z.infer<typeof TmuxManagerAttachSessionSchema>;
791
+ export type TmuxManagerKillSession = z.infer<typeof TmuxManagerKillSessionSchema>;
792
+ export type TmuxManagerSendCommand = z.infer<typeof TmuxManagerSendCommandSchema>;
793
+ export type TmuxManagerBatchSendCommand = z.infer<typeof TmuxManagerBatchSendCommandSchema>;
794
+ export type TmuxManagerSplitPane = z.infer<typeof TmuxManagerSplitPaneSchema>;
795
+ export type TmuxManagerCapturePane = z.infer<typeof TmuxManagerCapturePaneSchema>;
796
+ export type TmuxManagerGetHistory = z.infer<typeof TmuxManagerGetHistorySchema>;
797
+ export type TmuxManagerListWindows = z.infer<typeof TmuxManagerListWindowsSchema>;
798
+ export type TmuxManagerListPanes = z.infer<typeof TmuxManagerListPanesSchema>;
799
+ export type TmuxManagerSwitchWindow = z.infer<typeof TmuxManagerSwitchWindowSchema>;
800
+ export type TmuxManagerSwitchPane = z.infer<typeof TmuxManagerSwitchPaneSchema>;
801
+ export type TmuxManagerRenameWindow = z.infer<typeof TmuxManagerRenameWindowSchema>;
802
+ export type TmuxManagerKillPane = z.infer<typeof TmuxManagerKillPaneSchema>;
803
+ export type TmuxManagerCleanupOldSessions = z.infer<typeof TmuxManagerCleanupOldSessionsSchema>;
804
+ export type TmuxManagerDetailedSession = z.infer<typeof TmuxManagerDetailedSessionSchema>;
805
+ export type TmuxManagerListSessionsQuery = z.infer<typeof TmuxManagerListSessionsQuerySchema>;
806
+
807
+ // ============================================
808
+ // Activities Schemas
809
+ // ============================================
810
+
811
+ /**
812
+ * Add Activity Request
813
+ */
814
+ export const AddActivityRequestSchema = z.object({
815
+ environmentId: z.string().min(1, "Environment ID is required"),
816
+ action: z.string().min(1, "Action is required").max(100),
817
+ environmentName: z.string().min(1, "Environment name is required").max(64),
818
+ details: z.string().max(1000).optional(),
819
+ });
820
+
821
+ /**
822
+ * Activities Query Schema (for query parameters)
823
+ */
824
+ export const ActivitiesQueryParamsSchema = z.object({
825
+ environmentId: z.string().optional(),
826
+ limit: z
827
+ .string()
828
+ .default("100")
829
+ .transform((val) => parseInt(val, 10))
830
+ .pipe(z.number().int().positive().max(1000))
831
+ .optional(),
832
+ hours: z
833
+ .string()
834
+ .transform((val) => parseInt(val, 10))
835
+ .pipe(z.number().int().positive())
836
+ .optional(),
837
+ since: z.string().datetime().optional(),
838
+ until: z.string().datetime().optional(),
839
+ action: z.string().optional(),
840
+ });
841
+
842
+ /**
843
+ * Cleanup Activities Request
844
+ */
845
+ export const CleanupActivitiesRequestSchema = z.object({
846
+ environmentId: z.string().optional(),
847
+ keepHours: z
848
+ .number()
849
+ .int()
850
+ .positive()
851
+ .default(720) // 30 days
852
+ .optional(),
853
+ });
854
+
855
+ export type AddActivityRequest = z.infer<typeof AddActivityRequestSchema>;
856
+ export type ActivitiesQueryParams = z.infer<typeof ActivitiesQueryParamsSchema>;
857
+ export type CleanupActivitiesRequest = z.infer<typeof CleanupActivitiesRequestSchema>;