claude-code-workflow 6.2.7 → 6.3.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 (208) hide show
  1. package/.claude/CLAUDE.md +16 -1
  2. package/.claude/workflows/cli-templates/protocols/analysis-protocol.md +11 -4
  3. package/.claude/workflows/cli-templates/protocols/write-protocol.md +10 -75
  4. package/.claude/workflows/cli-tools-usage.md +14 -24
  5. package/.codex/AGENTS.md +51 -1
  6. package/.codex/prompts/compact.md +378 -0
  7. package/.gemini/GEMINI.md +57 -20
  8. package/ccw/dist/cli.d.ts.map +1 -1
  9. package/ccw/dist/cli.js +21 -8
  10. package/ccw/dist/cli.js.map +1 -1
  11. package/ccw/dist/commands/cli.d.ts +2 -0
  12. package/ccw/dist/commands/cli.d.ts.map +1 -1
  13. package/ccw/dist/commands/cli.js +129 -8
  14. package/ccw/dist/commands/cli.js.map +1 -1
  15. package/ccw/dist/commands/hook.d.ts.map +1 -1
  16. package/ccw/dist/commands/hook.js +3 -2
  17. package/ccw/dist/commands/hook.js.map +1 -1
  18. package/ccw/dist/config/litellm-api-config-manager.d.ts +180 -0
  19. package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -0
  20. package/ccw/dist/config/litellm-api-config-manager.js +770 -0
  21. package/ccw/dist/config/litellm-api-config-manager.js.map +1 -0
  22. package/ccw/dist/config/provider-models.d.ts +73 -0
  23. package/ccw/dist/config/provider-models.d.ts.map +1 -0
  24. package/ccw/dist/config/provider-models.js +172 -0
  25. package/ccw/dist/config/provider-models.js.map +1 -0
  26. package/ccw/dist/core/cache-manager.d.ts.map +1 -1
  27. package/ccw/dist/core/cache-manager.js +3 -5
  28. package/ccw/dist/core/cache-manager.js.map +1 -1
  29. package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
  30. package/ccw/dist/core/dashboard-generator.js +3 -1
  31. package/ccw/dist/core/dashboard-generator.js.map +1 -1
  32. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  33. package/ccw/dist/core/routes/cli-routes.js +169 -0
  34. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  35. package/ccw/dist/core/routes/codexlens-routes.d.ts.map +1 -1
  36. package/ccw/dist/core/routes/codexlens-routes.js +234 -18
  37. package/ccw/dist/core/routes/codexlens-routes.js.map +1 -1
  38. package/ccw/dist/core/routes/hooks-routes.d.ts.map +1 -1
  39. package/ccw/dist/core/routes/hooks-routes.js +30 -32
  40. package/ccw/dist/core/routes/hooks-routes.js.map +1 -1
  41. package/ccw/dist/core/routes/litellm-api-routes.d.ts +21 -0
  42. package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -0
  43. package/ccw/dist/core/routes/litellm-api-routes.js +780 -0
  44. package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -0
  45. package/ccw/dist/core/routes/litellm-routes.d.ts +20 -0
  46. package/ccw/dist/core/routes/litellm-routes.d.ts.map +1 -0
  47. package/ccw/dist/core/routes/litellm-routes.js +85 -0
  48. package/ccw/dist/core/routes/litellm-routes.js.map +1 -0
  49. package/ccw/dist/core/routes/mcp-routes.js +2 -2
  50. package/ccw/dist/core/routes/mcp-routes.js.map +1 -1
  51. package/ccw/dist/core/routes/status-routes.d.ts.map +1 -1
  52. package/ccw/dist/core/routes/status-routes.js +39 -0
  53. package/ccw/dist/core/routes/status-routes.js.map +1 -1
  54. package/ccw/dist/core/routes/system-routes.js +1 -1
  55. package/ccw/dist/core/routes/system-routes.js.map +1 -1
  56. package/ccw/dist/core/server.d.ts.map +1 -1
  57. package/ccw/dist/core/server.js +15 -1
  58. package/ccw/dist/core/server.js.map +1 -1
  59. package/ccw/dist/mcp-server/index.js +1 -1
  60. package/ccw/dist/mcp-server/index.js.map +1 -1
  61. package/ccw/dist/tools/claude-cli-tools.d.ts +82 -0
  62. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -0
  63. package/ccw/dist/tools/claude-cli-tools.js +216 -0
  64. package/ccw/dist/tools/claude-cli-tools.js.map +1 -0
  65. package/ccw/dist/tools/cli-executor.d.ts.map +1 -1
  66. package/ccw/dist/tools/cli-executor.js +76 -14
  67. package/ccw/dist/tools/cli-executor.js.map +1 -1
  68. package/ccw/dist/tools/codex-lens.d.ts +9 -2
  69. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  70. package/ccw/dist/tools/codex-lens.js +114 -9
  71. package/ccw/dist/tools/codex-lens.js.map +1 -1
  72. package/ccw/dist/tools/context-cache-store.d.ts +136 -0
  73. package/ccw/dist/tools/context-cache-store.d.ts.map +1 -0
  74. package/ccw/dist/tools/context-cache-store.js +256 -0
  75. package/ccw/dist/tools/context-cache-store.js.map +1 -0
  76. package/ccw/dist/tools/context-cache.d.ts +56 -0
  77. package/ccw/dist/tools/context-cache.d.ts.map +1 -0
  78. package/ccw/dist/tools/context-cache.js +294 -0
  79. package/ccw/dist/tools/context-cache.js.map +1 -0
  80. package/ccw/dist/tools/core-memory.d.ts.map +1 -1
  81. package/ccw/dist/tools/core-memory.js +33 -19
  82. package/ccw/dist/tools/core-memory.js.map +1 -1
  83. package/ccw/dist/tools/index.d.ts.map +1 -1
  84. package/ccw/dist/tools/index.js +2 -0
  85. package/ccw/dist/tools/index.js.map +1 -1
  86. package/ccw/dist/tools/litellm-client.d.ts +85 -0
  87. package/ccw/dist/tools/litellm-client.d.ts.map +1 -0
  88. package/ccw/dist/tools/litellm-client.js +188 -0
  89. package/ccw/dist/tools/litellm-client.js.map +1 -0
  90. package/ccw/dist/tools/litellm-executor.d.ts +34 -0
  91. package/ccw/dist/tools/litellm-executor.d.ts.map +1 -0
  92. package/ccw/dist/tools/litellm-executor.js +192 -0
  93. package/ccw/dist/tools/litellm-executor.js.map +1 -0
  94. package/ccw/dist/tools/pattern-parser.d.ts +55 -0
  95. package/ccw/dist/tools/pattern-parser.d.ts.map +1 -0
  96. package/ccw/dist/tools/pattern-parser.js +237 -0
  97. package/ccw/dist/tools/pattern-parser.js.map +1 -0
  98. package/ccw/dist/tools/smart-search.d.ts +1 -0
  99. package/ccw/dist/tools/smart-search.d.ts.map +1 -1
  100. package/ccw/dist/tools/smart-search.js +117 -41
  101. package/ccw/dist/tools/smart-search.js.map +1 -1
  102. package/ccw/dist/types/litellm-api-config.d.ts +294 -0
  103. package/ccw/dist/types/litellm-api-config.d.ts.map +1 -0
  104. package/ccw/dist/types/litellm-api-config.js +8 -0
  105. package/ccw/dist/types/litellm-api-config.js.map +1 -0
  106. package/ccw/src/cli.ts +258 -244
  107. package/ccw/src/commands/cli.ts +153 -9
  108. package/ccw/src/commands/hook.ts +3 -2
  109. package/ccw/src/config/.litellm-api-config-manager.ts.2025-12-23T11-57-43-727Z.bak +441 -0
  110. package/ccw/src/config/litellm-api-config-manager.ts +1012 -0
  111. package/ccw/src/config/provider-models.ts +222 -0
  112. package/ccw/src/core/cache-manager.ts +292 -294
  113. package/ccw/src/core/dashboard-generator.ts +3 -1
  114. package/ccw/src/core/routes/cli-routes.ts +192 -0
  115. package/ccw/src/core/routes/codexlens-routes.ts +241 -19
  116. package/ccw/src/core/routes/hooks-routes.ts +399 -405
  117. package/ccw/src/core/routes/litellm-api-routes.ts +930 -0
  118. package/ccw/src/core/routes/litellm-routes.ts +107 -0
  119. package/ccw/src/core/routes/mcp-routes.ts +1271 -1271
  120. package/ccw/src/core/routes/status-routes.ts +51 -0
  121. package/ccw/src/core/routes/system-routes.ts +1 -1
  122. package/ccw/src/core/server.ts +15 -1
  123. package/ccw/src/mcp-server/index.ts +1 -1
  124. package/ccw/src/templates/dashboard-css/12-cli-legacy.css +44 -0
  125. package/ccw/src/templates/dashboard-css/31-api-settings.css +2265 -0
  126. package/ccw/src/templates/dashboard-js/components/cli-history.js +15 -8
  127. package/ccw/src/templates/dashboard-js/components/cli-status.js +323 -9
  128. package/ccw/src/templates/dashboard-js/components/navigation.js +329 -313
  129. package/ccw/src/templates/dashboard-js/i18n.js +583 -1
  130. package/ccw/src/templates/dashboard-js/views/api-settings.js +3362 -0
  131. package/ccw/src/templates/dashboard-js/views/cli-manager.js +199 -24
  132. package/ccw/src/templates/dashboard-js/views/codexlens-manager.js +1265 -27
  133. package/ccw/src/templates/dashboard.html +840 -831
  134. package/ccw/src/tools/claude-cli-tools.ts +300 -0
  135. package/ccw/src/tools/cli-executor.ts +83 -14
  136. package/ccw/src/tools/codex-lens.ts +146 -9
  137. package/ccw/src/tools/context-cache-store.ts +368 -0
  138. package/ccw/src/tools/context-cache.ts +393 -0
  139. package/ccw/src/tools/core-memory.ts +33 -19
  140. package/ccw/src/tools/index.ts +2 -0
  141. package/ccw/src/tools/litellm-client.ts +246 -0
  142. package/ccw/src/tools/litellm-executor.ts +241 -0
  143. package/ccw/src/tools/pattern-parser.ts +329 -0
  144. package/ccw/src/tools/smart-search.ts +142 -41
  145. package/ccw/src/types/litellm-api-config.ts +402 -0
  146. package/ccw-litellm/README.md +180 -0
  147. package/ccw-litellm/pyproject.toml +35 -0
  148. package/ccw-litellm/src/ccw_litellm/__init__.py +47 -0
  149. package/ccw-litellm/src/ccw_litellm/__pycache__/__init__.cpython-313.pyc +0 -0
  150. package/ccw-litellm/src/ccw_litellm/__pycache__/cli.cpython-313.pyc +0 -0
  151. package/ccw-litellm/src/ccw_litellm/cli.py +108 -0
  152. package/ccw-litellm/src/ccw_litellm/clients/__init__.py +12 -0
  153. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/__init__.cpython-313.pyc +0 -0
  154. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_embedder.cpython-313.pyc +0 -0
  155. package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_llm.cpython-313.pyc +0 -0
  156. package/ccw-litellm/src/ccw_litellm/clients/litellm_embedder.py +251 -0
  157. package/ccw-litellm/src/ccw_litellm/clients/litellm_llm.py +165 -0
  158. package/ccw-litellm/src/ccw_litellm/config/__init__.py +22 -0
  159. package/ccw-litellm/src/ccw_litellm/config/__pycache__/__init__.cpython-313.pyc +0 -0
  160. package/ccw-litellm/src/ccw_litellm/config/__pycache__/loader.cpython-313.pyc +0 -0
  161. package/ccw-litellm/src/ccw_litellm/config/__pycache__/models.cpython-313.pyc +0 -0
  162. package/ccw-litellm/src/ccw_litellm/config/loader.py +316 -0
  163. package/ccw-litellm/src/ccw_litellm/config/models.py +130 -0
  164. package/ccw-litellm/src/ccw_litellm/interfaces/__init__.py +14 -0
  165. package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/__init__.cpython-313.pyc +0 -0
  166. package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/embedder.cpython-313.pyc +0 -0
  167. package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/llm.cpython-313.pyc +0 -0
  168. package/ccw-litellm/src/ccw_litellm/interfaces/embedder.py +52 -0
  169. package/ccw-litellm/src/ccw_litellm/interfaces/llm.py +45 -0
  170. package/codex-lens/src/codexlens/__pycache__/config.cpython-313.pyc +0 -0
  171. package/codex-lens/src/codexlens/cli/__pycache__/commands.cpython-313.pyc +0 -0
  172. package/codex-lens/src/codexlens/cli/__pycache__/embedding_manager.cpython-313.pyc +0 -0
  173. package/codex-lens/src/codexlens/cli/__pycache__/model_manager.cpython-313.pyc +0 -0
  174. package/codex-lens/src/codexlens/cli/__pycache__/output.cpython-313.pyc +0 -0
  175. package/codex-lens/src/codexlens/cli/commands.py +378 -23
  176. package/codex-lens/src/codexlens/cli/embedding_manager.py +660 -56
  177. package/codex-lens/src/codexlens/cli/model_manager.py +31 -18
  178. package/codex-lens/src/codexlens/cli/output.py +12 -1
  179. package/codex-lens/src/codexlens/config.py +93 -0
  180. package/codex-lens/src/codexlens/search/__pycache__/chain_search.cpython-313.pyc +0 -0
  181. package/codex-lens/src/codexlens/search/__pycache__/hybrid_search.cpython-313.pyc +0 -0
  182. package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-313.pyc +0 -0
  183. package/codex-lens/src/codexlens/search/chain_search.py +6 -2
  184. package/codex-lens/src/codexlens/search/hybrid_search.py +44 -21
  185. package/codex-lens/src/codexlens/search/ranking.py +1 -1
  186. package/codex-lens/src/codexlens/semantic/__init__.py +42 -0
  187. package/codex-lens/src/codexlens/semantic/__pycache__/__init__.cpython-313.pyc +0 -0
  188. package/codex-lens/src/codexlens/semantic/__pycache__/base.cpython-313.pyc +0 -0
  189. package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-313.pyc +0 -0
  190. package/codex-lens/src/codexlens/semantic/__pycache__/embedder.cpython-313.pyc +0 -0
  191. package/codex-lens/src/codexlens/semantic/__pycache__/factory.cpython-313.pyc +0 -0
  192. package/codex-lens/src/codexlens/semantic/__pycache__/gpu_support.cpython-313.pyc +0 -0
  193. package/codex-lens/src/codexlens/semantic/__pycache__/litellm_embedder.cpython-313.pyc +0 -0
  194. package/codex-lens/src/codexlens/semantic/__pycache__/vector_store.cpython-313.pyc +0 -0
  195. package/codex-lens/src/codexlens/semantic/base.py +61 -0
  196. package/codex-lens/src/codexlens/semantic/chunker.py +43 -20
  197. package/codex-lens/src/codexlens/semantic/embedder.py +60 -13
  198. package/codex-lens/src/codexlens/semantic/factory.py +98 -0
  199. package/codex-lens/src/codexlens/semantic/gpu_support.py +225 -3
  200. package/codex-lens/src/codexlens/semantic/litellm_embedder.py +144 -0
  201. package/codex-lens/src/codexlens/semantic/rotational_embedder.py +434 -0
  202. package/codex-lens/src/codexlens/semantic/vector_store.py +33 -8
  203. package/codex-lens/src/codexlens/storage/__pycache__/path_mapper.cpython-313.pyc +0 -0
  204. package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_004_dual_fts.cpython-313.pyc +0 -0
  205. package/codex-lens/src/codexlens/storage/path_mapper.py +27 -1
  206. package/package.json +15 -5
  207. package/.codex/prompts.zip +0 -0
  208. package/ccw/package.json +0 -65
