zorya-classifier 0.1.0 → 0.2.1

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 (311) hide show
  1. package/NOTICE.md +2 -0
  2. package/README.md +37 -9
  3. package/dist/app/cli-arguments.d.ts +40 -0
  4. package/dist/app/cli-arguments.js +67 -0
  5. package/dist/app/create-classifier.d.ts +24 -0
  6. package/dist/app/create-classifier.js +226 -14
  7. package/dist/app/extraction-files.d.ts +9 -0
  8. package/dist/app/extraction-files.js +28 -0
  9. package/dist/cli.js +58 -14
  10. package/dist/entities/boundary-view.d.ts +29 -0
  11. package/dist/entities/boundary-view.js +1 -0
  12. package/dist/entities/contracts.d.ts +81 -1
  13. package/dist/entities/contracts.js +7 -0
  14. package/dist/entities/cutout-raster.d.ts +7 -0
  15. package/dist/entities/cutout-raster.js +1 -0
  16. package/dist/entities/object-proposals.d.ts +56 -0
  17. package/dist/entities/object-proposals.js +8 -0
  18. package/dist/entities/representation.d.ts +225 -0
  19. package/dist/entities/representation.js +33 -0
  20. package/dist/entities/segmentation-metadata.d.ts +11 -0
  21. package/dist/entities/segmentation-metadata.js +1 -0
  22. package/dist/entities/segmentation-verification.d.ts +31 -0
  23. package/dist/entities/segmentation-verification.js +1 -0
  24. package/dist/entities/segmentation.d.ts +164 -0
  25. package/dist/entities/segmentation.js +5 -0
  26. package/dist/entities/whole-object.d.ts +132 -0
  27. package/dist/entities/whole-object.js +7 -0
  28. package/dist/features/choice.d.ts +1 -1
  29. package/dist/features/choice.js +2 -2
  30. package/dist/features/segmentation/box-check.d.ts +10 -0
  31. package/dist/features/segmentation/box-check.js +299 -0
  32. package/dist/features/segmentation/mask.d.ts +6 -0
  33. package/dist/features/segmentation/mask.js +89 -0
  34. package/dist/features/segmentation/packed-mask.d.ts +5 -0
  35. package/dist/features/segmentation/packed-mask.js +53 -0
  36. package/dist/index.d.ts +6 -1
  37. package/dist/infrastructure/boundary-view.d.ts +2 -0
  38. package/dist/infrastructure/boundary-view.js +263 -0
  39. package/dist/infrastructure/openrouter-common.d.ts +8 -8
  40. package/dist/infrastructure/openrouter-vision.d.ts +3 -0
  41. package/dist/infrastructure/openrouter-vision.js +5 -0
  42. package/dist/infrastructure/raster.d.ts +10 -1
  43. package/dist/infrastructure/raster.js +99 -4
  44. package/dist/infrastructure/segmentation/box-presentation.d.ts +2 -0
  45. package/dist/infrastructure/segmentation/box-presentation.js +136 -0
  46. package/dist/infrastructure/segmentation/cutout-raster.d.ts +3 -0
  47. package/dist/infrastructure/segmentation/cutout-raster.js +79 -0
  48. package/dist/infrastructure/segmentation/grabcut/index.d.ts +17 -0
  49. package/dist/infrastructure/segmentation/grabcut/index.js +121 -0
  50. package/dist/infrastructure/segmentation/grabcut/worker-inference.d.ts +47 -0
  51. package/dist/infrastructure/segmentation/grabcut/worker-inference.js +260 -0
  52. package/dist/infrastructure/segmentation/index.d.ts +2 -0
  53. package/dist/infrastructure/segmentation/index.js +2 -0
  54. package/dist/infrastructure/segmentation/mobile-sam/index.d.ts +66 -0
  55. package/dist/infrastructure/segmentation/mobile-sam/index.js +478 -0
  56. package/dist/infrastructure/segmentation/mobile-sam/worker-inference.d.ts +149 -0
  57. package/dist/infrastructure/segmentation/mobile-sam/worker-inference.js +845 -0
  58. package/dist/infrastructure/segmentation/native-child.d.ts +23 -0
  59. package/dist/infrastructure/segmentation/native-child.js +297 -0
  60. package/dist/infrastructure/segmentation/native-protocol.d.ts +923 -0
  61. package/dist/infrastructure/segmentation/native-protocol.js +242 -0
  62. package/dist/infrastructure/segmentation/native-worker.d.ts +1 -0
  63. package/dist/infrastructure/segmentation/native-worker.js +93 -0
  64. package/dist/infrastructure/segmentation/probe-backend.d.ts +1 -0
  65. package/dist/infrastructure/segmentation/probe-backend.js +31 -0
  66. package/dist/infrastructure/segmentation/proposal-presentation.d.ts +3 -0
  67. package/dist/infrastructure/segmentation/proposal-presentation.js +371 -0
  68. package/dist/infrastructure/segmentation/verify-asset.d.ts +4 -0
  69. package/dist/infrastructure/segmentation/verify-asset.js +32 -0
  70. package/dist/infrastructure/text-representation.d.ts +23 -0
  71. package/dist/infrastructure/text-representation.js +226 -0
  72. package/dist/infrastructure/vision-chat.d.ts +1 -1
  73. package/dist/infrastructure/vision-chat.js +13 -4
  74. package/dist/openai-compatible.d.ts +3 -0
  75. package/dist/openai-compatible.js +4 -0
  76. package/dist/openrouter.d.ts +2 -2
  77. package/dist/openrouter.js +1 -1
  78. package/dist/processes/boundary-state.d.ts +12 -0
  79. package/dist/processes/boundary-state.js +196 -0
  80. package/dist/processes/classify.d.ts +2 -1
  81. package/dist/processes/classify.js +21 -3
  82. package/dist/processes/extract-from-region.d.ts +19 -0
  83. package/dist/processes/extract-from-region.js +415 -0
  84. package/dist/processes/extract.d.ts +25 -0
  85. package/dist/processes/extract.js +223 -0
  86. package/dist/processes/locate.d.ts +2 -1
  87. package/dist/processes/locate.js +84 -11
  88. package/dist/processes/proposal-location.d.ts +19 -0
  89. package/dist/processes/proposal-location.js +396 -0
  90. package/dist/processes/whole-object.d.ts +7 -0
  91. package/dist/processes/whole-object.js +272 -0
  92. package/dist/segmentation.d.ts +10 -0
  93. package/dist/segmentation.js +4 -0
  94. package/dist/shared/input-budget.d.ts +7 -0
  95. package/dist/shared/input-budget.js +21 -0
  96. package/docs/0.2.0-plan.md +190 -0
  97. package/docs/README.ru.md +43 -14
  98. package/docs/acceptance.md +116 -3
  99. package/docs/api.md +12 -6
  100. package/docs/architecture.md +22 -7
  101. package/docs/benchmarks.md +10 -0
  102. package/docs/categorical-presence-port.md +26 -0
  103. package/docs/evidence/v02/baseline.json +1043 -0
  104. package/docs/evidence/v02/boundary-variants.md +17 -0
  105. package/docs/evidence/v02/box-confirmation-dev40/README.md +15 -0
  106. package/docs/evidence/v02/box-confirmation-dev40/component-refinement.json +246 -0
  107. package/docs/evidence/v02/box-confirmation-dev40/evaluation.json +1663 -0
  108. package/docs/evidence/v02/box-confirmation-dev40/provenance.json +130 -0
  109. package/docs/evidence/v02/box-confirmation-dev40/report.json +127 -0
  110. package/docs/evidence/v02/box-confirmation-dev40-freeze-20261020-v1.json +230 -0
  111. package/docs/evidence/v02/box-confirmation-method-selection-20261020-v1.json +85 -0
  112. package/docs/evidence/v02/box-heldout-cancelled-before-dispatch-20261021-v1.json +32 -0
  113. package/docs/evidence/v02/box-heldout-combined-seal-20261021-v1.json +89 -0
  114. package/docs/evidence/v02/box-heldout-evaluator-truth-seal-20261021-v1.json +61 -0
  115. package/docs/evidence/v02/box-heldout-exclusion-audit-20261020-v1.json +81 -0
  116. package/docs/evidence/v02/box-heldout-map-seal-20261021-v1.json +48 -0
  117. package/docs/evidence/v02/box-heldout-photo-seal-20261020-v1.json +62 -0
  118. package/docs/evidence/v02/box-heldout-run-freeze-20261021-v1.json +61 -0
  119. package/docs/evidence/v02/box-heldout-source-review-20261020-v1.json +134 -0
  120. package/docs/evidence/v02/box-heldout-ui-seal-20261020-v1.json +44 -0
  121. package/docs/evidence/v02/calculator-proof-root-review-20261020-v1.json +63 -0
  122. package/docs/evidence/v02/categorical-dev40-freeze.json +94 -0
  123. package/docs/evidence/v02/categorical-dev40-preserve.json +460 -0
  124. package/docs/evidence/v02/categorical-dev40-target-only.json +460 -0
  125. package/docs/evidence/v02/categorical-heldout-admission-20261020-v3.json +215 -0
  126. package/docs/evidence/v02/categorical-heldout-admission-20261020-v4.json +270 -0
  127. package/docs/evidence/v02/categorical-heldout-dispatch-authorization-20261020-v4.json +79 -0
  128. package/docs/evidence/v02/categorical-heldout-predispatch-20261020-v3.json +57 -0
  129. package/docs/evidence/v02/categorical-heldout-producer-source-map-v4.json +262 -0
  130. package/docs/evidence/v02/categorical-heldout-producer-source-map.json +263 -0
  131. package/docs/evidence/v02/categorical-heldout-run-freeze-20261020-v3.json +35 -0
  132. package/docs/evidence/v02/categorical-heldout-run-freeze-20261020-v4.json +35 -0
  133. package/docs/evidence/v02/categorical-heldout-v4/candidate-evaluation.json +2812 -0
  134. package/docs/evidence/v02/categorical-heldout-v4/candidate-physical-receipts.json +15261 -0
  135. package/docs/evidence/v02/categorical-heldout-v4/candidate-provenance.json +131 -0
  136. package/docs/evidence/v02/categorical-heldout-v4/control-evaluation.json +855 -0
  137. package/docs/evidence/v02/categorical-heldout-v4/control-physical-receipts.json +4402 -0
  138. package/docs/evidence/v02/categorical-heldout-v4/control-provenance.json +31 -0
  139. package/docs/evidence/v02/categorical-heldout-v4/mask-normalized-exploratory.json +682 -0
  140. package/docs/evidence/v02/categorical-heldout-v4/paired-qualification.json +21 -0
  141. package/docs/evidence/v02/categorical-heldout-v4/report.json +258 -0
  142. package/docs/evidence/v02/categorical-presence-dev6.json +144 -0
  143. package/docs/evidence/v02/categorical-presence-dev6.md +18 -0
  144. package/docs/evidence/v02/categorical-vision-method-selection.json +90 -0
  145. package/docs/evidence/v02/checked-region-component-v1/README.md +7 -0
  146. package/docs/evidence/v02/checked-region-component-v1/evidence.json +311 -0
  147. package/docs/evidence/v02/checked-region-resource-interrupted-2b0d09f.json +102 -0
  148. package/docs/evidence/v02/checked-region-segmentation-resource-4df544c-receipt.json +167 -0
  149. package/docs/evidence/v02/checked-region-segmentation-resource-4df544c-root-review.json +58 -0
  150. package/docs/evidence/v02/checked-region-segmentation-resource-987ac32-receipt.json +158 -0
  151. package/docs/evidence/v02/ci-012b935.json +17 -0
  152. package/docs/evidence/v02/ci-0c365cb.json +372 -0
  153. package/docs/evidence/v02/ci-185bde8.json +32 -0
  154. package/docs/evidence/v02/ci-24f849f.json +95 -0
  155. package/docs/evidence/v02/ci-25c19cd.json +375 -0
  156. package/docs/evidence/v02/ci-2922caf.json +375 -0
  157. package/docs/evidence/v02/ci-29357d7.json +29 -0
  158. package/docs/evidence/v02/ci-32aa90d.json +24 -0
  159. package/docs/evidence/v02/ci-35e3064.json +376 -0
  160. package/docs/evidence/v02/ci-4331b1b.json +384 -0
  161. package/docs/evidence/v02/ci-43b7426.json +376 -0
  162. package/docs/evidence/v02/ci-450439c.json +373 -0
  163. package/docs/evidence/v02/ci-46283fe.json +29 -0
  164. package/docs/evidence/v02/ci-4c9c09f.json +34 -0
  165. package/docs/evidence/v02/ci-5579646.json +27 -0
  166. package/docs/evidence/v02/ci-6f9cc15.json +127 -0
  167. package/docs/evidence/v02/ci-7c1051f.json +27 -0
  168. package/docs/evidence/v02/ci-9837888.json +34 -0
  169. package/docs/evidence/v02/ci-987ac32.json +29 -0
  170. package/docs/evidence/v02/ci-9d00fe5.json +25 -0
  171. package/docs/evidence/v02/ci-9f85acc.json +127 -0
  172. package/docs/evidence/v02/ci-be275a6.json +201 -0
  173. package/docs/evidence/v02/ci-c107ddf.json +372 -0
  174. package/docs/evidence/v02/ci-c35f67d.json +127 -0
  175. package/docs/evidence/v02/ci-c5eddd8.json +32 -0
  176. package/docs/evidence/v02/ci-d2042e0.json +372 -0
  177. package/docs/evidence/v02/ci-d684259.json +375 -0
  178. package/docs/evidence/v02/ci-e0c190b.json +127 -0
  179. package/docs/evidence/v02/ci-e551253.json +372 -0
  180. package/docs/evidence/v02/ci-f9d4633.json +29 -0
  181. package/docs/evidence/v02/dev1-proposal-evaluation.md +13 -0
  182. package/docs/evidence/v02/dev2-mobile-sam-proposal-oracle.md +21 -0
  183. package/docs/evidence/v02/dev2-proposal-evaluation.md +21 -0
  184. package/docs/evidence/v02/fresh-development.md +16 -0
  185. package/docs/evidence/v02/fresh-native-numeric/artifact-hashes.json +9 -0
  186. package/docs/evidence/v02/fresh-native-numeric/evaluation-root-v1.json +568 -0
  187. package/docs/evidence/v02/fresh-native-numeric/run-manifest.json +342 -0
  188. package/docs/evidence/v02/fresh-native-numeric/summary.json +5654 -0
  189. package/docs/evidence/v02/fresh-native-outline-axis/artifact-hashes.json +9 -0
  190. package/docs/evidence/v02/fresh-native-outline-axis/evaluation-root-v1.json +568 -0
  191. package/docs/evidence/v02/fresh-native-outline-axis/run-manifest.json +378 -0
  192. package/docs/evidence/v02/fresh-native-outline-axis/summary.json +5605 -0
  193. package/docs/evidence/v02/fresh-text/README.md +23 -0
  194. package/docs/evidence/v02/fresh-text/ascii-contours-v1/classify-followup-run-manifest.json +405 -0
  195. package/docs/evidence/v02/fresh-text/ascii-contours-v1/classify-followup-summary.json +1646 -0
  196. package/docs/evidence/v02/fresh-text/ascii-contours-v1/evaluation.json +568 -0
  197. package/docs/evidence/v02/fresh-text/ascii-contours-v1/original-run-manifest.json +404 -0
  198. package/docs/evidence/v02/fresh-text/ascii-contours-v1/original-summary.json +4416 -0
  199. package/docs/evidence/v02/fresh-text/ascii-luma-v1/classify-followup-run-manifest.json +405 -0
  200. package/docs/evidence/v02/fresh-text/ascii-luma-v1/classify-followup-summary.json +1646 -0
  201. package/docs/evidence/v02/fresh-text/ascii-luma-v1/evaluation.json +568 -0
  202. package/docs/evidence/v02/fresh-text/ascii-luma-v1/original-run-manifest.json +404 -0
  203. package/docs/evidence/v02/fresh-text/ascii-luma-v1/original-summary.json +4647 -0
  204. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/classify-followup-run-manifest.json +405 -0
  205. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/classify-followup-summary.json +846 -0
  206. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/evaluation.json +568 -0
  207. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/original-run-manifest.json +404 -0
  208. package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/original-summary.json +1789 -0
  209. package/docs/evidence/v02/fresh-text/no-image-control/evaluation.json +568 -0
  210. package/docs/evidence/v02/fresh-text/no-image-control/original-run-manifest.json +404 -0
  211. package/docs/evidence/v02/fresh-text/no-image-control/original-summary.json +3953 -0
  212. package/docs/evidence/v02/fresh-text/palette-grid-v1/classify-followup-run-manifest.json +405 -0
  213. package/docs/evidence/v02/fresh-text/palette-grid-v1/classify-followup-summary.json +1646 -0
  214. package/docs/evidence/v02/fresh-text/palette-grid-v1/evaluation.json +568 -0
  215. package/docs/evidence/v02/fresh-text/palette-grid-v1/original-run-manifest.json +404 -0
  216. package/docs/evidence/v02/fresh-text/palette-grid-v1/original-summary.json +3974 -0
  217. package/docs/evidence/v02/fresh-text/pixel-rle-v1/classify-followup-run-manifest.json +405 -0
  218. package/docs/evidence/v02/fresh-text/pixel-rle-v1/classify-followup-summary.json +1646 -0
  219. package/docs/evidence/v02/fresh-text/pixel-rle-v1/evaluation.json +568 -0
  220. package/docs/evidence/v02/fresh-text/pixel-rle-v1/original-run-manifest.json +404 -0
  221. package/docs/evidence/v02/fresh-text/pixel-rle-v1/original-summary.json +4945 -0
  222. package/docs/evidence/v02/fresh-text/report.json +284 -0
  223. package/docs/evidence/v02/fresh-text/svg-contours-v1/classify-followup-run-manifest.json +405 -0
  224. package/docs/evidence/v02/fresh-text/svg-contours-v1/classify-followup-summary.json +846 -0
  225. package/docs/evidence/v02/fresh-text/svg-contours-v1/evaluation.json +568 -0
  226. package/docs/evidence/v02/fresh-text/svg-contours-v1/original-run-manifest.json +404 -0
  227. package/docs/evidence/v02/fresh-text/svg-contours-v1/original-summary.json +2189 -0
  228. package/docs/evidence/v02/heldout-evaluation-20261020.md +37 -0
  229. package/docs/evidence/v02/heldout-input-derivation.md +18 -0
  230. package/docs/evidence/v02/integration-0c365cb.json +90 -0
  231. package/docs/evidence/v02/integration-25c19cd.json +52 -0
  232. package/docs/evidence/v02/integration-35e3064.json +41 -0
  233. package/docs/evidence/v02/integration-4331b1b.json +42 -0
  234. package/docs/evidence/v02/integration-4c9c09f.json +46 -0
  235. package/docs/evidence/v02/integration-8010aad.json +48 -0
  236. package/docs/evidence/v02/integration-c1aa640.json +41 -0
  237. package/docs/evidence/v02/integration-eea1790.json +46 -0
  238. package/docs/evidence/v02/integration-fa82e65.json +42 -0
  239. package/docs/evidence/v02/jpeg-transport-offline.json +268 -0
  240. package/docs/evidence/v02/jpeg-transport-offline.md +7 -0
  241. package/docs/evidence/v02/local-archive-cleanup.json +59 -0
  242. package/docs/evidence/v02/native-base64-after.json +30 -0
  243. package/docs/evidence/v02/native-base64-before.json +32 -0
  244. package/docs/evidence/v02/native-checked-region-windows-46283fe.json +248 -0
  245. package/docs/evidence/v02/native-checked-region-windows-987ac32.json +141 -0
  246. package/docs/evidence/v02/native-grabcut-windows-4c494a3-run2.json +148 -0
  247. package/docs/evidence/v02/native-grabcut-windows-4c494a3-run3.json +148 -0
  248. package/docs/evidence/v02/native-grabcut-windows-4c494a3.json +56 -0
  249. package/docs/evidence/v02/native-proposal-windows-0c365cb.json +148 -0
  250. package/docs/evidence/v02/native-proposal-windows-450439c.json +156 -0
  251. package/docs/evidence/v02/native-proposal-windows-4c9c09f-retry1.json +147 -0
  252. package/docs/evidence/v02/native-proposal-windows-4c9c09f.json +52 -0
  253. package/docs/evidence/v02/native-region-windows-efc9318.json +163 -0
  254. package/docs/evidence/v02/native-windows-eea1790-baseline.json +198 -0
  255. package/docs/evidence/v02/native-windows-eea1790.json +228 -0
  256. package/docs/evidence/v02/ordinary-luna-axis/run-manifest.json +99 -0
  257. package/docs/evidence/v02/ordinary-luna-axis/summary.json +811 -0
  258. package/docs/evidence/v02/owned-temp-cleanup-20261020-v1.json +28 -0
  259. package/docs/evidence/v02/presentation-paired-20261020.json +1438 -0
  260. package/docs/evidence/v02/proposal-resource-soak-261dc23.json +201 -0
  261. package/docs/evidence/v02/proposal-resource-soak-450439c-receipt.md +13 -0
  262. package/docs/evidence/v02/reconstructed-c03-box.json +41 -0
  263. package/docs/evidence/v02/region-seeded-dev-v1/README.md +17 -0
  264. package/docs/evidence/v02/region-seeded-dev-v1/evaluation.json +260 -0
  265. package/docs/evidence/v02/region-seeded-dev-v2/README.md +15 -0
  266. package/docs/evidence/v02/region-seeded-dev-v2/evaluation.json +232 -0
  267. package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/README.md +9 -0
  268. package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/control-identity-failure.json +22 -0
  269. package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/evaluation.json +160 -0
  270. package/docs/evidence/v02/region-seeded-dev-v3-control-r2/README.md +9 -0
  271. package/docs/evidence/v02/region-seeded-dev-v3-control-r2/attempt-accounting.json +55 -0
  272. package/docs/evidence/v02/region-seeded-dev-v3-control-r2/evaluation.json +136 -0
  273. package/docs/evidence/v02/region-seeded-development-control-r2-freeze-20261021.json +132 -0
  274. package/docs/evidence/v02/region-seeded-development-freeze-20261021-v1.json +167 -0
  275. package/docs/evidence/v02/region-seeded-development-freeze-20261021-v2.json +186 -0
  276. package/docs/evidence/v02/region-seeded-development-freeze-20261021-v3.json +205 -0
  277. package/docs/evidence/v02/region-seeded-heldout-cancelled-before-dispatch-20261021-v2.json +20 -0
  278. package/docs/evidence/v02/region-seeded-heldout-dispatch-authorization-20261021-v3.json +47 -0
  279. package/docs/evidence/v02/region-seeded-heldout-readiness-audit-20261021-v3.json +125 -0
  280. package/docs/evidence/v02/region-seeded-heldout-run-freeze-20261021-v2.json +234 -0
  281. package/docs/evidence/v02/region-seeded-heldout-run-freeze-20261021-v3.json +357 -0
  282. package/docs/evidence/v02/region-seeded-heldout-v3/README.md +19 -0
  283. package/docs/evidence/v02/region-seeded-heldout-v3/evaluation-summary.json +445 -0
  284. package/docs/evidence/v02/region-seeded-method-selection-20261021-v2.json +66 -0
  285. package/docs/evidence/v02/region-seeded-method-selection-20261021-v3.json +120 -0
  286. package/docs/evidence/v02/region-segmentation-resource-0ba4c87-receipt.json +156 -0
  287. package/docs/evidence/v02/resource-soak-linux-8010aad.json +125 -0
  288. package/docs/evidence/v02/screen-v2-terminal-evaluation.md +22 -0
  289. package/docs/evidence/v02/seed-outline/run-manifest.json +59 -0
  290. package/docs/evidence/v02/seed-outline/summary.json +487 -0
  291. package/docs/evidence/v02/seed-unbounded/run-manifest.json +80 -0
  292. package/docs/evidence/v02/seed-unbounded/summary.json +730 -0
  293. package/docs/evidence/v02/segmentation/README.md +21 -0
  294. package/docs/evidence/v02/segmentation/component-comparison-summary.json +240 -0
  295. package/docs/evidence/v02/segmentation/provenance/MOBILE-SAM-LICENSE.txt +201 -0
  296. package/docs/evidence/v02/segmentation/provenance/OPENCV-LICENSE.txt +202 -0
  297. package/docs/evidence/v02/segmentation/provenance/mobile-sam-download-receipt.json +29 -0
  298. package/docs/evidence/v02/segmentation/provenance/mobile-sam-graph-audit.json +214 -0
  299. package/docs/evidence/v02/segmentation/provenance/mobile-sam-model-metadata.json +166 -0
  300. package/docs/evidence/v02/split-choice-noul-dev6.json +72 -0
  301. package/docs/evidence/v02/split-choice-noul-dev6.md +11 -0
  302. package/docs/evidence/v02/supported-vision-screen-20261020.md +65 -0
  303. package/docs/evidence/v02/wesnoth-1.16.11-minimap-projection-source-audit.md +56 -0
  304. package/docs/evidence/v02/wesnoth-proof-root-review-20261020-v1.json +76 -0
  305. package/docs/operations.md +8 -2
  306. package/docs/plan.md +2 -0
  307. package/docs/publishing.md +16 -1
  308. package/docs/research/text-transport-audit.md +66 -0
  309. package/docs/v02-usage.md +164 -0
  310. package/docs/vision-results.md +31 -2
  311. package/package.json +30 -5
