omnius 1.0.842 → 1.0.845

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 (42) hide show
  1. package/dist/api/py-embed.js +651 -91
  2. package/dist/computer-use/models.lock.yaml +495 -0
  3. package/dist/index.js +2 -2
  4. package/dist/library.d.ts +1 -0
  5. package/dist/library.js +176498 -55325
  6. package/dist/scripts/rapid-computer-use/gpu_lease.py +64 -0
  7. package/dist/scripts/rapid-computer-use/laya_service.py +483 -0
  8. package/dist/scripts/rapid-computer-use/model_gate.py +755 -0
  9. package/dist/scripts/rapid-computer-use/photon_service.py +700 -0
  10. package/dist/scripts/rapid-computer-use/point_benchmark.py +278 -0
  11. package/dist/update-worker.js +651 -91
  12. package/docs/DISCOVERY.json +1781 -808
  13. package/docs/DISCOVERY.md +25 -0
  14. package/docs/guides/bring-your-own-inference.md +128 -0
  15. package/docs/reference/slash-commands.md +138 -22
  16. package/docs/work-orders/WO-active-inference-route-and-telegram-review-20261012.md +94 -0
  17. package/docs/work-orders/WO-inference-fallback-20261012.md +89 -0
  18. package/docs/work-orders/WO-primary-checkout-fallback-delivery-20261012.md +94 -0
  19. package/docs/work-orders/WO-telegram-fallback-20261012.md +83 -0
  20. package/docs/work-orders/active-inference-route-remote-probes-20261012.json +34 -0
  21. package/docs/work-orders/inference-fallback-bundle-20261012.json +75 -0
  22. package/docs/work-orders/inference-fallback-live-20261012.json +39 -0
  23. package/docs/work-orders/primary-inference-fallback-bundle-20261012.json +88 -0
  24. package/docs/work-orders/rapid-computer-use-20261011/README.md +125 -0
  25. package/docs/work-orders/rapid-computer-use-20261011/WO-01-native-save-recovery.md +86 -0
  26. package/docs/work-orders/rapid-computer-use-20261011/WO-02-semantic-control.md +93 -0
  27. package/docs/work-orders/rapid-computer-use-20261011/WO-03-policy-workflows.md +130 -0
  28. package/docs/work-orders/rapid-computer-use-20261011/WO-04-live-model-gates.md +322 -0
  29. package/docs/work-orders/rapid-computer-use-20261011/WO-05-verification-delivery.md +389 -0
  30. package/docs/work-orders/rapid-computer-use-20261011/WO-06-medium-horizon-runtime.md +166 -0
  31. package/docs/work-orders/rapid-computer-use-20261011/WO-07-tool-routing-prompts.md +81 -0
  32. package/docs/work-orders/rapid-computer-use-20261011/WO-08-cross-application-desktop.md +214 -0
  33. package/docs/work-orders/rapid-computer-use-20261011/architecture-source.md +871 -0
  34. package/docs/work-orders/telegram-progress-browser-20261011/README.md +79 -0
  35. package/docs/work-orders/telegram-progress-browser-20261011/WO-01-diagnostic-visibility.md +64 -0
  36. package/docs/work-orders/telegram-progress-browser-20261011/WO-02-task-narration.md +127 -0
  37. package/docs/work-orders/telegram-progress-browser-20261011/WO-03-browser-observation.md +51 -0
  38. package/docs/work-orders/telegram-progress-browser-20261011/WO-04-download-desktop-handoff.md +96 -0
  39. package/docs/work-orders/telegram-progress-browser-20261011/WO-05-verification-delivery.md +129 -0
  40. package/npm-shrinkwrap.json +2 -2
  41. package/package.json +1 -1
  42. package/prompts/agentic/system-common.md +7 -0
