zorya-classifier 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +13 -0
  3. package/README.md +139 -2
  4. package/dist/app/cli-arguments.d.ts +40 -0
  5. package/dist/app/cli-arguments.js +67 -0
  6. package/dist/app/cli-route.d.ts +3 -0
  7. package/dist/app/cli-route.js +40 -0
  8. package/dist/app/create-classifier.d.ts +33 -0
  9. package/dist/app/create-classifier.js +312 -0
  10. package/dist/app/extraction-files.d.ts +9 -0
  11. package/dist/app/extraction-files.js +28 -0
  12. package/dist/cli.d.ts +2 -0
  13. package/dist/cli.js +77 -0
  14. package/dist/entities/boundary-view.d.ts +29 -0
  15. package/dist/entities/boundary-view.js +1 -0
  16. package/dist/entities/contracts.d.ts +471 -0
  17. package/dist/entities/contracts.js +97 -0
  18. package/dist/entities/cutout-raster.d.ts +7 -0
  19. package/dist/entities/cutout-raster.js +1 -0
  20. package/dist/entities/errors.d.ts +7 -0
  21. package/dist/entities/errors.js +16 -0
  22. package/dist/entities/object-proposals.d.ts +53 -0
  23. package/dist/entities/object-proposals.js +8 -0
  24. package/dist/entities/representation.d.ts +225 -0
  25. package/dist/entities/representation.js +33 -0
  26. package/dist/entities/segmentation-metadata.d.ts +11 -0
  27. package/dist/entities/segmentation-metadata.js +1 -0
  28. package/dist/entities/segmentation-verification.d.ts +30 -0
  29. package/dist/entities/segmentation-verification.js +1 -0
  30. package/dist/entities/segmentation.d.ts +159 -0
  31. package/dist/entities/segmentation.js +5 -0
  32. package/dist/entities/whole-object.d.ts +128 -0
  33. package/dist/entities/whole-object.js +7 -0
  34. package/dist/features/choice-beam-layout.d.ts +18 -0
  35. package/dist/features/choice-beam-layout.js +136 -0
  36. package/dist/features/choice.d.ts +4 -0
  37. package/dist/features/choice.js +83 -0
  38. package/dist/features/prompts.d.ts +8 -0
  39. package/dist/features/prompts.js +56 -0
  40. package/dist/features/segmentation/box-check.d.ts +10 -0
  41. package/dist/features/segmentation/box-check.js +299 -0
  42. package/dist/features/segmentation/mask.d.ts +6 -0
  43. package/dist/features/segmentation/mask.js +89 -0
  44. package/dist/features/segmentation/packed-mask.d.ts +5 -0
  45. package/dist/features/segmentation/packed-mask.js +53 -0
  46. package/dist/features/uniform-grid.d.ts +3 -0
  47. package/dist/features/uniform-grid.js +35 -0
  48. package/dist/index.d.ts +10 -0
  49. package/dist/index.js +2 -0
  50. package/dist/infrastructure/boundary-view.d.ts +2 -0
  51. package/dist/infrastructure/boundary-view.js +263 -0
  52. package/dist/infrastructure/openrouter-common.d.ts +130 -0
  53. package/dist/infrastructure/openrouter-common.js +317 -0
  54. package/dist/infrastructure/openrouter-vision.d.ts +11 -0
  55. package/dist/infrastructure/openrouter-vision.js +17 -0
  56. package/dist/infrastructure/openrouter.d.ts +19 -0
  57. package/dist/infrastructure/openrouter.js +207 -0
  58. package/dist/infrastructure/raster.d.ts +11 -0
  59. package/dist/infrastructure/raster.js +216 -0
  60. package/dist/infrastructure/segmentation/box-presentation.d.ts +2 -0
  61. package/dist/infrastructure/segmentation/box-presentation.js +136 -0
  62. package/dist/infrastructure/segmentation/cutout-raster.d.ts +3 -0
  63. package/dist/infrastructure/segmentation/cutout-raster.js +79 -0
  64. package/dist/infrastructure/segmentation/grabcut/index.d.ts +13 -0
  65. package/dist/infrastructure/segmentation/grabcut/index.js +118 -0
  66. package/dist/infrastructure/segmentation/grabcut/worker-inference.d.ts +47 -0
  67. package/dist/infrastructure/segmentation/grabcut/worker-inference.js +260 -0
  68. package/dist/infrastructure/segmentation/index.d.ts +2 -0
  69. package/dist/infrastructure/segmentation/index.js +2 -0
  70. package/dist/infrastructure/segmentation/mobile-sam/index.d.ts +58 -0
  71. package/dist/infrastructure/segmentation/mobile-sam/index.js +472 -0
  72. package/dist/infrastructure/segmentation/mobile-sam/worker-inference.d.ts +149 -0
  73. package/dist/infrastructure/segmentation/mobile-sam/worker-inference.js +845 -0
  74. package/dist/infrastructure/segmentation/native-child.d.ts +23 -0
  75. package/dist/infrastructure/segmentation/native-child.js +297 -0
  76. package/dist/infrastructure/segmentation/native-protocol.d.ts +923 -0
  77. package/dist/infrastructure/segmentation/native-protocol.js +242 -0
  78. package/dist/infrastructure/segmentation/native-worker.d.ts +1 -0
  79. package/dist/infrastructure/segmentation/native-worker.js +93 -0
  80. package/dist/infrastructure/segmentation/probe-backend.d.ts +1 -0
  81. package/dist/infrastructure/segmentation/probe-backend.js +31 -0
  82. package/dist/infrastructure/segmentation/proposal-presentation.d.ts +3 -0
  83. package/dist/infrastructure/segmentation/proposal-presentation.js +371 -0
  84. package/dist/infrastructure/segmentation/verify-asset.d.ts +4 -0
  85. package/dist/infrastructure/segmentation/verify-asset.js +32 -0
  86. package/dist/infrastructure/text-representation.d.ts +23 -0
  87. package/dist/infrastructure/text-representation.js +226 -0
  88. package/dist/infrastructure/vision-chat.d.ts +64 -0
  89. package/dist/infrastructure/vision-chat.js +318 -0
  90. package/dist/openai-compatible.d.ts +8 -0
  91. package/dist/openai-compatible.js +11 -0
  92. package/dist/openrouter.d.ts +4 -0
  93. package/dist/openrouter.js +2 -0
  94. package/dist/processes/boundary-state.d.ts +12 -0
  95. package/dist/processes/boundary-state.js +196 -0
  96. package/dist/processes/classify.d.ts +3 -0
  97. package/dist/processes/classify.js +39 -0
  98. package/dist/processes/extract-from-region.d.ts +19 -0
  99. package/dist/processes/extract-from-region.js +415 -0
  100. package/dist/processes/extract.d.ts +25 -0
  101. package/dist/processes/extract.js +223 -0
  102. package/dist/processes/locate.d.ts +3 -0
  103. package/dist/processes/locate.js +274 -0
  104. package/dist/processes/proposal-location.d.ts +19 -0
  105. package/dist/processes/proposal-location.js +396 -0
  106. package/dist/processes/whole-object.d.ts +7 -0
  107. package/dist/processes/whole-object.js +272 -0
  108. package/dist/segmentation.d.ts +10 -0
  109. package/dist/segmentation.js +4 -0
  110. package/dist/shared/choice-mass.d.ts +2 -0
  111. package/dist/shared/choice-mass.js +19 -0
  112. package/dist/shared/gate.d.ts +11 -0
  113. package/dist/shared/gate.js +52 -0
  114. package/dist/shared/input-budget.d.ts +7 -0
  115. package/dist/shared/input-budget.js +21 -0
  116. package/dist/shared/scope.d.ts +12 -0
  117. package/dist/shared/scope.js +29 -0
  118. package/docs/0.2.0-plan.md +190 -0
  119. package/docs/README.ru.md +258 -0
  120. package/docs/acceptance.md +144 -0
  121. package/docs/api.md +49 -0
  122. package/docs/architecture.md +45 -0
  123. package/docs/benchmarks.md +63 -0
  124. package/docs/categorical-presence-port.md +26 -0
  125. package/docs/evidence/current-linux-check.json +15 -0
  126. package/docs/evidence/decisions-completion-v1-manifest.json +96 -0
  127. package/docs/evidence/decisions-completion-v1-report.json +1205 -0
  128. package/docs/evidence/decisions-selection-v1-manifest.json +96 -0
  129. package/docs/evidence/decisions-selection-v1-report.json +1457 -0
  130. package/docs/evidence/jev-pricing-2026-10-18.json +69 -0
  131. package/docs/evidence/linux-check.json +20 -0
  132. package/docs/evidence/linux-check.txt +205 -0
  133. package/docs/evidence/live-release-smoke-manifest.json +82 -0
  134. package/docs/evidence/live-release-smoke-provenance.json +9 -0
  135. package/docs/evidence/live-release-smoke-report.json +2136 -0
  136. package/docs/evidence/live-v1-manifest.json +84 -0
  137. package/docs/evidence/live-v1-provenance.json +9 -0
  138. package/docs/evidence/live-v1-report.json +15555 -0
  139. package/docs/evidence/luna-decisions-fine-probe.json +19 -0
  140. package/docs/evidence/luna-decisions-locator-smoke-manifest.json +39 -0
  141. package/docs/evidence/luna-decisions-locator-smoke-report.json +149 -0
  142. package/docs/evidence/pack-check.json +26 -0
  143. package/docs/evidence/protocol-probes.json +61 -0
  144. package/docs/evidence/rejected-vision-selection-v1-qwen-photo-dev-01.json +42 -0
  145. package/docs/evidence/rejected-vision-selection-v1-qwen-photo-dev-17.json +42 -0
  146. package/docs/evidence/rejected-vision-selection-v1-qwen-photo-heldout-09.json +42 -0
  147. package/docs/evidence/rejected-vision-selection-v2-haiku-photo-dev-16.json +42 -0
  148. package/docs/evidence/rejected-vision-selection-v2-haiku-support-heldout-016.json +42 -0
  149. package/docs/evidence/v02/baseline.json +1043 -0
  150. package/docs/evidence/v02/boundary-variants.md +17 -0
  151. package/docs/evidence/v02/box-confirmation-dev40/README.md +15 -0
  152. package/docs/evidence/v02/box-confirmation-dev40/component-refinement.json +246 -0
  153. package/docs/evidence/v02/box-confirmation-dev40/evaluation.json +1663 -0
  154. package/docs/evidence/v02/box-confirmation-dev40/provenance.json +130 -0
  155. package/docs/evidence/v02/box-confirmation-dev40/report.json +127 -0
  156. package/docs/evidence/v02/box-confirmation-dev40-freeze-20261020-v1.json +230 -0
  157. package/docs/evidence/v02/box-confirmation-method-selection-20261020-v1.json +85 -0
  158. package/docs/evidence/v02/box-heldout-cancelled-before-dispatch-20261021-v1.json +32 -0
  159. package/docs/evidence/v02/box-heldout-combined-seal-20261021-v1.json +89 -0
  160. package/docs/evidence/v02/box-heldout-evaluator-truth-seal-20261021-v1.json +61 -0
  161. package/docs/evidence/v02/box-heldout-exclusion-audit-20261020-v1.json +81 -0
  162. package/docs/evidence/v02/box-heldout-map-seal-20261021-v1.json +48 -0
  163. package/docs/evidence/v02/box-heldout-photo-seal-20261020-v1.json +62 -0
  164. package/docs/evidence/v02/box-heldout-run-freeze-20261021-v1.json +61 -0
  165. package/docs/evidence/v02/box-heldout-source-review-20261020-v1.json +134 -0
  166. package/docs/evidence/v02/box-heldout-ui-seal-20261020-v1.json +44 -0
  167. package/docs/evidence/v02/calculator-proof-root-review-20261020-v1.json +63 -0
  168. package/docs/evidence/v02/categorical-dev40-freeze.json +94 -0
  169. package/docs/evidence/v02/categorical-dev40-preserve.json +460 -0
  170. package/docs/evidence/v02/categorical-dev40-target-only.json +460 -0
  171. package/docs/evidence/v02/categorical-heldout-admission-20261020-v3.json +215 -0
  172. package/docs/evidence/v02/categorical-heldout-admission-20261020-v4.json +270 -0
  173. package/docs/evidence/v02/categorical-heldout-dispatch-authorization-20261020-v4.json +79 -0
  174. package/docs/evidence/v02/categorical-heldout-predispatch-20261020-v3.json +57 -0
  175. package/docs/evidence/v02/categorical-heldout-producer-source-map-v4.json +262 -0
  176. package/docs/evidence/v02/categorical-heldout-producer-source-map.json +263 -0
  177. package/docs/evidence/v02/categorical-heldout-run-freeze-20261020-v3.json +35 -0
  178. package/docs/evidence/v02/categorical-heldout-run-freeze-20261020-v4.json +35 -0
  179. package/docs/evidence/v02/categorical-heldout-v4/README.md +35 -0
  180. package/docs/evidence/v02/categorical-heldout-v4/candidate-evaluation.json +2812 -0
  181. package/docs/evidence/v02/categorical-heldout-v4/candidate-physical-receipts.json +15261 -0
  182. package/docs/evidence/v02/categorical-heldout-v4/candidate-provenance.json +131 -0
  183. package/docs/evidence/v02/categorical-heldout-v4/control-evaluation.json +855 -0
  184. package/docs/evidence/v02/categorical-heldout-v4/control-physical-receipts.json +4402 -0
  185. package/docs/evidence/v02/categorical-heldout-v4/control-provenance.json +31 -0
  186. package/docs/evidence/v02/categorical-heldout-v4/mask-normalized-exploratory.json +682 -0
  187. package/docs/evidence/v02/categorical-heldout-v4/paired-qualification.json +21 -0
  188. package/docs/evidence/v02/categorical-heldout-v4/report.json +258 -0
  189. package/docs/evidence/v02/categorical-presence-dev6.json +144 -0
  190. package/docs/evidence/v02/categorical-presence-dev6.md +18 -0
  191. package/docs/evidence/v02/categorical-vision-method-selection.json +90 -0
  192. package/docs/evidence/v02/checked-region-component-v1/README.md +7 -0
  193. package/docs/evidence/v02/checked-region-component-v1/evidence.json +311 -0
  194. package/docs/evidence/v02/checked-region-resource-interrupted-2b0d09f.json +102 -0
  195. package/docs/evidence/v02/checked-region-segmentation-resource-4df544c-receipt.json +167 -0
  196. package/docs/evidence/v02/checked-region-segmentation-resource-4df544c-root-review.json +58 -0
  197. package/docs/evidence/v02/checked-region-segmentation-resource-987ac32-receipt.json +158 -0
  198. package/docs/evidence/v02/ci-012b935.json +17 -0
  199. package/docs/evidence/v02/ci-0c365cb.json +372 -0
  200. package/docs/evidence/v02/ci-185bde8.json +32 -0
  201. package/docs/evidence/v02/ci-24f849f.json +95 -0
  202. package/docs/evidence/v02/ci-25c19cd.json +375 -0
  203. package/docs/evidence/v02/ci-2922caf.json +375 -0
  204. package/docs/evidence/v02/ci-29357d7.json +29 -0
  205. package/docs/evidence/v02/ci-32aa90d.json +24 -0
  206. package/docs/evidence/v02/ci-35e3064.json +376 -0
  207. package/docs/evidence/v02/ci-4331b1b.json +384 -0
  208. package/docs/evidence/v02/ci-43b7426.json +376 -0
  209. package/docs/evidence/v02/ci-450439c.json +373 -0
  210. package/docs/evidence/v02/ci-46283fe.json +29 -0
  211. package/docs/evidence/v02/ci-4c9c09f.json +34 -0
  212. package/docs/evidence/v02/ci-5579646.json +27 -0
  213. package/docs/evidence/v02/ci-6f9cc15.json +127 -0
  214. package/docs/evidence/v02/ci-7c1051f.json +27 -0
  215. package/docs/evidence/v02/ci-9837888.json +34 -0
  216. package/docs/evidence/v02/ci-987ac32.json +29 -0
  217. package/docs/evidence/v02/ci-9d00fe5.json +25 -0
  218. package/docs/evidence/v02/ci-9f85acc.json +127 -0
  219. package/docs/evidence/v02/ci-be275a6.json +201 -0
  220. package/docs/evidence/v02/ci-c107ddf.json +372 -0
  221. package/docs/evidence/v02/ci-c35f67d.json +127 -0
  222. package/docs/evidence/v02/ci-c5eddd8.json +32 -0
  223. package/docs/evidence/v02/ci-d2042e0.json +372 -0
  224. package/docs/evidence/v02/ci-d684259.json +375 -0
  225. package/docs/evidence/v02/ci-e0c190b.json +127 -0
  226. package/docs/evidence/v02/ci-e551253.json +372 -0
  227. package/docs/evidence/v02/ci-f9d4633.json +29 -0
  228. package/docs/evidence/v02/dev1-proposal-evaluation.md +13 -0
  229. package/docs/evidence/v02/dev2-mobile-sam-proposal-oracle.md +21 -0
  230. package/docs/evidence/v02/dev2-proposal-evaluation.md +21 -0
  231. package/docs/evidence/v02/fresh-development.md +16 -0
  232. package/docs/evidence/v02/fresh-native-numeric/artifact-hashes.json +9 -0
  233. package/docs/evidence/v02/fresh-native-numeric/evaluation-root-v1.json +568 -0
  234. package/docs/evidence/v02/fresh-native-numeric/run-manifest.json +342 -0
  235. package/docs/evidence/v02/fresh-native-numeric/summary.json +5654 -0
  236. package/docs/evidence/v02/fresh-native-outline-axis/artifact-hashes.json +9 -0
  237. package/docs/evidence/v02/fresh-native-outline-axis/evaluation-root-v1.json +568 -0
  238. package/docs/evidence/v02/fresh-native-outline-axis/run-manifest.json +378 -0
  239. package/docs/evidence/v02/fresh-native-outline-axis/summary.json +5605 -0
  240. package/docs/evidence/v02/fresh-text/README.md +23 -0
  241. package/docs/evidence/v02/fresh-text/ascii-contours-v1/classify-followup-run-manifest.json +405 -0
  242. package/docs/evidence/v02/fresh-text/ascii-contours-v1/classify-followup-summary.json +1646 -0
  243. package/docs/evidence/v02/fresh-text/ascii-contours-v1/evaluation.json +568 -0
  244. package/docs/evidence/v02/fresh-text/ascii-contours-v1/original-run-manifest.json +404 -0
  245. package/docs/evidence/v02/fresh-text/ascii-contours-v1/original-summary.json +4416 -0
  246. package/docs/evidence/v02/fresh-text/ascii-luma-v1/classify-followup-run-manifest.json +405 -0
  247. package/docs/evidence/v02/fresh-text/ascii-luma-v1/classify-followup-summary.json +1646 -0
  248. package/docs/evidence/v02/fresh-text/ascii-luma-v1/evaluation.json +568 -0
  249. package/docs/evidence/v02/fresh-text/ascii-luma-v1/original-run-manifest.json +404 -0
  250. package/docs/evidence/v02/fresh-text/ascii-luma-v1/original-summary.json +4647 -0
  251. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/classify-followup-run-manifest.json +405 -0
  252. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/classify-followup-summary.json +846 -0
  253. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/evaluation.json +568 -0
  254. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/original-run-manifest.json +404 -0
  255. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/original-summary.json +1789 -0
  256. package/docs/evidence/v02/fresh-text/no-image-control/evaluation.json +568 -0
  257. package/docs/evidence/v02/fresh-text/no-image-control/original-run-manifest.json +404 -0
  258. package/docs/evidence/v02/fresh-text/no-image-control/original-summary.json +3953 -0
  259. package/docs/evidence/v02/fresh-text/palette-grid-v1/classify-followup-run-manifest.json +405 -0
  260. package/docs/evidence/v02/fresh-text/palette-grid-v1/classify-followup-summary.json +1646 -0
  261. package/docs/evidence/v02/fresh-text/palette-grid-v1/evaluation.json +568 -0
  262. package/docs/evidence/v02/fresh-text/palette-grid-v1/original-run-manifest.json +404 -0
  263. package/docs/evidence/v02/fresh-text/palette-grid-v1/original-summary.json +3974 -0
  264. package/docs/evidence/v02/fresh-text/pixel-rle-v1/classify-followup-run-manifest.json +405 -0
  265. package/docs/evidence/v02/fresh-text/pixel-rle-v1/classify-followup-summary.json +1646 -0
  266. package/docs/evidence/v02/fresh-text/pixel-rle-v1/evaluation.json +568 -0
  267. package/docs/evidence/v02/fresh-text/pixel-rle-v1/original-run-manifest.json +404 -0
  268. package/docs/evidence/v02/fresh-text/pixel-rle-v1/original-summary.json +4945 -0
  269. package/docs/evidence/v02/fresh-text/report.json +284 -0
  270. package/docs/evidence/v02/fresh-text/svg-contours-v1/classify-followup-run-manifest.json +405 -0
  271. package/docs/evidence/v02/fresh-text/svg-contours-v1/classify-followup-summary.json +846 -0
  272. package/docs/evidence/v02/fresh-text/svg-contours-v1/evaluation.json +568 -0
  273. package/docs/evidence/v02/fresh-text/svg-contours-v1/original-run-manifest.json +404 -0
  274. package/docs/evidence/v02/fresh-text/svg-contours-v1/original-summary.json +2189 -0
  275. package/docs/evidence/v02/heldout-evaluation-20261020.md +37 -0
  276. package/docs/evidence/v02/heldout-input-derivation.md +18 -0
  277. package/docs/evidence/v02/integration-0c365cb.json +90 -0
  278. package/docs/evidence/v02/integration-25c19cd.json +52 -0
  279. package/docs/evidence/v02/integration-35e3064.json +41 -0
  280. package/docs/evidence/v02/integration-4331b1b.json +42 -0
  281. package/docs/evidence/v02/integration-4c9c09f.json +46 -0
  282. package/docs/evidence/v02/integration-8010aad.json +48 -0
  283. package/docs/evidence/v02/integration-c1aa640.json +41 -0
  284. package/docs/evidence/v02/integration-eea1790.json +46 -0
  285. package/docs/evidence/v02/integration-fa82e65.json +42 -0
  286. package/docs/evidence/v02/jpeg-transport-offline.json +268 -0
  287. package/docs/evidence/v02/jpeg-transport-offline.md +7 -0
  288. package/docs/evidence/v02/local-archive-cleanup.json +59 -0
  289. package/docs/evidence/v02/native-base64-after.json +30 -0
  290. package/docs/evidence/v02/native-base64-before.json +32 -0
  291. package/docs/evidence/v02/native-checked-region-windows-46283fe.json +248 -0
  292. package/docs/evidence/v02/native-checked-region-windows-987ac32.json +141 -0
  293. package/docs/evidence/v02/native-grabcut-windows-4c494a3-run2.json +148 -0
  294. package/docs/evidence/v02/native-grabcut-windows-4c494a3-run3.json +148 -0
  295. package/docs/evidence/v02/native-grabcut-windows-4c494a3.json +56 -0
  296. package/docs/evidence/v02/native-proposal-windows-0c365cb.json +148 -0
  297. package/docs/evidence/v02/native-proposal-windows-450439c.json +156 -0
  298. package/docs/evidence/v02/native-proposal-windows-4c9c09f-retry1.json +147 -0
  299. package/docs/evidence/v02/native-proposal-windows-4c9c09f.json +52 -0
  300. package/docs/evidence/v02/native-region-windows-efc9318.json +163 -0
  301. package/docs/evidence/v02/native-windows-eea1790-baseline.json +198 -0
  302. package/docs/evidence/v02/native-windows-eea1790.json +228 -0
  303. package/docs/evidence/v02/ordinary-luna-axis/run-manifest.json +99 -0
  304. package/docs/evidence/v02/ordinary-luna-axis/summary.json +811 -0
  305. package/docs/evidence/v02/owned-temp-cleanup-20261020-v1.json +28 -0
  306. package/docs/evidence/v02/presentation-paired-20261020.json +1438 -0
  307. package/docs/evidence/v02/proposal-resource-soak-261dc23.json +201 -0
  308. package/docs/evidence/v02/proposal-resource-soak-261dc23.md +15 -0
  309. package/docs/evidence/v02/proposal-resource-soak-450439c-receipt.md +13 -0
  310. package/docs/evidence/v02/reconstructed-c03-box.json +41 -0
  311. package/docs/evidence/v02/region-seeded-dev-v1/README.md +17 -0
  312. package/docs/evidence/v02/region-seeded-dev-v1/evaluation.json +260 -0
  313. package/docs/evidence/v02/region-seeded-dev-v2/README.md +15 -0
  314. package/docs/evidence/v02/region-seeded-dev-v2/evaluation.json +232 -0
  315. package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/README.md +9 -0
  316. package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/control-identity-failure.json +22 -0
  317. package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/evaluation.json +160 -0
  318. package/docs/evidence/v02/region-seeded-dev-v3-control-r2/README.md +9 -0
  319. package/docs/evidence/v02/region-seeded-dev-v3-control-r2/attempt-accounting.json +55 -0
  320. package/docs/evidence/v02/region-seeded-dev-v3-control-r2/evaluation.json +136 -0
  321. package/docs/evidence/v02/region-seeded-development-control-r2-freeze-20261021.json +132 -0
  322. package/docs/evidence/v02/region-seeded-development-freeze-20261021-v1.json +167 -0
  323. package/docs/evidence/v02/region-seeded-development-freeze-20261021-v2.json +186 -0
  324. package/docs/evidence/v02/region-seeded-development-freeze-20261021-v3.json +205 -0
  325. package/docs/evidence/v02/region-seeded-heldout-cancelled-before-dispatch-20261021-v2.json +20 -0
  326. package/docs/evidence/v02/region-seeded-heldout-dispatch-authorization-20261021-v3.json +47 -0
  327. package/docs/evidence/v02/region-seeded-heldout-readiness-audit-20261021-v3.json +125 -0
  328. package/docs/evidence/v02/region-seeded-heldout-run-freeze-20261021-v2.json +234 -0
  329. package/docs/evidence/v02/region-seeded-heldout-run-freeze-20261021-v3.json +357 -0
  330. package/docs/evidence/v02/region-seeded-heldout-v3/README.md +19 -0
  331. package/docs/evidence/v02/region-seeded-heldout-v3/evaluation-summary.json +445 -0
  332. package/docs/evidence/v02/region-seeded-method-selection-20261021-v2.json +66 -0
  333. package/docs/evidence/v02/region-seeded-method-selection-20261021-v3.json +120 -0
  334. package/docs/evidence/v02/region-segmentation-resource-0ba4c87-receipt.json +156 -0
  335. package/docs/evidence/v02/resource-soak-linux-8010aad.json +125 -0
  336. package/docs/evidence/v02/screen-v2-terminal-evaluation.md +22 -0
  337. package/docs/evidence/v02/seed-outline/run-manifest.json +59 -0
  338. package/docs/evidence/v02/seed-outline/summary.json +487 -0
  339. package/docs/evidence/v02/seed-unbounded/run-manifest.json +80 -0
  340. package/docs/evidence/v02/seed-unbounded/summary.json +730 -0
  341. package/docs/evidence/v02/segmentation/README.md +21 -0
  342. package/docs/evidence/v02/segmentation/component-comparison-summary.json +240 -0
  343. package/docs/evidence/v02/segmentation/provenance/MOBILE-SAM-LICENSE.txt +201 -0
  344. package/docs/evidence/v02/segmentation/provenance/OPENCV-LICENSE.txt +202 -0
  345. package/docs/evidence/v02/segmentation/provenance/mobile-sam-download-receipt.json +29 -0
  346. package/docs/evidence/v02/segmentation/provenance/mobile-sam-graph-audit.json +214 -0
  347. package/docs/evidence/v02/segmentation/provenance/mobile-sam-model-metadata.json +166 -0
  348. package/docs/evidence/v02/split-choice-noul-dev6.json +72 -0
  349. package/docs/evidence/v02/split-choice-noul-dev6.md +11 -0
  350. package/docs/evidence/v02/supported-vision-screen-20261020.md +65 -0
  351. package/docs/evidence/v02/wesnoth-1.16.11-minimap-projection-source-audit.md +56 -0
  352. package/docs/evidence/v02/wesnoth-proof-root-review-20261020-v1.json +76 -0
  353. package/docs/evidence/vision-cost-reconciliation.json +37 -0
  354. package/docs/evidence/vision-model-summary.json +562 -0
  355. package/docs/evidence/vision-selection-v1-manifest.json +95 -0
  356. package/docs/evidence/vision-selection-v1-report.json +4598 -0
  357. package/docs/evidence/vision-selection-v2-manifest.json +95 -0
  358. package/docs/evidence/vision-selection-v2-report.json +1139 -0
  359. package/docs/evidence/windows-native.json +73 -0
  360. package/docs/evidence/windows-secrets.json +46 -0
  361. package/docs/operations.md +21 -0
  362. package/docs/plan.md +27 -0
  363. package/docs/provenance.json +32 -0
  364. package/docs/publishing.md +30 -0
  365. package/docs/research/text-transport-audit.md +66 -0
  366. package/docs/results.md +69 -0
  367. package/docs/v02-usage.md +162 -0
  368. package/docs/vision-results.md +78 -0
  369. package/package.json +114 -4
