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.
- package/NOTICE.md +2 -0
- package/README.md +37 -9
- package/dist/app/cli-arguments.d.ts +40 -0
- package/dist/app/cli-arguments.js +67 -0
- package/dist/app/create-classifier.d.ts +24 -0
- package/dist/app/create-classifier.js +226 -14
- package/dist/app/extraction-files.d.ts +9 -0
- package/dist/app/extraction-files.js +28 -0
- package/dist/cli.js +58 -14
- package/dist/entities/boundary-view.d.ts +29 -0
- package/dist/entities/boundary-view.js +1 -0
- package/dist/entities/contracts.d.ts +81 -1
- package/dist/entities/contracts.js +7 -0
- package/dist/entities/cutout-raster.d.ts +7 -0
- package/dist/entities/cutout-raster.js +1 -0
- package/dist/entities/object-proposals.d.ts +56 -0
- package/dist/entities/object-proposals.js +8 -0
- package/dist/entities/representation.d.ts +225 -0
- package/dist/entities/representation.js +33 -0
- package/dist/entities/segmentation-metadata.d.ts +11 -0
- package/dist/entities/segmentation-metadata.js +1 -0
- package/dist/entities/segmentation-verification.d.ts +31 -0
- package/dist/entities/segmentation-verification.js +1 -0
- package/dist/entities/segmentation.d.ts +164 -0
- package/dist/entities/segmentation.js +5 -0
- package/dist/entities/whole-object.d.ts +132 -0
- package/dist/entities/whole-object.js +7 -0
- package/dist/features/choice.d.ts +1 -1
- package/dist/features/choice.js +2 -2
- package/dist/features/segmentation/box-check.d.ts +10 -0
- package/dist/features/segmentation/box-check.js +299 -0
- package/dist/features/segmentation/mask.d.ts +6 -0
- package/dist/features/segmentation/mask.js +89 -0
- package/dist/features/segmentation/packed-mask.d.ts +5 -0
- package/dist/features/segmentation/packed-mask.js +53 -0
- package/dist/index.d.ts +6 -1
- package/dist/infrastructure/boundary-view.d.ts +2 -0
- package/dist/infrastructure/boundary-view.js +263 -0
- package/dist/infrastructure/openrouter-common.d.ts +8 -8
- package/dist/infrastructure/openrouter-vision.d.ts +3 -0
- package/dist/infrastructure/openrouter-vision.js +5 -0
- package/dist/infrastructure/raster.d.ts +10 -1
- package/dist/infrastructure/raster.js +99 -4
- package/dist/infrastructure/segmentation/box-presentation.d.ts +2 -0
- package/dist/infrastructure/segmentation/box-presentation.js +136 -0
- package/dist/infrastructure/segmentation/cutout-raster.d.ts +3 -0
- package/dist/infrastructure/segmentation/cutout-raster.js +79 -0
- package/dist/infrastructure/segmentation/grabcut/index.d.ts +17 -0
- package/dist/infrastructure/segmentation/grabcut/index.js +121 -0
- package/dist/infrastructure/segmentation/grabcut/worker-inference.d.ts +47 -0
- package/dist/infrastructure/segmentation/grabcut/worker-inference.js +260 -0
- package/dist/infrastructure/segmentation/index.d.ts +2 -0
- package/dist/infrastructure/segmentation/index.js +2 -0
- package/dist/infrastructure/segmentation/mobile-sam/index.d.ts +66 -0
- package/dist/infrastructure/segmentation/mobile-sam/index.js +478 -0
- package/dist/infrastructure/segmentation/mobile-sam/worker-inference.d.ts +149 -0
- package/dist/infrastructure/segmentation/mobile-sam/worker-inference.js +845 -0
- package/dist/infrastructure/segmentation/native-child.d.ts +23 -0
- package/dist/infrastructure/segmentation/native-child.js +297 -0
- package/dist/infrastructure/segmentation/native-protocol.d.ts +923 -0
- package/dist/infrastructure/segmentation/native-protocol.js +242 -0
- package/dist/infrastructure/segmentation/native-worker.d.ts +1 -0
- package/dist/infrastructure/segmentation/native-worker.js +93 -0
- package/dist/infrastructure/segmentation/probe-backend.d.ts +1 -0
- package/dist/infrastructure/segmentation/probe-backend.js +31 -0
- package/dist/infrastructure/segmentation/proposal-presentation.d.ts +3 -0
- package/dist/infrastructure/segmentation/proposal-presentation.js +371 -0
- package/dist/infrastructure/segmentation/verify-asset.d.ts +4 -0
- package/dist/infrastructure/segmentation/verify-asset.js +32 -0
- package/dist/infrastructure/text-representation.d.ts +23 -0
- package/dist/infrastructure/text-representation.js +226 -0
- package/dist/infrastructure/vision-chat.d.ts +1 -1
- package/dist/infrastructure/vision-chat.js +13 -4
- package/dist/openai-compatible.d.ts +3 -0
- package/dist/openai-compatible.js +4 -0
- package/dist/openrouter.d.ts +2 -2
- package/dist/openrouter.js +1 -1
- package/dist/processes/boundary-state.d.ts +12 -0
- package/dist/processes/boundary-state.js +196 -0
- package/dist/processes/classify.d.ts +2 -1
- package/dist/processes/classify.js +21 -3
- package/dist/processes/extract-from-region.d.ts +19 -0
- package/dist/processes/extract-from-region.js +415 -0
- package/dist/processes/extract.d.ts +25 -0
- package/dist/processes/extract.js +223 -0
- package/dist/processes/locate.d.ts +2 -1
- package/dist/processes/locate.js +84 -11
- package/dist/processes/proposal-location.d.ts +19 -0
- package/dist/processes/proposal-location.js +396 -0
- package/dist/processes/whole-object.d.ts +7 -0
- package/dist/processes/whole-object.js +272 -0
- package/dist/segmentation.d.ts +10 -0
- package/dist/segmentation.js +4 -0
- package/dist/shared/input-budget.d.ts +7 -0
- package/dist/shared/input-budget.js +21 -0
- package/docs/0.2.0-plan.md +190 -0
- package/docs/README.ru.md +43 -14
- package/docs/acceptance.md +116 -3
- package/docs/api.md +12 -6
- package/docs/architecture.md +22 -7
- package/docs/benchmarks.md +10 -0
- package/docs/categorical-presence-port.md +26 -0
- package/docs/evidence/v02/baseline.json +1043 -0
- package/docs/evidence/v02/boundary-variants.md +17 -0
- package/docs/evidence/v02/box-confirmation-dev40/README.md +15 -0
- package/docs/evidence/v02/box-confirmation-dev40/component-refinement.json +246 -0
- package/docs/evidence/v02/box-confirmation-dev40/evaluation.json +1663 -0
- package/docs/evidence/v02/box-confirmation-dev40/provenance.json +130 -0
- package/docs/evidence/v02/box-confirmation-dev40/report.json +127 -0
- package/docs/evidence/v02/box-confirmation-dev40-freeze-20261020-v1.json +230 -0
- package/docs/evidence/v02/box-confirmation-method-selection-20261020-v1.json +85 -0
- package/docs/evidence/v02/box-heldout-cancelled-before-dispatch-20261021-v1.json +32 -0
- package/docs/evidence/v02/box-heldout-combined-seal-20261021-v1.json +89 -0
- package/docs/evidence/v02/box-heldout-evaluator-truth-seal-20261021-v1.json +61 -0
- package/docs/evidence/v02/box-heldout-exclusion-audit-20261020-v1.json +81 -0
- package/docs/evidence/v02/box-heldout-map-seal-20261021-v1.json +48 -0
- package/docs/evidence/v02/box-heldout-photo-seal-20261020-v1.json +62 -0
- package/docs/evidence/v02/box-heldout-run-freeze-20261021-v1.json +61 -0
- package/docs/evidence/v02/box-heldout-source-review-20261020-v1.json +134 -0
- package/docs/evidence/v02/box-heldout-ui-seal-20261020-v1.json +44 -0
- package/docs/evidence/v02/calculator-proof-root-review-20261020-v1.json +63 -0
- package/docs/evidence/v02/categorical-dev40-freeze.json +94 -0
- package/docs/evidence/v02/categorical-dev40-preserve.json +460 -0
- package/docs/evidence/v02/categorical-dev40-target-only.json +460 -0
- package/docs/evidence/v02/categorical-heldout-admission-20261020-v3.json +215 -0
- package/docs/evidence/v02/categorical-heldout-admission-20261020-v4.json +270 -0
- package/docs/evidence/v02/categorical-heldout-dispatch-authorization-20261020-v4.json +79 -0
- package/docs/evidence/v02/categorical-heldout-predispatch-20261020-v3.json +57 -0
- package/docs/evidence/v02/categorical-heldout-producer-source-map-v4.json +262 -0
- package/docs/evidence/v02/categorical-heldout-producer-source-map.json +263 -0
- package/docs/evidence/v02/categorical-heldout-run-freeze-20261020-v3.json +35 -0
- package/docs/evidence/v02/categorical-heldout-run-freeze-20261020-v4.json +35 -0
- package/docs/evidence/v02/categorical-heldout-v4/candidate-evaluation.json +2812 -0
- package/docs/evidence/v02/categorical-heldout-v4/candidate-physical-receipts.json +15261 -0
- package/docs/evidence/v02/categorical-heldout-v4/candidate-provenance.json +131 -0
- package/docs/evidence/v02/categorical-heldout-v4/control-evaluation.json +855 -0
- package/docs/evidence/v02/categorical-heldout-v4/control-physical-receipts.json +4402 -0
- package/docs/evidence/v02/categorical-heldout-v4/control-provenance.json +31 -0
- package/docs/evidence/v02/categorical-heldout-v4/mask-normalized-exploratory.json +682 -0
- package/docs/evidence/v02/categorical-heldout-v4/paired-qualification.json +21 -0
- package/docs/evidence/v02/categorical-heldout-v4/report.json +258 -0
- package/docs/evidence/v02/categorical-presence-dev6.json +144 -0
- package/docs/evidence/v02/categorical-presence-dev6.md +18 -0
- package/docs/evidence/v02/categorical-vision-method-selection.json +90 -0
- package/docs/evidence/v02/checked-region-component-v1/README.md +7 -0
- package/docs/evidence/v02/checked-region-component-v1/evidence.json +311 -0
- package/docs/evidence/v02/checked-region-resource-interrupted-2b0d09f.json +102 -0
- package/docs/evidence/v02/checked-region-segmentation-resource-4df544c-receipt.json +167 -0
- package/docs/evidence/v02/checked-region-segmentation-resource-4df544c-root-review.json +58 -0
- package/docs/evidence/v02/checked-region-segmentation-resource-987ac32-receipt.json +158 -0
- package/docs/evidence/v02/ci-012b935.json +17 -0
- package/docs/evidence/v02/ci-0c365cb.json +372 -0
- package/docs/evidence/v02/ci-185bde8.json +32 -0
- package/docs/evidence/v02/ci-24f849f.json +95 -0
- package/docs/evidence/v02/ci-25c19cd.json +375 -0
- package/docs/evidence/v02/ci-2922caf.json +375 -0
- package/docs/evidence/v02/ci-29357d7.json +29 -0
- package/docs/evidence/v02/ci-32aa90d.json +24 -0
- package/docs/evidence/v02/ci-35e3064.json +376 -0
- package/docs/evidence/v02/ci-4331b1b.json +384 -0
- package/docs/evidence/v02/ci-43b7426.json +376 -0
- package/docs/evidence/v02/ci-450439c.json +373 -0
- package/docs/evidence/v02/ci-46283fe.json +29 -0
- package/docs/evidence/v02/ci-4c9c09f.json +34 -0
- package/docs/evidence/v02/ci-5579646.json +27 -0
- package/docs/evidence/v02/ci-6f9cc15.json +127 -0
- package/docs/evidence/v02/ci-7c1051f.json +27 -0
- package/docs/evidence/v02/ci-9837888.json +34 -0
- package/docs/evidence/v02/ci-987ac32.json +29 -0
- package/docs/evidence/v02/ci-9d00fe5.json +25 -0
- package/docs/evidence/v02/ci-9f85acc.json +127 -0
- package/docs/evidence/v02/ci-be275a6.json +201 -0
- package/docs/evidence/v02/ci-c107ddf.json +372 -0
- package/docs/evidence/v02/ci-c35f67d.json +127 -0
- package/docs/evidence/v02/ci-c5eddd8.json +32 -0
- package/docs/evidence/v02/ci-d2042e0.json +372 -0
- package/docs/evidence/v02/ci-d684259.json +375 -0
- package/docs/evidence/v02/ci-e0c190b.json +127 -0
- package/docs/evidence/v02/ci-e551253.json +372 -0
- package/docs/evidence/v02/ci-f9d4633.json +29 -0
- package/docs/evidence/v02/dev1-proposal-evaluation.md +13 -0
- package/docs/evidence/v02/dev2-mobile-sam-proposal-oracle.md +21 -0
- package/docs/evidence/v02/dev2-proposal-evaluation.md +21 -0
- package/docs/evidence/v02/fresh-development.md +16 -0
- package/docs/evidence/v02/fresh-native-numeric/artifact-hashes.json +9 -0
- package/docs/evidence/v02/fresh-native-numeric/evaluation-root-v1.json +568 -0
- package/docs/evidence/v02/fresh-native-numeric/run-manifest.json +342 -0
- package/docs/evidence/v02/fresh-native-numeric/summary.json +5654 -0
- package/docs/evidence/v02/fresh-native-outline-axis/artifact-hashes.json +9 -0
- package/docs/evidence/v02/fresh-native-outline-axis/evaluation-root-v1.json +568 -0
- package/docs/evidence/v02/fresh-native-outline-axis/run-manifest.json +378 -0
- package/docs/evidence/v02/fresh-native-outline-axis/summary.json +5605 -0
- package/docs/evidence/v02/fresh-text/README.md +23 -0
- package/docs/evidence/v02/fresh-text/ascii-contours-v1/classify-followup-run-manifest.json +405 -0
- package/docs/evidence/v02/fresh-text/ascii-contours-v1/classify-followup-summary.json +1646 -0
- package/docs/evidence/v02/fresh-text/ascii-contours-v1/evaluation.json +568 -0
- package/docs/evidence/v02/fresh-text/ascii-contours-v1/original-run-manifest.json +404 -0
- package/docs/evidence/v02/fresh-text/ascii-contours-v1/original-summary.json +4416 -0
- package/docs/evidence/v02/fresh-text/ascii-luma-v1/classify-followup-run-manifest.json +405 -0
- package/docs/evidence/v02/fresh-text/ascii-luma-v1/classify-followup-summary.json +1646 -0
- package/docs/evidence/v02/fresh-text/ascii-luma-v1/evaluation.json +568 -0
- package/docs/evidence/v02/fresh-text/ascii-luma-v1/original-run-manifest.json +404 -0
- package/docs/evidence/v02/fresh-text/ascii-luma-v1/original-summary.json +4647 -0
- package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/classify-followup-run-manifest.json +405 -0
- package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/classify-followup-summary.json +846 -0
- package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/evaluation.json +568 -0
- package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/original-run-manifest.json +404 -0
- package/docs/evidence/v02/fresh-text/ascii-svg-layered-v1/original-summary.json +1789 -0
- package/docs/evidence/v02/fresh-text/no-image-control/evaluation.json +568 -0
- package/docs/evidence/v02/fresh-text/no-image-control/original-run-manifest.json +404 -0
- package/docs/evidence/v02/fresh-text/no-image-control/original-summary.json +3953 -0
- package/docs/evidence/v02/fresh-text/palette-grid-v1/classify-followup-run-manifest.json +405 -0
- package/docs/evidence/v02/fresh-text/palette-grid-v1/classify-followup-summary.json +1646 -0
- package/docs/evidence/v02/fresh-text/palette-grid-v1/evaluation.json +568 -0
- package/docs/evidence/v02/fresh-text/palette-grid-v1/original-run-manifest.json +404 -0
- package/docs/evidence/v02/fresh-text/palette-grid-v1/original-summary.json +3974 -0
- package/docs/evidence/v02/fresh-text/pixel-rle-v1/classify-followup-run-manifest.json +405 -0
- package/docs/evidence/v02/fresh-text/pixel-rle-v1/classify-followup-summary.json +1646 -0
- package/docs/evidence/v02/fresh-text/pixel-rle-v1/evaluation.json +568 -0
- package/docs/evidence/v02/fresh-text/pixel-rle-v1/original-run-manifest.json +404 -0
- package/docs/evidence/v02/fresh-text/pixel-rle-v1/original-summary.json +4945 -0
- package/docs/evidence/v02/fresh-text/report.json +284 -0
- package/docs/evidence/v02/fresh-text/svg-contours-v1/classify-followup-run-manifest.json +405 -0
- package/docs/evidence/v02/fresh-text/svg-contours-v1/classify-followup-summary.json +846 -0
- package/docs/evidence/v02/fresh-text/svg-contours-v1/evaluation.json +568 -0
- package/docs/evidence/v02/fresh-text/svg-contours-v1/original-run-manifest.json +404 -0
- package/docs/evidence/v02/fresh-text/svg-contours-v1/original-summary.json +2189 -0
- package/docs/evidence/v02/heldout-evaluation-20261020.md +37 -0
- package/docs/evidence/v02/heldout-input-derivation.md +18 -0
- package/docs/evidence/v02/integration-0c365cb.json +90 -0
- package/docs/evidence/v02/integration-25c19cd.json +52 -0
- package/docs/evidence/v02/integration-35e3064.json +41 -0
- package/docs/evidence/v02/integration-4331b1b.json +42 -0
- package/docs/evidence/v02/integration-4c9c09f.json +46 -0
- package/docs/evidence/v02/integration-8010aad.json +48 -0
- package/docs/evidence/v02/integration-c1aa640.json +41 -0
- package/docs/evidence/v02/integration-eea1790.json +46 -0
- package/docs/evidence/v02/integration-fa82e65.json +42 -0
- package/docs/evidence/v02/jpeg-transport-offline.json +268 -0
- package/docs/evidence/v02/jpeg-transport-offline.md +7 -0
- package/docs/evidence/v02/local-archive-cleanup.json +59 -0
- package/docs/evidence/v02/native-base64-after.json +30 -0
- package/docs/evidence/v02/native-base64-before.json +32 -0
- package/docs/evidence/v02/native-checked-region-windows-46283fe.json +248 -0
- package/docs/evidence/v02/native-checked-region-windows-987ac32.json +141 -0
- package/docs/evidence/v02/native-grabcut-windows-4c494a3-run2.json +148 -0
- package/docs/evidence/v02/native-grabcut-windows-4c494a3-run3.json +148 -0
- package/docs/evidence/v02/native-grabcut-windows-4c494a3.json +56 -0
- package/docs/evidence/v02/native-proposal-windows-0c365cb.json +148 -0
- package/docs/evidence/v02/native-proposal-windows-450439c.json +156 -0
- package/docs/evidence/v02/native-proposal-windows-4c9c09f-retry1.json +147 -0
- package/docs/evidence/v02/native-proposal-windows-4c9c09f.json +52 -0
- package/docs/evidence/v02/native-region-windows-efc9318.json +163 -0
- package/docs/evidence/v02/native-windows-eea1790-baseline.json +198 -0
- package/docs/evidence/v02/native-windows-eea1790.json +228 -0
- package/docs/evidence/v02/ordinary-luna-axis/run-manifest.json +99 -0
- package/docs/evidence/v02/ordinary-luna-axis/summary.json +811 -0
- package/docs/evidence/v02/owned-temp-cleanup-20261020-v1.json +28 -0
- package/docs/evidence/v02/presentation-paired-20261020.json +1438 -0
- package/docs/evidence/v02/proposal-resource-soak-261dc23.json +201 -0
- package/docs/evidence/v02/proposal-resource-soak-450439c-receipt.md +13 -0
- package/docs/evidence/v02/reconstructed-c03-box.json +41 -0
- package/docs/evidence/v02/region-seeded-dev-v1/README.md +17 -0
- package/docs/evidence/v02/region-seeded-dev-v1/evaluation.json +260 -0
- package/docs/evidence/v02/region-seeded-dev-v2/README.md +15 -0
- package/docs/evidence/v02/region-seeded-dev-v2/evaluation.json +232 -0
- package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/README.md +9 -0
- package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/control-identity-failure.json +22 -0
- package/docs/evidence/v02/region-seeded-dev-v3-candidate-only/evaluation.json +160 -0
- package/docs/evidence/v02/region-seeded-dev-v3-control-r2/README.md +9 -0
- package/docs/evidence/v02/region-seeded-dev-v3-control-r2/attempt-accounting.json +55 -0
- package/docs/evidence/v02/region-seeded-dev-v3-control-r2/evaluation.json +136 -0
- package/docs/evidence/v02/region-seeded-development-control-r2-freeze-20261021.json +132 -0
- package/docs/evidence/v02/region-seeded-development-freeze-20261021-v1.json +167 -0
- package/docs/evidence/v02/region-seeded-development-freeze-20261021-v2.json +186 -0
- package/docs/evidence/v02/region-seeded-development-freeze-20261021-v3.json +205 -0
- package/docs/evidence/v02/region-seeded-heldout-cancelled-before-dispatch-20261021-v2.json +20 -0
- package/docs/evidence/v02/region-seeded-heldout-dispatch-authorization-20261021-v3.json +47 -0
- package/docs/evidence/v02/region-seeded-heldout-readiness-audit-20261021-v3.json +125 -0
- package/docs/evidence/v02/region-seeded-heldout-run-freeze-20261021-v2.json +234 -0
- package/docs/evidence/v02/region-seeded-heldout-run-freeze-20261021-v3.json +357 -0
- package/docs/evidence/v02/region-seeded-heldout-v3/README.md +19 -0
- package/docs/evidence/v02/region-seeded-heldout-v3/evaluation-summary.json +445 -0
- package/docs/evidence/v02/region-seeded-method-selection-20261021-v2.json +66 -0
- package/docs/evidence/v02/region-seeded-method-selection-20261021-v3.json +120 -0
- package/docs/evidence/v02/region-segmentation-resource-0ba4c87-receipt.json +156 -0
- package/docs/evidence/v02/resource-soak-linux-8010aad.json +125 -0
- package/docs/evidence/v02/screen-v2-terminal-evaluation.md +22 -0
- package/docs/evidence/v02/seed-outline/run-manifest.json +59 -0
- package/docs/evidence/v02/seed-outline/summary.json +487 -0
- package/docs/evidence/v02/seed-unbounded/run-manifest.json +80 -0
- package/docs/evidence/v02/seed-unbounded/summary.json +730 -0
- package/docs/evidence/v02/segmentation/README.md +21 -0
- package/docs/evidence/v02/segmentation/component-comparison-summary.json +240 -0
- package/docs/evidence/v02/segmentation/provenance/MOBILE-SAM-LICENSE.txt +201 -0
- package/docs/evidence/v02/segmentation/provenance/OPENCV-LICENSE.txt +202 -0
- package/docs/evidence/v02/segmentation/provenance/mobile-sam-download-receipt.json +29 -0
- package/docs/evidence/v02/segmentation/provenance/mobile-sam-graph-audit.json +214 -0
- package/docs/evidence/v02/segmentation/provenance/mobile-sam-model-metadata.json +166 -0
- package/docs/evidence/v02/split-choice-noul-dev6.json +72 -0
- package/docs/evidence/v02/split-choice-noul-dev6.md +11 -0
- package/docs/evidence/v02/supported-vision-screen-20261020.md +65 -0
- package/docs/evidence/v02/wesnoth-1.16.11-minimap-projection-source-audit.md +56 -0
- package/docs/evidence/v02/wesnoth-proof-root-review-20261020-v1.json +76 -0
- package/docs/operations.md +8 -2
- package/docs/plan.md +2 -0
- package/docs/publishing.md +16 -1
- package/docs/research/text-transport-audit.md +66 -0
- package/docs/v02-usage.md +164 -0
- package/docs/vision-results.md +31 -2
- 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
|
|
7
|
-
if (command === '
|
|
8
|
-
console.log('zorya-classifier classify-text <text> <classes.json>\nzorya-classifier classify-image <image> <classes.json>\nzorya-classifier locate <image> <target
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
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 {};
|