maskweaver 0.9.4 → 0.9.5

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 (227) hide show
  1. package/dist/cli/doctor.js +5 -21
  2. package/dist/cli/install.d.ts +0 -8
  3. package/dist/cli/install.js +0 -39
  4. package/dist/context/config.d.ts +0 -22
  5. package/dist/context/config.js +0 -28
  6. package/dist/context/feature.d.ts +0 -39
  7. package/dist/context/feature.js +0 -77
  8. package/dist/context/files.d.ts +0 -13
  9. package/dist/context/files.js +1 -24
  10. package/dist/context/index.d.ts +0 -7
  11. package/dist/context/index.js +0 -12
  12. package/dist/context/project.d.ts +0 -21
  13. package/dist/context/project.js +0 -30
  14. package/dist/context/types.d.ts +0 -48
  15. package/dist/context/types.js +0 -12
  16. package/dist/context/utils.d.ts +0 -18
  17. package/dist/context/utils.js +0 -27
  18. package/dist/core/engine/promptBuilder.d.ts +0 -17
  19. package/dist/core/engine/promptBuilder.js +0 -28
  20. package/dist/core/index.d.ts +0 -6
  21. package/dist/core/index.js +0 -9
  22. package/dist/core/loader/MaskLoader.d.ts +0 -23
  23. package/dist/core/loader/MaskLoader.js +0 -29
  24. package/dist/core/schema/types.d.ts +0 -47
  25. package/dist/core/schema/types.js +0 -6
  26. package/dist/core/schema/validator.d.ts +0 -14
  27. package/dist/core/schema/validator.js +0 -18
  28. package/dist/i18n/index.d.ts +0 -18
  29. package/dist/i18n/index.js +4 -23
  30. package/dist/index.d.ts +0 -8
  31. package/dist/index.js +0 -8
  32. package/dist/lib.d.ts +0 -5
  33. package/dist/lib.js +0 -12
  34. package/dist/memory/chunking.d.ts +0 -22
  35. package/dist/memory/chunking.js +2 -37
  36. package/dist/memory/core.d.ts +0 -29
  37. package/dist/memory/core.js +1 -52
  38. package/dist/memory/index.d.ts +0 -5
  39. package/dist/memory/index.js +0 -10
  40. package/dist/memory/indexer.d.ts +0 -21
  41. package/dist/memory/indexer.js +0 -44
  42. package/dist/memory/providers/examples.d.ts +0 -5
  43. package/dist/memory/providers/examples.js +4 -64
  44. package/dist/memory/providers/factory.d.ts +0 -44
  45. package/dist/memory/providers/factory.js +0 -46
  46. package/dist/memory/providers/index.d.ts +0 -26
  47. package/dist/memory/providers/index.js +0 -28
  48. package/dist/memory/providers/ollama.d.ts +0 -6
  49. package/dist/memory/providers/ollama.js +1 -8
  50. package/dist/memory/providers/openai.d.ts +0 -6
  51. package/dist/memory/providers/openai.js +1 -8
  52. package/dist/memory/providers/openrouter.d.ts +0 -6
  53. package/dist/memory/providers/openrouter.js +0 -8
  54. package/dist/memory/providers/text-only.d.ts +0 -13
  55. package/dist/memory/providers/text-only.js +0 -17
  56. package/dist/memory/providers/types.d.ts +0 -39
  57. package/dist/memory/providers/types.js +0 -7
  58. package/dist/memory/providers/voyage.d.ts +0 -22
  59. package/dist/memory/providers/voyage.js +1 -24
  60. package/dist/memory/search/hybrid.d.ts +0 -12
  61. package/dist/memory/search/hybrid.js +1 -22
  62. package/dist/memory/store/sqlite.d.ts +0 -72
  63. package/dist/memory/store/sqlite.js +4 -127
  64. package/dist/plugin/config/index.d.ts +0 -112
  65. package/dist/plugin/config/index.js +0 -115
  66. package/dist/plugin/index.d.ts +0 -13
  67. package/dist/plugin/index.js +1 -123
  68. package/dist/plugin/tools/command-registry.d.ts +0 -6
  69. package/dist/plugin/tools/command-registry.js +0 -14
  70. package/dist/plugin/tools/context.d.ts +0 -12
  71. package/dist/plugin/tools/context.js +0 -58
  72. package/dist/plugin/tools/maskSave.d.ts +0 -3
  73. package/dist/plugin/tools/maskSave.js +0 -3
  74. package/dist/plugin/tools/memoryGet.d.ts +0 -3
  75. package/dist/plugin/tools/memoryGet.js +0 -3
  76. package/dist/plugin/tools/memoryIndexer.d.ts +0 -3
  77. package/dist/plugin/tools/memoryIndexer.js +0 -10
  78. package/dist/plugin/tools/memorySearch.d.ts +0 -31
  79. package/dist/plugin/tools/memorySearch.js +0 -79
  80. package/dist/plugin/tools/memoryWrite.d.ts +0 -8
  81. package/dist/plugin/tools/memoryWrite.js +0 -32
  82. package/dist/plugin/tools/retrospect.d.ts +0 -3
  83. package/dist/plugin/tools/retrospect.js +0 -3
  84. package/dist/plugin/tools/slashcommand.d.ts +0 -11
  85. package/dist/plugin/tools/slashcommand.js +0 -38
  86. package/dist/plugin/tools/squad.d.ts +0 -12
  87. package/dist/plugin/tools/squad.js +11 -83
  88. package/dist/plugin/tools/weave.d.ts +0 -6
  89. package/dist/plugin/tools/weave.js +0 -78
  90. package/dist/plugin/types.d.ts +0 -20
  91. package/dist/plugin/types.js +0 -7
  92. package/dist/retrospect/index.d.ts +0 -7
  93. package/dist/retrospect/index.js +0 -9
  94. package/dist/retrospect/mask-save.d.ts +0 -12
  95. package/dist/retrospect/mask-save.js +1 -80
  96. package/dist/retrospect/retrospect.d.ts +0 -18
  97. package/dist/retrospect/retrospect.js +0 -63
  98. package/dist/retrospect/strategies/base.d.ts +0 -15
  99. package/dist/retrospect/strategies/base.js +0 -7
  100. package/dist/retrospect/strategies/deep.d.ts +0 -12
  101. package/dist/retrospect/strategies/deep.js +0 -24
  102. package/dist/retrospect/strategies/index.d.ts +0 -12
  103. package/dist/retrospect/strategies/index.js +0 -12
  104. package/dist/retrospect/strategies/quick.d.ts +0 -12
  105. package/dist/retrospect/strategies/quick.js +0 -19
  106. package/dist/retrospect/strategies/standard.d.ts +0 -12
  107. package/dist/retrospect/strategies/standard.js +0 -15
  108. package/dist/retrospect/types.d.ts +0 -7
  109. package/dist/retrospect/types.js +0 -7
  110. package/dist/shared/config.d.ts +0 -105
  111. package/dist/shared/config.js +0 -33
  112. package/dist/shared/errors.d.ts +0 -18
  113. package/dist/shared/errors.js +0 -19
  114. package/dist/shared/generate-agents.d.ts +0 -69
  115. package/dist/shared/generate-agents.js +2 -86
  116. package/dist/shared/image.d.ts +0 -67
  117. package/dist/shared/image.js +6 -104
  118. package/dist/shared/index.d.ts +0 -5
  119. package/dist/shared/index.js +0 -7
  120. package/dist/shared/model-registry.d.ts +0 -72
  121. package/dist/shared/model-registry.js +5 -95
  122. package/dist/shared/types.d.ts +0 -15
  123. package/dist/shared/types.js +0 -3
  124. package/dist/shared-context/dag.d.ts +0 -105
  125. package/dist/shared-context/dag.js +3 -114
  126. package/dist/shared-context/index.d.ts +0 -5
  127. package/dist/shared-context/index.js +0 -15
  128. package/dist/shared-context/logger.d.ts +0 -37
  129. package/dist/shared-context/logger.js +0 -41
  130. package/dist/shared-context/parallel-executor.d.ts +0 -54
  131. package/dist/shared-context/parallel-executor.js +4 -56
  132. package/dist/shared-context/session.d.ts +0 -56
  133. package/dist/shared-context/session.js +0 -47
  134. package/dist/shared-context/squad.d.ts +0 -68
  135. package/dist/shared-context/squad.js +0 -63
  136. package/dist/shared-context/storage.d.ts +0 -132
  137. package/dist/shared-context/storage.js +0 -116
  138. package/dist/shared-context/task.d.ts +0 -120
  139. package/dist/shared-context/task.js +0 -152
  140. package/dist/shared-context/test/dag.test.js +9 -14
  141. package/dist/shared-context/test/logger.test.d.ts +0 -8
  142. package/dist/shared-context/test/logger.test.js +0 -52
  143. package/dist/shared-context/test/session.test.d.ts +0 -7
  144. package/dist/shared-context/test/session.test.js +0 -63
  145. package/dist/shared-context/test/squad.test.d.ts +0 -10
  146. package/dist/shared-context/test/squad.test.js +2 -68
  147. package/dist/shared-context/test/storage.test.d.ts +0 -8
  148. package/dist/shared-context/test/storage.test.js +0 -68
  149. package/dist/shared-context/test/task.test.d.ts +0 -7
  150. package/dist/shared-context/test/task.test.js +0 -54
  151. package/dist/shared-context/test/watchdog.test.d.ts +0 -7
  152. package/dist/shared-context/test/watchdog.test.js +3 -58
  153. package/dist/shared-context/types.d.ts +0 -215
  154. package/dist/shared-context/types.js +0 -125
  155. package/dist/shared-context/watchdog.d.ts +0 -127
  156. package/dist/shared-context/watchdog.js +0 -148
  157. package/dist/shared-context/worktree.d.ts +0 -68
  158. package/dist/shared-context/worktree.js +2 -34
  159. package/dist/verify/budget.d.ts +0 -29
  160. package/dist/verify/budget.js +0 -34
  161. package/dist/verify/critical-files.d.ts +0 -17
  162. package/dist/verify/critical-files.js +0 -37
  163. package/dist/verify/escalation.d.ts +0 -20
  164. package/dist/verify/escalation.js +0 -22
  165. package/dist/verify/index.d.ts +0 -5
  166. package/dist/verify/index.js +0 -11
  167. package/dist/verify/prompts.d.ts +0 -20
  168. package/dist/verify/prompts.js +0 -20
  169. package/dist/verify/types.d.ts +0 -26
  170. package/dist/verify/types.js +1 -12
  171. package/dist/verify/verifier.d.ts +0 -29
  172. package/dist/verify/verifier.js +0 -54
  173. package/dist/version.d.ts +1 -16
  174. package/dist/version.js +1 -16
  175. package/dist/weave/bridge.d.ts +0 -35
  176. package/dist/weave/bridge.js +0 -51
  177. package/dist/weave/environment/detector.d.ts +0 -6
  178. package/dist/weave/environment/detector.js +4 -45
  179. package/dist/weave/environment/index.d.ts +0 -19
  180. package/dist/weave/environment/index.js +1 -39
  181. package/dist/weave/environment/issues.d.ts +0 -35
  182. package/dist/weave/environment/issues.js +0 -59
  183. package/dist/weave/git.d.ts +0 -8
  184. package/dist/weave/git.js +0 -8
  185. package/dist/weave/index.d.ts +0 -13
  186. package/dist/weave/index.js +2 -28
  187. package/dist/weave/knowledge/global.d.ts +0 -39
  188. package/dist/weave/knowledge/global.js +2 -78
  189. package/dist/weave/loop.js +0 -3
  190. package/dist/weave/orchestrator.d.ts +0 -69
  191. package/dist/weave/orchestrator.js +1 -101
  192. package/dist/weave/phase-manager.d.ts +0 -64
  193. package/dist/weave/phase-manager.js +0 -89
  194. package/dist/weave/security/secret-scan.d.ts +0 -14
  195. package/dist/weave/security/secret-scan.js +0 -19
  196. package/dist/weave/stages/build.js +0 -15
  197. package/dist/weave/stages/execute.d.ts +0 -42
  198. package/dist/weave/stages/execute.js +4 -86
  199. package/dist/weave/stages/handoff.d.ts +0 -7
  200. package/dist/weave/stages/handoff.js +0 -43
  201. package/dist/weave/stages/index.d.ts +0 -3
  202. package/dist/weave/stages/index.js +0 -3
  203. package/dist/weave/stages/intake.d.ts +0 -8
  204. package/dist/weave/stages/intake.js +5 -65
  205. package/dist/weave/stages/map.d.ts +0 -1
  206. package/dist/weave/stages/openspec.d.ts +0 -1
  207. package/dist/weave/stages/plan.d.ts +0 -11
  208. package/dist/weave/stages/plan.js +1 -53
  209. package/dist/weave/stages/refine.d.ts +0 -7
  210. package/dist/weave/stages/refine.js +0 -7
  211. package/dist/weave/stages/research.d.ts +0 -6
  212. package/dist/weave/stages/research.js +0 -6
  213. package/dist/weave/stages/spec.d.ts +0 -12
  214. package/dist/weave/stages/spec.js +0 -17
  215. package/dist/weave/types.d.ts +0 -20
  216. package/dist/weave/types.js +0 -5
  217. package/dist/weave/verification/commands.d.ts +0 -12
  218. package/dist/weave/verification/commands.js +0 -19
  219. package/dist/weave/verification/index.d.ts +0 -6
  220. package/dist/weave/verification/index.js +1 -19
  221. package/dist/weave/verification/playwright.d.ts +0 -47
  222. package/dist/weave/verification/playwright.js +1 -90
  223. package/dist/weave/worktree.d.ts +0 -16
  224. package/dist/weave/worktree.js +0 -23
  225. package/dist/weave/yaml-repair.d.ts +0 -39
  226. package/dist/weave/yaml-repair.js +13 -116
  227. package/package.json +1 -1
