@sylphx/flow 1.0.1 → 1.0.3

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 (229) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/package.json +10 -9
  3. package/src/commands/codebase-command.ts +168 -0
  4. package/src/commands/flow-command.ts +1137 -0
  5. package/src/commands/flow-orchestrator.ts +296 -0
  6. package/src/commands/hook-command.ts +444 -0
  7. package/src/commands/init-command.ts +92 -0
  8. package/src/commands/init-core.ts +322 -0
  9. package/src/commands/knowledge-command.ts +161 -0
  10. package/src/commands/run-command.ts +120 -0
  11. package/src/components/benchmark-monitor.tsx +331 -0
  12. package/src/components/reindex-progress.tsx +261 -0
  13. package/src/composables/functional/index.ts +14 -0
  14. package/src/composables/functional/useEnvironment.ts +171 -0
  15. package/src/composables/functional/useFileSystem.ts +139 -0
  16. package/src/composables/index.ts +5 -0
  17. package/src/composables/useEnv.ts +13 -0
  18. package/src/composables/useRuntimeConfig.ts +27 -0
  19. package/src/composables/useTargetConfig.ts +45 -0
  20. package/src/config/ai-config.ts +376 -0
  21. package/src/config/constants.ts +35 -0
  22. package/src/config/index.ts +27 -0
  23. package/src/config/rules.ts +43 -0
  24. package/src/config/servers.ts +371 -0
  25. package/src/config/targets.ts +126 -0
  26. package/src/core/agent-loader.ts +141 -0
  27. package/src/core/agent-manager.ts +174 -0
  28. package/src/core/ai-sdk.ts +603 -0
  29. package/src/core/app-factory.ts +381 -0
  30. package/src/core/builtin-agents.ts +9 -0
  31. package/src/core/command-system.ts +550 -0
  32. package/src/core/config-system.ts +550 -0
  33. package/src/core/connection-pool.ts +390 -0
  34. package/src/core/di-container.ts +155 -0
  35. package/src/core/error-handling.ts +519 -0
  36. package/src/core/formatting/bytes.test.ts +115 -0
  37. package/src/core/formatting/bytes.ts +64 -0
  38. package/src/core/functional/async.ts +313 -0
  39. package/src/core/functional/either.ts +109 -0
  40. package/src/core/functional/error-handler.ts +135 -0
  41. package/src/core/functional/error-types.ts +311 -0
  42. package/src/core/functional/index.ts +19 -0
  43. package/src/core/functional/option.ts +142 -0
  44. package/src/core/functional/pipe.ts +189 -0
  45. package/src/core/functional/result.ts +204 -0
  46. package/src/core/functional/validation.ts +138 -0
  47. package/src/core/headless-display.ts +96 -0
  48. package/src/core/index.ts +6 -0
  49. package/src/core/installers/file-installer.ts +303 -0
  50. package/src/core/installers/mcp-installer.ts +213 -0
  51. package/src/core/interfaces/index.ts +22 -0
  52. package/src/core/interfaces/repository.interface.ts +91 -0
  53. package/src/core/interfaces/service.interface.ts +133 -0
  54. package/src/core/interfaces.ts +129 -0
  55. package/src/core/loop-controller.ts +200 -0
  56. package/src/core/result.ts +351 -0
  57. package/src/core/rule-loader.ts +147 -0
  58. package/src/core/rule-manager.ts +240 -0
  59. package/src/core/service-config.ts +252 -0
  60. package/src/core/session-service.ts +121 -0
  61. package/src/core/state-detector.ts +389 -0
  62. package/src/core/storage-factory.ts +115 -0
  63. package/src/core/stream-handler.ts +288 -0
  64. package/src/core/target-manager.ts +161 -0
  65. package/src/core/type-utils.ts +427 -0
  66. package/src/core/unified-storage.ts +456 -0
  67. package/src/core/upgrade-manager.ts +300 -0
  68. package/src/core/validation/limit.test.ts +155 -0
  69. package/src/core/validation/limit.ts +46 -0
  70. package/src/core/validation/query.test.ts +44 -0
  71. package/src/core/validation/query.ts +20 -0
  72. package/src/db/auto-migrate.ts +322 -0
  73. package/src/db/base-database-client.ts +144 -0
  74. package/src/db/cache-db.ts +218 -0
  75. package/src/db/cache-schema.ts +75 -0
  76. package/src/db/database.ts +70 -0
  77. package/src/db/index.ts +252 -0
  78. package/src/db/memory-db.ts +153 -0
  79. package/src/db/memory-schema.ts +29 -0
  80. package/src/db/schema.ts +289 -0
  81. package/src/db/session-repository.ts +733 -0
  82. package/src/domains/codebase/index.ts +5 -0
  83. package/src/domains/codebase/tools.ts +139 -0
  84. package/src/domains/index.ts +8 -0
  85. package/src/domains/knowledge/index.ts +10 -0
  86. package/src/domains/knowledge/resources.ts +537 -0
  87. package/src/domains/knowledge/tools.ts +174 -0
  88. package/src/domains/utilities/index.ts +6 -0
  89. package/src/domains/utilities/time/index.ts +5 -0
  90. package/src/domains/utilities/time/tools.ts +291 -0
  91. package/src/index.ts +211 -0
  92. package/src/services/agent-service.ts +273 -0
  93. package/src/services/claude-config-service.ts +252 -0
  94. package/src/services/config-service.ts +258 -0
  95. package/src/services/evaluation-service.ts +271 -0
  96. package/src/services/functional/evaluation-logic.ts +296 -0
  97. package/src/services/functional/file-processor.ts +273 -0
  98. package/src/services/functional/index.ts +12 -0
  99. package/src/services/index.ts +13 -0
  100. package/src/services/mcp-service.ts +432 -0
  101. package/src/services/memory.service.ts +476 -0
  102. package/src/services/search/base-indexer.ts +156 -0
  103. package/src/services/search/codebase-indexer-types.ts +38 -0
  104. package/src/services/search/codebase-indexer.ts +647 -0
  105. package/src/services/search/embeddings-provider.ts +455 -0
  106. package/src/services/search/embeddings.ts +316 -0
  107. package/src/services/search/functional-indexer.ts +323 -0
  108. package/src/services/search/index.ts +27 -0
  109. package/src/services/search/indexer.ts +380 -0
  110. package/src/services/search/knowledge-indexer.ts +422 -0
  111. package/src/services/search/semantic-search.ts +244 -0
  112. package/src/services/search/tfidf.ts +559 -0
  113. package/src/services/search/unified-search-service.ts +888 -0
  114. package/src/services/smart-config-service.ts +385 -0
  115. package/src/services/storage/cache-storage.ts +487 -0
  116. package/src/services/storage/drizzle-storage.ts +581 -0
  117. package/src/services/storage/index.ts +15 -0
  118. package/src/services/storage/lancedb-vector-storage.ts +494 -0
  119. package/src/services/storage/memory-storage.ts +268 -0
  120. package/src/services/storage/separated-storage.ts +467 -0
  121. package/src/services/storage/vector-storage.ts +13 -0
  122. package/src/shared/agents/index.ts +63 -0
  123. package/src/shared/files/index.ts +99 -0
  124. package/src/shared/index.ts +32 -0
  125. package/src/shared/logging/index.ts +24 -0
  126. package/src/shared/processing/index.ts +153 -0
  127. package/src/shared/types/index.ts +25 -0
  128. package/src/targets/claude-code.ts +574 -0
  129. package/src/targets/functional/claude-code-logic.ts +185 -0
  130. package/src/targets/functional/index.ts +6 -0
  131. package/src/targets/opencode.ts +529 -0
  132. package/src/types/agent.types.ts +32 -0
  133. package/src/types/api/batch.ts +108 -0
  134. package/src/types/api/errors.ts +118 -0
  135. package/src/types/api/index.ts +55 -0
  136. package/src/types/api/requests.ts +76 -0
  137. package/src/types/api/responses.ts +180 -0
  138. package/src/types/api/websockets.ts +85 -0
  139. package/src/types/api.types.ts +9 -0
  140. package/src/types/benchmark.ts +49 -0
  141. package/src/types/cli.types.ts +87 -0
  142. package/src/types/common.types.ts +35 -0
  143. package/src/types/database.types.ts +510 -0
  144. package/src/types/mcp-config.types.ts +448 -0
  145. package/src/types/mcp.types.ts +69 -0
  146. package/src/types/memory-types.ts +63 -0
  147. package/src/types/provider.types.ts +28 -0
  148. package/src/types/rule.types.ts +24 -0
  149. package/src/types/session.types.ts +214 -0
  150. package/src/types/target-config.types.ts +295 -0
  151. package/src/types/target.types.ts +140 -0
  152. package/src/types/todo.types.ts +25 -0
  153. package/src/types.ts +40 -0
  154. package/src/utils/advanced-tokenizer.ts +191 -0
  155. package/src/utils/agent-enhancer.ts +114 -0
  156. package/src/utils/ai-model-fetcher.ts +19 -0
  157. package/src/utils/async-file-operations.ts +516 -0
  158. package/src/utils/audio-player.ts +345 -0
  159. package/src/utils/cli-output.ts +266 -0
  160. package/src/utils/codebase-helpers.ts +211 -0
  161. package/src/utils/console-ui.ts +79 -0
  162. package/src/utils/database-errors.ts +140 -0
  163. package/src/utils/debug-logger.ts +49 -0
  164. package/src/utils/error-handler.ts +53 -0
  165. package/src/utils/file-operations.ts +310 -0
  166. package/src/utils/file-scanner.ts +259 -0
  167. package/src/utils/functional/array.ts +355 -0
  168. package/src/utils/functional/index.ts +15 -0
  169. package/src/utils/functional/object.ts +279 -0
  170. package/src/utils/functional/string.ts +281 -0
  171. package/src/utils/functional.ts +543 -0
  172. package/src/utils/help.ts +20 -0
  173. package/src/utils/immutable-cache.ts +106 -0
  174. package/src/utils/index.ts +78 -0
  175. package/src/utils/jsonc.ts +158 -0
  176. package/src/utils/logger.ts +396 -0
  177. package/src/utils/mcp-config.ts +249 -0
  178. package/src/utils/memory-tui.ts +414 -0
  179. package/src/utils/models-dev.ts +91 -0
  180. package/src/utils/notifications.ts +169 -0
  181. package/src/utils/object-utils.ts +51 -0
  182. package/src/utils/parallel-operations.ts +487 -0
  183. package/src/utils/paths.ts +143 -0
  184. package/src/utils/process-manager.ts +155 -0
  185. package/src/utils/prompts.ts +120 -0
  186. package/src/utils/search-tool-builder.ts +214 -0
  187. package/src/utils/secret-utils.ts +179 -0
  188. package/src/utils/security.ts +537 -0
  189. package/src/utils/session-manager.ts +168 -0
  190. package/src/utils/session-title.ts +87 -0
  191. package/src/utils/settings.ts +182 -0
  192. package/src/utils/simplified-errors.ts +410 -0
  193. package/src/utils/sync-utils.ts +159 -0
  194. package/src/utils/target-config.ts +570 -0
  195. package/src/utils/target-utils.ts +394 -0
  196. package/src/utils/template-engine.ts +94 -0
  197. package/src/utils/test-audio.ts +71 -0
  198. package/src/utils/todo-context.ts +46 -0
  199. package/src/utils/token-counter.ts +288 -0
  200. package/dist/index.d.ts +0 -10
  201. package/dist/index.js +0 -59554
  202. package/dist/lancedb.linux-x64-gnu-b7f0jgsz.node +0 -0
  203. package/dist/lancedb.linux-x64-musl-tgcv22rx.node +0 -0
  204. package/dist/shared/chunk-25dwp0dp.js +0 -89
  205. package/dist/shared/chunk-3pjb6063.js +0 -208
  206. package/dist/shared/chunk-4d6ydpw7.js +0 -2854
  207. package/dist/shared/chunk-4wjcadjk.js +0 -225
  208. package/dist/shared/chunk-5j4w74t6.js +0 -30
  209. package/dist/shared/chunk-5j8m3dh3.js +0 -58
  210. package/dist/shared/chunk-5thh3qem.js +0 -91
  211. package/dist/shared/chunk-6g9xy73m.js +0 -252
  212. package/dist/shared/chunk-7eq34c42.js +0 -23
  213. package/dist/shared/chunk-c2gwgx3r.js +0 -115
  214. package/dist/shared/chunk-cjd3mk4c.js +0 -1320
  215. package/dist/shared/chunk-g5cv6703.js +0 -368
  216. package/dist/shared/chunk-hpkhykhq.js +0 -574
  217. package/dist/shared/chunk-m2322pdk.js +0 -122
  218. package/dist/shared/chunk-nd5fdvaq.js +0 -26
  219. package/dist/shared/chunk-pgd3m6zf.js +0 -108
  220. package/dist/shared/chunk-qk8n91hw.js +0 -494
  221. package/dist/shared/chunk-rkkn8szp.js +0 -16855
  222. package/dist/shared/chunk-t16rfxh0.js +0 -61
  223. package/dist/shared/chunk-t4fbfa5v.js +0 -19
  224. package/dist/shared/chunk-t77h86w6.js +0 -276
  225. package/dist/shared/chunk-v0ez4aef.js +0 -71
  226. package/dist/shared/chunk-v29j2r3s.js +0 -32051
  227. package/dist/shared/chunk-vfbc6ew5.js +0 -765
  228. package/dist/shared/chunk-vmeqwm1c.js +0 -204
  229. package/dist/shared/chunk-x66eh37x.js +0 -137
