commandagi 0.6.3__tar.gz → 0.6.5__tar.gz

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 (84) hide show
  1. {commandagi-0.6.3 → commandagi-0.6.5}/CHANGELOG.md +74 -0
  2. {commandagi-0.6.3 → commandagi-0.6.5}/PKG-INFO +8 -3
  3. {commandagi-0.6.3 → commandagi-0.6.5}/README.md +7 -2
  4. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/__init__.py +1 -1
  5. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/__init__.py +17 -0
  6. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/fab.py +8 -3
  7. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/flows.py +16 -5
  8. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/part_fields.py +2 -2
  9. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/standards_data.py +1 -1
  10. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/study.py +1 -1
  11. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/threed.py +2 -0
  12. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/threed_elements.py +33 -9
  13. commandagi-0.6.5/commandagi/design/threed_schema.py +4 -0
  14. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_fab.py +7 -0
  15. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_flows.py +6 -2
  16. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_logistics.py +2 -0
  17. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_threed.py +25 -0
  18. commandagi-0.6.3/commandagi/design/threed_schema.py +0 -4
  19. {commandagi-0.6.3 → commandagi-0.6.5}/.gitignore +0 -0
  20. {commandagi-0.6.3 → commandagi-0.6.5}/LICENSE +0 -0
  21. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/_generated.py +0 -0
  22. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/client.py +0 -0
  23. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/agents.py +0 -0
  24. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/business.py +0 -0
  25. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/cad.py +0 -0
  26. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/cadquery.py +0 -0
  27. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/circuit_checks.py +0 -0
  28. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/documents.py +0 -0
  29. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/eda.py +0 -0
  30. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/element.py +0 -0
  31. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/firmware.py +0 -0
  32. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/graph.py +0 -0
  33. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/ir.py +0 -0
  34. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/media.py +0 -0
  35. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/monitors.py +0 -0
  36. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/office.py +0 -0
  37. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/ontology.py +0 -0
  38. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/pcb.py +0 -0
  39. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/pdf.py +0 -0
  40. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/postal.py +0 -0
  41. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/records.py +0 -0
  42. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/schema.py +0 -0
  43. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/schematic.py +0 -0
  44. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/solids.py +0 -0
  45. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/source.py +0 -0
  46. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/standards.py +0 -0
  47. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/systems.py +0 -0
  48. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/tasks.py +0 -0
  49. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/testplans.py +0 -0
  50. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/tolerances.py +0 -0
  51. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/tsx.py +0 -0
  52. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/twod.py +0 -0
  53. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/twod_schema.py +0 -0
  54. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/design/workbook_schema.py +0 -0
  55. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/gym_env.py +0 -0
  56. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/kernel.py +0 -0
  57. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi/lerobot.py +0 -0
  58. {commandagi-0.6.3 → commandagi-0.6.5}/commandagi-sdk.schema.json +0 -0
  59. {commandagi-0.6.3 → commandagi-0.6.5}/examples/drive_a_sim.py +0 -0
  60. {commandagi-0.6.3 → commandagi-0.6.5}/pyproject.toml +0 -0
  61. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_agents.py +0 -0
  62. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_business.py +0 -0
  63. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_design.py +0 -0
  64. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_kernel.py +0 -0
  65. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_media.py +0 -0
  66. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_monitors.py +0 -0
  67. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_office.py +0 -0
  68. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_ontology.py +0 -0
  69. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_pcb.py +0 -0
  70. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_pdf.py +0 -0
  71. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_postal.py +0 -0
  72. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_records.py +0 -0
  73. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_schematic.py +0 -0
  74. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_sdk.py +0 -0
  75. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_source.py +0 -0
  76. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_standards.py +0 -0
  77. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_study.py +0 -0
  78. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_systems.py +0 -0
  79. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_tasks.py +0 -0
  80. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_testplans.py +0 -0
  81. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_tolerances.py +0 -0
  82. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_tsx.py +0 -0
  83. {commandagi-0.6.3 → commandagi-0.6.5}/tests/test_twod.py +0 -0
  84. {commandagi-0.6.3 → commandagi-0.6.5}/uv.lock +0 -0