@@ -0,0 +1,278 @@
1
+ #!/usr/bin/env python3
2
+ """Evaluate twenty local PNG captures against an already resident /v1/point service.
3
+
4
+ Does not import a model SDK, load weights, capture a live desktop, or click. The
5
+ caller supplies frozen images and annotations; every request uses model_gate's
6
+ fresh hardware and short-lived statement gate. HTTP shape follows Moondream's
7
+ published point API; a compatible local Photon service must be provisioned
8
+ separately with its exact pinned runtime identity and broker lease.
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import argparse
13
+ import base64
14
+ import hashlib
15
+ import math
16
+ from pathlib import Path
17
+ import struct
18
+ import sys
19
+ import time
20
+
21
+ import model_gate as gate
22
+
23
+ MAX_IMAGE_BYTES = 20 * 1024 * 1024
24
+
25
+
26
+ def number(value):
27
+ return isinstance(value, (int, float)) and not isinstance(value, bool) and math.isfinite(value)
28
+
29
+
30
+ def rectangle(value, name):
31
+ gate.require(isinstance(value, dict) and all(number(value.get(key)) for key in ("x", "y", "width", "height"))
32
+ and value["width"] > 0 and value["height"] > 0, f"invalid {name} rectangle")
33
+ return value
34
+
35
+
36
+ def inside(point, bounds):
37
+ return bounds["x"] <= point["x"] < bounds["x"] + bounds["width"] and \
38
+ bounds["y"] <= point["y"] < bounds["y"] + bounds["height"]
39
+
40
+
41
+ def contains(outer, inner):
42
+ return inner["x"] >= outer["x"] and inner["y"] >= outer["y"] and \
43
+ inner["x"] + inner["width"] <= outer["x"] + outer["width"] and \
44
+ inner["y"] + inner["height"] <= outer["y"] + outer["height"]
45
+
46
+
47
+ def png_dimensions(raw):
48
+ gate.require(len(raw) >= 33 and raw[:8] == b"\x89PNG\r\n\x1a\n" and
49
+ raw[8:12] == b"\x00\x00\x00\r" and raw[12:16] == b"IHDR", "capture is not a PNG")
50
+ width, height = struct.unpack(">II", raw[16:24])
51
+ gate.require(0 < width <= 16384 and 0 < height <= 16384, "PNG dimensions exceed bounds")
52
+ return width, height
53
+
54
+
55
+ def capture_bytes(corpus_path, capture):
56
+ root = Path(corpus_path).resolve().parent
57
+ relative = Path(capture.get("file", ""))
58
+ gate.require(not relative.is_absolute() and relative.suffix.lower() == ".png", "relative PNG path required")
59
+ path = (root / relative).resolve()
60
+ gate.require(path.is_relative_to(root), "capture path escapes corpus directory")
61
+ with path.open("rb") as stream:
62
+ raw = stream.read(MAX_IMAGE_BYTES + 1)
63
+ gate.require(0 < len(raw) <= MAX_IMAGE_BYTES, "capture exceeds bounded image size")
64
+ gate.require(hashlib.sha256(raw).hexdigest() == capture.get("sha256"), "capture bytes changed since annotation")
65
+ width, height = png_dimensions(raw)
66
+ transform = capture.get("transform", {})
67
+ gate.require(transform.get("image", {}).get("width") == width and
68
+ transform.get("image", {}).get("height") == height, "PNG dimensions differ from image transform")
69
+ return raw
70
+
71
+
72
+ def verify_annotation(corpus_path, capture):
73
+ root = Path(corpus_path).resolve().parent
74
+ relative = Path(capture.get("annotation_receipt", ""))
75
+ gate.require(not relative.is_absolute() and relative.suffix == ".json", "relative annotation receipt required")
76
+ path = (root / relative).resolve()
77
+ gate.require(path.is_relative_to(root), "annotation path escapes corpus directory")
78
+ with path.open("rb") as stream:
79
+ raw = stream.read(gate.MAX_JSON_BYTES + 1)
80
+ gate.require(len(raw) <= gate.MAX_JSON_BYTES and
81
+ hashlib.sha256(raw).hexdigest() == capture.get("annotation_receipt_sha256"),
82
+ "host annotation receipt hash mismatch")
83
+ receipt = gate.strict_json(raw)
84
+ gate.require(receipt.get("schema") == "omnius.computer-use.capture-annotation.v1" and
85
+ receipt.get("source") in ("playwright-dom", "native-accessibility"),
86
+ "annotation must come from a host semantic observer")
87
+ for key, source in (("capture_id", "id"), ("capture_sha256", "sha256"),
88
+ ("capture_revision", "capture_revision"), ("window_id", "window_id"),
89
+ ("target_bounds", "target_bounds"), ("transform", "transform")):
90
+ gate.require(receipt.get(key) == capture.get(source), f"annotation does not match capture: {key}")
91
+
92
+
93
+ def validate_transform(capture):
94
+ transform = capture.get("transform", {})
95
+ gate.require(bool(capture.get("capture_revision")) and
96
+ transform.get("revision") == capture["capture_revision"], "capture revision mismatch")
97
+ gate.require(bool(capture.get("window_id")) and transform.get("windowId") == capture["window_id"],
98
+ "capture window identity mismatch")
99
+ dimensions = transform.get("capture", {})
100
+ gate.require(dimensions.get("x", 0) == 0 and dimensions.get("y", 0) == 0,
101
+ "capture origin must be zero; use crop/input offsets for translation")
102
+ full = rectangle({"x": 0, "y": 0, **dimensions}, "capture")
103
+ image = rectangle({"x": 0, "y": 0, "width": transform.get("image", {}).get("width"),
104
+ "height": transform.get("image", {}).get("height")}, "image")
105
+ crop = rectangle(transform.get("crop", full), "crop")
106
+ content = rectangle(transform.get("image", {}).get("content", image), "image content")
107
+ output = rectangle(transform.get("input"), "input")
108
+ target = rectangle(capture.get("target_bounds"), "annotated target")
109
+ gate.require(contains(full, crop) and contains(image, content) and contains(output, target),
110
+ "crop, content, or target exceeds its containing rectangle")
111
+ gate.require(output.get("space") in ("device-pixel", "screen-logical", "css-viewport"),
112
+ "input coordinate space must be explicit")
113
+ return full, image, crop, content, output, target
114
+
115
+
116
+ def map_point(point, capture):
117
+ full, image, crop, content, output, _ = validate_transform(capture)
118
+ gate.require(isinstance(point, dict) and number(point.get("x")) and number(point.get("y"))
119
+ and 0 <= point["x"] < 1 and 0 <= point["y"] < 1, "point must be normalized in [0,1)")
120
+ pixel = {"x": point["x"] * image["width"], "y": point["y"] * image["height"]}
121
+ gate.require(inside(pixel, content), "point lies in letterbox padding")
122
+ original_x = crop["x"] + (pixel["x"] - content["x"]) * crop["width"] / content["width"]
123
+ original_y = crop["y"] + (pixel["y"] - content["y"]) * crop["height"] / content["height"]
124
+ mapped = {"x": output["x"] + original_x * output["width"] / full["width"],
125
+ "y": output["y"] + original_y * output["height"] / full["height"]}
126
+ gate.require(inside(mapped, output), "mapped point is outside the input surface")
127
+ return mapped
128
+
129
+
130
+ def load_capture_corpus_hashed(path):
131
+ corpus, sha = gate.read_json_hashed(path)
132
+ gate.require(corpus.get("schema") == "omnius.computer-use.capture-corpus.v1", "unsupported capture corpus")
133
+ gate.require(corpus.get("source") in ("local_capture", "synthetic_fixture"), "capture provenance required")
134
+ captures = corpus.get("captures")
135
+ gate.require(isinstance(captures, list) and 20 <= len(captures) <= 200,
136
+ "twenty to two hundred annotated local captures are required")
137
+ gate.require(len({item.get("id") for item in captures}) == len(captures), "duplicate capture ID")
138
+ gate.require(len({item.get("sha256") for item in captures}) == len(captures), "twenty distinct image hashes required")
139
+ for capture in captures:
140
+ gate.require(isinstance(capture.get("id"), str) and bool(capture["id"]), "capture ID required")
141
+ gate.require(isinstance(capture.get("query"), str) and 0 < len(capture["query"]) <= 1000,
142
+ "bounded target query required")
143
+ gate.require(capture.get("annotation_source") in ("human", "fixture_expected_bounds", "host_semantic_receipt"),
144
+ "target bounds require independent annotation")
145
+ if corpus["source"] == "local_capture":
146
+ gate.require(capture["annotation_source"] in ("human", "host_semantic_receipt"),
147
+ "local captures require independent human or host semantic bounds")
148
+ if capture["annotation_source"] == "host_semantic_receipt":
149
+ gate.require(gate.re.fullmatch(r"[a-f0-9]{64}", capture.get("annotation_receipt_sha256", "")) is not None,
150
+ "semantic bounds require their host receipt hash")
151
+ verify_annotation(path, capture)
152
+ validate_transform(capture)
153
+ capture_bytes(path, capture)
154
+ return corpus, sha
155
+
156
+
157
+ def load_capture_corpus(path):
158
+ return load_capture_corpus_hashed(path)[0]
159
+
160
+
161
+ def point_request(selection, corpus_path, capture):
162
+ raw = capture_bytes(corpus_path, capture)
163
+ return {"model": selection["model"], "object": capture["query"],
164
+ "image_url": "data:image/png;base64," + base64.b64encode(raw).decode("ascii")}
165
+
166
+
167
+ def point_answer(response, capture):
168
+ gate.require(isinstance(response, dict) and isinstance(response.get("points"), list)
169
+ and len(response["points"]) <= 100, "invalid bounded point response")
170
+ points = response["points"]
171
+ for point in points:
172
+ gate.require(isinstance(point, dict) and number(point.get("x")) and number(point.get("y"))
173
+ and 0 <= point["x"] < 1 and 0 <= point["y"] < 1, "non-normalized point response")
174
+ if len(points) != 1:
175
+ return {"status": "abstained", "hit": False, "reason": "missing or ambiguous target points"}
176
+ mapped = map_point(points[0], capture)
177
+ return {"status": "ok", "point": points[0], "mapped_point": mapped,
178
+ "hit": inside(mapped, capture["target_bounds"])}
179
+
180
+
181
+ def point_metrics(rows, source):
182
+ gate.require(source in ("live_model", "synthetic_fixture_replay"), "measurement provenance required")
183
+ quality = {"target_hit_rate_including_errors": sum(row.get("hit") is True for row in rows) / len(rows)
184
+ if rows else None, "ambiguous_or_missing_count": sum(row["status"] == "abstained" for row in rows),
185
+ "error_count": sum(row["status"] == "error" for row in rows)}
186
+ return {"measurement_kind": source, "count": len(rows),
187
+ "model_grounding_metrics": quality if source == "live_model" else None,
188
+ "fixture_contract_metrics": quality if source == "synthetic_fixture_replay" else None,
189
+ "stage_latency_ms": {"ground": gate.quantiles([row["latency_ms"] for row in rows])},
190
+ "clicks_performed": 0, "task_completion_claimed": False, "peak_vram_mib": None,
191
+ "cold_start_measured": False}
192
+
193
+
194
+ def run_capture_benchmark(selection, lock, receipt, approval, corpus_path, corpus,
195
+ collector=gate.collect_snapshot, sender=gate.local_json,
196
+ clock=time.time, timer=time.perf_counter, checkpoint=None):
197
+ gate.require(selection.get("protocol") == "moondream-point", "point protocol required")
198
+ gate.require(corpus.get("source") in ("local_capture", "synthetic_fixture"),
199
+ "live grounding requires declared local capture provenance")
200
+ rows = []
201
+ for capture in corpus["captures"]:
202
+ request = point_request(selection, corpus_path, capture)
203
+ try:
204
+ preflight = gate.verify_preflight(selection, lock, receipt, collector(selection, receipt), clock())
205
+ gate.verify_approval(approval, preflight, clock())
206
+ except gate.GateError as error:
207
+ error.partial_rows = rows
208
+ raise
209
+ started = timer()
210
+ row = {"capture_id": capture["id"], "capture_sha256": capture["sha256"]}
211
+ try:
212
+ row.update(point_answer(sender(selection["endpoint"], request, timeout=60), capture))
213
+ except gate.GateError as error:
214
+ row.update(status="error", hit=False, reason=str(error))
215
+ row["latency_ms"] = (timer() - started) * 1000
216
+ rows.append(row)
217
+ if checkpoint:
218
+ checkpoint(rows)
219
+ return rows
220
+
221
+
222
+ def main(argv=None):
223
+ parser = argparse.ArgumentParser(description=__doc__)
224
+ parser.add_argument("command", choices=("check-corpus", "benchmark"))
225
+ parser.add_argument("--corpus", required=True, type=Path)
226
+ parser.add_argument("--output", type=Path)
227
+ parser.add_argument("--selection", type=Path)
228
+ parser.add_argument("--runtime-receipt", type=Path)
229
+ parser.add_argument("--approval", type=Path)
230
+ parser.add_argument("--lock", type=Path, default=gate.DEFAULT_LOCK)
231
+ args = parser.parse_args(argv)
232
+ attempted = False
233
+ try:
234
+ corpus, corpus_sha = load_capture_corpus_hashed(args.corpus)
235
+ if args.command == "check-corpus":
236
+ print(gate.json.dumps({"status": "valid", "count": len(corpus["captures"]),
237
+ "corpus_sha256": corpus_sha, "model_inference_performed": False}))
238
+ return 0
239
+ gate.require(all((args.output, args.selection, args.runtime_receipt, args.approval)),
240
+ "benchmark requires selection, runtime receipt, approval, and output")
241
+ selection = gate.read_json(args.selection)
242
+ lock, lock_sha = gate.read_json_hashed(args.lock)
243
+ gate.verify_corpus_lock(lock, corpus_sha, point=True)
244
+ receipt, approval = gate.read_json(args.runtime_receipt), gate.read_json(args.approval)
245
+ gate.validate_selection(selection, lock)
246
+ gate.write_json(args.output, {"schema": "omnius.computer-use.point-report.v1", "status": "in_progress",
247
+ "selection": selection, "corpus_sha256": corpus_sha, "rows": []})
248
+ def checkpoint(rows):
249
+ gate.write_json(args.output, {"schema": "omnius.computer-use.point-report.v1",
250
+ "status": "in_progress", "selection": selection,
251
+ "corpus_sha256": corpus_sha, "rows": rows})
252
+ attempted = True
253
+ rows = run_capture_benchmark(selection, lock, receipt, approval, args.corpus, corpus,
254
+ checkpoint=checkpoint)
255
+ result = {"schema": "omnius.computer-use.point-report.v1", "status": "completed",
256
+ "selection": selection, "corpus_sha256": corpus_sha, "rows": rows,
257
+ "corpus_source": corpus["source"],
258
+ "corpus_kind": corpus.get("corpus_kind", "operator_supplied_local_captures"),
259
+ "limitations": ["Actual model predictions on the declared capture corpus only; synthetic UI inputs do not establish real-application accuracy."],
260
+ "models_lock_sha256": lock_sha,
261
+ **point_metrics(rows, "live_model")}
262
+ if any(row["status"] == "error" for row in rows):
263
+ result["status"] = "completed_with_errors"
264
+ gate.write_json(args.output, result)
265
+ print(gate.json.dumps({"status": result["status"], "artifact": str(args.output)}))
266
+ return 3 if result["status"] == "completed_with_errors" else 0
267
+ except (gate.GateError, OSError, KeyError, TypeError) as error:
268
+ failure = {"schema": "omnius.computer-use.gate-failure.v1", "status": "blocked", "reason": str(error),
269
+ "inference_status": "possibly_started" if attempted else "not_attempted",
270
+ "partial_rows": getattr(error, "partial_rows", [])}
271
+ if args.output:
272
+ gate.write_json(args.output, failure)
273
+ print(gate.json.dumps(failure), file=sys.stderr)
274
+ return 2
275
+
276
+
277
+ if __name__ == "__main__":
278
+ raise SystemExit(main())