vis-agent 0.1.43__py3-none-any.whl

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 (39) hide show
  1. blockether/vis/__init__.py +6 -0
  2. blockether/vis/_contracts.py +142 -0
  3. blockether/vis/_data/activity.json +50 -0
  4. blockether/vis/_data/config.json +64 -0
  5. blockether/vis/_data/content.json +50 -0
  6. blockether/vis/_data/fixtures/activity-cases.json +2008 -0
  7. blockether/vis/_data/fixtures/activity.json +53 -0
  8. blockether/vis/_data/fixtures/view.json +79 -0
  9. blockether/vis/_data/gateway.json +1331 -0
  10. blockether/vis/_data/provider.json +51 -0
  11. blockether/vis/_data/python-host.json +137 -0
  12. blockether/vis/_data/schema/activity.json +935 -0
  13. blockether/vis/_data/schema/common.json +43 -0
  14. blockether/vis/_data/schema/config.json +1264 -0
  15. blockether/vis/_data/schema/content.json +444 -0
  16. blockether/vis/_data/schema/gateway.json +509 -0
  17. blockether/vis/_data/schema/provider.json +254 -0
  18. blockether/vis/_data/schema/python-host.json +126 -0
  19. blockether/vis/_data/schema/surface.json +484 -0
  20. blockether/vis/_data/schema/test-runner.json +193 -0
  21. blockether/vis/_data/schema/toggle.json +126 -0
  22. blockether/vis/_data/schema/view.json +2513 -0
  23. blockether/vis/_data/surface.json +8 -0
  24. blockether/vis/_data/test-runner.json +23 -0
  25. blockether/vis/_data/toggle.json +30 -0
  26. blockether/vis/_data/view.json +119 -0
  27. blockether/vis/_outside.py +1099 -0
  28. blockether/vis/_wire.py +28 -0
  29. blockether/vis/activity.py +185 -0
  30. blockether/vis/engine/__init__.py +41 -0
  31. blockether/vis/engine/_client.py +2420 -0
  32. blockether/vis/engine/_local.py +258 -0
  33. blockether/vis/extension.py +3018 -0
  34. blockether/vis/py.typed +0 -0
  35. blockether/vis/views.py +154 -0
  36. vis_agent-0.1.43.dist-info/METADATA +380 -0
  37. vis_agent-0.1.43.dist-info/RECORD +39 -0
  38. vis_agent-0.1.43.dist-info/WHEEL +4 -0
  39. vis_agent-0.1.43.dist-info/licenses/LICENSE +190 -0