@@ -4,6 +4,80 @@ One entry for each release. A release is the tag `v<version>` in this repository
4
4
  TypeScript and Rust SDKs carry the same version number. A version promises nothing about the next one (README
5
5
  § Versions): read this file before you change the version you pin.
6
6
 
7
+ ## 0.6.5 (2026-10-22)
8
+
9
+ The items still open after 0.6.4 (the microfab team's ids in brackets). `@commandagi/host` 0.6.5 carries the checks.
10
+
11
+ Changed (a document written for 0.6.4 may need an edit)
12
+
13
+ - A `<fastener at>` is a point on the screw's axis, on or above the first clamped part: the rebuild seats the stack on
14
+ the face its washer or head bears on (a counterbore's floor, a top face, a countersink), and builds every piece
15
+ there; `grip` is measured from the seat. A stack that finds no seat stays at `at`, and `head-not-seated` says why
16
+ (PCBC-06).
17
+
18
+ Added
19
+
20
+ - Board fills read KiCad's thermal spoke angle (45° for a round pad, 90° otherwise), relieve heatsink vias as KiCad
21
+ does, and hold a spoke to the pad's width and the zone's least width: the team's axis node now has KiCad's 5 GND
22
+ pieces (EDA-27).
23
+ - `<group near maxDistance>` is a hard rule of the placer; a wide net necks to its class's `minWidth` only where full
24
+ width does not fit, and `pcb_layout` names each neck. The axis node lays out complete: KiCad 0 errors, 0
25
+ unconnected, 0 parity (EDA-20).
26
+ - A planar face of many edges is triangulated by the kernel itself: the 1136-hole breadboard's mesh in 2.5 s, not 30 s,
27
+ the same mesh (CORE-23).
28
+ - A syntax error in plain code names `file:line:col` and its token in every runner (the command line, the platform, the
29
+ page; Python too).
30
+ - The T-slot profiles are drawn as the catalog draws them: each section's area, moments and mass within 5 % of MISUMI's
31
+ (the table also gains `cavity_floor_width`, and HFS6-3030 its corner holes).
32
+
33
+ ## 0.6.4 (2026-10-22)
34
+
35
+ The fixes for the microfab team's re-test on 0.6.3 (66 open items; the ids in brackets are theirs). The vocabulary below
36
+ is the same in the three SDKs, in each language's spelling; `@commandagi/host` 0.6.4 carries the checks.
37
+
38
+ Changed (a document written for 0.6.3 may need an edit)
39
+
40
+ - A placed assembly keeps its own `<permitted>`, `<library>`, `<accept>` (`body` and `other`) and names under the
41
+ placement: a dock that passes alone passes where it is placed. A placement's id selects its members in `bodies`,
42
+ `against` and `pair` (`dock`, `dock/MF-SH-VEE-20`) (CORE-51, CORE-52, CORE-54). A placed file of several parts keeps
43
+ each as `<placement>/<id>`.
44
+ - Every file resolves its imports from its own folder, in every command; the folder a run reads is `--folder`, else the
45
+ file's git repository (CORE-48, CORE-50). A `<part>` or `<assembly>` inside another document says to place its file.
46
+ - `commandagi diff` prints its lines; `--json` or `--out FILE` gives the JSON (CORE-45).
47
+ - An accept of a check that ran and covers nothing warns (`accept-unused`); a whole-part finding (`mill.material`) has
48
+ no place, so a body + rule accept covers it (CORE-47). `--only` leaves out the other checks' accepts (IC2-18).
49
+ - One finding per hole, cup or region, each with its own size (CORE-46). A washer is what bears on a clamped part
50
+ (IC2-14).
51
+ - A bill line of fastener pieces is named by its designation, a roll-up line by its part number (CORE-29).
52
+ - `route` says `complete: false` while a net has islands, pours counted (EDA-23); `route`/`layout` `--out` names the
53
+ board written, the input is left (EDA-22); copper too near the edge is an error (EDA-25); a part with no sheet
54
+ position is in ERC (EDA-21).
55
+
56
+ Added
57
+
58
+ - `<check sweep={{ joint, samples | step }}>`: interference and clearance over a joint's limits, each finding at its
59
+ joint value with where it starts and ends (PCBC-14); `<accept maxVolume>` (PCBC-18).
60
+ - `<externalPart omit moves>`: one placed file with parts left out or moved; a frame placed in every station (IC1-19,
61
+ IC1-14, PCBC-20).
62
+ - `engineering.envelope` and `mountingHoles` for a bought part drawn as its envelope (IC2-13); `<library sizes>`, one
63
+ table of sizes, part numbers and prices (CORE-29); a library screw's mass (CORE-44).
64
+ - STEP files hold one product per part used N times, nested sub-assemblies, and the library's part numbers (CORE-20,
65
+ CORE-53, IC2-19); `threed observe` names bodies as the checks do (CORE-39).
66
+ - `<slice device>`: a resin setup names its printer (CORE-42). A through hole is drilled from both declared setups
67
+ (CORE-40). A run of primitive cuts is one boolean: 473 cut cylinders check in 2.7 s, not 21 s (IC2-15).
68
+ - Studies: results are streamed (a 2.18M-node study, 1.2 GB of results, runs to its verdict: CORE-55); a container
69
+ ends with its host; stress beside a converging re-entrant edge is read (CORE-56); `spring` and `pin` supports
70
+ (IC1-15); `--keep field` (PCBC-19); `study check` refuses what `study run` refuses (CORE-41).
71
+ - `COMMANDAGI_THREED=cloud` on the command line, and every report says where its kernel ran (CORE-43, IC1-18,
72
+ IC2-16). Times per check and per feature (IC1-09, PCBC-15). A long hole table continues on further sheets
73
+ (IC1-17); a misplaced view is named (IC2-17). A wrong bracket is reported at its token (IC1-16).
74
+ - `diff`, `release status --diff` and a task's check read flows, systems, requirements and interfaces (LABS-21); a
75
+ release checks its flows (LABS-22); `make.ratePerHourHigh` (LABS-23); `<visit tool minutes>` in a flow step
76
+ (LABS-24); `commandagi task propose | approve | decline` offline (LABS-13); `live-miss` (LABS-14); `"unknown"` for
77
+ HS code, origin, hazmat, ECCN and datasheet (PCBC-16).
78
+ - Boards: pours read KiCad's own fill settings (EDA-27, in part); plane vias from the router (EDA-23); `pins
79
+ --install-hook` (EDA-26); RXD0/TXD0 GPIO numbers (EDA-12); `.3d.py` relative imports (PCBC-17).
80
+
7
81
  ## 0.6.3 (2026-10-21)
8
82
 
9
83
  The fixes for the microfab team's report on 0.6.2 (110 issues; the ids in brackets are theirs). The vocabulary below
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: commandagi
3
- Version: 0.6.3
3
+ Version: 0.6.5
4
4
  Summary: The CommandAGI SDK for Python — agent threads, memory and integrations, and live computers, robots and simulated worlds you watch and control.
5
5
  Project-URL: Homepage, https://commandagi.com
6
6
  Project-URL: Documentation, https://github.com/CommandAGI/commandagi-sdk-python/blob/main/README.md
@@ -33,7 +33,7 @@ Drive the whole CommandAGI platform as code: agent threads, memory and integrati
33
33
 
34
34
  ```bash
35
35
  pip install commandagi
36
- # or, in an environment uv manages: uv pip install commandagi (in a uv project: uv add commandagi)
36
+ # a virtual environment uv made has no pip: uv pip install --python .venv/bin/python commandagi (a uv project: uv add commandagi)
37
37
  export COMMANDAGI_API_KEY=cagi_... # Settings → API keys
38
38
  ```
39
39
 
@@ -280,7 +280,12 @@ graph (`run_module(...)["graph"]`) or the graph's JSON text. An entity is `{"bod
280
280
  ## Versions
281
281
 
282
282
  - A release is the tag `v<version>` in this repository and the same version on PyPI. Pin an exact version:
283
- `commandagi==0.6.3`. A range (`^`, `~=`, `>=`) takes the next release without asking you.
283
+ `pip install commandagi==0.6.5`, or in a virtual environment uv made (it has no pip)
284
+ `uv pip install --python .venv/bin/python commandagi==0.6.5`. A range (`^`, `~=`, `>=`) takes the next release
285
+ without asking you.
286
+ - After an upgrade, check what runs: `python -c "import commandagi; print(commandagi.__version__)"`, and
287
+ `commandagi --version` for the host that runs the local 3D kernel (`npm install -g @commandagi/host@0.6.5`). The two
288
+ are upgraded apart, and a kernel of another version may read a document differently.
284
289
  - The three SDKs (Python, TypeScript, Rust) carry one version number. A vocabulary at version X in one language is
285
290
  the vocabulary at version X in the others.
286
291
  - A version promises nothing about the next one. CommandAGI keeps no compatibility layers: a release may rename or
@@ -5,7 +5,7 @@ Drive the whole CommandAGI platform as code: agent threads, memory and integrati
5
5
 
6
6
  ```bash
7
7
  pip install commandagi
8
- # or, in an environment uv manages: uv pip install commandagi (in a uv project: uv add commandagi)
8
+ # a virtual environment uv made has no pip: uv pip install --python .venv/bin/python commandagi (a uv project: uv add commandagi)
9
9
  export COMMANDAGI_API_KEY=cagi_... # Settings → API keys
10
10
  ```
11
11
 
@@ -252,7 +252,12 @@ graph (`run_module(...)["graph"]`) or the graph's JSON text. An entity is `{"bod
252
252
  ## Versions
253
253
 
254
254
  - A release is the tag `v<version>` in this repository and the same version on PyPI. Pin an exact version:
255
- `commandagi==0.6.3`. A range (`^`, `~=`, `>=`) takes the next release without asking you.
255
+ `pip install commandagi==0.6.5`, or in a virtual environment uv made (it has no pip)
256
+ `uv pip install --python .venv/bin/python commandagi==0.6.5`. A range (`^`, `~=`, `>=`) takes the next release
257
+ without asking you.
258
+ - After an upgrade, check what runs: `python -c "import commandagi; print(commandagi.__version__)"`, and
259
+ `commandagi --version` for the host that runs the local 3D kernel (`npm install -g @commandagi/host@0.6.5`). The two
260
+ are upgraded apart, and a kernel of another version may read a document differently.
256
261
  - The three SDKs (Python, TypeScript, Rust) carry one version number. A vocabulary at version X in one language is
257
262
  the vocabulary at version X in the others.
258
263
  - A version promises nothing about the next one. CommandAGI keeps no compatibility layers: a release may rename or
@@ -60,4 +60,4 @@ __all__ = [
60
60
  "ENV_THREAD_ID",
61
61
  "DEFAULT_BASE_URL",
62
62
  ]
63
- __version__ = "0.6.3"
63
+ __version__ = "0.6.5"
@@ -16,7 +16,10 @@ document. Each element carries the call that made it, and each node or record it
16
16
  from __future__ import annotations
17
17
 
18
18
  import json
19
+ import os
19
20
  import re
21
+ import sys
22
+ import types
20
23
  from typing import Any, Dict, List, Optional
21
24
 
22
25
  from .ir import Declaration, NodeRef, Out, Scope, channels, check_ir, is_ir_graph
@@ -64,6 +67,10 @@ def _stem(path: str) -> str:
64
67
  "", name, flags=re.IGNORECASE) or "Part"
65
68
 
66
69
 
70
+ #: The package a code file's own folder is while it runs (its relative imports read that folder).
71
+ _FOLDER_PACKAGE = "__code_folder__"
72
+
73
+
67
74
  def run_module(source: str, path: str, inputs: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
68
75
  """Run a code part's source with these inputs; return ``{"graph", "params"}`` (JSON-ready)."""
69
76
  inputs = dict(inputs or {})
@@ -78,6 +85,16 @@ def run_module(source: str, path: str, inputs: Optional[Dict[str, Any]] = None)
78
85
  shown.append(obj)
79
86
 
80
87
  ns: Dict[str, Any] = {"__name__": "__code_part__", "__file__": path, "param": param, "show_object": show_object, "inputs": inputs}
88
+ # The file's folder is its package, so a relative import (`from .helper import x`) reads the module beside it, as
89
+ # `from helper import x` does.
90
+ folder = os.path.dirname(path)
91
+ if folder:
92
+ for name in [m for m in sys.modules if m.startswith(f"{_FOLDER_PACKAGE}.")]:
93
+ del sys.modules[name]
94
+ package = types.ModuleType(_FOLDER_PACKAGE)
95
+ package.__path__ = [folder]
96
+ sys.modules[_FOLDER_PACKAGE] = package
97
+ ns["__package__"] = _FOLDER_PACKAGE
81
98
  with _source.running(source, path) as run:
82
99
  exec(compile(source, path, "exec"), ns)
83
100
  declared = ns.get("params")
@@ -17,6 +17,9 @@ the 3D app's CAM and slicing modes edit: the same elements as the TypeScript SDK
17
17
  result = slice(source(file_id="carrier.stl", name="carrier.stl"), spool(material_id="pla", diameter_mm=1.75),
18
18
  profile="fdm_pla_0.20_draft")
19
19
 
20
+ A slicing setup that runs on no unit names its printer by its device definition: ``slice(…, profile=…, device=…)`` (a
21
+ ref to a ``definition.tsx`` that declares ``process.print``). With a ``machine`` too, the unit's device is that definition.
22
+
20
23
  The rule of the ontology's files: a record is an element and its fields are its attributes (keywords in snake_case
21
24
  of the native names: ``thickness_mm`` is ``thicknessMm``; millimetres). A setup's single records (``source``,
22
25
  ``design``, ``stock``, ``part``, ``machine``, ``runsOn``, ``spool``) are one element each, absent when the native field