@@ -0,0 +1,402 @@
1
+ /**
2
+ * LiteLLM API Configuration Type Definitions
3
+ *
4
+ * Defines types for provider credentials, cache strategies, custom endpoints,
5
+ * and the overall configuration structure for LiteLLM API integration.
6
+ */
7
+
8
+ /**
9
+ * API format types (simplified)
10
+ * Most providers use OpenAI-compatible format
11
+ */
12
+ export type ProviderType =
13
+ | 'openai' // OpenAI-compatible format (most providers)
14
+ | 'anthropic' // Anthropic format
15
+ | 'custom'; // Custom format
16
+
17
+ /**
18
+ * Advanced provider settings for LiteLLM compatibility
19
+ * Maps to LiteLLM's provider configuration options
20
+ */
21
+ export interface ProviderAdvancedSettings {
22
+ /** Request timeout in seconds (default: 300) */
23
+ timeout?: number;
24
+
25
+ /** Maximum retry attempts on failure (default: 3) */
26
+ maxRetries?: number;
27
+
28
+ /** Organization ID (OpenAI-specific) */
29
+ organization?: string;
30
+
31
+ /** API version string (Azure-specific, e.g., "2024-02-01") */
32
+ apiVersion?: string;
33
+
34
+ /** Custom HTTP headers as JSON object */
35
+ customHeaders?: Record<string, string>;
36
+
37
+ /** Requests per minute rate limit */
38
+ rpm?: number;
39
+
40
+ /** Tokens per minute rate limit */
41
+ tpm?: number;
42
+
43
+ /** Proxy server URL (e.g., "http://proxy.example.com:8080") */
44
+ proxy?: string;
45
+ }
46
+
47
+ /**
48
+ * Model type classification
49
+ */
50
+ export type ModelType = 'llm' | 'embedding';
51
+
52
+ /**
53
+ * Model capability metadata
54
+ */
55
+ export interface ModelCapabilities {
56
+ /** Whether the model supports streaming responses */
57
+ streaming?: boolean;
58
+
59
+ /** Whether the model supports function/tool calling */
60
+ functionCalling?: boolean;
61
+
62
+ /** Whether the model supports vision/image input */
63
+ vision?: boolean;
64
+
65
+ /** Context window size in tokens */
66
+ contextWindow?: number;
67
+
68
+ /** Embedding dimension (for embedding models only) */
69
+ embeddingDimension?: number;
70
+
71
+ /** Maximum output tokens */
72
+ maxOutputTokens?: number;
73
+ }
74
+
75
+ /**
76
+ * Routing strategy for load balancing across multiple keys
77
+ */
78
+ export type RoutingStrategy =
79
+ | 'simple-shuffle' // Random selection (default, recommended)
80
+ | 'weighted' // Weight-based distribution
81
+ | 'latency-based' // Route to lowest latency
82
+ | 'cost-based' // Route to lowest cost
83
+ | 'least-busy'; // Route to least concurrent
84
+
85
+ /**
86
+ * Individual API key configuration with optional weight
87
+ */
88
+ export interface ApiKeyEntry {
89
+ /** Unique identifier */
90
+ id: string;
91
+
92
+ /** API key value or env var reference */
93
+ key: string;
94
+
95
+ /** Display label for this key */
96
+ label?: string;
97
+
98
+ /** Weight for weighted routing (default: 1) */
99
+ weight?: number;
100
+
101
+ /** Whether this key is enabled */
102
+ enabled: boolean;
103
+
104
+ /** Last health check status */
105
+ healthStatus?: 'healthy' | 'unhealthy' | 'unknown';
106
+
107
+ /** Last health check timestamp */
108
+ lastHealthCheck?: string;
109
+
110
+ /** Error message if unhealthy */
111
+ lastError?: string;
112
+ }
113
+
114
+ /**
115
+ * Health check configuration
116
+ */
117
+ export interface HealthCheckConfig {
118
+ /** Enable automatic health checks */
119
+ enabled: boolean;
120
+
121
+ /** Check interval in seconds (default: 300) */
122
+ intervalSeconds: number;
123
+
124
+ /** Cooldown period after failure in seconds (default: 5) */
125
+ cooldownSeconds: number;
126
+
127
+ /** Number of failures before marking unhealthy (default: 3) */
128
+ failureThreshold: number;
129
+ }
130
+
131
+
132
+ /**
133
+ * Model-specific endpoint settings
134
+ * Allows per-model configuration overrides
135
+ */
136
+ export interface ModelEndpointSettings {
137
+ /** Override base URL for this model */
138
+ baseUrl?: string;
139
+
140
+ /** Override timeout for this model */
141
+ timeout?: number;
142
+
143
+ /** Override max retries for this model */
144
+ maxRetries?: number;
145
+
146
+ /** Custom headers for this model */
147
+ customHeaders?: Record<string, string>;
148
+
149
+ /** Cache strategy for this model */
150
+ cacheStrategy?: CacheStrategy;
151
+ }
152
+
153
+ /**
154
+ * Model definition with type and grouping
155
+ */
156
+ export interface ModelDefinition {
157
+ /** Unique identifier for this model */
158
+ id: string;
159
+
160
+ /** Display name for UI */
161
+ name: string;
162
+
163
+ /** Model type: LLM or Embedding */
164
+ type: ModelType;
165
+
166
+ /** Model series for grouping (e.g., "GPT-4", "Claude-3") */
167
+ series: string;
168
+
169
+ /** Whether this model is enabled */
170
+ enabled: boolean;
171
+
172
+ /** Model capabilities */
173
+ capabilities?: ModelCapabilities;
174
+
175
+ /** Model-specific endpoint settings */
176
+ endpointSettings?: ModelEndpointSettings;
177
+
178
+ /** Optional description */
179
+ description?: string;
180
+
181
+ /** Creation timestamp (ISO 8601) */
182
+ createdAt: string;
183
+
184
+ /** Last update timestamp (ISO 8601) */
185
+ updatedAt: string;
186
+ }
187
+
188
+ /**
189
+ * Provider credential configuration
190
+ * Stores API keys, base URLs, and provider metadata
191
+ */
192
+ export interface ProviderCredential {
193
+ /** Unique identifier for this provider configuration */
194
+ id: string;
195
+
196
+ /** Display name for UI */
197
+ name: string;
198
+
199
+ /** Provider type */
200
+ type: ProviderType;
201
+
202
+ /** API key or environment variable reference (e.g., ${OPENAI_API_KEY}) */
203
+ apiKey: string;
204
+
205
+ /** Custom API base URL (optional, overrides provider default) */
206
+ apiBase?: string;
207
+
208
+ /** Whether this provider is enabled */
209
+ enabled: boolean;
210
+
211
+ /** Advanced provider settings (optional) */
212
+ advancedSettings?: ProviderAdvancedSettings;
213
+
214
+ /** Multiple API keys for load balancing */
215
+ apiKeys?: ApiKeyEntry[];
216
+
217
+ /** Routing strategy for multi-key load balancing */
218
+ routingStrategy?: RoutingStrategy;
219
+
220
+ /** Health check configuration */
221
+ healthCheck?: HealthCheckConfig;
222
+
223
+ /** LLM models configured for this provider */
224
+ llmModels?: ModelDefinition[];
225
+
226
+ /** Embedding models configured for this provider */
227
+ embeddingModels?: ModelDefinition[];
228
+
229
+ /** Creation timestamp (ISO 8601) */
230
+ createdAt: string;
231
+
232
+ /** Last update timestamp (ISO 8601) */
233
+ updatedAt: string;
234
+ }
235
+
236
+ /**
237
+ * Cache strategy for prompt context optimization
238
+ * Enables file-based caching to reduce token usage
239
+ */
240
+ export interface CacheStrategy {
241
+ /** Whether caching is enabled for this endpoint */
242
+ enabled: boolean;
243
+
244
+ /** Time-to-live in minutes (default: 60) */
245
+ ttlMinutes: number;
246
+
247
+ /** Maximum cache size in KB (default: 512) */
248
+ maxSizeKB: number;
249
+
250
+ /** File patterns to cache (glob patterns like "*.md", "*.ts") */
251
+ filePatterns: string[];
252
+ }
253
+
254
+ /**
255
+ * Custom endpoint configuration
256
+ * Maps CLI identifiers to specific models and caching strategies
257
+ */
258
+ export interface CustomEndpoint {
259
+ /** Unique CLI identifier (used in --model flag, e.g., "my-gpt4o") */
260
+ id: string;
261
+
262
+ /** Display name for UI */
263
+ name: string;
264
+
265
+ /** Reference to provider credential ID */
266
+ providerId: string;
267
+
268
+ /** Model identifier (e.g., "gpt-4o", "claude-3-5-sonnet-20241022") */
269
+ model: string;
270
+
271
+ /** Optional description */
272
+ description?: string;
273
+
274
+ /** Cache strategy for this endpoint */
275
+ cacheStrategy: CacheStrategy;
276
+
277
+ /** Whether this endpoint is enabled */
278
+ enabled: boolean;
279
+
280
+ /** Creation timestamp (ISO 8601) */
281
+ createdAt: string;
282
+
283
+ /** Last update timestamp (ISO 8601) */
284
+ updatedAt: string;
285
+ }
286
+
287
+ /**
288
+ * Global cache settings
289
+ * Applies to all endpoints unless overridden
290
+ */
291
+ export interface GlobalCacheSettings {
292
+ /** Whether caching is globally enabled */
293
+ enabled: boolean;
294
+
295
+ /** Cache directory path (default: ~/.ccw/cache/context) */
296
+ cacheDir: string;
297
+
298
+ /** Maximum total cache size in MB (default: 100) */
299
+ maxTotalSizeMB: number;
300
+ }
301
+
302
+ /**
303
+ * CodexLens embedding provider selection for rotation
304
+ * Aggregates provider + model + all API keys
305
+ */
306
+ export interface CodexLensEmbeddingProvider {
307
+ /** Reference to provider credential ID */
308
+ providerId: string;
309
+
310
+ /** Embedding model ID from the provider */
311
+ modelId: string;
312
+
313
+ /** Whether to use all API keys from this provider (default: true) */
314
+ useAllKeys: boolean;
315
+
316
+ /** Specific API key IDs to use (if useAllKeys is false) */
317
+ selectedKeyIds?: string[];
318
+
319
+ /** Weight for weighted routing (default: 1.0, applies to all keys from this provider) */
320
+ weight: number;
321
+
322
+ /** Maximum concurrent requests per key (default: 4) */
323
+ maxConcurrentPerKey: number;
324
+
325
+ /** Whether this provider is enabled for rotation */
326
+ enabled: boolean;
327
+ }
328
+
329
+ /**
330
+ * CodexLens multi-provider embedding rotation configuration
331
+ * Aggregates multiple providers with same model for parallel rotation
332
+ */
333
+ export interface CodexLensEmbeddingRotation {
334
+ /** Whether multi-provider rotation is enabled */
335
+ enabled: boolean;
336
+
337
+ /** Selection strategy: round_robin, latency_aware, weighted_random */
338
+ strategy: 'round_robin' | 'latency_aware' | 'weighted_random';
339
+
340
+ /** Default cooldown seconds for rate-limited endpoints (default: 60) */
341
+ defaultCooldown: number;
342
+
343
+ /** Target model name that all providers should support (e.g., "qwen3-embedding") */
344
+ targetModel: string;
345
+
346
+ /** List of providers to aggregate for rotation */
347
+ providers: CodexLensEmbeddingProvider[];
348
+ }
349
+
350
+ /**
351
+ * Generic embedding pool configuration (refactored from CodexLensEmbeddingRotation)
352
+ * Supports automatic discovery of all providers offering a specific model
353
+ */
354
+ export interface EmbeddingPoolConfig {
355
+ /** Whether embedding pool is enabled */
356
+ enabled: boolean;
357
+
358
+ /** Target embedding model name (e.g., "text-embedding-3-small") */
359
+ targetModel: string;
360
+
361
+ /** Selection strategy: round_robin, latency_aware, weighted_random */
362
+ strategy: 'round_robin' | 'latency_aware' | 'weighted_random';
363
+
364
+ /** Whether to automatically discover all providers offering targetModel */
365
+ autoDiscover: boolean;
366
+
367
+ /** Provider IDs to exclude from auto-discovery (optional) */
368
+ excludedProviderIds?: string[];
369
+
370
+ /** Default cooldown seconds for rate-limited endpoints (default: 60) */
371
+ defaultCooldown: number;
372
+
373
+ /** Default maximum concurrent requests per key (default: 4) */
374
+ defaultMaxConcurrentPerKey: number;
375
+ }
376
+
377
+ /**
378
+ * Complete LiteLLM API configuration
379
+ * Root configuration object stored in JSON file
380
+ */
381
+ export interface LiteLLMApiConfig {
382
+ /** Configuration schema version */
383
+ version: number;
384
+
385
+ /** List of configured providers */
386
+ providers: ProviderCredential[];
387
+
388
+ /** List of custom endpoints */
389
+ endpoints: CustomEndpoint[];
390
+
391
+ /** Default endpoint ID (optional) */
392
+ defaultEndpoint?: string;
393
+
394
+ /** Global cache settings */
395
+ globalCacheSettings: GlobalCacheSettings;
396
+
397
+ /** CodexLens multi-provider embedding rotation config (deprecated, use embeddingPoolConfig) */
398
+ codexlensEmbeddingRotation?: CodexLensEmbeddingRotation;
399
+
400
+ /** Generic embedding pool configuration with auto-discovery support */
401
+ embeddingPoolConfig?: EmbeddingPoolConfig;
402
+ }
@@ -0,0 +1,180 @@
1
+ # ccw-litellm
2
+
3
+ Unified LiteLLM interface layer shared by ccw and codex-lens projects.
4
+
5
+ ## Features
6
+
7
+ - **Unified LLM Interface**: Abstract interface for LLM operations (chat, completion)
8
+ - **Unified Embedding Interface**: Abstract interface for text embeddings
9
+ - **Multi-Provider Support**: OpenAI, Anthropic, Azure, and more via LiteLLM
10
+ - **Configuration Management**: YAML-based configuration with environment variable substitution
11
+ - **Type Safety**: Full type annotations with Pydantic models
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install -e .
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ### Configuration
22
+
23
+ Create a configuration file at `~/.ccw/config/litellm-config.yaml`:
24
+
25
+ ```yaml
26
+ version: 1
27
+ default_provider: openai
28
+
29
+ providers:
30
+ openai:
31
+ api_key: ${OPENAI_API_KEY}
32
+ api_base: https://api.openai.com/v1
33
+
34
+ llm_models:
35
+ default:
36
+ provider: openai
37
+ model: gpt-4
38
+
39
+ embedding_models:
40
+ default:
41
+ provider: openai
42
+ model: text-embedding-3-small
43
+ dimensions: 1536
44
+ ```
45
+
46
+ ### Usage
47
+
48
+ #### LLM Client
49
+
50
+ ```python
51
+ from ccw_litellm import LiteLLMClient, ChatMessage
52
+
53
+ # Initialize client with default model
54
+ client = LiteLLMClient(model="default")
55
+
56
+ # Chat completion
57
+ messages = [
58
+ ChatMessage(role="user", content="Hello, how are you?")
59
+ ]
60
+ response = client.chat(messages)
61
+ print(response.content)
62
+
63
+ # Text completion
64
+ response = client.complete("Once upon a time")
65
+ print(response.content)
66
+ ```
67
+
68
+ #### Embedder
69
+
70
+ ```python
71
+ from ccw_litellm import LiteLLMEmbedder
72
+
73
+ # Initialize embedder with default model
74
+ embedder = LiteLLMEmbedder(model="default")
75
+
76
+ # Embed single text
77
+ vector = embedder.embed("Hello world")
78
+ print(vector.shape) # (1, 1536)
79
+
80
+ # Embed multiple texts
81
+ vectors = embedder.embed(["Text 1", "Text 2", "Text 3"])
82
+ print(vectors.shape) # (3, 1536)
83
+ ```
84
+
85
+ #### Custom Configuration
86
+
87
+ ```python
88
+ from ccw_litellm import LiteLLMClient, load_config
89
+
90
+ # Load custom configuration
91
+ config = load_config("/path/to/custom-config.yaml")
92
+
93
+ # Use custom configuration
94
+ client = LiteLLMClient(model="fast", config=config)
95
+ ```
96
+
97
+ ## Configuration Reference
98
+
99
+ ### Provider Configuration
100
+
101
+ ```yaml
102
+ providers:
103
+ <provider_name>:
104
+ api_key: <api_key_or_${ENV_VAR}>
105
+ api_base: <base_url>
106
+ ```
107
+
108
+ Supported providers: `openai`, `anthropic`, `azure`, `vertex_ai`, `bedrock`, etc.
109
+
110
+ ### LLM Model Configuration
111
+
112
+ ```yaml
113
+ llm_models:
114
+ <model_name>:
115
+ provider: <provider_name>
116
+ model: <model_identifier>
117
+ ```
118
+
119
+ ### Embedding Model Configuration
120
+
121
+ ```yaml
122
+ embedding_models:
123
+ <model_name>:
124
+ provider: <provider_name>
125
+ model: <model_identifier>
126
+ dimensions: <embedding_dimensions>
127
+ ```
128
+
129
+ ## Environment Variables
130
+
131
+ The configuration supports environment variable substitution using the `${VAR}` or `${VAR:-default}` syntax:
132
+
133
+ ```yaml
134
+ providers:
135
+ openai:
136
+ api_key: ${OPENAI_API_KEY} # Required
137
+ api_base: ${OPENAI_API_BASE:-https://api.openai.com/v1} # With default
138
+ ```
139
+
140
+ ## API Reference
141
+
142
+ ### Interfaces
143
+
144
+ - `AbstractLLMClient`: Abstract base class for LLM clients
145
+ - `AbstractEmbedder`: Abstract base class for embedders
146
+ - `ChatMessage`: Message data class (role, content)
147
+ - `LLMResponse`: Response data class (content, raw)
148
+
149
+ ### Implementations
150
+
151
+ - `LiteLLMClient`: LiteLLM implementation of AbstractLLMClient
152
+ - `LiteLLMEmbedder`: LiteLLM implementation of AbstractEmbedder
153
+
154
+ ### Configuration
155
+
156
+ - `LiteLLMConfig`: Root configuration model
157
+ - `ProviderConfig`: Provider configuration model
158
+ - `LLMModelConfig`: LLM model configuration model
159
+ - `EmbeddingModelConfig`: Embedding model configuration model
160
+ - `load_config(path)`: Load configuration from YAML file
161
+ - `get_config(path, reload)`: Get global configuration singleton
162
+ - `reset_config()`: Reset global configuration (for testing)
163
+
164
+ ## Development
165
+
166
+ ### Running Tests
167
+
168
+ ```bash
169
+ pytest tests/ -v
170
+ ```
171
+
172
+ ### Type Checking
173
+
174
+ ```bash
175
+ mypy src/ccw_litellm
176
+ ```
177
+
178
+ ## License
179
+
180
+ MIT
@@ -0,0 +1,35 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ccw-litellm"
7
+ version = "0.1.0"
8
+ description = "Unified LiteLLM interface layer shared by ccw and codex-lens"
9
+ requires-python = ">=3.10"
10
+ authors = [{ name = "ccw-litellm contributors" }]
11
+ dependencies = [
12
+ "litellm>=1.0.0",
13
+ "pyyaml",
14
+ "numpy",
15
+ "pydantic>=2.0",
16
+ ]
17
+
18
+ [project.optional-dependencies]
19
+ dev = [
20
+ "pytest>=7.0",
21
+ ]
22
+
23
+ [project.scripts]
24
+ ccw-litellm = "ccw_litellm.cli:main"
25
+
26
+ [tool.setuptools]
27
+ package-dir = { "" = "src" }
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["src"]
31
+ include = ["ccw_litellm*"]
32
+
33
+ [tool.pytest.ini_options]
34
+ testpaths = ["tests"]
35
+ addopts = "-q"
@@ -0,0 +1,47 @@
1
+ """ccw-litellm package.
2
+
3
+ This package provides a small, stable interface layer around LiteLLM to share
4
+ between the ccw and codex-lens projects.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from .clients import LiteLLMClient, LiteLLMEmbedder
10
+ from .config import (
11
+ EmbeddingModelConfig,
12
+ LiteLLMConfig,
13
+ LLMModelConfig,
14
+ ProviderConfig,
15
+ get_config,
16
+ load_config,
17
+ reset_config,
18
+ )
19
+ from .interfaces import (
20
+ AbstractEmbedder,
21
+ AbstractLLMClient,
22
+ ChatMessage,
23
+ LLMResponse,
24
+ )
25
+
26
+ __version__ = "0.1.0"
27
+
28
+ __all__ = [
29
+ "__version__",
30
+ # Abstract interfaces
31
+ "AbstractEmbedder",
32
+ "AbstractLLMClient",
33
+ "ChatMessage",
34
+ "LLMResponse",
35
+ # Client implementations
36
+ "LiteLLMClient",
37
+ "LiteLLMEmbedder",
38
+ # Configuration
39
+ "LiteLLMConfig",
40
+ "ProviderConfig",
41
+ "LLMModelConfig",
42
+ "EmbeddingModelConfig",
43
+ "load_config",
44
+ "get_config",
45
+ "reset_config",
46
+ ]
47
+