package/dist/cli.js CHANGED
@@ -2,29 +2,73 @@
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { createClassifier } from './index.js';
4
4
  import { createCliDecision } from './app/cli-route.js';
5
+ import { parseCliArguments } from './app/cli-arguments.js';
6
+ import { writeExtractionFiles } from './app/extraction-files.js';
7
+ import { createMobileSamSegmenter, createGrabCutSegmenter } from './segmentation.js';
5
8
  async function main() {
6
- const [command, value, target] = process.argv.slice(2);
7
- if (command === '--help' || !command) {
8
- console.log('zorya-classifier classify-text <text> <classes.json>\nzorya-classifier classify-image <image> <classes.json>\nzorya-classifier locate <image> <target>\nSet ZORYA_MODEL. Default ZORYA_MODE=decisions; use chat for ordinary vision models/custom chat endpoints. OpenRouter: OPENROUTER_API_KEY + ZORYA_PROVIDER. Direct: ZORYA_ENDPOINT + optional ZORYA_API_KEY. Optional ZORYA_REASONING_EFFORT and ZORYA_RESPONSE_FORMAT. One classify request; up to three locate requests.');
9
+ const args = parseCliArguments(process.argv.slice(2));
10
+ if (args.command === 'help') {
11
+ console.log('zorya-classifier classify-text <text> <classes.json>\nzorya-classifier classify-image <image> <classes.json>\nzorya-classifier locate <image> <target> [--mode region|whole-object] (experimental, unqualified spatial search)\nzorya-classifier extract <image> <target> --output <prefix> --backend mobile-sam --encoder <path> --decoder <path> [--provider cpu|dml] (experimental extraction)\nzorya-classifier extract <image> <target> --output <prefix> --backend grabcut --opencv <path> (experimental extraction)\nSet ZORYA_MODEL. Default ZORYA_MODE=decisions; use chat for ordinary vision models/custom chat endpoints. OpenRouter: OPENROUTER_API_KEY + ZORYA_PROVIDER. Direct: ZORYA_ENDPOINT + optional ZORYA_API_KEY. Optional ZORYA_REASONING_EFFORT and ZORYA_RESPONSE_FORMAT. classify is supported; locate/extract/object backends are experimental and not qualified for general use. One classify request; up to three region or six whole-object requests. Extraction additionally runs the explicit local backend. Output files are never overwritten; native assets are never downloaded automatically.');
9
12
  return;
10
13
  }
11
- if (!['classify-text', 'classify-image', 'locate'].includes(command) || !value || !target)
12
- throw new Error('Invalid arguments; use --help');
13
- const client = createClassifier({ decision: createCliDecision(process.env) });
14
+ const { command, value, target } = args;
15
+ const decision = createCliDecision(process.env);
16
+ const controller = new AbortController();
17
+ const abort = () => controller.abort();
18
+ process.once('SIGINT', abort);
19
+ process.once('SIGTERM', abort);
20
+ let segmenter;
21
+ let client;
14
22
  try {
15
- if (command === 'locate')
16
- console.log(JSON.stringify(await client.locate({ image: await readFile(value), target }), null, 2));
17
- else {
23
+ // Validate local data before creating a native worker or dispatching any model request.
24
+ const image = command === 'classify-text' ? undefined : await readFile(value);
25
+ let classes;
26
+ if (command === 'classify-text' || command === 'classify-image') {
18
27
  const { z } = await import('zod');
19
- const { classSchema } = await import('./entities/contracts.js');
28
+ const { classSchema, limits } = await import('./entities/contracts.js');
20
29
  const unknownClasses = JSON.parse(await readFile(target, 'utf8'));
21
- const classes = z.array(classSchema).parse(unknownClasses);
22
- const input = command === 'classify-text' ? value : { image: await readFile(value) };
23
- console.log(JSON.stringify(await client.classify({ input, classes }), null, 2));
30
+ classes = z.array(classSchema).min(2).max(limits.maxClasses).parse(unknownClasses);
31
+ }
32
+ controller.signal.throwIfAborted();
33
+ if (command === 'extract')
34
+ segmenter =
35
+ args.backend === 'mobile-sam'
36
+ ? await createMobileSamSegmenter({
37
+ encoderPath: args.encoder,
38
+ decoderPath: args.decoder,
39
+ executionProvider: args.provider ?? 'cpu',
40
+ })
41
+ : await createGrabCutSegmenter({ assetPath: args.opencv });
42
+ client = createClassifier({ decision, ...(segmenter ? { segmentation: segmenter } : {}) });
43
+ controller.signal.throwIfAborted();
44
+ if (command === 'locate') {
45
+ console.log(JSON.stringify(await client.locate({
46
+ image: image,
47
+ target,
48
+ ...(args.mode ? { mode: args.mode } : {}),
49
+ signal: controller.signal,
50
+ }), null, 2));
51
+ }
52
+ else if (command === 'extract') {
53
+ const result = await client.extract({ image: image, target, signal: controller.signal });
54
+ console.log(JSON.stringify(result.status === 'extracted'
55
+ ? { status: result.status, files: await writeExtractionFiles(args.output, result) }
56
+ : result, null, 2));
57
+ }
58
+ else {
59
+ const input = command === 'classify-text' ? value : { image: image };
60
+ console.log(JSON.stringify(await client.classify({ input, classes: classes, signal: controller.signal }), null, 2));
24
61
  }
25
62
  }
26
63
  finally {
27
- await client.dispose();
64
+ process.removeListener('SIGINT', abort);
65
+ process.removeListener('SIGTERM', abort);
66
+ try {
67
+ await client?.dispose();
68
+ }
69
+ finally {
70
+ await segmenter?.dispose();
71
+ }
28
72
  }
29
73
  }
30
74
  main().catch((error) => {
@@ -0,0 +1,29 @@
1
+ import type { PixelRect, RasterImage } from './contracts.js';
2
+ import type { BoundaryInterval } from './whole-object.js';
3
+ export type BoundaryAxis = 'left' | 'right' | 'top' | 'bottom';
4
+ export interface BoundaryCandidate {
5
+ /** Exact closed Choice key; display labels are mapped back to this ID by code. */
6
+ id: string;
7
+ display: string;
8
+ interval: BoundaryInterval;
9
+ }
10
+ export interface BoundaryViewInput {
11
+ source: RasterImage;
12
+ sourceRegion: PixelRect;
13
+ axis: BoundaryAxis;
14
+ candidates: readonly BoundaryCandidate[];
15
+ signal: AbortSignal;
16
+ }
17
+ export interface BoundaryView {
18
+ image: RasterImage;
19
+ sourceRegion: PixelRect;
20
+ /** Source pixels occupy this rectangle; rulers/gutters are outside it. */
21
+ content: PixelRect;
22
+ scaleX: number;
23
+ scaleY: number;
24
+ candidates: readonly BoundaryCandidate[];
25
+ }
26
+ /** Rendering only: never infers target facts or generates source coordinates. */
27
+ export interface BoundaryViewPort {
28
+ render(input: BoundaryViewInput): Promise<BoundaryView>;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -48,6 +48,23 @@ export declare const classSchema: z.ZodObject<{
48
48
  description: string;
49
49
  }>;
50
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>;
51
68
  export declare const classifySchema: z.ZodObject<{
52
69
  input: z.ZodUnion<[z.ZodString, z.ZodEffects<z.ZodObject<{
53
70
  text: z.ZodOptional<z.ZodString>;
@@ -82,6 +99,22 @@ export declare const classifySchema: z.ZodObject<{
82
99
  description: string;
83
100
  }[]>;
84
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
+ }>]>>;
85
118
  }, "strict", z.ZodTypeAny, {
86
119
  input: string | {
87
120
  text?: string | undefined;
@@ -92,6 +125,12 @@ export declare const classifySchema: z.ZodObject<{
92
125
  description: string;
93
126
  }[];
94
127
  instructions?: string | undefined;
128
+ representation?: {
129
+ type: "vision";
130
+ } | {
131
+ type: "experimental-text";
132
+ profile: "text-image-v1";
133
+ } | undefined;
95
134
  }, {
96
135
  input: string | {
97
136
  text?: string | undefined;
@@ -102,6 +141,12 @@ export declare const classifySchema: z.ZodObject<{
102
141
  description: string;
103
142
  }[];
104
143
  instructions?: string | undefined;
144
+ representation?: {
145
+ type: "vision";
146
+ } | {
147
+ type: "experimental-text";
148
+ profile: "text-image-v1";
149
+ } | undefined;
105
150
  }>;
106
151
  export type ClassifyInput = z.input<typeof classifySchema> & {
107
152
  signal?: AbortSignal;
@@ -126,19 +171,49 @@ export declare const locateSchema: z.ZodObject<{
126
171
  width: number;
127
172
  height: number;
128
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
+ }>]>>;
129
191
  }, "strict", z.ZodTypeAny, {
130
192
  image: Uint8Array<ArrayBufferLike>;
131
193
  target: string;
132
194
  exclusions: string[];
195
+ representation?: {
196
+ type: "vision";
197
+ } | {
198
+ type: "experimental-text";
199
+ profile: "text-image-v1";
200
+ } | undefined;
133
201
  roi?: {
134
202
  left: number;
135
203
  top: number;
136
204
  width: number;
137
205
  height: number;
138
206
  } | undefined;
207
+ mode?: "region" | undefined;
139
208
  }, {
140
209
  image: Uint8Array<ArrayBufferLike>;
141
210
  target: string;
211
+ representation?: {
212
+ type: "vision";
213
+ } | {
214
+ type: "experimental-text";
215
+ profile: "text-image-v1";
216
+ } | undefined;
142
217
  exclusions?: string[] | undefined;
143
218
  roi?: {
144
219
  left: number;
@@ -146,7 +221,9 @@ export declare const locateSchema: z.ZodObject<{
146
221
  width: number;
147
222
  height: number;
148
223
  } | undefined;
224
+ mode?: "region" | undefined;
149
225
  }>;
226
+ /** @experimental Unqualified coarse region search; a located grid cell is a hypothesis, not reliable whole-object geometry or proof of absence. */
150
227
  export type LocateInput = z.input<typeof locateSchema> & {
151
228
  signal?: AbortSignal;
152
229
  };
@@ -337,7 +414,7 @@ export interface ChoiceSelection {
337
414
  export interface ClassificationResult extends ChoiceSelection {
338
415
  metadata: DecisionMetadata;
339
416
  }
340
- interface LocalizationMetadata {
417
+ export interface LocalizationMetadata {
341
418
  image: {
342
419
  width: number;
343
420
  height: number;
@@ -348,6 +425,7 @@ interface LocalizationMetadata {
348
425
  knownCostUsd: number;
349
426
  unknownCostCount: number;
350
427
  }
428
+ /** @experimental Outcome of unqualified spatial localization; grid regions are not semantic object boxes or masks. */
351
429
  export type LocalizationResult = ({
352
430
  status: 'located';
353
431
  region: PixelRect;
@@ -364,6 +442,7 @@ export type LocalizationResult = ({
364
442
  }) & {
365
443
  metadata: LocalizationMetadata;
366
444
  };
445
+ /** @experimental Optional legacy region refinement with no general quality qualification. */
367
446
  export type RefinementResult = {
368
447
  status: 'refined';
369
448
  region: PixelRect;
@@ -372,6 +451,7 @@ export type RefinementResult = {
372
451
  status: 'unknown';
373
452
  reason: string;
374
453
  };
454
+ /** @experimental Caller-owned refinement hook; unqualified for general spatial accuracy. */
375
455
  export interface RefinementPort {
376
456
  refine(input: {
377
457
  image: Uint8Array;
@@ -28,6 +28,10 @@ export const classSchema = z
28
28
  const imageSchema = z
29
29
  .custom((value) => value instanceof Uint8Array)
30
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
+ ]);
31
35
  const mediaInputSchema = z
32
36
  .object({ text: z.string().trim().min(1).max(32000).optional(), image: imageSchema.optional() })
33
37
  .strict()
@@ -41,6 +45,7 @@ export const classifySchema = z
41
45
  .max(limits.maxClasses)
42
46
  .refine((v) => new Set(v.map((c) => c.id)).size === v.length, 'Class IDs must be unique'),
43
47
  instructions: z.string().trim().min(1).max(4000).optional(),
48
+ representation: representationSchema.optional(),
44
49
  })
45
50
  .strict();
46
51
  export const locateSchema = z
@@ -49,6 +54,8 @@ export const locateSchema = z
49
54
  target: z.string().trim().min(1).max(2000),
50
55
  exclusions: z.array(z.string().trim().min(1).max(500)).max(16).default([]),
51
56
  roi: pixelRectSchema.optional(),
57
+ mode: z.literal('region').optional(),
58
+ representation: representationSchema.optional(),
52
59
  })
53
60
  .strict();
54
61
  const choiceAnswerSchema = z.object({
@@ -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,56 @@
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
+ /**
37
+ * Caller-owned. propose settles only after physical work closes; no model calls here.
38
+ * @experimental Mask proposal strategy with no general quality qualification.
39
+ */
40
+ export interface ObjectProposalPort {
41
+ propose(input: ObjectProposalInput): Promise<ObjectProposalBatch>;
42
+ settle(): Promise<void>;
43
+ dispose(): Promise<void>;
44
+ }
45
+ /** Pixel-derived boxes are computed and validated by the process, never generated by a model. */
46
+ export interface PresentedObjectProposal extends ObjectProposal {
47
+ region: PixelRect | null;
48
+ }
49
+ export interface ObjectProposalPresentationPort {
50
+ render(input: {
51
+ image: RgbaRaster;
52
+ seedRegion: PixelRect;
53
+ proposals: readonly PresentedObjectProposal[];
54
+ signal: AbortSignal;
55
+ }): Promise<readonly Uint8Array[]>;
56
+ }
@@ -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
+ });
@@ -0,0 +1,225 @@
1
+ import type { DecisionState, GridCell, PixelRect, RasterImage } from './contracts.js';
2
+ import { z } from 'zod';
3
+ /** Canonical oriented RGBA8. Alpha remains meaningful; transparent is not black. */
4
+ export interface RgbaRaster {
5
+ data: Uint8Array;
6
+ width: number;
7
+ height: number;
8
+ format: 'rgba8';
9
+ }
10
+ export interface RepresentationView {
11
+ id: string;
12
+ role: 'source' | 'crop' | 'grid';
13
+ image: RasterImage;
14
+ sourceRegion: PixelRect;
15
+ grid?: {
16
+ cells: readonly GridCell[];
17
+ labels: ReadonlyMap<string, string>;
18
+ };
19
+ }
20
+ export interface RepresentationMetadata {
21
+ profile: string;
22
+ bytes: number;
23
+ views: {
24
+ id: string;
25
+ sourceRegion: PixelRect;
26
+ width: number;
27
+ height: number;
28
+ scaleX: number;
29
+ scaleY: number;
30
+ content?: PixelRect;
31
+ }[];
32
+ }
33
+ /** Prepare once for the entire decision request, including all candidate views. */
34
+ export interface ImageRepresentationPort {
35
+ prepare(input: {
36
+ source: RasterImage;
37
+ views: readonly RepresentationView[];
38
+ signal: AbortSignal;
39
+ }): Promise<{
40
+ state: DecisionState;
41
+ metadata: RepresentationMetadata;
42
+ }>;
43
+ }
44
+ export declare const representationLimits: Readonly<{
45
+ totalBytes: number;
46
+ partCharacters: 64000;
47
+ maxSide: 64;
48
+ maxViews: 9;
49
+ }>;
50
+ export declare const preparedTextSchema: z.ZodObject<{
51
+ state: z.ZodArray<z.ZodString, "many">;
52
+ metadata: z.ZodObject<{
53
+ profile: z.ZodString;
54
+ bytes: z.ZodNumber;
55
+ views: z.ZodArray<z.ZodObject<{
56
+ id: z.ZodString;
57
+ sourceRegion: z.ZodObject<{
58
+ left: z.ZodNumber;
59
+ top: z.ZodNumber;
60
+ width: z.ZodNumber;
61
+ height: z.ZodNumber;
62
+ }, "strict", z.ZodTypeAny, {
63
+ left: number;
64
+ top: number;
65
+ width: number;
66
+ height: number;
67
+ }, {
68
+ left: number;
69
+ top: number;
70
+ width: number;
71
+ height: number;
72
+ }>;
73
+ width: z.ZodNumber;
74
+ height: z.ZodNumber;
75
+ scaleX: z.ZodNumber;
76
+ scaleY: z.ZodNumber;
77
+ content: z.ZodOptional<z.ZodObject<{
78
+ left: z.ZodNumber;
79
+ top: z.ZodNumber;
80
+ width: z.ZodNumber;
81
+ height: z.ZodNumber;
82
+ }, "strict", z.ZodTypeAny, {
83
+ left: number;
84
+ top: number;
85
+ width: number;
86
+ height: number;
87
+ }, {
88
+ left: number;
89
+ top: number;
90
+ width: number;
91
+ height: number;
92
+ }>>;
93
+ }, "strict", z.ZodTypeAny, {
94
+ width: number;
95
+ height: number;
96
+ id: string;
97
+ sourceRegion: {
98
+ left: number;
99
+ top: number;
100
+ width: number;
101
+ height: number;
102
+ };
103
+ scaleX: number;
104
+ scaleY: number;
105
+ content?: {
106
+ left: number;
107
+ top: number;
108
+ width: number;
109
+ height: number;
110
+ } | undefined;
111
+ }, {
112
+ width: number;
113
+ height: number;
114
+ id: string;
115
+ sourceRegion: {
116
+ left: number;
117
+ top: number;
118
+ width: number;
119
+ height: number;
120
+ };
121
+ scaleX: number;
122
+ scaleY: number;
123
+ content?: {
124
+ left: number;
125
+ top: number;
126
+ width: number;
127
+ height: number;
128
+ } | undefined;
129
+ }>, "many">;
130
+ }, "strict", z.ZodTypeAny, {
131
+ profile: string;
132
+ bytes: number;
133
+ views: {
134
+ width: number;
135
+ height: number;
136
+ id: string;
137
+ sourceRegion: {
138
+ left: number;
139
+ top: number;
140
+ width: number;
141
+ height: number;
142
+ };
143
+ scaleX: number;
144
+ scaleY: number;
145
+ content?: {
146
+ left: number;
147
+ top: number;
148
+ width: number;
149
+ height: number;
150
+ } | undefined;
151
+ }[];
152
+ }, {
153
+ profile: string;
154
+ bytes: number;
155
+ views: {
156
+ width: number;
157
+ height: number;
158
+ id: string;
159
+ sourceRegion: {
160
+ left: number;
161
+ top: number;
162
+ width: number;
163
+ height: number;
164
+ };
165
+ scaleX: number;
166
+ scaleY: number;
167
+ content?: {
168
+ left: number;
169
+ top: number;
170
+ width: number;
171
+ height: number;
172
+ } | undefined;
173
+ }[];
174
+ }>;
175
+ }, "strict", z.ZodTypeAny, {
176
+ metadata: {
177
+ profile: string;
178
+ bytes: number;
179
+ views: {
180
+ width: number;
181
+ height: number;
182
+ id: string;
183
+ sourceRegion: {
184
+ left: number;
185
+ top: number;
186
+ width: number;
187
+ height: number;
188
+ };
189
+ scaleX: number;
190
+ scaleY: number;
191
+ content?: {
192
+ left: number;
193
+ top: number;
194
+ width: number;
195
+ height: number;
196
+ } | undefined;
197
+ }[];
198
+ };
199
+ state: string[];
200
+ }, {
201
+ metadata: {
202
+ profile: string;
203
+ bytes: number;
204
+ views: {
205
+ width: number;
206
+ height: number;
207
+ id: string;
208
+ sourceRegion: {
209
+ left: number;
210
+ top: number;
211
+ width: number;
212
+ height: number;
213
+ };
214
+ scaleX: number;
215
+ scaleY: number;
216
+ content?: {
217
+ left: number;
218
+ top: number;
219
+ width: number;
220
+ height: number;
221
+ } | undefined;
222
+ }[];
223
+ };
224
+ state: string[];
225
+ }>;
@@ -0,0 +1,33 @@
1
+ import { pixelRectSchema } from './contracts.js';
2
+ import { z } from 'zod';
3
+ export const representationLimits = Object.freeze({
4
+ totalBytes: 64 * 1024,
5
+ partCharacters: 64000,
6
+ maxSide: 64,
7
+ maxViews: 9,
8
+ });
9
+ export const preparedTextSchema = z
10
+ .object({
11
+ state: z.array(z.string().min(1).max(representationLimits.partCharacters)).min(1).max(64),
12
+ metadata: z
13
+ .object({
14
+ profile: z.string().min(1).max(128),
15
+ bytes: z.number().int().nonnegative().max(representationLimits.totalBytes),
16
+ views: z
17
+ .array(z
18
+ .object({
19
+ id: z.string().min(1).max(256),
20
+ sourceRegion: pixelRectSchema,
21
+ width: z.number().int().positive().max(16384),
22
+ height: z.number().int().positive().max(16384),
23
+ scaleX: z.number().finite().positive(),
24
+ scaleY: z.number().finite().positive(),
25
+ content: pixelRectSchema.optional(),
26
+ })
27
+ .strict())
28
+ .min(1)
29
+ .max(representationLimits.maxViews),
30
+ })
31
+ .strict(),
32
+ })
33
+ .strict();
@@ -0,0 +1,11 @@
1
+ /** Diagnostic native scores are uncalibrated finite values, not probabilities. */
2
+ export interface SegmentationMetadata {
3
+ method: string;
4
+ backend: string;
5
+ durationMs: number;
6
+ input: {
7
+ width: number;
8
+ height: number;
9
+ };
10
+ qualityScore?: number;
11
+ }
@@ -0,0 +1 @@
1
+ export {};