@@ -42,6 +45,8 @@ CAM_OPERATION_FIELDS = ["id", "op", "profile", "enabled", "params", "tabs", "reg
42
45
  #: A unit's channel a job runs on (``runsOn`` of a machining setup, ``machine`` of a slicing setup).
43
46
  TARGET_FIELDS = ["unit", "channel", "name"]
44
47
  SPOOL_FIELDS = ["materialId", "diameterMm"]
48
+ #: A slicing setup's own fields: its profile, its overrides, and the printer's definition (``device``).
49
+ SLICE_FIELDS = ["profile", "params", "device"]
45
50
 
46
51
  _HOLDS: Dict[str, Any] = {"holds": "children"}
47
52
  #: Every tag of the machine jobs: what it holds (the TypeScript SDK's ``SIGNATURES``). ``machine``, ``source`` and
@@ -52,7 +57,7 @@ SIGNATURES: Dict[str, Dict[str, Any]] = {
52
57
  }
53
58
 
54
59
  __all__ = ["CAM_REF_FIELDS", "CAM_STOCK_FIELDS", "CAM_PART_FIELDS", "CAM_MACHINE_FIELDS", "CAM_FIXTURE_FIELDS",
55
- "CAM_OPERATION_FIELDS", "TARGET_FIELDS", "SPOOL_FIELDS", "SIGNATURES", "cam_vocabulary", "slice_vocabulary", "FAB",
60
+ "CAM_OPERATION_FIELDS", "TARGET_FIELDS", "SPOOL_FIELDS", "SLICE_FIELDS", "SIGNATURES", "cam_vocabulary", "slice_vocabulary", "FAB",
56
61
  *define(globals(), "fab", SIGNATURES)]
57
62
 
58
63
 
@@ -133,7 +138,7 @@ def _slice_from_tree(t: Dict[str, Any]) -> Dict[str, Any]:
133
138
 
134
139
 
135
140
  def _slice_to_tree(d: Dict[str, Any]) -> Dict[str, Any]:
136
- return {"tag": "slice", "attrs": _attrs_of(d, ["profile", "params"]), "children": [
141
+ return {"tag": "slice", "attrs": _attrs_of(d, SLICE_FIELDS), "children": [
137
142
  *_one("source", d.get("source"), CAM_REF_FIELDS), *_one("design", d.get("design"), CAM_REF_FIELDS),
138
143
  *_one("spool", d.get("spool"), SPOOL_FIELDS), *_one("machine", d.get("machine"), TARGET_FIELDS)]}
139
144
 
@@ -141,7 +146,7 @@ def _slice_to_tree(d: Dict[str, Any]) -> Dict[str, Any]:
141
146
  slice_vocabulary = Vocabulary(
142
147
  format="slice", noun="a slicing setup", root="slice",
143
148
  tags={
144
- "slice": {"parents": [], "required": ["profile"], "attrs": ["profile", "params"]},
149
+ "slice": {"parents": [], "required": ["profile"], "attrs": SLICE_FIELDS},
145
150
  "source": {"parents": ["slice"], "single": True, **_REF},
146
151
  "design": {"parents": ["slice"], "single": True, **_REF},
147
152
  "spool": {"parents": ["slice"], "single": True, "attrs": SPOOL_FIELDS},
@@ -2,7 +2,7 @@
2
2
  visits, its recipe parameters with their units, its time and who does it, and the measurements taken in the process,
3
3
  the same document and the same elements as the TypeScript SDK's JSX (``commandagi/design`` ``flows.ts``)::
4
4
 
5
- from commandagi.design.flows import flow, tool, step, param, measure
5
+ from commandagi.design.flows import flow, tool, step, param, measure, visit
6
6
 
7
7
  result = flow(
8
8
  tool(id="coater", ref="stage1.bom.3d.py#coater", rate_per_hour=40, currency="USD"),
@@ -10,13 +10,15 @@ the same document and the same elements as the TypeScript SDK's JSX (``commandag
10
10
  step(
11
11
  param(name="speed", value=3000, unit="rpm"),
12
12
  measure(id="resist", name="resist thickness", nominal=1.2, plus=0.1, minus=0.1, unit="um"),
13
+ visit(tool="oven", minutes=2, instruction="soft bake"),
13
14
  id="coat", order=1, tool="coater", by="in-house", minutes=6,
14
15
  ),
15
16
  name="Alignment marks", of="stage1.bom.3d.py#wafer",
16
17
  )
17
18
 
18
19
  A record is an element and its fields are the element's attributes (snake_case keywords: ``rate_per_hour`` is
19
- ``ratePerHour``). Nothing adds a default. The check is the host's (``commandagi check <file>.flow.py``).
20
+ ``ratePerHour``). A step that goes to more tools than its own names each in a ``visit(tool=…, minutes=…)``. Nothing
21
+ adds a default. The check is the host's (``commandagi check <file>.flow.py``).
20
22
  """
21
23
  from __future__ import annotations
22
24
 
@@ -35,10 +37,11 @@ FLOW_STEP_FIELDS = ["id", "order", "kind", "tool", "fixture", "by", "minutes", "
35
37
  "note"]
36
38
  FLOW_PARAM_FIELDS = ["name", "value", "unit", "description"]
37
39
  FLOW_MEASURE_FIELDS = ["id", "name", "nominal", "min", "max", "plus", "minus", "unit", "method", "sampling", "acceptance"]
40
+ FLOW_VISIT_FIELDS = ["tool", "minutes", "setupMinutes", "ratePerHour", "currency", "instruction"]
38
41
 
39
42
  _CHILDREN = {"holds": "children"}
40
43
  #: Every tag and what it holds (the TypeScript SDK's ``SIGNATURES``).
41
- SIGNATURES: Dict[str, Dict[str, Any]] = {"flow": _CHILDREN, "tool": {}, "step": _CHILDREN, "param": {}, "measure": {}}
44
+ SIGNATURES: Dict[str, Dict[str, Any]] = {"flow": _CHILDREN, "tool": {}, "step": _CHILDREN, "param": {}, "measure": {}, "visit": {}}
42
45
 
43
46
  __all__ = ["FLOW_STEP_KINDS", "SIGNATURES", "FLOW_VOCABULARY", *define(globals(), "flows", SIGNATURES)]
44
47
 
@@ -85,7 +88,7 @@ def _step(t: DocTree) -> None:
85
88
  _money(a, at)
86
89
  if a.get("kind") == "note":
87
90
  _check("tool" not in a and a.get("minutes", 0) == 0 and not t["children"],
88
- f"{at}: a note step names no tool, takes no time (minutes 0 or absent) and holds no param or measure")
91
+ f"{at}: a note step names no tool, takes no time (minutes 0 or absent) and holds no param, measure or visit")
89
92
  names = [c["attrs"].get("name") for c in t["children"] if c["tag"] == "param"]
90
93
  twice = next((n for i, n in enumerate(names) if n in names[:i]), None)
91
94
  _check(twice is None, f"{at}: two params are named {json.dumps(twice, ensure_ascii=False)}")
@@ -97,6 +100,12 @@ def _step(t: DocTree) -> None:
97
100
  v = b.get("value")
98
101
  _check(_num(v) or isinstance(v, (str, bool)), f"{pat}: value is a number, a text or true/false")
99
102
  _check("unit" not in b or (isinstance(b["unit"], str) and b["unit"].strip()), f"{pat}: unit is a unit's symbol (rpm, sccm, mTorr, °C, s)")
103
+ elif c["tag"] == "visit":
104
+ vat = f'{at} {_where("visit", "tool", b)}'
105
+ _check(isinstance(b.get("tool"), str) and _ID.fullmatch(b["tool"]), f"{vat}: tool is the id of one of the flow's tools")
106
+ for k in ("minutes", "setupMinutes"):
107
+ _check(k not in b or (_num(b[k]) and b[k] >= 0), f"{vat}: {k} is a number of at least 0")
108
+ _money(b, vat)
100
109
  else:
101
110
  mat = _where("measure", "id", b)
102
111
  _check(isinstance(b.get("id"), str) and _ID.fullmatch(b["id"]), f'{mat}: id is letters, digits, ".", "_" and "-"')
@@ -111,7 +120,8 @@ def _step(t: DocTree) -> None:
111
120
  def _step_record(t: DocTree) -> Dict[str, Any]:
112
121
  params = [dict(c["attrs"]) for c in t["children"] if c["tag"] == "param"]
113
122
  measures = [dict(c["attrs"]) for c in t["children"] if c["tag"] == "measure"]
114
- return {**t["attrs"], **({"params": params} if params else {}), **({"measures": measures} if measures else {})}
123
+ visits = [dict(c["attrs"]) for c in t["children"] if c["tag"] == "visit"]
124
+ return {**t["attrs"], **({"params": params} if params else {}), **({"measures": measures} if measures else {}), **({"visits": visits} if visits else {})}
115
125
 
116
126
 
117
127
  def _flow(t: DocTree) -> Dict[str, Any]:
@@ -138,6 +148,7 @@ FLOW_VOCABULARY = Vocabulary("flow", "a process flow", "flow", {
138
148
  "step": {"parents": ["flow"], "key": "id", "required": ["id"], "attrs": FLOW_STEP_FIELDS},
139
149
  "param": {"parents": ["step"], "required": ["name", "value"], "attrs": FLOW_PARAM_FIELDS},
140
150
  "measure": {"parents": ["step"], "key": "id", "required": ["id"], "attrs": FLOW_MEASURE_FIELDS},
151
+ "visit": {"parents": ["step"], "required": ["tool"], "attrs": FLOW_VISIT_FIELDS},
141
152
  }, _flow, _never, lambda name: {"name": name})
142
153
 
143
154
  register_vocabulary(FLOW_VOCABULARY, "flows")
@@ -246,8 +246,8 @@ def check_facet(where: str, arg: str, v: Any) -> Dict[str, Any]:
246
246
  raise ValueError(f'{where}: {key} is one of {", ".join(_CHOICES[key])} (got "{x}")')
247
247
  if key in _DATES and not _DAY.match(x):
248
248
  raise ValueError(f"{where}: {key} is YYYY-MM-DD")
249
- if key == "shipping.origin" and not re.match(r"^[A-Z]{2}$", x):
250
- raise ValueError(f'{where}: {key} is an ISO 3166 alpha-2 code ("CN")')
249
+ if key == "shipping.origin" and not re.match(r"^(?:[A-Z]{2}|unknown)$", x):
250
+ raise ValueError(f'{where}: {key} is an ISO 3166 alpha-2 code ("CN"), or "unknown"')
251
251
  return {k: copy.deepcopy(x) for k, x in v.items() if x is not None}
252
252
 
253
253