@@ -1,20 +1,6 @@
1
- /**
2
- * @maskweaver/shared - Image Normalization Utilities
3
- *
4
- * LLM Vision API를 위한 이미지 정규화 유틸리티
5
- * 모든 주요 LLM (OpenAI, Claude, Gemini, Kimi)이 지원하는 포맷으로 변환
6
- *
7
- * 지원 포맷: JPEG, PNG, WebP, GIF (모든 LLM 공통)
8
- * 권장 설정: JPEG (최대 호환성), 2048x2048 이하
9
- */
10
1
  import * as fs from "node:fs";
11
2
  import * as path from "node:path";
12
- // ============================================================================
13
- // Constants
14
- // ============================================================================
15
- /** Universally supported formats across all major LLMs */
16
3
  const SUPPORTED_FORMATS = ["jpeg", "jpg", "png", "webp", "gif"];
17
- /** MIME type mappings */
18
4
  const MIME_TYPES = {
19
5
  jpeg: "image/jpeg",
20
6
  jpg: "image/jpeg",
@@ -22,25 +8,18 @@ const MIME_TYPES = {
22
8
  webp: "image/webp",
23
9
  gif: "image/gif",
24
10
  };
25
- /** Maximum dimensions by LLM (using most restrictive for safety) */
26
11
  const LLM_LIMITS = {
27
- maxDimension: 2048, // Safe for all LLMs
28
- maxFileSize: 20 * 1024 * 1024, // 20MB (OpenAI limit)
29
- kimiMaxDimension: 4096, // Kimi allows up to 4K
30
- claudeMaxDimension: 8000, // Claude allows up to 8000x8000
12
+ maxDimension: 2048,
13
+ maxFileSize: 20 * 1024 * 1024,
14
+ kimiMaxDimension: 4096,
15
+ claudeMaxDimension: 8000,
31
16
  };
32
- // ============================================================================
33
- // Image Detection (Pure JS - no dependencies)
34
- // ============================================================================
35
- /** Detect image format from magic bytes */
36
17
  function detectFormat(buffer) {
37
18
  if (buffer.length < 12)
38
19
  return null;
39
- // JPEG: FF D8 FF
40
20
  if (buffer[0] === 0xff && buffer[1] === 0xd8 && buffer[2] === 0xff) {
41
21
  return "jpeg";
42
22
  }
43
- // PNG: 89 50 4E 47 0D 0A 1A 0A
44
23
  if (buffer[0] === 0x89 &&
45
24
  buffer[1] === 0x50 &&
46
25
  buffer[2] === 0x4e &&
@@ -51,7 +30,6 @@ function detectFormat(buffer) {
51
30
  buffer[7] === 0x0a) {
52
31
  return "png";
53
32
  }
54
- // WebP: RIFF....WEBP
55
33
  if (buffer[0] === 0x52 &&
56
34
  buffer[1] === 0x49 &&
57
35
  buffer[2] === 0x46 &&
@@ -62,7 +40,6 @@ function detectFormat(buffer) {
62
40
  buffer[11] === 0x50) {
63
41
  return "webp";
64
42
  }
65
- // GIF: GIF87a or GIF89a
66
43
  if (buffer[0] === 0x47 &&
67
44
  buffer[1] === 0x49 &&
68
45
  buffer[2] === 0x46 &&
@@ -71,16 +48,13 @@ function detectFormat(buffer) {
71
48
  buffer[5] === 0x61) {
72
49
  return "gif";
73
50
  }
74
- // BMP: BM
75
51
  if (buffer[0] === 0x42 && buffer[1] === 0x4d) {
76
52
  return "bmp";
77
53
  }
78
- // TIFF: II or MM
79
54
  if ((buffer[0] === 0x49 && buffer[1] === 0x49) ||
80
55
  (buffer[0] === 0x4d && buffer[1] === 0x4d)) {
81
56
  return "tiff";
82
57
  }
83
- // HEIC/HEIF: ftyp followed by heic, heix, mif1, etc.
84
58
  if (buffer[4] === 0x66 &&
85
59
  buffer[5] === 0x74 &&
86
60
  buffer[6] === 0x79 &&
@@ -92,25 +66,21 @@ function detectFormat(buffer) {
92
66
  }
93
67
  return null;
94
68
  }
95
- /** Get PNG dimensions (width, height) from header */
96
69
  function getPngDimensions(buffer) {
97
- // PNG IHDR chunk starts at byte 8, width at 16, height at 20
98
70
  if (buffer.length < 24)
99
71
  return null;
100
72
  if (buffer[12] !== 0x49 || buffer[13] !== 0x48)
101
- return null; // 'IH'
73
+ return null;
102
74
  const width = buffer.readUInt32BE(16);
103
75
  const height = buffer.readUInt32BE(20);
104
76
  return { width, height };
105
77
  }
106
- /** Get JPEG dimensions (more complex due to variable structure) */
107
78
  function getJpegDimensions(buffer) {
108
- let offset = 2; // Skip SOI marker
79
+ let offset = 2;
109
80
  while (offset < buffer.length - 1) {
110
81
  if (buffer[offset] !== 0xff)
111
82
  return null;
112
83
  const marker = buffer[offset + 1];
113
- // SOF markers (Start of Frame)
114
84
  if (marker >= 0xc0 &&
115
85
  marker <= 0xcf &&
116
86
  marker !== 0xc4 &&
@@ -122,7 +92,6 @@ function getJpegDimensions(buffer) {
122
92
  const width = buffer.readUInt16BE(offset + 7);
123
93
  return { width, height };
124
94
  }
125
- // Skip to next marker
126
95
  if (marker === 0xd8 || marker === 0xd9) {
127
96
  offset += 2;
128
97
  }
@@ -136,7 +105,6 @@ function getJpegDimensions(buffer) {
136
105
  }
137
106
  return null;
138
107
  }
139
- /** Get image info without external dependencies */
140
108
  export function getImageInfo(input) {
141
109
  const buffer = typeof input === "string" ? fs.readFileSync(input) : input;
142
110
  const format = detectFormat(buffer);
@@ -157,29 +125,21 @@ export function getImageInfo(input) {
157
125
  hasAlpha: format === "png" || format === "webp",
158
126
  };
159
127
  }
160
- // ============================================================================
161
- // Normalization Logic
162
- // ============================================================================
163
- /** Check if format is supported by all LLMs */
164
128
  export function isSupported(format) {
165
129
  return SUPPORTED_FORMATS.includes(format.toLowerCase());
166
130
  }
167
- /** Check if image needs conversion */
168
131
  export function needsConversion(info, options) {
169
132
  const reasons = [];
170
133
  const maxDim = options?.maxDimension ?? LLM_LIMITS.maxDimension;
171
- // Format not supported
172
134
  if (!isSupported(info.format)) {
173
135
  reasons.push(`Format '${info.format}' not supported by all LLMs`);
174
136
  }
175
- // Too large
176
137
  if (info.width && info.width > maxDim) {
177
138
  reasons.push(`Width ${info.width}px exceeds max ${maxDim}px`);
178
139
  }
179
140
  if (info.height && info.height > maxDim) {
180
141
  reasons.push(`Height ${info.height}px exceeds max ${maxDim}px`);
181
142
  }
182
- // File too big
183
143
  if (info.sizeBytes > LLM_LIMITS.maxFileSize) {
184
144
  reasons.push(`File size ${(info.sizeBytes / 1024 / 1024).toFixed(1)}MB exceeds 20MB limit`);
185
145
  }
@@ -188,28 +148,6 @@ export function needsConversion(info, options) {
188
148
  reasons,
189
149
  };
190
150
  }
191
- /**
192
- * Normalize an image for LLM Vision API compatibility
193
- *
194
- * This is the main entry point. It will:
195
- * 1. Detect image format
196
- * 2. Check if conversion is needed
197
- * 3. Convert if necessary (requires sharp)
198
- * 4. Return base64-encoded result
199
- *
200
- * @example
201
- * ```typescript
202
- * import { normalizeImage } from 'maskweaver/shared';
203
- *
204
- * // From file path
205
- * const result = await normalizeImage('/path/to/screenshot.png');
206
- * console.log(result.base64); // Use in LLM API
207
- *
208
- * // From buffer
209
- * const buffer = fs.readFileSync('/path/to/image.bmp');
210
- * const result = await normalizeImage(buffer, { format: 'jpeg' });
211
- * ```
212
- */
213
151
  export async function normalizeImage(input, options) {
214
152
  const buffer = typeof input === "string" ? fs.readFileSync(input) : input;
215
153
  const originalPath = typeof input === "string" ? input : undefined;
@@ -219,7 +157,6 @@ export async function normalizeImage(input, options) {
219
157
  throw new Error("Unable to detect image format. File may be corrupted or unsupported.");
220
158
  }
221
159
  const checkResult = needsConversion(info, options);
222
- // If no conversion needed, return as-is
223
160
  if (!checkResult.needsConversion) {
224
161
  return {
225
162
  base64: buffer.toString("base64"),
@@ -228,14 +165,10 @@ export async function normalizeImage(input, options) {
228
165
  converted: false,
229
166
  };
230
167
  }
231
- // Conversion needed - try to use sharp if available
232
168
  warnings.push(...checkResult.reasons);
233
169
  try {
234
- // Dynamic import to avoid hard dependency
235
- // eslint-disable-next-line @typescript-eslint/no-require-imports
236
170
  const sharp = await (async () => {
237
171
  try {
238
- // Use Function constructor to avoid static analysis
239
172
  const importFn = new Function('modulePath', 'return import(modulePath)');
240
173
  return await importFn('sharp');
241
174
  }
@@ -244,9 +177,7 @@ export async function normalizeImage(input, options) {
244
177
  }
245
178
  })();
246
179
  if (!sharp) {
247
- // No sharp available - return with warnings
248
180
  if (isSupported(info.format)) {
249
- // Format is OK, just size issues - return anyway with warning
250
181
  warnings.push("Image may be too large. Install 'sharp' for automatic resizing.");
251
182
  return {
252
183
  base64: buffer.toString("base64"),
@@ -260,12 +191,10 @@ export async function normalizeImage(input, options) {
260
191
  throw new Error(`Image format '${info.format}' requires conversion. Install 'sharp' package: npm install sharp`);
261
192
  }
262
193
  }
263
- // Use sharp for conversion
264
194
  const targetFormat = options?.format ?? "jpeg";
265
195
  const maxDim = options?.maxDimension ?? LLM_LIMITS.maxDimension;
266
196
  const quality = options?.quality ?? 85;
267
197
  let pipeline = sharp.default(buffer);
268
- // Resize if needed
269
198
  if ((info.width && info.width > maxDim) ||
270
199
  (info.height && info.height > maxDim)) {
271
200
  pipeline = pipeline.resize(maxDim, maxDim, {
@@ -273,7 +202,6 @@ export async function normalizeImage(input, options) {
273
202
  withoutEnlargement: true,
274
203
  });
275
204
  }
276
- // Convert format
277
205
  if (targetFormat === "jpeg") {
278
206
  pipeline = pipeline.jpeg({ quality });
279
207
  }
@@ -299,22 +227,9 @@ export async function normalizeImage(input, options) {
299
227
  throw new Error(`Image conversion failed: ${error}`);
300
228
  }
301
229
  }
302
- /**
303
- * Normalize image and save to file
304
- *
305
- * @example
306
- * ```typescript
307
- * const outputPath = await normalizeImageToFile(
308
- * '/path/to/screenshot.bmp',
309
- * '/path/to/output.jpg',
310
- * { format: 'jpeg', quality: 90 }
311
- * );
312
- * ```
313
- */
314
230
  export async function normalizeImageToFile(input, outputPath, options) {
315
231
  const result = await normalizeImage(input, options);
316
232
  const buffer = Buffer.from(result.base64, "base64");
317
- // Ensure directory exists
318
233
  const dir = path.dirname(outputPath);
319
234
  if (!fs.existsSync(dir)) {
320
235
  fs.mkdirSync(dir, { recursive: true });
@@ -322,15 +237,11 @@ export async function normalizeImageToFile(input, outputPath, options) {
322
237
  fs.writeFileSync(outputPath, buffer);
323
238
  return outputPath;
324
239
  }
325
- /**
326
- * Quick check if an image file is LLM-compatible without loading full file
327
- */
328
240
  export function isLLMCompatible(filePath) {
329
241
  const issues = [];
330
242
  if (!fs.existsSync(filePath)) {
331
243
  return { compatible: false, format: null, issues: ["File not found"] };
332
244
  }
333
- // Read only first 24 bytes for format detection
334
245
  const fd = fs.openSync(filePath, "r");
335
246
  const header = Buffer.alloc(24);
336
247
  fs.readSync(fd, header, 0, 24, 0);
@@ -352,15 +263,6 @@ export function isLLMCompatible(filePath) {
352
263
  issues,
353
264
  };
354
265
  }
355
- /**
356
- * Create LLM-ready image data URL
357
- *
358
- * @example
359
- * ```typescript
360
- * const dataUrl = await createImageDataUrl('/path/to/image.png');
361
- * // Returns: "data:image/png;base64,iVBORw0KGgo..."
362
- * ```
363
- */
364
266
  export async function createImageDataUrl(input, options) {
365
267
  const result = await normalizeImage(input, options);
366
268
  return `data:${result.mimeType};base64,${result.base64}`;
@@ -1,8 +1,3 @@
1
- /**
2
- * @maskweaver/shared
3
- *
4
- * Common types, errors, and configuration for Maskweaver
5
- */
6
1
  export type { Result, HealthCheckResult, LogLevel, FeatureStatus, } from "./types.js";
7
2
  export { MaskweaverError, ConfigError, ProviderError, StorageError, ValidationError, } from "./errors.js";
8
3
  export type { MemoryProviderType, VerifyMode, ReviewerType, RetrospectDepth, ContextConfig, MemoryConfig, RetrospectConfig, VerifyConfig, FeaturesConfig, MemoryProviderConfigs, VerifyConfigOptions, LoggingConfig, MaskweaverConfig, } from "./config.js";
@@ -1,11 +1,4 @@
1
- /**
2
- * @maskweaver/shared
3
- *
4
- * Common types, errors, and configuration for Maskweaver
5
- */
6
- // Errors
7
1
  export { MaskweaverError, ConfigError, ProviderError, StorageError, ValidationError, } from "./errors.js";
8
2
  export { DEFAULT_CONFIG } from "./config.js";
9
3
  export { normalizeImage, normalizeImageToFile, getImageInfo, isSupported, needsConversion, isLLMCompatible, createImageDataUrl, } from "./image.js";
10
- // Agent generation from pool config
11
4
  export { generatePoolAgentFiles, generatePoolAgentFilesFromConfig, writeDefaultRuntimeConfig, writeDefaultPluginConfig, findUserGlobalConfig, DEFAULT_RUNTIME_CONFIG_TEMPLATE, DEFAULT_PLUGIN_CONFIG_TEMPLATE, } from "./generate-agents.js";
@@ -1,108 +1,46 @@
1
- /**
2
- * Model Registry
3
- *
4
- * Manages the pool of available AI models with:
5
- * - Concurrency tracking (max N simultaneous uses per model)
6
- * - Capability-based matching (task → best model)
7
- * - Tier-based fallback (if preferred model is full, find similar)
8
- * - Cost-aware scheduling (prefer cheaper models for simple tasks)
9
- *
10
- * "The art of programming is the art of organizing complexity." - Dijkstra
11
- *
12
- * @author Mask Weaver
13
- */
14
1
  import type { ModelPoolEntry, ModelTier, ModelCapability } from './config.js';
15
- /** Runtime state for a model in the pool */
16
2
  export interface ModelSlot {
17
- /** The model definition from config */
18
3
  entry: ModelPoolEntry;
19
- /** Current number of active uses */
20
4
  activeCount: number;
21
- /** Whether this model has available slots */
22
5
  available: boolean;
23
- /** Remaining available slots */
24
6
  remainingSlots: number;
25
7
  }
26
- /** Options for acquiring a model */
27
8
  export interface AcquireOptions {
28
- /** Preferred tier (flash/human/premium) */
29
9
  tier?: ModelTier;
30
- /** Required capabilities (at least one must match) */
31
10
  capabilities?: ModelCapability[];
32
- /** Prefer lower cost when multiple models match */
33
11
  preferCheap?: boolean;
34
- /** Specific model ID to request */
35
12
  modelId?: string;
36
13
  }
37
- /** Result of a model acquisition attempt */
38
14
  export interface AcquireResult {
39
- /** Whether a model was successfully acquired */
40
15
  success: boolean;
41
- /** The acquired model slot (if success) */
42
16
  slot?: ModelSlot;
43
- /** The agent name to use (e.g., "dummy-gemini-flash") */
44
17
  agentName?: string;
45
- /** Reason for failure (if not success) */
46
18
  reason?: string;
47
- /** Suggested alternative if primary choice unavailable */
48
19
  suggestion?: string;
49
20
  }
50
- /** Snapshot of all model statuses */
51
21
  export interface RegistryStatus {
52
- /** All model slots with their current state */
53
22
  models: ModelSlot[];
54
- /** Total capacity across all models */
55
23
  totalCapacity: number;
56
- /** Currently in use */
57
24
  totalActive: number;
58
- /** Available slots */
59
25
  totalAvailable: number;
60
26
  }
61
27
  export declare class ModelRegistry {
62
28
  private pool;
63
29
  private activeCountMap;
64
30
  constructor(pool: ModelPoolEntry[]);
65
- /**
66
- * Acquire a model from the pool.
67
- *
68
- * Selection strategy:
69
- * 1. If modelId specified → try that exact model
70
- * 2. Filter by tier preference
71
- * 3. Filter by required capabilities
72
- * 4. Among candidates, pick best available (cost-aware)
73
- * 5. If no match in preferred tier, try fallback tiers
74
- */
75
31
  acquire(options?: AcquireOptions): AcquireResult;
76
- /**
77
- * Release a model back to the pool.
78
- * Must be called when a task using this model completes.
79
- */
80
32
  release(modelId: string): boolean;
81
- /** Get the current status of all models in the pool */
82
33
  getStatus(): RegistryStatus;
83
- /** Get available models for a specific tier */
84
34
  getAvailableForTier(tier: ModelTier): ModelSlot[];
85
- /** Get all models with a specific capability */
86
35
  getModelsWithCapability(capability: ModelCapability): ModelSlot[];
87
- /** Get the total concurrency available for a tier (including fallbacks) */
88
36
  getTierConcurrency(tier: ModelTier): {
89
37
  total: number;
90
38
  available: number;
91
39
  models: string[];
92
40
  };
93
- /** Get the pool entries */
94
41
  getPool(): ModelPoolEntry[];
95
- /** Get the agent name for a pool entry */
96
42
  getAgentName(entry: ModelPoolEntry): string;
97
- /**
98
- * Recommend the best model for a task based on its capabilities.
99
- * Does NOT acquire — just suggests.
100
- */
101
43
  recommend(options?: AcquireOptions): ModelPoolEntry | null;
102
- /**
103
- * Compute maximum parallelism for a set of tasks.
104
- * Given N tasks of different tiers, returns how many can run simultaneously.
105
- */
106
44
  computeMaxParallelism(taskTiers: ModelTier[]): number;
107
45
  private getSlot;
108
46
  private tryAcquire;
@@ -110,16 +48,6 @@ export declare class ModelRegistry {
110
48
  private sortCandidates;
111
49
  private suggestWait;
112
50
  }
113
- /**
114
- * Get the global model registry.
115
- * Lazily initialized from maskweaver.config.json.
116
- */
117
51
  export declare function getModelRegistry(basePath?: string): ModelRegistry;
118
- /**
119
- * Reset the registry (for testing or config reload).
120
- */
121
52
  export declare function resetModelRegistry(): void;
122
- /**
123
- * Create a fresh registry from explicit pool entries.
124
- */
125
53
  export declare function createModelRegistry(pool: ModelPoolEntry[]): ModelRegistry;