@@ -0,0 +1,6 @@
1
+ """Vis SDK: extension authoring and explicit engine clients.
2
+
3
+ Import ``blockether.vis.extension`` to author an extension, or
4
+ ``blockether.vis.engine`` to control an engine. Importing this package performs
5
+ no host initialization, registration, process startup or gateway connection.
6
+ """
@@ -0,0 +1,142 @@
1
+ """Private reader and validator for the canonical, language-neutral Vis documents."""
2
+
3
+ import json
4
+ from functools import lru_cache
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ _DATA = Path(__file__).with_name("_data")
9
+ if not _DATA.is_dir():
10
+ _DATA = Path(__file__).resolve().parents[4] / "vis-contract/resources/vis-contract"
11
+
12
+
13
+ def _load_document(name):
14
+ return json.loads((_DATA / f"{name}.json").read_text(encoding="utf-8"))
15
+
16
+
17
+ _DOCUMENT_NAMES = (
18
+ "activity",
19
+ "gateway",
20
+ "view",
21
+ "content",
22
+ "config",
23
+ "toggle",
24
+ "provider",
25
+ "surface",
26
+ "test-runner",
27
+ )
28
+ _SCHEMA_NAMES = (*_DOCUMENT_NAMES, "python-host", "common")
29
+
30
+ _host = _load_document("python-host")
31
+ CONTRACT = {
32
+ "version": _host["version"],
33
+ "ops": _host["ops"],
34
+ "shell": _host["shell"],
35
+ "live": _host["live"],
36
+ **{name.replace("-", "_"): _load_document(name) for name in _DOCUMENT_NAMES},
37
+ }
38
+ """All canonical contract documents, keyed as the public Python API expects."""
39
+
40
+ ACTIVITY = CONTRACT["activity"]
41
+ """Host-owned tool lifecycle evidence, closed vocabulary, and presentation limits."""
42
+
43
+ GATEWAY = CONTRACT["gateway"]
44
+ """Canonical routes, headers, events, envelopes and replay semantics."""
45
+
46
+ VERSION = CONTRACT["version"]
47
+ """Bumped whenever an op is added, removed or re-shaped."""
48
+
49
+ OPS = {entry["name"]: entry for entry in CONTRACT["ops"]}
50
+ """Every declared op by name, in document order."""
51
+
52
+ SHELL = CONTRACT["shell"]
53
+ """The `shell` verb's lifecycle grammar: `default_op`, `handle_ops`, `spawn_ops`."""
54
+
55
+ LIVE = CONTRACT["live"]
56
+ """The `live` operation vocabulary and flush interval."""
57
+
58
+ VIEW = CONTRACT["view"]
59
+ """The closed View vocabulary — lifecycle kinds, semantic nodes and their bounds."""
60
+
61
+ CONTENT = CONTRACT["content"]
62
+ """Canonical content vocabulary."""
63
+
64
+ CONFIG = CONTRACT["config"]
65
+ """Canonical configuration vocabulary."""
66
+
67
+ TOGGLE = CONTRACT["toggle"]
68
+ """Canonical toggle vocabulary."""
69
+
70
+ PROVIDER = CONTRACT["provider"]
71
+ """Canonical provider-limits vocabulary."""
72
+
73
+ SURFACE = CONTRACT["surface"]
74
+ """Canonical language-surface vocabulary."""
75
+
76
+ TEST_RUNNER = CONTRACT["test_runner"]
77
+ """Canonical test-runner vocabulary."""
78
+
79
+
80
+ def schema(name: str) -> dict[str, Any]:
81
+ """Read the shipped JSON Schema; never retrieve schemas from the network."""
82
+ if name not in _SCHEMA_NAMES:
83
+ raise ValueError("unknown contract document")
84
+ return _load_document("schema/" + name)
85
+
86
+
87
+ @lru_cache(maxsize=64)
88
+ def _validator(name: str, definition: str):
89
+ from jsonschema import Draft202012Validator, FormatChecker
90
+ from referencing import Registry, Resource
91
+
92
+ source = schema(name)
93
+ if definition not in source.get("$defs", {}):
94
+ raise ValueError("unknown contract definition")
95
+ registry = Registry().with_resources(
96
+ (document["$id"], Resource.from_contents(document))
97
+ for document in (schema(name) for name in _SCHEMA_NAMES)
98
+ )
99
+ target = {key: source[key] for key in ("$schema", "$id", "$defs")}
100
+ target["$ref"] = "#/$defs/" + definition
101
+ return Draft202012Validator(
102
+ target, registry=registry, format_checker=FormatChecker()
103
+ )
104
+
105
+
106
+ def _json_value(item):
107
+ import math
108
+
109
+ if item is None or type(item) in (str, bool, int):
110
+ return True
111
+ if type(item) is float:
112
+ return math.isfinite(item)
113
+ if type(item) is list:
114
+ return all(_json_value(child) for child in item)
115
+ return type(item) is dict and all(
116
+ type(k) is str and _json_value(v) for k, v in item.items()
117
+ )
118
+
119
+
120
+ def validate(name: str, definition: str, value: Any) -> Any:
121
+ """Validate portable JSON data, returning it or raising a payload-free ValueError.
122
+
123
+ Schemas resolve only from the installed package. Runtime lifecycle, IO and
124
+ authorization belong to the engine, not JSON Schema.
125
+ """
126
+ try:
127
+ valid = _json_value(value) and _validator(name, definition).is_valid(value)
128
+ except (RecursionError, TypeError, ValueError):
129
+ valid = False
130
+ if not valid:
131
+ raise ValueError(f"invalid {name}.{definition} contract")
132
+ return value
133
+
134
+
135
+ def op(name):
136
+ """The declared op called `name`, or None."""
137
+ return OPS.get(name)
138
+
139
+
140
+ def refusal(name):
141
+ """The refusal message for an op unavailable outside Vis, if any."""
142
+ return OPS.get(name, {}).get("refusal")
@@ -0,0 +1,50 @@
1
+ {
2
+ "version": 1,
3
+ "event": "block.activity",
4
+ "presenters": [
5
+ "generic",
6
+ "shell",
7
+ "tests",
8
+ "patch",
9
+ "observation",
10
+ "lint",
11
+ "repl",
12
+ "format",
13
+ "list"
14
+ ],
15
+ "signals": [
16
+ "generic",
17
+ "observation",
18
+ "mutation",
19
+ "verification"
20
+ ],
21
+ "states": [
22
+ "idle",
23
+ "running",
24
+ "succeeded",
25
+ "failed",
26
+ "cancelled"
27
+ ],
28
+ "text_formats": [
29
+ "inline",
30
+ "markdown"
31
+ ],
32
+ "limits": {
33
+ "max_rows": 128,
34
+ "max_depth": 2,
35
+ "max_resources": 8,
36
+ "max_receipt_bytes": 65536,
37
+ "max_summary_bytes": 512,
38
+ "max_detail_bytes": 2048,
39
+ "max_event_bytes": 262144,
40
+ "max_diff_line_bytes": 512
41
+ },
42
+ "semantics": {
43
+ "ownership": "A projection belongs to its containing form. Only the event envelope carries session, turn, iteration and form_index. Activity is not a View and never enters model context.",
44
+ "delivery": "Each block.activity is a complete replacement, not a delta. Envelope seq orders revisions. Reconnect replays the latest replacement; settled evidence is durable.",
45
+ "lifecycle": "The engine allocates invocation identity and entry sequence, records running before execution, and exactly one succeeded, failed or cancelled result. Presentation cannot control the operation.",
46
+ "counts": "Counts describe observed invocations, including omitted rows. Group rows are presentation, not additional invocations. omitted.by_classification counts omitted evidence by signal.",
47
+ "bounds": "Redact credential-bearing structured fields before summarizing; enforce UTF-8 byte limits. Row ids are globally unique within a projection. At most max_rows top-level rows and max_depth child edges. Omission is explicit, never invented success.",
48
+ "declaration": "Symbols publish a presentation: headline, one-line summary, content blocks and optional sections of the same headline/summary/content shape. Headline and summary remain visible when collapsed; only content is disclosed. Up to 8 sections, 32 blocks in total and 32 KiB per replacement; each headline and summary is at most 512 UTF-8 bytes. Content includes headings, Markdown, tables, code, diffs, attachment references and progress. The engine alone owns identity, timing and outcome; presentation failures never alter tool results."
49
+ }
50
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "api_style_values": [
3
+ "anthropic",
4
+ "openai",
5
+ "openai-responses",
6
+ "gemini"
7
+ ],
8
+ "api_style_aliases": {
9
+ "anthropic": "anthropic",
10
+ "anthropic-messages": "anthropic",
11
+ "anthropic_messages": "anthropic",
12
+ "claude": "anthropic",
13
+ "messages": "anthropic",
14
+ "openai": "openai-compatible-chat",
15
+ "openai-chat": "openai-compatible-chat",
16
+ "openai_chat": "openai-compatible-chat",
17
+ "openai-compatible": "openai-compatible-chat",
18
+ "openai_compatible": "openai-compatible-chat",
19
+ "openai-compatible-chat": "openai-compatible-chat",
20
+ "openai_compatible_chat": "openai-compatible-chat",
21
+ "chat": "openai-compatible-chat",
22
+ "chat-completions": "openai-compatible-chat",
23
+ "chat_completions": "openai-compatible-chat",
24
+ "openai-responses": "openai-compatible-responses",
25
+ "openai_responses": "openai-compatible-responses",
26
+ "openai-compatible-responses": "openai-compatible-responses",
27
+ "openai_compatible_responses": "openai-compatible-responses",
28
+ "responses": "openai-compatible-responses",
29
+ "gemini": "gemini",
30
+ "google": "gemini",
31
+ "google-gemini": "gemini",
32
+ "google_gemini": "gemini"
33
+ },
34
+ "workspace_access_values": [
35
+ "read-only",
36
+ "readonly",
37
+ "ro",
38
+ "read-write",
39
+ "readwrite",
40
+ "rw"
41
+ ],
42
+ "workspace_draft_values": [
43
+ "shared",
44
+ "copy-only",
45
+ "copy-and-apply",
46
+ "not-allowed"
47
+ ],
48
+ "workspace_os_values": [
49
+ "macos",
50
+ "linux",
51
+ "wsl",
52
+ "windows"
53
+ ],
54
+ "jail_environment_values": [
55
+ "declared",
56
+ "inherit"
57
+ ],
58
+ "titling_modes": [
59
+ "llm",
60
+ "first_sentence",
61
+ "first_words",
62
+ "disabled"
63
+ ]
64
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "block_types": [
3
+ "attachment",
4
+ "code",
5
+ "error",
6
+ "notice",
7
+ "prose",
8
+ "reasoning",
9
+ "speech",
10
+ "tool"
11
+ ],
12
+ "delta_fields": [
13
+ "markdown",
14
+ "text"
15
+ ],
16
+ "event_types": [
17
+ "content.block.completed",
18
+ "content.block.delta",
19
+ "content.block.started",
20
+ "turn.cancelled",
21
+ "turn.completed",
22
+ "turn.failed"
23
+ ],
24
+ "message_statuses": [
25
+ "cancelled",
26
+ "completed",
27
+ "failed",
28
+ "streaming",
29
+ "suspended"
30
+ ],
31
+ "reasoning_visibilities": [
32
+ "private",
33
+ "visible"
34
+ ],
35
+ "roles": [
36
+ "assistant",
37
+ "developer",
38
+ "system",
39
+ "tool",
40
+ "user"
41
+ ],
42
+ "tool_statuses": [
43
+ "cancelled",
44
+ "completed",
45
+ "failed",
46
+ "pending",
47
+ "running"
48
+ ],
49
+ "version": 2
50
+ }