@@ -0,0 +1,118 @@
1
+ import { z } from 'zod';
2
+
3
+ // ============================================================================
4
+ // API ERROR INTERFACES
5
+ // ============================================================================
6
+
7
+ /**
8
+ * API error information
9
+ */
10
+ export interface ApiError {
11
+ /** Error code */
12
+ code: string;
13
+ /** Error message */
14
+ message: string;
15
+ /** HTTP status code */
16
+ statusCode?: number;
17
+ /** Error type for categorization */
18
+ type:
19
+ | 'validation'
20
+ | 'authentication'
21
+ | 'authorization'
22
+ | 'not_found'
23
+ | 'conflict'
24
+ | 'rate_limit'
25
+ | 'server_error'
26
+ | 'network'
27
+ | 'timeout';
28
+ /** Detailed error description */
29
+ description?: string;
30
+ /** Field-specific errors (for validation errors) */
31
+ fieldErrors?: Record<string, string[]>;
32
+ /** Stack trace (development only) */
33
+ stack?: string;
34
+ /** Error context information */
35
+ context?: Record<string, unknown>;
36
+ /** Suggestions for resolution */
37
+ suggestions?: string[];
38
+ }
39
+
40
+ /**
41
+ * Enhanced error with additional context
42
+ */
43
+ export interface EnhancedError extends Error {
44
+ /** Error code */
45
+ code: string;
46
+ /** HTTP status code */
47
+ statusCode?: number;
48
+ /** Error type */
49
+ type: ApiError['type'];
50
+ /** Error context */
51
+ context?: ErrorContext;
52
+ /** Suggestions for resolution */
53
+ suggestions?: string[];
54
+ /** Original error that caused this error */
55
+ originalError?: Error;
56
+ /** Timestamp when error occurred */
57
+ timestamp: string;
58
+ /** Request ID for tracing */
59
+ requestId?: string;
60
+ }
61
+
62
+ /**
63
+ * Error context information
64
+ */
65
+ export interface ErrorContext {
66
+ /** User ID if available */
67
+ userId?: string;
68
+ /** Session ID if available */
69
+ sessionId?: string;
70
+ /** IP address if available */
71
+ ipAddress?: string;
72
+ /** User agent if available */
73
+ userAgent?: string;
74
+ /** Request path */
75
+ path?: string;
76
+ /** HTTP method */
77
+ method?: string;
78
+ /** Additional context data */
79
+ data?: Record<string, unknown>;
80
+ }
81
+
82
+ // ============================================================================
83
+ // ZOD SCHEMAS
84
+ // ============================================================================
85
+
86
+ export const ErrorContextSchema = z.object({
87
+ userId: z.string().optional(),
88
+ sessionId: z.string().optional(),
89
+ ipAddress: z.string().optional(),
90
+ userAgent: z.string().optional(),
91
+ path: z.string().optional(),
92
+ method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']).optional(),
93
+ data: z.record(z.unknown()).optional(),
94
+ });
95
+
96
+ export const EnhancedErrorSchema = z.object({
97
+ name: z.string(),
98
+ message: z.string(),
99
+ code: z.string(),
100
+ statusCode: z.number().optional(),
101
+ type: z.enum([
102
+ 'validation',
103
+ 'authentication',
104
+ 'authorization',
105
+ 'not_found',
106
+ 'conflict',
107
+ 'rate_limit',
108
+ 'server_error',
109
+ 'network',
110
+ 'timeout',
111
+ ]),
112
+ context: ErrorContextSchema.optional(),
113
+ suggestions: z.array(z.string()).optional(),
114
+ originalError: z.instanceof(Error).optional(),
115
+ timestamp: z.string(),
116
+ requestId: z.string().optional(),
117
+ stack: z.string().optional(),
118
+ });
@@ -0,0 +1,55 @@
1
+ /**
2
+ * API types barrel export
3
+ * Organized API-related types and interfaces
4
+ */
5
+
6
+ // Batch operation types
7
+ export type {
8
+ BatchApiResult,
9
+ BatchOperationResult,
10
+ } from './batch.js';
11
+ export {
12
+ BatchApiResultSchema,
13
+ BatchOperationResultSchema,
14
+ } from './batch.js';
15
+
16
+ // Error types
17
+ export type {
18
+ ApiError,
19
+ EnhancedError,
20
+ ErrorContext,
21
+ } from './errors.js';
22
+
23
+ export {
24
+ EnhancedErrorSchema,
25
+ ErrorContextSchema,
26
+ } from './errors.js';
27
+
28
+ // Request types
29
+ export type { HttpRequestConfig } from './requests.js';
30
+
31
+ export { HttpRequestConfigSchema } from './requests.js';
32
+ // Response types
33
+ export type {
34
+ ApiResponse,
35
+ HttpResponse,
36
+ PaginationInfo,
37
+ RateLimitInfo,
38
+ } from './responses.js';
39
+ export {
40
+ ApiResponseSchema,
41
+ HttpResponseSchema,
42
+ PaginationInfoSchema,
43
+ RateLimitInfoSchema,
44
+ } from './responses.js';
45
+
46
+ // WebSocket types
47
+ export type {
48
+ WebSocketConnectionStatus,
49
+ WebSocketMessage,
50
+ } from './websockets.js';
51
+
52
+ export {
53
+ WebSocketConnectionStatusSchema,
54
+ WebSocketMessageSchema,
55
+ } from './websockets.js';
@@ -0,0 +1,76 @@
1
+ import { z } from 'zod';
2
+
3
+ // ============================================================================
4
+ // API REQUEST INTERFACES
5
+ // ============================================================================
6
+
7
+ /**
8
+ * HTTP request configuration
9
+ */
10
+ export interface HttpRequestConfig {
11
+ /** Request URL */
12
+ url: string;
13
+ /** HTTP method */
14
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
15
+ /** Request headers */
16
+ headers?: Record<string, string>;
17
+ /** Request body */
18
+ body?: unknown;
19
+ /** Query parameters */
20
+ params?: Record<string, string | number | boolean>;
21
+ /** Request timeout in milliseconds */
22
+ timeout?: number;
23
+ /** Number of retry attempts */
24
+ retries?: number;
25
+ /** Retry delay in milliseconds */
26
+ retryDelay?: number;
27
+ /** Whether to validate SSL certificates */
28
+ validateSSL?: boolean;
29
+ /** Request ID for tracing */
30
+ requestId?: string;
31
+ /** User agent */
32
+ userAgent?: string;
33
+ /** Authentication token */
34
+ token?: string;
35
+ /** API key */
36
+ apiKey?: string;
37
+ /** Request metadata */
38
+ metadata?: {
39
+ /** Source of the request */
40
+ source?: string;
41
+ /** Request priority */
42
+ priority?: 'low' | 'normal' | 'high';
43
+ /** Request tags */
44
+ tags?: string[];
45
+ /** Custom metadata */
46
+ data?: Record<string, unknown>;
47
+ };
48
+ }
49
+
50
+ // ============================================================================
51
+ // ZOD SCHEMAS
52
+ // ============================================================================
53
+
54
+ export const HttpRequestConfigSchema = z.object({
55
+ url: z.string().url(),
56
+ method: z.enum(['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']),
57
+ headers: z.record(z.string()).optional(),
58
+ body: z.unknown().optional(),
59
+ params: z.record(z.union([z.string(), z.number(), z.boolean()])).optional(),
60
+ timeout: z.number().positive().optional(),
61
+ retries: z.number().min(0).optional(),
62
+ retryDelay: z.number().min(0).optional(),
63
+ validateSSL: z.boolean().optional(),
64
+ requestId: z.string().optional(),
65
+ userAgent: z.string().optional(),
66
+ token: z.string().optional(),
67
+ apiKey: z.string().optional(),
68
+ metadata: z
69
+ .object({
70
+ source: z.string().optional(),
71
+ priority: z.enum(['low', 'normal', 'high']).optional(),
72
+ tags: z.array(z.string()).optional(),
73
+ data: z.record(z.unknown()).optional(),
74
+ })
75
+ .optional(),
76
+ });
@@ -0,0 +1,180 @@
1
+ import { z } from 'zod';
2
+
3
+ // ============================================================================
4
+ // API RESPONSE INTERFACES
5
+ // ============================================================================
6
+
7
+ /**
8
+ * Standard API response wrapper
9
+ */
10
+ export interface ApiResponse<T = unknown> {
11
+ /** Response success status */
12
+ success: boolean;
13
+ /** Response data */
14
+ data?: T;
15
+ /** Response message */
16
+ message?: string;
17
+ /** Response metadata */
18
+ metadata?: {
19
+ /** Response timestamp */
20
+ timestamp: string;
21
+ /** Request ID for tracing */
22
+ requestId?: string;
23
+ /** API version */
24
+ version?: string;
25
+ /** Response time in milliseconds */
26
+ responseTime?: number;
27
+ /** Pagination information */
28
+ pagination?: PaginationInfo;
29
+ /** Rate limiting information */
30
+ rateLimit?: RateLimitInfo;
31
+ };
32
+ /** Error information */
33
+ error?: ApiError;
34
+ }
35
+
36
+ /**
37
+ * HTTP response wrapper
38
+ */
39
+ export interface HttpResponse<T = unknown> {
40
+ /** Response data */
41
+ data: T;
42
+ /** HTTP status code */
43
+ status: number;
44
+ /** HTTP status text */
45
+ statusText: string;
46
+ /** Response headers */
47
+ headers: Record<string, string>;
48
+ /** Response metadata */
49
+ metadata?: {
50
+ /** Response timestamp */
51
+ timestamp: string;
52
+ /** Request ID for tracing */
53
+ requestId?: string;
54
+ /** Response time in milliseconds */
55
+ responseTime?: number;
56
+ /** Response size in bytes */
57
+ size?: number;
58
+ /** Cached response indicator */
59
+ fromCache?: boolean;
60
+ };
61
+ }
62
+
63
+ /**
64
+ * Pagination information
65
+ */
66
+ export interface PaginationInfo {
67
+ /** Current page number */
68
+ page: number;
69
+ /** Items per page */
70
+ limit: number;
71
+ /** Total number of items */
72
+ total: number;
73
+ /** Total number of pages */
74
+ totalPages: number;
75
+ /** Whether there's a next page */
76
+ hasNext: boolean;
77
+ /** Whether there's a previous page */
78
+ hasPrev: boolean;
79
+ /** Next page cursor (for cursor-based pagination) */
80
+ nextCursor?: string;
81
+ /** Previous page cursor (for cursor-based pagination) */
82
+ prevCursor?: string;
83
+ }
84
+
85
+ /**
86
+ * Rate limiting information
87
+ */
88
+ export interface RateLimitInfo {
89
+ /** Maximum requests allowed */
90
+ limit: number;
91
+ /** Remaining requests */
92
+ remaining: number;
93
+ /** Reset timestamp (Unix timestamp) */
94
+ resetAt: number;
95
+ /** Reset time in ISO format */
96
+ resetTime?: string;
97
+ /** Retry after seconds */
98
+ retryAfter?: number;
99
+ /** Request window in seconds */
100
+ window?: number;
101
+ }
102
+
103
+ // ============================================================================
104
+ // ZOD SCHEMAS
105
+ // ============================================================================
106
+
107
+ export const PaginationInfoSchema = z.object({
108
+ page: z.number().min(1),
109
+ limit: z.number().min(1).max(100),
110
+ total: z.number().min(0),
111
+ totalPages: z.number().min(0),
112
+ hasNext: z.boolean(),
113
+ hasPrev: z.boolean(),
114
+ nextCursor: z.string().optional(),
115
+ prevCursor: z.string().optional(),
116
+ });
117
+
118
+ export const RateLimitInfoSchema = z.object({
119
+ limit: z.number().min(1),
120
+ remaining: z.number().min(0),
121
+ resetAt: z.number().min(0),
122
+ resetTime: z.string().optional(),
123
+ retryAfter: z.number().optional(),
124
+ window: z.number().optional(),
125
+ });
126
+
127
+ export const ApiErrorSchema = z.object({
128
+ code: z.string(),
129
+ message: z.string(),
130
+ statusCode: z.number().optional(),
131
+ type: z.enum([
132
+ 'validation',
133
+ 'authentication',
134
+ 'authorization',
135
+ 'not_found',
136
+ 'conflict',
137
+ 'rate_limit',
138
+ 'server_error',
139
+ 'network',
140
+ 'timeout',
141
+ ]),
142
+ description: z.string().optional(),
143
+ fieldErrors: z.record(z.array(z.string())).optional(),
144
+ stack: z.string().optional(),
145
+ context: z.record(z.unknown()).optional(),
146
+ suggestions: z.array(z.string()).optional(),
147
+ });
148
+
149
+ export const ApiResponseSchema = z.object({
150
+ success: z.boolean(),
151
+ data: z.unknown().optional(),
152
+ message: z.string().optional(),
153
+ metadata: z
154
+ .object({
155
+ timestamp: z.string(),
156
+ requestId: z.string().optional(),
157
+ version: z.string().optional(),
158
+ responseTime: z.number().optional(),
159
+ pagination: PaginationInfoSchema.optional(),
160
+ rateLimit: RateLimitInfoSchema.optional(),
161
+ })
162
+ .optional(),
163
+ error: ApiErrorSchema.optional(),
164
+ });
165
+
166
+ export const HttpResponseSchema = z.object({
167
+ data: z.unknown(),
168
+ status: z.number(),
169
+ statusText: z.string(),
170
+ headers: z.record(z.string()),
171
+ metadata: z
172
+ .object({
173
+ timestamp: z.string(),
174
+ requestId: z.string().optional(),
175
+ responseTime: z.number().optional(),
176
+ size: z.number().optional(),
177
+ fromCache: z.boolean().optional(),
178
+ })
179
+ .optional(),
180
+ });
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+
3
+ // ============================================================================
4
+ // WEBSOCKET INTERFACES
5
+ // ============================================================================
6
+
7
+ /**
8
+ * WebSocket message structure
9
+ */
10
+ export interface WebSocketMessage<T = unknown> {
11
+ /** Message type for routing */
12
+ type: string;
13
+ /** Message payload */
14
+ payload: T;
15
+ /** Message ID for correlation */
16
+ id?: string;
17
+ /** Timestamp when message was created */
18
+ timestamp: string;
19
+ /** Message metadata */
20
+ metadata?: {
21
+ /** Sender ID */
22
+ senderId?: string;
23
+ /** Recipient ID (for direct messages) */
24
+ recipientId?: string;
25
+ /** Room or channel ID */
26
+ room?: string;
27
+ /** Message version for compatibility */
28
+ version?: string;
29
+ /** Whether message requires acknowledgment */
30
+ requiresAck?: boolean;
31
+ /** Message priority */
32
+ priority?: 'low' | 'normal' | 'high';
33
+ };
34
+ }
35
+
36
+ /**
37
+ * WebSocket connection status
38
+ */
39
+ export interface WebSocketConnectionStatus {
40
+ /** Connection state */
41
+ status: 'connecting' | 'connected' | 'disconnected' | 'error' | 'reconnecting';
42
+ /** Connection ID */
43
+ connectionId?: string;
44
+ /** URL of connected server */
45
+ url?: string;
46
+ /** Connection timestamp */
47
+ connectedAt?: string;
48
+ /** Last activity timestamp */
49
+ lastActivity?: string;
50
+ /** Number of reconnection attempts */
51
+ retryCount?: number;
52
+ /** Connection error (if any) */
53
+ error?: string;
54
+ }
55
+
56
+ // ============================================================================
57
+ // ZOD SCHEMAS
58
+ // ============================================================================
59
+
60
+ export const WebSocketMessageSchema = z.object({
61
+ type: z.string(),
62
+ payload: z.unknown(),
63
+ id: z.string().optional(),
64
+ timestamp: z.string(),
65
+ metadata: z
66
+ .object({
67
+ senderId: z.string().optional(),
68
+ recipientId: z.string().optional(),
69
+ room: z.string().optional(),
70
+ version: z.string().optional(),
71
+ requiresAck: z.boolean().optional(),
72
+ priority: z.enum(['low', 'normal', 'high']).optional(),
73
+ })
74
+ .optional(),
75
+ });
76
+
77
+ export const WebSocketConnectionStatusSchema = z.object({
78
+ status: z.enum(['connecting', 'connected', 'disconnected', 'error', 'reconnecting']),
79
+ connectionId: z.string().optional(),
80
+ url: z.string().optional(),
81
+ connectedAt: z.string().optional(),
82
+ lastActivity: z.string().optional(),
83
+ retryCount: z.number().min(0).optional(),
84
+ error: z.string().optional(),
85
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Backward compatibility layer for API types
3
+ * Re-exports from the organized API types module
4
+ *
5
+ * @deprecated Import from './types/api' instead
6
+ */
7
+
8
+ // Re-export everything from the organized API types module
9
+ export * from './types/api/index.js';
@@ -0,0 +1,49 @@
1
+ export interface BenchmarkCommandOptions {
2
+ agents?: string;
3
+ task?: string;
4
+ output?: string;
5
+ context?: string;
6
+ evaluate?: boolean;
7
+ report?: string;
8
+ concurrency?: number;
9
+ delay?: number;
10
+ timeout?: number;
11
+ quiet?: boolean;
12
+ }
13
+
14
+ export type AgentStatus = 'idle' | 'running' | 'completed' | 'error';
15
+
16
+ export interface AgentData {
17
+ status: AgentStatus;
18
+ output: string[];
19
+ startTime?: number;
20
+ endTime?: number;
21
+ pid?: number;
22
+ }
23
+
24
+ export interface InitialInfo {
25
+ agentCount: number;
26
+ concurrency: number;
27
+ delay: number;
28
+ taskFile: string;
29
+ outputDir: string;
30
+ }
31
+
32
+ export interface AgentWork {
33
+ [key: string]: string;
34
+ }
35
+
36
+ export interface AgentTimings {
37
+ [key: string]: {
38
+ startTime?: number;
39
+ endTime?: number;
40
+ duration?: number;
41
+ };
42
+ }
43
+
44
+ export interface TimingData {
45
+ endTime: number;
46
+ exitCode: number;
47
+ stdoutLength: number;
48
+ stderrLength: number;
49
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * CLI-specific type definitions
3
+ * Types for command-line interface operations
4
+ */
5
+
6
+ /**
7
+ * Application-specific options that extend Commander's built-in parsing
8
+ * Aggregates all possible CLI options across different commands
9
+ */
10
+ export interface CommandOptions {
11
+ // Common CLI options
12
+ target?: string;
13
+ verbose?: boolean;
14
+ dryRun?: boolean;
15
+ clear?: boolean;
16
+ mcp?: string[] | null | boolean;
17
+ servers?: string[];
18
+ server?: string;
19
+ all?: boolean;
20
+
21
+ // Init command skip flags (--no-X sets to false)
22
+ // Note: 'agents' and 'rules' may also be strings in other commands
23
+ rules?: boolean | string;
24
+ outputStyles?: boolean;
25
+ hooks?: boolean;
26
+
27
+ // Memory command options
28
+ namespace?: string;
29
+ limit?: number;
30
+ pattern?: string;
31
+ key?: string;
32
+ confirm?: boolean;
33
+
34
+ // Benchmark-specific options
35
+ agents?: string | boolean; // boolean for init command --no-agents
36
+ task?: string;
37
+ output?: string;
38
+ context?: string;
39
+ evaluate?: boolean;
40
+ report?: string;
41
+ concurrency?: number;
42
+ delay?: number;
43
+
44
+ // Codebase command options
45
+ includeContent?: boolean;
46
+ extensions?: string[];
47
+ path?: string;
48
+ exclude?: string[];
49
+ query?: string;
50
+
51
+ // Knowledge command options
52
+ category?: string;
53
+ uri?: string;
54
+
55
+ // Allow dynamic properties - Commander.js already handles this
56
+ [key: string]: unknown;
57
+ }
58
+
59
+ /**
60
+ * Command configuration interface
61
+ */
62
+ export interface CommandConfig {
63
+ name: string;
64
+ description: string;
65
+ handler: CommandHandler;
66
+ options?: Record<string, any>;
67
+ }
68
+
69
+ /**
70
+ * Command handler function type
71
+ * All CLI commands implement this signature
72
+ */
73
+ export type CommandHandler = (options: CommandOptions) => Promise<void>;
74
+
75
+ /**
76
+ * Options for executing commands on targets (Claude Code, OpenCode)
77
+ */
78
+ export interface RunCommandOptions {
79
+ target?: string;
80
+ verbose?: boolean;
81
+ dryRun?: boolean;
82
+ agent?: string;
83
+ agentFile?: string;
84
+ prompt?: string;
85
+ print?: boolean; // Headless print mode
86
+ continue?: boolean; // Continue previous conversation
87
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Common types shared across modules
3
+ * Reusable types for cross-cutting concerns
4
+ */
5
+
6
+ /**
7
+ * Type for resolvable values
8
+ * Can be a static value, sync function, or async function
9
+ * Enables lazy evaluation and dynamic configuration
10
+ */
11
+ export type Resolvable<T> = T | (() => Promise<T>) | (() => T);
12
+
13
+ /**
14
+ * Common options shared across commands and operations
15
+ */
16
+ export interface CommonOptions {
17
+ target?: string;
18
+ verbose?: boolean;
19
+ dryRun?: boolean;
20
+ clear?: boolean;
21
+ mcp?: string[] | null | boolean;
22
+ quiet?: boolean;
23
+ agent?: string;
24
+ }
25
+
26
+ /**
27
+ * Standardized result from setup methods
28
+ * Used for consistent UI feedback across different setup operations
29
+ */
30
+ export interface SetupResult {
31
+ /** Number of items processed (servers, agents, files, etc.) */
32
+ count: number;
33
+ /** Optional detailed message */
34
+ message?: string;
35
+ }