@@ -0,0 +1,471 @@
1
+ import { z } from 'zod';
2
+ export declare const limits: Readonly<{
3
+ imageBytes: number;
4
+ imagePixels: 16777216;
5
+ bodyBytes: number;
6
+ maxClasses: 255;
7
+ maxImages: 9;
8
+ }>;
9
+ export declare const pixelRectSchema: z.ZodObject<{
10
+ left: z.ZodNumber;
11
+ top: z.ZodNumber;
12
+ width: z.ZodNumber;
13
+ height: z.ZodNumber;
14
+ }, "strict", z.ZodTypeAny, {
15
+ left: number;
16
+ top: number;
17
+ width: number;
18
+ height: number;
19
+ }, {
20
+ left: number;
21
+ top: number;
22
+ width: number;
23
+ height: number;
24
+ }>;
25
+ export type PixelRect = z.infer<typeof pixelRectSchema>;
26
+ export interface GridCell {
27
+ id: string;
28
+ column: number;
29
+ row: number;
30
+ region: PixelRect;
31
+ xId?: string;
32
+ yId?: string;
33
+ kind?: 'cell';
34
+ }
35
+ export interface GridPanel {
36
+ id: string;
37
+ region: PixelRect;
38
+ cells: readonly GridCell[];
39
+ }
40
+ export declare const classSchema: z.ZodObject<{
41
+ id: z.ZodString;
42
+ description: z.ZodString;
43
+ }, "strict", z.ZodTypeAny, {
44
+ id: string;
45
+ description: string;
46
+ }, {
47
+ id: string;
48
+ description: string;
49
+ }>;
50
+ export type ClassDefinition = z.infer<typeof classSchema>;
51
+ export declare const representationSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
52
+ type: z.ZodLiteral<"vision">;
53
+ }, "strict", z.ZodTypeAny, {
54
+ type: "vision";
55
+ }, {
56
+ type: "vision";
57
+ }>, z.ZodObject<{
58
+ type: z.ZodLiteral<"experimental-text">;
59
+ profile: z.ZodLiteral<"text-image-v1">;
60
+ }, "strict", z.ZodTypeAny, {
61
+ type: "experimental-text";
62
+ profile: "text-image-v1";
63
+ }, {
64
+ type: "experimental-text";
65
+ profile: "text-image-v1";
66
+ }>]>;
67
+ export type Representation = z.infer<typeof representationSchema>;
68
+ export declare const classifySchema: z.ZodObject<{
69
+ input: z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodObject<{
70
+ text: z.ZodOptional<z.ZodString>;
71
+ image: z.ZodOptional<z.ZodEffects<z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>>;
72
+ }, "strict", z.ZodTypeAny, {
73
+ text?: string | undefined;
74
+ image?: Uint8Array<ArrayBufferLike> | undefined;
75
+ }, {
76
+ text?: string | undefined;
77
+ image?: Uint8Array<ArrayBufferLike> | undefined;
78
+ }>, {
79
+ text?: string | undefined;
80
+ image?: Uint8Array<ArrayBufferLike> | undefined;
81
+ }, {
82
+ text?: string | undefined;
83
+ image?: Uint8Array<ArrayBufferLike> | undefined;
84
+ }>]>;
85
+ classes: z.ZodEffects<z.ZodArray<z.ZodObject<{
86
+ id: z.ZodString;
87
+ description: z.ZodString;
88
+ }, "strict", z.ZodTypeAny, {
89
+ id: string;
90
+ description: string;
91
+ }, {
92
+ id: string;
93
+ description: string;
94
+ }>, "many">, {
95
+ id: string;
96
+ description: string;
97
+ }[], {
98
+ id: string;
99
+ description: string;
100
+ }[]>;
101
+ instructions: z.ZodOptional<z.ZodString>;
102
+ representation: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
103
+ type: z.ZodLiteral<"vision">;
104
+ }, "strict", z.ZodTypeAny, {
105
+ type: "vision";
106
+ }, {
107
+ type: "vision";
108
+ }>, z.ZodObject<{
109
+ type: z.ZodLiteral<"experimental-text">;
110
+ profile: z.ZodLiteral<"text-image-v1">;
111
+ }, "strict", z.ZodTypeAny, {
112
+ type: "experimental-text";
113
+ profile: "text-image-v1";
114
+ }, {
115
+ type: "experimental-text";
116
+ profile: "text-image-v1";
117
+ }>]>>;
118
+ }, "strict", z.ZodTypeAny, {
119
+ input: string | {
120
+ text?: string | undefined;
121
+ image?: Uint8Array<ArrayBufferLike> | undefined;
122
+ };
123
+ classes: {
124
+ id: string;
125
+ description: string;
126
+ }[];
127
+ instructions?: string | undefined;
128
+ representation?: {
129
+ type: "vision";
130
+ } | {
131
+ type: "experimental-text";
132
+ profile: "text-image-v1";
133
+ } | undefined;
134
+ }, {
135
+ input: string | {
136
+ text?: string | undefined;
137
+ image?: Uint8Array<ArrayBufferLike> | undefined;
138
+ };
139
+ classes: {
140
+ id: string;
141
+ description: string;
142
+ }[];
143
+ instructions?: string | undefined;
144
+ representation?: {
145
+ type: "vision";
146
+ } | {
147
+ type: "experimental-text";
148
+ profile: "text-image-v1";
149
+ } | undefined;
150
+ }>;
151
+ export type ClassifyInput = z.input<typeof classifySchema> & {
152
+ signal?: AbortSignal;
153
+ };
154
+ export declare const locateSchema: z.ZodObject<{
155
+ image: z.ZodEffects<z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>;
156
+ target: z.ZodString;
157
+ exclusions: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
158
+ roi: z.ZodOptional<z.ZodObject<{
159
+ left: z.ZodNumber;
160
+ top: z.ZodNumber;
161
+ width: z.ZodNumber;
162
+ height: z.ZodNumber;
163
+ }, "strict", z.ZodTypeAny, {
164
+ left: number;
165
+ top: number;
166
+ width: number;
167
+ height: number;
168
+ }, {
169
+ left: number;
170
+ top: number;
171
+ width: number;
172
+ height: number;
173
+ }>>;
174
+ mode: z.ZodOptional<z.ZodLiteral<"region">>;
175
+ representation: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
176
+ type: z.ZodLiteral<"vision">;
177
+ }, "strict", z.ZodTypeAny, {
178
+ type: "vision";
179
+ }, {
180
+ type: "vision";
181
+ }>, z.ZodObject<{
182
+ type: z.ZodLiteral<"experimental-text">;
183
+ profile: z.ZodLiteral<"text-image-v1">;
184
+ }, "strict", z.ZodTypeAny, {
185
+ type: "experimental-text";
186
+ profile: "text-image-v1";
187
+ }, {
188
+ type: "experimental-text";
189
+ profile: "text-image-v1";
190
+ }>]>>;
191
+ }, "strict", z.ZodTypeAny, {
192
+ image: Uint8Array<ArrayBufferLike>;
193
+ target: string;
194
+ exclusions: string[];
195
+ representation?: {
196
+ type: "vision";
197
+ } | {
198
+ type: "experimental-text";
199
+ profile: "text-image-v1";
200
+ } | undefined;
201
+ roi?: {
202
+ left: number;
203
+ top: number;
204
+ width: number;
205
+ height: number;
206
+ } | undefined;
207
+ mode?: "region" | undefined;
208
+ }, {
209
+ image: Uint8Array<ArrayBufferLike>;
210
+ target: string;
211
+ representation?: {
212
+ type: "vision";
213
+ } | {
214
+ type: "experimental-text";
215
+ profile: "text-image-v1";
216
+ } | undefined;
217
+ exclusions?: string[] | undefined;
218
+ roi?: {
219
+ left: number;
220
+ top: number;
221
+ width: number;
222
+ height: number;
223
+ } | undefined;
224
+ mode?: "region" | undefined;
225
+ }>;
226
+ export type LocateInput = z.input<typeof locateSchema> & {
227
+ signal?: AbortSignal;
228
+ };
229
+ export type ImagePart = {
230
+ type: 'image_url';
231
+ image_url: {
232
+ url: string;
233
+ detail: 'high';
234
+ };
235
+ };
236
+ export type DecisionState = (string | ImagePart)[];
237
+ export type ChoiceQuestion = {
238
+ type: 'choice';
239
+ rankingSize?: 1 | 4;
240
+ instructions: string;
241
+ criteria: Record<string, string>;
242
+ };
243
+ type NoulQuestion = {
244
+ type: 'noul';
245
+ instructions: string;
246
+ };
247
+ type DecisionQuestion = ChoiceQuestion | NoulQuestion;
248
+ export type DecisionRequest = {
249
+ state: DecisionState;
250
+ questions: Record<string, DecisionQuestion>;
251
+ };
252
+ export interface DecisionMetadata {
253
+ model: string | null;
254
+ provider: string | null;
255
+ requestId: string | null;
256
+ durationMs: number;
257
+ costUsd: number | null;
258
+ attempts: number;
259
+ }
260
+ declare const choiceAnswerSchema: z.ZodObject<{
261
+ type: z.ZodLiteral<"choice">;
262
+ choice: z.ZodString;
263
+ probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
264
+ confidence: z.ZodOptional<z.ZodNumber>;
265
+ probabilityRoundingStep: z.ZodOptional<z.ZodLiteral<0.01>>;
266
+ }, "strip", z.ZodTypeAny, {
267
+ type: "choice";
268
+ choice: string;
269
+ probabilities: Record<string, number>;
270
+ confidence?: number | undefined;
271
+ probabilityRoundingStep?: 0.01 | undefined;
272
+ }, {
273
+ type: "choice";
274
+ choice: string;
275
+ probabilities: Record<string, number>;
276
+ confidence?: number | undefined;
277
+ probabilityRoundingStep?: 0.01 | undefined;
278
+ }>;
279
+ export type ChoiceAnswer = z.infer<typeof choiceAnswerSchema>;
280
+ export declare const decisionResultSchema: z.ZodObject<{
281
+ answers: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
282
+ type: z.ZodLiteral<"choice">;
283
+ choice: z.ZodString;
284
+ probabilities: z.ZodRecord<z.ZodString, z.ZodNumber>;
285
+ confidence: z.ZodOptional<z.ZodNumber>;
286
+ probabilityRoundingStep: z.ZodOptional<z.ZodLiteral<0.01>>;
287
+ }, "strip", z.ZodTypeAny, {
288
+ type: "choice";
289
+ choice: string;
290
+ probabilities: Record<string, number>;
291
+ confidence?: number | undefined;
292
+ probabilityRoundingStep?: 0.01 | undefined;
293
+ }, {
294
+ type: "choice";
295
+ choice: string;
296
+ probabilities: Record<string, number>;
297
+ confidence?: number | undefined;
298
+ probabilityRoundingStep?: 0.01 | undefined;
299
+ }>, z.ZodObject<{
300
+ type: z.ZodLiteral<"ranked-choice">;
301
+ ranking: z.ZodArray<z.ZodString, "many">;
302
+ }, "strict", z.ZodTypeAny, {
303
+ type: "ranked-choice";
304
+ ranking: string[];
305
+ }, {
306
+ type: "ranked-choice";
307
+ ranking: string[];
308
+ }>, z.ZodObject<{
309
+ type: z.ZodLiteral<"presence">;
310
+ presence: z.ZodEnum<["present", "absent", "unknown"]>;
311
+ }, "strict", z.ZodTypeAny, {
312
+ type: "presence";
313
+ presence: "unknown" | "present" | "absent";
314
+ }, {
315
+ type: "presence";
316
+ presence: "unknown" | "present" | "absent";
317
+ }>, z.ZodObject<{
318
+ type: z.ZodLiteral<"noul">;
319
+ noul: z.ZodNumber;
320
+ }, "strip", z.ZodTypeAny, {
321
+ type: "noul";
322
+ noul: number;
323
+ }, {
324
+ type: "noul";
325
+ noul: number;
326
+ }>]>>;
327
+ metadata: z.ZodObject<{
328
+ model: z.ZodNullable<z.ZodString>;
329
+ provider: z.ZodNullable<z.ZodString>;
330
+ requestId: z.ZodNullable<z.ZodString>;
331
+ durationMs: z.ZodNumber;
332
+ costUsd: z.ZodNullable<z.ZodNumber>;
333
+ attempts: z.ZodNumber;
334
+ }, "strip", z.ZodTypeAny, {
335
+ model: string | null;
336
+ provider: string | null;
337
+ requestId: string | null;
338
+ durationMs: number;
339
+ costUsd: number | null;
340
+ attempts: number;
341
+ }, {
342
+ model: string | null;
343
+ provider: string | null;
344
+ requestId: string | null;
345
+ durationMs: number;
346
+ costUsd: number | null;
347
+ attempts: number;
348
+ }>;
349
+ }, "strip", z.ZodTypeAny, {
350
+ answers: Record<string, {
351
+ type: "choice";
352
+ choice: string;
353
+ probabilities: Record<string, number>;
354
+ confidence?: number | undefined;
355
+ probabilityRoundingStep?: 0.01 | undefined;
356
+ } | {
357
+ type: "ranked-choice";
358
+ ranking: string[];
359
+ } | {
360
+ type: "presence";
361
+ presence: "unknown" | "present" | "absent";
362
+ } | {
363
+ type: "noul";
364
+ noul: number;
365
+ }>;
366
+ metadata: {
367
+ model: string | null;
368
+ provider: string | null;
369
+ requestId: string | null;
370
+ durationMs: number;
371
+ costUsd: number | null;
372
+ attempts: number;
373
+ };
374
+ }, {
375
+ answers: Record<string, {
376
+ type: "choice";
377
+ choice: string;
378
+ probabilities: Record<string, number>;
379
+ confidence?: number | undefined;
380
+ probabilityRoundingStep?: 0.01 | undefined;
381
+ } | {
382
+ type: "ranked-choice";
383
+ ranking: string[];
384
+ } | {
385
+ type: "presence";
386
+ presence: "unknown" | "present" | "absent";
387
+ } | {
388
+ type: "noul";
389
+ noul: number;
390
+ }>;
391
+ metadata: {
392
+ model: string | null;
393
+ provider: string | null;
394
+ requestId: string | null;
395
+ durationMs: number;
396
+ costUsd: number | null;
397
+ attempts: number;
398
+ };
399
+ }>;
400
+ export type DecisionResult = z.infer<typeof decisionResultSchema>;
401
+ export interface DecisionPort {
402
+ decide(request: DecisionRequest, signal: AbortSignal): Promise<DecisionResult>;
403
+ }
404
+ export interface ChoiceSelection {
405
+ choice: string;
406
+ nativeChoice: string | null;
407
+ probabilities: Record<string, number> | null;
408
+ ranking?: string[];
409
+ confidence?: number;
410
+ probabilityRoundingStep?: 0.01;
411
+ tied: string[];
412
+ }
413
+ export interface ClassificationResult extends ChoiceSelection {
414
+ metadata: DecisionMetadata;
415
+ }
416
+ export interface LocalizationMetadata {
417
+ image: {
418
+ width: number;
419
+ height: number;
420
+ coordinateSpace: 'oriented-source-pixels';
421
+ };
422
+ stages: DecisionMetadata[];
423
+ durationMs: number;
424
+ knownCostUsd: number;
425
+ unknownCostCount: number;
426
+ }
427
+ export type LocalizationResult = ({
428
+ status: 'located';
429
+ region: PixelRect;
430
+ normalizedRegion: PixelRect;
431
+ selection: ChoiceSelection;
432
+ method: 'three-choice-grid-v1';
433
+ refinement?: RefinementResult;
434
+ } | {
435
+ status: 'not-found';
436
+ reason: 'absent-in-evaluated-region';
437
+ } | {
438
+ status: 'unknown';
439
+ reason: 'uncertain-presence' | 'candidate-union-empty' | 'contradictory-evidence' | 'layout-limit';
440
+ }) & {
441
+ metadata: LocalizationMetadata;
442
+ };
443
+ export type RefinementResult = {
444
+ status: 'refined';
445
+ region: PixelRect;
446
+ method: string;
447
+ } | {
448
+ status: 'unknown';
449
+ reason: string;
450
+ };
451
+ export interface RefinementPort {
452
+ refine(input: {
453
+ image: Uint8Array;
454
+ target: string;
455
+ region: PixelRect;
456
+ signal: AbortSignal;
457
+ }): Promise<RefinementResult>;
458
+ }
459
+ export declare function parse<T>(schema: z.ZodType<T, z.ZodTypeDef, unknown>, value: unknown, code?: 'INVALID_INPUT' | 'INVALID_RESPONSE'): T;
460
+ export interface RasterImage {
461
+ bytes: Uint8Array;
462
+ width: number;
463
+ height: number;
464
+ }
465
+ export interface RasterPort {
466
+ normalize(bytes: Uint8Array, signal: AbortSignal): Promise<RasterImage>;
467
+ crop(image: RasterImage, region: PixelRect, signal: AbortSignal, scale?: number): Promise<RasterImage>;
468
+ imageState(image: RasterImage, signal: AbortSignal): Promise<DecisionState>;
469
+ grid(image: RasterImage, region: PixelRect, cells: readonly GridCell[], labels: ReadonlyMap<string, string>, signal: AbortSignal): Promise<RasterImage>;
470
+ }
471
+ export {};
@@ -0,0 +1,97 @@
1
+ import { z } from 'zod';
2
+ import { ClassifierError } from './errors.js';
3
+ export const limits = Object.freeze({
4
+ imageBytes: 16 * 1024 * 1024,
5
+ imagePixels: 16_777_216,
6
+ bodyBytes: 32 * 1024 * 1024,
7
+ maxClasses: 255,
8
+ maxImages: 9,
9
+ });
10
+ export const pixelRectSchema = z
11
+ .object({
12
+ left: z.number().int().nonnegative().safe(),
13
+ top: z.number().int().nonnegative().safe(),
14
+ width: z.number().int().positive().max(16384),
15
+ height: z.number().int().positive().max(16384),
16
+ })
17
+ .strict();
18
+ export const classSchema = z
19
+ .object({
20
+ id: z
21
+ .string()
22
+ .min(1)
23
+ .max(128)
24
+ .regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/),
25
+ description: z.string().trim().min(1).max(300),
26
+ })
27
+ .strict();
28
+ const imageSchema = z
29
+ .custom((value) => value instanceof Uint8Array)
30
+ .refine((v) => v.byteLength > 0 && v.byteLength <= limits.imageBytes, 'Expected 1..16MiB image bytes');
31
+ export const representationSchema = z.discriminatedUnion('type', [
32
+ z.object({ type: z.literal('vision') }).strict(),
33
+ z.object({ type: z.literal('experimental-text'), profile: z.literal('text-image-v1') }).strict(),
34
+ ]);
35
+ const mediaInputSchema = z
36
+ .object({ text: z.string().trim().min(1).max(32000).optional(), image: imageSchema.optional() })
37
+ .strict()
38
+ .refine((v) => v.text !== undefined || v.image !== undefined, 'Provide text or image');
39
+ export const classifySchema = z
40
+ .object({
41
+ input: z.union([z.string().trim().min(1).max(32000), mediaInputSchema]),
42
+ classes: z
43
+ .array(classSchema)
44
+ .min(2)
45
+ .max(limits.maxClasses)
46
+ .refine((v) => new Set(v.map((c) => c.id)).size === v.length, 'Class IDs must be unique'),
47
+ instructions: z.string().trim().min(1).max(4000).optional(),
48
+ representation: representationSchema.optional(),
49
+ })
50
+ .strict();
51
+ export const locateSchema = z
52
+ .object({
53
+ image: imageSchema,
54
+ target: z.string().trim().min(1).max(2000),
55
+ exclusions: z.array(z.string().trim().min(1).max(500)).max(16).default([]),
56
+ roi: pixelRectSchema.optional(),
57
+ mode: z.literal('region').optional(),
58
+ representation: representationSchema.optional(),
59
+ })
60
+ .strict();
61
+ const choiceAnswerSchema = z.object({
62
+ type: z.literal('choice'),
63
+ choice: z.string(),
64
+ probabilities: z.record(z.number().finite().min(0).max(1)),
65
+ confidence: z.number().finite().min(0).max(1).optional(),
66
+ probabilityRoundingStep: z.literal(0.01).optional(),
67
+ });
68
+ const answersSchema = z.record(z.discriminatedUnion('type', [
69
+ choiceAnswerSchema,
70
+ z
71
+ .object({
72
+ type: z.literal('ranked-choice'),
73
+ ranking: z.array(z.string().min(1).max(128)).min(1).max(4),
74
+ })
75
+ .strict(),
76
+ z
77
+ .object({ type: z.literal('presence'), presence: z.enum(['present', 'absent', 'unknown']) })
78
+ .strict(),
79
+ z.object({ type: z.literal('noul'), noul: z.number().finite().min(0).max(1) }),
80
+ ]));
81
+ const metadataSchema = z.object({
82
+ model: z.string().nullable(),
83
+ provider: z.string().nullable(),
84
+ requestId: z.string().nullable(),
85
+ durationMs: z.number().finite().nonnegative(),
86
+ costUsd: z.number().finite().nonnegative().nullable(),
87
+ attempts: z.number().int().positive(),
88
+ });
89
+ export const decisionResultSchema = z.object({ answers: answersSchema, metadata: metadataSchema });
90
+ export function parse(schema, value, code = 'INVALID_INPUT') {
91
+ const result = schema.safeParse(value);
92
+ if (!result.success)
93
+ throw new ClassifierError(code, 'Schema validation failed', {
94
+ paths: result.error.issues.map((v) => v.path.join('.')),
95
+ });
96
+ return result.data;
97
+ }
@@ -0,0 +1,7 @@
1
+ import type { RasterImage } from './contracts.js';
2
+ import type { RgbaRaster } from './representation.js';
3
+ /** Pixel codec boundary owned by infrastructure; orchestration only sees canonical pixels. */
4
+ export interface CutoutRasterPort {
5
+ rgba(image: RasterImage, signal: AbortSignal): Promise<RgbaRaster>;
6
+ png(image: RgbaRaster, signal: AbortSignal): Promise<Uint8Array>;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export type ErrorCode = 'INVALID_INPUT' | 'INVALID_RESPONSE' | 'TIMEOUT' | 'ABORTED' | 'CAPACITY' | 'DISPOSED' | 'PROVIDER' | 'AUTHENTICATION' | 'UNSUPPORTED' | 'RESOURCE_LIMIT';
2
+ export declare class ClassifierError extends Error {
3
+ readonly code: ErrorCode;
4
+ readonly details: Readonly<Record<string, unknown>>;
5
+ constructor(code: ErrorCode, message: string, details?: Readonly<Record<string, unknown>>);
6
+ }
7
+ export declare function assertActive(signal: AbortSignal): void;
@@ -0,0 +1,16 @@
1
+ export class ClassifierError extends Error {
2
+ code;
3
+ details;
4
+ constructor(code, message, details = {}) {
5
+ super(message);
6
+ this.code = code;
7
+ this.details = details;
8
+ this.name = 'ClassifierError';
9
+ }
10
+ }
11
+ export function assertActive(signal) {
12
+ if (signal.aborted)
13
+ throw signal.reason instanceof ClassifierError
14
+ ? signal.reason
15
+ : new ClassifierError('ABORTED', 'Operation cancelled');
16
+ }
@@ -0,0 +1,53 @@
1
+ import type { PixelRect } from './contracts.js';
2
+ import type { RgbaRaster } from './representation.js';
3
+ import type { SegmentationMetadata } from './segmentation-metadata.js';
4
+ /** One-shot packed proposals avoid keeping native workers alive during model requests. */
5
+ export declare const objectProposalLimits: Readonly<{
6
+ imagePixels: 2097152;
7
+ candidates: 36;
8
+ packedBytes: number;
9
+ presentationBytes: number;
10
+ presentationImages: 4;
11
+ }>;
12
+ /** Row-major, least-significant bit first; unused bits in the last byte must be zero. */
13
+ export interface PackedBinaryMask {
14
+ data: Uint8Array;
15
+ width: number;
16
+ height: number;
17
+ format: 'binary-lsb0';
18
+ }
19
+ export interface ObjectProposal {
20
+ /** Stable input-order alias C00…C35, never a case ID or semantic annotation. */
21
+ id: string;
22
+ mask: PackedBinaryMask;
23
+ /** Uncalibrated native diagnostic only; never included in model requests. */
24
+ qualityScore?: number;
25
+ }
26
+ export interface ObjectProposalInput {
27
+ image: RgbaRaster;
28
+ seedRegion: PixelRect;
29
+ roi: PixelRect;
30
+ signal: AbortSignal;
31
+ }
32
+ export interface ObjectProposalBatch {
33
+ proposals: readonly ObjectProposal[];
34
+ metadata: SegmentationMetadata;
35
+ }
36
+ /** Caller-owned. propose settles only after physical work closes; no model calls here. */
37
+ export interface ObjectProposalPort {
38
+ propose(input: ObjectProposalInput): Promise<ObjectProposalBatch>;
39
+ settle(): Promise<void>;
40
+ dispose(): Promise<void>;
41
+ }
42
+ /** Pixel-derived boxes are computed and validated by the process, never generated by a model. */
43
+ export interface PresentedObjectProposal extends ObjectProposal {
44
+ region: PixelRect | null;
45
+ }
46
+ export interface ObjectProposalPresentationPort {
47
+ render(input: {
48
+ image: RgbaRaster;
49
+ seedRegion: PixelRect;
50
+ proposals: readonly PresentedObjectProposal[];
51
+ signal: AbortSignal;
52
+ }): Promise<readonly Uint8Array[]>;
53
+ }
@@ -0,0 +1,8 @@
1
+ /** One-shot packed proposals avoid keeping native workers alive during model requests. */
2
+ export const objectProposalLimits = Object.freeze({
3
+ imagePixels: 2_097_152,
4
+ candidates: 36,
5
+ packedBytes: 10 * 1024 * 1024,
6
+ presentationBytes: 16 * 1024 * 1024,
7
+ presentationImages: 4,
8
+ });